Mercurial > pidgin
changeset 20813:66e7b104b4ea
rlaager pointed out that purple_connection_error_reason should be setting
wants_to_die appropriately to the reason, rather than leaving it up to the
prpl, so let's make it so!
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Tue, 09 Oct 2007 13:25:47 +0000 |
parents | 88aa557b997f |
children | bde477ec6a71 |
files | libpurple/connection.c libpurple/connection.h |
diffstat | 2 files changed, 29 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/connection.c Sun Oct 07 10:28:32 2007 +0000 +++ b/libpurple/connection.c Tue Oct 09 13:25:47 2007 +0000 @@ -488,7 +488,10 @@ void purple_connection_error(PurpleConnection *gc, const char *text) { - purple_connection_error_reason (gc, PURPLE_REASON_OTHER_ERROR, text); + PurpleDisconnectReason reason = gc->wants_to_die + ? PURPLE_REASON_OTHER_ERROR + : PURPLE_REASON_NETWORK_ERROR; + purple_connection_error_reason (gc, reason, text); } void @@ -497,28 +500,21 @@ const char *description) { PurpleConnectionUiOps *ops; - gboolean fatal; g_return_if_fail(gc != NULL); + g_assert (reason < PURPLE_NUM_REASONS); if (description == NULL) { purple_debug_error("connection", "purple_connection_error_reason: check `description != NULL' failed\n"); description = _("Unknown error"); } - g_assert (reason < PURPLE_NUM_REASONS); - - /* This should probably be removed at some point */ - fatal = purple_connection_reason_is_fatal (reason); - if (fatal != gc->wants_to_die) - purple_debug_warning ("connection", - "reason %u is %sfatal but wants_to_die is %u", - reason, (fatal ? "" : "not "), gc->wants_to_die); - /* If we've already got one error, we don't need any more */ if (gc->disconnect_timeout) return; + gc->wants_to_die = purple_connection_reason_is_fatal (reason); + ops = purple_connections_get_ui_ops(); if (ops != NULL)
--- a/libpurple/connection.h Sun Oct 07 10:28:32 2007 +0000 +++ b/libpurple/connection.h Tue Oct 09 13:25:47 2007 +0000 @@ -215,19 +215,23 @@ char *password; /**< The password used. */ int inpa; /**< The input watcher. */ - GSList *buddy_chats; /**< A list of active chats. */ + GSList *buddy_chats; /**< A list of active chats + (#PurpleConversation structs of type + #PURPLE_CONV_TYPE_CHAT). */ void *proto_data; /**< Protocol-specific data. */ char *display_name; /**< How you appear to other people. */ guint keepalive; /**< Keep-alive. */ + /** Wants to Die state. This is set when the user chooses to log out, or + * when the protocol is disconnected and should not be automatically + * reconnected (incorrect password, etc.). prpls should rely on + * purple_connection_error_reason() to set this for them rather than + * setting it themselves. + * @see purple_connection_reason_is_fatal + */ + gboolean wants_to_die; - gboolean wants_to_die; /**< Wants to Die state. This is set - when the user chooses to log out, - or when the protocol is - disconnected and should not be - automatically reconnected - (incorrect password, etc.) */ guint disconnect_timeout; /**< Timer used for nasty stack tricks */ }; @@ -285,7 +289,7 @@ /** * Sets the connection state. PRPLs should call this and pass in - * the state "PURPLE_CONNECTED" when the account is completely + * the state #PURPLE_CONNECTED when the account is completely * signed on. What does it mean to be completely signed on? If * the core can call prpl->set_status, and it successfully changes * your status, then the account is online. @@ -381,13 +385,17 @@ * @param reason The error text. * @deprecated in favour of #purple_connection_error_reason. Calling * @c purple_connection_error(gc, text) is equivalent to calling - * @c purple_connection_error_reason(gc, PURPLE_REASON_OTHER_ERROR, text). + * @c purple_connection_error_reason(gc, reason, text) where @c reason is + * #PURPLE_REASON_OTHER_ERROR if @c gc->wants_to_die is @c TRUE, and + * #PURPLE_REASON_NETWORK_ERROR if not. (This is to keep auto-reconnection + * behaviour the same when using old prpls which don't use reasons yet.) */ void purple_connection_error(PurpleConnection *gc, const char *reason); /** * Closes a connection with an error and an optional description of the - * error. + * error. It also sets @c gc->wants_to_die to the value of + * #purple_connection_reason_is_fatal(@a reason). * * @param reason why the connection is closing. * @param description a localized description of the error. @@ -409,19 +417,19 @@ /** * Reports whether a disconnection reason is fatal (in which case the account * should probably not be automatically reconnected) or transient (so - * auto-reconnection is a good idea. + * auto-reconnection is a good idea). * For instance, #PURPLE_REASON_NETWORK_ERROR is a temporary * error, which might be caused by losing the network connection, so * @a purple_connection_reason_is_fatal(PURPLE_REASON_NETWORK_ERROR) is - * @a FALSE. On the other hand, #PURPLE_REASON_AUTHENTICATION_FAILED probably + * @c FALSE. On the other hand, #PURPLE_REASON_AUTHENTICATION_FAILED probably * indicates a misconfiguration of the account which needs the user to go fix * it up, so @a * purple_connection_reason_is_fatal(PURPLE_REASON_AUTHENTICATION_FAILED) - * is @a TRUE. + * is @c TRUE. * * (This function is meant to replace checking PurpleConnection.wants_to_die.) * - * @return @a TRUE iff automatic reconnection is a bad idea. + * @return @c TRUE iff automatic reconnection is a bad idea. */ gboolean purple_connection_reason_is_fatal (PurpleDisconnectReason reason);