/soc/2013/ankitkv/gobjectification: ae920fa34143: Merged soc.201...

Ankit Vani a at nevitus.org
Thu Oct 24 08:52:00 EDT 2013


Changeset: ae920fa3414351d186e08f01d347fa1147975d4e
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-10-24 18:21 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/ae920fa34143

Description:

Merged soc.2013.gobjectification branch

diffstat:

 ChangeLog.API                       |   1 +
 finch/gntxfer.h                     |   6 +-
 libpurple/connection.c              |  52 ++++++++++++++++++++----
 libpurple/connection.h              |  16 ++++++-
 libpurple/plugins/dbus-example.c    |   6 +--
 libpurple/protocols/gg/blist.h      |   6 +-
 libpurple/protocols/jabber/jabber.c |   9 ++-
 libpurple/protocols/jabber/jabber.h |   1 +
 libpurple/protocols/jabber/jutil.c  |  10 ++--
 libpurple/protocols/jabber/parser.c |   5 +-
 libpurple/request.c                 |  76 ++++++++++++++++++++++++++++++------
 libpurple/request.h                 |  11 +++++
 pidgin/gtkaccount.c                 |  12 +---
 pidgin/gtkprivacy.c                 |  12 +++--
 pidgin/gtkxfer.h                    |   6 +-
 15 files changed, 163 insertions(+), 66 deletions(-)

diffs (truncated from 563 to 300 lines):

diff --git a/ChangeLog.API b/ChangeLog.API
--- a/ChangeLog.API
+++ b/ChangeLog.API
@@ -33,6 +33,7 @@ version 3.0.0 (??/??/????):
 		* 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
diff --git a/finch/gntxfer.h b/finch/gntxfer.h
--- a/finch/gntxfer.h
+++ b/finch/gntxfer.h
@@ -23,8 +23,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
  */
-#ifndef _FINCHFT_H_
-#define _FINCHFT_H_
+#ifndef _GNT_XFER_H_
+#define _GNT_XFER_H_
 
 #include "xfer.h"
 
