Mon, 16 Apr 2007 00:44:33 +0000
merge of 'b98e72d4089afb8a1879e5fe9627cfb132ee88de'
and '606a402fea87c797c4b751475228a6f6a5385122'
| 8113 | 1 | /** |
| 2 | * @file roomlist.h Room List API | |
| 3 | * @ingroup core | |
| 4 | * | |
| 15884 | 5 | * purple |
| 8113 | 6 | * |
| 15884 | 7 | * Purple is the legal property of its developers, whose names are too numerous |
|
8146
4961c9c5fd61
[gaim-migrate @ 8854]
John Silvestri <john.silvestri@gmail.com>
parents:
8113
diff
changeset
|
8 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
4961c9c5fd61
[gaim-migrate @ 8854]
John Silvestri <john.silvestri@gmail.com>
parents:
8113
diff
changeset
|
9 | * source distribution. |
| 8113 | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify | |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * along with this program; if not, write to the Free Software | |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 24 | */ | |
| 25 | ||
| 15884 | 26 | #ifndef _PURPLE_ROOMLIST_H_ |
| 27 | #define _PURPLE_ROOMLIST_H_ | |
| 8113 | 28 | |
| 15884 | 29 | typedef struct _PurpleRoomlist PurpleRoomlist; |
| 30 | typedef struct _PurpleRoomlistRoom PurpleRoomlistRoom; | |
| 31 | typedef struct _PurpleRoomlistField PurpleRoomlistField; | |
| 32 | typedef struct _PurpleRoomlistUiOps PurpleRoomlistUiOps; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9000
diff
changeset
|
33 | |
|
9999
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
34 | /** |
|
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
35 | * The types of rooms. |
|
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
36 | * |
|
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
37 | * These are ORable flags. |
|
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
38 | */ |
|
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
39 | typedef enum |
|
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
40 | { |
| 15884 | 41 | PURPLE_ROOMLIST_ROOMTYPE_CATEGORY = 0x01, /**< It's a category, but not a room you can join. */ |
| 42 | PURPLE_ROOMLIST_ROOMTYPE_ROOM = 0x02 /**< It's a room, like the kind you can join. */ | |
|
9999
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
43 | |
| 15884 | 44 | } PurpleRoomlistRoomType; |
|
9999
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
45 | |
|
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
46 | /** |
|
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
47 | * The types of fields. |
|
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
48 | */ |
|
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
49 | typedef enum |
|
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
50 | { |
| 15884 | 51 | PURPLE_ROOMLIST_FIELD_BOOL, |
| 52 | PURPLE_ROOMLIST_FIELD_INT, | |
| 53 | PURPLE_ROOMLIST_FIELD_STRING /**< We do a g_strdup on the passed value if it's this type. */ | |
|
9999
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
54 | |
| 15884 | 55 | } PurpleRoomlistFieldType; |
|
9999
86e89e1dee10
[gaim-migrate @ 10913]
Mark Doliner <markdoliner@pidgin.im>
parents:
9030
diff
changeset
|
56 | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9000
diff
changeset
|
57 | #include "account.h" |
|
10023
6b0014040323
[gaim-migrate @ 10955]
Mark Doliner <markdoliner@pidgin.im>
parents:
9999
diff
changeset
|
58 | #include "glib.h" |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9000
diff
changeset
|
59 | |
| 8113 | 60 | /**************************************************************************/ |
| 61 | /** Data Structures */ | |
| 62 | /**************************************************************************/ | |
| 63 | ||
| 64 | /** | |
| 65 | * Represents a list of rooms for a given connection on a given protocol. | |
| 66 | */ | |
| 15884 | 67 | struct _PurpleRoomlist { |
| 68 | PurpleAccount *account; /**< The account this list belongs to. */ | |
| 8113 | 69 | GList *fields; /**< The fields. */ |
| 70 | GList *rooms; /**< The list of rooms. */ | |
| 8199 | 71 | gboolean in_progress; /**< The listing is in progress. */ |
| 8113 | 72 | gpointer ui_data; /**< UI private data. */ |
| 73 | gpointer proto_data; /** Prpl private data. */ | |
| 74 | guint ref; /**< The reference count. */ | |
| 75 | }; | |
| 76 | ||
| 77 | /** | |
| 78 | * Represents a room. | |
| 79 | */ | |
| 15884 | 80 | struct _PurpleRoomlistRoom { |
| 81 | PurpleRoomlistRoomType type; /**< The type of room. */ | |
| 8113 | 82 | gchar *name; /**< The name of the room. */ |
| 83 | GList *fields; /**< Other fields. */ | |
| 15884 | 84 | PurpleRoomlistRoom *parent; /**< The parent room, or NULL. */ |
| 8113 | 85 | gboolean expanded_once; /**< A flag the UI uses to avoid multiple expand prpl cbs. */ |
| 86 | }; | |
| 87 | ||
| 88 | /** | |
| 89 | * A field a room might have. | |
| 90 | */ | |
| 15884 | 91 | struct _PurpleRoomlistField { |
| 92 | PurpleRoomlistFieldType type; /**< The type of field. */ | |
| 8113 | 93 | gchar *label; /**< The i18n user displayed name of the field. */ |
| 94 | gchar *name; /**< The internal name of the field. */ | |
| 95 | gboolean hidden; /**< Hidden? */ | |
| 96 | }; | |
| 97 | ||
| 98 | /** | |
| 99 | * The room list ops to be filled out by the UI. | |
| 100 | */ | |
| 15884 | 101 | struct _PurpleRoomlistUiOps { |
| 102 | void (*show_with_account)(PurpleAccount *account); /**< Force the ui to pop up a dialog and get the list */ | |
| 103 | void (*create)(PurpleRoomlist *list); /**< A new list was created. */ | |
| 104 | void (*set_fields)(PurpleRoomlist *list, GList *fields); /**< Sets the columns. */ | |
| 105 | void (*add_room)(PurpleRoomlist *list, PurpleRoomlistRoom *room); /**< Add a room to the list. */ | |
| 106 | void (*in_progress)(PurpleRoomlist *list, gboolean flag); /**< Are we fetching stuff still? */ | |
| 107 | void (*destroy)(PurpleRoomlist *list); /**< We're destroying list. */ | |
| 8113 | 108 | }; |
| 109 | ||
| 110 | ||
| 111 | #ifdef __cplusplus | |
| 112 | extern "C" { | |
| 113 | #endif | |
| 114 | ||
| 115 | /**************************************************************************/ | |
| 116 | /** @name Room List API */ | |
| 117 | /**************************************************************************/ | |
| 118 | /*@{*/ | |
| 119 | ||
| 120 | /** | |
| 8352 | 121 | * This is used to get the room list on an account, asking the UI |
| 122 | * to pop up a dialog with the specified account already selected, | |
| 123 | * and pretend the user clicked the get list button. | |
| 124 | * While we're pretending, predend I didn't say anything about dialogs | |
| 125 | * or buttons, since this is the core. | |
| 126 | * | |
| 127 | * @param account The account to get the list on. | |
| 128 | */ | |
| 15884 | 129 | void purple_roomlist_show_with_account(PurpleAccount *account); |
| 8352 | 130 | |
| 131 | /** | |
| 8113 | 132 | * Returns a newly created room list object. |
| 133 | * | |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8584
diff
changeset
|
134 | * It has an initial reference count of 1. |
| 8113 | 135 | * |
| 136 | * @param account The account that's listing rooms. | |
| 137 | * @return The new room list handle. | |
| 138 | */ | |
| 15884 | 139 | PurpleRoomlist *purple_roomlist_new(PurpleAccount *account); |
| 8113 | 140 | |
| 141 | /** | |
| 142 | * Increases the reference count on the room list. | |
| 143 | * | |
| 144 | * @param list The object to ref. | |
| 145 | */ | |
| 15884 | 146 | void purple_roomlist_ref(PurpleRoomlist *list); |
| 8113 | 147 | |
| 148 | /** | |
| 149 | * Decreases the reference count on the room list. | |
| 150 | * | |
| 151 | * The room list will be destroyed when this reaches 0. | |
| 152 | * | |
| 153 | * @param list The room list object to unref and possibly | |
| 154 | * destroy. | |
| 155 | */ | |
| 15884 | 156 | void purple_roomlist_unref(PurpleRoomlist *list); |
| 8113 | 157 | |
| 158 | /** | |
| 159 | * Set the different field types and their names for this protocol. | |
| 160 | * | |
| 15884 | 161 | * This must be called before purple_roomlist_room_add(). |
| 8113 | 162 | * |
| 163 | * @param list The room list. | |
| 15884 | 164 | * @param fields A GList of PurpleRoomlistField's. UI's are encouraged |
| 8113 | 165 | * to default to displaying them in the order given. |
| 166 | */ | |
| 15884 | 167 | void purple_roomlist_set_fields(PurpleRoomlist *list, GList *fields); |
| 8113 | 168 | |
| 169 | /** | |
| 170 | * Set the "in progress" state of the room list. | |
| 171 | * | |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8584
diff
changeset
|
172 | * The UI is encouraged to somehow hint to the user |
| 8113 | 173 | * whether or not we're busy downloading a room list or not. |
| 174 | * | |
| 175 | * @param list The room list. | |
| 176 | * @param in_progress We're downloading it, or we're not. | |
| 177 | */ | |
| 15884 | 178 | void purple_roomlist_set_in_progress(PurpleRoomlist *list, gboolean in_progress); |
| 8113 | 179 | |
| 180 | /** | |
| 8199 | 181 | * Gets the "in progress" state of the room list. |
| 182 | * | |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8584
diff
changeset
|
183 | * The UI is encouraged to somehow hint to the user |
| 8199 | 184 | * whether or not we're busy downloading a room list or not. |
| 185 | * | |
| 186 | * @param list The room list. | |
| 8866 | 187 | * @return True if we're downloading it, or false if we're not. |
| 8199 | 188 | */ |
| 15884 | 189 | gboolean purple_roomlist_get_in_progress(PurpleRoomlist *list); |
| 8199 | 190 | |
| 191 | /** | |
| 8113 | 192 | * Adds a room to the list of them. |
| 193 | * | |
| 194 | * @param list The room list. | |
| 195 | * @param room The room to add to the list. The GList of fields must be in the same | |
| 15884 | 196 | order as was given in purple_roomlist_set_fields(). |
| 8113 | 197 | */ |
| 15884 | 198 | void purple_roomlist_room_add(PurpleRoomlist *list, PurpleRoomlistRoom *room); |
| 8113 | 199 | |
| 200 | /** | |
| 15884 | 201 | * Returns a PurpleRoomlist structure from the prpl, and |
| 8113 | 202 | * instructs the prpl to start fetching the list. |
| 203 | * | |
| 15884 | 204 | * @param gc The PurpleConnection to have get a list. |
| 8113 | 205 | * |
| 15884 | 206 | * @return A PurpleRoomlist* or @c NULL if the protocol |
| 8113 | 207 | * doesn't support that. |
| 208 | */ | |
| 15884 | 209 | PurpleRoomlist *purple_roomlist_get_list(PurpleConnection *gc); |
| 8113 | 210 | |
| 211 | /** | |
| 212 | * Tells the prpl to stop fetching the list. | |
| 213 | * If this is possible and done, the prpl will | |
| 214 | * call set_in_progress with @c FALSE and possibly | |
| 215 | * unref the list if it took a reference. | |
| 216 | * | |
| 217 | * @param list The room list to cancel a get_list on. | |
| 218 | */ | |
| 15884 | 219 | void purple_roomlist_cancel_get_list(PurpleRoomlist *list); |
| 8113 | 220 | |
| 221 | /** | |
| 8584 | 222 | * Tells the prpl that a category was expanded. |
| 8113 | 223 | * |
| 8584 | 224 | * On some protocols, the rooms in the category |
| 8113 | 225 | * won't be fetched until this is called. |
| 226 | * | |
| 9000 | 227 | * @param list The room list. |
| 228 | * @param category The category that was expanded. The expression | |
| 15884 | 229 | * (category->type & PURPLE_ROOMLIST_ROOMTYPE_CATEGORY) |
| 9000 | 230 | * must be true. |
| 8113 | 231 | */ |
| 15884 | 232 | void purple_roomlist_expand_category(PurpleRoomlist *list, PurpleRoomlistRoom *category); |
| 8113 | 233 | |
| 234 | /*@}*/ | |
| 235 | ||
| 236 | /**************************************************************************/ | |
| 237 | /** @name Room API */ | |
| 238 | /**************************************************************************/ | |
| 239 | /*@{*/ | |
| 240 | ||
| 241 | /** | |
| 242 | * Creates a new room, to be added to the list. | |
| 243 | * | |
| 244 | * @param type The type of room. | |
| 245 | * @param name The name of the room. | |
| 246 | * @param parent The room's parent, if any. | |
| 247 | * | |
| 248 | * @return A new room. | |
| 249 | */ | |
| 15884 | 250 | PurpleRoomlistRoom *purple_roomlist_room_new(PurpleRoomlistRoomType type, const gchar *name, |
| 251 | PurpleRoomlistRoom *parent); | |
| 8113 | 252 | |
| 253 | /** | |
| 254 | * Adds a field to a room. | |
| 255 | * | |
| 256 | * @param list The room list the room belongs to. | |
| 257 | * @param room The room. | |
| 258 | * @param field The field to append. Strings get g_strdup'd internally. | |
| 259 | */ | |
| 15884 | 260 | void purple_roomlist_room_add_field(PurpleRoomlist *list, PurpleRoomlistRoom *room, gconstpointer field); |
| 8113 | 261 | |
| 8199 | 262 | /** |
| 15884 | 263 | * Join a room, given a PurpleRoomlistRoom and it's associated PurpleRoomlist. |
| 8199 | 264 | * |
| 265 | * @param list The room list the room belongs to. | |
| 266 | * @param room The room to join. | |
| 267 | */ | |
| 15884 | 268 | void purple_roomlist_room_join(PurpleRoomlist *list, PurpleRoomlistRoom *room); |
| 8199 | 269 | |
| 8113 | 270 | /*@}*/ |
| 271 | ||
| 272 | /**************************************************************************/ | |
| 273 | /** @name Room Field API */ | |
| 274 | /**************************************************************************/ | |
| 275 | /*@{*/ | |
| 276 | ||
| 277 | /** | |
| 278 | * Creates a new field. | |
| 279 | * | |
| 9000 | 280 | * @param type The type of the field. |
| 281 | * @param label The i18n'ed, user displayable name. | |
| 282 | * @param name The internal name of the field. | |
| 283 | * @param hidden Hide the field. | |
| 8113 | 284 | * |
| 15884 | 285 | * @return A new PurpleRoomlistField, ready to be added to a GList and passed to |
| 286 | * purple_roomlist_set_fields(). | |
| 8113 | 287 | */ |
| 15884 | 288 | PurpleRoomlistField *purple_roomlist_field_new(PurpleRoomlistFieldType type, |
| 8113 | 289 | const gchar *label, const gchar *name, |
| 290 | gboolean hidden); | |
| 291 | /*@}*/ | |
| 292 | ||
| 293 | /**************************************************************************/ | |
| 294 | /** @name UI Registration Functions */ | |
| 295 | /**************************************************************************/ | |
| 296 | /*@{*/ | |
| 297 | ||
| 298 | /** | |
| 15884 | 299 | * Sets the UI operations structure to be used in all purple room lists. |
| 8113 | 300 | * |
| 301 | * @param ops The UI operations structure. | |
| 302 | */ | |
| 15884 | 303 | void purple_roomlist_set_ui_ops(PurpleRoomlistUiOps *ops); |
| 8113 | 304 | |
| 305 | /** | |
| 15884 | 306 | * Returns the purple window UI operations structure to be used in |
| 8113 | 307 | * new windows. |
| 308 | * | |
| 15884 | 309 | * @return A filled-out PurpleRoomlistUiOps structure. |
| 8113 | 310 | */ |
| 15884 | 311 | PurpleRoomlistUiOps *purple_roomlist_get_ui_ops(void); |
| 8113 | 312 | |
| 313 | /*@}*/ | |
| 314 | ||
| 315 | #ifdef __cplusplus | |
| 316 | } | |
| 317 | #endif | |
| 318 | ||
| 15884 | 319 | #endif /* _PURPLE_ROOMLIST_H_ */ |