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