8113
|
1 /**
|
|
2 * @file roomlist.h Room List API
|
|
3 * @ingroup core
|
|
4 *
|
|
5 * gaim
|
|
6 *
|
8146
|
7 * Gaim is the legal property of its developers, whose names are too numerous
|
|
8 * to list here. Please refer to the COPYRIGHT file distributed with this
|
|
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
|
|
26 #ifndef _GAIM_ROOMLIST_H_
|
|
27 #define _GAIM_ROOMLIST_H_
|
|
28
|
|
29 /**************************************************************************/
|
|
30 /** Data Structures */
|
|
31 /**************************************************************************/
|
|
32
|
|
33 typedef struct _GaimRoomlist GaimRoomlist;
|
|
34 typedef struct _GaimRoomlistRoom GaimRoomlistRoom;
|
|
35 typedef enum _GaimRoomlistRoomType GaimRoomlistRoomType;
|
|
36 typedef struct _GaimRoomlistField GaimRoomlistField;
|
|
37 typedef enum _GaimRoomlistFieldType GaimRoomlistFieldType;
|
|
38 typedef struct _GaimRoomlistUiOps GaimRoomlistUiOps;
|
|
39
|
|
40 /**
|
|
41 * Represents a list of rooms for a given connection on a given protocol.
|
|
42 */
|
|
43 struct _GaimRoomlist {
|
|
44 GaimAccount *account; /**< The account this list belongs to. */
|
|
45 GList *fields; /**< The fields. */
|
|
46 GList *rooms; /**< The list of rooms. */
|
8199
|
47 gboolean in_progress; /**< The listing is in progress. */
|
8113
|
48 gpointer ui_data; /**< UI private data. */
|
|
49 gpointer proto_data; /** Prpl private data. */
|
|
50 guint ref; /**< The reference count. */
|
|
51 };
|
|
52
|
|
53 /**
|
|
54 * The types of rooms.
|
|
55 *
|
|
56 * These are ORable flags.
|
|
57 */
|
|
58 enum _GaimRoomlistRoomType {
|
|
59 GAIM_ROOMLIST_ROOMTYPE_CATAGORY = 0x01, /**< It's a catagory, but not a room you can join. */
|
|
60 GAIM_ROOMLIST_ROOMTYPE_ROOM = 0x02, /**< It's a room, like the kind you can join. */
|
|
61 };
|
|
62
|
|
63 /**
|
|
64 * Represents a room.
|
|
65 */
|
|
66 struct _GaimRoomlistRoom {
|
|
67 GaimRoomlistRoomType type; /**< The type of room. */
|
|
68 gchar *name; /**< The name of the room. */
|
|
69 GList *fields; /**< Other fields. */
|
|
70 GaimRoomlistRoom *parent; /**< The parent room, or NULL. */
|
|
71 gboolean expanded_once; /**< A flag the UI uses to avoid multiple expand prpl cbs. */
|
|
72 };
|
|
73
|
|
74 /**
|
|
75 * The types of fields.
|
|
76 */
|
|
77 enum _GaimRoomlistFieldType {
|
|
78 GAIM_ROOMLIST_FIELD_BOOL,
|
|
79 GAIM_ROOMLIST_FIELD_INT,
|
|
80 GAIM_ROOMLIST_FIELD_STRING, /**< We do a g_strdup on the passed value if it's this type. */
|
|
81 };
|
|
82
|
|
83 /**
|
|
84 * A field a room might have.
|
|
85 */
|
|
86 struct _GaimRoomlistField {
|
|
87 GaimRoomlistFieldType type; /**< The type of field. */
|
|
88 gchar *label; /**< The i18n user displayed name of the field. */
|
|
89 gchar *name; /**< The internal name of the field. */
|
|
90 gboolean hidden; /**< Hidden? */
|
|
91 };
|
|
92
|
|
93 /**
|
|
94 * The room list ops to be filled out by the UI.
|
|
95 */
|
|
96 struct _GaimRoomlistUiOps {
|
|
97 void (*new)(GaimRoomlist *list); /**< A new list was created. */
|
|
98 void (*set_fields)(GaimRoomlist *list, GList *fields); /**< Sets the columns. */
|
|
99 void (*add_room)(GaimRoomlist *list, GaimRoomlistRoom *room); /**< Add a room to the list. */
|
|
100 void (*in_progress)(GaimRoomlist *list, gboolean flag); /**< Are we fetching stuff still? */
|
|
101 void (*destroy)(GaimRoomlist *list); /**< We're destroying list. */
|
|
102 };
|
|
103
|
|
104
|
|
105 #ifdef __cplusplus
|
|
106 extern "C" {
|
|
107 #endif
|
|
108
|
|
109 /**************************************************************************/
|
|
110 /** @name Room List API */
|
|
111 /**************************************************************************/
|
|
112 /*@{*/
|
|
113
|
|
114 /**
|
|
115 * Returns a newly created room list object.
|
|
116 *
|
|
117 * It has an inital reference count of 1.
|
|
118 *
|
|
119 * @param account The account that's listing rooms.
|
|
120 * @return The new room list handle.
|
|
121 */
|
|
122 GaimRoomlist *gaim_roomlist_new(GaimAccount *account);
|
|
123
|
|
124 /**
|
|
125 * Increases the reference count on the room list.
|
|
126 *
|
|
127 * @param list The object to ref.
|
|
128 */
|
|
129 void gaim_roomlist_ref(GaimRoomlist *list);
|
|
130
|
|
131 /**
|
|
132 * Decreases the reference count on the room list.
|
|
133 *
|
|
134 * The room list will be destroyed when this reaches 0.
|
|
135 *
|
|
136 * @param list The room list object to unref and possibly
|
|
137 * destroy.
|
|
138 */
|
|
139 void gaim_roomlist_unref(GaimRoomlist *list);
|
|
140
|
|
141 /**
|
|
142 * Set the different field types and their names for this protocol.
|
|
143 *
|
|
144 * This must be called before gaim_roomlist_room_add().
|
|
145 *
|
|
146 * @param list The room list.
|
|
147 * @param fields A GList of GaimRoomlistField's. UI's are encourged
|
|
148 * to default to displaying them in the order given.
|
|
149 */
|
|
150 void gaim_roomlist_set_fields(GaimRoomlist *list, GList *fields);
|
|
151
|
|
152 /**
|
|
153 * Set the "in progress" state of the room list.
|
|
154 *
|
|
155 * The UI is encourged to somehow hint to the user
|
|
156 * whether or not we're busy downloading a room list or not.
|
|
157 *
|
|
158 * @param list The room list.
|
|
159 * @param in_progress We're downloading it, or we're not.
|
|
160 */
|
|
161 void gaim_roomlist_set_in_progress(GaimRoomlist *list, gboolean in_progress);
|
|
162
|
|
163 /**
|
8199
|
164 * Gets the "in progress" state of the room list.
|
|
165 *
|
|
166 * The UI is encourged to somehow hint to the user
|
|
167 * whether or not we're busy downloading a room list or not.
|
|
168 *
|
|
169 * @param list The room list.
|
|
170 * @returns True if we're downloading it, or false if we're not.
|
|
171 */
|
|
172 gboolean gaim_roomlist_get_in_progress(GaimRoomlist *list);
|
|
173
|
|
174 /**
|
8113
|
175 * Adds a room to the list of them.
|
|
176 *
|
|
177 * @param list The room list.
|
|
178 * @param room The room to add to the list. The GList of fields must be in the same
|
|
179 order as was given in gaim_roomlist_set_fields().
|
|
180 */
|
|
181 void gaim_roomlist_room_add(GaimRoomlist *list, GaimRoomlistRoom *room);
|
|
182
|
|
183 /**
|
|
184 * Do we support room listing?
|
|
185 *
|
|
186 * @param gc The GaimConnection we're asking.
|
|
187 * @return @c TRUE if it's possible to get a room list.
|
|
188 */
|
|
189 gboolean gaim_roomlist_is_possible(GaimConnection *gc);
|
|
190
|
|
191 /**
|
|
192 * Returns a GaimRoomlist structure from the prpl, and
|
|
193 * instructs the prpl to start fetching the list.
|
|
194 *
|
|
195 * @param gc The GaimConnection to have get a list.
|
|
196 *
|
|
197 * @return A GaimRoomlist* or @c NULL if the protocol
|
|
198 * doesn't support that.
|
|
199 */
|
|
200 GaimRoomlist *gaim_roomlist_get_list(GaimConnection *gc);
|
|
201
|
|
202 /**
|
|
203 * Tells the prpl to stop fetching the list.
|
|
204 * If this is possible and done, the prpl will
|
|
205 * call set_in_progress with @c FALSE and possibly
|
|
206 * unref the list if it took a reference.
|
|
207 *
|
|
208 * @param list The room list to cancel a get_list on.
|
|
209 */
|
|
210 void gaim_roomlist_cancel_get_list(GaimRoomlist *list);
|
|
211
|
|
212 /**
|
|
213 * Tells the prpl that a catagory was expanded.
|
|
214 *
|
|
215 * On some protocols, the rooms in the catagory
|
|
216 * won't be fetched until this is called.
|
|
217 *
|
|
218 * @param list The room list.
|
|
219 * @param room The catagory that was expanded. The expression
|
|
220 * (catagory->type & GAIM_ROOMLIST_ROOMTYPE_CATAGORY)
|
|
221 * must be true.
|
|
222 */
|
|
223 void gaim_roomlist_expand_catagory(GaimRoomlist *list, GaimRoomlistRoom *catagory);
|
|
224
|
|
225 /*@}*/
|
|
226
|
|
227 /**************************************************************************/
|
|
228 /** @name Room API */
|
|
229 /**************************************************************************/
|
|
230 /*@{*/
|
|
231
|
|
232 /**
|
|
233 * Creates a new room, to be added to the list.
|
|
234 *
|
|
235 * @param type The type of room.
|
|
236 * @param name The name of the room.
|
|
237 * @param parent The room's parent, if any.
|
|
238 *
|
|
239 * @return A new room.
|
|
240 */
|
|
241 GaimRoomlistRoom *gaim_roomlist_room_new(GaimRoomlistRoomType type, const gchar *name,
|
|
242 GaimRoomlistRoom *parent);
|
|
243
|
|
244 /**
|
|
245 * Adds a field to a room.
|
|
246 *
|
|
247 * @param list The room list the room belongs to.
|
|
248 * @param room The room.
|
|
249 * @param field The field to append. Strings get g_strdup'd internally.
|
|
250 */
|
|
251 void gaim_roomlist_room_add_field(GaimRoomlist *list, GaimRoomlistRoom *room, gconstpointer field);
|
|
252
|
8199
|
253 /**
|
|
254 * Join a room, given a GaimRoomlistRoom and it's associated GaimRoomlist.
|
|
255 *
|
|
256 * @param list The room list the room belongs to.
|
|
257 * @param room The room to join.
|
|
258 */
|
|
259 void gaim_roomlist_room_join(GaimRoomlist *list, GaimRoomlistRoom *room);
|
|
260
|
8113
|
261 /*@}*/
|
|
262
|
|
263 /**************************************************************************/
|
|
264 /** @name Room Field API */
|
|
265 /**************************************************************************/
|
|
266 /*@{*/
|
|
267
|
|
268 /**
|
|
269 * Creates a new field.
|
|
270 *
|
|
271 * @param type The type of the field.
|
|
272 * @param label The i18n'ed, user displayable name.
|
|
273 * @param name The internal name of the field.
|
|
274 *
|
|
275 * @return A new GaimRoomlistField, ready to be added to a GList and passed to
|
|
276 * gaim_roomlist_set_fields().
|
|
277 */
|
|
278 GaimRoomlistField *gaim_roomlist_field_new(GaimRoomlistFieldType type,
|
|
279 const gchar *label, const gchar *name,
|
|
280 gboolean hidden);
|
|
281 /*@}*/
|
|
282
|
|
283 /**************************************************************************/
|
|
284 /** @name UI Registration Functions */
|
|
285 /**************************************************************************/
|
|
286 /*@{*/
|
|
287
|
|
288 /**
|
|
289 * Sets the UI operations structure to be used in all gaim room lists.
|
|
290 *
|
|
291 * @param ops The UI operations structure.
|
|
292 */
|
|
293 void gaim_roomlist_set_ui_ops(GaimRoomlistUiOps *ops);
|
|
294
|
|
295 /**
|
|
296 * Returns the gaim window UI operations structure to be used in
|
|
297 * new windows.
|
|
298 *
|
|
299 * @return A filled-out GaimRoomlistUiOps structure.
|
|
300 */
|
|
301 GaimRoomlistUiOps *gaim_roomlist_get_ui_ops(void);
|
|
302
|
|
303 /*@}*/
|
|
304
|
|
305 #ifdef __cplusplus
|
|
306 }
|
|
307 #endif
|
|
308
|
|
309 #endif /* _GAIM_ROOMLIST_H_ */
|