Merged soc.2013.gobjectification branch soc.2013.gobjectification.plugins

Thu, 24 Oct 2013 18:21:35 +0530

author
Ankit Vani <a@nevitus.org>
date
Thu, 24 Oct 2013 18:21:35 +0530
branch
soc.2013.gobjectification.plugins
changeset 36928
ae920fa34143
parent 36927
de37cfe2f1a0 (current diff)
parent 35044
8060985edd4a (diff)
child 36929
eed15b8d51a1

Merged soc.2013.gobjectification branch

ChangeLog.API file | annotate | diff | comparison | revisions
libpurple/connection.c file | annotate | diff | comparison | revisions
libpurple/connection.h file | annotate | diff | comparison | revisions
libpurple/plugins/dbus-example.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/jabber.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/jabber.h file | annotate | diff | comparison | revisions
libpurple/request.h file | annotate | diff | comparison | revisions
pidgin/gtkaccount.c file | annotate | diff | comparison | revisions
--- a/ChangeLog.API	Thu Oct 24 04:22:27 2013 +0530
+++ b/ChangeLog.API	Thu Oct 24 18:21:35 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/finch/gntxfer.h	Thu Oct 24 04:22:27 2013 +0530
+++ b/finch/gntxfer.h	Thu Oct 24 18:21:35 2013 +0530
@@ -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 @@
 
 /*@}*/
 
-#endif /* _FINCHFT_H_ */
+#endif /* _GNT_XFER_H_ */
--- a/libpurple/connection.c	Thu Oct 24 04:22:27 2013 +0530
+++ b/libpurple/connection.c	Thu Oct 24 18:21:35 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
 	                                protocols 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
  **************************************************************************/
@@ -441,8 +448,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);
@@ -466,7 +473,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);
@@ -479,6 +486,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);
 
@@ -486,6 +495,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)
@@ -550,21 +569,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
@@ -747,6 +776,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 04:22:27 2013 +0530
+++ b/libpurple/connection.h	Thu Oct 24 18:21:35 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/plugins/dbus-example.c	Thu Oct 24 04:22:27 2013 +0530
+++ b/libpurple/plugins/dbus-example.c	Thu Oct 24 18:21:35 2013 +0530
@@ -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>
--- a/libpurple/protocols/gg/blist.h	Thu Oct 24 04:22:27 2013 +0530
+++ b/libpurple/protocols/gg/blist.h	Thu Oct 24 18:21:35 2013 +0530
@@ -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 @@
  */
 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: */
--- a/libpurple/protocols/jabber/jabber.c	Thu Oct 24 04:22:27 2013 +0530
+++ b/libpurple/protocols/jabber/jabber.c	Thu Oct 24 18:21:35 2013 +0530
@@ -94,7 +94,6 @@
 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 @@
 
 	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 @@
 		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;
--- a/libpurple/protocols/jabber/jabber.h	Thu Oct 24 04:22:27 2013 +0530
+++ b/libpurple/protocols/jabber/jabber.h	Thu Oct 24 18:21:35 2013 +0530
@@ -275,6 +275,7 @@
 	guint keepalive_timeout;
 	guint max_inactivity;
 	guint inactivity_timer;
+	guint conn_close_timeout;
 
 	PurpleSrvResponse *srv_rec;
 	guint srv_rec_idx;
--- a/libpurple/protocols/jabber/jutil.c	Thu Oct 24 04:22:27 2013 +0530
+++ b/libpurple/protocols/jabber/jutil.c	Thu Oct 24 18:21:35 2013 +0530
@@ -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 @@
 	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"))
 		hash = purple_sha1_hash_new();
-	else if (g_str_equal(hash_algo, "md4"))
-		hash = purple_md4_hash_new();
+	else if (g_str_equal(hash_algo, "sha256"))
+		hash = purple_sha256_hash_new();
 	else if (g_str_equal(hash_algo, "md5"))
 		hash = purple_md5_hash_new();
