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_FACEBOOK_UTIL_H
23 #define PURPLE_FACEBOOK_UTIL_H
27 * @section_id: facebook-util
28 * @short_description: <filename>util.h</filename>
29 * @title: General Utilities
31 * The general utilities.
36 #include <libpurple/util.h>
39 #include "conversationtypes.h"
41 #include "connection.h"
42 #include "conversation.h"
47 * Shortcut #PurpleDebugLevel for unsafe and verbose info messages.
49 #define FB_UTIL_DEBUG_INFO ( \
51 FB_UTIL_DEBUG_FLAG_UNSAFE | \
52 FB_UTIL_DEBUG_FLAG_VERBOSE \
58 * The #GQuark of the domain of utility errors.
60 #define FB_UTIL_ERROR fb_util_error_quark()
63 * FbUtilRequestBuddyFunc:
64 * @buddies: The list of #PurpleBuddy's.
65 * @data: The user-defined data.
67 * The callback for requested buddies.
69 typedef void (*FbUtilRequestBuddyFunc
) (GSList
*buddies
, gpointer data
);
73 * @FB_UTIL_DEBUG_FLAG_UNSAFE: The message is unsafe.
74 * @FB_UTIL_DEBUG_FLAG_VERBOSE: The message is verbose.
75 * @FB_UTIL_DEBUG_FLAG_ALL: All of the flags.
77 * The debugging message flags. These flags are inserted on top of
78 * a #PurpleDebugLevel.
82 FB_UTIL_DEBUG_FLAG_UNSAFE
= 1 << 25,
83 FB_UTIL_DEBUG_FLAG_VERBOSE
= 1 << 26,
84 FB_UTIL_DEBUG_FLAG_ALL
= 3 << 25
89 * @FB_UTIL_ERROR_GENERAL: General failure.
91 * The error codes for the #FB_UTIL_ERROR domain.
99 * fb_util_error_quark:
101 * Gets the #GQuark of the domain of utility errors.
103 * Returns: The #GQuark of the domain.
106 fb_util_error_quark(void);
109 * fb_util_account_find_buddy:
110 * @acct: The #PurpleAccount.
111 * @chat: The #PurpleChatConversation.
112 * @name: The name of the buddy.
113 * @error: The return location for the #GError or #NULL.
115 * Finds a buddy by their name or alias.
117 * Returns: The #PurpleBuddy if found, otherwise #NULL.
120 fb_util_account_find_buddy(PurpleAccount
*acct
, PurpleChatConversation
*chat
,
121 const gchar
*name
, GError
**error
);
125 * @level: The #PurpleDebugLevel.
126 * @format: The format string literal.
127 * @...: The arguments for @format.
129 * Logs a debugging message. If the messages is unsafe or verbose,
130 * apply the appropriate #FbUtilDebugFlags.
133 fb_util_debug(PurpleDebugLevel level
, const gchar
*format
, ...)
138 * @level: The #PurpleDebugLevel.
139 * @format: The format string literal.
142 * Logs a debugging message. If the messages is unsafe or verbose,
143 * apply the appropriate #FbUtilDebugFlags.
146 fb_util_vdebug(PurpleDebugLevel level
, const gchar
*format
, va_list ap
);
149 * fb_util_debug_misc:
150 * @format: The format string literal.
151 * @...: The arguments for @format.
153 * Logs a debugging message with the level of #PURPLE_DEBUG_MISC.
156 fb_util_debug_misc(const gchar
*format
, ...)
160 * fb_util_debug_info:
161 * @format: The format string literal.
162 * @...: The arguments for @format.
164 * Logs a debugging message with the level of #PURPLE_DEBUG_INFO.
167 fb_util_debug_info(const gchar
*format
, ...)
171 * fb_util_debug_warning:
172 * @format: The format string literal.
173 * @...: The arguments for @format.
175 * Logs a debugging message with the level of #PURPLE_DEBUG_WARNING.
178 fb_util_debug_warning(const gchar
*format
, ...)
182 * fb_util_debug_error:
183 * @format: The format string literal.
184 * @...: The arguments for @format.
186 * Logs a debugging message with the level of #PURPLE_DEBUG_ERROR.
189 fb_util_debug_error(const gchar
*format
, ...)
193 * fb_util_debug_fatal:
194 * @format: The format string literal.
195 * @...: The arguments for @format.
197 * Logs a debugging message with the level of #PURPLE_DEBUG_FATAL.
200 fb_util_debug_fatal(const gchar
*format
, ...)
204 * fb_util_debug_hexdump:
205 * @level: The #PurpleDebugLevel.
206 * @bytes: The #GByteArray.
207 * @format: The format string literal.
208 * @...: The arguments for @format.
210 * Logs a hexdump of a #GByteArray. If the messages is unsafe or
211 * verbose, apply the appropriate #FbUtilDebugFlags.
214 fb_util_debug_hexdump(PurpleDebugLevel level
, const GByteArray
*bytes
,
215 const gchar
*format
, ...)
219 * fb_util_get_locale:
221 * Gets the locale string (ex: en_US) from the system. The returned
222 * string should be freed with #g_free() when no longer needed.
224 * Returns: The locale string.
227 fb_util_get_locale(void);
230 * fb_util_rand_alnum:
231 * @len: The length of the string.
233 * Gets a random alphanumeric (A-Za-z0-9) string. This function should
234 * *not* be relied on for cryptographic operations. The returned string
235 * should be freed with #g_free() when no longer needed.
237 * Returns: The alphanumeric string.
240 fb_util_rand_alnum(guint len
);
243 * fb_util_request_buddy:
244 * @gc: The #PurpleConnection.
245 * @title: The title of the message or #NULL.
246 * @primary: The main point of the message or #NULL.
247 * @secondary: The secondary information or #NULL.
248 * @select: A #GSList of selected buddies or #NULL.
249 * @multi: #TRUE to for multiple buddy selections, otherwise #FALSE.
250 * @ok_cb: The callback for the `OK` button or #NULL.
251 * @cancel_cb: The callback for the `Cancel` button or #NULL.
252 * @data: The user-defined data.
254 * Displays a buddy list selection form.
256 * Returns: The UI-specific handle.
259 fb_util_request_buddy(PurpleConnection
*gc
, const gchar
*title
,
260 const gchar
*primary
, const gchar
*secondary
,
261 GSList
*select
, gboolean multi
, GCallback ok_cb
,
262 GCallback cancel_cb
, gpointer data
);
265 * fb_util_serv_got_im:
266 * @gc: The #PurpleConnection.
267 * @who: The message sender or receiver.
268 * @text: The message text.
269 * @flags: The #PurpleMessageFlags.
270 * @timestamp: The message timestamp.
272 * Handles an incoming IM message. This function is special in that it
273 * handles self messages. This function determines the direction of the
274 * message from the #PurpleMessageFlags.
277 fb_util_serv_got_im(PurpleConnection
*gc
, const gchar
*who
, const gchar
*text
,
278 PurpleMessageFlags flags
, guint64 timestamp
);
281 * fb_util_serv_got_chat_in:
282 * @gc: The #PurpleConnection.
283 * @id: The id of the chat.
284 * @who: The message sender or receiver.
285 * @text: The message text.
286 * @flags: The #PurpleMessageFlags.
287 * @timestamp: The message timestamp.
289 * Handles an incoming chat message. This function is special in that
290 * it handles self messages. This function determines the direction of
291 * the message from the #PurpleMessageFlags.
294 fb_util_serv_got_chat_in(PurpleConnection
*gc
, gint id
, const gchar
*who
,
295 const gchar
*text
, PurpleMessageFlags flags
,
301 * @type: The #GAsciiType.
303 * Tests if the string only contains characters allowed by the
304 * #GAsciiType. More than one type can be specified by ORing the types
307 * Returns: #TRUE if the string only contains characters allowed by the
308 * #GAsciiType, otherwise #FALSE.
311 fb_util_strtest(const gchar
*str
, GAsciiType type
);
315 * @bytes: The #GByteArray.
317 * Tests if the #GByteArray is zlib compressed.
319 * Returns: #TRUE if the #GByteArray is compressed, otherwise #FALSE.
322 fb_util_zlib_test(const GByteArray
*bytes
);
325 * fb_util_zlib_deflate:
326 * @bytes: The #GByteArray.
327 * @error: The return location for the #GError or #NULL.
329 * Deflates a #GByteArray with zlib. The returned #GByteArray should be
330 * freed with #g_byte_array_free() when no longer needed.
332 * Returns: The deflated #GByteArray or #NULL on error.
335 fb_util_zlib_deflate(const GByteArray
*bytes
, GError
**error
);
338 * fb_util_zlib_inflate:
339 * @bytes: The #GByteArray.
340 * @error: The return location for the #GError or #NULL.
342 * Inflates a #GByteArray with zlib. The returned #GByteArray should be
343 * freed with #g_byte_array_free() when no longer needed.
345 * Returns: The inflated #GByteArray or #NULL on error.
348 fb_util_zlib_inflate(const GByteArray
*bytes
, GError
**error
);
350 #endif /* PURPLE_FACEBOOK_UTIL_H */