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