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_PROTOCOLS_H
23 #define PURPLE_PROTOCOLS_H
26 * @section_id: libpurple-protocols
27 * @short_description: <filename>protocols.h</filename>
28 * @title: Protocols Subsystem API
29 * @see_also: <link linkend="chapter-signals-protocol">Protocol signals</link>
32 #define PURPLE_PROTOCOLS_DOMAIN (g_quark_from_static_string("protocols"))
34 /**************************************************************************/
35 /* Basic Protocol Information */
36 /**************************************************************************/
38 typedef struct _PurpleProtocolChatEntry PurpleProtocolChatEntry
;
41 * PurpleProtocolOptions:
42 * @OPT_PROTO_UNIQUE_CHATNAME: User names are unique to a chat and are not
43 * shared between rooms.<sbr/>
44 * XMPP lets you choose what name you want in chats, so it shouldn't
45 * be pulling the aliases from the buddy list for the chat list; it
47 * @OPT_PROTO_CHAT_TOPIC: Chat rooms have topics.<sbr/>
48 * IRC and XMPP support this.
49 * @OPT_PROTO_NO_PASSWORD: Don't require passwords for sign-in.<sbr/>
50 * Zephyr doesn't require passwords, so there's no need for a
52 * @OPT_PROTO_MAIL_CHECK: Notify on new mail.<sbr/>
53 * MSN and Yahoo notify you when you have new mail.
54 * @OPT_PROTO_PASSWORD_OPTIONAL: Allow passwords to be optional.<sbr/>
55 * Passwords in IRC are optional, and are needed for certain
57 * @OPT_PROTO_USE_POINTSIZE: Allows font size to be specified in sane point
59 * Probably just XMPP and Y!M
60 * @OPT_PROTO_REGISTER_NOSCREENNAME: Set the Register button active even when
61 * the username has not been specified.<sbr/>
62 * Gadu-Gadu doesn't need a username to register new account (because
63 * usernames are assigned by the server).
64 * @OPT_PROTO_SLASH_COMMANDS_NATIVE: Indicates that slash commands are native
65 * to this protocol.<sbr/>
66 * Used as a hint that unknown commands should not be sent as
68 * @OPT_PROTO_INVITE_MESSAGE: Indicates that this protocol supports sending a
69 * user-supplied message along with an invitation.
70 * @OPT_PROTO_AUTHORIZATION_GRANTED_MESSAGE: Indicates that this protocol
71 * supports sending a user-supplied message along with an
72 * authorization acceptance.
73 * @OPT_PROTO_AUTHORIZATION_DENIED_MESSAGE: Indicates that this protocol
74 * supports sending a user-supplied message along with an
75 * authorization denial.
79 * These should all be stuff that some protocols can do and others can't.
81 typedef enum /*< flags >*/
83 OPT_PROTO_UNIQUE_CHATNAME
= 0x00000004,
84 OPT_PROTO_CHAT_TOPIC
= 0x00000008,
85 OPT_PROTO_NO_PASSWORD
= 0x00000010,
86 OPT_PROTO_MAIL_CHECK
= 0x00000020,
87 OPT_PROTO_PASSWORD_OPTIONAL
= 0x00000080,
88 OPT_PROTO_USE_POINTSIZE
= 0x00000100,
89 OPT_PROTO_REGISTER_NOSCREENNAME
= 0x00000200,
90 OPT_PROTO_SLASH_COMMANDS_NATIVE
= 0x00000400,
91 OPT_PROTO_INVITE_MESSAGE
= 0x00000800,
92 OPT_PROTO_AUTHORIZATION_GRANTED_MESSAGE
= 0x00001000,
93 OPT_PROTO_AUTHORIZATION_DENIED_MESSAGE
= 0x00002000
95 } PurpleProtocolOptions
;
101 #define PURPLE_TYPE_PROTOCOL_CHAT_ENTRY (purple_protocol_chat_entry_get_type())
104 * PurpleProtocolChatEntry:
105 * @label: User-friendly name of the entry
106 * @identifier: Used by the protocol to identify the option
107 * @required: True if it's required
108 * @is_int: True if the entry expects an integer
109 * @min: Minimum value in case of integer
110 * @max: Maximum value in case of integer
111 * @secret: True if the entry is secret (password)
113 * Represents an entry containing information that must be supplied by the
114 * user when joining a chat.
116 struct _PurpleProtocolChatEntry
{
118 const char *identifier
;
128 /**************************************************************************/
129 /* Attention Type API */
130 /**************************************************************************/
132 /**************************************************************************/
133 /* Protocol Chat Entry API */
134 /**************************************************************************/
137 * purple_protocol_chat_entry_get_type:
139 * Returns: The #GType for the #PurpleProtocolChatEntry boxed structure.
141 GType
purple_protocol_chat_entry_get_type(void);
143 /**************************************************************************/
145 /**************************************************************************/
148 * purple_protocol_got_account_idle:
149 * @account: The account.
150 * @idle: The user's idle state.
151 * @idle_time: The user's idle time.
153 * Notifies Purple that our account's idle state and time have changed.
155 * This is meant to be called from protocols.
157 void purple_protocol_got_account_idle(PurpleAccount
*account
, gboolean idle
,
161 * purple_protocol_got_account_login_time:
162 * @account: The account the user is on.
163 * @login_time: The user's log-in time.
165 * Notifies Purple of our account's log-in time.
167 * This is meant to be called from protocols.
169 void purple_protocol_got_account_login_time(PurpleAccount
*account
,
173 * purple_protocol_got_account_status:
174 * @account: The account the user is on.
175 * @status_id: The status ID.
176 * @...: A NULL-terminated list of attribute IDs and values,
177 * beginning with the value for <literal>attr_id</literal>.
179 * Notifies Purple that our account's status has changed.
181 * This is meant to be called from protocols.
183 void purple_protocol_got_account_status(PurpleAccount
*account
,
184 const char *status_id
, ...)
185 G_GNUC_NULL_TERMINATED
;
188 * purple_protocol_got_account_actions:
189 * @account: The account.
191 * Notifies Purple that our account's actions have changed. This is only
192 * called after the initial connection. Emits the account-actions-changed
195 * This is meant to be called from protocols.
197 * See <link linkend="accounts-account-actions-changed"><literal>"account-actions-changed"</literal></link>
199 void purple_protocol_got_account_actions(PurpleAccount
*account
);
202 * purple_protocol_got_user_idle:
203 * @account: The account the user is on.
204 * @name: The name of the buddy.
205 * @idle: The user's idle state.
206 * @idle_time: The user's idle time. This is the time at
207 * which the user became idle, in seconds since
208 * the epoch. If the protocol does not know this value
209 * then it should pass 0.
211 * Notifies Purple that a buddy's idle state and time have changed.
213 * This is meant to be called from protocols.
215 void purple_protocol_got_user_idle(PurpleAccount
*account
, const char *name
,
216 gboolean idle
, time_t idle_time
);
219 * purple_protocol_got_user_login_time:
220 * @account: The account the user is on.
221 * @name: The name of the buddy.
222 * @login_time: The user's log-in time.
224 * Notifies Purple of a buddy's log-in time.
226 * This is meant to be called from protocols.
228 void purple_protocol_got_user_login_time(PurpleAccount
*account
,
229 const char *name
, time_t login_time
);
232 * purple_protocol_got_user_status:
233 * @account: The account the user is on.
234 * @name: The name of the buddy.
235 * @status_id: The status ID.
236 * @...: A NULL-terminated list of attribute IDs and values,
237 * beginning with the value for <literal>attr_id</literal>.
239 * Notifies Purple that a buddy's status has been activated.
241 * This is meant to be called from protocols.
243 void purple_protocol_got_user_status(PurpleAccount
*account
, const char *name
,
244 const char *status_id
, ...)
245 G_GNUC_NULL_TERMINATED
;
248 * purple_protocol_got_user_status_deactive:
249 * @account: The account the user is on.
250 * @name: The name of the buddy.
251 * @status_id: The status ID.
253 * Notifies libpurple that a buddy's status has been deactivated
255 * This is meant to be called from protocols.
257 void purple_protocol_got_user_status_deactive(PurpleAccount
*account
,
259 const char *status_id
);
262 * purple_protocol_change_account_status:
263 * @account: The account the user is on.
264 * @old_status: The previous status.
265 * @new_status: The status that was activated, or deactivated
266 * (in the case of independent statuses).
268 * Informs the server that our account's status changed.
270 void purple_protocol_change_account_status(PurpleAccount
*account
,
271 PurpleStatus
*old_status
,
272 PurpleStatus
*new_status
);
275 * purple_protocol_get_statuses:
276 * @account: The account the user is on.
277 * @presence: The presence for which we're going to get statuses
279 * Retrieves the list of stock status types from a protocol.
281 * Returns: (transfer full) (element-type PurpleStatus): List of statuses
283 GList
*purple_protocol_get_statuses(PurpleAccount
*account
,
284 PurplePresence
*presence
);
287 * purple_protocol_send_attention:
288 * @gc: The connection to send the message on.
289 * @who: Whose attention to request.
290 * @type_code: An index into the protocol's attention_types list determining the type
291 * of the attention request command to send. 0 if protocol only defines one
292 * (for example, Yahoo and MSN), but protocols are allowed to define more.
294 * Send an attention request message.
296 * Note that you can't send arbitrary PurpleAttentionType's, because there is
297 * only a fixed set of attention commands.
299 void purple_protocol_send_attention(PurpleConnection
*gc
, const char *who
,
303 * purple_protocol_got_attention:
304 * @gc: The connection that received the attention message.
305 * @who: Who requested your attention.
306 * @type_code: An index into the protocol's attention_types list
307 * determining the type of the attention request command to
310 * Process an incoming attention message.
312 void purple_protocol_got_attention(PurpleConnection
*gc
, const char *who
,
316 * purple_protocol_got_attention_in_chat:
317 * @gc: The connection that received the attention message.
319 * @who: Who requested your attention.
320 * @type_code: An index into the protocol's attention_types list
321 * determining the type of the attention request command to
324 * Process an incoming attention message in a chat.
326 void purple_protocol_got_attention_in_chat(PurpleConnection
*gc
, int id
,
327 const char *who
, guint type_code
);
330 * purple_protocol_get_media_caps:
331 * @account: The account the user is on.
332 * @who: The name of the contact to check capabilities for.
334 * Determines if the contact supports the given media session type.
336 * Returns: The media caps the contact supports.
338 PurpleMediaCaps
purple_protocol_get_media_caps(PurpleAccount
*account
,
342 * purple_protocol_initiate_media:
343 * @account: The account the user is on.
344 * @who: The name of the contact to start a session with.
345 * @type: The type of media session to start.
347 * Initiates a media session with the given contact.
349 * Returns: TRUE if the call succeeded else FALSE. (Doesn't imply the media
350 * session or stream will be successfully created)
352 gboolean
purple_protocol_initiate_media(PurpleAccount
*account
,
354 PurpleMediaSessionType type
);
357 * purple_protocol_got_media_caps:
358 * @account: The account the user is on.
359 * @who: The name of the contact for which capabilities have been received.
361 * Signals that the protocol received capabilities for the given contact.
363 * This function is intended to be used only by protocols.
365 void purple_protocol_got_media_caps(PurpleAccount
*account
, const char *who
);
368 * purple_protocol_get_max_message_size:
369 * @protocol: The protocol to query.
371 * Gets the safe maximum message size in bytes for the protocol.
373 * See #PurpleProtocolClientInterface's <literal>get_max_message_size</literal>.
375 * Returns: Maximum message size, 0 if unspecified, -1 for infinite.
378 purple_protocol_get_max_message_size(PurpleProtocol
*protocol
);
380 /**************************************************************************/
382 /**************************************************************************/
385 * purple_protocols_find:
386 * @id: The protocol's ID.
388 * Finds a protocol by ID.
390 * Returns: (transfer none): The protocol, if found, or %NULL otherwise.
392 PurpleProtocol
*purple_protocols_find(const char *id
);
395 * purple_protocols_add:
396 * @protocol_type: The type of the protocol to add.
397 * @error: Return location for a #GError or %NULL. If provided, this
398 * will be set to the reason if adding fails.
400 * Adds a protocol to the list of protocols.
402 * Returns: (transfer none): The protocol instance if the protocol was added,
405 PurpleProtocol
*purple_protocols_add(GType protocol_type
, GError
**error
);
408 * purple_protocols_remove:
409 * @protocol: The protocol to remove.
410 * @error: Return location for a #GError or %NULL. If provided, this
411 * will be set to the reason if removing fails.
413 * Removes a protocol from the list of protocols. This will disconnect all
414 * connected accounts using this protocol, and free the protocol's user splits
415 * and protocol options.
417 * Returns: TRUE if the protocol was removed, else FALSE.
419 gboolean
purple_protocols_remove(PurpleProtocol
*protocol
, GError
**error
);
422 * purple_protocols_get_all:
424 * Returns a list of all loaded protocols.
426 * Returns: (element-type PurpleProtocol) (transfer container): A list of all
429 GList
*purple_protocols_get_all(void);
431 /**************************************************************************/
432 /* Protocols Subsytem API */
433 /**************************************************************************/
436 * purple_protocols_init:
438 * Initializes the protocols subsystem.
440 void purple_protocols_init(void);
443 * purple_protocols_get_handle:
445 * Returns the protocols subsystem handle.
447 * Returns: The protocols subsystem handle.
449 void *purple_protocols_get_handle(void);
452 * purple_protocols_uninit:
454 * Uninitializes the protocols subsystem.
456 void purple_protocols_uninit(void);
460 #endif /* PURPLE_PROTOCOLS_H */