Thu, 24 Oct 2013 17:54:31 +0530
Added purple_connection_get_error_info()
--- a/ChangeLog.API Thu Oct 24 16:48:06 2013 +0530 +++ b/ChangeLog.API Thu Oct 24 17:54:31 2013 +0530 @@ -33,6 +33,7 @@ * purple_chat_user_set_ui_data * purple_chat_user_set_chat * purple_connection_get_active_chats + * purple_connection_get_error_info * purple_connection_get_flags * purple_connection_set_flags * purple_connection_update_last_received
--- a/libpurple/connection.c Thu Oct 24 16:48:06 2013 +0530 +++ b/libpurple/connection.c Thu Oct 24 17:54:31 2013 +0530 @@ -79,6 +79,9 @@ */ gboolean wants_to_die; + /** The connection error and its description if an error occured */ + PurpleConnectionErrorInfo *error_info; + guint disconnect_timeout; /**< Timer used for nasty stack tricks */ time_t last_received; /**< When we last received a packet. Set by the prpl to avoid sending unneeded keepalives */ @@ -105,6 +108,10 @@ static int connections_handle; +static PurpleConnectionErrorInfo * +purple_connection_error_info_new(PurpleConnectionError type, + const gchar *description); + /************************************************************************** * Connection API **************************************************************************/ @@ -446,8 +453,8 @@ void purple_connection_error (PurpleConnection *gc, - PurpleConnectionError reason, - const char *description) + PurpleConnectionError reason, + const char *description) { PurpleConnectionUiOps *ops; PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc); @@ -471,7 +478,7 @@ } /* If we've already got one error, we don't need any more */ - if (priv->disconnect_timeout > 0) + if (purple_connection_get_error_info(gc)) return; priv->wants_to_die = purple_connection_error_is_fatal (reason); @@ -484,6 +491,8 @@ if (ops && ops->report_disconnect) ops->report_disconnect(gc, reason, description); + priv->error_info = purple_connection_error_info_new(reason, description); + purple_signal_emit(purple_connections_get_handle(), "connection-error", gc, reason, description); @@ -491,6 +500,16 @@ purple_connection_get_account(gc)); } +PurpleConnectionErrorInfo * +purple_connection_get_error_info(const PurpleConnection *gc) +{ + PurpleConnectionPrivate *priv = PURPLE_CONNECTION_GET_PRIVATE(gc); + + g_return_val_if_fail(priv != NULL, TRUE); + + return priv->error_info; +} + void purple_connection_ssl_error (PurpleConnection *gc, PurpleSslErrorType ssl_error) @@ -555,21 +574,31 @@ priv->last_received = time(NULL); } +static PurpleConnectionErrorInfo * +purple_connection_error_info_new(PurpleConnectionError type, + const gchar *description) +{ + PurpleConnectionErrorInfo *err; + + g_return_val_if_fail(description != NULL, NULL); + + err = g_new(PurpleConnectionErrorInfo, 1); + + err->type = type; + err->description = g_strdup(description); + + return err; +} + /************************************************************************** * GBoxed code **************************************************************************/ static PurpleConnectionErrorInfo * purple_connection_error_info_copy(PurpleConnectionErrorInfo *err) { - PurpleConnectionErrorInfo *newerr; - g_return_val_if_fail(err != NULL, NULL); - newerr = g_new(PurpleConnectionErrorInfo, 1); - newerr->type = err->type; - newerr->description = g_strdup(err->description); - - return newerr; + return purple_connection_error_info_new(err->type, err->description); } static void @@ -755,6 +784,9 @@ purple_account_set_connection(account, NULL); + if (priv->error_info) + purple_connection_error_info_free(priv->error_info); + if (priv->disconnect_timeout > 0) purple_timeout_remove(priv->disconnect_timeout);
--- a/libpurple/connection.h Thu Oct 24 16:48:06 2013 +0530 +++ b/libpurple/connection.h Thu Oct 24 17:54:31 2013 +0530 @@ -386,7 +386,7 @@ * * @return The protocol data for the connection. */ -void *purple_connection_get_protocol_data(const PurpleConnection *connection); +void *purple_connection_get_protocol_data(const PurpleConnection *gc); /** * Updates the connection progress. @@ -413,7 +413,7 @@ * * @param gc the connection which is closing. * @param reason why the connection is closing. - * @param description a non-@c NULL localized description of the error. + * @param description a localized description of the error (not @c NULL ). */ void purple_connection_error(PurpleConnection *gc, @@ -421,6 +421,18 @@ const char *description); /** + * Returns the #PurpleConnectionErrorInfo instance of a connection if an + * error exists. + * + * @param gc The connection. + * + * @return The #PurpleConnectionErrorInfo instance of the connection if an + * error exists, @c NULL otherwise. + */ +PurpleConnectionErrorInfo * +purple_connection_get_error_info(const PurpleConnection *gc); + +/** * Closes a connection due to an SSL error; this is basically a shortcut to * turning the #PurpleSslErrorType into a #PurpleConnectionError and a * human-readable string and then calling purple_connection_error().
--- a/libpurple/protocols/jabber/parser.c Thu Oct 24 16:48:06 2013 +0530 +++ b/libpurple/protocols/jabber/parser.c Thu Oct 24 17:54:31 2013 +0530 @@ -308,10 +308,7 @@ } if (js->protocol_version.major == 0 && js->protocol_version.minor == 9 && -#if 0 - /* FIXME Is this required here? */ - !js->gc->disconnect_timeout && -#endif + !purple_connection_get_error_info(js->gc) && (js->state == JABBER_STREAM_INITIALIZING || js->state == JABBER_STREAM_INITIALIZING_ENCRYPTION)) { /*