| 37 char *who; |
37 char *who; |
| 38 char *node; |
38 char *node; |
| 39 GList *actionslist; |
39 GList *actionslist; |
| 40 } JabberAdHocActionInfo; |
40 } JabberAdHocActionInfo; |
| 41 |
41 |
| 42 void jabber_adhoc_disco_result_cb(JabberStream *js, const char *from, |
42 static void |
| 43 JabberIqType type, const char *id, |
43 jabber_adhoc_got_buddy_list(JabberStream *js, const char *from, xmlnode *query) |
| 44 xmlnode *packet, gpointer data) |
44 { |
| 45 { |
45 JabberID *jid; |
| 46 const char *node; |
|
| 47 xmlnode *query, *item; |
|
| 48 JabberID *jabberid; |
|
| 49 JabberBuddy *jb; |
46 JabberBuddy *jb; |
| 50 JabberBuddyResource *jbr = NULL; |
47 JabberBuddyResource *jbr = NULL; |
| 51 |
48 xmlnode *item; |
| 52 if (type == JABBER_IQ_ERROR) |
49 |
| 53 return; |
50 if ((jid = jabber_id_new(from))) { |
| 54 |
51 if (jid->resource && (jb = jabber_buddy_find(js, from, TRUE))) |
| 55 query = xmlnode_get_child_with_namespace(packet,"query","http://jabber.org/protocol/disco#items"); |
52 jbr = jabber_buddy_find_resource(jb, jid->resource); |
| 56 if(!query) |
53 jabber_id_free(jid); |
| 57 return; |
|
| 58 node = xmlnode_get_attrib(query,"node"); |
|
| 59 if(!node || strcmp(node, "http://jabber.org/protocol/commands")) |
|
| 60 return; |
|
| 61 |
|
| 62 if((jabberid = jabber_id_new(from))) { |
|
| 63 if(jabberid->resource && (jb = jabber_buddy_find(js, from, TRUE))) |
|
| 64 jbr = jabber_buddy_find_resource(jb, jabberid->resource); |
|
| 65 jabber_id_free(jabberid); |
|
| 66 } |
54 } |
| 67 |
55 |
| 68 if(!jbr) |
56 if(!jbr) |
| 69 return; |
57 return; |
| 70 |
58 |
| 94 |
82 |
| 95 jbr->commands = g_list_append(jbr->commands,cmd); |
83 jbr->commands = g_list_append(jbr->commands,cmd); |
| 96 } |
84 } |
| 97 } |
85 } |
| 98 |
86 |
| |
87 void |
| |
88 jabber_adhoc_disco_result_cb(JabberStream *js, const char *from, |
| |
89 JabberIqType type, const char *id, |
| |
90 xmlnode *packet, gpointer data) |
| |
91 { |
| |
92 xmlnode *query; |
| |
93 const char *node; |
| |
94 |
| |
95 if (type == JABBER_IQ_ERROR) |
| |
96 return; |
| |
97 |
| |
98 query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#items"); |
| |
99 if (!query) |
| |
100 return; |
| |
101 node = xmlnode_get_attrib(query, "node"); |
| |
102 if (!purple_strequal(node, "http://jabber.org/protocol/commands")) |
| |
103 return; |
| |
104 |
| |
105 jabber_adhoc_got_buddy_list(js, from, query); |
| |
106 } |
| |
107 |
| 99 static void jabber_adhoc_parse(JabberStream *js, const char *from, |
108 static void jabber_adhoc_parse(JabberStream *js, const char *from, |
| 100 JabberIqType type, const char *id, |
109 JabberIqType type, const char *id, |
| 101 xmlnode *packet, gpointer data); |
110 xmlnode *packet, gpointer data); |
| 102 |
|
| 103 |
111 |
| 104 static void do_adhoc_action_cb(JabberStream *js, xmlnode *result, const char *actionhandle, gpointer user_data) { |
112 static void do_adhoc_action_cb(JabberStream *js, xmlnode *result, const char *actionhandle, gpointer user_data) { |
| 105 xmlnode *command; |
113 xmlnode *command; |
| 106 GList *action; |
114 GList *action; |
| 107 JabberAdHocActionInfo *actionInfo = user_data; |
115 JabberAdHocActionInfo *actionInfo = user_data; |
| 222 jabber_adhoc_execute(js, cmd); |
230 jabber_adhoc_execute(js, cmd); |
| 223 } |
231 } |
| 224 } |
232 } |
| 225 |
233 |
| 226 static void |
234 static void |
| 227 jabber_adhoc_server_got_list_cb(JabberStream *js, const char *from, |
235 jabber_adhoc_got_server_list(JabberStream *js, const char *from, xmlnode *query) |
| 228 JabberIqType type, const char *id, |
236 { |
| 229 xmlnode *packet, gpointer data) |
|
| 230 { |
|
| 231 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#items"); |
|
| 232 xmlnode *item; |
237 xmlnode *item; |
| 233 |
238 |
| 234 if(!query) |
239 if(!query) |
| 235 return; |
240 return; |
| 236 |
241 |
| 255 cmd->jid = g_strdup(xmlnode_get_attrib(item,"jid")); |
260 cmd->jid = g_strdup(xmlnode_get_attrib(item,"jid")); |
| 256 cmd->node = g_strdup(xmlnode_get_attrib(item,"node")); |
261 cmd->node = g_strdup(xmlnode_get_attrib(item,"node")); |
| 257 cmd->name = g_strdup(xmlnode_get_attrib(item,"name")); |
262 cmd->name = g_strdup(xmlnode_get_attrib(item,"name")); |
| 258 |
263 |
| 259 js->commands = g_list_append(js->commands,cmd); |
264 js->commands = g_list_append(js->commands,cmd); |
| |
265 } |
| |
266 |
| |
267 if (js->state == JABBER_STREAM_CONNECTED) |
| |
268 purple_prpl_got_account_actions(purple_connection_get_account(js->gc)); |
| |
269 } |
| |
270 |
| |
271 static void |
| |
272 jabber_adhoc_server_got_list_cb(JabberStream *js, const char *from, |
| |
273 JabberIqType type, const char *id, |
| |
274 xmlnode *packet, gpointer data) |
| |
275 { |
| |
276 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#items"); |
| |
277 |
| |
278 jabber_adhoc_got_server_list(js, from, query); |
| |
279 |
| |
280 } |
| |
281 |
| |
282 void jabber_adhoc_got_list(JabberStream *js, const char *from, xmlnode *query) |
| |
283 { |
| |
284 if (purple_strequal(from, js->user->domain)) { |
| |
285 jabber_adhoc_got_server_list(js, from, query); |
| |
286 } else { |
| |
287 jabber_adhoc_got_buddy_list(js, from, query); |
| 260 } |
288 } |
| 261 } |
289 } |
| 262 |
290 |
| 263 void jabber_adhoc_server_get_list(JabberStream *js) { |
291 void jabber_adhoc_server_get_list(JabberStream *js) { |
| 264 JabberIq *iq = jabber_iq_new_query(js,JABBER_IQ_GET,"http://jabber.org/protocol/disco#items"); |
292 JabberIq *iq = jabber_iq_new_query(js,JABBER_IQ_GET,"http://jabber.org/protocol/disco#items"); |