changeset 26936:e0f6c61ba779

Add the XMPP signals to the signals-test plugin
author Paul Aurich <paul@darkrain42.org>
date Fri, 22 May 2009 05:09:12 +0000
parents 31f65046b92d
children 74c9f4f79825
files libpurple/plugins/signals-test.c
diffstat 1 files changed, 57 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/plugins/signals-test.c	Fri May 22 04:56:05 2009 +0000
+++ b/libpurple/plugins/signals-test.c	Fri May 22 05:09:12 2009 +0000
@@ -624,6 +624,43 @@
 }
 
 /**************************************************************************
+ * Jabber signals callbacks
+ **************************************************************************/
+static gboolean
+jabber_iq_received(PurpleConnection *pc, const char *type, const char *id,
+                   const char *from, xmlnode *iq)
+{
+	purple_debug_misc("signals test", "received IQ (type=%s, id=%s, from=%s) %p\n",
+	                  type, id, from, iq);
+
+	/* We don't want the plugin to stop processing */
+	return FALSE;
+}
+
+static gboolean
+jabber_message_received(PurpleConnection *pc, const char *type, const char *id,
+                        const char *from, const char *to, xmlnode *message)
+{
+	purple_debug_misc("signals test", "received message (type=%s, id=%s, "
+	                  "from=%s to=%s) %p\n",
+	                  type, id, from, to, message);
+
+	/* We don't want the plugin to stop processing */
+	return FALSE;
+}
+
+static gboolean
+jabber_presence_received(PurpleConnection *pc, const char *type,
+                         const char *from, xmlnode *presence)
+{
+	purple_debug_misc("signals test", "received presence (type=%s, from=%s) %p\n",
+	                  type, from, presence);
+
+	/* We don't want the plugin to stop processing */
+	return FALSE;
+}
+
+/**************************************************************************
  * Plugin stuff
  **************************************************************************/
 static gboolean
@@ -638,6 +675,7 @@
 	void *ft_handle       = purple_xfers_get_handle();
 	void *sound_handle    = purple_sounds_get_handle();
 	void *notify_handle   = purple_notify_get_handle();
+	void *jabber_handle   = purple_plugins_find_with_id("prpl-jabber");
 
 	/* Accounts subsystem signals */
 	purple_signal_connect(accounts_handle, "account-connecting",
@@ -783,6 +821,24 @@
 	purple_signal_connect(notify_handle, "displaying-emails-notification",
 						plugin, PURPLE_CALLBACK(notify_emails_cb), NULL);
 
+	/* Jabber signals */
+	if (jabber_handle) {
+		purple_signal_connect(jabber_handle, "jabber-receiving-iq", plugin,
+		                      PURPLE_CALLBACK(jabber_iq_received), NULL);
+		purple_signal_connect(jabber_handle, "jabber-receiving-message", plugin,
+		                      PURPLE_CALLBACK(jabber_message_received), NULL);
+		purple_signal_connect(jabber_handle, "jabber-receiving-presence", plugin,
+		                      PURPLE_CALLBACK(jabber_presence_received), NULL);
+	}
+
+	return TRUE;
+}
+
+static gboolean
+plugin_unload(PurplePlugin *plugin)
+{
+	purple_signals_disconnect_by_handle(plugin);
+
 	return TRUE;
 }
 
@@ -808,7 +864,7 @@
 	PURPLE_WEBSITE,                                     /**< homepage       */
 
 	plugin_load,                                      /**< load           */
-	NULL,                                             /**< unload         */
+	plugin_unload,                                    /**< unload         */
 	NULL,                                             /**< destroy        */
 
 	NULL,                                             /**< ui_info        */