47 |
47 |
48 #define DESCRIPTION ( "Service discovery requests\nProvides command /disco" ) |
48 #define DESCRIPTION ( "Service discovery requests\nProvides command /disco" ) |
49 |
49 |
50 static module_info_t info_disco_dev = { |
50 static module_info_t info_disco_dev = { |
51 .branch = "dev", |
51 .branch = "dev", |
52 .api = 13, |
52 .api = 20, |
53 .version = PROJECT_VERSION, |
53 .version = PROJECT_VERSION, |
54 .description = DESCRIPTION, |
54 .description = DESCRIPTION, |
55 .requires = NULL, |
55 .requires = NULL, |
56 .init = disco_init, |
56 .init = disco_init, |
57 .uninit = disco_uninit, |
57 .uninit = disco_uninit, |
58 .next = NULL, |
58 .next = NULL, |
59 }; |
59 }; |
60 |
60 |
61 module_info_t info_disco = { |
61 module_info_t info_disco_0_10_0 = { |
62 .branch = "0.10.0", |
62 .branch = "0.10.0", |
63 .api = 1, |
63 .api = 1, |
64 .version = PROJECT_VERSION, |
64 .version = PROJECT_VERSION, |
65 .description = DESCRIPTION, |
65 .description = DESCRIPTION, |
66 .requires = NULL, |
66 .requires = NULL, |
67 .init = disco_init, |
67 .init = disco_init, |
68 .uninit = disco_uninit, |
68 .uninit = disco_uninit, |
69 .next = &info_disco_dev, |
69 .next = &info_disco_dev, |
70 }; |
70 }; |
71 |
71 |
|
72 module_info_t info_disco = { |
|
73 .branch = "0.10.1", |
|
74 .api = 1, |
|
75 .version = PROJECT_VERSION, |
|
76 .description = DESCRIPTION, |
|
77 .requires = NULL, |
|
78 .init = disco_init, |
|
79 .uninit = disco_uninit, |
|
80 .next = &info_disco_0_10_0, |
|
81 }; |
|
82 |
72 // |
83 // |
73 // private types |
84 // private types |
74 // |
85 // |
75 |
86 |
76 // lm message handler userdata |
87 // lm message handler userdata |
172 identity -> reserved = NULL; |
183 identity -> reserved = NULL; |
173 |
184 |
174 identities = g_slist_append (identities, identity); |
185 identities = g_slist_append (identities, identity); |
175 } else if (!strcasecmp (node->name, "feature")) |
186 } else if (!strcasecmp (node->name, "feature")) |
176 features = g_slist_insert_sorted (features, (gpointer) lm_message_node_get_attribute (node, "var"), (GCompareFunc) g_strcmp0); |
187 features = g_slist_insert_sorted (features, (gpointer) lm_message_node_get_attribute (node, "var"), (GCompareFunc) g_strcmp0); |
177 |
188 |
178 // call handler |
189 // call handler |
179 cb -> handler (identities, features, cb -> data); |
190 cb -> handler (identities, features, cb -> data); |
180 |
191 |
181 { // free resources |
192 { // free resources |
182 GSList *iel; |
193 GSList *iel; |
250 item -> jid = lm_message_node_get_attribute (node, "jid"); |
261 item -> jid = lm_message_node_get_attribute (node, "jid"); |
251 item -> node = lm_message_node_get_attribute (node, "node"); |
262 item -> node = lm_message_node_get_attribute (node, "node"); |
252 |
263 |
253 items = g_slist_append (items, item); |
264 items = g_slist_append (items, item); |
254 } |
265 } |
255 |
266 |
256 // call handler |
267 // call handler |
257 cb -> handler (items, cb -> data); |
268 cb -> handler (items, cb -> data); |
258 |
269 |
259 { // free resources |
270 { // free resources |
260 GSList *iel; |
271 GSList *iel; |
356 if (dnode) |
367 if (dnode) |
357 lm_message_node_set_attribute (node, "node", dnode); |
368 lm_message_node_set_attribute (node, "node", dnode); |
358 |
369 |
359 { |
370 { |
360 disco_info_reply_handler_t *cb = g_new (disco_info_reply_handler_t, 1); |
371 disco_info_reply_handler_t *cb = g_new (disco_info_reply_handler_t, 1); |
361 |
372 |
362 lhandler = lm_message_handler_new (disco_info_reply_handler, cb, disco_info_reply_handler_destroy_notify); |
373 lhandler = lm_message_handler_new (disco_info_reply_handler, cb, disco_info_reply_handler_destroy_notify); |
363 |
374 |
364 cb -> handler = handler; |
375 cb -> handler = handler; |
365 cb -> data = userdata; |
376 cb -> data = userdata; |
366 cb -> notify = notify; |
377 cb -> notify = notify; |
405 if (dnode) |
416 if (dnode) |
406 lm_message_node_set_attribute (node, "node", dnode); |
417 lm_message_node_set_attribute (node, "node", dnode); |
407 |
418 |
408 { |
419 { |
409 disco_items_reply_handler_t *cb = g_new (disco_items_reply_handler_t, 1); |
420 disco_items_reply_handler_t *cb = g_new (disco_items_reply_handler_t, 1); |
410 |
421 |
411 lhandler = lm_message_handler_new (disco_items_reply_handler, cb, disco_items_reply_handler_destroy_notify); |
422 lhandler = lm_message_handler_new (disco_items_reply_handler, cb, disco_items_reply_handler_destroy_notify); |
412 |
423 |
413 cb -> handler = handler; |
424 cb -> handler = handler; |
414 cb -> data = userdata; |
425 cb -> data = userdata; |
415 cb -> notify = notify; |
426 cb -> notify = notify; |
587 to = to_utf8 (p); |
598 to = to_utf8 (p); |
588 |
599 |
589 if (args[2]) |
600 if (args[2]) |
590 dnode = to_utf8 (args[2]); |
601 dnode = to_utf8 (args[2]); |
591 } |
602 } |
592 // XXX send to all resources/current resource? |
603 |
|
604 if (!to) { |
|
605 // Use currently selected item, if possible |
|
606 if (current_buddy) { |
|
607 gpointer bud = BUDDATA(current_buddy); |
|
608 if (bud) { |
|
609 guint type = buddy_gettype (bud); |
|
610 if (type != ROSTER_TYPE_GROUP && type != ROSTER_TYPE_SPECIAL) |
|
611 to = g_strdup (buddy_getjid (bud)); // XXX memleak! |
|
612 } |
|
613 } |
|
614 } |
|
615 |
|
616 if (!to) { |
|
617 scr_log_print (LPRINT_NORMAL, "Invalid disco target."); |
|
618 free_arg_lst (args); |
|
619 return; |
|
620 } |
|
621 |
|
622 // XXX send to all resources/current resource? |
593 |
623 |
594 { |
624 { |
595 disco_handler_t *cb = g_new (disco_handler_t, 1); |
625 disco_handler_t *cb = g_new (disco_handler_t, 1); |
596 |
626 |
597 cb -> jid = to ? to : g_strdup (CURRENT_JID); |
627 cb -> jid = to; |
598 cb -> node = dnode; |
628 cb -> node = dnode; |
599 |
629 |
600 if (info) |
630 if (info) |
601 disco_info_request (cb -> jid, cb -> node, disco_info_handler, cb, disco_handler_destroy_notify); |
631 disco_info_request (cb -> jid, cb -> node, disco_info_handler, cb, disco_handler_destroy_notify); |
602 else |
632 else |