Frameworks/libpurple.framework/Versions/0.6.2/Headers/connection.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 2504 Frameworks/libpurple.framework/Versions/0.6.0/Headers/connection.h@97ec2ce929ec
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
Evan@653
     1
/**
Evan@653
     2
 * @file connection.h Connection API
Evan@653
     3
 * @ingroup core
Evan@653
     4
 * @see @ref connection-signals
Evan@653
     5
 */
Evan@653
     6
Evan@653
     7
/* purple
Evan@653
     8
 *
Evan@653
     9
 * Purple is the legal property of its developers, whose names are too numerous
Evan@653
    10
 * to list here.  Please refer to the COPYRIGHT file distributed with this
Evan@653
    11
 * source distribution.
Evan@653
    12
 *
Evan@653
    13
 * This program is free software; you can redistribute it and/or modify
Evan@653
    14
 * it under the terms of the GNU General Public License as published by
Evan@653
    15
 * the Free Software Foundation; either version 2 of the License, or
Evan@653
    16
 * (at your option) any later version.
Evan@653
    17
 *
Evan@653
    18
 * This program is distributed in the hope that it will be useful,
Evan@653
    19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Evan@653
    20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Evan@653
    21
 * GNU General Public License for more details.
Evan@653
    22
 *
Evan@653
    23
 * You should have received a copy of the GNU General Public License
Evan@653
    24
 * along with this program; if not, write to the Free Software
Evan@653
    25
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
Evan@653
    26
 */
Evan@653
    27
#ifndef _PURPLE_CONNECTION_H_
Evan@653
    28
#define _PURPLE_CONNECTION_H_
Evan@653
    29
Evan@653
    30
/** @copydoc _PurpleConnection */
Evan@653
    31
typedef struct _PurpleConnection PurpleConnection;
Evan@653
    32
Evan@653
    33
/**
Evan@653
    34
 * Flags to change behavior of the client for a given connection.
Evan@653
    35
 */
Evan@653
    36
typedef enum
Evan@653
    37
{
Evan@653
    38
	PURPLE_CONNECTION_HTML       = 0x0001, /**< Connection sends/receives in 'HTML'. */
Evan@653
    39
	PURPLE_CONNECTION_NO_BGCOLOR = 0x0002, /**< Connection does not send/receive
Evan@653
    40
					           background colors.                  */
Evan@653
    41
	PURPLE_CONNECTION_AUTO_RESP  = 0x0004,  /**< Send auto responses when away.       */
Evan@653
    42
	PURPLE_CONNECTION_FORMATTING_WBFO = 0x0008, /**< The text buffer must be formatted as a whole */
Evan@653
    43
	PURPLE_CONNECTION_NO_NEWLINES = 0x0010, /**< No new lines are allowed in outgoing messages */
Evan@653
    44
	PURPLE_CONNECTION_NO_FONTSIZE = 0x0020, /**< Connection does not send/receive font sizes */
Evan@1427
    45
	PURPLE_CONNECTION_NO_URLDESC = 0x0040,  /**< Connection does not support descriptions with links */
Evan@653
    46
	PURPLE_CONNECTION_NO_IMAGES = 0x0080,  /**< Connection does not support sending of images */
Evan@653
    47
	PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY = 0x0100 /**< Connection supports sending and receiving custom smileys */
Evan@653
    48
Evan@653
    49
} PurpleConnectionFlags;
Evan@653
    50
Evan@653
    51
typedef enum
Evan@653
    52
{
Evan@653
    53
	PURPLE_DISCONNECTED = 0, /**< Disconnected. */
Evan@653
    54
	PURPLE_CONNECTED,        /**< Connected.    */
Evan@653
    55
	PURPLE_CONNECTING        /**< Connecting.   */
Evan@653
    56
Evan@653
    57
} PurpleConnectionState;
Evan@653
    58
Evan@1427
    59
/**
Evan@1427
    60
 * Possible errors that can cause a connection to be closed.
Evan@1427
    61
 *
Evan@653
    62
 *  @since 2.3.0
Evan@653
    63
 */
Evan@653
    64
