3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef _PURPLE_ROOMLIST_H_
23 #define _PURPLE_ROOMLIST_H_
26 * @section_id: libpurple-roomlist
27 * @short_description: <filename>roomlist.h</filename>
28 * @title: Room List API
31 #define PURPLE_TYPE_ROOMLIST (purple_roomlist_get_type())
32 #define PURPLE_ROOMLIST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_ROOMLIST, PurpleRoomlist))
33 #define PURPLE_ROOMLIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_ROOMLIST, PurpleRoomlistClass))
34 #define PURPLE_IS_ROOMLIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_ROOMLIST))
35 #define PURPLE_IS_ROOMLIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_ROOMLIST))
36 #define PURPLE_ROOMLIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_ROOMLIST, PurpleRoomlistClass))
38 typedef struct _PurpleRoomlist PurpleRoomlist
;
39 typedef struct _PurpleRoomlistClass PurpleRoomlistClass
;
41 #define PURPLE_TYPE_ROOMLIST_ROOM (purple_roomlist_room_get_type())
43 typedef struct _PurpleRoomlistRoom PurpleRoomlistRoom
;
45 #define PURPLE_TYPE_ROOMLIST_FIELD (purple_roomlist_field_get_type())
47 typedef struct _PurpleRoomlistField PurpleRoomlistField
;
49 #define PURPLE_TYPE_ROOMLIST_UI_OPS (purple_roomlist_ui_ops_get_type())
51 typedef struct _PurpleRoomlistUiOps PurpleRoomlistUiOps
;
54 * PurpleRoomlistRoomType:
55 * @PURPLE_ROOMLIST_ROOMTYPE_CATEGORY: It's a category, but not a room you can
57 * @PURPLE_ROOMLIST_ROOMTYPE_ROOM: It's a room, like the kind you can join.
61 * These are ORable flags.
65 PURPLE_ROOMLIST_ROOMTYPE_CATEGORY
= 0x01,
66 PURPLE_ROOMLIST_ROOMTYPE_ROOM
= 0x02
68 } PurpleRoomlistRoomType
;
71 * PurpleRoomlistFieldType:
72 * @PURPLE_ROOMLIST_FIELD_STRING: We do a g_strdup on the passed value if it's
75 * The types of fields.
79 PURPLE_ROOMLIST_FIELD_BOOL
,
80 PURPLE_ROOMLIST_FIELD_INT
,
81 PURPLE_ROOMLIST_FIELD_STRING
83 } PurpleRoomlistFieldType
;
88 /**************************************************************************/
89 /** Data Structures */
90 /**************************************************************************/
93 * PurpleRoomlistUiOps:
94 * @show_with_account: Force the ui to pop up a dialog and get the list.
95 * @create: A new list was created.
96 * @set_fields: Sets the columns.
97 * @add_room: Add a room to the list.
98 * @in_progress: Are we fetching stuff still?
99 * @destroy: We're destroying list.
101 * The room list ops to be filled out by the UI.
103 struct _PurpleRoomlistUiOps
{
104 void (*show_with_account
)(PurpleAccount
*account
);
105 void (*create
)(PurpleRoomlist
*list
);
106 void (*set_fields
)(PurpleRoomlist
*list
, GList
*fields
);
107 void (*add_room
)(PurpleRoomlist
*list
, PurpleRoomlistRoom
*room
);
108 void (*in_progress
)(PurpleRoomlist
*list
, gboolean flag
);
109 void (*destroy
)(PurpleRoomlist
*list
);
112 void (*_purple_reserved1
)(void);
113 void (*_purple_reserved2
)(void);
114 void (*_purple_reserved3
)(void);
115 void (*_purple_reserved4
)(void);
120 * @ui_data: The UI data associated with this room list. This is a convenience
121 * field provided to the UIs -- it is not used by the libpurple core.
123 * Represents a list of rooms for a given connection on a given protocol.
125 struct _PurpleRoomlist
{
133 * PurpleRoomlistClass:
135 * Base class for all #PurpleRoomlist's
137 struct _PurpleRoomlistClass
{
138 GObjectClass parent_class
;
141 void (*_purple_reserved1
)(void);
142 void (*_purple_reserved2
)(void);
143 void (*_purple_reserved3
)(void);
144 void (*_purple_reserved4
)(void);
149 /**************************************************************************/
151 /**************************************************************************/
154 * purple_roomlist_get_type:
156 * Returns: The #GType for the Room List object.
158 GType
purple_roomlist_get_type(void);
161 * purple_roomlist_show_with_account:
162 * @account: The account to get the list on.
164 * This is used to get the room list on an account, asking the UI
165 * to pop up a dialog with the specified account already selected,
166 * and pretend the user clicked the get list button.
167 * While we're pretending, predend I didn't say anything about dialogs
168 * or buttons, since this is the core.
170 void purple_roomlist_show_with_account(PurpleAccount
*account
);
173 * purple_roomlist_new:
174 * @account: The account that's listing rooms.
176 * Returns a newly created room list object.
178 * Returns: The new room list handle.
180 PurpleRoomlist
*purple_roomlist_new(PurpleAccount
*account
);
183 * purple_roomlist_get_account:
185 * Retrieve the PurpleAccount that was given when the room list was
188 * Returns: The PurpleAccount tied to this room list.
190 PurpleAccount
*purple_roomlist_get_account(PurpleRoomlist
*list
);
193 * purple_roomlist_set_fields:
194 * @list: The room list.
195 * @fields: A GList of PurpleRoomlistField's. UI's are encouraged
196 * to default to displaying them in the order given.
198 * Set the different field types and their names for this protocol.
200 * This must be called before purple_roomlist_room_add().
202 void purple_roomlist_set_fields(PurpleRoomlist
*list
, GList
*fields
);
205 * purple_roomlist_set_in_progress:
206 * @list: The room list.
207 * @in_progress: We're downloading it, or we're not.
209 * Set the "in progress" state of the room list.
211 * The UI is encouraged to somehow hint to the user
212 * whether or not we're busy downloading a room list or not.
214 void purple_roomlist_set_in_progress(PurpleRoomlist
*list
, gboolean in_progress
);
217 * purple_roomlist_get_in_progress:
218 * @list: The room list.
220 * Gets the "in progress" state of the room list.
222 * The UI is encouraged to somehow hint to the user
223 * whether or not we're busy downloading a room list or not.
225 * Returns: True if we're downloading it, or false if we're not.
227 gboolean
purple_roomlist_get_in_progress(PurpleRoomlist
*list
);
230 * purple_roomlist_room_add:
231 * @list: The room list.
232 * @room: The room to add to the list. The GList of fields must be in the same
233 order as was given in purple_roomlist_set_fields().
235 * Adds a room to the list of them.
237 void purple_roomlist_room_add(PurpleRoomlist
*list
, PurpleRoomlistRoom
*room
);
240 * purple_roomlist_get_list:
241 * @gc: The PurpleConnection to have get a list.
243 * Returns a PurpleRoomlist structure from the protocol, and
244 * instructs the protocol to start fetching the list.
246 * Returns: A PurpleRoomlist* or %NULL if the protocol
247 * doesn't support that.
249 PurpleRoomlist
*purple_roomlist_get_list(PurpleConnection
*gc
);
252 * purple_roomlist_cancel_get_list:
253 * @list: The room list to cancel a get_list on.
255 * Tells the protocol to stop fetching the list.
256 * If this is possible and done, the protocol will
257 * call set_in_progress with %FALSE and possibly
258 * unref the list if it took a reference.
260 void purple_roomlist_cancel_get_list(PurpleRoomlist
*list
);
263 * purple_roomlist_expand_category:
264 * @list: The room list.
265 * @category: The category that was expanded. The expression
266 * (category->type & PURPLE_ROOMLIST_ROOMTYPE_CATEGORY)
269 * Tells the protocol that a category was expanded.
271 * On some protocols, the rooms in the category
272 * won't be fetched until this is called.
274 void purple_roomlist_expand_category(PurpleRoomlist
*list
, PurpleRoomlistRoom
*category
);
277 * purple_roomlist_get_fields:
278 * @roomlist: The roomlist, which must not be %NULL.
280 * Get the list of fields for a roomlist.
282 * Returns: (transfer none): A list of fields
284 GList
*purple_roomlist_get_fields(PurpleRoomlist
*roomlist
);
287 * purple_roomlist_get_protocol_data:
288 * @list: The roomlist, which must not be %NULL.
290 * Get the protocol data associated with this room list.
292 * Returns: The protocol data associated with this room list. This is a
293 * convenience field provided to the protocol -- it is not
294 * used the libpurple core.
296 gpointer
purple_roomlist_get_protocol_data(PurpleRoomlist
*list
);
299 * purple_roomlist_set_protocol_data:
300 * @list: The roomlist, which must not be %NULL.
301 * @proto_data: A pointer to associate with this room list.
303 * Set the protocol data associated with this room list.
305 void purple_roomlist_set_protocol_data(PurpleRoomlist
*list
, gpointer proto_data
);
308 * purple_roomlist_get_ui_data:
309 * @list: The roomlist, which must not be %NULL.
311 * Get the UI data associated with this room list.
313 * Returns: The UI data associated with this room list. This is a
314 * convenience field provided to the UIs--it is not
315 * used by the libpurple core.
317 gpointer
purple_roomlist_get_ui_data(PurpleRoomlist
*list
);
320 * purple_roomlist_set_ui_data:
321 * @list: The roomlist, which must not be %NULL.
322 * @ui_data: A pointer to associate with this room list.
324 * Set the UI data associated with this room list.
326 void purple_roomlist_set_ui_data(PurpleRoomlist
*list
, gpointer ui_data
);
328 /**************************************************************************/
330 /**************************************************************************/
333 * purple_roomlist_room_get_type:
335 * Returns: The #GType for the #PurpleRoomlistRoom boxed structure.
337 GType
purple_roomlist_room_get_type(void);
340 * purple_roomlist_room_new:
341 * @type: The type of room.
342 * @name: The name of the room.
343 * @parent: The room's parent, if any.
345 * Creates a new room, to be added to the list.
347 * Returns: A new room.
349 PurpleRoomlistRoom
*purple_roomlist_room_new(PurpleRoomlistRoomType type
, const gchar
*name
,
350 PurpleRoomlistRoom
*parent
);
353 * purple_roomlist_room_add_field:
354 * @list: The room list the room belongs to.
356 * @field: The field to append. Strings get g_strdup'd internally.
358 * Adds a field to a room.
360 void purple_roomlist_room_add_field(PurpleRoomlist
*list
, PurpleRoomlistRoom
*room
, gconstpointer field
);
363 * purple_roomlist_room_join:
364 * @list: The room list the room belongs to.
365 * @room: The room to join.
367 * Join a room, given a PurpleRoomlistRoom and it's associated PurpleRoomlist.
369 void purple_roomlist_room_join(PurpleRoomlist
*list
, PurpleRoomlistRoom
*room
);
372 * purple_roomlist_room_get_room_type:
373 * @room: The room, which must not be %NULL.
375 * Get the type of a room.
377 * Returns: The type of the room.
379 PurpleRoomlistRoomType
purple_roomlist_room_get_room_type(PurpleRoomlistRoom
*room
);
382 * purple_roomlist_room_get_name:
383 * @room: The room, which must not be %NULL.
385 * Get the name of a room.
387 * Returns: The name of the room.
389 const char * purple_roomlist_room_get_name(PurpleRoomlistRoom
*room
);
392 * purple_roomlist_room_get_parent:
393 * @room: The room, which must not be %NULL.
395 * Get the parent of a room.
397 * Returns: The parent of the room, which can be %NULL.
399 PurpleRoomlistRoom
* purple_roomlist_room_get_parent(PurpleRoomlistRoom
*room
);
402 * purple_roomlist_room_get_expanded_once:
403 * @room: The room, which must not be %NULL.
405 * Get the value of the expanded_once flag.
407 * Returns: The value of the expanded_once flag.
409 gboolean
purple_roomlist_room_get_expanded_once(PurpleRoomlistRoom
*room
);
412 * purple_roomlist_room_set_expanded_once:
413 * @room: The room, which must not be %NULL.
414 * @expanded_once: The new value of the expanded_once flag.
416 * Set the expanded_once flag.
418 void purple_roomlist_room_set_expanded_once(PurpleRoomlistRoom
*room
, gboolean expanded_once
);
421 * purple_roomlist_room_get_fields:
422 * @room: The room, which must not be %NULL.
424 * Get the list of fields for a room.
426 * Returns: (transfer none): A list of fields
428 GList
* purple_roomlist_room_get_fields(PurpleRoomlistRoom
*room
);
430 /**************************************************************************/
432 /**************************************************************************/
435 * purple_roomlist_field_get_type:
437 * Returns: The #GType for the #PurpleRoomlistField boxed structure.
439 GType
purple_roomlist_field_get_type(void);
442 * purple_roomlist_field_new:
443 * @type: The type of the field.
444 * @label: The i18n'ed, user displayable name.
445 * @name: The internal name of the field.
446 * @hidden: Hide the field.
448 * Creates a new field.
450 * Returns: A new PurpleRoomlistField, ready to be added to a GList and passed to
451 * purple_roomlist_set_fields().
453 PurpleRoomlistField
*purple_roomlist_field_new(PurpleRoomlistFieldType type
,
454 const gchar
*label
, const gchar
*name
,
458 * purple_roomlist_field_get_field_type:
459 * @field: A PurpleRoomlistField, which must not be %NULL.
461 * Get the type of a field.
463 * Returns: The type of the field.
465 PurpleRoomlistFieldType
purple_roomlist_field_get_field_type(PurpleRoomlistField
*field
);
468 * purple_roomlist_field_get_label:
469 * @field: A PurpleRoomlistField, which must not be %NULL.
471 * Get the label of a field.
473 * Returns: The label of the field.
475 const char * purple_roomlist_field_get_label(PurpleRoomlistField
*field
);
478 * purple_roomlist_field_get_hidden:
479 * @field: A PurpleRoomlistField, which must not be %NULL.
481 * Check whether a roomlist-field is hidden.
483 * Returns: %TRUE if the field is hidden, %FALSE otherwise.
485 gboolean
purple_roomlist_field_get_hidden(PurpleRoomlistField
*field
);
487 /**************************************************************************/
488 /* UI Registration Functions */
489 /**************************************************************************/
492 * purple_roomlist_ui_ops_get_type:
494 * Returns: The #GType for the #PurpleRoomlistUiOps boxed structure.
496 GType
purple_roomlist_ui_ops_get_type(void);
499 * purple_roomlist_set_ui_ops:
500 * @ops: The UI operations structure.
502 * Sets the UI operations structure to be used in all purple room lists.
504 void purple_roomlist_set_ui_ops(PurpleRoomlistUiOps
*ops
);
507 * purple_roomlist_get_ui_ops:
509 * Returns the purple window UI operations structure to be used in
512 * Returns: A filled-out PurpleRoomlistUiOps structure.
514 PurpleRoomlistUiOps
*purple_roomlist_get_ui_ops(void);
518 #endif /* _PURPLE_ROOMLIST_H_ */