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 #include <glib/gi18n-lib.h>
47 /* The above should normally be the same as BUF_LEN,
48 * but just so we're explicitly asking for the max message
50 #define BUF_LEN MSG_LEN
51 #define BUF_LONG BUF_LEN * 2
53 #include <sys/types.h>
72 #ifdef HAVE_LANGINFO_CODESET
77 # include <netinet/in.h>
78 # include <sys/socket.h>
79 # include <arpa/inet.h>
81 # include <sys/utsname.h>
88 # define HOST_NAME_MAX 255
92 #include <glib/gstdio.h>
95 #include "win32/win32dep.h"
99 #if SIZEOF_TIME_T == 4
100 # define PURPLE_TIME_T_MODIFIER "lu"
101 #elif SIZEOF_TIME_T == 8
102 # define PURPLE_TIME_T_MODIFIER "zu"
104 #error Unknown size of time_t
108 #define PURPLE_STATIC_ASSERT(condition, message) \
109 { typedef char static_assertion_failed_ ## message \
110 [(condition) ? 1 : -1]; static_assertion_failed_ ## message dummy; \
113 /* This is meant to track use-after-free errors.
114 * TODO: it should be disabled in released code. */
115 #define PURPLE_ASSERT_CONNECTION_IS_VALID(gc) \
116 _purple_assert_connection_is_valid(gc, __FILE__, __LINE__)
120 #define PURPLE_BEGIN_IGNORE_CAST_ALIGN \
121 _Pragma ("clang diagnostic push") \
122 _Pragma ("clang diagnostic ignored \"-Wcast-align\"")
124 #define PURPLE_END_IGNORE_CAST_ALIGN \
125 _Pragma ("clang diagnostic pop")
129 #define PURPLE_BEGIN_IGNORE_CAST_ALIGN
130 #define PURPLE_END_IGNORE_CAST_ALIGN
132 #endif /* __clang__ */
134 #include <glib-object.h>
138 /* avoid TAINTED_SCALAR warning */
139 #undef g_utf8_next_char
140 #define g_utf8_next_char(p) (char *)((p) + 1)
147 struct sockaddr_in in
;
148 struct sockaddr_in6 in6
;
149 struct sockaddr_storage storage
;
152 #define PURPLE_WEBSITE "https://pidgin.im/"
153 #define PURPLE_DEVEL_WEBSITE "https://developer.pidgin.im/"
156 /* INTERNAL FUNCTIONS */
158 #include "accounts.h"
159 #include "connection.h"
162 * _purple_account_set_current_error:
163 * @account: The account to set the error for.
164 * @new_err: The #PurpleConnectionErrorInfo instance representing the
167 * Sets an error for an account.
169 void _purple_account_set_current_error(PurpleAccount
*account
,
170 PurpleConnectionErrorInfo
*new_err
);
173 * _purple_account_to_xmlnode:
174 * @account: The account
176 * Get an XML description of an account.
178 * Returns: The XML description of the account.
180 PurpleXmlNode
*_purple_account_to_xmlnode(PurpleAccount
*account
);
183 * _purple_blist_get_last_child:
184 * @node: The node whose last child is to be retrieved.
186 * Returns the last child of a particular node.
188 * Returns: The last child of the node.
190 PurpleBlistNode
*_purple_blist_get_last_child(PurpleBlistNode
*node
);
192 /* This is for the accounts code to notify the buddy icon code that
193 * it's done loading. We may want to replace this with a signal. */
195 _purple_buddy_icons_account_loaded_cb(void);
197 /* This is for the buddy list to notify the buddy icon code that
198 * it's done loading. We may want to replace this with a signal. */
200 _purple_buddy_icons_blist_loaded_cb(void);
203 * _purple_connection_new:
204 * @account: The account the connection should be connecting to.
205 * @regist: Whether we are registering a new account or just
206 * trying to do a normal signon.
207 * @password: The password to use.
209 * Creates a connection to the specified account and either connects
210 * or attempts to register a new account. If you are logging in,
211 * the connection uses the current active status for this account.
212 * So if you want to sign on as "away," for example, you need to
213 * have called purple_account_set_status(account, "away").
214 * (And this will call purple_account_connect() automatically).
216 * Note: This function should only be called by purple_account_connect()
217 * in account.c. If you're trying to sign on an account, use that
220 void _purple_connection_new(PurpleAccount
*account
, gboolean regist
,
221 const char *password
);
223 * _purple_connection_new_unregister:
224 * @account: The account to unregister
225 * @password: The password to use.
226 * @cb: Optional callback to be called when unregistration is complete
227 * @user_data: user data to pass to the callback
229 * Tries to unregister the account on the server. If the account is not
230 * connected, also creates a new connection.
232 * Note: This function should only be called by purple_account_unregister()
235 void _purple_connection_new_unregister(PurpleAccount
*account
, const char *password
,
236 PurpleAccountUnregistrationCb cb
, void *user_data
);
238 * _purple_connection_wants_to_die:
239 * @gc: The connection to check
241 * Checks if a connection is disconnecting, and should not attempt to reconnect.
243 * Note: This function should only be called by purple_account_set_enabled()
246 gboolean
_purple_connection_wants_to_die(PurpleConnection
*gc
);
249 * _purple_connection_add_active_chat:
250 * @gc: The connection
251 * @chat: The chat conversation to add
253 * Adds a chat to the active chats list of a connection
255 * Note: This function should only be called by purple_serv_got_joined_chat()
258 void _purple_connection_add_active_chat(PurpleConnection
*gc
,
259 PurpleChatConversation
*chat
);
261 * _purple_connection_remove_active_chat:
262 * @gc: The connection
263 * @chat: The chat conversation to remove
265 * Removes a chat from the active chats list of a connection
267 * Note: This function should only be called by purple_serv_got_chat_left()
270 void _purple_connection_remove_active_chat(PurpleConnection
*gc
,
271 PurpleChatConversation
*chat
);
274 * _purple_conversations_update_cache:
275 * @conv: The conversation.
276 * @name: The new name. If no change, use %NULL.
277 * @account: The new account. If no change, use %NULL.
279 * Updates the conversation cache to use a new conversation name and/or
280 * account. This function only updates the conversation cache. It is the
281 * caller's responsibility to actually update the conversation.
283 * Note: This function should only be called by purple_conversation_set_name()
284 * and purple_conversation_set_account() in conversation.c.
286 void _purple_conversations_update_cache(PurpleConversation
*conv
,
287 const char *name
, PurpleAccount
*account
);
290 * _purple_statuses_get_primitive_scores:
292 * Note: This function should only be called by
293 * purple_buddy_presence_compute_score() in presence.c.
295 * Returns: The primitive scores array from status.c.
297 int *_purple_statuses_get_primitive_scores(void);
300 * _purple_blist_get_localized_default_group_name:
302 * Returns the name of default group for previously used non-English
303 * localization. It's used for merging default group, in case when roster
304 * contains localized name.
306 * Please note, prpls shouldn't save default group name depending on current
307 * locale. So, this function is mostly for libpurple2 compatibility. And for
308 * improperly written prpls.
311 _purple_blist_get_localized_default_group_name(void);
314 * Sets most commonly used socket flags: O_NONBLOCK and FD_CLOEXEC.
316 * @param fd The file descriptor for the socket.
318 * @return TRUE if succeeded, FALSE otherwise.
321 _purple_network_set_common_socket_flags(int fd
);
324 * A fstat alternative, like g_stat for stat.
326 * @param fd The file descriptor.
327 * @param st The stat buffer.
329 * @return the result just like for fstat.
332 _purple_fstat(int fd
, GStatBuf
*st
);
335 * _purple_message_init: (skip)
337 * Initializes the #PurpleMessage subsystem.
340 _purple_message_init(void);
343 * _purple_message_uninit: (skip)
345 * Uninitializes the #PurpleMessage subsystem.
348 _purple_message_uninit(void);
351 _purple_assert_connection_is_valid(PurpleConnection
*gc
,
352 const gchar
*file
, int line
);
355 * _purple_conversation_write_common:
356 * @conv: The conversation.
359 * Writes to a conversation window.
361 * This function should not be used to write IM or chat messages. Use
362 * purple_conversation_write_message() instead. This function will
363 * most likely call this anyway, but it may do it's own formatting,
364 * sound playback, etc. depending on whether the conversation is a chat or an
367 * See purple_conversation_write_message().
370 _purple_conversation_write_common(PurpleConversation
*conv
, PurpleMessage
*msg
);
372 #endif /* PURPLE_INTERNAL_H */