typedef enum
Evan@653
    65
{
Evan@653
    66
	/** There was an error sending or receiving on the network socket, or
Evan@653
    67
	 *  there was some protocol error (such as the server sending malformed
Evan@653
    68
	 *  data).
Evan@653
    69
	 */
Evan@653
    70
	PURPLE_CONNECTION_ERROR_NETWORK_ERROR = 0,
Evan@653
    71
	/** The username supplied was not valid. */
Evan@653
    72
	PURPLE_CONNECTION_ERROR_INVALID_USERNAME = 1,
Evan@653
    73
	/** The username, password or some other credential was incorrect.  Use
Evan@653
    74
	 *  #PURPLE_CONNECTION_ERROR_INVALID_USERNAME instead if the username
Evan@1427
    75
	 *  is known to be invalid.
Evan@653
    76
	 */
Evan@653
    77
	PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED = 2,
Evan@653
    78
	/** libpurple doesn't speak any of the authentication methods the
Evan@653
    79
	 *  server offered.
Evan@653
    80
	 */
Evan@653
    81
	PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE = 3,
Evan@653
    82
	/** libpurple was built without SSL support, and the connection needs
Evan@653
    83
	 *  SSL.
Evan@653
    84
	 */
Evan@653
    85
	PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT = 4,
Evan@653
    86
	/** There was an error negotiating SSL on this connection, or the
Evan@653
    87
	 *  server does not support encryption but an account option was set to
Evan@653
    88
	 *  require it.
Evan@653
    89
	 */
Evan@653
    90
	PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR = 5,
Evan@653
    91
	/** Someone is already connected to the server using the name you are
Evan@653
    92
	 *  trying to connect with.
Evan@653
    93
	 */
Evan@653
    94
	PURPLE_CONNECTION_ERROR_NAME_IN_USE = 6,
Evan@653
    95
Evan@653
    96
	/** The username/server/other preference for the account isn't valid.
Evan@1427
    97
	 *  For instance, on IRC the username cannot contain white space.
Evan@653
    98
	 *  This reason should not be used for incorrect passwords etc: use
Evan@653
    99
	 *  #PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED for that.
Evan@653
   100
	 *
Evan@653
   101
	 *  @todo This reason really shouldn't be necessary.  Usernames and
Evan@653
   102
	 *        other account preferences should be validated when the
Evan@653
   103
	 *        account is created.
Evan@653
   104
	 */
Evan@653
   105
	PURPLE_CONNECTION_ERROR_INVALID_SETTINGS = 7,
Evan@653
   106
Evan@653
   107
	/** The server did not provide a SSL certificate. */
Evan@653
   108
	PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED = 8,
Evan@653
   109
	/** The server's SSL certificate could not be trusted. */
Evan@653
   110
	PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED = 9,
Evan@653
   111
	/** The server's SSL certificate has expired. */
Evan@653
   112
	PURPLE_CONNECTION_ERROR_CERT_EXPIRED = 10,
Evan@653
   113
	/** The server's SSL certificate is not yet valid. */
Evan@653
   114
	PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED = 11,
Evan@653
   115
	/** The server's SSL certificate did not match its hostname. */
Evan@653
   116
	PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH = 12,
Evan@653
   117
	/** The server's SSL certificate does not have the expected
Evan@653
   118
	 *  fingerprint.
Evan@653
   119
	 */
Evan@653
   120
	PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH = 13,
Evan@653
   121
	/** The server's SSL certificate is self-signed.  */
Evan@653
   122
	PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED = 14,
Evan@653
   123
	/** There was some other error validating the server's SSL certificate.
Evan@653
   124
	 */
Evan@653
   125
	PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR = 15,
Evan@653
   126
Evan@653
   127
	/** Some other error occurred which fits into none of the other
Evan@653
   128
	 *  categories.
Evan@653
   129
	 */
Evan@653
   130
	/* purple_connection_error_reason() in connection.c uses the fact that
Evan@653
   131
	 * this is the last member of the enum when sanity-checking; if other
Evan@653
   132
	 * reasons are added after it, the check must be updated.
Evan@653
   133
	 */
Evan@653
   134
	PURPLE_CONNECTION_ERROR_OTHER_ERROR = 16
Evan@653
   135
} PurpleConnectionError;
Evan@653
   136
Evan@653
   137
/** Holds the type of an error along with its description. */
Evan@653
   138
