comparison src/protocols/jabber/disco.c @ 13384:a580ffe73314

[gaim-migrate @ 15757] jabber updates, including the first half of JEP-0115 support, and maybe the fix for jabber plaintext messages not having their line-endings preserved committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 03 Mar 2006 03:38:36 +0000
parents 828802f2251b
children d7ace957fcf8
comparison
equal deleted inserted replaced
13383:07286677b8b8 13384:a580ffe73314
23 #include "prefs.h" 23 #include "prefs.h"
24 24
25 #include "buddy.h" 25 #include "buddy.h"
26 #include "iq.h" 26 #include "iq.h"
27 #include "disco.h" 27 #include "disco.h"
28 #include "jabber.h"
28 29
29 30
30 struct _jabber_disco_info_cb_data { 31 struct _jabber_disco_info_cb_data {
31 gpointer data; 32 gpointer data;
32 JabberDiscoInfoCallback *callback; 33 JabberDiscoInfoCallback *callback;
44 if(!from || !type) 45 if(!from || !type)
45 return; 46 return;
46 47
47 if(!strcmp(type, "get")) { 48 if(!strcmp(type, "get")) {
48 xmlnode *query, *identity, *feature; 49 xmlnode *query, *identity, *feature;
49 JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, 50 JabberIq *iq;
51
52 xmlnode *in_query;
53 const char *node = NULL;
54
55 if((in_query = xmlnode_get_child(packet, "query"))) {
56 node = xmlnode_get_attrib(in_query, "node");
57 }
58
59
60 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT,
50 "http://jabber.org/protocol/disco#info"); 61 "http://jabber.org/protocol/disco#info");
51 62
52 jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id")); 63 jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id"));
53 64
54 xmlnode_set_attrib(iq->node, "to", from); 65 xmlnode_set_attrib(iq->node, "to", from);
55 query = xmlnode_get_child(iq->node, "query"); 66 query = xmlnode_get_child(iq->node, "query");
56 67
57 identity = xmlnode_new_child(query, "identity"); 68 if(node)
58 xmlnode_set_attrib(identity, "category", "client"); 69 xmlnode_set_attrib(query, "node", node);
59 xmlnode_set_attrib(identity, "type", "pc"); /* XXX: bot, console, 70
60 * handheld, pc, phone, 71 if(!node || !strcmp(node, CAPS0115_NODE "#" VERSION)) {
61 * web */ 72
62 73 identity = xmlnode_new_child(query, "identity");
63 SUPPORT_FEATURE("jabber:iq:last") 74 xmlnode_set_attrib(identity, "category", "client");
64 SUPPORT_FEATURE("jabber:iq:oob") 75 xmlnode_set_attrib(identity, "type", "pc"); /* XXX: bot, console,
65 SUPPORT_FEATURE("jabber:iq:time") 76 * handheld, pc, phone,
66 SUPPORT_FEATURE("jabber:iq:version") 77 * web */
67 SUPPORT_FEATURE("jabber:x:conference") 78
68 SUPPORT_FEATURE("http://jabber.org/protocol/bytestreams") 79 SUPPORT_FEATURE("jabber:iq:last")
69 SUPPORT_FEATURE("http://jabber.org/protocol/disco#info") 80 SUPPORT_FEATURE("jabber:iq:oob")
70 SUPPORT_FEATURE("http://jabber.org/protocol/disco#items") 81 SUPPORT_FEATURE("jabber:iq:time")
82 SUPPORT_FEATURE("jabber:iq:version")
83 SUPPORT_FEATURE("jabber:x:conference")
84 SUPPORT_FEATURE("http://jabber.org/protocol/bytestreams")
85 SUPPORT_FEATURE("http://jabber.org/protocol/disco#info")
86 SUPPORT_FEATURE("http://jabber.org/protocol/disco#items")
71 #if 0 87 #if 0
72 SUPPORT_FEATURE("http://jabber.org/protocol/ibb") 88 SUPPORT_FEATURE("http://jabber.org/protocol/ibb")
73 #endif 89 #endif
74 SUPPORT_FEATURE("http://jabber.org/protocol/muc") 90 SUPPORT_FEATURE("http://jabber.org/protocol/muc")
75 SUPPORT_FEATURE("http://jabber.org/protocol/muc#user") 91 SUPPORT_FEATURE("http://jabber.org/protocol/muc#user")
76 SUPPORT_FEATURE("http://jabber.org/protocol/si") 92 SUPPORT_FEATURE("http://jabber.org/protocol/si")
77 SUPPORT_FEATURE("http://jabber.org/protocol/si/profile/file-transfer") 93 SUPPORT_FEATURE("http://jabber.org/protocol/si/profile/file-transfer")
78 SUPPORT_FEATURE("http://jabber.org/protocol/xhtml-im") 94 SUPPORT_FEATURE("http://jabber.org/protocol/xhtml-im")
95 } else {
96 xmlnode *error, *inf;
97
98 /* XXX: gross hack, implement jabber_iq_set_type or something */
99 xmlnode_set_attrib(iq->node, "type", "error");
100 iq->type = JABBER_IQ_ERROR;
101
102 error = xmlnode_new_child(query, "error");
103 xmlnode_set_attrib(error, "code", "404");
104 xmlnode_set_attrib(error, "type", "cancel");
105 inf = xmlnode_new_child(error, "item-not-found");
106 xmlnode_set_attrib(inf, "xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas");
107 }
79 108
80 jabber_iq_send(iq); 109 jabber_iq_send(iq);
81 } else if(!strcmp(type, "result")) { 110 } else if(!strcmp(type, "result")) {
82 xmlnode *query = xmlnode_get_child(packet, "query"); 111 xmlnode *query = xmlnode_get_child(packet, "query");
83 xmlnode *child; 112 xmlnode *child;