im.pidgin.cpw.resiak.disconnectreason: d6c432d04466e50bb075c5c814cf85150f31a1fb
resiak at soc.pidgin.im
resiak at soc.pidgin.im
Tue Oct 9 09:45:59 EDT 2007
-----------------------------------------------------------------
Revision: d6c432d04466e50bb075c5c814cf85150f31a1fb
Ancestor: 9b07571878e8adb00763448bfb3c9b0de422c8b0
Author: resiak at soc.pidgin.im
Date: 2007-10-09T13:25:47
Branch: im.pidgin.cpw.resiak.disconnectreason
Modified files:
libpurple/connection.c libpurple/connection.h
ChangeLog:
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!
-------------- next part --------------
============================================================
--- libpurple/connection.c 5a2434e95f0bfb7b590ad00a748dba1959ac7ef7
+++ libpurple/connection.c 9a675b6653a914a2ce3297f3e2bc275ecc489306
@@ -488,7 +488,10 @@ purple_connection_error(PurpleConnection
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 @@ purple_connection_error_reason (PurpleCo
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)
============================================================
--- libpurple/connection.h d8dc8298166a4ef827513535b3d1f86e81c68dba
+++ libpurple/connection.h 23a623556ef0a41f710947004cbef501ce9c3df5
@@ -215,19 +215,23 @@ struct _PurpleConnection
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 @@ void purple_connection_destroy(PurpleCon
/**
* 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 @@ void purple_connection_notice(PurpleConn
* @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 @@ purple_connection_ssl_error (PurpleConne
/**
* 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);
More information about the Commits
mailing list