typedef struct
Evan@653
   139
{
Evan@653
   140
	/** The type of error. */
Evan@653
   141
	PurpleConnectionError type;
Evan@653
   142
	/** A localised, human-readable description of the error. */
Evan@653
   143
	char *description;
Evan@653
   144
} PurpleConnectionErrorInfo;
Evan@653
   145
Evan@653
   146
#include <time.h>
Evan@653
   147
Evan@653
   148
#include "account.h"
Evan@653
   149
#include "plugin.h"
Evan@653
   150
#include "status.h"
Evan@653
   151
#include "sslconn.h"
Evan@653
   152
Evan@1427
   153
/**
Evan@1427
   154
 * Connection UI operations.  Used to notify the user of changes to
Evan@1427
   155
 * connections, such as being disconnected, and to respond to the
Evan@1427
   156
 * underlying network connection appearing and disappearing.  UIs should
Evan@1427
   157
 * call #purple_connections_set_ui_ops() with an instance of this struct.
Evan@653
   158
 *
Evan@1427
   159
 * @see @ref ui-ops
Evan@653
   160
 */
Evan@653
   161
typedef struct
Evan@653
   162
{
Evan@1427
   163
	/**
Evan@1427
   164
	 * When an account is connecting, this operation is called to notify
Evan@1427
   165
	 * the UI of what is happening, as well as which @a step out of @a
Evan@1427
   166
	 * step_count has been reached (which might be displayed as a progress
Evan@1427
   167
	 * bar).
Evan@1427
   168
	 * @see #purple_connection_update_progress
Evan@653
   169
	 */
Evan@653
   170
	void (*connect_progress)(PurpleConnection *gc,
Evan@653
   171
	                         const char *text,
Evan@653
   172
	                         size_t step,
Evan@653
   173
	                         size_t step_count);
Evan@653
   174
Evan@1427
   175
	/**
Evan@1427
   176
	 * Called when a connection is established (just before the
Evan@1427
   177
	 * @ref signed-on signal).
Evan@653
   178
	 */
Evan@653
   179
	void (*connected)(PurpleConnection *gc);
Evan@1427
   180
Evan@1427
   181
	/**
Evan@1427
   182
	 * Called when a connection is ended (between the @ref signing-off
Evan@1427
   183
	 * and @ref signed-off signals).
Evan@653
   184
	 */
Evan@653
   185
	void (*disconnected)(PurpleConnection *gc);
Evan@653
   186
Evan@1427
   187
	/**
Evan@1427
   188
	 * Used to display connection-specific notices.  (Pidgin's Gtk user
Evan@1427
   189
	 * interface implements this as a no-op; #purple_connection_notice(),
Evan@1427
   190
	 * which uses this operation, is not used by any of the protocols
Evan@1427
   191
	 * shipped with libpurple.)
Evan@653
   192
	 */
Evan@653
   193
	void (*notice)(PurpleConnection *gc, const char *text);
Evan@653
   194
Evan@1427
   195
	/**
Evan@1427
   196
	 * Called when an error causes a connection to be disconnected.
Evan@1427
   197
	 * Called before #disconnected.
Evan@1427
   198
	 * @param text  a localized error message.
Evan@1427
   199
	 * @see #purple_connection_error
Evan@1427
   200
	 * @deprecated in favour of
Evan@1427
   201
	 *             #PurpleConnectionUiOps.report_disconnect_reason.
Evan@653
   202
	 */
Evan@653
   203
	void (*report_disconnect)(PurpleConnection *gc, const char *text);
Evan@653
   204
Evan@1427
   205
	/**
Evan@1427
   206
	 * Called when libpurple discovers that the computer's network
Evan@1427
   207
	 * connection is active.  On Linux, this uses Network Manager if
Evan@1427
   208
	 * available; on Windows, it uses Win32's network change notification
Evan@1427
   209
	 * infrastructure.
Evan@653
   210
	 */
Evan@653
   211
	void (*network_connected)(void);
Evan@1427
   212
Evan@1427
   213
	/**
Evan@1427
   214
	 * Called when libpurple discovers that the computer's network
Evan@1427
   215
	 * connection has gone away.
Evan@653
   216
	 */
Evan@653
   217
	void (*network_disconnected)(void);
Evan@653
   218
Evan@1427
   219
	/**
Evan@1427
   220
	 * Called when an error causes a connection to be disconnected.
Evan@653
   221
	 *  Called before #disconnected.  This op is intended to replace
Evan@653
   222
	 *  #report_disconnect.  If both are implemented, this will be called
Evan@653
   223
	 *  first; however, there's no real reason to implement both.
Evan@1427
   224
	 *
Evan@653
   225
	 *  @param reason  why the connection ended, if known, or
Evan@653
   226
	 *                 #PURPLE_CONNECTION_ERROR_OTHER_ERROR, if not.
Evan@653
   227
	 *  @param text  a localized message describing the disconnection
Evan@653
   228
	 *               in more detail to the user.
Evan@653
   229
	 *  @see #purple_connection_error_reason
Evan@1427
   230
	 *
Evan@653
   231
	 *  @since 2.3.0
Evan@653
   232
	 */
Evan@653
   233
	void (*report_disconnect_reason)(PurpleConnection *gc,
Evan@653
   234
	                                 PurpleConnectionError reason,
Evan@653
   235
	                                 const char *text);
Evan@653
   236
Evan@653
   237
	void (*_purple_reserved1)(void);
Evan@653
   238
	void (*_purple_reserved2)(void);
Evan@653
   239
	void (*_purple_reserved3)(void);
Evan@653
   240
} PurpleConnectionUiOps;
Evan@653
   241
