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_INTERNAL_H_
23 #define _PURPLE_INTERNAL_H_
26 * @section_id: libpurple-internal
27 * @short_description: <filename>internal.h</filename>
28 * @title: Internal definitions and includes
35 /* for SIOCGIFCONF in SKYOS */
37 #include <net/sockios.h>
40 * If we're using NLS, make sure gettext works. If not, then define
41 * dummy macros in place of the normal gettext macros.
43 * Also, the perl XS config.h file sometimes defines _ So we need to
44 * make sure _ isn't already defined before trying to define it.
46 * The Singular/Plural/Number ngettext dummy definition below was
47 * taken from an email to the texinfo mailing list by Manuel Guerrero.
48 * Thank you Manuel, and thank you Alex's good friend Google.
54 # define _(String) ((const char *)dgettext(PACKAGE, String))
56 # define N_(String) gettext_noop (String)
58 # define N_(String) (String)
62 # define N_(String) (String)
64 # define _(String) ((const char *)String)
66 # define ngettext(Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
67 # define dngettext(Domain, Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
75 /* The above should normally be the same as BUF_LEN,
76 * but just so we're explicitly asking for the max message
78 #define BUF_LEN MSG_LEN
79 #define BUF_LONG BUF_LEN * 2
81 #include <sys/types.h>
100 #ifdef HAVE_LANGINFO_CODESET
101 #include <langinfo.h>
105 # include <netinet/in.h>
106 # include <sys/socket.h>
107 # include <arpa/inet.h>
109 # include <sys/utsname.h>
115 #ifndef HOST_NAME_MAX
116 # define HOST_NAME_MAX 255
120 #include <glib/gstdio.h>
123 #include "win32/win32dep.h"
127 #if SIZEOF_TIME_T == 4
128 # define PURPLE_TIME_T_MODIFIER "lu"
129 #elif SIZEOF_TIME_T == 8
130 # define PURPLE_TIME_T_MODIFIER "zu"
132 #error Unknown size of time_t
136 #define PURPLE_STATIC_ASSERT(condition, message) \
137 { typedef char static_assertion_failed_ ## message \
138 [(condition) ? 1 : -1]; static_assertion_failed_ ## message dummy; \
141 /* This is meant to track use-after-free errors.
142 * TODO: it should be disabled in released code. */
143 #define PURPLE_ASSERT_CONNECTION_IS_VALID(gc) \
144 _purple_assert_connection_is_valid(gc, __FILE__, __LINE__)
148 #define PURPLE_BEGIN_IGNORE_CAST_ALIGN \
149 _Pragma ("clang diagnostic push") \
150 _Pragma ("clang diagnostic ignored \"-Wcast-align\"")
152 #define PURPLE_END_IGNORE_CAST_ALIGN \
153 _Pragma ("clang diagnostic pop")
157 #define PURPLE_BEGIN_IGNORE_CAST_ALIGN
158 #define PURPLE_END_IGNORE_CAST_ALIGN
160 #endif /* __clang__ */
162 #include <glib-object.h>
166 /* avoid TAINTED_SCALAR warning */
167 #undef g_utf8_next_char
168 #define g_utf8_next_char(p) (char *)((p) + 1)
175 struct sockaddr_in in
;
176 struct sockaddr_in6 in6
;
177 struct sockaddr_storage storage
;
180 #define PURPLE_WEBSITE "https://pidgin.im/"
181 #define PURPLE_DEVEL_WEBSITE "https://developer.pidgin.im/"
184 /* INTERNAL FUNCTIONS */
186 #include "accounts.h"
187 #include "connection.h"
190 * _purple_account_set_current_error:
191 * @account: The account to set the error for.
192 * @new_err: The #PurpleConnectionErrorInfo instance representing the
195 * Sets an error for an account.
197 void _purple_account_set_current_error(PurpleAccount
*account
,
198 PurpleConnectionErrorInfo
*new_err
);
201 * _purple_account_to_xmlnode:
202 * @account: The account
204 * Get an XML description of an account.
206 * Returns: The XML description of the account.
208 PurpleXmlNode
*_purple_account_to_xmlnode(PurpleAccount
*account
);
211 * _purple_blist_get_last_child:
212 * @node: The node whose last child is to be retrieved.
214 * Returns the last child of a particular node.
216 * Returns: The last child of the node.
218 PurpleBlistNode
*_purple_blist_get_last_child(PurpleBlistNode
*node
);
220 /* This is for the accounts code to notify the buddy icon code that
221 * it's done loading. We may want to replace this with a signal. */
223 _purple_buddy_icons_account_loaded_cb(void);
225 /* This is for the buddy list to notify the buddy icon code that
226 * it's done loading. We may want to replace this with a signal. */
228 _purple_buddy_icons_blist_loaded_cb(void);
231 * _purple_connection_new:
232 * @account: The account the connection should be connecting to.
233 * @regist: Whether we are registering a new account or just
234 * trying to do a normal signon.
235 * @password: The password to use.
237 * Creates a connection to the specified account and either connects
238 * or attempts to register a new account. If you are logging in,
239 * the connection uses the current active status for this account.
240 * So if you want to sign on as "away," for example, you need to
241 * have called purple_account_set_status(account, "away").
242 * (And this will call purple_account_connect() automatically).
244 * Note: This function should only be called by purple_account_connect()
245 * in account.c. If you're trying to sign on an account, use that
248 void _purple_connection_new(PurpleAccount
*account
, gboolean regist
,
249 const char *password
);
251 * _purple_connection_new_unregister:
252 * @account: The account to unregister
253 * @password: The password to use.
254 * @cb: Optional callback to be called when unregistration is complete
255 * @user_data: user data to pass to the callback
257 * Tries to unregister the account on the server. If the account is not
258 * connected, also creates a new connection.
260 * Note: This function should only be called by purple_account_unregister()
263 void _purple_connection_new_unregister(PurpleAccount
*account
, const char *password
,
264 PurpleAccountUnregistrationCb cb
, void *user_data
);
266 * _purple_connection_wants_to_die:
267 * @gc: The connection to check
269 * Checks if a connection is disconnecting, and should not attempt to reconnect.
271 * Note: This function should only be called by purple_account_set_enabled()
274 gboolean
_purple_connection_wants_to_die(const PurpleConnection
*gc
);
277 * _purple_connection_add_active_chat:
278 * @gc: The connection
279 * @chat: The chat conversation to add
281 * Adds a chat to the active chats list of a connection
283 * Note: This function should only be called by purple_serv_got_joined_chat()
286 void _purple_connection_add_active_chat(PurpleConnection
*gc
,
287 PurpleChatConversation
*chat
);
289 * _purple_connection_remove_active_chat:
290 * @gc: The connection
291 * @chat: The chat conversation to remove
293 * Removes a chat from the active chats list of a connection
295 * Note: This function should only be called by purple_serv_got_chat_left()
298 void _purple_connection_remove_active_chat(PurpleConnection
*gc
,
299 PurpleChatConversation
*chat
);
302 * _purple_conversations_update_cache:
303 * @conv: The conversation.
304 * @name: The new name. If no change, use %NULL.
305 * @account: The new account. If no change, use %NULL.
307 * Updates the conversation cache to use a new conversation name and/or
308 * account. This function only updates the conversation cache. It is the
309 * caller's responsibility to actually update the conversation.
311 * Note: This function should only be called by purple_conversation_set_name()
312 * and purple_conversation_set_account() in conversation.c.
314 void _purple_conversations_update_cache(PurpleConversation
*conv
,
315 const char *name
, PurpleAccount
*account
);
318 * _purple_statuses_get_primitive_scores:
320 * Note: This function should only be called by
321 * purple_buddy_presence_compute_score() in presence.c.
323 * Returns: The primitive scores array from status.c.
325 int *_purple_statuses_get_primitive_scores(void);
328 * _purple_blist_get_localized_default_group_name:
330 * Returns the name of default group for previously used non-English
331 * localization. It's used for merging default group, in case when roster
332 * contains localized name.
334 * Please note, prpls shouldn't save default group name depending on current
335 * locale. So, this function is mostly for libpurple2 compatibility. And for
336 * improperly written prpls.
339 _purple_blist_get_localized_default_group_name(void);
342 * Sets most commonly used socket flags: O_NONBLOCK and FD_CLOEXEC.
344 * @param fd The file descriptor for the socket.
346 * @return TRUE if succeeded, FALSE otherwise.
349 _purple_network_set_common_socket_flags(int fd
);
352 * A fstat alternative, like g_stat for stat.
354 * @param fd The file descriptor.
355 * @param st The stat buffer.
357 * @return the result just like for fstat.
360 _purple_fstat(int fd
, GStatBuf
*st
);
363 * _purple_message_init: (skip)
365 * Initializes the #PurpleMessage subsystem.
368 _purple_message_init(void);
371 * _purple_message_uninit: (skip)
373 * Uninitializes the #PurpleMessage subsystem.
376 _purple_message_uninit(void);
379 _purple_assert_connection_is_valid(PurpleConnection
*gc
,
380 const gchar
*file
, int line
);
383 * _purple_conversation_write_common:
384 * @conv: The conversation.
387 * Writes to a conversation window.
389 * This function should not be used to write IM or chat messages. Use
390 * purple_conversation_write_message() instead. This function will
391 * most likely call this anyway, but it may do it's own formatting,
392 * sound playback, etc. depending on whether the conversation is a chat or an
395 * See purple_conversation_write_message().
398 _purple_conversation_write_common(PurpleConversation
*conv
, PurpleMessage
*msg
);
400 #endif /* _PURPLE_INTERNAL_H_ */