annotate src/protocols/jabber/iq.c @ 13104:e1e5462b7d81

[gaim-migrate @ 15466] Rework lots of date parsing. I either introduced a whole lot of bugs, or I've made sure all dates are localized properly now. Only time will tell which it is... ;) committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Thu, 02 Feb 2006 19:50:51 +0000
parents ecd471d1eeec
children 02c7d18f5cc3
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"
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
24 #include "util.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
25
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
26 #include "buddy.h"
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
27 #include "disco.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28 #include "iq.h"
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
29 #include "oob.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 #include "roster.h"
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
31 #include "si.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32
7058
06e7697f3fae [gaim-migrate @ 7621]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7014
diff changeset
33 #ifdef _WIN32
06e7697f3fae [gaim-migrate @ 7621]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7014
diff changeset
34 #include "utsname.h"
06e7697f3fae [gaim-migrate @ 7621]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7014
diff changeset
35 #endif
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37 JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
38 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39 JabberIq *iq;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
40
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
41 iq = g_new0(JabberIq, 1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
42
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43 iq->type = type;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
44
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
45 iq->node = xmlnode_new("iq");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
46 switch(iq->type) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
47 case JABBER_IQ_SET:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48 xmlnode_set_attrib(iq->node, "type", "set");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
49 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50 case JABBER_IQ_GET:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
51 xmlnode_set_attrib(iq->node, "type", "get");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
53 case JABBER_IQ_ERROR:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
54 xmlnode_set_attrib(iq->node, "type", "error");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
55 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
56 case JABBER_IQ_RESULT:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57 xmlnode_set_attrib(iq->node, "type", "result");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
59 case JABBER_IQ_NONE:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
60 /* this shouldn't ever happen */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
61 break;
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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
64 iq->js = js;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
65
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
66 if(type == JABBER_IQ_GET || type == JABBER_IQ_SET) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
67 iq->id = jabber_get_next_id(js);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
68 xmlnode_set_attrib(iq->node, "id", iq->id);
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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
71 return iq;
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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
74 JabberIq *jabber_iq_new_query(JabberStream *js, JabberIqType type,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
75 const char *xmlns)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
76 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
77 JabberIq *iq = jabber_iq_new(js, type);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
78 xmlnode *query;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
79
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
80 query = xmlnode_new_child(iq->node, "query");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
81 xmlnode_set_attrib(query, "xmlns", xmlns);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
82
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
83 return iq;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
84 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
85
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
86 typedef struct _JabberCallbackData {
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
87 JabberIqCallback *callback;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
88 gpointer data;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
89 } JabberCallbackData;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
90
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
91 void
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
92 jabber_iq_set_callback(JabberIq *iq, JabberIqCallback *callback, gpointer data)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
94 iq->callback = callback;
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
95 iq->callback_data = data;
7014
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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
98 void jabber_iq_set_id(JabberIq *iq, const char *id)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
99 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
100 if(iq->id)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
101 g_free(iq->id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
102
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
103 if(id) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
104 xmlnode_set_attrib(iq->node, "id", id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
105 iq->id = g_strdup(id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
106 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
107 xmlnode_remove_attrib(iq->node, "id");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
108 iq->id = NULL;
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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
112 void jabber_iq_send(JabberIq *iq)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
113 {
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
114 JabberCallbackData *jcd;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
115 g_return_if_fail(iq != NULL);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
116
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
117 jabber_send(iq->js, iq->node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
118
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
119 if(iq->id && iq->callback) {
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
120 jcd = g_new0(JabberCallbackData, 1);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
121 jcd->callback = iq->callback;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
122 jcd->data = iq->callback_data;
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
123 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
124 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
125
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
126 jabber_iq_free(iq);
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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
129 void jabber_iq_free(JabberIq *iq)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
130 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
131 g_return_if_fail(iq != NULL);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
132
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
133 g_free(iq->id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
134 xmlnode_free(iq->node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
135 g_free(iq);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
136 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
137
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
138 static void jabber_iq_last_parse(JabberStream *js, xmlnode *packet)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
139 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
140 JabberIq *iq;
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
141 const char *type;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
142 const char *from;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
143 const char *id;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
144 xmlnode *query;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
145 char *idle_time;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
146
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
147 type = xmlnode_get_attrib(packet, "type");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
148 from = xmlnode_get_attrib(packet, "from");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
149 id = xmlnode_get_attrib(packet, "id");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
150
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
151 if(type && !strcmp(type, "get")) {
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
152 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
153 jabber_iq_set_id(iq, id);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
154 xmlnode_set_attrib(iq->node, "to", from);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
155
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
156 query = xmlnode_get_child(iq->node, "query");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
157
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
158 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
159 xmlnode_set_attrib(query, "seconds", idle_time);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
160 g_free(idle_time);
7401
aaf91a891cd9 [gaim-migrate @ 7997]
Nathan Walp <nwalp@pidgin.im>
parents: 7395
diff changeset
161
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
162 jabber_iq_send(iq);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
163 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
164 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
165
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
166 static void jabber_iq_time_parse(JabberStream *js, xmlnode *packet)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
167 {
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
168 const char *type, *from, *id;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
169 JabberIq *iq;
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;
9709
4d05b6e9e9cd [gaim-migrate @ 10570]
Mark Doliner <mark@kingant.net>
parents: 8315
diff changeset
172 struct tm *now;
9722
25866d09063d [gaim-migrate @ 10583]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
173
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
174 time(&now_t);
9709
4d05b6e9e9cd [gaim-migrate @ 10570]
Mark Doliner <mark@kingant.net>
parents: 8315
diff changeset
175 now = localtime(&now_t);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
176
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
177 type = xmlnode_get_attrib(packet, "type");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
178 from = xmlnode_get_attrib(packet, "from");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
179 id = xmlnode_get_attrib(packet, "id");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
180
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
181 if(type && !strcmp(type, "get")) {
13104
e1e5462b7d81 [gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents: 12284
diff changeset
182 const char *date;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
183
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
184 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
185 jabber_iq_set_id(iq, id);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
186 xmlnode_set_attrib(iq->node, "to", from);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
187
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
188 query = xmlnode_get_child(iq->node, "query");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
189
13104
e1e5462b7d81 [gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents: 12284
diff changeset
190 date = gaim_utf8_strftime("%Y%m%dT%T", now);
e1e5462b7d81 [gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents: 12284
diff changeset
191 xmlnode_insert_data(xmlnode_new_child(query, "utc"), date, -1);
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
192
13104
e1e5462b7d81 [gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents: 12284
diff changeset
193 date = gaim_utf8_strftime("%Z", now);
e1e5462b7d81 [gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents: 12284
diff changeset
194 xmlnode_insert_data(xmlnode_new_child(query, "tz"), date, -1);
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
195
13104
e1e5462b7d81 [gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents: 12284
diff changeset
196 date = gaim_utf8_strftime("%d %b %Y %T", now);
e1e5462b7d81 [gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents: 12284
diff changeset
197 xmlnode_insert_data(xmlnode_new_child(query, "display"), date, -1);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
198
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
199 jabber_iq_send(iq);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
200 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
201 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
202
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
203 static void jabber_iq_version_parse(JabberStream *js, xmlnode *packet)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
204 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
205 JabberIq *iq;
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
206 const char *type, *from, *id;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
207 xmlnode *query;
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
208 char *os = NULL;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
209
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
210 type = xmlnode_get_attrib(packet, "type");
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
211
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
212 if(type && !strcmp(type, "get")) {
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
213
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
214 if(!gaim_prefs_get_bool("/plugins/prpl/jabber/hide_os")) {
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
215 struct utsname osinfo;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
216
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
217 uname(&osinfo);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
218 os = g_strdup_printf("%s %s %s", osinfo.sysname, osinfo.release,
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
219 osinfo.machine);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
220 }
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
221
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
222 from = xmlnode_get_attrib(packet, "from");
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
223 id = xmlnode_get_attrib(packet, "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 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
226 xmlnode_set_attrib(iq->node, "to", from);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
227 jabber_iq_set_id(iq, id);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
228
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
229 query = xmlnode_get_child(iq->node, "query");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
230
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
231 xmlnode_insert_data(xmlnode_new_child(query, "name"), PACKAGE, -1);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
232 xmlnode_insert_data(xmlnode_new_child(query, "version"), VERSION, -1);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
233 if(os) {
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
234 xmlnode_insert_data(xmlnode_new_child(query, "os"), os, -1);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
235 g_free(os);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
236 }
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
237
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
238 jabber_iq_send(iq);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
239 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
240 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
241
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
242 void jabber_iq_parse(JabberStream *js, xmlnode *packet)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
243 {
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
244 JabberCallbackData *jcd;
8169
a64774143a42 [gaim-migrate @ 8882]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
245 xmlnode *query, *error, *x;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
246 const char *xmlns;
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
247 const char *type, *id, *from;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
248
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
249 query = xmlnode_get_child(packet, "query");
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
250 type = xmlnode_get_attrib(packet, "type");
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
251 from = xmlnode_get_attrib(packet, "from");
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
252 id = xmlnode_get_attrib(packet, "id");
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
253
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
254 /* First, lets see if a special callback got registered */
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
255
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
256 if(type && (!strcmp(type, "result") || !strcmp(type, "error"))) {
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
257 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
258 jcd->callback(js, packet, jcd->data);
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
259 g_hash_table_remove(js->iq_callbacks, id);
8314
db1123eb56b0 [gaim-migrate @ 9038]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
260 return;
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
261 }
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
262 }
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
263
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
264 /* 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
265
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
266 if(type && query && (xmlns = xmlnode_get_attrib(query, "xmlns"))) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
267 if(!strcmp(type, "set")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
268 if(!strcmp(xmlns, "jabber:iq:roster")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
269 jabber_roster_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
270 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
271 } else if(!strcmp(xmlns, "jabber:iq:oob")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
272 jabber_oob_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
273 return;
8262
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
274 } else if(!strcmp(xmlns, "http://jabber.org/protocol/bytestreams")) {
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
275 jabber_bytestreams_parse(js, packet);
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
276 return;
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
277 }
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
278 } else if(!strcmp(type, "get")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
279 if(!strcmp(xmlns, "jabber:iq:last")) {
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
280 jabber_iq_last_parse(js, packet);
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
281 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
282 } else if(!strcmp(xmlns, "jabber:iq:time")) {
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
283 jabber_iq_time_parse(js, packet);
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
284 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
285 } else if(!strcmp(xmlns, "jabber:iq:version")) {
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
286 jabber_iq_version_parse(js, packet);
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
287 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
288 } else if(!strcmp(xmlns, "http://jabber.org/protocol/disco#info")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
289 jabber_disco_info_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
290 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
291 } else if(!strcmp(xmlns, "http://jabber.org/protocol/disco#items")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
292 jabber_disco_items_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
293 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
294 }
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
295 } else if(!strcmp(type, "result")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
296 if(!strcmp(xmlns, "jabber:iq:roster")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
297 jabber_roster_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
298 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
299 } else if(!strcmp(xmlns, "jabber:iq:register")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
300 jabber_register_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
301 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
302 } else if(!strcmp(xmlns, "http://jabber.org/protocol/disco#info")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
303 jabber_disco_info_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
304 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
305 }
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
306 }
8262
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
307 } else {
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
308 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
309 jabber_si_parse(js, packet);
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
310 return;
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
311 }
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
312 }
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
313
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
314 /* If we get here, send the default error reply mandated by XMPP-CORE */
8315
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
315 if(type && (!strcmp(type, "set") || !strcmp(type, "get"))) {
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
316 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_ERROR);
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
317
8315
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
318 xmlnode_free(iq->node);
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
319 iq->node = xmlnode_copy(packet);
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
320 xmlnode_set_attrib(iq->node, "to", from);
11825
9e14f1850369 [gaim-migrate @ 14116]
Mark Doliner <mark@kingant.net>
parents: 11822
diff changeset
321 xmlnode_remove_attrib(iq->node, "from");
8315
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
322 xmlnode_set_attrib(iq->node, "type", "error");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
323 error = xmlnode_new_child(iq->node, "error");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
324 xmlnode_set_attrib(error, "type", "cancel");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
325 xmlnode_set_attrib(error, "code", "501");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
326 x = xmlnode_new_child(error, "feature-not-implemented");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
327 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
328
8315
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
329 jabber_iq_send(iq);
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
330 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
331 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
332