pidgin: 7d05235d: Add the XMPP signals to the signals-test...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Fri May 22 01:35:46 EDT 2009


-----------------------------------------------------------------
Revision: 7d05235d2c1a49697d1c5064fccd9f3b96ec72b6
Ancestor: 122e7022b562ad4e1efe3289c682fe972dd9ae91
Author: darkrain42 at pidgin.im
Date: 2009-05-22T05:09:12
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/7d05235d2c1a49697d1c5064fccd9f3b96ec72b6

Modified files:
        libpurple/plugins/signals-test.c

ChangeLog: 

Add the XMPP signals to the signals-test plugin

-------------- next part --------------
============================================================
--- libpurple/plugins/signals-test.c	c0bbcda4e92bb62a954e7188819ee3da3b02be74
+++ libpurple/plugins/signals-test.c	cad02c444d9d6c567dc3cc98be93537d5b4fb912
@@ -624,6 +624,43 @@ notify_emails_cb(char **subjects, char *
 }
 
 /**************************************************************************
+ * 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 @@ plugin_load(PurplePlugin *plugin)
 	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,9 +821,27 @@ plugin_load(PurplePlugin *plugin)
 	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;
+}
+
 static PurplePluginInfo info =
 {
 	PURPLE_PLUGIN_MAGIC,
@@ -808,7 +864,7 @@ static PurplePluginInfo info =
 	PURPLE_WEBSITE,                                     /**< homepage       */
 
 	plugin_load,                                      /**< load           */
-	NULL,                                             /**< unload         */
+	plugin_unload,                                    /**< unload         */
 	NULL,                                             /**< destroy        */
 
 	NULL,                                             /**< ui_info        */


More information about the Commits mailing list