annotate src/protocols/jabber/iq.c @ 9278:2401a9ef74a0

[gaim-migrate @ 10081] Some reorganization. Renamed struct yahoo_friend to YahooFriend. Gave it its own file, which only has two functions. Either I've lost it or I intend to add to it. You decide. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Mon, 14 Jun 2004 04:51:14 +0000
parents 52ea0ab31caa
children 4d05b6e9e9cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
2 * gaim - Jabber Protocol Plugin
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 #include "internal.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 #include "debug.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include "prefs.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
25 #include "buddy.h"
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
26 #include "disco.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27 #include "iq.h"
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
28 #include "oob.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
29 #include "roster.h"
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
30 #include "si.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31
7058
06e7697f3fae [gaim-migrate @ 7621]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7014
diff changeset
32 #ifdef _WIN32
06e7697f3fae [gaim-migrate @ 7621]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7014
diff changeset
33 #include "utsname.h"
06e7697f3fae [gaim-migrate @ 7621]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7014
diff changeset
34 #endif
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
35
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36 JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
38 JabberIq *iq;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
40 iq = g_new0(JabberIq, 1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
41
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
42 iq->type = type;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
44 iq->node = xmlnode_new("iq");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
45 switch(iq->type) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
46 case JABBER_IQ_SET:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
47 xmlnode_set_attrib(iq->node, "type", "set");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
49 case JABBER_IQ_GET:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50 xmlnode_set_attrib(iq->node, "type", "get");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
51 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52 case JABBER_IQ_ERROR:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
53 xmlnode_set_attrib(iq->node, "type", "error");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
54 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
55 case JABBER_IQ_RESULT:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
56 xmlnode_set_attrib(iq->node, "type", "result");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58 case JABBER_IQ_NONE:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
59 /* this shouldn't ever happen */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
60 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
61 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
62
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
63 iq->js = js;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
64
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
65 if(type == JABBER_IQ_GET || type == JABBER_IQ_SET) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
66 iq->id = jabber_get_next_id(js);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
67 xmlnode_set_attrib(iq->node, "id", iq->id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
68 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
69
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
70 return iq;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
71 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
72
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
73 JabberIq *jabber_iq_new_query(JabberStream *js, JabberIqType type,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
74 const char *xmlns)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
75 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
76 JabberIq *iq = jabber_iq_new(js, type);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
77 xmlnode *query;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
78
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
79 query = xmlnode_new_child(iq->node, "query");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
80 xmlnode_set_attrib(query, "xmlns", xmlns);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
81
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
82 return iq;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
83 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
84
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
85 typedef struct _JabberCallbackData {
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
86 JabberIqCallback *callback;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
87 gpointer data;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
88 } JabberCallbackData;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
89
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
90 void
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
91 jabber_iq_set_callback(JabberIq *iq, JabberIqCallback *callback, gpointer data)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
92 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93 iq->callback = callback;
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
94 iq->callback_data = data;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
95 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
96
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
97 void jabber_iq_set_id(JabberIq *iq, const char *id)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
98 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
99 if(iq->id)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
100 g_free(iq->id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
101
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
102 if(id) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
103 xmlnode_set_attrib(iq->node, "id", id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
104 iq->id = g_strdup(id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
105 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
106 xmlnode_remove_attrib(iq->node, "id");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
107 iq->id = NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
108 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
109 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
110
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
111 void jabber_iq_send(JabberIq *iq)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
112 {
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
113 JabberCallbackData *jcd;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
114 g_return_if_fail(iq != NULL);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
115
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
116 jabber_send(iq->js, iq->node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
117
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
118 if(iq->id && iq->callback) {
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
119 jcd = g_new0(JabberCallbackData, 1);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
120 jcd->callback = iq->callback;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
121 jcd->data = iq->callback_data;
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
122 g_hash_table_insert(iq->js->iq_callbacks, g_strdup(iq->id), jcd);
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
123 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
124
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
125 jabber_iq_free(iq);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
126 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
127
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
128 void jabber_iq_free(JabberIq *iq)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
129 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
130 g_return_if_fail(iq != NULL);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
131
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
132 g_free(iq->id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
133 xmlnode_free(iq->node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
134 g_free(iq);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
135 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
136
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
137 static void jabber_iq_last_parse(JabberStream *js, xmlnode *packet)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
138 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
139 JabberIq *iq;
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
140 const char *type;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
141 const char *from;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
142 const char *id;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
143 xmlnode *query;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
144 char *idle_time;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
145
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
146 type = xmlnode_get_attrib(packet, "type");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
147 from = xmlnode_get_attrib(packet, "from");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
148 id = xmlnode_get_attrib(packet, "id");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
149
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
150 if(type && !strcmp(type, "get")) {
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
151 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:last");
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
152 jabber_iq_set_id(iq, id);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
153 xmlnode_set_attrib(iq->node, "to", from);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
154
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
155 query = xmlnode_get_child(iq->node, "query");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
156
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
157 idle_time = g_strdup_printf("%ld", js->idle ? time(NULL) - js->idle : 0);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
158 xmlnode_set_attrib(query, "seconds", idle_time);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
159 g_free(idle_time);
7401
aaf91a891cd9 [gaim-migrate @ 7997]
Nathan Walp <nwalp@pidgin.im>
parents: 7395
diff changeset
160
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
161 jabber_iq_send(iq);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
162 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
163 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
164
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
165 static void jabber_iq_time_parse(JabberStream *js, xmlnode *packet)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
166 {
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
167 const char *type, *from, *id;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
168 JabberIq *iq;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
169 char buf[1024];
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
170 xmlnode *query;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
171 time_t now_t;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
172 struct tm now;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
173 time(&now_t);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
174 localtime_r(&now_t, &now);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
175
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
176 type = xmlnode_get_attrib(packet, "type");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
177 from = xmlnode_get_attrib(packet, "from");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
178 id = xmlnode_get_attrib(packet, "id");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
179
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
180 if(type && !strcmp(type, "get")) {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
181
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
182 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:time");
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
183 jabber_iq_set_id(iq, id);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
184 xmlnode_set_attrib(iq->node, "to", from);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
185
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
186 query = xmlnode_get_child(iq->node, "query");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
187
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
188 strftime(buf, sizeof(buf), "%Y%m%dT%T", &now);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
189 xmlnode_insert_data(xmlnode_new_child(query, "utc"), buf, -1);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
190 strftime(buf, sizeof(buf), "%Z", &now);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
191 xmlnode_insert_data(xmlnode_new_child(query, "tz"), buf, -1);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
192 strftime(buf, sizeof(buf), "%d %b %Y %T", &now);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
193 xmlnode_insert_data(xmlnode_new_child(query, "display"), buf, -1);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
194
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
195 jabber_iq_send(iq);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
196 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
197 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
198
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
199 static void jabber_iq_version_parse(JabberStream *js, xmlnode *packet)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
200 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
201 JabberIq *iq;
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
202 const char *type, *from, *id;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
203 xmlnode *query;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
204 char *os = NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
205
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
206 type = xmlnode_get_attrib(packet, "type");
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
207
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
208 if(type && !strcmp(type, "get")) {
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
209
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
210 if(!gaim_prefs_get_bool("/plugins/prpl/jabber/hide_os")) {
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
211 struct utsname osinfo;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
212
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
213 uname(&osinfo);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
214 os = g_strdup_printf("%s %s %s", osinfo.sysname, osinfo.release,
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
215 osinfo.machine);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
216 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
217
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
218 from = xmlnode_get_attrib(packet, "from");
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
219 id = xmlnode_get_attrib(packet, "id");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
220
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
221 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:version");
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
222 xmlnode_set_attrib(iq->node, "to", from);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
223 jabber_iq_set_id(iq, id);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
224
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
225 query = xmlnode_get_child(iq->node, "query");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
226
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
227 xmlnode_insert_data(xmlnode_new_child(query, "name"), PACKAGE, -1);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
228 xmlnode_insert_data(xmlnode_new_child(query, "version"), VERSION, -1);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
229 if(os) {
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
230 xmlnode_insert_data(xmlnode_new_child(query, "os"), os, -1);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
231 g_free(os);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
232 }
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
233
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
234 jabber_iq_send(iq);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
235 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
236 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
237
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
238 void jabber_iq_parse(JabberStream *js, xmlnode *packet)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
239 {
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
240 JabberCallbackData *jcd;
8169
a64774143a42 [gaim-migrate @ 8882]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
241 xmlnode *query, *error, *x;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
242 const char *xmlns;
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
243 const char *type, *id, *from;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
244
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
245 query = xmlnode_get_child(packet, "query");
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
246 type = xmlnode_get_attrib(packet, "type");
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
247 from = xmlnode_get_attrib(packet, "from");
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
248 id = xmlnode_get_attrib(packet, "id");
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
249
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
250 /* First, lets see if a special callback got registered */
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
251
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
252 if(type && (!strcmp(type, "result") || !strcmp(type, "error"))) {
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
253 if(id && *id && (jcd = g_hash_table_lookup(js->iq_callbacks, id))) {
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
254 jcd->callback(js, packet, jcd->data);
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
255 g_hash_table_remove(js->iq_callbacks, id);
8314
db1123eb56b0 [gaim-migrate @ 9038]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
256 return;
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
257 }
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
258 }
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
259
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
260 /* Apparently not, so lets see if we have a pre-defined handler */
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
261
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
262 if(type && query && (xmlns = xmlnode_get_attrib(query, "xmlns"))) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
263 if(!strcmp(type, "set")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
264 if(!strcmp(xmlns, "jabber:iq:roster")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
265 jabber_roster_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
266 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
267 } else if(!strcmp(xmlns, "jabber:iq:oob")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
268 jabber_oob_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
269 return;
8262
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
270 } else if(!strcmp(xmlns, "http://jabber.org/protocol/bytestreams")) {
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
271 jabber_bytestreams_parse(js, packet);
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
272 return;
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
273 }
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
274 } else if(!strcmp(type, "get")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
275 if(!strcmp(xmlns, "jabber:iq:last")) {
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
276 jabber_iq_last_parse(js, packet);
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
277 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
278 } else if(!strcmp(xmlns, "jabber:iq:time")) {
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
279 jabber_iq_time_parse(js, packet);
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
280 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
281 } else if(!strcmp(xmlns, "jabber:iq:version")) {
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
282 jabber_iq_version_parse(js, packet);
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
283 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
284 } else if(!strcmp(xmlns, "http://jabber.org/protocol/disco#info")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
285 jabber_disco_info_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
286 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
287 } else if(!strcmp(xmlns, "http://jabber.org/protocol/disco#items")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
288 jabber_disco_items_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
289 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
290 }
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
291 } else if(!strcmp(type, "result")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
292 if(!strcmp(xmlns, "jabber:iq:roster")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
293 jabber_roster_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
294 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
295 } else if(!strcmp(xmlns, "jabber:iq:register")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
296 jabber_register_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
297 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
298 } else if(!strcmp(xmlns, "http://jabber.org/protocol/disco#info")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
299 jabber_disco_info_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
300 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
301 }
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
302 }
8262
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
303 } else {
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
304 if(xmlnode_get_child_with_namespace(packet, "si", "http://jabber.org/protocol/si")) {
8262
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
305 jabber_si_parse(js, packet);
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
306 return;
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
307 }
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
308 }
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
309
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
310
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
311 /* If we get here, send the default error reply mandated by XMPP-CORE */
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
312
8315
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
313 if(type && (!strcmp(type, "set") || !strcmp(type, "get"))) {
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
314 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_ERROR);
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
315
8315
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
316 xmlnode_free(iq->node);
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
317 iq->node = xmlnode_copy(packet);
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
318 xmlnode_set_attrib(iq->node, "to", from);
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
319 xmlnode_set_attrib(iq->node, "type", "error");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
320 error = xmlnode_new_child(iq->node, "error");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
321 xmlnode_set_attrib(error, "type", "cancel");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
322 xmlnode_set_attrib(error, "code", "501");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
323 x = xmlnode_new_child(error, "feature-not-implemented");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
324 xmlnode_set_attrib(x, "xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas");
8169
a64774143a42 [gaim-migrate @ 8882]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
325
8315
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
326 jabber_iq_send(iq);
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
327 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
328 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
329