@@ -111,4 +111,4 @@ PurpleXferUiOps *finch_xfers_get_ui_ops(
 
 /*@}*/
 
-#endif /* _FINCHFT_H_ */
+#endif /* _GNT_XFER_H_ */
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -79,6 +79,9 @@ struct _PurpleConnectionPrivate
 	 */
 	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
 	                                protocols to avoid sending unneeded keepalives */
@@ -105,6 +108,10 @@ static PurpleConnectionUiOps *connection
 
 static int connections_handle;
 
+static PurpleConnectionErrorInfo *
+purple_connection_error_info_new(PurpleConnectionError type,
+                                 const gchar *description);
+
 /**************************************************************************
  * Connection API
  **************************************************************************/
@@ -441,8 +448,8 @@ purple_connection_disconnect_cb(gpointer
 
 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);
@@ -466,7 +473,7 @@ purple_connection_error (PurpleConnectio
 	}
 
 	/* 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);
@@ -479,6 +486,8 @@ purple_connection_error (PurpleConnectio
 	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);
 
@@ -486,6 +495,16 @@ purple_connection_error (PurpleConnectio
 			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)
@@ -550,21 +569,31 @@ void purple_connection_update_last_recei
 	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
@@ -747,6 +776,9 @@ purple_connection_finalize(GObject *obje
 
 	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);
 
diff --git a/libpurple/connection.h b/libpurple/connection.h
--- a/libpurple/connection.h
+++ b/libpurple/connection.h
@@ -386,7 +386,7 @@ const char *purple_connection_get_displa
  *
  * @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 @@ void purple_connection_notice(PurpleConn
  *
  * @param gc          the connection which is closing.
  * @param reason      why the connection is closing.
- * @param description a non- at 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 @@ purple_connection_error(PurpleConnection
                         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().
diff --git a/libpurple/plugins/dbus-example.c b/libpurple/plugins/dbus-example.c
--- a/libpurple/plugins/dbus-example.c
+++ b/libpurple/plugins/dbus-example.c
@@ -36,11 +36,7 @@
  */
 
 #include "internal.h"
-
-#include "buddylist.h"
-#include "notify.h"
-#include "plugins.h"
-#include "version.h"
+#include "purple.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libpurple/protocols/gg/blist.h b/libpurple/protocols/gg/blist.h
--- a/libpurple/protocols/gg/blist.h
+++ b/libpurple/protocols/gg/blist.h
@@ -21,8 +21,8 @@
  */
 
 
-#ifndef _PURPLE_GG_BUDDYLIST_H
-#define _PURPLE_GG_BUDDYLIST_H
+#ifndef _PURPLE_GG_BLIST_H
+#define _PURPLE_GG_BLIST_H
 
 #include "connection.h"
 #include "account.h"
@@ -61,7 +61,7 @@ ggp_buddylist_dump(PurpleAccount *accoun
  */
 const char * ggp_buddylist_get_buddy_name(PurpleConnection *gc, const uin_t uin);
 
-#endif /* _PURPLE_GG_BUDDYLIST_H */
+#endif /* _PURPLE_GG_BLIST_H */
 
 
 /* vim: set ts=8 sts=0 sw=8 noet: */
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -94,7 +94,6 @@ static PurpleProtocol *facebook_protocol
 static GHashTable *jabber_cmds = NULL; /* PurpleProtocol * => GSList of ids */
 
 static gint plugin_ref = 0;
-static guint conn_close_timeout = 0;
 
 static void jabber_unregister_account_cb(JabberStream *js);
 static void try_srv_connect(JabberStream *js);
@@ -1132,13 +1131,15 @@ conn_close_cb(gpointer data)
 
 	purple_account_disconnect(account);
 
+	js->conn_close_timeout = 0;
+
 	return FALSE;
 }
 
 static void
 jabber_connection_schedule_close(JabberStream *js)
 {
-	conn_close_timeout = purple_timeout_add(0, conn_close_cb, js);
+	js->conn_close_timeout = purple_timeout_add(0, conn_close_cb, js);
 }
 
 static void
@@ -1706,8 +1707,8 @@ void jabber_close(PurpleConnection *gc)
 		purple_timeout_remove(js->keepalive_timeout);
 	if (js->inactivity_timer != 0)
 		purple_timeout_remove(js->inactivity_timer);
-	if (conn_close_timeout != 0)
-		purple_timeout_remove(conn_close_timeout);
+	if (js->conn_close_timeout != 0)
+		purple_timeout_remove(js->conn_close_timeout);
 
 	g_free(js->srv_rec);
 	js->srv_rec = NULL;
diff --git a/libpurple/protocols/jabber/jabber.h b/libpurple/protocols/jabber/jabber.h
--- a/libpurple/protocols/jabber/jabber.h
+++ b/libpurple/protocols/jabber/jabber.h
@@ -275,6 +275,7 @@ struct _JabberStream
 	guint keepalive_timeout;
 	guint max_inactivity;
 	guint inactivity_timer;
+	guint conn_close_timeout;
 
 	PurpleSrvResponse *srv_rec;
 	guint srv_rec_idx;
diff --git a/libpurple/protocols/jabber/jutil.c b/libpurple/protocols/jabber/jutil.c
--- a/libpurple/protocols/jabber/jutil.c
+++ b/libpurple/protocols/jabber/jutil.c
@@ -32,9 +32,9 @@
 #include "presence.h"
 #include "jutil.h"
 
-#include "ciphers/md4hash.h"
+#include "ciphers/sha1hash.h"
+#include "ciphers/sha256hash.h"
 #include "ciphers/md5hash.h"
-#include "ciphers/sha1hash.h"
 
 #ifdef USE_IDN
 #include <idna.h>
@@ -742,13 +742,13 @@ jabber_calculate_data_hash(gconstpointer
 	PurpleHash *hash = NULL;
 	static gchar digest[129]; /* 512 bits hex + \0 */
 
-	/* FIXME: Check the source of this change and what we need here... */
 	if (g_str_equal(hash_algo, "sha1"))



More information about the Commits mailing list