Frameworks/libpurple.framework/Versions/0.6.2/Headers/prpl.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 2250 Frameworks/libpurple.framework/Versions/0.6.0/Headers/prpl.h@9da0b118ce57
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
     1 /**
     2  * @file prpl.h Protocol Plugin functions
     3  * @ingroup core
     4  */
     5 
     6 /* purple
     7  *
     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.
    11  *
    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.
    16  *
    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.
    21  *
    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
    25  */
    26 
    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. */
    29 
    30 #ifndef _PURPLE_PRPL_H_
    31 #define _PURPLE_PRPL_H_
    32 
    33 typedef struct _PurplePluginProtocolInfo PurplePluginProtocolInfo;
    34 /** @copydoc _PurpleAttentionType */
    35 typedef struct _PurpleAttentionType PurpleAttentionType;
    36 
    37 /**************************************************************************/
    38 /** @name Basic Protocol Information                                      */
    39 /**************************************************************************/
    40 
    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;
    45 
    46 
    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.
    51  */
    52 typedef struct _PurpleBuddyIconSpec PurpleBuddyIconSpec;
    53 
    54 /**
    55  * This \#define exists just to make it easier to fill out the buddy icon
    56  * field in the prpl info struct for protocols that couldn't care less.
    57  */
    58 #define NO_BUDDY_ICONS {NULL, 0, 0, 0, 0, 0, 0}
    59 
    60 #ifdef HAVE_UNISTD_H
    61 #include <unistd.h>
    62 #endif
    63 
    64 #include "blist.h"
    65 #include "conversation.h"
    66 #include "ft.h"
    67 #include "imgstore.h"
    68 #include "media.h"
    69 #include "notify.h"
    70 #include "proxy.h"
    71 #include "plugin.h"
    72 #include "roomlist.h"
    73 #include "status.h"
    74 #include "whiteboard.h"
    75 
    76 
    77 /** @copydoc PurpleBuddyIconSpec */
    78 struct _PurpleBuddyIconSpec {
    79 	/** This is a comma-delimited list of image formats or @c NULL if icons
    80 	 *  are not supported.  Neither the core nor the prpl will actually
    81 	 *  check to see if the data it's given matches this; it's entirely up
    82 	 *  to the UI to do what it wants
    83 	 */
    84 	char *format;
    85 
    86 	int min_width;                     /**< Minimum width of this icon  */
    87 	int min_height;                    /**< Minimum height of this icon */
    88 	int max_width;                     /**< Maximum width of this icon  */
    89 	int max_height;                    /**< Maximum height of this icon */
    90 	size_t max_filesize;               /**< Maximum size in bytes */
    91 	PurpleIconScaleRules scale_rules;  /**< How to stretch this icon */
    92 };
    93 
    94 struct proto_chat_entry {
    95 	const char *label;
    96 	const char *identifier;
    97 	gboolean required;
    98 	gboolean is_int;
    99 	int min;
   100 	int max;
   101 	gboolean secret;
   102 };
   103 
   104 /** Represents "nudges" and "buzzes" that you may send to a buddy to attract
   105  *  their attention (or vice-versa).
   106  */
   107 struct _PurpleAttentionType
   108 {
   109 	const char *name;                  /**< Shown in GUI elements */
   110 	const char *incoming_description;  /**< Shown when sent */
   111 	const char *outgoing_description;  /**< Shown when receied */
   112 	const char *icon_name;             /**< Icon to display (optional) */
   113 	const char *unlocalized_name;      /**< Unlocalized name for UIs needing it */
   114 
   115 	/* Reserved fields for future purposes */
   116 	gpointer _reserved2;
   117 	gpointer _reserved3;
   118 	gpointer _reserved4;
   119 };
   120 
   121 /**
   122  * Protocol options
   123  *
   124  * These should all be stuff that some plugins can do and others can't.
   125  */
   126 typedef enum
   127 {
   128 	/**
   129 	 * User names are unique to a chat and are not shared between rooms.
   130 	 *
   131 	 * XMPP lets you choose what name you want in chats, so it shouldn't
   132 	 * be pulling the aliases from the buddy list for the chat list;
   133 	 * it gets annoying.
   134 	 */
   135 	OPT_PROTO_UNIQUE_CHATNAME = 0x00000004,
   136 
   137 	/**
   138 	 * Chat rooms have topics.
   139 	 *
   140 	 * IRC and XMPP support this.
   141 	 */
   142 	OPT_PROTO_CHAT_TOPIC = 0x00000008,
   143 
   144 	/**
   145 	 * Don't require passwords for sign-in.
   146 	 *
   147 	 * Zephyr doesn't require passwords, so there's no
   148 	 * need for a password prompt.
   149 	 */
   150 	OPT_PROTO_NO_PASSWORD = 0x00000010,
   151 
   152 	/**
   153 	 * Notify on new mail.
   154 	 *
   155 	 * MSN and Yahoo notify you when you have new mail.
   156 	 */
   157 	OPT_PROTO_MAIL_CHECK = 0x00000020,
   158 
   159 	/**
   160 	 * Images in IMs.
   161 	 *
   162 	 * Oscar lets you send images in direct IMs.
   163 	 */
   164 	OPT_PROTO_IM_IMAGE = 0x00000040,
   165 
   166 	/**
   167 	 * Allow passwords to be optional.
   168 	 *
   169 	 * Passwords in IRC are optional, and are needed for certain
   170 	 * functionality.
   171 	 */
   172 	OPT_PROTO_PASSWORD_OPTIONAL = 0x00000080,
   173 
   174 	/**
   175 	 * Allows font size to be specified in sane point size
   176 	 *
   177 	 * Probably just XMPP and Y!M
   178 	 */
   179 	OPT_PROTO_USE_POINTSIZE = 0x00000100,
   180 
   181 	/**
   182 	 * Set the Register button active even when the username has not
   183 	 * been specified.
   184 	 *
   185 	 * Gadu-Gadu doesn't need a username to register new account (because
   186 	 * usernames are assigned by the server).
   187 	 */
   188 	OPT_PROTO_REGISTER_NOSCREENNAME = 0x00000200,
   189 
   190 	/**
   191 	 * Indicates that slash commands are native to this protocol.
   192 	 * Used as a hint that unknown commands should not be sent as messages.
   193 	 * @since 2.1.0
   194 	 */
   195 	OPT_PROTO_SLASH_COMMANDS_NATIVE = 0x00000400
   196 
   197 } PurpleProtocolOptions;
   198 
   199 /**
   200  * A protocol plugin information structure.
   201  *
   202  * Every protocol plugin initializes this structure. It is the gateway
   203  * between purple and the protocol plugin.  Many of these callbacks can be
   204  * NULL.  If a callback must be implemented, it has a comment indicating so.
   205  */
   206 struct _PurplePluginProtocolInfo
   207 {
   208 	PurpleProtocolOptions options;  /**< Protocol options.          */
   209 
   210 	GList *user_splits;      /**< A GList of PurpleAccountUserSplit */
   211 	GList *protocol_options; /**< A GList of PurpleAccountOption    */
   212 
   213 	PurpleBuddyIconSpec icon_spec; /**< The icon spec. */
   214 
   215 	/**
   216 	 * Returns the base icon name for the given buddy and account.
   217 	 * If buddy is NULL and the account is non-NULL, it will return the
   218 	 * name to use for the account's icon. If both are NULL, it will
   219 	 * return the name to use for the protocol's icon.
   220 	 *
   221 	 * This must be implemented.
   222 	 */
   223 	const char *(*list_icon)(PurpleAccount *account, PurpleBuddy *buddy);
   224 
   225 	/**
   226 	 * Fills the four char**'s with string identifiers for "emblems"
   227 	 * that the UI will interpret and display as relevant
   228 	 */
   229 	const char *(*list_emblem)(PurpleBuddy *buddy);
   230 
   231 	/**
   232 	 * Gets a short string representing this buddy's status.  This will
   233 	 * be shown on the buddy list.
   234 	 */
   235 	char *(*status_text)(PurpleBuddy *buddy);
   236 
   237 	/**
   238 	 * Allows the prpl to add text to a buddy's tooltip.
   239 	 */
   240 	void (*tooltip_text)(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full);
   241 
   242 	/**
   243 	 * Returns a list of #PurpleStatusType which exist for this account;
   244 	 * this must be implemented, and must add at least the offline and
   245 	 * online states.
   246 	 */
   247 	GList *(*status_types)(PurpleAccount *account);
   248 
   249 	/**
   250 	 * Returns a list of #PurpleMenuAction structs, which represent extra
   251 	 * actions to be shown in (for example) the right-click menu for @a
   252 	 * node.
   253 	 */
   254 	GList *(*blist_node_menu)(PurpleBlistNode *node);
   255 	GList *(*chat_info)(PurpleConnection *);
   256 	GHashTable *(*chat_info_defaults)(PurpleConnection *, const char *chat_name);
   257 
   258 	/* All the server-related functions */
   259 
   260 	/** This must be implemented. */
   261 	void (*login)(PurpleAccount *);
   262 
   263 	/** This must be implemented. */
   264 	void (*close)(PurpleConnection *);
   265 
   266 	/**
   267 	 * This PRPL function should return a positive value on success.
   268 	 * If the message is too big to be sent, return -E2BIG.  If
   269 	 * the account is not connected, return -ENOTCONN.  If the
   270 	 * PRPL is unable to send the message for another reason, return
   271 	 * some other negative value.  You can use one of the valid
   272 	 * errno values, or just big something.  If the message should
   273 	 * not be echoed to the conversation window, return 0.
   274 	 */
   275 	int  (*send_im)(PurpleConnection *, const char *who,
   276 					const char *message,
   277 					PurpleMessageFlags flags);
   278 
   279 	void (*set_info)(PurpleConnection *, const char *info);
   280 
   281 	/**
   282 	 * @return If this protocol requires the PURPLE_TYPING message to
   283 	 *         be sent repeatedly to signify that the user is still
   284 	 *         typing, then the PRPL should return the number of
   285 	 *         seconds to wait before sending a subsequent notification.
   286 	 *         Otherwise the PRPL should return 0.
   287 	 */
   288 	unsigned int (*send_typing)(PurpleConnection *, const char *name, PurpleTypingState state);
   289 
   290 	/**
   291 	 * Should arrange for purple_notify_userinfo() to be called with
   292 	 * @a who's user info.
   293 	 */
   294 	void (*get_info)(PurpleConnection *, const char *who);
   295 	void (*set_status)(PurpleAccount *account, PurpleStatus *status);
   296 
   297 	void (*set_idle)(PurpleConnection *, int idletime);
   298 	void (*change_passwd)(PurpleConnection *, const char *old_pass,
   299 						  const char *new_pass);
   300 	/**
   301 	 * Add a buddy to a group on the server.
   302 	 *
   303 	 * This PRPL function may be called in situations in which the buddy is
   304 	 * already in the specified group. If the protocol supports
   305 	 * authorization and the user is not already authorized to see the
   306 	 * status of \a buddy, \a add_buddy should request authorization.
   307 	 */
   308 	void (*add_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
   309 	void (*add_buddies)(PurpleConnection *, GList *buddies, GList *groups);
   310 	void (*remove_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
   311 	void (*remove_buddies)(PurpleConnection *, GList *buddies, GList *groups);
   312 	void (*add_permit)(PurpleConnection *, const char *name);
   313 	void (*add_deny)(PurpleConnection *, const char *name);
   314 	void (*rem_permit)(PurpleConnection *, const char *name);
   315 	void (*rem_deny)(PurpleConnection *, const char *name);
   316 	void (*set_permit_deny)(PurpleConnection *);
   317 	void (*join_chat)(PurpleConnection *, GHashTable *components);
   318 	void (*reject_chat)(PurpleConnection *, GHashTable *components);
   319 	char *(*get_chat_name)(GHashTable *components);
   320 	void (*chat_invite)(PurpleConnection *, int id,
   321 						const char *message, const char *who);
   322 	void (*chat_leave)(PurpleConnection *, int id);
   323 	void (*chat_whisper)(PurpleConnection *, int id,
   324 						 const char *who, const char *message);
   325 	int  (*chat_send)(PurpleConnection *, int id, const char *message, PurpleMessageFlags flags);
   326 
   327 	/** If implemented, this will be called regularly for this prpl's
   328 	 *  active connections.  You'd want to do this if you need to repeatedly
   329 	 *  send some kind of keepalive packet to the server to avoid being
   330 	 *  disconnected.  ("Regularly" is defined by
   331 	 *  <code>KEEPALIVE_INTERVAL</code> in <tt>libpurple/connection.c</tt>.)
   332 	 */
   333 	void (*keepalive)(PurpleConnection *);
   334 
   335 	/** new user registration */
   336 	void (*register_user)(PurpleAccount *);
   337 
   338 	/**
   339 	 * @deprecated Use #PurplePluginProtocolInfo.get_info instead.
   340 	 */
   341 	void (*get_cb_info)(PurpleConnection *, int, const char *who);
   342 	/**
   343 	 * @deprecated Use #PurplePluginProtocolInfo.get_cb_real_name and
   344 	 *             #PurplePluginProtocolInfo.status_text instead.
   345 	 */
   346 	void (*get_cb_away)(PurpleConnection *, int, const char *who);
   347 
   348 	/** save/store buddy's alias on server list/roster */
   349 	void (*alias_buddy)(PurpleConnection *, const char *who,
   350 						const char *alias);
   351 
   352 	/** change a buddy's group on a server list/roster */
   353 	void (*group_buddy)(PurpleConnection *, const char *who,
   354 						const char *old_group, const char *new_group);
   355 
   356 	/** rename a group on a server list/roster */
   357 	void (*rename_group)(PurpleConnection *, const char *old_name,
   358 						 PurpleGroup *group, GList *moved_buddies);
   359 
   360 	void (*buddy_free)(PurpleBuddy *);
   361 
   362 	void (*convo_closed)(PurpleConnection *, const char *who);
   363 
   364 	/**
   365 	 *  Convert the username @a who to its canonical form.  (For example,
   366 	 *  AIM treats "fOo BaR" and "foobar" as the same user; this function
   367 	 *  should return the same normalized string for both of those.)
   368 	 */
   369 	const char *(*normalize)(const PurpleAccount *, const char *who);
   370 
   371 	/**
   372 	 * Set the buddy icon for the given connection to @a img.  The prpl
   373 	 * does NOT own a reference to @a img; if it needs one, it must
   374 	 * #purple_imgstore_ref(@a img) itself.
   375 	 */
   376 	void (*set_buddy_icon)(PurpleConnection *, PurpleStoredImage *img);
   377 
   378 	void (*remove_group)(PurpleConnection *gc, PurpleGroup *group);
   379 
   380 	/** Gets the real name of a participant in a chat.  For example, on
   381 	 *  XMPP this turns a chat room nick <tt>foo</tt> into
   382 	 *  <tt>room\@server/foo</tt>
   383 	 *  @param gc  the connection on which the room is.
   384 	 *  @param id  the ID of the chat room.
   385 	 *  @param who the nickname of the chat participant.
   386 	 *  @return    the real name of the participant.  This string must be
   387 	 *             freed by the caller.
   388 	 */
   389 	char *(*get_cb_real_name)(PurpleConnection *gc, int id, const char *who);
   390 
   391 	void (*set_chat_topic)(PurpleConnection *gc, int id, const char *topic);
   392 
   393 	PurpleChat *(*find_blist_chat)(PurpleAccount *account, const char *name);
   394 
   395 	/* room listing prpl callbacks */
   396 	PurpleRoomlist *(*roomlist_get_list)(PurpleConnection *gc);
   397 	void (*roomlist_cancel)(PurpleRoomlist *list);
   398 	void (*roomlist_expand_category)(PurpleRoomlist *list, PurpleRoomlistRoom *category);
   399 
   400 	/* file transfer callbacks */
   401 	gboolean (*can_receive_file)(PurpleConnection *, const char *who);
   402 	void (*send_file)(PurpleConnection *, const char *who, const char *filename);
   403 	PurpleXfer *(*new_xfer)(PurpleConnection *, const char *who);
   404 
   405 	/** Checks whether offline messages to @a buddy are supported.
   406 	 *  @return @c TRUE if @a buddy can be sent messages while they are
   407 	 *          offline, or @c FALSE if not.
   408 	 */
   409 	gboolean (*offline_message)(const PurpleBuddy *buddy);
   410 
   411 	PurpleWhiteboardPrplOps *whiteboard_prpl_ops;
   412 
   413 	/** For use in plugins that may understand the underlying protocol */
   414 	int (*send_raw)(PurpleConnection *gc, const char *buf, int len);
   415 
   416 	/* room list serialize */
   417 	char *(*roomlist_room_serialize)(PurpleRoomlistRoom *room);
   418 
   419 	/** Remove the user from the server.  The account can either be
   420 	 * connected or disconnected. After the removal is finished, the
   421 	 * connection will stay open and has to be closed!
   422 	 */
   423 	/* This is here rather than next to register_user for API compatibility
   424 	 * reasons.
   425 	 */
   426 	void (*unregister_user)(PurpleAccount *, PurpleAccountUnregistrationCb cb, void *user_data);
   427 
   428 	/* Attention API for sending & receiving zaps/nudges/buzzes etc. */
   429 	gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type);
   430 	GList *(*get_attention_types)(PurpleAccount *acct);
   431 
   432 	/**
   433 	 * The size of the PurplePluginProtocolInfo. This should always be sizeof(PurplePluginProtocolInfo).
   434 	 * This allows adding more functions to this struct without requiring a major version bump.
   435 	 */
   436 	unsigned long struct_size;
   437 
   438 	/* NOTE:
   439 	 * If more functions are added, they should accessed using the following syntax:
   440 	 *
   441 	 *		if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, new_function))
   442 	 *			prpl->new_function(...);
   443 	 *
   444 	 * instead of
   445 	 *
   446 	 *		if (prpl->new_function != NULL)
   447 	 *			prpl->new_function(...);
   448 	 *
   449 	 * The PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro can be used for the older member
   450 	 * functions (e.g. login, send_im etc.) too.
   451 	 */
   452 
   453 	/** This allows protocols to specify additional strings to be used for
   454 	 * various purposes.  The idea is to stuff a bunch of strings in this hash
   455 	 * table instead of expanding the struct for every addition.  This hash
   456 	 * table is allocated every call and MUST be unrefed by the caller.
   457 	 *
   458 	 * @param account The account to specify.  This can be NULL.
   459 	 * @return The protocol's string hash table. The hash table should be
   460 	 *         destroyed by the caller when it's no longer needed.
   461 	 */
   462 	GHashTable *(*get_account_text_table)(PurpleAccount *account);
   463 
   464 	/**
   465 	 * Initiate a media session with the given contact.
   466 	 *
   467 	 * @param account The account to initiate the media session on.
   468 	 * @param who The remote user to initiate the session with.
   469 	 * @param type The type of media session to initiate.
   470 	 * @return TRUE if the call succeeded else FALSE. (Doesn't imply the media session or stream will be successfully created)
   471 	 */
   472 	gboolean (*initiate_media)(PurpleAccount *account, const char *who,
   473 					PurpleMediaSessionType type);
   474 
   475 	/**
   476 	 * Checks to see if the given contact supports the given type of media session.
   477 	 *
   478 	 * @param account The account the contact is on.
   479 	 * @param who The remote user to check for media capability with.
   480 	 * @return The media caps the contact supports.
   481 	 */
   482 	PurpleMediaCaps (*get_media_caps)(PurpleAccount *account,
   483 					  const char *who);
   484 };
   485 
   486 #define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \
   487 	(((G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < G_STRUCT_OFFSET(PurplePluginProtocolInfo, struct_size)) \
   488 	  || (G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < prpl->struct_size)) && \
   489 	 prpl->member != NULL)
   490 
   491 
   492 #define PURPLE_IS_PROTOCOL_PLUGIN(plugin) \
   493 	((plugin)->info->type == PURPLE_PLUGIN_PROTOCOL)
   494 
   495 #define PURPLE_PLUGIN_PROTOCOL_INFO(plugin) \
   496 	((PurplePluginProtocolInfo *)(plugin)->info->extra_info)
   497 
   498 #ifdef __cplusplus
   499 extern "C" {
   500 #endif
   501 
   502 /**************************************************************************/
   503 /** @name Attention Type API                                              */
   504 /**************************************************************************/
   505 /*@{*/
   506 
   507 /**
   508  * Creates a new #PurpleAttentionType object and sets its mandatory parameters.
   509  *
   510  * @param ulname A non-localized string that can be used by UIs in need of such
   511  *               non-localized strings.  This should be the same as @a name,
   512  *               without localization.
   513  * @param name A localized string that the UI may display for the event. This
   514  *             should be the same string as @a ulname, with localization.
   515  * @param inc_desc A localized description shown when the event is received.
   516  * @param out_desc A localized description shown when the event is sent.
   517  * @return A pointer to the new object.
   518  * @since 2.4.0
   519  */
   520 PurpleAttentionType *purple_attention_type_new(const char *ulname, const char *name,
   521 								const char *inc_desc, const char *out_desc);
   522 
   523 /**
   524  * Sets the displayed name of the attention-demanding event.
   525  *
   526  * @param type The attention type.
   527  * @param name The localized name that will be displayed by UIs. This should be
   528  *             the same string given as the unlocalized name, but with
   529  *             localization.
   530  * @since 2.4.0
   531  */
   532 void purple_attention_type_set_name(PurpleAttentionType *type, const char *name);
   533 
   534 /**
   535  * Sets the description of the attention-demanding event shown in  conversations
   536  * when the event is received.
   537  *
   538  * @param type The attention type.
   539  * @param desc The localized description for incoming events.
   540  * @since 2.4.0
   541  */
   542 void purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const char *desc);
   543 
   544 /**
   545  * Sets the description of the attention-demanding event shown in conversations
   546  * when the event is sent.
   547  *
   548  * @param type The attention type.
   549  * @param desc The localized description for outgoing events.
   550  * @since 2.4.0
   551  */
   552 void purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const char *desc);
   553 
   554 /**
   555  * Sets the name of the icon to display for the attention event; this is optional.
   556  *
   557  * @param type The attention type.
   558  * @param name The icon's name.
   559  * @note Icons are optional for attention events.
   560  * @since 2.4.0
   561  */
   562 void purple_attention_type_set_icon_name(PurpleAttentionType *type, const char *name);
   563 
   564 /**
   565  * Sets the unlocalized name of the attention event; some UIs may need this,
   566  * thus it is required.
   567  *
   568  * @param type The attention type.
   569  * @param ulname The unlocalized name.  This should be the same string given as
   570  *               the localized name, but without localization.
   571  * @since 2.4.0
   572  */
   573 void purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const char *ulname);
   574 
   575 /**
   576  * Get the attention type's name as displayed by the UI.
   577  *
   578  * @param type The attention type.
   579  * @return The name.
   580  * @since 2.4.0
   581  */
   582 const char *purple_attention_type_get_name(const PurpleAttentionType *type);
   583 
   584 /**
   585  * Get the attention type's description shown when the event is received.
   586  *
   587  * @param type The attention type.
   588  * @return The description.
   589  * @since 2.4.0
   590  */
   591 const char *purple_attention_type_get_incoming_desc(const PurpleAttentionType *type);
   592 
   593 /**
   594  * Get the attention type's description shown when the event is sent.
   595  *
   596  * @param type The attention type.
   597  * @return The description.
   598  * @since 2.4.0
   599  */
   600 const char *purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type);
   601 
   602 /**
   603  * Get the attention type's icon name.
   604  *
   605  * @param type The attention type.
   606  * @return The icon name or @c NULL if unset/empty.
   607  * @note Icons are optional for attention events.
   608  * @since 2.4.0
   609  */
   610 const char *purple_attention_type_get_icon_name(const PurpleAttentionType *type);
   611 
   612 /**
   613  * Get the attention type's unlocalized name; this is useful for some UIs.
   614  *
   615  * @param type The attention type
   616  * @return The unlocalized name.
   617  * @since 2.4.0
   618  */
   619 const char *purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type);
   620 
   621 /*@}*/
   622 
   623 /**************************************************************************/
   624 /** @name Protocol Plugin API                                             */
   625 /**************************************************************************/
   626 /*@{*/
   627 
   628 /**
   629  * Notifies Purple that our account's idle state and time have changed.
   630  *
   631  * This is meant to be called from protocol plugins.
   632  *
   633  * @param account   The account.
   634  * @param idle      The user's idle state.
   635  * @param idle_time The user's idle time.
   636  */
   637 void purple_prpl_got_account_idle(PurpleAccount *account, gboolean idle,
   638 								time_t idle_time);
   639 
   640 /**
   641  * Notifies Purple of our account's log-in time.
   642  *
   643  * This is meant to be called from protocol plugins.
   644  *
   645  * @param account    The account the user is on.
   646  * @param login_time The user's log-in time.
   647  */
   648 void purple_prpl_got_account_login_time(PurpleAccount *account, time_t login_time);
   649 
   650 /**
   651  * Notifies Purple that our account's status has changed.
   652  *
   653  * This is meant to be called from protocol plugins.
   654  *
   655  * @param account   The account the user is on.
   656  * @param status_id The status ID.
   657  * @param ...       A NULL-terminated list of attribute IDs and values,
   658  *                  beginning with the value for @a attr_id.
   659  */
   660 void purple_prpl_got_account_status(PurpleAccount *account,
   661 								  const char *status_id, ...) G_GNUC_NULL_TERMINATED;
   662 
   663 /**
   664  * Notifies Purple that our account's actions have changed. This is only
   665  * called after the initial connection. Emits the account-actions-changed
   666  * signal.
   667  *
   668  * This is meant to be called from protocol plugins.
   669  *
   670  * @param account   The account.
   671  *
   672  * @see account-actions-changed
   673  * @since 2.6.0
   674  */
   675 void purple_prpl_got_account_actions(PurpleAccount *account);
   676 
   677 /**
   678  * Notifies Purple that a buddy's idle state and time have changed.
   679  *
   680  * This is meant to be called from protocol plugins.
   681  *
   682  * @param account   The account the user is on.
   683  * @param name      The name of the buddy.
   684  * @param idle      The user's idle state.
   685  * @param idle_time The user's idle time.  This is the time at
   686  *                  which the user became idle, in seconds since
   687  *                  the epoch.  If the PRPL does not know this value
   688  *                  then it should pass 0.
   689  */
   690 void purple_prpl_got_user_idle(PurpleAccount *account, const char *name,
   691 							 gboolean idle, time_t idle_time);
   692 
   693 /**
   694  * Notifies Purple of a buddy's log-in time.
   695  *
   696  * This is meant to be called from protocol plugins.
   697  *
   698  * @param account    The account the user is on.
   699  * @param name       The name of the buddy.
   700  * @param login_time The user's log-in time.
   701  */
   702 void purple_prpl_got_user_login_time(PurpleAccount *account, const char *name,
   703 								   time_t login_time);
   704 
   705 /**
   706  * Notifies Purple that a buddy's status has been activated.
   707  *
   708  * This is meant to be called from protocol plugins.
   709  *
   710  * @param account   The account the user is on.
   711  * @param name      The name of the buddy.
   712  * @param status_id The status ID.
   713  * @param ...       A NULL-terminated list of attribute IDs and values,
   714  *                  beginning with the value for @a attr_id.
   715  */
   716 void purple_prpl_got_user_status(PurpleAccount *account, const char *name,
   717 							   const char *status_id, ...) G_GNUC_NULL_TERMINATED;
   718 
   719 /**
   720  * Notifies libpurple that a buddy's status has been deactivated
   721  *
   722  * This is meant to be called from protocol plugins.
   723  *
   724  * @param account   The account the user is on.
   725  * @param name      The name of the buddy.
   726  * @param status_id The status ID.
   727  */
   728 void purple_prpl_got_user_status_deactive(PurpleAccount *account, const char *name,
   729 					const char *status_id);
   730 
   731 /**
   732  * Informs the server that our account's status changed.
   733  *
   734  * @param account    The account the user is on.
   735  * @param old_status The previous status.
   736  * @param new_status The status that was activated, or deactivated
   737  *                   (in the case of independent statuses).
   738  */
   739 void purple_prpl_change_account_status(PurpleAccount *account,
   740 									 PurpleStatus *old_status,
   741 									 PurpleStatus *new_status);
   742 
   743 /**
   744  * Retrieves the list of stock status types from a prpl.
   745  *
   746  * @param account The account the user is on.
   747  * @param presence The presence for which we're going to get statuses
   748  *
   749  * @return List of statuses
   750  */
   751 GList *purple_prpl_get_statuses(PurpleAccount *account, PurplePresence *presence);
   752 
   753 /**
   754  * Send an attention request message.
   755  *
   756  * @param gc The connection to send the message on.
   757  * @param who Whose attention to request.
   758  * @param type_code An index into the prpl's attention_types list determining the type
   759  *        of the attention request command to send. 0 if prpl only defines one
   760  *        (for example, Yahoo and MSN), but some protocols define more (MySpaceIM).
   761  *
   762  * Note that you can't send arbitrary PurpleAttentionType's, because there is
   763  * only a fixed set of attention commands.
   764  *
   765  * @since 2.5.0
   766  */
   767 void purple_prpl_send_attention(PurpleConnection *gc, const char *who, guint type_code);
   768 
   769 /**
   770  * Process an incoming attention message.
   771  *
   772  * @param gc The connection that received the attention message.
   773  * @param who Who requested your attention.
   774  * @param type_code An index into the prpl's attention_types list determining the type
   775  *        of the attention request command to send.
   776  *
   777  * @since 2.5.0
   778  */
   779 void purple_prpl_got_attention(PurpleConnection *gc, const char *who, guint type_code);
   780 
   781 /**
   782  * Process an incoming attention message in a chat.
   783  *
   784  * @param gc The connection that received the attention message.
   785  * @param id The chat id.
   786  * @param who Who requested your attention.
   787  * @param type_code An index into the prpl's attention_types list determining the type
   788  *        of the attention request command to send.
   789  *
   790  * @since 2.5.0
   791  */
   792 void purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code);
   793 
   794 /**
   795  * Determines if the contact supports the given media session type.
   796  *
   797  * @param account The account the user is on.
   798  * @param who The name of the contact to check capabilities for.
   799  *
   800  * @return The media caps the contact supports.
   801  */
   802 PurpleMediaCaps purple_prpl_get_media_caps(PurpleAccount *account,
   803 				  const char *who);
   804 
   805 /**
   806  * Initiates a media session with the given contact.
   807  *
   808  * @param account The account the user is on.
   809  * @param who The name of the contact to start a session with.
   810  * @param type The type of media session to start.
   811  *
   812  * @return TRUE if the call succeeded else FALSE. (Doesn't imply the media session or stream will be successfully created)
   813  */
   814 gboolean purple_prpl_initiate_media(PurpleAccount *account,
   815 					const char *who,
   816 					PurpleMediaSessionType type);
   817 
   818 /*@}*/
   819 
   820 /**************************************************************************/
   821 /** @name Protocol Plugin Subsystem API                                   */
   822 /**************************************************************************/
   823 /*@{*/
   824 
   825 /**
   826  * Finds a protocol plugin structure of the specified type.
   827  *
   828  * @param id The protocol plugin;
   829  */
   830 PurplePlugin *purple_find_prpl(const char *id);
   831 
   832 /*@}*/
   833 
   834 #ifdef __cplusplus
   835 }
   836 #endif
   837 
   838 #endif /* _PRPL_H_ */