Evan@653
   242
Evan@653
   243
/* Represents an active connection on an account. */
Evan@653
   244
struct _PurpleConnection
Evan@653
   245
{
Evan@653
   246
	PurplePlugin *prpl;            /**< The protocol plugin.               */
Evan@653
   247
	PurpleConnectionFlags flags;   /**< Connection flags.                  */
Evan@653
   248
Evan@653
   249
	PurpleConnectionState state;   /**< The connection state.              */
Evan@653
   250
Evan@653
   251
	PurpleAccount *account;        /**< The account being connected to.    */
Evan@653
   252
	char *password;              /**< The password used.                 */
Evan@653
   253
	int inpa;                    /**< The input watcher.                 */
Evan@653
   254
Evan@653
   255
	GSList *buddy_chats;         /**< A list of active chats
Evan@653
   256
	                                  (#PurpleConversation structs of type
Evan@653
   257
	                                  #PURPLE_CONV_TYPE_CHAT).           */
Evan@653
   258
	void *proto_data;            /**< Protocol-specific data.            */
Evan@653
   259
Evan@653
   260
	char *display_name;          /**< How you appear to other people.    */
Evan@653
   261
	guint keepalive;             /**< Keep-alive.                        */
Evan@653
   262
Evan@653
   263
	/** Wants to Die state.  This is set when the user chooses to log out, or
Evan@653
   264
	 * when the protocol is disconnected and should not be automatically
Evan@653
   265
	 * reconnected (incorrect password, etc.).  prpls should rely on
Evan@653
   266
	 * purple_connection_error_reason() to set this for them rather than
Evan@653
   267
	 * setting it themselves.
Evan@653
   268
	 * @see purple_connection_error_is_fatal
Evan@653
   269
	 */
Evan@653
   270
	gboolean wants_to_die;
Evan@653
   271
Evan@653
   272
	guint disconnect_timeout;    /**< Timer used for nasty stack tricks  */
Evan@653
   273
	time_t last_received;        /**< When we last received a packet. Set by the
Evan@653
   274
					  prpl to avoid sending unneeded keepalives */
Evan@653
   275
};
Evan@653
   276
Evan@653
   277
#ifdef __cplusplus
Evan@653
   278
