pidgin: 6bcd7cfc: Add a new signal which is emitted (after...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun Apr 26 13:05:52 EDT 2009


-----------------------------------------------------------------
Revision: 6bcd7cfc161122f058f5093da0fab2dceeec0cfa
Ancestor: 83592c610006db8f5109ca540344521661236cad
Author: darkrain42 at pidgin.im
Date: 2009-04-26T06:45:55
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/6bcd7cfc161122f058f5093da0fab2dceeec0cfa

Modified files:
        ChangeLog ChangeLog.API doc/account-signals.dox
        finch/gntblist.c libpurple/account.c
        libpurple/protocols/jabber/adhoccommands.c
        libpurple/protocols/jabber/adhoccommands.h
        libpurple/protocols/jabber/message.c libpurple/prpl.c
        libpurple/prpl.h pidgin/gtkblist.c

ChangeLog: 

Add a new signal which is emitted (after the account is connected) if the
associated account actions are changed. This is necessary since XMPP's
account actions are not known when setting the account to connected. Also
added support for push updates as specified in XEP-0050 2.3.

Refs #7233.

-------------- next part --------------
============================================================
--- ChangeLog	13bb4559bc289d35a8385606b3ec0cc85e6f2ee3
+++ ChangeLog	8a921c5211f4d7595db407d5e117f2587a8ab666
@@ -26,6 +26,8 @@ version 2.6.0 (??/??/2009):
 	* Fix crash on connection with recent gstreamer0.10-plugins-bad.
 	* Don't create a new conversation window for incoming messages of
 	  type 'headline'.
+	* The Ad-Hoc commands associated with our server are now always shown at
+	  login.
 
 	IRC:
 	* Correctly handle WHOIS for users who are joined to a large number of
============================================================
--- ChangeLog.API	a555b10c153bfb9cf9bfebe3117274c33fb5ee7a
+++ ChangeLog.API	3314ceaba0004f34ae95317a7d71a14950034ef6
@@ -9,6 +9,7 @@ version 2.6.0 (??/??/2009):
 		* PURPLE_CONTACT
 		* PURPLE_BUDDY
 		* PURPLE_CHAT
+		* account-actions-changed (see account-signals.dox)
 		* purple_buddy_destroy
 		* purple_buddy_get_protocol_data
 		* purple_buddy_set_protocol_data
@@ -32,6 +33,7 @@ version 2.6.0 (??/??/2009):
 		* purple_network_get_stun_ip
 		* purple_network_get_turn_ip
 		* purple_prpl_get_media_caps
+		* purple_prpl_got_account_actions
 		* purple_prpl_initiate_media
 		* purple_request_field_get_group
 		* purple_request_field_get_ui_data
============================================================
--- doc/account-signals.dox	247415f9faa5a8b1ccee21b533aa7fa12b42f898
+++ doc/account-signals.dox	aa104adec82568d433a16c118e3f3f046ba54289
@@ -9,6 +9,7 @@
   @signal account-setting-info
   @signal account-set-info
   @signal account-status-changed
+  @signal account-actions-changed
   @signal account-alias-changed
   @signal account-authorization-requested
   @signal account-authorization-denied
@@ -97,6 +98,15 @@ void (*account_status_changed)(PurpleAcc
   @param new     The status after change.
  @endsignaldef
 
+ @signaldef account-actions-changed
+  @signalproto
+void (*account_actions_changed)(PurpleAccount *account);
+  @endsignalproto
+  @signaldesc
+   Emitted when the account actions are changed after initial connection.
+  @param account The account whose actions changed.
+ @endsignaldef
+
  @signaldef account-alias-changed
   @signalproto
 void (*account_alias_changed)(PurpleAccount *account, const char *old);
============================================================
--- finch/gntblist.c	65a72670877e66b083d13b0addc6a1e48c8b1220
+++ finch/gntblist.c	603aaf81c42454c96d5feebd74102c082ff49a11
@@ -3123,6 +3123,8 @@ blist_show(PurpleBuddyList *list)
 				PURPLE_CALLBACK(reconstruct_accounts_menu), NULL);
 	purple_signal_connect(purple_connections_get_handle(), "signed-off", finch_blist_get_handle(),
 				PURPLE_CALLBACK(reconstruct_accounts_menu), NULL);
+	purple_signal_connect(purple_accounts_get_handle(), "account-actions-changed", finch_blist_get_handle(),
+				PURPLE_CALLBACK(reconstruct_accounts_menu), NULL);
 	purple_signal_connect(purple_blist_get_handle(), "buddy-status-changed", finch_blist_get_handle(),
 				PURPLE_CALLBACK(buddy_status_changed), ggblist);
 	purple_signal_connect(purple_blist_get_handle(), "buddy-idle-changed", finch_blist_get_handle(),
============================================================
--- libpurple/account.c	1381740959655ea35b24368ed79f9de5ebd31bea
+++ libpurple/account.c	1e14b918b175465951bc9d012bc277d5911e3ccc
@@ -2742,6 +2742,10 @@ purple_accounts_init(void)
 						 purple_value_new(PURPLE_TYPE_SUBTYPE,
 										PURPLE_SUBTYPE_STATUS));
 
+	purple_signal_register(handle, "account-actions-changed",
+						 purple_marshal_VOID__POINTER, NULL, 1,
+						 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT));
+
 	purple_signal_register(handle, "account-alias-changed",
 						 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
 						 purple_value_new(PURPLE_TYPE_SUBTYPE,
============================================================
--- libpurple/protocols/jabber/adhoccommands.c	855252c767e3b29b5e7ebadb7f56398df6fb57b7
+++ libpurple/protocols/jabber/adhoccommands.c	b2cedfb3034e16377a84810ccde999d98aae34da
@@ -39,30 +39,18 @@ typedef struct _JabberAdHocActionInfo {
 	GList *actionslist;
 } JabberAdHocActionInfo;
 
-void jabber_adhoc_disco_result_cb(JabberStream *js, const char *from,
-                                  JabberIqType type, const char *id,
-                                  xmlnode *packet, gpointer data)
+static void
+jabber_adhoc_got_buddy_list(JabberStream *js, const char *from, xmlnode *query)
 {
-	const char *node;
-	xmlnode *query, *item;
-	JabberID *jabberid;
+	JabberID *jid;
 	JabberBuddy *jb;
 	JabberBuddyResource *jbr = NULL;
+	xmlnode *item;
 
-	if (type == JABBER_IQ_ERROR)
-		return;
-
-	query = xmlnode_get_child_with_namespace(packet,"query","http://jabber.org/protocol/disco#items");
-	if(!query)
-		return;
-	node = xmlnode_get_attrib(query,"node");
-	if(!node || strcmp(node, "http://jabber.org/protocol/commands"))
-		return;
-
-	if((jabberid = jabber_id_new(from))) {
-		if(jabberid->resource && (jb = jabber_buddy_find(js, from, TRUE)))
-			jbr = jabber_buddy_find_resource(jb, jabberid->resource);
-		jabber_id_free(jabberid);
+	if ((jid = jabber_id_new(from))) {
+		if (jid->resource && (jb = jabber_buddy_find(js, from, TRUE)))
+			jbr = jabber_buddy_find_resource(jb, jid->resource);
+		jabber_id_free(jid);
 	}
 
 	if(!jbr)
@@ -96,11 +84,31 @@ void jabber_adhoc_disco_result_cb(Jabber
 	}
 }
 
+void
+jabber_adhoc_disco_result_cb(JabberStream *js, const char *from,
+                             JabberIqType type, const char *id,
+                             xmlnode *packet, gpointer data)
+{
+	xmlnode *query;
+	const char *node;
+
+	if (type == JABBER_IQ_ERROR)
+		return;
+
+	query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#items");
+	if (!query)
+		return;
+	node = xmlnode_get_attrib(query, "node");
+	if (!purple_strequal(node, "http://jabber.org/protocol/commands"))
+		return;
+
+	jabber_adhoc_got_buddy_list(js, from, query);
+}
+
 static void jabber_adhoc_parse(JabberStream *js, const char *from,
                                JabberIqType type, const char *id,
                                xmlnode *packet, gpointer data);
 
-
 static void do_adhoc_action_cb(JabberStream *js, xmlnode *result, const char *actionhandle, gpointer user_data) {
 	xmlnode *command;
 	GList *action;
@@ -224,11 +232,8 @@ static void
 }
 
 static void
-jabber_adhoc_server_got_list_cb(JabberStream *js, const char *from,
-                                JabberIqType type, const char *id,
-                                xmlnode *packet, gpointer data)
+jabber_adhoc_got_server_list(JabberStream *js, const char *from, xmlnode *query)
 {
-	xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#items");
 	xmlnode *item;
 
 	if(!query)
@@ -258,8 +263,31 @@ jabber_adhoc_server_got_list_cb(JabberSt
 
 		js->commands = g_list_append(js->commands,cmd);
 	}
+
+	if (js->state == JABBER_STREAM_CONNECTED)
+		purple_prpl_got_account_actions(purple_connection_get_account(js->gc));
 }
 
+static void
+jabber_adhoc_server_got_list_cb(JabberStream *js, const char *from,
+                                JabberIqType type, const char *id,
+                                xmlnode *packet, gpointer data)
+{
+	xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#items");
+
+	jabber_adhoc_got_server_list(js, from, query);
+
+}
+
+void jabber_adhoc_got_list(JabberStream *js, const char *from, xmlnode *query)
+{
+	if (purple_strequal(from, js->user->domain)) {
+		jabber_adhoc_got_server_list(js, from, query);
+	} else {
+		jabber_adhoc_got_buddy_list(js, from, query);
+	}
+}
+
 void jabber_adhoc_server_get_list(JabberStream *js) {
 	JabberIq *iq = jabber_iq_new_query(js,JABBER_IQ_GET,"http://jabber.org/protocol/disco#items");
 	xmlnode *query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#items");
============================================================
--- libpurple/protocols/jabber/adhoccommands.h	8d18780c8a1e587a5371fc095ce7d58f72bea793
+++ libpurple/protocols/jabber/adhoccommands.h	17162402cae8dbec0e0384ba080dcc9747bcff06
@@ -34,6 +34,8 @@ void jabber_adhoc_execute_action(PurpleB
 
 void jabber_adhoc_execute_action(PurpleBlistNode *node, gpointer data);
 
+void jabber_adhoc_got_list(JabberStream *js, const char *from, xmlnode *query);
+
 void jabber_adhoc_server_get_list(JabberStream *js);
 
 void jabber_adhoc_init_server_commands(JabberStream *js, GList **m);
============================================================
--- libpurple/protocols/jabber/message.c	cbd33175ecd35c6b1fa712d1723f052825478df2
+++ libpurple/protocols/jabber/message.c	53d42c196b00568b4de63ccc24413b21f9b3afee
@@ -24,6 +24,7 @@
 #include "notify.h"
 #include "server.h"
 #include "util.h"
+#include "adhoccommands.h"
 #include "buddy.h"
 #include "chat.h"
 #include "data.h"
@@ -780,6 +781,12 @@ void jabber_message_parse(JabberStream *
 			} else {
 				jm->etc = g_list_append(jm->etc, child);
 			}
+		} else if (g_str_equal(child->name, "query")) {
+			const char *node = xmlnode_get_attrib(child, "node");
+			if (purple_strequal(xmlns, "http://jabber.org/protocol/disco#items")
+					&& purple_strequal(node, "http://jabber.org/protocol/commands")) {
+				jabber_adhoc_got_list(js, jm->from, child);
+			}
 		}
 	}
 
============================================================
--- libpurple/prpl.c	956491630baa6b5447264e8a4e44d4e1a7782d1e
+++ libpurple/prpl.c	4776c5f5236811baf3015d81bb490ad8af9f775d
@@ -182,6 +182,17 @@ void
 }
 
 void
+purple_prpl_got_account_actions(PurpleAccount *account)
+{
+
+	g_return_if_fail(account != NULL);
+	g_return_if_fail(purple_account_is_connected(account));
+
+	purple_signal_emit(purple_accounts_get_handle(), "account-actions-changed",
+	                   account);
+}
+
+void
 purple_prpl_got_user_idle(PurpleAccount *account, const char *name,
 		gboolean idle, time_t idle_time)
 {
============================================================
--- libpurple/prpl.h	b7845aba7e07168be2cea73ea1ea4179d29036dd
+++ libpurple/prpl.h	620d5a0b2d88617bed8ec93c777bba58e6aec95e
@@ -661,6 +661,20 @@ void purple_prpl_got_account_status(Purp
 								  const char *status_id, ...) G_GNUC_NULL_TERMINATED;
 
 /**
+ * Notifies Purple that our account's actions have changed. This is only
+ * called after the initial connection. Emits the account-actions-changed
+ * signal.
+ *
+ * This is meant to be called from protocol plugins.
+ *
+ * @param account   The account.
+ *
+ * @see account-actions-changed
+ * @since 2.6.0
+ */
+void purple_prpl_got_account_actions(PurpleAccount *account);
+
+/**
  * Notifies Purple that a buddy's idle state and time have changed.
  *
  * This is meant to be called from protocol plugins.
============================================================
--- pidgin/gtkblist.c	401d1dd56b46e8896207a42474361c142116b9da
+++ pidgin/gtkblist.c	ca6640cfe35d9bf54b28750c58cb4304062d37cc
@@ -4652,6 +4652,12 @@ static void
 }
 
 static void
+account_actions_changed(PurpleAccount *account, gpointer data)
+{
+	pidgin_blist_update_accounts_menu();
+}
+
+static void
 account_status_changed(PurpleAccount *account, PurpleStatus *old,
 					   PurpleStatus *new, PidginBuddyList *gtkblist)
 {
@@ -5837,6 +5843,8 @@ static void pidgin_blist_show(PurpleBudd
 	purple_signal_connect(handle, "account-error-changed", gtkblist,
 	                      PURPLE_CALLBACK(update_account_error_state),
 	                      gtkblist);
+	purple_signal_connect(handle, "account-actions-changed", gtkblist,
+	                      PURPLE_CALLBACK(account_actions_changed), NULL);
 
 	handle = pidgin_account_get_handle();
 	purple_signal_connect(handle, "account-modified", gtkblist,


More information about the Commits mailing list