Frameworks/libpurple.framework/Versions/0.6.2/Headers/roomlist.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 1739 Frameworks/libpurple.framework/Versions/0.6.0/Headers/roomlist.h@8b0daad9656c
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
Evan@653
     1
/**
Evan@653
     2
 * @file roomlist.h Room List API
Evan@653
     3
 * @ingroup core
Evan@653
     4
 */
Evan@653
     5
Evan@653
     6
/* purple
Evan@653
     7
 *
Evan@653
     8
 * Purple is the legal property of its developers, whose names are too numerous
Evan@653
     9
 * to list here.  Please refer to the COPYRIGHT file distributed with this
Evan@653
    10
 * source distribution.
Evan@653
    11
 *
Evan@653
    12
 * This program is free software; you can redistribute it and/or modify
Evan@653
    13
 * it under the terms of the GNU General Public License as published by
Evan@653
    14
 * the Free Software Foundation; either version 2 of the License, or
Evan@653
    15
 * (at your option) any later version.
Evan@653
    16
 *
Evan@653
    17
 * This program is distributed in the hope that it will be useful,
Evan@653
    18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Evan@653
    19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Evan@653
    20
 * GNU General Public License for more details.
Evan@653
    21
 *
Evan@653
    22
 * You should have received a copy of the GNU General Public License
Evan@653
    23
 * along with this program; if not, write to the Free Software
Evan@653
    24
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
Evan@653
    25
 */
Evan@653
    26
Evan@653
    27
#ifndef _PURPLE_ROOMLIST_H_
Evan@653
    28
#define _PURPLE_ROOMLIST_H_
Evan@653
    29
Evan@653
    30
typedef struct _PurpleRoomlist PurpleRoomlist;
Evan@653
    31
typedef struct _PurpleRoomlistRoom PurpleRoomlistRoom;
Evan@653
    32
typedef struct _PurpleRoomlistField PurpleRoomlistField;
Evan@653
    33
/** @copydoc _PurpleRoomlistUiOps */
Evan@653
    34
typedef struct _PurpleRoomlistUiOps PurpleRoomlistUiOps;
Evan@653
    35
Evan@653
    36
/**
Evan@653
    37
 * The types of rooms.
Evan@653
    38
 *
Evan@653
    39
 * These are ORable flags.
Evan@653
    40
 */
Evan@653
    41
typedef enum
Evan@653
    42
{
Evan@653
    43
	PURPLE_ROOMLIST_ROOMTYPE_CATEGORY = 0x01, /**< It's a category, but not a room you can join. */
Evan@653
    44
	PURPLE_ROOMLIST_ROOMTYPE_ROOM = 0x02      /**< It's a room, like the kind you can join. */
Evan@653
    45
Evan@653
    46
} PurpleRoomlistRoomType;
Evan@653
    47
Evan@653
    48
/**
Evan@653
    49
 * The types of fields.
Evan@653
    50
 */
Evan@653
    51
typedef enum
Evan@653
    52
{
Evan@653
    53
	PURPLE_ROOMLIST_FIELD_BOOL,
Evan@653
    54
	PURPLE_ROOMLIST_FIELD_INT,
Evan@653
    55
	PURPLE_ROOMLIST_FIELD_STRING /**< We do a g_strdup on the passed value if it's this type. */
Evan@653
    56
Evan@653
    57
} PurpleRoomlistFieldType;
Evan@653
    58
Evan@653
    59
#include "account.h"
Evan@653
    60
#include "glib.h"
Evan@653
    61
Evan@653
    62
/**************************************************************************/
Evan@653
    63
/** Data Structures                                                       */
Evan@653
    64
/**************************************************************************/
Evan@653
    65
Evan@653
    66
/**
Evan@653
    67
 * Represents a list of rooms for a given connection on a given protocol.
Evan@653
    68
 */
Evan@653
    69
struct _PurpleRoomlist {
Evan@653
    70
	PurpleAccount *account; /**< The account this list belongs to. */
Evan@653
    71
	GList *fields; /**< The fields. */
Evan@653
    72
	GList *rooms; /**< The list of rooms. */
Evan@653
    73
	gboolean in_progress; /**< The listing is in progress. */
Evan@653
    74
	gpointer ui_data; /**< UI private data. */
Evan@653
    75
	gpointer proto_data; /** Prpl private data. */
Evan@653
    76
	guint ref; /**< The reference count. */
Evan@653
    77
};
Evan@653
    78
