2 * @file internal.h Internal definitions and includes
8 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 #ifndef _PURPLE_INTERNAL_H_
27 #define _PURPLE_INTERNAL_H_
33 /* for SIOCGIFCONF in SKYOS */
35 #include <net/sockios.h>
38 * If we're using NLS, make sure gettext works. If not, then define
39 * dummy macros in place of the normal gettext macros.
41 * Also, the perl XS config.h file sometimes defines _ So we need to
42 * make sure _ isn't already defined before trying to define it.
44 * The Singular/Plural/Number ngettext dummy definition below was
45 * taken from an email to the texinfo mailing list by Manuel Guerrero.
46 * Thank you Manuel, and thank you Alex's good friend Google.
51 # define _(String) ((const char *)dgettext(PACKAGE, String))
53 # define N_(String) gettext_noop (String)
55 # define N_(String) (String)
59 # define N_(String) (String)
61 # define _(String) ((const char *)String)
63 # define ngettext(Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
64 # define dngettext(Domain, Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
72 /* The above should normally be the same as BUF_LEN,
73 * but just so we're explicitly asking for the max message
75 #define BUF_LEN MSG_LEN
76 #define BUF_LONG BUF_LEN * 2
79 #include <sys/types.h>
98 #ifdef HAVE_LANGINFO_CODESET
104 #ifdef PURPLE_PLUGINS
111 # include <netinet/in.h>
112 # include <sys/socket.h>
113 # include <arpa/inet.h>
115 # include <sys/utsname.h>
121 /* MAXPATHLEN should only be used with readlink() on glib < 2.4.0. For
122 * anything else, use g_file_read_link() or other dynamic functions. This is
123 * important because Hurd has no hard limits on path length. */
124 #if !GLIB_CHECK_VERSION(2,4,0)
127 # define MAXPATHLEN PATH_MAX
129 # define MAXPATHLEN 1024
134 #ifndef HOST_NAME_MAX
135 # define HOST_NAME_MAX 255
139 #if !GLIB_CHECK_VERSION(2,4,0)
140 # define G_MAXUINT32 ((guint32) 0xffffffff)
144 # if GLIB_SIZEOF_LONG == 8
145 # define G_MAXSIZE ((gsize) 0xffffffffffffffff)
147 # define G_MAXSIZE ((gsize) 0xffffffff)
152 # if GLIB_SIZEOF_LONG == 8
153 # define G_MAXSSIZE ((gssize) 0x7fffffffffffffff)
155 # define G_MAXSSIZE ((gssize) 0x7fffffff)
159 #if GLIB_CHECK_VERSION(2,6,0)
160 # include <glib/gstdio.h>
163 #if !GLIB_CHECK_VERSION(2,6,0)
164 # define g_freopen freopen
165 # define g_fopen fopen
166 # define g_rmdir rmdir
167 # define g_remove remove
168 # define g_unlink unlink
169 # define g_lstat lstat
171 # define g_mkdir mkdir
172 # define g_rename rename
176 #if !GLIB_CHECK_VERSION(2,8,0) && !defined _WIN32
177 # define g_access access
180 #if !GLIB_CHECK_VERSION(2,10,0)
181 # define g_slice_new(type) g_new(type, 1)
182 # define g_slice_new0(type) g_new0(type, 1)
183 # define g_slice_free(type, mem) g_free(mem)
187 #include "win32dep.h"
191 /* This is a workaround for the fact that G_GINT64_MODIFIER and G_GSIZE_FORMAT
192 * are only defined in Glib >= 2.4 */
193 #ifndef G_GINT64_MODIFIER
194 # if GLIB_SIZEOF_LONG == 8
195 # define G_GINT64_MODIFIER "l"
197 # define G_GINT64_MODIFIER "ll"
201 #ifndef G_GSIZE_MODIFIER
202 # if GLIB_SIZEOF_LONG == 8
203 # define G_GSIZE_MODIFIER "l"
205 # define G_GSIZE_MODIFIER ""
209 #ifndef G_GSIZE_FORMAT
210 # if GLIB_SIZEOF_LONG == 8
211 # define G_GSIZE_FORMAT "lu"
213 # define G_GSIZE_FORMAT "u"
217 #ifndef G_GSSIZE_FORMAT
218 # if GLIB_SIZEOF_LONG == 8
219 # define G_GSSIZE_FORMAT "li"
221 # define G_GSSIZE_FORMAT "i"
225 #ifndef G_GNUC_NULL_TERMINATED
227 # define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
229 # define G_GNUC_NULL_TERMINATED
234 #if SIZEOF_TIME_T == 4
235 # define PURPLE_TIME_T_MODIFIER "lu"
236 #elif SIZEOF_TIME_T == 8
237 # define PURPLE_TIME_T_MODIFIER "zu"
239 #error Unknown size of time_t
243 #include <glib-object.h>
245 #ifndef G_DEFINE_TYPE
246 #define G_DEFINE_TYPE(TypeName, type_name, TYPE_PARENT) \
248 static void type_name##_init (TypeName *self); \
249 static void type_name##_class_init (TypeName##Class *klass); \
250 static gpointer type_name##_parent_class = NULL; \
251 static void type_name##_class_intern_init (gpointer klass) \
253 type_name##_parent_class = g_type_class_peek_parent (klass); \
254 type_name##_class_init ((TypeName##Class*) klass); \
258 type_name##_get_type (void) \
260 static GType g_define_type_id = 0; \
261 if (G_UNLIKELY (g_define_type_id == 0)) \
264 g_type_register_static_simple (TYPE_PARENT, \
265 g_intern_static_string (#TypeName), \
266 sizeof (TypeName##Class), \
267 (GClassInitFunc)type_name##_class_intern_init, \
269 (GInstanceInitFunc)type_name##_init, \
272 return g_define_type_id; \
273 } /* closes type_name##_get_type() */
277 /* Safer ways to work with static buffers. When using non-static
278 * buffers, either use g_strdup_* functions (preferred) or use
279 * g_strlcpy/g_strlcpy directly. */
280 #define purple_strlcpy(dest, src) g_strlcpy(dest, src, sizeof(dest))
281 #define purple_strlcat(dest, src) g_strlcat(dest, src, sizeof(dest))
283 #define PURPLE_WEBSITE "http://pidgin.im/"
284 #define PURPLE_DEVEL_WEBSITE "http://developer.pidgin.im/"
287 /* INTERNAL FUNCTIONS */
290 #include "connection.h"
292 /* This is for the accounts code to notify the buddy icon code that
293 * it's done loading. We may want to replace this with a signal. */
295 _purple_buddy_icons_account_loaded_cb(void);
297 /* This is for the buddy list to notify the buddy icon code that
298 * it's done loading. We may want to replace this with a signal. */
300 _purple_buddy_icons_blist_loaded_cb(void);
302 /* This is for the purple_core_migrate() code to tell the buddy
303 * icon subsystem about the old icons directory so it can
304 * migrate any icons in use. */
306 _purple_buddy_icon_set_old_icons_dir(const char *dirname);
309 * Creates a connection to the specified account and either connects
310 * or attempts to register a new account. If you are logging in,
311 * the connection uses the current active status for this account.
312 * So if you want to sign on as "away," for example, you need to
313 * have called purple_account_set_status(account, "away").
314 * (And this will call purple_account_connect() automatically).
316 * @note This function should only be called by purple_account_connect()
317 * in account.c. If you're trying to sign on an account, use that
320 * @param account The account the connection should be connecting to.
321 * @param regist Whether we are registering a new account or just
322 * trying to do a normal signon.
323 * @param password The password to use.
325 void _purple_connection_new(PurpleAccount *account, gboolean regist,
326 const char *password);
328 * Tries to unregister the account on the server. If the account is not
329 * connected, also creates a new connection.
331 * @note This function should only be called by purple_account_unregister()
334 * @param account The account to unregister
335 * @param password The password to use.
336 * @param cb Optional callback to be called when unregistration is complete
337 * @param user_data user data to pass to the callback
339 void _purple_connection_new_unregister(PurpleAccount *account, const char *password,
340 PurpleAccountUnregistrationCb cb, void *user_data);
342 * Disconnects and destroys a PurpleConnection.
344 * @note This function should only be called by purple_account_disconnect()
345 * in account.c. If you're trying to sign off an account, use that
348 * @param gc The purple connection to destroy.
350 void _purple_connection_destroy(PurpleConnection *gc);
352 #endif /* _PURPLE_INTERNAL_H_ */