applied changes from fb4435d514398a0b1febebe8bf46339e2c2b52b6
[pidgin-git.git] / libpurple / prpl.h
blob51e8575d3ec7dbcd537c4a2636adb3ca062e4f83
1 /**
2 * @file prpl.h Protocol Plugin functions
3 * @ingroup core
4 */
6 /* purple
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
27 /* this file should be all that prpls need to include. therefore, by including
28 * this file, they should get glib, proxy, purple_connection, prpl, etc. */
30 #ifndef _PURPLE_PRPL_H_
31 #define _PURPLE_PRPL_H_
33 typedef struct _PurplePluginProtocolInfo PurplePluginProtocolInfo;
34 /** @copydoc _PurpleAttentionType */
35 typedef struct _PurpleAttentionType PurpleAttentionType;
37 /**************************************************************************/
38 /** @name Basic Protocol Information */
39 /**************************************************************************/
41 typedef enum {
42 PURPLE_ICON_SCALE_DISPLAY = 0x01, /**< We scale the icon when we display it */
43 PURPLE_ICON_SCALE_SEND = 0x02 /**< We scale the icon before we send it to the server */
44 } PurpleIconScaleRules;
47 /**
48 * A description of a Buddy Icon specification. This tells Purple what kind of image file
49 * it should give this prpl, and what kind of image file it should expect back.
50 * Dimensions less than 1 should be ignored and the image not scaled.
52 typedef struct _PurpleBuddyIconSpec PurpleBuddyIconSpec;
54 /**
55 * A description of a file transfer thumbnail specification.
56 * This tells the UI if and what image formats the prpl support for file
57 * transfer thumbnails.
59 typedef struct _PurpleThumbnailSpec PurpleThumbnailSpec;
61 /**
62 * This \#define exists just to make it easier to fill out the buddy icon
63 * field in the prpl info struct for protocols that couldn't care less.
65 #define NO_BUDDY_ICONS {NULL, 0, 0, 0, 0, 0, 0}
67 #ifdef HAVE_UNISTD_H
68 #include <unistd.h>
69 #endif
71 #include "blist.h"
72 #include "conversation.h"
73 #include "ft.h"
74 #include "imgstore.h"
75 #include "media.h"
76 #include "notify.h"
77 #include "proxy.h"
78 #include "plugin.h"
79 #include "roomlist.h"
80 #include "status.h"
81 #include "whiteboard.h"
84 /** @copydoc PurpleBuddyIconSpec */
85 struct _PurpleBuddyIconSpec {
86 /** This is a comma-delimited list of image formats or @c NULL if icons
87 * are not supported. Neither the core nor the prpl will actually
88 * check to see if the data it's given matches this; it's entirely up
89 * to the UI to do what it wants
91 char *format;
93 int min_width; /**< Minimum width of this icon */
94 int min_height; /**< Minimum height of this icon */
95 int max_width; /**< Maximum width of this icon */
96 int max_height; /**< Maximum height of this icon */
97 size_t max_filesize; /**< Maximum size in bytes */
98 PurpleIconScaleRules scale_rules; /**< How to stretch this icon */
101 /** Represents an entry containing information that must be supplied by the
102 * user when joining a chat.
104 struct proto_chat_entry {
105 const char *label; /**< User-friendly name of the entry */
106 const char *identifier; /**< Used by the PRPL to identify the option */
107 gboolean required; /**< True if it's required */
108 gboolean is_int; /**< True if the entry expects an integer */
109 int min; /**< Minimum value in case of integer */
110 int max; /**< Maximum value in case of integer */
111 gboolean secret; /**< True if the entry is secret (password) */
114 /** Represents "nudges" and "buzzes" that you may send to a buddy to attract
115 * their attention (or vice-versa).
117 struct _PurpleAttentionType
119 const char *name; /**< Shown in GUI elements */
120 const char *incoming_description; /**< Shown when sent */
121 const char *outgoing_description; /**< Shown when receied */
122 const char *icon_name; /**< Icon to display (optional) */
123 const char *unlocalized_name; /**< Unlocalized name for UIs needing it */
125 /* Reserved fields for future purposes */
126 gpointer _reserved2;
127 gpointer _reserved3;
128 gpointer _reserved4;
132 * Protocol options
134 * These should all be stuff that some plugins can do and others can't.
136 typedef enum
139 * User names are unique to a chat and are not shared between rooms.
141 * XMPP lets you choose what name you want in chats, so it shouldn't
142 * be pulling the aliases from the buddy list for the chat list;
143 * it gets annoying.
145 OPT_PROTO_UNIQUE_CHATNAME = 0x00000004,
148 * Chat rooms have topics.
150 * IRC and XMPP support this.
152 OPT_PROTO_CHAT_TOPIC = 0x00000008,
155 * Don't require passwords for sign-in.
157 * Zephyr doesn't require passwords, so there's no
158 * need for a password prompt.
160 OPT_PROTO_NO_PASSWORD = 0x00000010,
163 * Notify on new mail.
165 * MSN and Yahoo notify you when you have new mail.
167 OPT_PROTO_MAIL_CHECK = 0x00000020,
170 * Images in IMs.
172 * Oscar lets you send images in direct IMs.
174 OPT_PROTO_IM_IMAGE = 0x00000040,
177 * Allow passwords to be optional.
179 * Passwords in IRC are optional, and are needed for certain
180 * functionality.
182 OPT_PROTO_PASSWORD_OPTIONAL = 0x00000080,
185 * Allows font size to be specified in sane point size
187 * Probably just XMPP and Y!M
189 OPT_PROTO_USE_POINTSIZE = 0x00000100,
192 * Set the Register button active even when the username has not
193 * been specified.
195 * Gadu-Gadu doesn't need a username to register new account (because
196 * usernames are assigned by the server).
198 OPT_PROTO_REGISTER_NOSCREENNAME = 0x00000200,
201 * Indicates that slash commands are native to this protocol.
202 * Used as a hint that unknown commands should not be sent as messages.
203 * @since 2.1.0
205 OPT_PROTO_SLASH_COMMANDS_NATIVE = 0x00000400,
208 * Indicates that this protocol supports sending a user-supplied message
209 * along with an invitation.
210 * @since 2.8.0
212 OPT_PROTO_INVITE_MESSAGE = 0x00000800
214 } PurpleProtocolOptions;
217 * A protocol plugin information structure.
219 * Every protocol plugin initializes this structure. It is the gateway
220 * between purple and the protocol plugin. Many of these callbacks can be
221 * NULL. If a callback must be implemented, it has a comment indicating so.
223 struct _PurplePluginProtocolInfo
225 PurpleProtocolOptions options; /**< Protocol options. */
227 GList *user_splits; /**< A GList of PurpleAccountUserSplit */
228 GList *protocol_options; /**< A GList of PurpleAccountOption */
230 PurpleBuddyIconSpec icon_spec; /**< The icon spec. */
233 * Returns the base icon name for the given buddy and account.
234 * If buddy is NULL and the account is non-NULL, it will return the
235 * name to use for the account's icon. If both are NULL, it will
236 * return the name to use for the protocol's icon.
238 * This must be implemented.
240 const char *(*list_icon)(PurpleAccount *account, PurpleBuddy *buddy);
243 * Fills the four char**'s with string identifiers for "emblems"
244 * that the UI will interpret and display as relevant
246 const char *(*list_emblem)(PurpleBuddy *buddy);
249 * Gets a short string representing this buddy's status. This will
250 * be shown on the buddy list.
252 char *(*status_text)(PurpleBuddy *buddy);
255 * Allows the prpl to add text to a buddy's tooltip.
257 void (*tooltip_text)(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full);
260 * Returns a list of #PurpleStatusType which exist for this account;
261 * this must be implemented, and must add at least the offline and
262 * online states.
264 GList *(*status_types)(PurpleAccount *account);
267 * Returns a list of #PurpleMenuAction structs, which represent extra
268 * actions to be shown in (for example) the right-click menu for @a
269 * node.
271 GList *(*blist_node_menu)(PurpleBlistNode *node);
274 * Returns a list of #proto_chat_entry structs, which represent
275 * information required by the PRPL to join a chat. libpurple will
276 * call join_chat along with the information filled by the user.
278 * @return A list of #proto_chat_entry structs
280 GList *(*chat_info)(PurpleConnection *);
283 * Returns a hashtable which maps #proto_chat_entry struct identifiers
284 * to default options as strings based on chat_name. The resulting
285 * hashtable should be created with g_hash_table_new_full(g_str_hash,
286 * g_str_equal, NULL, g_free);. Use #get_chat_name if you instead need
287 * to extract a chat name from a hashtable.
289 * @param chat_name The chat name to be turned into components
290 * @return Hashtable containing the information extracted from chat_name
292 GHashTable *(*chat_info_defaults)(PurpleConnection *, const char *chat_name);
294 /* All the server-related functions */
296 /** This must be implemented. */
297 void (*login)(PurpleAccount *);
299 /** This must be implemented. */
300 void (*close)(PurpleConnection *);
303 * This PRPL function should return a positive value on success.
304 * If the message is too big to be sent, return -E2BIG. If
305 * the account is not connected, return -ENOTCONN. If the
306 * PRPL is unable to send the message for another reason, return
307 * some other negative value. You can use one of the valid
308 * errno values, or just big something. If the message should
309 * not be echoed to the conversation window, return 0.
311 int (*send_im)(PurpleConnection *, const char *who,
312 const char *message,
313 PurpleMessageFlags flags);
315 void (*set_info)(PurpleConnection *, const char *info);
318 * @return If this protocol requires the PURPLE_TYPING message to
319 * be sent repeatedly to signify that the user is still
320 * typing, then the PRPL should return the number of
321 * seconds to wait before sending a subsequent notification.
322 * Otherwise the PRPL should return 0.
324 unsigned int (*send_typing)(PurpleConnection *, const char *name, PurpleTypingState state);
327 * Should arrange for purple_notify_userinfo() to be called with
328 * @a who's user info.
330 void (*get_info)(PurpleConnection *, const char *who);
331 void (*set_status)(PurpleAccount *account, PurpleStatus *status);
333 void (*set_idle)(PurpleConnection *, int idletime);
334 void (*change_passwd)(PurpleConnection *, const char *old_pass,
335 const char *new_pass);
337 * Add a buddy to a group on the server.
339 * This PRPL function may be called in situations in which the buddy is
340 * already in the specified group. If the protocol supports
341 * authorization and the user is not already authorized to see the
342 * status of \a buddy, \a add_buddy should request authorization.
344 * @deprecated Since 2.8.0, add_buddy_with_invite is preferred.
345 * @see add_buddy_with_invite
347 void (*add_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
348 void (*add_buddies)(PurpleConnection *, GList *buddies, GList *groups);
349 void (*remove_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
350 void (*remove_buddies)(PurpleConnection *, GList *buddies, GList *groups);
351 void (*add_permit)(PurpleConnection *, const char *name);
352 void (*add_deny)(PurpleConnection *, const char *name);
353 void (*rem_permit)(PurpleConnection *, const char *name);
354 void (*rem_deny)(PurpleConnection *, const char *name);
355 void (*set_permit_deny)(PurpleConnection *);
358 * Called when the user requests joining a chat. Should arrange for
359 * #serv_got_joined_chat to be called.
361 * @param components A hashtable containing information required to
362 * join the chat as described by the entries returned
363 * by #chat_info. It may also be called when accepting
364 * an invitation, in which case this matches the
365 * data parameter passed to #serv_got_chat_invite.
367 void (*join_chat)(PurpleConnection *, GHashTable *components);
370 * Called when the user refuses a chat invitation.
372 * @param components A hashtable containing information required to
373 * join the chat as passed to #serv_got_chat_invite.
375 void (*reject_chat)(PurpleConnection *, GHashTable *components);
378 * Returns a chat name based on the information in components. Use
379 * #chat_info_defaults if you instead need to generate a hashtable
380 * from a chat name.
382 * @param components A hashtable containing information about the chat.
384 char *(*get_chat_name)(GHashTable *components);
387 * Invite a user to join a chat.
389 * @param id The id of the chat to invite the user to.
390 * @param message A message displayed to the user when the invitation
391 * is received.
392 * @param who The name of the user to send the invation to.
394 void (*chat_invite)(PurpleConnection *, int id,
395 const char *message, const char *who);
397 * Called when the user requests leaving a chat.
399 * @param id The id of the chat to leave
401 void (*chat_leave)(PurpleConnection *, int id);
404 * Send a whisper to a user in a chat.
406 * @param id The id of the chat.
407 * @param who The name of the user to send the whisper to.
408 * @param message The message of the whisper.
410 void (*chat_whisper)(PurpleConnection *, int id,
411 const char *who, const char *message);
414 * Send a message to a chat.
415 * This PRPL function should return a positive value on success.
416 * If the message is too big to be sent, return -E2BIG. If
417 * the account is not connected, return -ENOTCONN. If the
418 * PRPL is unable to send the message for another reason, return
419 * some other negative value. You can use one of the valid
420 * errno values, or just big something. If the message should
421 * not be echoed to the conversation window, return 0.
423 * @param id The id of the chat to send the message to.
424 * @param message The message to send to the chat.
425 * @param flags A bitwise OR of #PurpleMessageFlags representing
426 * message flags.
427 * @return A positive number or 0 in case of succes,
428 * a negative error number in case of failure.
430 int (*chat_send)(PurpleConnection *, int id, const char *message, PurpleMessageFlags flags);
432 /** If implemented, this will be called regularly for this prpl's
433 * active connections. You'd want to do this if you need to repeatedly
434 * send some kind of keepalive packet to the server to avoid being
435 * disconnected. ("Regularly" is defined by
436 * <code>KEEPALIVE_INTERVAL</code> in <tt>libpurple/connection.c</tt>.)
438 void (*keepalive)(PurpleConnection *);
440 /** new user registration */
441 void (*register_user)(PurpleAccount *);
444 * @deprecated Use #PurplePluginProtocolInfo.get_info instead.
446 void (*get_cb_info)(PurpleConnection *, int, const char *who);
448 * @deprecated Use #PurplePluginProtocolInfo.get_cb_real_name and
449 * #PurplePluginProtocolInfo.status_text instead.
451 void (*get_cb_away)(PurpleConnection *, int, const char *who);
453 /** save/store buddy's alias on server list/roster */
454 void (*alias_buddy)(PurpleConnection *, const char *who,
455 const char *alias);
457 /** change a buddy's group on a server list/roster */
458 void (*group_buddy)(PurpleConnection *, const char *who,
459 const char *old_group, const char *new_group);
461 /** rename a group on a server list/roster */
462 void (*rename_group)(PurpleConnection *, const char *old_name,
463 PurpleGroup *group, GList *moved_buddies);
465 void (*buddy_free)(PurpleBuddy *);
467 void (*convo_closed)(PurpleConnection *, const char *who);
470 * Convert the username @a who to its canonical form. (For example,
471 * AIM treats "fOo BaR" and "foobar" as the same user; this function
472 * should return the same normalized string for both of those.)
474 const char *(*normalize)(const PurpleAccount *, const char *who);
477 * Set the buddy icon for the given connection to @a img. The prpl
478 * does NOT own a reference to @a img; if it needs one, it must
479 * #purple_imgstore_ref(@a img) itself.
481 void (*set_buddy_icon)(PurpleConnection *, PurpleStoredImage *img);
483 void (*remove_group)(PurpleConnection *gc, PurpleGroup *group);
485 /** Gets the real name of a participant in a chat. For example, on
486 * XMPP this turns a chat room nick <tt>foo</tt> into
487 * <tt>room\@server/foo</tt>
488 * @param gc the connection on which the room is.
489 * @param id the ID of the chat room.
490 * @param who the nickname of the chat participant.
491 * @return the real name of the participant. This string must be
492 * freed by the caller.
494 char *(*get_cb_real_name)(PurpleConnection *gc, int id, const char *who);
496 void (*set_chat_topic)(PurpleConnection *gc, int id, const char *topic);
498 PurpleChat *(*find_blist_chat)(PurpleAccount *account, const char *name);
500 /* room listing prpl callbacks */
501 PurpleRoomlist *(*roomlist_get_list)(PurpleConnection *gc);
502 void (*roomlist_cancel)(PurpleRoomlist *list);
503 void (*roomlist_expand_category)(PurpleRoomlist *list, PurpleRoomlistRoom *category);
505 /* file transfer callbacks */
506 gboolean (*can_receive_file)(PurpleConnection *, const char *who);
507 void (*send_file)(PurpleConnection *, const char *who, const char *filename);
508 PurpleXfer *(*new_xfer)(PurpleConnection *, const char *who);
510 /** Checks whether offline messages to @a buddy are supported.
511 * @return @c TRUE if @a buddy can be sent messages while they are
512 * offline, or @c FALSE if not.
514 gboolean (*offline_message)(const PurpleBuddy *buddy);
516 PurpleWhiteboardPrplOps *whiteboard_prpl_ops;
518 /** For use in plugins that may understand the underlying protocol */
519 int (*send_raw)(PurpleConnection *gc, const char *buf, int len);
521 /* room list serialize */
522 char *(*roomlist_room_serialize)(PurpleRoomlistRoom *room);
524 /** Remove the user from the server. The account can either be
525 * connected or disconnected. After the removal is finished, the
526 * connection will stay open and has to be closed!
528 /* This is here rather than next to register_user for API compatibility
529 * reasons.
531 void (*unregister_user)(PurpleAccount *, PurpleAccountUnregistrationCb cb, void *user_data);
533 /* Attention API for sending & receiving zaps/nudges/buzzes etc. */
534 gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type);
535 GList *(*get_attention_types)(PurpleAccount *acct);
538 * The size of the PurplePluginProtocolInfo. This should always be sizeof(PurplePluginProtocolInfo).
539 * This allows adding more functions to this struct without requiring a major version bump.
541 unsigned long struct_size;
543 /* NOTE:
544 * If more functions are added, they should accessed using the following syntax:
546 * if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, new_function))
547 * prpl->new_function(...);
549 * instead of
551 * if (prpl->new_function != NULL)
552 * prpl->new_function(...);
554 * The PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro can be used for the older member
555 * functions (e.g. login, send_im etc.) too.
558 /** This allows protocols to specify additional strings to be used for
559 * various purposes. The idea is to stuff a bunch of strings in this hash
560 * table instead of expanding the struct for every addition. This hash
561 * table is allocated every call and MUST be unrefed by the caller.
563 * @param account The account to specify. This can be NULL.
564 * @return The protocol's string hash table. The hash table should be
565 * destroyed by the caller when it's no longer needed.
567 GHashTable *(*get_account_text_table)(PurpleAccount *account);
570 * Initiate a media session with the given contact.
572 * @param account The account to initiate the media session on.
573 * @param who The remote user to initiate the session with.
574 * @param type The type of media session to initiate.
575 * @return TRUE if the call succeeded else FALSE. (Doesn't imply the media session or stream will be successfully created)
577 gboolean (*initiate_media)(PurpleAccount *account, const char *who,
578 PurpleMediaSessionType type);
581 * Checks to see if the given contact supports the given type of media session.
583 * @param account The account the contact is on.
584 * @param who The remote user to check for media capability with.
585 * @return The media caps the contact supports.
587 PurpleMediaCaps (*get_media_caps)(PurpleAccount *account,
588 const char *who);
591 * Returns an array of "PurpleMood"s, with the last one having
592 * "mood" set to @c NULL.
593 * @since 2.7.0
595 PurpleMood *(*get_moods)(PurpleAccount *account);
598 * Set the user's "friendly name" (or alias or nickname or
599 * whatever term you want to call it) on the server. The
600 * protocol plugin should call success_cb or failure_cb
601 * *asynchronously* (if it knows immediately that the set will fail,
602 * call one of the callbacks from an idle/0-second timeout) depending
603 * on if the nickname is set successfully.
605 * @param gc The connection for which to set an alias
606 * @param alias The new server-side alias/nickname for this account,
607 * or NULL to unset the alias/nickname (or return it to
608 * a protocol-specific "default").
609 * @param success_cb Callback to be called if the public alias is set
610 * @param failure_cb Callback to be called if setting the public alias
611 * fails
612 * @see purple_account_set_public_alias
613 * @since 2.7.0
615 void (*set_public_alias)(PurpleConnection *gc, const char *alias,
616 PurpleSetPublicAliasSuccessCallback success_cb,
617 PurpleSetPublicAliasFailureCallback failure_cb);
619 * Retrieve the user's "friendly name" as set on the server.
620 * The protocol plugin should call success_cb or failure_cb
621 * *asynchronously* (even if it knows immediately that the get will fail,
622 * call one of the callbacks from an idle/0-second timeout) depending
623 * on if the nickname is retrieved.
625 * @param gc The connection for which to retireve the alias
626 * @param success_cb Callback to be called with the retrieved alias
627 * @param failure_cb Callback to be called if the prpl is unable to
628 * retrieve the alias
629 * @see purple_account_get_public_alias
630 * @since 2.7.0
632 void (*get_public_alias)(PurpleConnection *gc,
633 PurpleGetPublicAliasSuccessCallback success_cb,
634 PurpleGetPublicAliasFailureCallback failure_cb);
637 * Add a buddy to a group on the server.
639 * This PRPL function may be called in situations in which the buddy is
640 * already in the specified group. If the protocol supports
641 * authorization and the user is not already authorized to see the
642 * status of \a buddy, \a add_buddy should request authorization.
644 * If authorization is required, then use the supplied invite message.
646 * @since 2.8.0
648 void (*add_buddy_with_invite)(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group, const char *message);
649 void (*add_buddies_with_invite)(PurpleConnection *pc, GList *buddies, GList *groups, const char *message);
652 #define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \
653 (((G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < G_STRUCT_OFFSET(PurplePluginProtocolInfo, struct_size)) \
654 || (G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < prpl->struct_size)) && \
655 prpl->member != NULL)
658 #define PURPLE_IS_PROTOCOL_PLUGIN(plugin) \
659 ((plugin)->info->type == PURPLE_PLUGIN_PROTOCOL)
661 #define PURPLE_PLUGIN_PROTOCOL_INFO(plugin) \
662 ((PurplePluginProtocolInfo *)(plugin)->info->extra_info)
664 #ifdef __cplusplus
665 extern "C" {
666 #endif
668 /**************************************************************************/
669 /** @name Attention Type API */
670 /**************************************************************************/
671 /*@{*/
674 * Creates a new #PurpleAttentionType object and sets its mandatory parameters.
676 * @param ulname A non-localized string that can be used by UIs in need of such
677 * non-localized strings. This should be the same as @a name,
678 * without localization.
679 * @param name A localized string that the UI may display for the event. This
680 * should be the same string as @a ulname, with localization.
681 * @param inc_desc A localized description shown when the event is received.
682 * @param out_desc A localized description shown when the event is sent.
683 * @return A pointer to the new object.
684 * @since 2.4.0
686 PurpleAttentionType *purple_attention_type_new(const char *ulname, const char *name,
687 const char *inc_desc, const char *out_desc);
690 * Sets the displayed name of the attention-demanding event.
692 * @param type The attention type.
693 * @param name The localized name that will be displayed by UIs. This should be
694 * the same string given as the unlocalized name, but with
695 * localization.
696 * @since 2.4.0
698 void purple_attention_type_set_name(PurpleAttentionType *type, const char *name);
701 * Sets the description of the attention-demanding event shown in conversations
702 * when the event is received.
704 * @param type The attention type.
705 * @param desc The localized description for incoming events.
706 * @since 2.4.0
708 void purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const char *desc);
711 * Sets the description of the attention-demanding event shown in conversations
712 * when the event is sent.
714 * @param type The attention type.
715 * @param desc The localized description for outgoing events.
716 * @since 2.4.0
718 void purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const char *desc);
721 * Sets the name of the icon to display for the attention event; this is optional.
723 * @param type The attention type.
724 * @param name The icon's name.
725 * @note Icons are optional for attention events.
726 * @since 2.4.0
728 void purple_attention_type_set_icon_name(PurpleAttentionType *type, const char *name);
731 * Sets the unlocalized name of the attention event; some UIs may need this,
732 * thus it is required.
734 * @param type The attention type.
735 * @param ulname The unlocalized name. This should be the same string given as
736 * the localized name, but without localization.
737 * @since 2.4.0
739 void purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const char *ulname);
742 * Get the attention type's name as displayed by the UI.
744 * @param type The attention type.
745 * @return The name.
746 * @since 2.4.0
748 const char *purple_attention_type_get_name(const PurpleAttentionType *type);
751 * Get the attention type's description shown when the event is received.
753 * @param type The attention type.
754 * @return The description.
755 * @since 2.4.0
757 const char *purple_attention_type_get_incoming_desc(const PurpleAttentionType *type);
760 * Get the attention type's description shown when the event is sent.
762 * @param type The attention type.
763 * @return The description.
764 * @since 2.4.0
766 const char *purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type);
769 * Get the attention type's icon name.
771 * @param type The attention type.
772 * @return The icon name or @c NULL if unset/empty.
773 * @note Icons are optional for attention events.
774 * @since 2.4.0
776 const char *purple_attention_type_get_icon_name(const PurpleAttentionType *type);
779 * Get the attention type's unlocalized name; this is useful for some UIs.
781 * @param type The attention type
782 * @return The unlocalized name.
783 * @since 2.4.0
785 const char *purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type);
787 /*@}*/
789 /**************************************************************************/
790 /** @name Protocol Plugin API */
791 /**************************************************************************/
792 /*@{*/
795 * Notifies Purple that our account's idle state and time have changed.
797 * This is meant to be called from protocol plugins.
799 * @param account The account.
800 * @param idle The user's idle state.
801 * @param idle_time The user's idle time.
803 void purple_prpl_got_account_idle(PurpleAccount *account, gboolean idle,
804 time_t idle_time);
807 * Notifies Purple of our account's log-in time.
809 * This is meant to be called from protocol plugins.
811 * @param account The account the user is on.
812 * @param login_time The user's log-in time.
814 void purple_prpl_got_account_login_time(PurpleAccount *account, time_t login_time);
817 * Notifies Purple that our account's status has changed.
819 * This is meant to be called from protocol plugins.
821 * @param account The account the user is on.
822 * @param status_id The status ID.
823 * @param ... A NULL-terminated list of attribute IDs and values,
824 * beginning with the value for @a attr_id.
826 void purple_prpl_got_account_status(PurpleAccount *account,
827 const char *status_id, ...) G_GNUC_NULL_TERMINATED;
830 * Notifies Purple that our account's actions have changed. This is only
831 * called after the initial connection. Emits the account-actions-changed
832 * signal.
834 * This is meant to be called from protocol plugins.
836 * @param account The account.
838 * @see account-actions-changed
839 * @since 2.6.0
841 void purple_prpl_got_account_actions(PurpleAccount *account);
844 * Notifies Purple that a buddy's idle state and time have changed.
846 * This is meant to be called from protocol plugins.
848 * @param account The account the user is on.
849 * @param name The name of the buddy.
850 * @param idle The user's idle state.
851 * @param idle_time The user's idle time. This is the time at
852 * which the user became idle, in seconds since
853 * the epoch. If the PRPL does not know this value
854 * then it should pass 0.
856 void purple_prpl_got_user_idle(PurpleAccount *account, const char *name,
857 gboolean idle, time_t idle_time);
860 * Notifies Purple of a buddy's log-in time.
862 * This is meant to be called from protocol plugins.
864 * @param account The account the user is on.
865 * @param name The name of the buddy.
866 * @param login_time The user's log-in time.
868 void purple_prpl_got_user_login_time(PurpleAccount *account, const char *name,
869 time_t login_time);
872 * Notifies Purple that a buddy's status has been activated.
874 * This is meant to be called from protocol plugins.
876 * @param account The account the user is on.
877 * @param name The name of the buddy.
878 * @param status_id The status ID.
879 * @param ... A NULL-terminated list of attribute IDs and values,
880 * beginning with the value for @a attr_id.
882 void purple_prpl_got_user_status(PurpleAccount *account, const char *name,
883 const char *status_id, ...) G_GNUC_NULL_TERMINATED;
886 * Notifies libpurple that a buddy's status has been deactivated
888 * This is meant to be called from protocol plugins.
890 * @param account The account the user is on.
891 * @param name The name of the buddy.
892 * @param status_id The status ID.
894 void purple_prpl_got_user_status_deactive(PurpleAccount *account, const char *name,
895 const char *status_id);
898 * Informs the server that our account's status changed.
900 * @param account The account the user is on.
901 * @param old_status The previous status.
902 * @param new_status The status that was activated, or deactivated
903 * (in the case of independent statuses).
905 void purple_prpl_change_account_status(PurpleAccount *account,
906 PurpleStatus *old_status,
907 PurpleStatus *new_status);
910 * Retrieves the list of stock status types from a prpl.
912 * @param account The account the user is on.
913 * @param presence The presence for which we're going to get statuses
915 * @return List of statuses
917 GList *purple_prpl_get_statuses(PurpleAccount *account, PurplePresence *presence);
920 * Send an attention request message.
922 * @param gc The connection to send the message on.
923 * @param who Whose attention to request.
924 * @param type_code An index into the prpl's attention_types list determining the type
925 * of the attention request command to send. 0 if prpl only defines one
926 * (for example, Yahoo and MSN), but some protocols define more (MySpaceIM).
928 * Note that you can't send arbitrary PurpleAttentionType's, because there is
929 * only a fixed set of attention commands.
931 * @since 2.5.0
933 void purple_prpl_send_attention(PurpleConnection *gc, const char *who, guint type_code);
936 * Process an incoming attention message.
938 * @param gc The connection that received the attention message.
939 * @param who Who requested your attention.
940 * @param type_code An index into the prpl's attention_types list determining the type
941 * of the attention request command to send.
943 * @since 2.5.0
945 void purple_prpl_got_attention(PurpleConnection *gc, const char *who, guint type_code);
948 * Process an incoming attention message in a chat.
950 * @param gc The connection that received the attention message.
951 * @param id The chat id.
952 * @param who Who requested your attention.
953 * @param type_code An index into the prpl's attention_types list determining the type
954 * of the attention request command to send.
956 * @since 2.5.0
958 void purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code);
961 * Determines if the contact supports the given media session type.
963 * @param account The account the user is on.
964 * @param who The name of the contact to check capabilities for.
966 * @return The media caps the contact supports.
968 PurpleMediaCaps purple_prpl_get_media_caps(PurpleAccount *account,
969 const char *who);
972 * Initiates a media session with the given contact.
974 * @param account The account the user is on.
975 * @param who The name of the contact to start a session with.
976 * @param type The type of media session to start.
978 * @return TRUE if the call succeeded else FALSE. (Doesn't imply the media session or stream will be successfully created)
980 gboolean purple_prpl_initiate_media(PurpleAccount *account,
981 const char *who,
982 PurpleMediaSessionType type);
985 * Signals that the prpl received capabilities for the given contact.
987 * This function is intended to be used only by prpls.
989 * @param account The account the user is on.
990 * @param who The name of the contact for which capabilities have been received.
991 * @since 2.7.0
993 void purple_prpl_got_media_caps(PurpleAccount *account, const char *who);
995 /*@}*/
997 /**************************************************************************/
998 /** @name Protocol Plugin Subsystem API */
999 /**************************************************************************/
1000 /*@{*/
1003 * Finds a protocol plugin structure of the specified type.
1005 * @param id The protocol plugin;
1007 PurplePlugin *purple_find_prpl(const char *id);
1009 /*@}*/
1011 #ifdef __cplusplus
1013 #endif
1015 #endif /* _PRPL_H_ */