+
 	if (hash == NULL)
 	{
 		purple_debug_error("jabber", "Could not find %s cipher\n", hash_algo);
--- a/libpurple/protocols/jabber/parser.c	Thu Oct 24 04:22:27 2013 +0530
+++ b/libpurple/protocols/jabber/parser.c	Thu Oct 24 18:21:35 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)) {
 		/*
--- a/libpurple/request.c	Thu Oct 24 04:22:27 2013 +0530
+++ b/libpurple/request.c	Thu Oct 24 18:21:35 2013 +0530
@@ -36,10 +36,16 @@
 
 typedef struct
 {
+	GDestroyNotify cb;
+	gpointer data;
+} PurpleRequestCloseNotified;
+
+typedef struct
+{
 	PurpleRequestType type;
 	void *handle;
 	void *ui_handle;
-
+	GSList *notify_on_close;
 } PurpleRequestInfo;
 
 struct _PurpleRequestField
@@ -447,6 +453,23 @@
 	return cpar->parent_from;
 }
 
+static PurpleRequestInfo *
+purple_request_info_from_ui_handle(void *ui_handle)
+{
+	GList *it;
+
+	g_return_val_if_fail(ui_handle != NULL, NULL);
+
+	for (it = handles; it != NULL; it = g_list_next(it)) {
+		PurpleRequestInfo *info = it->data;
+
+		if (info->ui_handle == ui_handle)
+			return info;
+	}
+
+	return NULL;
+}
+
 PurpleRequestFields *
 purple_request_fields_new(void)
 {
@@ -2312,29 +2335,47 @@
 gboolean
 purple_request_is_valid_ui_handle(void *ui_handle, PurpleRequestType *type)
 {
-	GList *it;
+	PurpleRequestInfo *info;
 
 	if (ui_handle == NULL)
 		return FALSE;
 
-	for (it = handles; it != NULL; it = g_list_next(it)) {
-		PurpleRequestInfo *info = it->data;
-
-		if (info->ui_handle != ui_handle)
-			continue;
-
-		if (type != NULL)
-			*type = info->type;
-		return TRUE;
-	}
-
-	return FALSE;
+	info = purple_request_info_from_ui_handle(ui_handle);
+
+	if (info == NULL)
+		return FALSE;
+
+	if (type != NULL)
+		*type = info->type;
+
+	return TRUE;
+}
+
+void
+purple_request_add_close_notify(void *ui_handle, GDestroyNotify notify,
+	gpointer notify_data)
+{
+	PurpleRequestInfo *info;
+	PurpleRequestCloseNotified *notified;
+
+	g_return_if_fail(ui_handle != NULL);
+	g_return_if_fail(notify != NULL);
+
+	info = purple_request_info_from_ui_handle(ui_handle);
+	g_return_if_fail(info != NULL);
+
+	notified = g_new0(PurpleRequestCloseNotified, 1);
+	notified->cb = notify;
+	notified->data = notify_data;
+
+	info->notify_on_close = g_slist_append(info->notify_on_close, notified);
 }
 
 static void
 purple_request_close_info(PurpleRequestInfo *info)
 {
 	PurpleRequestUiOps *ops;
+	GSList *it;
 
 	ops = purple_request_get_ui_ops();
 
@@ -2344,6 +2385,13 @@
 	if (ops != NULL && ops->close_request != NULL)
 		ops->close_request(info->type, info->ui_handle);
 
+	for (it = info->notify_on_close; it; it = g_slist_next(it)) {
+		PurpleRequestCloseNotified *notify = it->data;
+
+		notify->cb(notify->data);
+	}
+
+	g_slist_free_full(info->notify_on_close, g_free);
 	g_free(info);
 }
 
--- a/libpurple/request.h	Thu Oct 24 04:22:27 2013 +0530
+++ b/libpurple/request.h	Thu Oct 24 18:21:35 2013 +0530
@@ -1880,6 +1880,17 @@
 purple_request_is_valid_ui_handle(void *ui_handle, PurpleRequestType *type);
 
 /**
+ * Adds a function called when notification dialog is closed.
+ *
+ * @param ui_handle   The UI handle.
+ * @param notify      The function to be called.
+ * @param notify_data The data to be passed to the callback function.
+ */
+void
+purple_request_add_close_notify(void *ui_handle, GDestroyNotify notify,
+	gpointer notify_data);
+
+/**
  * Closes a request.
  *
  * @param type     The request type.
--- a/pidgin/gtkaccount.c	Thu Oct 24 04:22:27 2013 +0530
+++ b/pidgin/gtkaccount.c	Thu Oct 24 18:21:35 2013 +0530
@@ -164,10 +164,6 @@
 static void set_account(GtkListStore *store, GtkTreeIter *iter,
 						  PurpleAccount *account, GdkPixbuf *global_buddyicon);
 
-/* privacy UI ops */
-void pidgin_permit_added_removed(PurpleAccount *account, const char *name);
-void pidgin_deny_added_removed(PurpleAccount *account, const char *name);
-
 /**************************************************************************
  * Add/Modify Account dialog
  **************************************************************************/
@@ -2908,10 +2904,10 @@
 	pidgin_accounts_request_add,
 	pidgin_accounts_request_authorization,
 	pidgin_accounts_request_close,
-	pidgin_permit_added_removed,
-	pidgin_permit_added_removed,
-	pidgin_deny_added_removed,
-	pidgin_deny_added_removed,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
 	NULL, NULL, NULL, NULL
 };
 
