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