Evan@653
    79
/**
Evan@653
    80
 * Represents a room.
Evan@653
    81
 */
Evan@653
    82
struct _PurpleRoomlistRoom {
Evan@653
    83
	PurpleRoomlistRoomType type; /**< The type of room. */
Evan@653
    84
	gchar *name; /**< The name of the room. */
Evan@653
    85
	GList *fields; /**< Other fields. */
Evan@653
    86
	PurpleRoomlistRoom *parent; /**< The parent room, or NULL. */
Evan@653
    87
	gboolean expanded_once; /**< A flag the UI uses to avoid multiple expand prpl cbs. */
Evan@653
    88
};
Evan@653
    89
Evan@653
    90
/**
Evan@653
    91
 * A field a room might have.
Evan@653
    92
 */
Evan@653
    93
struct _PurpleRoomlistField {
Evan@653
    94
	PurpleRoomlistFieldType type; /**< The type of field. */
Evan@653
    95
	gchar *label; /**< The i18n user displayed name of the field. */
Evan@653
    96
	gchar *name; /**< The internal name of the field. */
Evan@653
    97
	gboolean hidden; /**< Hidden? */
Evan@653
    98
};
Evan@653
    99
Evan@653
   100
/**
Evan@653
   101
 * The room list ops to be filled out by the UI.
Evan@653
   102
 */
Evan@653
   103
struct _PurpleRoomlistUiOps {
Evan@653
   104
	void (*show_with_account)(PurpleAccount *account); /**< Force the ui to pop up a dialog and get the list */
Evan@653
   105
	void (*create)(PurpleRoomlist *list); /**< A new list was created. */
Evan@653
   106
	void (*set_fields)(PurpleRoomlist *list, GList *fields); /**< Sets the columns. */
Evan@653
   107
	void (*add_room)(PurpleRoomlist *list, PurpleRoomlistRoom *room); /**< Add a room to the list. */
Evan@653
   108
	void (*in_progress)(PurpleRoomlist *list, gboolean flag); /**< Are we fetching stuff still? */
Evan@653
   109
	void (*destroy)(PurpleRoomlist *list); /**< We're destroying list. */
Evan@653
   110
Evan@653
   111
	void (*_purple_reserved1)(void);
Evan@653
   112
	void (*_purple_reserved2)(void);
Evan@653
   113
	void (*_purple_reserved3)(void);
Evan@653
   114
	void (*_purple_reserved4)(void);
Evan@653
   115
};
Evan@653
   116
Evan@653
   117
Evan@653
   118
#ifdef __cplusplus
Evan@653
   119
