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_PROTOCOL_H_
23 #define _PURPLE_PROTOCOL_H_
26 * @section_id: libpurple-protocol
27 * @short_description: <filename>protocol.h</filename>
28 * @title: Protocol Object and Interfaces
31 #define PURPLE_TYPE_PROTOCOL (purple_protocol_get_type())
32 #define PURPLE_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_PROTOCOL, PurpleProtocol))
33 #define PURPLE_PROTOCOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_PROTOCOL, PurpleProtocolClass))
34 #define PURPLE_IS_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL))
35 #define PURPLE_IS_PROTOCOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_PROTOCOL))
36 #define PURPLE_PROTOCOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_PROTOCOL, PurpleProtocolClass))
38 typedef struct _PurpleProtocol PurpleProtocol
;
39 typedef struct _PurpleProtocolClass PurpleProtocolClass
;
42 #include "accountopt.h"
43 #include "buddyicon.h"
44 #include "buddylist.h"
45 #include "connection.h"
46 #include "conversations.h"
56 #include "whiteboard.h"
59 * PurpleProtocolOverrideFlags:
61 * Flags to indicate what base protocol's data a derived protocol wants to
64 * See purple_protocol_override().
66 typedef enum /*< flags >*/
68 PURPLE_PROTOCOL_OVERRIDE_USER_SPLITS
= 1 << 1,
69 PURPLE_PROTOCOL_OVERRIDE_PROTOCOL_OPTIONS
= 1 << 2,
70 PURPLE_PROTOCOL_OVERRIDE_ICON_SPEC
= 1 << 3,
71 } PurpleProtocolOverrideFlags
;
76 * @name: Translated name of the protocol
77 * @options: Protocol options
78 * @user_splits: A GList of PurpleAccountUserSplit
79 * @account_options: A GList of PurpleAccountOption
80 * @icon_spec: The icon spec.
81 * @whiteboard_ops: Whiteboard operations
83 * Represents an instance of a protocol registered with the protocols
84 * subsystem. Protocols must initialize the members to appropriate values.
86 struct _PurpleProtocol
94 PurpleProtocolOptions options
;
97 GList
*account_options
;
99 PurpleBuddyIconSpec
*icon_spec
;
100 PurpleWhiteboardOps
*whiteboard_ops
;
103 void (*_purple_reserved1
)(void);
104 void (*_purple_reserved2
)(void);
105 void (*_purple_reserved3
)(void);
106 void (*_purple_reserved4
)(void);
110 * PurpleProtocolClass:
111 * @login: Log in to the server.
112 * @close: Close connection with the server.
113 * @status_types: Returns a list of #PurpleStatusType which exist for this
114 * account; and must add at least the offline and online states.
115 * @list_icon: Returns the base icon name for the given buddy and account. If
116 * buddy is %NULL and the account is non-%NULL, it will return
117 * the name to use for the account's icon. If both are %NULL, it
118 * will return the name to use for the protocol's icon.
120 * The base class for all protocols.
122 * All protocol types must implement the methods in this class.
124 /* If adding new methods to this class, ensure you add checks for them in
125 purple_protocols_add().
127 struct _PurpleProtocolClass
129 GObjectClass parent_class
;
131 void (*login
)(PurpleAccount
*);
133 void (*close
)(PurpleConnection
*);
135 GList
*(*status_types
)(PurpleAccount
*account
);
137 const char *(*list_icon
)(PurpleAccount
*account
, PurpleBuddy
*buddy
);
140 void (*_purple_reserved1
)(void);
141 void (*_purple_reserved2
)(void);
142 void (*_purple_reserved3
)(void);
143 void (*_purple_reserved4
)(void);
146 #define PURPLE_TYPE_PROTOCOL_CLIENT_IFACE (purple_protocol_client_iface_get_type())
148 typedef struct _PurpleProtocolClientIface PurpleProtocolClientIface
;
151 * PurpleProtocolClientIface:
152 * @get_actions: Returns the actions the protocol can perform. These will
153 * show up in the Accounts menu, under a submenu with the name
155 * @list_emblem: Fills the four <type>char**</type>'s with string
156 * identifiers for "emblems" that the UI will interpret and
157 * display as relevant
158 * @status_text: Gets a short string representing this buddy's status. This
159 * will be shown on the buddy list.
160 * @tooltip_text: Allows the protocol to add text to a buddy's tooltip.
161 * @blist_node_menu: Returns a list of #PurpleMenuAction structs, which
162 * represent extra actions to be shown in (for example) the
163 * right-click menu for @node.
164 * @normalize: Convert the username @who to its canonical form. Also checks for
166 * <sbr/>For example, AIM treats "fOo BaR" and "foobar" as the same
167 * user; this function should return the same normalized string for
168 * both of those. On the other hand, both of these are invalid for
169 * protocols with number-based usernames, so function should return
170 * %NULL in such case.
171 * <sbr/>@account: The account the username is related to. Can be
173 * <sbr/>@who: The username to convert.
174 * <sbr/>Returns: Normalized username, or %NULL, if it's invalid.
175 * @offline_message: Checks whether offline messages to @buddy are supported.
176 * <sbr/>Returns: %TRUE if @buddy can be sent messages while
177 * they are offline, or %FALSE if not.
178 * @get_account_text_table: This allows protocols to specify additional strings
179 * to be used for various purposes. The idea is to
180 * stuff a bunch of strings in this hash table instead
181 * of expanding the struct for every addition. This
182 * hash table is allocated every call and
183 * <emphasis>MUST</emphasis> be unrefed by the caller.
184 * <sbr/>@account: The account to specify. This can be
186 * <sbr/>Returns: The protocol's string hash table.
187 * The hash table should be destroyed
188 * by the caller when it's no longer
190 * @get_moods: Returns an array of #PurpleMood's, with the last one having
191 * "mood" set to %NULL.
192 * @get_max_message_size: Gets the maximum message size in bytes for the
194 * <sbr/>It may depend on connection-specific or
195 * conversation-specific variables, like channel or
196 * buddy's name length.
197 * <sbr/>This value is intended for plaintext message,
198 * the exact value may be lower because of:
199 * <sbr/> - used newlines (some protocols count them as
200 * more than one byte),
201 * <sbr/> - formatting,
202 * <sbr/> - used special characters.
203 * <sbr/>@conv: The conversation to query, or NULL to
204 * get safe minimum for the protocol.
205 * <sbr/>Returns: Maximum message size, 0 if unspecified,
208 * The protocol client interface.
210 * This interface provides a gateway between purple and the protocol.
212 struct _PurpleProtocolClientIface
215 GTypeInterface parent_iface
;
218 GList
*(*get_actions
)(PurpleConnection
*);
220 const char *(*list_emblem
)(PurpleBuddy
*buddy
);
222 char *(*status_text
)(PurpleBuddy
*buddy
);
224 void (*tooltip_text
)(PurpleBuddy
*buddy
, PurpleNotifyUserInfo
*user_info
,
227 GList
*(*blist_node_menu
)(PurpleBlistNode
*node
);
229 void (*buddy_free
)(PurpleBuddy
*);
231 void (*convo_closed
)(PurpleConnection
*, const char *who
);
233 const char *(*normalize
)(const PurpleAccount
*account
, const char *who
);
235 PurpleChat
*(*find_blist_chat
)(PurpleAccount
*account
, const char *name
);
237 gboolean (*offline_message
)(const PurpleBuddy
*buddy
);
239 GHashTable
*(*get_account_text_table
)(PurpleAccount
*account
);
241 PurpleMood
*(*get_moods
)(PurpleAccount
*account
);
243 gssize (*get_max_message_size
)(PurpleConversation
*conv
);
246 #define PURPLE_PROTOCOL_HAS_CLIENT_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_CLIENT_IFACE))
247 #define PURPLE_PROTOCOL_GET_CLIENT_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_CLIENT_IFACE, \
248 PurpleProtocolClientIface))
250 #define PURPLE_TYPE_PROTOCOL_SERVER_IFACE (purple_protocol_server_iface_get_type())
252 typedef struct _PurpleProtocolServerIface PurpleProtocolServerIface
;
255 * PurpleProtocolServerIface:
256 * @register_user: New user registration
257 * @unregister_user: Remove the user from the server. The account can either be
258 * connected or disconnected. After the removal is finished,
259 * the connection will stay open and has to be closed!
260 * @get_info: Should arrange for purple_notify_userinfo() to be called
261 * with @who's user info.
262 * @add_buddy: Add a buddy to a group on the server.
263 * <sbr/>This protocol function may be called in situations in
264 * which the buddy is already in the specified group. If the
265 * protocol supports authorization and the user is not already
266 * authorized to see the status of @buddy, @add_buddy should
267 * request authorization.
268 * <sbr/>If authorization is required, then use the supplied
270 * @keepalive: If implemented, this will be called regularly for this
271 * protocol's active connections. You'd want to do this if you
272 * need to repeatedly send some kind of keepalive packet to
273 * the server to avoid being disconnected. ("Regularly" is
274 * defined by <literal>KEEPALIVE_INTERVAL</literal> in
275 * <filename>libpurple/connection.c</filename>.)
276 * @alias_buddy: Save/store buddy's alias on server list/roster
277 * @group_buddy: Change a buddy's group on a server list/roster
278 * @rename_group: Rename a group on a server list/roster
279 * @set_buddy_icon: Set the buddy icon for the given connection to @img. The
280 * protocol does <emphasis>NOT</emphasis> own a reference to
281 * @img; if it needs one, it must #g_object_ref(@img)
283 * @send_raw: For use in plugins that may understand the underlying
285 * @set_public_alias: Set the user's "friendly name" (or alias or nickname or
286 * whatever term you want to call it) on the server. The
287 * protocol should call @success_cb or @failure_cb
288 * <emphasis>asynchronously</emphasis> (if it knows
289 * immediately that the set will fail, call one of the
290 * callbacks from an idle/0-second timeout) depending on if
291 * the nickname is set successfully. See
292 * purple_account_set_public_alias().
293 * <sbr/>@gc: The connection for which to set an alias
294 * <sbr/>@alias: The new server-side alias/nickname for this
295 * account, or %NULL to unset the
296 * alias/nickname (or return it to a
297 * protocol-specific "default").
298 * <sbr/>@success_cb: Callback to be called if the public
300 * <sbr/>@failure_cb: Callback to be called if setting the
302 * @get_public_alias: Retrieve the user's "friendly name" as set on the server.
303 * The protocol should call @success_cb or @failure_cb
304 * <emphasis>asynchronously</emphasis> (even if it knows
305 * immediately that the get will fail, call one of the
306 * callbacks from an idle/0-second timeout) depending on if
307 * the nickname is retrieved. See
308 * purple_account_get_public_alias().
309 * <sbr/>@gc: The connection for which to retireve
311 * <sbr/>@success_cb: Callback to be called with the
313 * <sbr/>@failure_cb: Callback to be called if the protocol
314 * is unable to retrieve the alias
316 * The protocol server interface.
318 * This interface provides a gateway between purple and the protocol's server.
320 struct _PurpleProtocolServerIface
323 GTypeInterface parent_iface
;
326 void (*register_user
)(PurpleAccount
*);
328 void (*unregister_user
)(PurpleAccount
*, PurpleAccountUnregistrationCb cb
,
331 void (*set_info
)(PurpleConnection
*, const char *info
);
333 void (*get_info
)(PurpleConnection
*, const char *who
);
335 void (*set_status
)(PurpleAccount
*account
, PurpleStatus
*status
);
337 void (*set_idle
)(PurpleConnection
*, int idletime
);
339 void (*change_passwd
)(PurpleConnection
*, const char *old_pass
,
340 const char *new_pass
);
342 void (*add_buddy
)(PurpleConnection
*pc
, PurpleBuddy
*buddy
,
343 PurpleGroup
*group
, const char *message
);
345 void (*add_buddies
)(PurpleConnection
*pc
, GList
*buddies
, GList
*groups
,
346 const char *message
);
348 void (*remove_buddy
)(PurpleConnection
*, PurpleBuddy
*buddy
,
351 void (*remove_buddies
)(PurpleConnection
*, GList
*buddies
, GList
*groups
);
353 void (*keepalive
)(PurpleConnection
*);
355 void (*alias_buddy
)(PurpleConnection
*, const char *who
,
358 void (*group_buddy
)(PurpleConnection
*, const char *who
,
359 const char *old_group
, const char *new_group
);
361 void (*rename_group
)(PurpleConnection
*, const char *old_name
,
362 PurpleGroup
*group
, GList
*moved_buddies
);
364 void (*set_buddy_icon
)(PurpleConnection
*, PurpleImage
*img
);
366 void (*remove_group
)(PurpleConnection
*gc
, PurpleGroup
*group
);
368 int (*send_raw
)(PurpleConnection
*gc
, const char *buf
, int len
);
370 void (*set_public_alias
)(PurpleConnection
*gc
, const char *alias
,
371 PurpleSetPublicAliasSuccessCallback success_cb
,
372 PurpleSetPublicAliasFailureCallback failure_cb
);
374 void (*get_public_alias
)(PurpleConnection
*gc
,
375 PurpleGetPublicAliasSuccessCallback success_cb
,
376 PurpleGetPublicAliasFailureCallback failure_cb
);
379 #define PURPLE_PROTOCOL_HAS_SERVER_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_SERVER_IFACE))
380 #define PURPLE_PROTOCOL_GET_SERVER_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_SERVER_IFACE, \
381 PurpleProtocolServerIface))
383 #define PURPLE_TYPE_PROTOCOL_IM_IFACE (purple_protocol_im_iface_get_type())
385 typedef struct _PurpleProtocolIMIface PurpleProtocolIMIface
;
388 * PurpleProtocolIMIface:
389 * @send: This protocol function should return a positive value on
390 * success. If the message is too big to be sent, return
391 * <literal>-E2BIG</literal>. If the account is not connected,
392 * return <literal>-ENOTCONN</literal>. If the protocol is unable
393 * to send the message for another reason, return some other
394 * negative value. You can use one of the valid #errno values, or
395 * just big something. If the message should not be echoed to the
396 * conversation window, return 0.
397 * @send_typing: If this protocol requires the #PURPLE_IM_TYPING message to be
398 * sent repeatedly to signify that the user is still typing, then
399 * the protocol should return the number of seconds to wait before
400 * sending a subsequent notification. Otherwise the protocol
403 * The protocol IM interface.
405 * This interface provides callbacks needed by protocols that implement IMs.
407 struct _PurpleProtocolIMIface
410 GTypeInterface parent_iface
;
413 int (*send
)(PurpleConnection
*, PurpleMessage
*msg
);
415 unsigned int (*send_typing
)(PurpleConnection
*, const char *name
,
416 PurpleIMTypingState state
);
419 #define PURPLE_PROTOCOL_HAS_IM_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_IM_IFACE))
420 #define PURPLE_PROTOCOL_GET_IM_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_IM_IFACE, \
421 PurpleProtocolIMIface))
423 #define PURPLE_TYPE_PROTOCOL_CHAT_IFACE (purple_protocol_chat_iface_get_type())
425 typedef struct _PurpleProtocolChatIface PurpleProtocolChatIface
;
428 * PurpleProtocolChatIface:
429 * @info: Returns a list of #PurpleProtocolChatEntry structs, which represent
430 * information required by the protocol to join a chat. libpurple will
431 * call join_chat along with the information filled by the user.
432 * <sbr/>Returns: A list of #PurpleProtocolChatEntry's
433 * @info_defaults: Returns a hashtable which maps #PurpleProtocolChatEntry
434 * struct identifiers to default options as strings based on
435 * @chat_name. The resulting hashtable should be created with
436 * #g_hash_table_new_full(#g_str_hash, #g_str_equal, %NULL,
437 * #g_free). Use @get_name if you instead need to extract a chat
438 * name from a hashtable.
439 * <sbr/>@chat_name: The chat name to be turned into components
440 * <sbr/>Returns: Hashtable containing the information extracted
442 * @join: Called when the user requests joining a chat. Should arrange for
443 * purple_serv_got_joined_chat() to be called.
444 * <sbr/>@components: A hashtable containing information required to join
445 * the chat as described by the entries returned by
446 * @info. It may also be called when accepting an
447 * invitation, in which case this matches the data
448 * parameter passed to purple_serv_got_chat_invite().
449 * @reject: Called when the user refuses a chat invitation.
450 * <sbr/>@components: A hashtable containing information required to
451 * join the chat as passed to purple_serv_got_chat_invite().
452 * @get_name: Returns a chat name based on the information in components. Use
453 * @info_defaults if you instead need to generate a hashtable from a
455 * <sbr/>@components: A hashtable containing information about the
457 * @invite: Invite a user to join a chat.
458 * <sbr/>@id: The id of the chat to invite the user to.
459 * <sbr/>@message: A message displayed to the user when the invitation
461 * <sbr/>@who: The name of the user to send the invation to.
462 * @leave: Called when the user requests leaving a chat.
463 * <sbr/>@id: The id of the chat to leave
464 * @send: Send a message to a chat.
465 * <sbr/>This protocol function should return a positive value on
466 * success. If the message is too big to be sent, return
467 * <literal>-E2BIG</literal>. If the account is not connected,
468 * return <literal>-ENOTCONN</literal>. If the protocol is unable
469 * to send the message for another reason, return some other
470 * negative value. You can use one of the valid #errno values, or
471 * just big something.
472 * <sbr/>@id: The id of the chat to send the message to.
473 * <sbr/>@msg: The message to send to the chat.
474 * <sbr/>Returns: A positive number or 0 in case of success, a
475 * negative error number in case of failure.
476 * @get_user_real_name: Gets the real name of a participant in a chat. For
477 * example, on XMPP this turns a chat room nick
478 * <literal>foo</literal> into
479 * <literal>room\@server/foo</literal>.
480 * <sbr/>@gc: the connection on which the room is.
481 * <sbr/>@id: the ID of the chat room.
482 * <sbr/>@who: the nickname of the chat participant.
483 * <sbr/>Returns: the real name of the participant. This
484 * string must be freed by the caller.
486 * The protocol chat interface.
488 * This interface provides callbacks needed by protocols that implement chats.
490 struct _PurpleProtocolChatIface
493 GTypeInterface parent_iface
;
496 GList
*(*info
)(PurpleConnection
*);
498 GHashTable
*(*info_defaults
)(PurpleConnection
*, const char *chat_name
);
500 void (*join
)(PurpleConnection
*, GHashTable
*components
);
502 void (*reject
)(PurpleConnection
*, GHashTable
*components
);
504 char *(*get_name
)(GHashTable
*components
);
506 void (*invite
)(PurpleConnection
*, int id
,
507 const char *message
, const char *who
);
509 void (*leave
)(PurpleConnection
*, int id
);
511 int (*send
)(PurpleConnection
*, int id
, PurpleMessage
*msg
);
513 char *(*get_user_real_name
)(PurpleConnection
*gc
, int id
, const char *who
);
515 void (*set_topic
)(PurpleConnection
*gc
, int id
, const char *topic
);
518 #define PURPLE_PROTOCOL_HAS_CHAT_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_CHAT_IFACE))
519 #define PURPLE_PROTOCOL_GET_CHAT_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_CHAT_IFACE, \
520 PurpleProtocolChatIface))
522 #define PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE (purple_protocol_privacy_iface_get_type())
524 typedef struct _PurpleProtocolPrivacyIface PurpleProtocolPrivacyIface
;
527 * PurpleProtocolPrivacyIface:
528 * @add_permit: Add the buddy on the required authorized list.
529 * @add_deny: Add the buddy on the required blocked list.
530 * @rem_permit: Remove the buddy from the requried authorized list.
531 * @rem_deny: Remove the buddy from the required blocked list.
532 * @set_permit_deny:Update the server with the privacy information on the permit and deny lists.
534 * The protocol privacy interface.
536 * This interface provides privacy callbacks such as to permit/deny users.
538 struct _PurpleProtocolPrivacyIface
541 GTypeInterface parent_iface
;
544 void (*add_permit
)(PurpleConnection
*gc
, const char *name
);
546 void (*add_deny
)(PurpleConnection
*gc
, const char *name
);
548 void (*rem_permit
)(PurpleConnection
*gc
, const char *name
);
550 void (*rem_deny
)(PurpleConnection
*gc
, const char *name
);
552 void (*set_permit_deny
)(PurpleConnection
*gc
);
555 #define PURPLE_PROTOCOL_HAS_PRIVACY_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE))
556 #define PURPLE_PROTOCOL_GET_PRIVACY_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE, \
557 PurpleProtocolPrivacyIface))
559 #define PURPLE_TYPE_PROTOCOL_XFER_IFACE (purple_protocol_xfer_iface_get_type())
561 typedef struct _PurpleProtocolXferIface PurpleProtocolXferIface
;
564 * PurpleProtocolXferIface:
566 * The protocol file transfer interface.
568 * This interface provides file transfer callbacks for the protocol.
570 struct _PurpleProtocolXferIface
573 GTypeInterface parent_iface
;
576 gboolean (*can_receive
)(PurpleConnection
*, const char *who
);
578 void (*send
)(PurpleConnection
*, const char *who
,
579 const char *filename
);
581 PurpleXfer
*(*new_xfer
)(PurpleConnection
*, const char *who
);
584 #define PURPLE_PROTOCOL_HAS_XFER_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_XFER_IFACE))
585 #define PURPLE_PROTOCOL_GET_XFER_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_XFER_IFACE, \
586 PurpleProtocolXferIface))
588 #define PURPLE_TYPE_PROTOCOL_ROOMLIST_IFACE (purple_protocol_roomlist_iface_get_type())
590 typedef struct _PurpleProtocolRoomlistIface PurpleProtocolRoomlistIface
;
593 * PurpleProtocolRoomlistIface:
595 * The protocol roomlist interface.
597 * This interface provides callbacks for room listing.
599 struct _PurpleProtocolRoomlistIface
602 GTypeInterface parent_iface
;
605 PurpleRoomlist
*(*get_list
)(PurpleConnection
*gc
);
607 void (*cancel
)(PurpleRoomlist
*list
);
609 void (*expand_category
)(PurpleRoomlist
*list
,
610 PurpleRoomlistRoom
*category
);
612 /* room list serialize */
613 char *(*room_serialize
)(PurpleRoomlistRoom
*room
);
616 #define PURPLE_PROTOCOL_HAS_ROOMLIST_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_ROOMLIST_IFACE))
617 #define PURPLE_PROTOCOL_GET_ROOMLIST_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_ROOMLIST_IFACE, \
618 PurpleProtocolRoomlistIface))
620 #define PURPLE_TYPE_PROTOCOL_ATTENTION_IFACE (purple_protocol_attention_iface_get_type())
622 typedef struct _PurpleProtocolAttentionIface PurpleProtocolAttentionIface
;
625 * PurpleProtocolAttentionIface:
627 * The protocol attention interface.
629 * This interface provides attention API for sending and receiving
630 * zaps/nudges/buzzes etc.
632 struct _PurpleProtocolAttentionIface
635 GTypeInterface parent_iface
;
638 gboolean (*send
)(PurpleConnection
*gc
, const char *username
,
641 GList
*(*get_types
)(PurpleAccount
*acct
);
644 #define PURPLE_PROTOCOL_HAS_ATTENTION_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_ATTENTION_IFACE))
645 #define PURPLE_PROTOCOL_GET_ATTENTION_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_ATTENTION_IFACE, \
646 PurpleProtocolAttentionIface))
648 #define PURPLE_TYPE_PROTOCOL_MEDIA_IFACE (purple_protocol_media_iface_get_type())
650 typedef struct _PurpleProtocolMediaIface PurpleProtocolMediaIface
;
653 * PurpleProtocolMediaIface:
654 * @initiate_session: Initiate a media session with the given contact.
655 * <sbr/>@account: The account to initiate the media session
657 * <sbr/>@who: The remote user to initiate the session with.
658 * <sbr/>@type: The type of media session to initiate.
659 * <sbr/>Returns: %TRUE if the call succeeded else %FALSE.
660 * (Doesn't imply the media session or stream
661 * will be successfully created)
662 * @get_caps: Checks to see if the given contact supports the given type of
664 * <sbr/>@account: The account the contact is on.
665 * <sbr/>@who: The remote user to check for media capability with.
666 * <sbr/>Returns: The media caps the contact supports.
667 * @send_dtmf: Sends DTMF codes out-of-band in a protocol-specific way if the
668 * protocol supports it, or failing that in-band if the media backend
669 * can do so. See purple_media_send_dtmf().
671 * The protocol media interface.
673 * This interface provides callbacks for media sessions on the protocol.
675 struct _PurpleProtocolMediaIface
678 GTypeInterface parent_iface
;
681 gboolean (*initiate_session
)(PurpleAccount
*account
, const char *who
,
682 PurpleMediaSessionType type
);
684 PurpleMediaCaps (*get_caps
)(PurpleAccount
*account
,
687 gboolean (*send_dtmf
)(PurpleMedia
*media
, gchar dtmf
,
688 guint8 volume
, guint8 duration
);
691 #define PURPLE_PROTOCOL_HAS_MEDIA_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_MEDIA_IFACE))
692 #define PURPLE_PROTOCOL_GET_MEDIA_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_MEDIA_IFACE, \
693 PurpleProtocolMediaIface))
695 #define PURPLE_TYPE_PROTOCOL_FACTORY_IFACE (purple_protocol_factory_iface_get_type())
697 typedef struct _PurpleProtocolFactoryIface PurpleProtocolFactoryIface
;
700 * PurpleProtocolFactoryIface:
701 * @connection_new: Creates a new protocol-specific connection object that
702 * inherits #PurpleConnection.
703 * @roomlist_new: Creates a new protocol-specific room list object that
704 * inherits #PurpleRoomlist.
705 * @whiteboard_new: Creates a new protocol-specific whiteboard object that
706 * inherits #PurpleWhiteboard.
707 * @xfer_new: Creates a new protocol-specific file transfer object that
708 * inherits #PurpleXfer.
710 * The protocol factory interface.
712 * This interface provides callbacks for construction of protocol-specific
713 * subclasses of some purple objects.
715 struct _PurpleProtocolFactoryIface
718 GTypeInterface parent_iface
;
721 PurpleConnection
*(*connection_new
)(PurpleProtocol
*protocol
,
722 PurpleAccount
*account
,
723 const char *password
);
725 PurpleRoomlist
*(*roomlist_new
)(PurpleAccount
*account
);
727 PurpleWhiteboard
*(*whiteboard_new
)(PurpleAccount
*account
,
728 const char *who
, int state
);
730 PurpleXfer
*(*xfer_new
)(PurpleAccount
*account
, PurpleXferType type
,
734 #define PURPLE_PROTOCOL_HAS_FACTORY_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_FACTORY_IFACE))
735 #define PURPLE_PROTOCOL_GET_FACTORY_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_FACTORY_IFACE, \
736 PurpleProtocolFactoryIface))
739 * PURPLE_PROTOCOL_IMPLEMENTS:
740 * @protocol: The protocol in which to check
741 * @IFACE: The interface name in caps. e.g. <literal>CLIENT_IFACE</literal>
742 * @func: The function to check
744 * Returns: %TRUE if a protocol implements a function in an interface,
747 #define PURPLE_PROTOCOL_IMPLEMENTS(protocol, IFACE, func) \
748 (PURPLE_PROTOCOL_HAS_##IFACE(protocol) && \
749 PURPLE_PROTOCOL_GET_##IFACE(protocol)->func != NULL)
753 /**************************************************************************/
754 /* Protocol Object API */
755 /**************************************************************************/
758 * purple_protocol_get_type:
760 * Returns: The #GType for #PurpleProtocol.
762 GType
purple_protocol_get_type(void);
765 * purple_protocol_get_id:
766 * @protocol: The protocol.
768 * Returns the ID of a protocol.
770 * Returns: The ID of the protocol.
772 const char *purple_protocol_get_id(const PurpleProtocol
*protocol
);
775 * purple_protocol_get_name:
776 * @protocol: The protocol.
778 * Returns the translated name of a protocol.
780 * Returns: The translated name of the protocol.
782 const char *purple_protocol_get_name(const PurpleProtocol
*protocol
);
785 * purple_protocol_get_options:
786 * @protocol: The protocol.
788 * Returns the options of a protocol.
790 * Returns: The options of the protocol.
792 PurpleProtocolOptions
purple_protocol_get_options(const PurpleProtocol
*protocol
);
795 * purple_protocol_get_user_splits:
796 * @protocol: The protocol.
798 * Returns the user splits of a protocol.
800 * Returns: The user splits of the protocol.
802 GList
*purple_protocol_get_user_splits(const PurpleProtocol
*protocol
);
805 * purple_protocol_get_account_options:
806 * @protocol: The protocol.
808 * Returns the account options for a protocol.
810 * Returns: The account options for the protocol.
812 GList
*purple_protocol_get_account_options(const PurpleProtocol
*protocol
);
815 * purple_protocol_get_icon_spec:
816 * @protocol: The protocol.
818 * Returns the icon spec of a protocol.
820 * Returns: The icon spec of the protocol.
822 PurpleBuddyIconSpec
*purple_protocol_get_icon_spec(const PurpleProtocol
*protocol
);
825 * purple_protocol_get_whiteboard_ops:
826 * @protocol: The protocol.
828 * Returns the whiteboard ops of a protocol.
830 * Returns: The whiteboard ops of the protocol.
832 PurpleWhiteboardOps
*purple_protocol_get_whiteboard_ops(const PurpleProtocol
*protocol
);
835 * purple_protocol_override:
836 * @protocol: The protocol instance.
837 * @flags: What instance data to delete.
839 * Lets derived protocol types override the base type's instance data, such as
840 * protocol options, user splits, icon spec, etc.
841 * This function is called in the *_init() function of your derived protocol,
842 * to delete the parent type's data so you can define your own.
844 void purple_protocol_override(PurpleProtocol
*protocol
,
845 PurpleProtocolOverrideFlags flags
);
847 /**************************************************************************/
848 /* Protocol Class API */
849 /**************************************************************************/
851 void purple_protocol_class_login(PurpleProtocol
*, PurpleAccount
*);
853 void purple_protocol_class_close(PurpleProtocol
*, PurpleConnection
*);
855 GList
*purple_protocol_class_status_types(PurpleProtocol
*,
856 PurpleAccount
*account
);
858 const char *purple_protocol_class_list_icon(PurpleProtocol
*,
859 PurpleAccount
*account
, PurpleBuddy
*buddy
);
861 /**************************************************************************/
862 /* Protocol Client Interface API */
863 /**************************************************************************/
866 * purple_protocol_client_iface_get_type:
868 * Returns: The #GType for the protocol client interface.
870 GType
purple_protocol_client_iface_get_type(void);
872 GList
*purple_protocol_client_iface_get_actions(PurpleProtocol
*,
875 const char *purple_protocol_client_iface_list_emblem(PurpleProtocol
*,
878 char *purple_protocol_client_iface_status_text(PurpleProtocol
*,
881 void purple_protocol_client_iface_tooltip_text(PurpleProtocol
*,
882 PurpleBuddy
*buddy
, PurpleNotifyUserInfo
*user_info
, gboolean full
);
884 GList
*purple_protocol_client_iface_blist_node_menu(PurpleProtocol
*,
885 PurpleBlistNode
*node
);
887 void purple_protocol_client_iface_buddy_free(PurpleProtocol
*, PurpleBuddy
*);
889 void purple_protocol_client_iface_convo_closed(PurpleProtocol
*,
890 PurpleConnection
*, const char *who
);
892 const char *purple_protocol_client_iface_normalize(PurpleProtocol
*,
893 const PurpleAccount
*account
, const char *who
);
895 PurpleChat
*purple_protocol_client_iface_find_blist_chat(PurpleProtocol
*,
896 PurpleAccount
*account
, const char *name
);
898 gboolean
purple_protocol_client_iface_offline_message(PurpleProtocol
*,
899 const PurpleBuddy
*buddy
);
901 GHashTable
*purple_protocol_client_iface_get_account_text_table(PurpleProtocol
*,
902 PurpleAccount
*account
);
904 PurpleMood
*purple_protocol_client_iface_get_moods(PurpleProtocol
*,
905 PurpleAccount
*account
);
907 gssize
purple_protocol_client_iface_get_max_message_size(PurpleProtocol
*,
908 PurpleConversation
*conv
);
910 /**************************************************************************/
911 /* Protocol Server Interface API */
912 /**************************************************************************/
915 * purple_protocol_server_iface_get_type:
917 * Returns: The #GType for the protocol server interface.
919 GType
purple_protocol_server_iface_get_type(void);
921 void purple_protocol_server_iface_register_user(PurpleProtocol
*,
925 * purple_protocol_server_iface_unregister_user:
928 void purple_protocol_server_iface_unregister_user(PurpleProtocol
*,
929 PurpleAccount
*, PurpleAccountUnregistrationCb cb
, void *user_data
);
931 void purple_protocol_server_iface_set_info(PurpleProtocol
*, PurpleConnection
*,
934 void purple_protocol_server_iface_get_info(PurpleProtocol
*, PurpleConnection
*,
937 void purple_protocol_server_iface_set_status(PurpleProtocol
*,
938 PurpleAccount
*account
, PurpleStatus
*status
);
940 void purple_protocol_server_iface_set_idle(PurpleProtocol
*, PurpleConnection
*,
943 void purple_protocol_server_iface_change_passwd(PurpleProtocol
*,
944 PurpleConnection
*, const char *old_pass
, const char *new_pass
);
946 void purple_protocol_server_iface_add_buddy(PurpleProtocol
*,
947 PurpleConnection
*pc
, PurpleBuddy
*buddy
, PurpleGroup
*group
,
948 const char *message
);
950 void purple_protocol_server_iface_add_buddies(PurpleProtocol
*,
951 PurpleConnection
*pc
, GList
*buddies
, GList
*groups
,
952 const char *message
);
954 void purple_protocol_server_iface_remove_buddy(PurpleProtocol
*,
955 PurpleConnection
*, PurpleBuddy
*buddy
, PurpleGroup
*group
);
957 void purple_protocol_server_iface_remove_buddies(PurpleProtocol
*,
958 PurpleConnection
*, GList
*buddies
, GList
*groups
);
960 void purple_protocol_server_iface_keepalive(PurpleProtocol
*,
963 void purple_protocol_server_iface_alias_buddy(PurpleProtocol
*,
964 PurpleConnection
*, const char *who
, const char *alias
);
966 void purple_protocol_server_iface_group_buddy(PurpleProtocol
*,
967 PurpleConnection
*, const char *who
, const char *old_group
,
968 const char *new_group
);
970 void purple_protocol_server_iface_rename_group(PurpleProtocol
*,
971 PurpleConnection
*, const char *old_name
, PurpleGroup
*group
,
972 GList
*moved_buddies
);
974 void purple_protocol_server_iface_set_buddy_icon(PurpleProtocol
*,
975 PurpleConnection
*, PurpleImage
*img
);
977 void purple_protocol_server_iface_remove_group(PurpleProtocol
*,
978 PurpleConnection
*gc
, PurpleGroup
*group
);
980 int purple_protocol_server_iface_send_raw(PurpleProtocol
*,
981 PurpleConnection
*gc
, const char *buf
, int len
);
984 * purple_protocol_server_iface_set_public_alias:
985 * @success_cb: (scope call):
986 * @failure_cb: (scope call):
988 void purple_protocol_server_iface_set_public_alias(PurpleProtocol
*,
989 PurpleConnection
*gc
, const char *alias
,
990 PurpleSetPublicAliasSuccessCallback success_cb
,
991 PurpleSetPublicAliasFailureCallback failure_cb
);
994 * purple_protocol_server_iface_get_public_alias:
995 * @success_cb: (scope call):
996 * @failure_cb: (scope call):
998 void purple_protocol_server_iface_get_public_alias(PurpleProtocol
*,
999 PurpleConnection
*gc
, PurpleGetPublicAliasSuccessCallback success_cb
,
1000 PurpleGetPublicAliasFailureCallback failure_cb
);
1002 /**************************************************************************/
1003 /* Protocol IM Interface API */
1004 /**************************************************************************/
1007 * purple_protocol_im_iface_get_type:
1009 * Returns: The #GType for the protocol IM interface.
1011 GType
purple_protocol_im_iface_get_type(void);
1013 int purple_protocol_im_iface_send(PurpleProtocol
*, PurpleConnection
*,
1014 PurpleMessage
*msg
);
1016 unsigned int purple_protocol_im_iface_send_typing(PurpleProtocol
*,
1017 PurpleConnection
*, const char *name
, PurpleIMTypingState state
);
1019 /**************************************************************************/
1020 /* Protocol Chat Interface API */
1021 /**************************************************************************/
1024 * purple_protocol_chat_iface_get_type:
1026 * Returns: The #GType for the protocol chat interface.
1028 GType
purple_protocol_chat_iface_get_type(void);
1030 GList
*purple_protocol_chat_iface_info(PurpleProtocol
*,
1031 PurpleConnection
*);
1033 GHashTable
*purple_protocol_chat_iface_info_defaults(PurpleProtocol
*,
1034 PurpleConnection
*, const char *chat_name
);
1036 void purple_protocol_chat_iface_join(PurpleProtocol
*, PurpleConnection
*,
1037 GHashTable
*components
);
1039 void purple_protocol_chat_iface_reject(PurpleProtocol
*,
1040 PurpleConnection
*, GHashTable
*components
);
1042 char *purple_protocol_chat_iface_get_name(PurpleProtocol
*,
1043 GHashTable
*components
);
1045 void purple_protocol_chat_iface_invite(PurpleProtocol
*,
1046 PurpleConnection
*, int id
, const char *message
, const char *who
);
1048 void purple_protocol_chat_iface_leave(PurpleProtocol
*, PurpleConnection
*,
1051 int purple_protocol_chat_iface_send(PurpleProtocol
*, PurpleConnection
*,
1052 int id
, PurpleMessage
*msg
);
1054 char *purple_protocol_chat_iface_get_user_real_name(PurpleProtocol
*,
1055 PurpleConnection
*gc
, int id
, const char *who
);
1057 void purple_protocol_chat_iface_set_topic(PurpleProtocol
*,
1058 PurpleConnection
*gc
, int id
, const char *topic
);
1060 /**************************************************************************/
1061 /* Protocol Privacy Interface API */
1062 /**************************************************************************/
1065 * purple_protocol_privacy_iface_get_type:
1067 * Returns: The #GType for the protocol privacy interface.
1069 GType
purple_protocol_privacy_iface_get_type(void);
1071 void purple_protocol_privacy_iface_add_permit(PurpleProtocol
*,
1072 PurpleConnection
*, const char *name
);
1074 void purple_protocol_privacy_iface_add_deny(PurpleProtocol
*,
1075 PurpleConnection
*, const char *name
);
1077 void purple_protocol_privacy_iface_rem_permit(PurpleProtocol
*,
1078 PurpleConnection
*, const char *name
);
1080 void purple_protocol_privacy_iface_rem_deny(PurpleProtocol
*,
1081 PurpleConnection
*, const char *name
);
1083 void purple_protocol_privacy_iface_set_permit_deny(PurpleProtocol
*,
1084 PurpleConnection
*);
1086 /**************************************************************************/
1087 /* Protocol Xfer Interface API */
1088 /**************************************************************************/
1091 * purple_protocol_xfer_iface_get_type:
1093 * Returns: The #GType for the protocol xfer interface.
1095 GType
purple_protocol_xfer_iface_get_type(void);
1097 gboolean
purple_protocol_xfer_iface_can_receive(PurpleProtocol
*,
1098 PurpleConnection
*, const char *who
);
1100 void purple_protocol_xfer_iface_send(PurpleProtocol
*, PurpleConnection
*,
1101 const char *who
, const char *filename
);
1103 PurpleXfer
*purple_protocol_xfer_iface_new_xfer(PurpleProtocol
*,
1104 PurpleConnection
*, const char *who
);
1106 /**************************************************************************/
1107 /* Protocol Roomlist Interface API */
1108 /**************************************************************************/
1111 * purple_protocol_roomlist_iface_get_type:
1113 * Returns: The #GType for the protocol roomlist interface.
1115 GType
purple_protocol_roomlist_iface_get_type(void);
1117 PurpleRoomlist
*purple_protocol_roomlist_iface_get_list(PurpleProtocol
*,
1118 PurpleConnection
*gc
);
1120 void purple_protocol_roomlist_iface_cancel(PurpleProtocol
*,
1121 PurpleRoomlist
*list
);
1123 void purple_protocol_roomlist_iface_expand_category(PurpleProtocol
*,
1124 PurpleRoomlist
*list
, PurpleRoomlistRoom
*category
);
1126 char *purple_protocol_roomlist_iface_room_serialize(PurpleProtocol
*,
1127 PurpleRoomlistRoom
*room
);
1129 /**************************************************************************/
1130 /* Protocol Attention Interface API */
1131 /**************************************************************************/
1134 * purple_protocol_attention_iface_get_type:
1136 * Returns: The #GType for the protocol attention interface.
1138 GType
purple_protocol_attention_iface_get_type(void);
1140 gboolean
purple_protocol_attention_iface_send(PurpleProtocol
*,
1141 PurpleConnection
*gc
, const char *username
, guint type
);
1143 GList
*purple_protocol_attention_iface_get_types(PurpleProtocol
*,
1144 PurpleAccount
*acct
);
1146 /**************************************************************************/
1147 /* Protocol Media Interface API */
1148 /**************************************************************************/
1151 * purple_protocol_media_iface_get_type:
1153 * Returns: The #GType for the protocol media interface.
1155 GType
purple_protocol_media_iface_get_type(void);
1157 gboolean
purple_protocol_media_iface_initiate_session(PurpleProtocol
*,
1158 PurpleAccount
*account
, const char *who
, PurpleMediaSessionType type
);
1160 PurpleMediaCaps
purple_protocol_media_iface_get_caps(PurpleProtocol
*,
1161 PurpleAccount
*account
, const char *who
);
1163 gboolean
purple_protocol_media_iface_send_dtmf(PurpleProtocol
*,
1164 PurpleMedia
*media
, gchar dtmf
, guint8 volume
, guint8 duration
);
1166 /**************************************************************************/
1167 /* Protocol Factory Interface API */
1168 /**************************************************************************/
1171 * purple_protocol_factory_iface_get_type:
1173 * Returns: The #GType for the protocol factory interface.
1175 GType
purple_protocol_factory_iface_get_type(void);
1177 PurpleConnection
*purple_protocol_factory_iface_connection_new(PurpleProtocol
*,
1178 PurpleAccount
*account
, const char *password
);
1180 PurpleRoomlist
*purple_protocol_factory_iface_roomlist_new(PurpleProtocol
*,
1181 PurpleAccount
*account
);
1183 PurpleWhiteboard
*purple_protocol_factory_iface_whiteboard_new(PurpleProtocol
*,
1184 PurpleAccount
*account
, const char *who
, int state
);
1186 PurpleXfer
*purple_protocol_factory_iface_xfer_new(PurpleProtocol
*,
1187 PurpleAccount
*account
, PurpleXferType type
, const char *who
);
1191 #endif /* _PROTOCOL_H_ */