mark PurpleImageClass as private
[pidgin-git.git] / libpurple / protocols / facebook / data.h
blobb93e9618ab77ede10455ed4507c4e0e809261899
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_FACEBOOK_DATA_H
23 #define PURPLE_FACEBOOK_DATA_H
25 /**
26 * SECTION:data
27 * @section_id: facebook-data
28 * @short_description: <filename>data.h</filename>
29 * @title: Connection Data
31 * The Connection Data.
34 #include <glib.h>
36 #include "connection.h"
37 #include "roomlist.h"
39 #include "api.h"
40 #include "http.h"
41 #include "id.h"
43 #define FB_TYPE_DATA fb_data_get_type()
44 #define FB_TYPE_DATA_IMAGE fb_data_image_get_type()
46 /**
47 * FB_DATA_ICON_MAX:
49 * The maximum of number of concurrent icon fetches.
51 #define FB_DATA_ICON_MAX 4
53 /**
54 * FB_DATA_ICON_SIZE_MAX:
56 * The maximum size of a fetched icon.
58 #define FB_DATA_ICON_SIZE_MAX 0xa00000 /* 10MiB */
60 /**
61 * fb_data_get_type:
63 * Returns: The #GType for an #FbData.
65 G_DECLARE_FINAL_TYPE(FbData, fb_data, FB, DATA, GObject)
67 /**
68 * fb_data_image_get_type:
70 * Returns: The #GType for an #FbDataImage.
72 G_DECLARE_FINAL_TYPE(FbDataImage, fb_data_image, FB, DATA_IMAGE, GObject)
74 /**
75 * FbDataImageFunc:
76 * @img: The #FbDataImage.
77 * @error: The #GError or #NULL.
79 * The callback for a fetched #FbDataImage.
81 typedef void (*FbDataImageFunc) (FbDataImage *img, GError *error);
83 /**
84 * fb_data_new:
85 * @gc: The #PurpleConnection.
87 * Creates a new #FbData. The returned #FbData should be freed with
88 * #g_object_unref() when no longer needed.
90 * Returns: The new #FbData.
92 FbData *
93 fb_data_new(PurpleConnection *gc);
95 /**
96 * fb_data_load:
97 * @fata: The #FbData.
99 * Loads the internal data from the underlying #PurpleAccount.
101 * Return: #TRUE if all of the data was loaded, otherwise #FALSE.
103 gboolean
104 fb_data_load(FbData *fata);
107 * fb_data_save:
108 * @fata: The #FbData.
110 * Saves the internal data to the underlying #PurpleAccount.
112 void
113 fb_data_save(FbData *fata);
116 * fb_data_add_timeout:
117 * @fata: The #FbData.
118 * @name: The name of the timeout.
119 * @interval: The time, in milliseconds, between calls to @func.
120 * @func: The #GSourceFunc.
121 * @data: The data passed to @func.
123 * Adds a new callback timer. The callback is called repeatedly on the
124 * basis of @interval, until @func returns #FALSE. The timeout should
125 * be cleared with #fb_data_clear_timeout() when no longer needed.
127 void
128 fb_data_add_timeout(FbData *fata, const gchar *name, guint interval,
129 GSourceFunc func, gpointer data);
132 * fb_data_clear_timeout:
133 * @fata: The #FbData.
134 * @name: The name of the timeout.
135 * @remove: #TRUE to remove from the event loop, otherwise #FALSE.
137 * Clears and removes a callback timer. The only time @remove should be
138 * #FALSE, is when being called from a #GSourceFunc, which is returning
139 * #FALSE.
141 void
142 fb_data_clear_timeout(FbData *fata, const gchar *name, gboolean remove);
145 * fb_data_get_api:
146 * @fata: The #FbData.
148 * Gets the #FbApi from the #FbData.
150 * Return: The #FbApi.
152 FbApi *
153 fb_data_get_api(FbData *fata);
156 * fb_data_get_connection:
157 * @fata: The #FbData.
159 * Gets the #PurpleConnection from the #FbData.
161 * Return: The #PurpleConnection.
163 PurpleConnection *
164 fb_data_get_connection(FbData *fata);
167 * fb_data_get_roomlist:
168 * @fata: The #FbData.
170 * Gets the #PurpleRoomlist from the #FbData.
172 * Return: The #PurpleRoomlist.
174 PurpleRoomlist *
175 fb_data_get_roomlist(FbData *fata);
178 * fb_data_get_unread:
179 * @fata: The #FbData.
180 * @id: The #FbId.
182 * Gets the unread state of an #FbId.
184 * Return: #TRUE if the #FbId is unread, otherwise #FALSE.
186 gboolean
187 fb_data_get_unread(FbData *fata, FbId id);
190 * fb_data_set_roomlist:
191 * @fata: The #FbData.
192 * @list: The #PurpleRoomlist.
194 * Sets the #PurpleRoomlist to the #FbData.
196 void
197 fb_data_set_roomlist(FbData *fata, PurpleRoomlist *list);
200 * fb_data_set_unread:
201 * @fata: The #FbData.
202 * @id: The #FbId.
203 * @unread: #TRUE if the #FbId is unread, otherwise #FALSE.
205 * Sets the unread state of an #FbId to the #FbData.
207 void
208 fb_data_set_unread(FbData *fata, FbId id, gboolean unread);
211 * fb_data_add_message:
212 * @fata: The #FbData.
213 * @msg: The #FbApiMessage.
215 * Adds an #FbApiMessage to the #FbData.
217 void
218 fb_data_add_message(FbData *fata, FbApiMessage *msg);
221 * fb_data_remove_message:
222 * @fata: The #FbData.
223 * @msg: The #FbApiMessage.
225 * Removes an #FbApiMessage from the #FbData.
227 void
228 fb_data_remove_message(FbData *fata, FbApiMessage *msg);
231 * fb_data_take_messages:
232 * @fata: The #FbData.
233 * @uid: The user #FbId.
235 * Gets a #GSList of messages by the user #FbId from the #FbData. The
236 * #FbApiMessage's are removed from the #FbData. The returned #GSList
237 * and its #FbApiMessage's should be freed with #fb_api_message_free()
238 * and #g_slist_free_full() when no longer needed.
240 GSList *
241 fb_data_take_messages(FbData *fata, FbId uid);
244 * fb_data_image_add:
245 * @fata: The #FbData.
246 * @url: The image URL.
247 * @func: The #FbDataImageFunc.
248 * @data: The user-defined data.
249 * @dunc: The #GDestroyNotify for @data or #NULL.
251 * Adds a new #FbDataImage to the #FbData. This is used to fetch images
252 * from HTTP sources. After calling this, #fb_data_image_queue() should
253 * be called to queue the fetching process.
255 * Return: The #FbDataImage.
257 FbDataImage *
258 fb_data_image_add(FbData *fata, const gchar *url, FbDataImageFunc func,
259 gpointer data, GDestroyNotify dunc);
262 * fb_data_image_get_active:
263 * @img: The #FbDataImage.
265 * Gets the active fetching state from the #FbDataImage.
267 * Returns: #TRUE if the image is being fetched, otherwise #FALSE.
269 gboolean
270 fb_data_image_get_active(FbDataImage *img);
273 * fb_data_image_get_data:
274 * @img: The #FbDataImage.
276 * Gets the user-defined data from the #FbDataImage.
278 * Returns: The user-defined data.
280 gpointer
281 fb_data_image_get_data(FbDataImage *img);
284 * fb_data_image_get_fata:
285 * @img: The #FbDataImage.
287 * Gets the #FbData from the #FbDataImage.
289 * Returns: The #FbData.
291 FbData *
292 fb_data_image_get_fata(FbDataImage *img);
295 * fb_data_image_get_image:
296 * @img: The #FbDataImage.
297 * @size: The return location for the image size or #NULL.
299 * Gets the image data from the #FbDataImage.
301 * Returns: The image data.
303 const guint8 *
304 fb_data_image_get_image(FbDataImage *img, gsize *size);
307 * fb_data_image_dup_image:
308 * @img: The #FbDataImage.
309 * @size: The return location for the image size or #NULL.
311 * Gets the duplicated image data from the #FbDataImage. The returned
312 * data should be freed with #g_free() when no longer needed.
314 * Returns: The duplicated image data.
316 guint8 *
317 fb_data_image_dup_image(FbDataImage *img, gsize *size);
320 * fb_data_image_get_url:
321 * @img: The #FbDataImage.
323 * Gets the image URL from the #FbDataImage.
325 * Returns: The image URL.
327 const gchar *
328 fb_data_image_get_url(FbDataImage *img);
331 * fb_data_image_queue:
332 * @fata: The #FbData.
334 * Queues the next #FbDataImage fetches.
336 void
337 fb_data_image_queue(FbData *fata);
339 #endif /* PURPLE_FACEBOOK_DATA_H */