comparison libpurple/connection.h @ 21358:ba41f2a60253

Rename: * PurpleDisconnectReason to PurpleConnectionError; * elements of that enum from PURPLE_REASON_* to PURPLE_CONNECTION_ERROR_*; * purple_connection_reason_is_fatal to purple_connection_error_is_fatal.
author Will Thompson <will.thompson@collabora.co.uk>
date Sun, 14 Oct 2007 21:08:42 +0000
parents 5a3242b676ad
children fe57b8062249
comparison
equal deleted inserted replaced
21357:5a3242b676ad 21358:ba41f2a60253
61 { 61 {
62 /** There was an error sending or receiving on the network socket, or 62 /** There was an error sending or receiving on the network socket, or
63 * there was some protocol error (such as the server sending malformed 63 * there was some protocol error (such as the server sending malformed
64 * data). 64 * data).
65 */ 65 */
66 PURPLE_REASON_NETWORK_ERROR = 0, 66 PURPLE_CONNECTION_ERROR_NETWORK_ERROR = 0,
67 /** The username or password (or some other credential) was incorrect. 67 /** The username or password (or some other credential) was incorrect.
68 */ 68 */
69 PURPLE_REASON_AUTHENTICATION_FAILED = 1, 69 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED = 1,
70 /** libpurple doesn't speak any of the authentication methods the 70 /** libpurple doesn't speak any of the authentication methods the
71 * server offered. 71 * server offered.
72 */ 72 */
73 PURPLE_REASON_AUTHENTICATION_IMPOSSIBLE = 2, 73 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE = 2,
74 /** libpurple was built without SSL support, and the connection needs 74 /** libpurple was built without SSL support, and the connection needs
75 * SSL. 75 * SSL.
76 */ 76 */
77 PURPLE_REASON_NO_SSL_SUPPORT = 3, 77 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT = 3,
78 /** There was an error negotiating SSL on this connection, or the 78 /** There was an error negotiating SSL on this connection, or the
79 * server does not support encryption but an account option was set to 79 * server does not support encryption but an account option was set to
80 * require it. 80 * require it.
81 */ 81 */
82 PURPLE_REASON_ENCRYPTION_ERROR = 4, 82 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR = 4,
83 /** Someone is already connected to the server using the name you are 83 /** Someone is already connected to the server using the name you are
84 * trying to connect with. 84 * trying to connect with.
85 */ 85 */
86 PURPLE_REASON_NAME_IN_USE = 5, 86 PURPLE_CONNECTION_ERROR_NAME_IN_USE = 5,
87 87
88 /** The username/server/other preference for the account isn't valid. 88 /** The username/server/other preference for the account isn't valid.
89 * For instance, on IRC the screen name cannot contain white space. 89 * For instance, on IRC the screen name cannot contain white space.
90 * This reason should not be used for incorrect passwords etc: use 90 * This reason should not be used for incorrect passwords etc: use
91 * #PURPLE_REASON_AUTHENTICATION_FAILED for that. 91 * #PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED for that.
92 * 92 *
93 * @todo This reason really shouldn't be necessary. Usernames and 93 * @todo This reason really shouldn't be necessary. Usernames and
94 * other account preferences should be validated when the 94 * other account preferences should be validated when the
95 * account is created. 95 * account is created.
96 */ 96 */
97 PURPLE_REASON_INVALID_SETTINGS = 6, 97 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS = 6,
98 98
99 /** The server did not provide a SSL certificate. */ 99 /** The server did not provide a SSL certificate. */
100 PURPLE_REASON_CERT_NOT_PROVIDED = 7, 100 PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED = 7,
101 /** The server's SSL certificate could not be trusted. */ 101 /** The server's SSL certificate could not be trusted. */
102 PURPLE_REASON_CERT_UNTRUSTED = 8, 102 PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED = 8,
103 /** The server's SSL certificate has expired. */ 103 /** The server's SSL certificate has expired. */
104 PURPLE_REASON_CERT_EXPIRED = 9, 104 PURPLE_CONNECTION_ERROR_CERT_EXPIRED = 9,
105 /** The server's SSL certificate is not yet valid. */ 105 /** The server's SSL certificate is not yet valid. */
106 PURPLE_REASON_CERT_NOT_ACTIVATED = 10, 106 PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED = 10,
107 /** The server's SSL certificate did not match its hostname. */ 107 /** The server's SSL certificate did not match its hostname. */
108 PURPLE_REASON_CERT_HOSTNAME_MISMATCH = 11, 108 PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH = 11,
109 /** The server's SSL certificate does not have the expected 109 /** The server's SSL certificate does not have the expected
110 * fingerprint. 110 * fingerprint.
111 */ 111 */
112 PURPLE_REASON_CERT_FINGERPRINT_MISMATCH = 12, 112 PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH = 12,
113 /** The server's SSL certificate is self-signed. */ 113 /** The server's SSL certificate is self-signed. */
114 PURPLE_REASON_CERT_SELF_SIGNED = 13, 114 PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED = 13,
115 /** There was some other error validating the server's SSL certificate. 115 /** There was some other error validating the server's SSL certificate.
116 */ 116 */
117 PURPLE_REASON_CERT_OTHER_ERROR = 14, 117 PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR = 14,
118 118
119 /** Some other error occured which fits into none of the other 119 /** Some other error occured which fits into none of the other
120 * categories. 120 * categories.
121 */ 121 */
122 /* purple_connection_error_reason() in connection.c uses the fact that 122 /* purple_connection_error_reason() in connection.c uses the fact that
123 * this is the last member of the enum when sanity-checking; if other 123 * this is the last member of the enum when sanity-checking; if other
124 * reasons are added after it, the check must be updated. 124 * reasons are added after it, the check must be updated.
125 */ 125 */
126 PURPLE_REASON_OTHER_ERROR = 15 126 PURPLE_CONNECTION_ERROR_OTHER_ERROR = 15
127 } PurpleDisconnectReason; 127 } PurpleConnectionError;
128 128
129 #include <time.h> 129 #include <time.h>
130 130
131 #include "account.h" 131 #include "account.h"
132 #include "plugin.h" 132 #include "plugin.h"
192 /** Called when an error causes a connection to be disconnected. 192 /** Called when an error causes a connection to be disconnected.
193 * Called before #disconnected. This op is intended to replace 193 * Called before #disconnected. This op is intended to replace
194 * #report_disconnect. If both are implemented, this will be called 194 * #report_disconnect. If both are implemented, this will be called
195 * first; however, there's no real reason to implement both. 195 * first; however, there's no real reason to implement both.
196 * @param reason why the connection ended, if known, or 196 * @param reason why the connection ended, if known, or
197 * #PURPLE_REASON_OTHER_ERROR, if not. 197 * #PURPLE_CONNECTION_ERROR_OTHER_ERROR, if not.
198 * @param text a localized message describing the disconnection 198 * @param text a localized message describing the disconnection
199 * in more detail to the user. 199 * in more detail to the user.
200 * @see #purple_connection_error_reason 200 * @see #purple_connection_error_reason
201 * @since 2.3.0 201 * @since 2.3.0
202 */ 202 */
203 void (*report_disconnect_reason)(PurpleConnection *gc, 203 void (*report_disconnect_reason)(PurpleConnection *gc,
204 PurpleDisconnectReason reason, 204 PurpleConnectionError reason,
205 const char *text); 205 const char *text);
206 206
207 void (*_purple_reserved1)(void); 207 void (*_purple_reserved1)(void);
208 void (*_purple_reserved2)(void); 208 void (*_purple_reserved2)(void);
209 void (*_purple_reserved3)(void); 209 void (*_purple_reserved3)(void);
231 /** Wants to Die state. This is set when the user chooses to log out, or 231 /** Wants to Die state. This is set when the user chooses to log out, or
232 * when the protocol is disconnected and should not be automatically 232 * when the protocol is disconnected and should not be automatically
233 * reconnected (incorrect password, etc.). prpls should rely on 233 * reconnected (incorrect password, etc.). prpls should rely on
234 * purple_connection_error_reason() to set this for them rather than 234 * purple_connection_error_reason() to set this for them rather than
235 * setting it themselves. 235 * setting it themselves.
236 * @see purple_connection_reason_is_fatal 236 * @see purple_connection_error_is_fatal
237 */ 237 */
238 gboolean wants_to_die; 238 gboolean wants_to_die;
239 239
240 guint disconnect_timeout; /**< Timer used for nasty stack tricks */ 240 guint disconnect_timeout; /**< Timer used for nasty stack tricks */
241 }; 241 };
389 * @param gc The connection. 389 * @param gc The connection.
390 * @param reason The error text. 390 * @param reason The error text.
391 * @deprecated in favour of #purple_connection_error_reason. Calling 391 * @deprecated in favour of #purple_connection_error_reason. Calling
392 * @c purple_connection_error(gc, text) is equivalent to calling 392 * @c purple_connection_error(gc, text) is equivalent to calling
393 * @c purple_connection_error_reason(gc, reason, text) where @c reason is 393 * @c purple_connection_error_reason(gc, reason, text) where @c reason is
394 * #PURPLE_REASON_OTHER_ERROR if @c gc->wants_to_die is @c TRUE, and 394 * #PURPLE_CONNECTION_ERROR_OTHER_ERROR if @c gc->wants_to_die is @c TRUE, and
395 * #PURPLE_REASON_NETWORK_ERROR if not. (This is to keep auto-reconnection 395 * #PURPLE_CONNECTION_ERROR_NETWORK_ERROR if not. (This is to keep
396 * behaviour the same when using old prpls which don't use reasons yet.) 396 * auto-reconnection behaviour the same when using old prpls which don't use
397 * reasons yet.)
397 */ 398 */
398 void purple_connection_error(PurpleConnection *gc, const char *reason); 399 void purple_connection_error(PurpleConnection *gc, const char *reason);
399 400
400 /** 401 /**
401 * Closes a connection with an error and an optional description of the 402 * Closes a connection with an error and an optional description of the
402 * error. It also sets @c gc->wants_to_die to the value of 403 * error. It also sets @c gc->wants_to_die to the value of
403 * #purple_connection_reason_is_fatal(@a reason). 404 * #purple_connection_error_is_fatal(@a reason).
404 * 405 *
405 * @param reason why the connection is closing. 406 * @param reason why the connection is closing.
406 * @param description a localized description of the error. 407 * @param description a localized description of the error.
407 * @since 2.3.0 408 * @since 2.3.0
408 */ 409 */
409 void 410 void
410 purple_connection_error_reason (PurpleConnection *gc, 411 purple_connection_error_reason (PurpleConnection *gc,
411 PurpleDisconnectReason reason, 412 PurpleConnectionError reason,
412 const char *description); 413 const char *description);
413 414
414 /** 415 /**
415 * Closes a connection due to an SSL error; this is basically a shortcut to 416 * Closes a connection due to an SSL error; this is basically a shortcut to
416 * turning the #PurpleSslErrorType into a #PurpleDisconnectReason and a 417 * turning the #PurpleSslErrorType into a #PurpleConnectionError and a
417 * human-readable string and then calling purple_connection_error_reason(). 418 * human-readable string and then calling purple_connection_error_reason().
418 * @since 2.3.0 419 * @since 2.3.0
419 */ 420 */
420 void 421 void
421 purple_connection_ssl_error (PurpleConnection *gc, 422 purple_connection_ssl_error (PurpleConnection *gc,
423 424
424 /** 425 /**
425 * Reports whether a disconnection reason is fatal (in which case the account 426 * Reports whether a disconnection reason is fatal (in which case the account
426 * should probably not be automatically reconnected) or transient (so 427 * should probably not be automatically reconnected) or transient (so
427 * auto-reconnection is a good idea). 428 * auto-reconnection is a good idea).
428 * For instance, #PURPLE_REASON_NETWORK_ERROR is a temporary 429 * For instance, #PURPLE_CONNECTION_ERROR_NETWORK_ERROR is a temporary
429 * error, which might be caused by losing the network connection, so 430 * error, which might be caused by losing the network connection, so
430 * @a purple_connection_reason_is_fatal(PURPLE_REASON_NETWORK_ERROR) is 431 * @c purple_connection_error_is_fatal
431 * @c FALSE. On the other hand, #PURPLE_REASON_AUTHENTICATION_FAILED probably 432 * (@c PURPLE_CONNECTION_ERROR_NETWORK_ERROR) is @c FALSE. On the other hand,
432 * indicates a misconfiguration of the account which needs the user to go fix 433 * #PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED probably indicates a
433 * it up, so @a 434 * misconfiguration of the account which needs the user to go fix it up, so
434 * purple_connection_reason_is_fatal(PURPLE_REASON_AUTHENTICATION_FAILED) 435 * @c purple_connection_error_is_fatal
435 * is @c TRUE. 436 * (@c PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED) is @c TRUE.
436 * 437 *
437 * (This function is meant to replace checking PurpleConnection.wants_to_die.) 438 * (This function is meant to replace checking PurpleConnection.wants_to_die.)
438 * 439 *
439 * @return @c TRUE if the account should not be automatically reconnected, and 440 * @return @c TRUE if the account should not be automatically reconnected, and
440 * @c FALSE otherwise. 441 * @c FALSE otherwise.
441 * @since 2.3.0 442 * @since 2.3.0
442 */ 443 */
443 gboolean 444 gboolean
444 purple_connection_reason_is_fatal (PurpleDisconnectReason reason); 445 purple_connection_error_is_fatal (PurpleConnectionError reason);
445 446
446 /*@}*/ 447 /*@}*/
447 448
448 /**************************************************************************/ 449 /**************************************************************************/
449 /** @name Connections API */ 450 /** @name Connections API */