extern "C" {
Evan@653
   279
#endif
Evan@653
   280
Evan@653
   281
/**************************************************************************/
Evan@653
   282
/** @name Connection API                                                  */
Evan@653
   283
/**************************************************************************/
Evan@653
   284
/*@{*/
Evan@653
   285
Evan@653
   286
#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_CONNECTION_C_)
Evan@653
   287
/**
Evan@653
   288
 * This function should only be called by purple_account_connect()
Evan@653
   289
 * in account.c.  If you're trying to sign on an account, use that
Evan@653
   290
 * function instead.
Evan@653
   291
 *
Evan@653
   292
 * Creates a connection to the specified account and either connects
Evan@653
   293
 * or attempts to register a new account.  If you are logging in,
Evan@653
   294
 * the connection uses the current active status for this account.
Evan@653
   295
 * So if you want to sign on as "away," for example, you need to
Evan@653
   296
 * have called purple_account_set_status(account, "away").
Evan@653
   297
 * (And this will call purple_account_connect() automatically).
Evan@653
   298
 *
Evan@653
   299
 * @param account  The account the connection should be connecting to.
Evan@653
   300
 * @param regist   Whether we are registering a new account or just
Evan@653
   301
 *                 trying to do a normal signon.
Evan@653
   302
 * @param password The password to use.
Evan@653
   303
 *
Evan@653
   304
 * @deprecated As this is internal, we should make it private in 3.0.0.
Evan@653
   305
 */
Evan@653
   306
void purple_connection_new(PurpleAccount *account, gboolean regist,
Evan@653
   307
									const char *password);
Evan@653
   308
#endif
Evan@653
   309
Evan@653
   310
#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_CONNECTION_C_)
Evan@653
   311
/**
Evan@653
   312
 * This function should only be called by purple_account_unregister()
Evan@653
   313
 * in account.c.
Evan@653
   314
 *
Evan@653
   315
 * Tries to unregister the account on the server. If the account is not
Evan@653
   316
 * connected, also creates a new connection.
Evan@653
   317
 *
Evan@653
   318
 * @param account  The account to unregister
Evan@653
   319
 * @param password The password to use.
Evan@653
   320
 * @param cb Optional callback to be called when unregistration is complete
Evan@653
   321
 * @param user_data user data to pass to the callback
Evan@653
   322
 *
Evan@653
   323
 * @deprecated As this is internal, we should make it private in 3.0.0.
Evan@653
   324
 */
Evan@653
   325
void purple_connection_new_unregister(PurpleAccount *account, const char *password, PurpleAccountUnregistrationCb cb, void *user_data);
Evan@653
   326
#endif
Evan@653
   327
Evan@653
   328
#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_CONNECTION_C_)
Evan@653
   329
/**
Evan@653
   330
 * Disconnects and destroys a PurpleConnection.
Evan@653
   331
 *
Evan@653
   332
 * This function should only be called by purple_account_disconnect()
Evan@653
   333
 * in account.c.  If you're trying to sign off an account, use that
Evan@653
   334
 * function instead.
Evan@653
   335
 *
Evan@653
   336
 * @param gc The purple connection to destroy.
Evan@653
   337
 *
Evan@653
   338
 * @deprecated As this is internal, we should make it private in 3.0.0.
Evan@653
   339
 */
Evan@653
   340
void purple_connection_destroy(PurpleConnection *gc);
Evan@653
   341
#endif
Evan@653
   342
Evan@653
   343
/**
Evan@653
   344
 * Sets the connection state.  PRPLs should call this and pass in
Evan@653
   345
 * the state #PURPLE_CONNECTED when the account is completely
Evan@653
   346
 * signed on.  What does it mean to be completely signed on?  If
Evan@653
   347
 * the core can call prpl->set_status, and it successfully changes
Evan@653
   348
 * your status, then the account is online.
Evan@653
   349
 *
Evan@653
   350
 * @param gc    The connection.
Evan@653
   351
 * @param state The connection state.
Evan@653
   352
 */
Evan@653
   353
void purple_connection_set_state(PurpleConnection *gc, PurpleConnectionState state);
Evan@653
   354
Evan@653
   355
/**
Evan@653
   356
 * Sets the connection's account.
Evan@653
   357
 *
Evan@653
   358
 * @param gc      The connection.
Evan@653
   359
 * @param account The account.
Evan@653
   360
 */
Evan@653
   361
void purple_connection_set_account(PurpleConnection *gc, PurpleAccount *account);
Evan@653
   362
Evan@653
   363
/**
Evan@653
   364
 * Sets the connection's displayed name.
Evan@653
   365
 *
Evan@653
   366
 * @param gc   The connection.
Evan@653
   367
 * @param name The displayed name.
Evan@653
   368
 */
Evan@653
   369
void purple_connection_set_display_name(PurpleConnection *gc, const char *name);
Evan@653
   370
Evan@653
   371
/**
Evan@1427
   372
 * Sets the protocol data for a connection.
Evan@1427
   373
 *
Evan@1427
   374
 * @param connection The PurpleConnection.
Evan@1427
   375
 * @param proto_data The protocol data to set for the connection.
Evan@1427
   376
 *
Evan@1427
   377
 * @since 2.6.0
Evan@1427
   378
 */
Evan@1427
   379
void purple_connection_set_protocol_data(PurpleConnection *connection, void *proto_data);
Evan@1427
   380
Evan@1427
   381
/**
Evan@653
   382
 * Returns the connection state.
Evan@653
   383
 *
Evan@653
   384
 * @param gc The connection.
Evan@653
   385
 *
Evan@653
   386
 * @return The connection state.
Evan@653
   387
 */
Evan@653
   388
PurpleConnectionState purple_connection_get_state(const PurpleConnection *gc);
Evan@653
   389
Evan@653
   390
/**
Evan@653
   391
 * Returns TRUE if the account is connected, otherwise returns FALSE.
Evan@653
   392
 *
Evan@653
   393
 * @return TRUE if the account is connected, otherwise returns FALSE.
Evan@653
   394
 */
Evan@653
   395
#define PURPLE_CONNECTION_IS_CONNECTED(gc) \
Evan@653
   396
	(purple_connection_get_state(gc) == PURPLE_CONNECTED)
Evan@653
   397
Evan@653
   398
/**
Evan@653
   399
 * Returns the connection's account.
Evan@653
   400
 *
Evan@653
   401
 * @param gc The connection.
Evan@653
   402
 *
Evan@653
   403
 * @return The connection's account.
Evan@653
   404
 */
Evan@653
   405
PurpleAccount *purple_connection_get_account(const PurpleConnection *gc);
Evan@653
   406
Evan@653
   407
/**
Evan@653
   408
 * Returns the protocol plugin managing a connection.
Evan@653
   409
 *
Evan@653
   410
 * @param gc The connection.
Evan@653
   411
 *
Evan@653
   412
 * @return The protocol plugin.
Evan@1427
   413
 *
Evan@653
   414
 * @since 2.4.0
Evan@653
   415
 */
Evan@653
   416
PurplePlugin * purple_connection_get_prpl(const PurpleConnection *gc);
Evan@653
   417
Evan@653
   418
/**
Evan@653
   419
 * Returns the connection's password.
Evan@653
   420
 *
Evan@653
   421
 * @param gc The connection.
Evan@653
   422
 *
Evan@653
   423
 * @return The connection's password.
Evan@653
   424
 */
Evan@653
   425
const char *purple_connection_get_password(const PurpleConnection *gc);
Evan@653
   426
Evan@653
   427
/**
Evan@653
   428
 * Returns the connection's displayed name.
Evan@653
   429
 *
Evan@653
   430
 * @param gc The connection.
Evan@653
   431
 *
Evan@653
   432
 * @return The connection's displayed name.
Evan@653
   433
 */
Evan@653
   434
const char *purple_connection_get_display_name(const PurpleConnection *gc);
Evan@653
   435
Evan@653
   436
/**
Evan@1427
   437
 * Gets the protocol data from a connection.
Evan@1427
   438
 *
Evan@1427
   439
 * @param connection The PurpleConnection.
Evan@1427
   440
 *
Evan@1427
   441
 * @return The protocol data for the connection.
Evan@1427
   442
 *
Evan@1427
   443
 * @since 2.6.0
Evan@1427
   444
 */
Evan@1427
   445
void *purple_connection_get_protocol_data(const PurpleConnection *connection);
Evan@1427
   446
Evan@1427
   447
/**
Evan@653
   448
 * Updates the connection progress.
Evan@653
   449
 *
Evan@653
   450
 * @param gc    The connection.
Evan@653
   451
 * @param text  Information on the current step.
Evan@653
   452
 * @param step  The current step.
Evan@653
   453
 * @param count The total number of steps.
Evan@653
   454
 */
Evan@653
   455
void purple_connection_update_progress(PurpleConnection *gc, const char *text,
Evan@653
   456
									 size_t step, size_t count);
Evan@653
   457
Evan@653
   458
/**
Evan@653
   459
 * Displays a connection-specific notice.
Evan@653
   460
 *
Evan@653
   461
 * @param gc   The connection.
Evan@653
   462
 * @param text The notice text.
Evan@653
   463
 */
Evan@653
   464
void purple_connection_notice(PurpleConnection *gc, const char *text);
Evan@653
   465
Evan@653
   466
/**
Evan@653
   467
 * Closes a connection with an error.
Evan@653
   468
 *
Evan@653
   469
 * @param gc     The connection.
Evan@653
   470
 * @param reason The error text, which may not be @c NULL.
Evan@653
   471
 * @deprecated in favour of #purple_connection_error_reason.  Calling
Evan@653
   472
 *  @c purple_connection_error(gc, text) is equivalent to calling
Evan@653
   473
 *  @c purple_connection_error_reason(gc, reason, text) where @c reason is
Evan@653
   474
 *  #PURPLE_CONNECTION_ERROR_OTHER_ERROR if @c gc->wants_to_die is @c TRUE, and
Evan@653
   475
 *  #PURPLE_CONNECTION_ERROR_NETWORK_ERROR if not.  (This is to keep
Evan@653
   476
 *  auto-reconnection behaviour the same when using old prpls which don't use
Evan@653
   477
 *  reasons yet.)
Evan@653
   478
 */
Evan@653
   479
void purple_connection_error(PurpleConnection *gc, const char *reason);
Evan@653
   480
Evan@653
   481
/**
Evan@653
   482
 * Closes a connection with an error and a human-readable description of the
Evan@653
   483
 * error.  It also sets @c gc->wants_to_die to the value of
Evan@653
   484
 * #purple_connection_error_is_fatal(@a reason), mainly for
Evan@653
   485
 * backwards-compatibility.
Evan@653
   486
 *
Evan@653
   487
 * @param gc          the connection which is closing.
Evan@653
   488
 * @param reason      why the connection is closing.
Evan@653
   489
 * @param description a non-@c NULL localized description of the error.
Evan@1427
   490
 *
Evan@653
   491
 * @since 2.3.0
Evan@653
   492
 */
Evan@653
   493
void
Evan@653
   494
purple_connection_error_reason (PurpleConnection *gc,
Evan@653
   495
                                PurpleConnectionError reason,
Evan@653
   496
                                const char *description);
Evan@653
   497
Evan@653
   498
/**
Evan@653
   499
 * Closes a connection due to an SSL error; this is basically a shortcut to
Evan@653
   500
 * turning the #PurpleSslErrorType into a #PurpleConnectionError and a
Evan@653
   501
 * human-readable string and then calling purple_connection_error_reason().
Evan@1427
   502
 *
Evan@653
   503
 * @since 2.3.0
Evan@653
   504
 */
Evan@653
   505
void
Evan@653
   506
purple_connection_ssl_error (PurpleConnection *gc,
Evan@653
   507
                             PurpleSslErrorType ssl_error);
Evan@653
   508
Evan@653
   509
/**
Evan@653
   510
 * Reports whether a disconnection reason is fatal (in which case the account
Evan@653
   511
 * should probably not be automatically reconnected) or transient (so
Evan@653
   512
 * auto-reconnection is a good idea).
Evan@653
   513
 * For instance, #PURPLE_CONNECTION_ERROR_NETWORK_ERROR is a temporary error,
Evan@653
   514
 * which might be caused by losing the network connection, so <tt>
Evan@653
   515
 * purple_connection_error_is_fatal (PURPLE_CONNECTION_ERROR_NETWORK_ERROR)</tt>
Evan@653
   516
 * is @c FALSE.  On the other hand,
Evan@653
   517
 * #PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED probably indicates a
Evan@653
   518
 * misconfiguration of the account which needs the user to go fix it up, so
Evan@653
   519
 * <tt> purple_connection_error_is_fatal
Evan@653
   520
 * (PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED)</tt> is @c TRUE.
Evan@653
   521
 *
Evan@653
   522
 * (This function is meant to replace checking PurpleConnection.wants_to_die.)
Evan@653
   523
 *
Evan@653
   524
 * @return @c TRUE if the account should not be automatically reconnected, and
Evan@653
   525
 *         @c FALSE otherwise.
Evan@1427
   526
 *
Evan@653
   527
 * @since 2.3.0
Evan@653
   528
 */
Evan@653
   529
gboolean
Evan@653
   530
purple_connection_error_is_fatal (PurpleConnectionError reason);
Evan@653
   531
Evan@653
   532
/*@}*/
Evan@653
   533
Evan@653
   534
/**************************************************************************/
Evan@653
   535
/** @name Connections API                                                 */
Evan@653
   536
/**************************************************************************/
Evan@653
   537
/*@{*/
Evan@653
   538
Evan@653
   539
/**
Evan@653
   540
 * Disconnects from all connections.
Evan@653
   541
 */
Evan@653
   542
void purple_connections_disconnect_all(void);
Evan@653
   543
Evan@653
   544
/**
Evan@653
   545
 * Returns a list of all active connections.  This does not
Evan@653
   546
 * include connections that are in the process of connecting.
Evan@653
   547
 *
Evan@653
   548
 * @constreturn A list of all active connections.
Evan@653
   549
 */
Evan@653
   550
GList *purple_connections_get_all(void);
Evan@653
   551
Evan@653
   552
/**
Evan@653
   553
 * Returns a list of all connections in the process of connecting.
Evan@653
   554
 *
Evan@653
   555
 * @constreturn A list of connecting connections.
Evan@653
   556
 */
Evan@653
   557
GList *purple_connections_get_connecting(void);
Evan@653
   558
Evan@653
   559
/**
Evan@653
   560
 * Checks if gc is still a valid pointer to a gc.
Evan@653
   561
 *
Evan@653
   562
 * @return @c TRUE if gc is valid.
zacw@2504
   563
 *
zacw@2504
   564
 * @deprecated Do not use this.  Instead, cancel your asynchronous request
zacw@2504
   565
 *             when the PurpleConnection is destroyed.
Evan@653
   566
 */
Evan@653
   567
/*
Evan@653
   568
 * TODO: Eventually this bad boy will be removed, because it is
Evan@653
   569
 *       a gross fix for a crashy problem.
Evan@653
   570
 */
Evan@653
   571
#define PURPLE_CONNECTION_IS_VALID(gc) (g_list_find(purple_connections_get_all(), (gc)) != NULL)
Evan@653
   572
Evan@653
   573
/*@}*/
Evan@653
   574
Evan@653
   575
/**************************************************************************/
Evan@653
   576
/** @name UI Registration Functions                                       */
Evan@653
   577
/**************************************************************************/
Evan@653
   578
/*@{*/
Evan@653
   579
Evan@653
   580
/**
Evan@653
   581
 * Sets the UI operations structure to be used for connections.
Evan@653
   582
 *
Evan@653
   583
 * @param ops The UI operations structure.
Evan@653
   584
 */
Evan@653
   585
void purple_connections_set_ui_ops(PurpleConnectionUiOps *ops);
Evan@653
   586
Evan@653
   587
/**
Evan@653
   588
 * Returns the UI operations structure used for connections.
Evan@653
   589
 *
Evan@653
   590
 * @return The UI operations structure in use.
Evan@653
   591
 */
Evan@653
   592
PurpleConnectionUiOps *purple_connections_get_ui_ops(void);
Evan@653
   593
Evan@653
   594
/*@}*/
Evan@653
   595
Evan@653
   596
/**************************************************************************/
Evan@653
   597
/** @name Connections Subsystem                                           */
Evan@653
   598
/**************************************************************************/
Evan@653
   599
/*@{*/
Evan@653
   600
Evan@653
   601
/**
Evan@653
   602
 * Initializes the connections subsystem.
Evan@653
   603
 */
Evan@653
   604
void purple_connections_init(void);
Evan@653
   605
Evan@653
   606
/**
Evan@653
   607
 * Uninitializes the connections subsystem.
Evan@653
   608
 */
Evan@653
   609
void purple_connections_uninit(void);
Evan@653
   610
Evan@653
   611
/**
Evan@653
   612
 * Returns the handle to the connections subsystem.
Evan@653
   613
 *
Evan@653
   614
 * @return The connections subsystem handle.
Evan@653
   615
 */
Evan@653
   616
void *purple_connections_get_handle(void);
Evan@653
   617
Evan@653
   618
/*@}*/
Evan@653
   619
Evan@653
   620
Evan@653
   621
#ifdef __cplusplus
Evan@653
   622
}
Evan@653
   623
#endif
Evan@653
   624
Evan@653
   625
#endif /* _PURPLE_CONNECTION_H_ */