Convert XMPP console dialogs to popovers.
[pidgin-git.git] / libpurple / roomlist.h
blob14544ffe0ccb4cc3971d1e4e8498ac4edc63f048
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 typedef struct _PurpleRoomlist PurpleRoomlist;
34 #define PURPLE_TYPE_ROOMLIST_ROOM (purple_roomlist_room_get_type())
36 typedef struct _PurpleRoomlistRoom PurpleRoomlistRoom;
38 #define PURPLE_TYPE_ROOMLIST_FIELD (purple_roomlist_field_get_type())
40 typedef struct _PurpleRoomlistField PurpleRoomlistField;
42 #define PURPLE_TYPE_ROOMLIST_UI_OPS (purple_roomlist_ui_ops_get_type())
44 typedef struct _PurpleRoomlistUiOps PurpleRoomlistUiOps;
46 /**
47 * PurpleRoomlistRoomType:
48 * @PURPLE_ROOMLIST_ROOMTYPE_CATEGORY: It's a category, but not a room you can
49 * join.
50 * @PURPLE_ROOMLIST_ROOMTYPE_ROOM: It's a room, like the kind you can join.
52 * The types of rooms.
54 * These are ORable flags.
56 typedef enum
58 PURPLE_ROOMLIST_ROOMTYPE_CATEGORY = 0x01,
59 PURPLE_ROOMLIST_ROOMTYPE_ROOM = 0x02
61 } PurpleRoomlistRoomType;
63 /**
64 * PurpleRoomlistFieldType:
65 * @PURPLE_ROOMLIST_FIELD_BOOL: The field is a boolean.
66 * @PURPLE_ROOMLIST_FIELD_INT: The field is an integer.
67 * @PURPLE_ROOMLIST_FIELD_STRING: We do a g_strdup on the passed value if it's
68 * this type.
70 * The types of fields.
72 typedef enum
74 PURPLE_ROOMLIST_FIELD_BOOL,
75 PURPLE_ROOMLIST_FIELD_INT,
76 PURPLE_ROOMLIST_FIELD_STRING
78 } PurpleRoomlistFieldType;
80 #include "account.h"
81 #include <glib.h>
83 /**************************************************************************/
84 /* Data Structures */
85 /**************************************************************************/
87 /**
88 * PurpleRoomlistUiOps:
89 * @show_with_account: Force the ui to pop up a dialog and get the list.
90 * @create: A new list was created.
91 * @set_fields: Sets the columns.
92 * @add_room: Add a room to the list.
93 * @in_progress: Are we fetching stuff still?
94 * @destroy: We're destroying list.
96 * The room list ops to be filled out by the UI.
98 struct _PurpleRoomlistUiOps {
99 void (*show_with_account)(PurpleAccount *account);
100 void (*create)(PurpleRoomlist *list);
101 void (*set_fields)(PurpleRoomlist *list, GList *fields);
102 void (*add_room)(PurpleRoomlist *list, PurpleRoomlistRoom *room);
103 void (*in_progress)(PurpleRoomlist *list, gboolean flag);
104 void (*destroy)(PurpleRoomlist *list);
106 /*< private >*/
107 void (*_purple_reserved1)(void);
108 void (*_purple_reserved2)(void);
109 void (*_purple_reserved3)(void);
110 void (*_purple_reserved4)(void);
114 * PurpleRoomlist:
115 * @ui_data: The UI data associated with this room list. This is a convenience
116 * field provided to the UIs -- it is not used by the libpurple core.
118 * Represents a list of rooms for a given connection on a given protocol.
120 struct _PurpleRoomlist {
121 GObject gparent;
123 /*< public >*/
124 gpointer ui_data;
127 G_BEGIN_DECLS
129 /**************************************************************************/
130 /* Room List API */
131 /**************************************************************************/
134 * purple_roomlist_get_type:
136 * Returns: The #GType for the Room List object.
138 G_DECLARE_FINAL_TYPE(PurpleRoomlist, purple_roomlist, PURPLE, ROOMLIST, GObject)
141 * purple_roomlist_show_with_account:
142 * @account: The account to get the list on.
144 * This is used to get the room list on an account, asking the UI
145 * to pop up a dialog with the specified account already selected,
146 * and pretend the user clicked the get list button.
147 * While we're pretending, predend I didn't say anything about dialogs
148 * or buttons, since this is the core.
150 void purple_roomlist_show_with_account(PurpleAccount *account);
153 * purple_roomlist_new:
154 * @account: The account that's listing rooms.
156 * Returns a newly created room list object.
158 * Returns: The new room list handle.
160 PurpleRoomlist *purple_roomlist_new(PurpleAccount *account);
163 * purple_roomlist_get_account:
164 * @list: The room list.
166 * Retrieve the PurpleAccount that was given when the room list was
167 * created.
169 * Returns: (transfer none): The PurpleAccount tied to this room list.
171 PurpleAccount *purple_roomlist_get_account(PurpleRoomlist *list);
174 * purple_roomlist_set_fields:
175 * @list: The room list.
176 * @fields: (element-type PurpleRoomlistField) (transfer full): UI's are
177 * encouraged to default to displaying these fields in the order given.
179 * Set the different field types and their names for this protocol.
181 * This must be called before purple_roomlist_room_add().
183 void purple_roomlist_set_fields(PurpleRoomlist *list, GList *fields);
186 * purple_roomlist_set_in_progress:
187 * @list: The room list.
188 * @in_progress: We're downloading it, or we're not.
190 * Set the "in progress" state of the room list.
192 * The UI is encouraged to somehow hint to the user
193 * whether or not we're busy downloading a room list or not.
195 void purple_roomlist_set_in_progress(PurpleRoomlist *list, gboolean in_progress);
198 * purple_roomlist_get_in_progress:
199 * @list: The room list.
201 * Gets the "in progress" state of the room list.
203 * The UI is encouraged to somehow hint to the user
204 * whether or not we're busy downloading a room list or not.
206 * Returns: True if we're downloading it, or false if we're not.
208 gboolean purple_roomlist_get_in_progress(PurpleRoomlist *list);
211 * purple_roomlist_room_add:
212 * @list: The room list.
213 * @room: The room to add to the list. The GList of fields must be in the same
214 order as was given in purple_roomlist_set_fields().
216 * Adds a room to the list of them.
218 void purple_roomlist_room_add(PurpleRoomlist *list, PurpleRoomlistRoom *room);
221 * purple_roomlist_get_list:
222 * @gc: The PurpleConnection to have get a list.
224 * Returns a PurpleRoomlist structure from the protocol, and
225 * instructs the protocol to start fetching the list.
227 * Returns: (transfer full): A PurpleRoomlist* or %NULL if the protocol doesn't
228 * support that.
230 PurpleRoomlist *purple_roomlist_get_list(PurpleConnection *gc);
233 * purple_roomlist_cancel_get_list:
234 * @list: The room list to cancel a get_list on.
236 * Tells the protocol to stop fetching the list.
237 * If this is possible and done, the protocol will
238 * call set_in_progress with %FALSE and possibly
239 * unref the list if it took a reference.
241 void purple_roomlist_cancel_get_list(PurpleRoomlist *list);
244 * purple_roomlist_expand_category:
245 * @list: The room list.
246 * @category: The category that was expanded. The expression
247 * (category->type & PURPLE_ROOMLIST_ROOMTYPE_CATEGORY)
248 * must be true.
250 * Tells the protocol that a category was expanded.
252 * On some protocols, the rooms in the category
253 * won't be fetched until this is called.
255 void purple_roomlist_expand_category(PurpleRoomlist *list, PurpleRoomlistRoom *category);
258 * purple_roomlist_get_fields:
259 * @roomlist: The roomlist, which must not be %NULL.
261 * Get the list of fields for a roomlist.
263 * Returns: (element-type PurpleRoomlistField) (transfer none): A list of fields
265 GList *purple_roomlist_get_fields(PurpleRoomlist *roomlist);
268 * purple_roomlist_get_protocol_data:
269 * @list: The roomlist, which must not be %NULL.
271 * Get the protocol data associated with this room list.
273 * Returns: The protocol data associated with this room list. This is a
274 * convenience field provided to the protocol -- it is not
275 * used the libpurple core.
277 gpointer purple_roomlist_get_protocol_data(PurpleRoomlist *list);
280 * purple_roomlist_set_protocol_data:
281 * @list: The roomlist, which must not be %NULL.
282 * @proto_data: A pointer to associate with this room list.
284 * Set the protocol data associated with this room list.
286 void purple_roomlist_set_protocol_data(PurpleRoomlist *list, gpointer proto_data);
289 * purple_roomlist_get_ui_data:
290 * @list: The roomlist, which must not be %NULL.
292 * Get the UI data associated with this room list.
294 * Returns: The UI data associated with this room list. This is a
295 * convenience field provided to the UIs--it is not
296 * used by the libpurple core.
298 gpointer purple_roomlist_get_ui_data(PurpleRoomlist *list);
301 * purple_roomlist_set_ui_data:
302 * @list: The roomlist, which must not be %NULL.
303 * @ui_data: A pointer to associate with this room list.
305 * Set the UI data associated with this room list.
307 void purple_roomlist_set_ui_data(PurpleRoomlist *list, gpointer ui_data);
309 /**************************************************************************/
310 /* Room API */
311 /**************************************************************************/
314 * purple_roomlist_room_get_type:
316 * Returns: The #GType for the #PurpleRoomlistRoom boxed structure.
318 GType purple_roomlist_room_get_type(void);
321 * purple_roomlist_room_new:
322 * @type: The type of room.
323 * @name: The name of the room.
324 * @parent: The room's parent, if any.
326 * Creates a new room, to be added to the list.
328 * Returns: A new room.
330 PurpleRoomlistRoom *purple_roomlist_room_new(PurpleRoomlistRoomType type, const gchar *name,
331 PurpleRoomlistRoom *parent);
334 * purple_roomlist_room_add_field:
335 * @list: The room list the room belongs to.
336 * @room: The room.
337 * @field: The field to append. Strings get g_strdup'd internally.
339 * Adds a field to a room.
341 void purple_roomlist_room_add_field(PurpleRoomlist *list, PurpleRoomlistRoom *room, gconstpointer field);
344 * purple_roomlist_room_join:
345 * @list: The room list the room belongs to.
346 * @room: The room to join.
348 * Join a room, given a PurpleRoomlistRoom and it's associated PurpleRoomlist.
350 void purple_roomlist_room_join(PurpleRoomlist *list, PurpleRoomlistRoom *room);
353 * purple_roomlist_room_get_room_type:
354 * @room: The room, which must not be %NULL.
356 * Get the type of a room.
358 * Returns: The type of the room.
360 PurpleRoomlistRoomType purple_roomlist_room_get_room_type(PurpleRoomlistRoom *room);
363 * purple_roomlist_room_get_name:
364 * @room: The room, which must not be %NULL.
366 * Get the name of a room.
368 * Returns: The name of the room.
370 const char * purple_roomlist_room_get_name(PurpleRoomlistRoom *room);
373 * purple_roomlist_room_get_parent:
374 * @room: The room, which must not be %NULL.
376 * Get the parent of a room.
378 * Returns: The parent of the room, which can be %NULL.
380 PurpleRoomlistRoom * purple_roomlist_room_get_parent(PurpleRoomlistRoom *room);
383 * purple_roomlist_room_get_expanded_once:
384 * @room: The room, which must not be %NULL.
386 * Get the value of the expanded_once flag.
388 * Returns: The value of the expanded_once flag.
390 gboolean purple_roomlist_room_get_expanded_once(PurpleRoomlistRoom *room);
393 * purple_roomlist_room_set_expanded_once:
394 * @room: The room, which must not be %NULL.
395 * @expanded_once: The new value of the expanded_once flag.
397 * Set the expanded_once flag.
399 void purple_roomlist_room_set_expanded_once(PurpleRoomlistRoom *room, gboolean expanded_once);
402 * purple_roomlist_room_get_fields:
403 * @room: The room, which must not be %NULL.
405 * Get the list of fields for a room.
407 * Returns: (element-type PurpleRoomlistField) (transfer none): A list of fields
409 GList * purple_roomlist_room_get_fields(PurpleRoomlistRoom *room);
411 /**************************************************************************/
412 /* Room Field API */
413 /**************************************************************************/
416 * purple_roomlist_field_get_type:
418 * Returns: The #GType for the #PurpleRoomlistField boxed structure.
420 GType purple_roomlist_field_get_type(void);
423 * purple_roomlist_field_new:
424 * @type: The type of the field.
425 * @label: The i18n'ed, user displayable name.
426 * @name: The internal name of the field.
427 * @hidden: Hide the field.
429 * Creates a new field.
431 * Returns: A new PurpleRoomlistField, ready to be added to a GList and passed to
432 * purple_roomlist_set_fields().
434 PurpleRoomlistField *purple_roomlist_field_new(PurpleRoomlistFieldType type,
435 const gchar *label, const gchar *name,
436 gboolean hidden);
439 * purple_roomlist_field_get_field_type:
440 * @field: A PurpleRoomlistField, which must not be %NULL.
442 * Get the type of a field.
444 * Returns: The type of the field.
446 PurpleRoomlistFieldType purple_roomlist_field_get_field_type(PurpleRoomlistField *field);
449 * purple_roomlist_field_get_label:
450 * @field: A PurpleRoomlistField, which must not be %NULL.
452 * Get the label of a field.
454 * Returns: The label of the field.
456 const char * purple_roomlist_field_get_label(PurpleRoomlistField *field);
459 * purple_roomlist_field_get_hidden:
460 * @field: A PurpleRoomlistField, which must not be %NULL.
462 * Check whether a roomlist-field is hidden.
464 * Returns: %TRUE if the field is hidden, %FALSE otherwise.
466 gboolean purple_roomlist_field_get_hidden(PurpleRoomlistField *field);
468 /**************************************************************************/
469 /* UI Registration Functions */
470 /**************************************************************************/
473 * purple_roomlist_ui_ops_get_type:
475 * Returns: The #GType for the #PurpleRoomlistUiOps boxed structure.
477 GType purple_roomlist_ui_ops_get_type(void);
480 * purple_roomlist_set_ui_ops:
481 * @ops: The UI operations structure.
483 * Sets the UI operations structure to be used in all purple room lists.
485 void purple_roomlist_set_ui_ops(PurpleRoomlistUiOps *ops);
488 * purple_roomlist_get_ui_ops:
490 * Returns the purple window UI operations structure to be used in
491 * new windows.
493 * Returns: A filled-out PurpleRoomlistUiOps structure.
495 PurpleRoomlistUiOps *purple_roomlist_get_ui_ops(void);
497 G_END_DECLS
499 #endif /* PURPLE_ROOMLIST_H */