--- a/pidgin/gtkprivacy.c	Thu Oct 24 04:22:27 2013 +0530
+++ b/pidgin/gtkprivacy.c	Thu Oct 24 18:21:35 2013 +0530
@@ -31,6 +31,7 @@
 #include "request.h"
 #include "util.h"
 
+#include "gtkaccount.h"
 #include "gtkblist.h"
 #include "gtkprivacy.h"
 #include "gtkutils.h"
@@ -90,9 +91,6 @@
 
 static PidginPrivacyDialog *privacy_dialog = NULL;
 
-void pidgin_permit_added_removed(PurpleAccount *account, const char *name);
-void pidgin_deny_added_removed(PurpleAccount *account, const char *name);
-
 static void
 rebuild_allow_list(PidginPrivacyDialog *dialog)
 {
@@ -559,14 +557,14 @@
 	}
 }
 
-void
+static void
 pidgin_permit_added_removed(PurpleAccount *account, const char *name)
 {
 	if (privacy_dialog != NULL)
 		rebuild_allow_list(privacy_dialog);
 }
 
-void
+static void
 pidgin_deny_added_removed(PurpleAccount *account, const char *name)
 {
 	if (privacy_dialog != NULL)
@@ -576,4 +574,8 @@
 void
 pidgin_privacy_init(void)
 {
+	PurpleAccountUiOps *ops = pidgin_accounts_get_ui_ops();
+
+	ops->permit_added = ops->permit_removed = pidgin_permit_added_removed;
+	ops->deny_added = ops->deny_removed = pidgin_deny_added_removed;
 }
--- a/pidgin/gtkxfer.h	Thu Oct 24 04:22:27 2013 +0530
+++ b/pidgin/gtkxfer.h	Thu Oct 24 18:21:35 2013 +0530
@@ -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 _PIDGINFT_H_
-#define _PIDGINFT_H_
+#ifndef _PIDGINXFER_H_
+#define _PIDGINXFER_H_
 
 #include "xfer.h"
 
@@ -149,4 +149,4 @@
 
 G_END_DECLS
 
-#endif /* _PIDGINFT_H_ */
+#endif /* _PIDGINXFER_H_ */

mercurial