Mercurial > hg
annotate mcabber/src/jab_iq.c @ 595:0c1d37300862
IQ: send feature-not-implemented error stanzas
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Tue, 13 Dec 2005 20:08:46 +0100 |
parents | bd176d6f34af |
children | 6c7fd289648f |
rev | line source |
---|---|
29 | 1 /* |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
2 * jab_iq.c -- Jabber protocol IQ-related fonctions |
393 | 3 * |
29 | 4 * Copyright (C) 2005 Mikael Berthe <bmikael@lists.lilotux.net> |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
5 * Some parts initially came from the centericq project: |
29 | 6 * Copyright (C) 2002-2005 by Konstantin Klyagin <konst@konst.org.ua> |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or (at | |
11 * your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
21 * USA | |
22 */ | |
23 | |
24 #include "jabglue.h" | |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
25 #include "jab_priv.h" |
81 | 26 #include "roster.h" |
29 | 27 #include "utils.h" |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
28 #include "logprint.h" |
164 | 29 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
30 int s_id; // XXX |
31 | 31 |
533
c478e8f7f074
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
532
diff
changeset
|
32 static void gotloggedin(void) |
29 | 33 { |
34 xmlnode x; | |
35 | |
36 x = jutil_iqnew(JPACKET__GET, NS_AGENTS); | |
37 xmlnode_put_attrib(x, "id", "Agent List"); | |
38 jab_send(jc, x); | |
39 xmlnode_free(x); | |
40 | |
41 x = jutil_iqnew(JPACKET__GET, NS_ROSTER); | |
42 xmlnode_put_attrib(x, "id", "Roster"); | |
43 jab_send(jc, x); | |
44 xmlnode_free(x); | |
45 } | |
46 | |
533
c478e8f7f074
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
532
diff
changeset
|
47 static void gotroster(xmlnode x) |
29 | 48 { |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
49 xmlnode y; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
50 const char *jid, *name, *group; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
51 char *buddyname; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
52 char *cleanalias; |
29 | 53 |
54 for (y = xmlnode_get_tag(x, "item"); y; y = xmlnode_get_nextsibling(y)) { | |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
55 gchar *name_noutf8 = NULL; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
56 gchar *group_noutf8 = NULL; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
57 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
58 jid = xmlnode_get_attrib(y, "jid"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
59 name = xmlnode_get_attrib(y, "name"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
60 //sub = xmlnode_get_attrib(y, "subscription"); // TODO Not used |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
61 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
62 group = xmlnode_get_tag_data(y, "group"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
63 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
64 if (!jid) |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
65 continue; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
66 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
67 buddyname = cleanalias = jidtodisp(jid); |
29 | 68 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
69 if (name) { |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
70 name_noutf8 = from_utf8(name); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
71 if (name_noutf8) |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
72 buddyname = name_noutf8; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
73 else |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
74 scr_LogPrint(LPRINT_LOG, "Decoding of buddy alias has failed: %s", |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
75 name); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
76 } |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
77 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
78 if (group) { |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
79 group_noutf8 = from_utf8(group); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
80 if (!group_noutf8) |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
81 scr_LogPrint(LPRINT_LOG, "Decoding of buddy group has failed: %s", |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
82 group); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
83 } |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
84 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
85 roster_add_user(cleanalias, buddyname, group_noutf8, ROSTER_TYPE_USER); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
86 if (name_noutf8) g_free(name_noutf8); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
87 if (group_noutf8) g_free(group_noutf8); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
88 g_free(cleanalias); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
89 } |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
90 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
91 // Post-login stuff |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
92 jb_setstatus(available, NULL, NULL); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
93 buddylist_build(); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
94 } |
29 | 95 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
96 static void gotagents(jconn conn, xmlnode x) |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
97 { |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
98 xmlnode y; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
99 const char *alias; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
100 const char *name, *desc; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
101 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
102 y = xmlnode_get_tag(x, "agent"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
103 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
104 for (; y; y = xmlnode_get_nextsibling(y)) { |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
105 enum agtype atype = unknown; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
106 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
107 alias = xmlnode_get_attrib(y, "jid"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
108 if (!alias) |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
109 continue; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
110 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
111 name = xmlnode_get_tag_data(y, "name"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
112 desc = xmlnode_get_tag_data(y, "description"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
113 // TODO |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
114 // service = xmlnode_get_tag_data(y, "service"); |
213 | 115 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
116 if (xmlnode_get_tag(y, TMSG_GROUPCHAT)) atype = groupchat; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
117 else if (xmlnode_get_tag(y, "transport")) atype = transport; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
118 else if (xmlnode_get_tag(y, "search")) atype = search; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
119 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
120 if (atype == transport) { |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
121 char *cleanjid = jidtodisp(alias); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
122 roster_add_user(cleanjid, NULL, JABBER_AGENT_GROUP, |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
123 ROSTER_TYPE_AGENT); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
124 g_free(cleanjid); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
125 } |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
126 if (alias && name && desc) { |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
127 scr_LogPrint(LPRINT_LOGNORM, "Agent: %s / %s / %s / type=%d", |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
128 alias, name, desc, atype); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
129 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
130 if (atype == search) { |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
131 x = jutil_iqnew (JPACKET__GET, NS_SEARCH); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
132 xmlnode_put_attrib(x, "to", alias); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
133 xmlnode_put_attrib(x, "id", "Agent info"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
134 jab_send(conn, x); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
135 xmlnode_free(x); |
441
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
136 } |
35 | 137 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
138 if (xmlnode_get_tag(y, "register")) { |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
139 x = jutil_iqnew (JPACKET__GET, NS_REGISTER); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
140 xmlnode_put_attrib(x, "to", alias); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
141 xmlnode_put_attrib(x, "id", "Agent info"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
142 jab_send(conn, x); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
143 xmlnode_free(x); |
523
fc6bc26f891e
Write UTF-9 conversion failures to the tracelog file
Mikael Berthe <mikael@lilotux.net>
parents:
521
diff
changeset
|
144 } |
29 | 145 } |
146 } | |
147 | |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
148 /* |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
149 if (find(jhook.agents.begin(), jhook.agents.end(), DEFAULT_CONFSERV) == jhook.agents.end()) |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
150 jhook.agents.insert(jhook.agents.begin(), agent(DEFAULT_CONFSERV, DEFAULT_CONFSERV, |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
151 _("Default Jabber conference server"), agent::atGroupchat)); |
420
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
152 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
153 */ |
420
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
154 } |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
155 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
156 static void handle_iq_result(jconn conn, char *from, xmlnode xmldata) |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
157 { |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
158 xmlnode x; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
159 char *p; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
160 char *ns; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
161 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
162 if ((p = xmlnode_get_attrib(xmldata, "id")) != NULL) { |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
163 int iid = atoi(p); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
164 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
165 //scr_LogPrint(LPRINT_DEBUG, "iid = %d", iid); |
595
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
166 if (iid == s_id) { // Authentication |
578 | 167 if (jstate == STATE_GETAUTH) { |
168 if ((x = xmlnode_get_tag(xmldata, "query")) != NULL) | |
169 if (!xmlnode_get_tag(x, "digest")) { | |
170 jc->sid = 0; | |
171 } | |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
172 |
578 | 173 s_id = atoi(jab_auth(jc)); |
174 jstate = STATE_SENDAUTH; | |
175 } else if (jstate == STATE_SENDAUTH) { | |
176 gotloggedin(); | |
177 jstate = STATE_LOGGED; | |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
178 } |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
179 return; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
180 } |
430
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
181 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
182 if (!strcmp(p, "VCARDreq")) { |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
183 x = xmlnode_get_firstchild(xmldata); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
184 if (!x) x = xmldata; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
185 |
595
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
186 scr_LogPrint(LPRINT_LOGNORM, "Got VCARD"); // TODO |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
187 return; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
188 } else if (!strcmp(p, "versionreq")) { |
595
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
189 scr_LogPrint(LPRINT_LOGNORM, "Got version"); // TODO |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
190 return; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
191 } |
430
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
192 } |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
193 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
194 x = xmlnode_get_tag(xmldata, "query"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
195 if (!x) return; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
196 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
197 ns = xmlnode_get_attrib(x, "xmlns"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
198 if (!ns) return; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
199 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
200 if (!strcmp(ns, NS_ROSTER)) { |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
201 gotroster(x); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
202 } else if (!strcmp(ns, NS_AGENTS)) { |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
203 gotagents(conn, x); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
204 } else if (!strcmp(ns, NS_SEARCH) || !strcmp(ns, NS_REGISTER)) { |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
205 char *id = xmlnode_get_attrib(xmldata, "id"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
206 if (!id) id = ""; |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
207 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
208 if (!strcmp(id, "Agent info")) { |
595
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
209 scr_LogPrint(LPRINT_LOGNORM, "Got agent info"); // TODO |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
210 } else if (!strcmp(id, "Lookup")) { |
595
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
211 scr_LogPrint(LPRINT_LOGNORM, "Got search results"); // TODO |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
212 } else if (!strcmp(id, "Register")) { |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
213 if (!from) |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
214 return; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
215 x = jutil_iqnew(JPACKET__GET, NS_REGISTER); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
216 xmlnode_put_attrib(x, "to", from); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
217 xmlnode_put_attrib(x, "id", "Agent info"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
218 jab_send(conn, x); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
219 xmlnode_free(x); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
220 } |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
221 } |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
222 } |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
223 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
224 static void handle_iq_get(jconn conn, char *from, xmlnode xmldata) |
31 | 225 { |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
226 char *id; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
227 xmlnode x, y, z; |
31 | 228 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
229 id = xmlnode_get_attrib(xmldata, "id"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
230 if (!id) return; |
31 | 231 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
232 // Nothing implemented yet. |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
233 x = xmlnode_new_tag("iq"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
234 xmlnode_put_attrib(x, "to", from); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
235 xmlnode_put_attrib(x, "id", id); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
236 xmlnode_put_attrib(x, "type", TMSG_ERROR); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
237 y = xmlnode_insert_tag(x, TMSG_ERROR); |
595
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
238 xmlnode_put_attrib(y, "code", "501"); |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
239 xmlnode_put_attrib(y, "type", "cancel"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
240 z = xmlnode_insert_tag(y, "feature-not-implemented"); |
595
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
241 xmlnode_put_attrib(z, "xmlns", NS_XMPP_STANZAS); |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
242 jab_send(conn, x); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
243 xmlnode_free(x); |
31 | 244 } |
245 | |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
246 static void handle_iq_set(jconn conn, char *from, xmlnode xmldata) |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
247 { |
595
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
248 char *id; |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
249 xmlnode x, y, z; |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
250 |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
251 id = xmlnode_get_attrib(xmldata, "id"); |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
252 if (!id) return; |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
253 |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
254 /* Not implemented yet: send an error stanza */ |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
255 x = xmlnode_new_tag("iq"); |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
256 xmlnode_put_attrib(x, "to", from); |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
257 xmlnode_put_attrib(x, "id", id); |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
258 xmlnode_put_attrib(x, "type", TMSG_ERROR); |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
259 y = xmlnode_insert_tag(x, TMSG_ERROR); |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
260 xmlnode_put_attrib(y, "code", "501"); |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
261 xmlnode_put_attrib(y, "type", "cancel"); |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
262 z = xmlnode_insert_tag(y, "feature-not-implemented"); |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
263 xmlnode_put_attrib(z, "xmlns", NS_XMPP_STANZAS); |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
264 |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
265 jab_send(conn, x); |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
266 xmlnode_free(x); |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
267 } |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
268 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
269 void handle_packet_iq(jconn conn, char *type, char *from, xmlnode xmldata) |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
270 { |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
271 if (!type) |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
272 return; |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
273 |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
274 if (!strcmp(type, "result")) { |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
275 handle_iq_result(conn, from, xmldata); |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
276 } else if (!strcmp(type, "get")) { |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
277 handle_iq_get(conn, from, xmldata); |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
278 } else if (!strcmp(type, "set")) { |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
279 handle_iq_set(conn, from, xmldata); |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
280 } else if (!strcmp(type, TMSG_ERROR)) { |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
281 xmlnode x = xmlnode_get_tag(xmldata, TMSG_ERROR); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
282 if (x) |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
283 display_server_error(x); |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
284 } |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
285 } |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
286 |
580 | 287 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |