Merged pidgin/main into default
[pidgin-git.git] / libpurple / roomlist.h
blobd129826839527eb8ae6a4f3e6dfd0cc6991568c6
1 /* purple
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
5 * source distribution.
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_
24 /**
25 * SECTION:roomlist
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;
53 /**
54 * PurpleRoomlistRoomType:
55 * @PURPLE_ROOMLIST_ROOMTYPE_CATEGORY: It's a category, but not a room you can
56 * join.
57 * @PURPLE_ROOMLIST_ROOMTYPE_ROOM: It's a room, like the kind you can join.
59 * The types of rooms.
61 * These are ORable flags.
63 typedef enum
65 PURPLE_ROOMLIST_ROOMTYPE_CATEGORY = 0x01,
66 PURPLE_ROOMLIST_ROOMTYPE_ROOM = 0x02
68 } PurpleRoomlistRoomType;
70 /**
71 * PurpleRoomlistFieldType:
72 * @PURPLE_ROOMLIST_FIELD_STRING: We do a g_strdup on the passed value if it's
73 * this type.
75 * The types of fields.
77 typedef enum
79 PURPLE_ROOMLIST_FIELD_BOOL,
80 PURPLE_ROOMLIST_FIELD_INT,
81 PURPLE_ROOMLIST_FIELD_STRING
83 } PurpleRoomlistFieldType;
85 #include "account.h"
86 #include <glib.h>
88 /**************************************************************************/
89 /** Data Structures */
90 /**************************************************************************/
92 /**
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);
111 /*< private >*/
112 void (*_purple_reserved1)(void);
113 void (*_purple_reserved2)(void);
114 void (*_purple_reserved3)(void);
115 void (*_purple_reserved4)(void);
119 * PurpleRoomlist:
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 {
126 GObject gparent;
128 /*< public >*/
129 gpointer ui_data;
133 * PurpleRoomlistClass:
135 * Base class for all #PurpleRoomlist's
137 struct _PurpleRoomlistClass {
138 GObjectClass parent_class;
140 /*< private >*/
141 void (*_purple_reserved1)(void);
142 void (*_purple_reserved2)(void);
143 void (*_purple_reserved3)(void);
144 void (*_purple_reserved4)(void);
147 G_BEGIN_DECLS
149 /**************************************************************************/
150 /* Room List API */
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:
184 * @list: The room list.
186 * Retrieve the PurpleAccount that was given when the room list was
187 * created.
189 * Returns: The PurpleAccount tied to this room list.
191 PurpleAccount *purple_roomlist_get_account(PurpleRoomlist *list);
194 * purple_roomlist_set_fields:
195 * @list: The room list.
196 * @fields: (element-type PurpleRoomlistField) (transfer full): UI's are
197 * encouraged to default to displaying these fields in the order given.
199 * Set the different field types and their names for this protocol.
201 * This must be called before purple_roomlist_room_add().
203 void purple_roomlist_set_fields(PurpleRoomlist *list, GList *fields);
206 * purple_roomlist_set_in_progress:
207 * @list: The room list.
208 * @in_progress: We're downloading it, or we're not.
210 * Set the "in progress" state of the room list.
212 * The UI is encouraged to somehow hint to the user
213 * whether or not we're busy downloading a room list or not.
215 void purple_roomlist_set_in_progress(PurpleRoomlist *list, gboolean in_progress);
218 * purple_roomlist_get_in_progress:
219 * @list: The room list.
221 * Gets the "in progress" state of the room list.
223 * The UI is encouraged to somehow hint to the user
224 * whether or not we're busy downloading a room list or not.
226 * Returns: True if we're downloading it, or false if we're not.
228 gboolean purple_roomlist_get_in_progress(PurpleRoomlist *list);
231 * purple_roomlist_room_add:
232 * @list: The room list.
233 * @room: The room to add to the list. The GList of fields must be in the same
234 order as was given in purple_roomlist_set_fields().
236 * Adds a room to the list of them.
238 void purple_roomlist_room_add(PurpleRoomlist *list, PurpleRoomlistRoom *room);
241 * purple_roomlist_get_list:
242 * @gc: The PurpleConnection to have get a list.
244 * Returns a PurpleRoomlist structure from the protocol, and
245 * instructs the protocol to start fetching the list.
247 * Returns: A PurpleRoomlist* or %NULL if the protocol
248 * doesn't support that.
250 PurpleRoomlist *purple_roomlist_get_list(PurpleConnection *gc);
253 * purple_roomlist_cancel_get_list:
254 * @list: The room list to cancel a get_list on.
256 * Tells the protocol to stop fetching the list.
257 * If this is possible and done, the protocol will
258 * call set_in_progress with %FALSE and possibly
259 * unref the list if it took a reference.
261 void purple_roomlist_cancel_get_list(PurpleRoomlist *list);
264 * purple_roomlist_expand_category:
265 * @list: The room list.
266 * @category: The category that was expanded. The expression
267 * (category->type & PURPLE_ROOMLIST_ROOMTYPE_CATEGORY)
268 * must be true.
270 * Tells the protocol that a category was expanded.
272 * On some protocols, the rooms in the category
273 * won't be fetched until this is called.
275 void purple_roomlist_expand_category(PurpleRoomlist *list, PurpleRoomlistRoom *category);
278 * purple_roomlist_get_fields:
279 * @roomlist: The roomlist, which must not be %NULL.
281 * Get the list of fields for a roomlist.
283 * Returns: (element-type PurpleRoomlistField) (transfer none): A list of fields
285 GList *purple_roomlist_get_fields(PurpleRoomlist *roomlist);
288 * purple_roomlist_get_protocol_data:
289 * @list: The roomlist, which must not be %NULL.
291 * Get the protocol data associated with this room list.
293 * Returns: The protocol data associated with this room list. This is a
294 * convenience field provided to the protocol -- it is not
295 * used the libpurple core.
297 gpointer purple_roomlist_get_protocol_data(PurpleRoomlist *list);
300 * purple_roomlist_set_protocol_data:
301 * @list: The roomlist, which must not be %NULL.
302 * @proto_data: A pointer to associate with this room list.
304 * Set the protocol data associated with this room list.
306 void purple_roomlist_set_protocol_data(PurpleRoomlist *list, gpointer proto_data);
309 * purple_roomlist_get_ui_data:
310 * @list: The roomlist, which must not be %NULL.
312 * Get the UI data associated with this room list.
314 * Returns: The UI data associated with this room list. This is a
315 * convenience field provided to the UIs--it is not
316 * used by the libpurple core.
318 gpointer purple_roomlist_get_ui_data(PurpleRoomlist *list);
321 * purple_roomlist_set_ui_data:
322 * @list: The roomlist, which must not be %NULL.
323 * @ui_data: A pointer to associate with this room list.
325 * Set the UI data associated with this room list.
327 void purple_roomlist_set_ui_data(PurpleRoomlist *list, gpointer ui_data);
329 /**************************************************************************/
330 /* Room API */
331 /**************************************************************************/
334 * purple_roomlist_room_get_type:
336 * Returns: The #GType for the #PurpleRoomlistRoom boxed structure.
338 GType purple_roomlist_room_get_type(void);
341 * purple_roomlist_room_new:
342 * @type: The type of room.
343 * @name: The name of the room.
344 * @parent: The room's parent, if any.
346 * Creates a new room, to be added to the list.
348 * Returns: A new room.
350 PurpleRoomlistRoom *purple_roomlist_room_new(PurpleRoomlistRoomType type, const gchar *name,
351 PurpleRoomlistRoom *parent);
354 * purple_roomlist_room_add_field:
355 * @list: The room list the room belongs to.
356 * @room: The room.
357 * @field: The field to append. Strings get g_strdup'd internally.
359 * Adds a field to a room.
361 void purple_roomlist_room_add_field(PurpleRoomlist *list, PurpleRoomlistRoom *room, gconstpointer field);
364 * purple_roomlist_room_join:
365 * @list: The room list the room belongs to.
366 * @room: The room to join.
368 * Join a room, given a PurpleRoomlistRoom and it's associated PurpleRoomlist.
370 void purple_roomlist_room_join(PurpleRoomlist *list, PurpleRoomlistRoom *room);
373 * purple_roomlist_room_get_room_type:
374 * @room: The room, which must not be %NULL.
376 * Get the type of a room.
378 * Returns: The type of the room.
380 PurpleRoomlistRoomType purple_roomlist_room_get_room_type(PurpleRoomlistRoom *room);
383 * purple_roomlist_room_get_name:
384 * @room: The room, which must not be %NULL.
386 * Get the name of a room.
388 * Returns: The name of the room.
390 const char * purple_roomlist_room_get_name(PurpleRoomlistRoom *room);
393 * purple_roomlist_room_get_parent:
394 * @room: The room, which must not be %NULL.
396 * Get the parent of a room.
398 * Returns: The parent of the room, which can be %NULL.
400 PurpleRoomlistRoom * purple_roomlist_room_get_parent(PurpleRoomlistRoom *room);
403 * purple_roomlist_room_get_expanded_once:
404 * @room: The room, which must not be %NULL.
406 * Get the value of the expanded_once flag.
408 * Returns: The value of the expanded_once flag.
410 gboolean purple_roomlist_room_get_expanded_once(PurpleRoomlistRoom *room);
413 * purple_roomlist_room_set_expanded_once:
414 * @room: The room, which must not be %NULL.
415 * @expanded_once: The new value of the expanded_once flag.
417 * Set the expanded_once flag.
419 void purple_roomlist_room_set_expanded_once(PurpleRoomlistRoom *room, gboolean expanded_once);
422 * purple_roomlist_room_get_fields:
423 * @room: The room, which must not be %NULL.
425 * Get the list of fields for a room.
427 * Returns: (element-type PurpleRoomlistField) (transfer none): A list of fields
429 GList * purple_roomlist_room_get_fields(PurpleRoomlistRoom *room);
431 /**************************************************************************/
432 /* Room Field API */
433 /**************************************************************************/
436 * purple_roomlist_field_get_type:
438 * Returns: The #GType for the #PurpleRoomlistField boxed structure.
440 GType purple_roomlist_field_get_type(void);
443 * purple_roomlist_field_new:
444 * @type: The type of the field.
445 * @label: The i18n'ed, user displayable name.
446 * @name: The internal name of the field.
447 * @hidden: Hide the field.
449 * Creates a new field.
451 * Returns: A new PurpleRoomlistField, ready to be added to a GList and passed to
452 * purple_roomlist_set_fields().
454 PurpleRoomlistField *purple_roomlist_field_new(PurpleRoomlistFieldType type,
455 const gchar *label, const gchar *name,
456 gboolean hidden);
459 * purple_roomlist_field_get_field_type:
460 * @field: A PurpleRoomlistField, which must not be %NULL.
462 * Get the type of a field.
464 * Returns: The type of the field.
466 PurpleRoomlistFieldType purple_roomlist_field_get_field_type(PurpleRoomlistField *field);
469 * purple_roomlist_field_get_label:
470 * @field: A PurpleRoomlistField, which must not be %NULL.
472 * Get the label of a field.
474 * Returns: The label of the field.
476 const char * purple_roomlist_field_get_label(PurpleRoomlistField *field);
479 * purple_roomlist_field_get_hidden:
480 * @field: A PurpleRoomlistField, which must not be %NULL.
482 * Check whether a roomlist-field is hidden.
484 * Returns: %TRUE if the field is hidden, %FALSE otherwise.
486 gboolean purple_roomlist_field_get_hidden(PurpleRoomlistField *field);
488 /**************************************************************************/
489 /* UI Registration Functions */
490 /**************************************************************************/
493 * purple_roomlist_ui_ops_get_type:
495 * Returns: The #GType for the #PurpleRoomlistUiOps boxed structure.
497 GType purple_roomlist_ui_ops_get_type(void);
500 * purple_roomlist_set_ui_ops:
501 * @ops: The UI operations structure.
503 * Sets the UI operations structure to be used in all purple room lists.
505 void purple_roomlist_set_ui_ops(PurpleRoomlistUiOps *ops);
508 * purple_roomlist_get_ui_ops:
510 * Returns the purple window UI operations structure to be used in
511 * new windows.
513 * Returns: A filled-out PurpleRoomlistUiOps structure.
515 PurpleRoomlistUiOps *purple_roomlist_get_ui_ops(void);
517 G_END_DECLS
519 #endif /* _PURPLE_ROOMLIST_H_ */