extern "C" {
Evan@653
   120
#endif
Evan@653
   121
Evan@653
   122
/**************************************************************************/
Evan@653
   123
/** @name Room List API                                                   */
Evan@653
   124
/**************************************************************************/
Evan@653
   125
/*@{*/
Evan@653
   126
Evan@653
   127
/**
Evan@653
   128
 * This is used to get the room list on an account, asking the UI
Evan@653
   129
 * to pop up a dialog with the specified account already selected,
Evan@653
   130
 * and pretend the user clicked the get list button.
Evan@653
   131
 * While we're pretending, predend I didn't say anything about dialogs
Evan@653
   132
 * or buttons, since this is the core.
Evan@653
   133
 *
Evan@653
   134
 * @param account The account to get the list on.
Evan@653
   135
 */
Evan@653
   136
void purple_roomlist_show_with_account(PurpleAccount *account);
Evan@653
   137
Evan@653
   138
/**
Evan@653
   139
 * Returns a newly created room list object.
Evan@653
   140
 *
Evan@653
   141
 * It has an initial reference count of 1.
Evan@653
   142
 *
Evan@653
   143
 * @param account The account that's listing rooms.
Evan@653
   144
 * @return The new room list handle.
Evan@653
   145
 */
Evan@653
   146
PurpleRoomlist *purple_roomlist_new(PurpleAccount *account);
Evan@653
   147
Evan@653
   148
/**
Evan@653
   149
 * Increases the reference count on the room list.
Evan@653
   150
 *
Evan@653
   151
 * @param list The object to ref.
Evan@653
   152
 */
Evan@653
   153
void purple_roomlist_ref(PurpleRoomlist *list);
Evan@653
   154
Evan@653
   155
/**
Evan@653
   156
 * Decreases the reference count on the room list.
Evan@653
   157
 *
Evan@653
   158
 * The room list will be destroyed when this reaches 0.
Evan@653
   159
 *
Evan@653
   160
 * @param list The room list object to unref and possibly
Evan@653
   161
 *             destroy.
Evan@653
   162
 */
Evan@653
   163
void purple_roomlist_unref(PurpleRoomlist *list);
Evan@653
   164
Evan@653
   165
/**
Evan@653
   166
 * Set the different field types and their names for this protocol.
Evan@653
   167
 *
Evan@653
   168
 * This must be called before purple_roomlist_room_add().
Evan@653
   169
 *
Evan@653
   170
 * @param list The room list.
Evan@653
   171
 * @param fields A GList of PurpleRoomlistField's. UI's are encouraged
Evan@653
   172
 *               to default to displaying them in the order given.
Evan@653
   173
 */
Evan@653
   174
void purple_roomlist_set_fields(PurpleRoomlist *list, GList *fields);
Evan@653
   175
Evan@653
   176
/**
Evan@653
   177
 * Set the "in progress" state of the room list.
Evan@653
   178
 *
Evan@653
   179
 * The UI is encouraged to somehow hint to the user
Evan@653
   180
 * whether or not we're busy downloading a room list or not.
Evan@653
   181
 *
Evan@653
   182
 * @param list The room list.
Evan@653
   183
 * @param in_progress We're downloading it, or we're not.
Evan@653
   184
 */
Evan@653
   185
void purple_roomlist_set_in_progress(PurpleRoomlist *list, gboolean in_progress);
Evan@653
   186
Evan@653
   187
/**
Evan@653
   188
 * Gets the "in progress" state of the room list.
Evan@653
   189
 *
Evan@653
   190
 * The UI is encouraged to somehow hint to the user
Evan@653
   191
 * whether or not we're busy downloading a room list or not.
Evan@653
   192
 *
Evan@653
   193
 * @param list The room list.
Evan@653
   194
 * @return True if we're downloading it, or false if we're not.
Evan@653
   195
 */
Evan@653
   196
gboolean purple_roomlist_get_in_progress(PurpleRoomlist *list);
Evan@653
   197
Evan@653
   198
/**
Evan@653
   199
 * Adds a room to the list of them.
Evan@653
   200
 *
Evan@653
   201
 * @param list The room list.
Evan@653
   202
 * @param room The room to add to the list. The GList of fields must be in the same
Evan@653
   203
               order as was given in purple_roomlist_set_fields().
Evan@653
   204
*/
Evan@653
   205
void purple_roomlist_room_add(PurpleRoomlist *list, PurpleRoomlistRoom *room);
Evan@653
   206
Evan@653
   207
/**
Evan@653
   208
 * Returns a PurpleRoomlist structure from the prpl, and
Evan@653
   209
 * instructs the prpl to start fetching the list.
Evan@653
   210
 *
Evan@653
   211
 * @param gc The PurpleConnection to have get a list.
Evan@653
   212
 *
Evan@653
   213
 * @return A PurpleRoomlist* or @c NULL if the protocol
Evan@653
   214
 *         doesn't support that.
Evan@653
   215
 */
Evan@653
   216
PurpleRoomlist *purple_roomlist_get_list(PurpleConnection *gc);
Evan@653
   217
Evan@653
   218
/**
Evan@653
   219
 * Tells the prpl to stop fetching the list.
Evan@653
   220
 * If this is possible and done, the prpl will
Evan@653
   221
 * call set_in_progress with @c FALSE and possibly
Evan@653
   222
 * unref the list if it took a reference.
Evan@653
   223
 *
Evan@653
   224
 * @param list The room list to cancel a get_list on.
Evan@653
   225
 */
Evan@653
   226
void purple_roomlist_cancel_get_list(PurpleRoomlist *list);
Evan@653
   227
Evan@653
   228
/**
Evan@653
   229
 * Tells the prpl that a category was expanded.
Evan@653
   230
 *
Evan@653
   231
 * On some protocols, the rooms in the category
Evan@653
   232
 * won't be fetched until this is called.
Evan@653
   233
 *
Evan@653
   234
 * @param list     The room list.
Evan@653
   235
 * @param category The category that was expanded. The expression
Evan@653
   236
 *                 (category->type & PURPLE_ROOMLIST_ROOMTYPE_CATEGORY)
Evan@653
   237
 *                 must be true.
Evan@653
   238
 */
Evan@653
   239
void purple_roomlist_expand_category(PurpleRoomlist *list, PurpleRoomlistRoom *category);
Evan@653
   240
Evan@653
   241
/**
Evan@653
   242
 * Get the list of fields for a roomlist.
Evan@653
   243
 *
Evan@653
   244
 * @param roomlist  The roomlist, which must not be @c NULL.
Evan@653
   245
 * @constreturn A list of fields
Evan@653
   246
 * @since 2.4.0
Evan@653
   247
 */
Evan@653
   248
GList * purple_roomlist_get_fields(PurpleRoomlist *roomlist);
Evan@653
   249
Evan@653
   250
/*@}*/
Evan@653
   251
Evan@653
   252
/**************************************************************************/
Evan@653
   253
/** @name Room API                                                        */
Evan@653
   254
/**************************************************************************/
Evan@653
   255
/*@{*/
Evan@653
   256
Evan@653
   257
/**
Evan@653
   258
 * Creates a new room, to be added to the list.
Evan@653
   259
 *
Evan@653
   260
 * @param type The type of room.
Evan@653
   261
 * @param name The name of the room.
Evan@653
   262
 * @param parent The room's parent, if any.
Evan@653
   263
 *
Evan@653
   264
 * @return A new room.
Evan@653
   265
 */
Evan@653
   266
PurpleRoomlistRoom *purple_roomlist_room_new(PurpleRoomlistRoomType type, const gchar *name,
Evan@653
   267
                                         PurpleRoomlistRoom *parent);
Evan@653
   268
Evan@653
   269
/**
Evan@653
   270
 * Adds a field to a room.
Evan@653
   271
 *
Evan@653
   272
 * @param list The room list the room belongs to.
Evan@653
   273
 * @param room The room.
Evan@653
   274
 * @param field The field to append. Strings get g_strdup'd internally.
Evan@653
   275
 */
Evan@653
   276
void purple_roomlist_room_add_field(PurpleRoomlist *list, PurpleRoomlistRoom *room, gconstpointer field);
Evan@653
   277
Evan@653
   278
/**
Evan@653
   279
 * Join a room, given a PurpleRoomlistRoom and it's associated PurpleRoomlist.
Evan@653
   280
 *
Evan@653
   281
 * @param list The room list the room belongs to.
Evan@653
   282
 * @param room The room to join.
Evan@653
   283
 */
Evan@653
   284
void purple_roomlist_room_join(PurpleRoomlist *list, PurpleRoomlistRoom *room);
Evan@653
   285
Evan@653
   286
/**
Evan@653
   287
 * Get the type of a room.
Evan@653
   288
 * @param room  The room, which must not be @c NULL.
Evan@653
   289
 * @return The type of the room.
Evan@653
   290
 * @since 2.4.0
Evan@653
   291
 */
Evan@653
   292
PurpleRoomlistRoomType purple_roomlist_room_get_type(PurpleRoomlistRoom *room);
Evan@653
   293
Evan@653
   294
/**
Evan@653
   295
 * Get the name of a room.
Evan@653
   296
 * @param room  The room, which must not be @c NULL.
Evan@653
   297
 * @return The name of the room.
Evan@653
   298
 * @since 2.4.0
Evan@653
   299
 */
Evan@653
   300
const char * purple_roomlist_room_get_name(PurpleRoomlistRoom *room);
Evan@653
   301
Evan@653
   302
/**
Evan@653
   303
 * Get the parent of a room.
Evan@653
   304
 * @param room  The room, which must not be @c NULL.
Evan@653
   305
 * @return The parent of the room, which can be @c NULL.
Evan@653
   306
 * @since 2.4.0
Evan@653
   307
 */
Evan@653
   308
PurpleRoomlistRoom * purple_roomlist_room_get_parent(PurpleRoomlistRoom *room);
Evan@653
   309
Evan@653
   310
/**
Evan@653
   311
 * Get the list of fields for a room.
Evan@653
   312
 *
Evan@653
   313
 * @param room  The room, which must not be @c NULL.
Evan@653
   314
 * @constreturn A list of fields
Evan@653
   315
 * @since 2.4.0
Evan@653
   316
 */
Evan@653
   317
GList * purple_roomlist_room_get_fields(PurpleRoomlistRoom *room);
Evan@653
   318
Evan@653
   319
/*@}*/
Evan@653
   320
Evan@653
   321
/**************************************************************************/
Evan@653
   322
/** @name Room Field API                                                  */
Evan@653
   323
/**************************************************************************/
Evan@653
   324
/*@{*/
Evan@653
   325
Evan@653
   326
/**
Evan@653
   327
 * Creates a new field.
Evan@653
   328
 *
Evan@653
   329
 * @param type   The type of the field.
Evan@653
   330
 * @param label  The i18n'ed, user displayable name.
Evan@653
   331
 * @param name   The internal name of the field.
Evan@653
   332
 * @param hidden Hide the field.
Evan@653
   333
 *
Evan@653
   334
 * @return A new PurpleRoomlistField, ready to be added to a GList and passed to
Evan@653
   335
 *         purple_roomlist_set_fields().
Evan@653
   336
 */
Evan@653
   337
PurpleRoomlistField *purple_roomlist_field_new(PurpleRoomlistFieldType type,
Evan@653
   338
                                           const gchar *label, const gchar *name,
Evan@653
   339
                                           gboolean hidden);
Evan@653
   340
Evan@653
   341
/**
Evan@653
   342
 * Get the type of a field.
Evan@653
   343
 *
Evan@653
   344
 * @param field  A PurpleRoomlistField, which must not be @c NULL.
Evan@653
   345
 *
Evan@653
   346
 * @return  The type of the field.
Evan@653
   347
 * @since 2.4.0
Evan@653
   348
 */
Evan@653
   349
PurpleRoomlistFieldType purple_roomlist_field_get_type(PurpleRoomlistField *field);
Evan@653
   350
Evan@653
   351
/**
Evan@653
   352
 * Get the label of a field.
Evan@653
   353
 *
Evan@653
   354
 * @param field  A PurpleRoomlistField, which must not be @c NULL.
Evan@653
   355
 *
Evan@653
   356
 * @return  The label of the field.
Evan@653
   357
 * @since 2.4.0
Evan@653
   358
 */
Evan@653
   359
const char * purple_roomlist_field_get_label(PurpleRoomlistField *field);
Evan@653
   360
Evan@653
   361
/**
Evan@653
   362
 * Check whether a roomlist-field is hidden.
Evan@653
   363
 * @param field  A PurpleRoomlistField, which must not be @c NULL.
Evan@653
   364
 *
Evan@653
   365
 * @return  @c TRUE if the field is hidden, @c FALSE otherwise.
Evan@653
   366
 * @since 2.4.0
Evan@653
   367
 */
Evan@653
   368
gboolean purple_roomlist_field_get_hidden(PurpleRoomlistField *field);
Evan@653
   369
Evan@653
   370
/*@}*/
Evan@653
   371
Evan@653
   372
/**************************************************************************/
Evan@653
   373
/** @name UI Registration Functions                                       */
Evan@653
   374
/**************************************************************************/
Evan@653
   375
/*@{*/
Evan@653
   376
Evan@653
   377
/**
Evan@653
   378
 * Sets the UI operations structure to be used in all purple room lists.
Evan@653
   379
 *
Evan@653
   380
 * @param ops The UI operations structure.
Evan@653
   381
 */
Evan@653
   382
void purple_roomlist_set_ui_ops(PurpleRoomlistUiOps *ops);
Evan@653
   383
Evan@653
   384
/**
Evan@653
   385
 * Returns the purple window UI operations structure to be used in
Evan@653
   386
 * new windows.
Evan@653
   387
 *
Evan@653
   388
 * @return A filled-out PurpleRoomlistUiOps structure.
Evan@653
   389
 */
Evan@653
   390
PurpleRoomlistUiOps *purple_roomlist_get_ui_ops(void);
Evan@653
   391
Evan@653
   392
/*@}*/
Evan@653
   393
Evan@653
   394
#ifdef __cplusplus
Evan@653
   395
}
Evan@653
   396
#endif
Evan@653
   397
Evan@653
   398
#endif /* _PURPLE_ROOMLIST_H_ */