soc.2009.transport: 913bd4ae: Answer to disco#info for Ad-hoc command....

hanzz at soc.pidgin.im hanzz at soc.pidgin.im
Sun Jun 21 05:11:08 EDT 2009


-----------------------------------------------------------------
Revision: 913bd4aed7075ca58901bf899255295e22ed94bf
Ancestor: 3af8939828833ffee95056dc49037b53fe6fb8bc
Author: hanzz at soc.pidgin.im
Date: 2009-06-21T09:08:06
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/913bd4aed7075ca58901bf899255295e22ed94bf

Modified files:
        adhochandler.cpp discoinfohandler.cpp

ChangeLog: 

Answer to disco#info for Ad-hoc command. This should fix problems with Ad-hoc commands execution from Bombus client.

-------------- next part --------------
============================================================
--- adhochandler.cpp	eb81b81fd715a3a7b0067456eed3964a785599e0
+++ adhochandler.cpp	6e7e9462e60bb7b4f257741160f9993d744ede5a
@@ -64,7 +64,7 @@ Disco::ItemList GlooxAdhocHandler::handl
 			User *user = main->userManager()->getUserByJID(from);
 			if (user) {
 				for(std::map<std::string, adhocCommand>::iterator u = m_handlers.begin(); u != m_handlers.end() ; u++) {
-					lst.push_back( new Disco::Item( main->jid(),(*u).first, (std::string) tr(user->getLang(),(*u).second.name) ) );
+					lst.push_back( new Disco::Item( main->jid(),(*u).first, (std::string) tr(user->getLang(), "transport_" + (*u).second.name) ) );
 				}
 				if (user->isConnected() && purple_account_get_connection(user->account())) {
 					PurpleConnection *gc = purple_account_get_connection(user->account());
@@ -78,7 +78,7 @@ Disco::ItemList GlooxAdhocHandler::handl
 						for (l = actions; l != NULL; l = l->next) {
 							if (l->data) {
 								action = (PurplePluginAction *) l->data;
-								lst.push_back( new Disco::Item( main->jid(), (std::string) tr(user->getLang(), action->label), (std::string) action->label ) );
+								lst.push_back( new Disco::Item( main->jid(), (std::string) tr(user->getLang(), action->label), "transport_" + (std::string) action->label ) );
 								purple_plugin_action_free(action);
 							}
 						}
@@ -104,7 +104,7 @@ Disco::ItemList GlooxAdhocHandler::handl
 
 					for(l = ll = prpl_info->blist_node_menu((PurpleBlistNode*)buddy); l; l = l->next) {
 						PurpleMenuAction *action = (PurpleMenuAction *) l->data;
-						lst.push_back( new Disco::Item( _to.bare(), (std::string) tr(user->getLang(), action->label), (std::string) action->label ) );
+						lst.push_back( new Disco::Item( _to.bare(), (std::string) tr(user->getLang(), action->label), "transport_" + (std::string) action->label ) );
 						purple_menu_action_free(action);
 					}
 				}
@@ -156,7 +156,7 @@ bool GlooxAdhocHandler::handleIq( const 
 					for (l = actions; l != NULL; l = l->next) {
 						if (l->data) {
 							action = (PurplePluginAction *) l->data;
-							if (node == (std::string) action->label) {
+							if (node == "transport_" + (std::string) action->label) {
 								AdhocData data;
 								data.id = stanza.id();
 								data.from = stanza.from().full();
@@ -185,7 +185,7 @@ bool GlooxAdhocHandler::handleIq( const 
 
 				for(l = ll = prpl_info->blist_node_menu((PurpleBlistNode*)buddy); l; l = l->next) {
 					PurpleMenuAction *action = (PurpleMenuAction *) l->data;
-					if (node == (std::string) action->label) {
+					if (node == "transport_" + (std::string) action->label) {
 						void (*callback)(PurpleBlistNode *, gpointer);
 						callback = (void (*)(PurpleBlistNode *, gpointer))action->callback;
 						if (callback)
============================================================
--- discoinfohandler.cpp	a52350a6452a7a95dd9312d4d1ee92076d57d7d7
+++ discoinfohandler.cpp	9b15b6bda717ad0504c444bae027a703b4819797
@@ -89,6 +89,51 @@ bool GlooxDiscoInfoHandler::handleIq (co
 			return true;
 		}
 	}
+	else if (stanza.subtype() == IQ::Get) {
+		Tag *tag = stanza.tag();
+		Tag *query = tag->findChildWithAttrib("xmlns","http://jabber.org/protocol/disco#info");
+		std::string node = query->findAttribute("node");
+		if (node.find("transport_") == 0) {
+// 			<iq type='result'
+// 				to='requester at domain'
+// 				from='responder at domain'>
+// 			<query xmlns='http://jabber.org/protocol/disco#info'
+// 					node='config'>
+// 				<identity name='Configure Service'
+// 						category='automation'
+// 						type='command-node'/>
+// 				<feature var='http://jabber.org/protocol/commands'/>
+// 				<feature var='jabber:x:data'/>
+// 			</query>
+// 			</iq>
+			IQ _s(IQ::Result, stanza.from(), stanza.id());
+			_s.setFrom(stanza.to().full());
+			Tag *s = _s.tag();
+			Tag *query2 = new Tag("query");
+			query2->setXmlns("http://jabber.org/protocol/disco#info");
+			query2->addAttribute("node",node);
+			
+			Tag *t;
+			t = new Tag("identity");
+			t->addAttribute("category","gateway");
+// 			t->addAttribute("name","High Flyer Transport");
+			t->addAttribute("type",p->protocol()->gatewayIdentity());
+			query2->addChild(t);
+
+			t = new Tag("feature");
+			t->addAttribute("var","http://jabber.org/protocol/commands");
+			query2->addChild(t);
+
+			t = new Tag("feature");
+			t->addAttribute("var","jabber:x:data");
+			query2->addChild(t);
+
+			s->addChild(query2);
+			p->j->send( s );
+		}
+		delete tag;
+	}
+	
 	return true;
 }
 


More information about the Commits mailing list