comparison 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
comparison
equal deleted inserted replaced
594:f791f5f0cfce 595:0c1d37300862
161 161
162 if ((p = xmlnode_get_attrib(xmldata, "id")) != NULL) { 162 if ((p = xmlnode_get_attrib(xmldata, "id")) != NULL) {
163 int iid = atoi(p); 163 int iid = atoi(p);
164 164
165 //scr_LogPrint(LPRINT_DEBUG, "iid = %d", iid); 165 //scr_LogPrint(LPRINT_DEBUG, "iid = %d", iid);
166 if (iid == s_id) { 166 if (iid == s_id) { // Authentication
167 if (jstate == STATE_GETAUTH) { 167 if (jstate == STATE_GETAUTH) {
168 if ((x = xmlnode_get_tag(xmldata, "query")) != NULL) 168 if ((x = xmlnode_get_tag(xmldata, "query")) != NULL)
169 if (!xmlnode_get_tag(x, "digest")) { 169 if (!xmlnode_get_tag(x, "digest")) {
170 jc->sid = 0; 170 jc->sid = 0;
171 } 171 }
181 181
182 if (!strcmp(p, "VCARDreq")) { 182 if (!strcmp(p, "VCARDreq")) {
183 x = xmlnode_get_firstchild(xmldata); 183 x = xmlnode_get_firstchild(xmldata);
184 if (!x) x = xmldata; 184 if (!x) x = xmldata;
185 185
186 //jhook.gotvcard(ic, x); TODO 186 scr_LogPrint(LPRINT_LOGNORM, "Got VCARD"); // TODO
187 scr_LogPrint(LPRINT_LOGNORM, "Got VCARD");
188 return; 187 return;
189 } else if (!strcmp(p, "versionreq")) { 188 } else if (!strcmp(p, "versionreq")) {
190 // jhook.gotversion(ic, xmldata); TODO 189 scr_LogPrint(LPRINT_LOGNORM, "Got version"); // TODO
191 scr_LogPrint(LPRINT_LOGNORM, "Got version");
192 return; 190 return;
193 } 191 }
194 } 192 }
195 193
196 x = xmlnode_get_tag(xmldata, "query"); 194 x = xmlnode_get_tag(xmldata, "query");
206 } else if (!strcmp(ns, NS_SEARCH) || !strcmp(ns, NS_REGISTER)) { 204 } else if (!strcmp(ns, NS_SEARCH) || !strcmp(ns, NS_REGISTER)) {
207 char *id = xmlnode_get_attrib(xmldata, "id"); 205 char *id = xmlnode_get_attrib(xmldata, "id");
208 if (!id) id = ""; 206 if (!id) id = "";
209 207
210 if (!strcmp(id, "Agent info")) { 208 if (!strcmp(id, "Agent info")) {
211 // jhook.gotagentinfo(xmldata); TODO 209 scr_LogPrint(LPRINT_LOGNORM, "Got agent info"); // TODO
212 scr_LogPrint(LPRINT_LOGNORM, "Got agent info");
213 } else if (!strcmp(id, "Lookup")) { 210 } else if (!strcmp(id, "Lookup")) {
214 // jhook.gotsearchresults(xmldata); TODO 211 scr_LogPrint(LPRINT_LOGNORM, "Got search results"); // TODO
215 scr_LogPrint(LPRINT_LOGNORM, "Got search results");
216 } else if (!strcmp(id, "Register")) { 212 } else if (!strcmp(id, "Register")) {
217 if (!from) 213 if (!from)
218 return; 214 return;
219 x = jutil_iqnew(JPACKET__GET, NS_REGISTER); 215 x = jutil_iqnew(JPACKET__GET, NS_REGISTER);
220 xmlnode_put_attrib(x, "to", from); 216 xmlnode_put_attrib(x, "to", from);
221 xmlnode_put_attrib(x, "id", "Agent info"); 217 xmlnode_put_attrib(x, "id", "Agent info");
222 jab_send(conn, x); 218 jab_send(conn, x);
223 xmlnode_free(x); 219 xmlnode_free(x);
224 } 220 }
225
226 } 221 }
227 } 222 }
228 223
229 static void handle_iq_get(jconn conn, char *from, xmlnode xmldata) 224 static void handle_iq_get(jconn conn, char *from, xmlnode xmldata)
230 { 225 {
234 id = xmlnode_get_attrib(xmldata, "id"); 229 id = xmlnode_get_attrib(xmldata, "id");
235 if (!id) return; 230 if (!id) return;
236 231
237 // Nothing implemented yet. 232 // Nothing implemented yet.
238 x = xmlnode_new_tag("iq"); 233 x = xmlnode_new_tag("iq");
239 xmlnode_put_attrib(x, "type", "result");
240 xmlnode_put_attrib(x, "to", from); 234 xmlnode_put_attrib(x, "to", from);
241 xmlnode_put_attrib(x, "id", id); 235 xmlnode_put_attrib(x, "id", id);
242 xmlnode_put_attrib(x, "type", TMSG_ERROR); 236 xmlnode_put_attrib(x, "type", TMSG_ERROR);
243 y = xmlnode_insert_tag(x, TMSG_ERROR); 237 y = xmlnode_insert_tag(x, TMSG_ERROR);
244 xmlnode_put_attrib(y, "code", "503"); 238 xmlnode_put_attrib(y, "code", "501");
245 xmlnode_put_attrib(y, "type", "cancel"); 239 xmlnode_put_attrib(y, "type", "cancel");
246 z = xmlnode_insert_tag(y, "feature-not-implemented"); 240 z = xmlnode_insert_tag(y, "feature-not-implemented");
247 xmlnode_put_attrib(z, "xmlns", 241 xmlnode_put_attrib(z, "xmlns", NS_XMPP_STANZAS);
248 "urn:ietf:params:xml:ns:xmpp-stanzas");
249 jab_send(conn, x); 242 jab_send(conn, x);
250 xmlnode_free(x); 243 xmlnode_free(x);
251 } 244 }
252 245
253 static void handle_iq_set(jconn conn, char *from, xmlnode xmldata) 246 static void handle_iq_set(jconn conn, char *from, xmlnode xmldata)
254 { 247 {
255 /* FIXME: send error */ 248 char *id;
249 xmlnode x, y, z;
250
251 id = xmlnode_get_attrib(xmldata, "id");
252 if (!id) return;
253
254 /* Not implemented yet: send an error stanza */
255 x = xmlnode_new_tag("iq");
256 xmlnode_put_attrib(x, "to", from);
257 xmlnode_put_attrib(x, "id", id);
258 xmlnode_put_attrib(x, "type", TMSG_ERROR);
259 y = xmlnode_insert_tag(x, TMSG_ERROR);
260 xmlnode_put_attrib(y, "code", "501");
261 xmlnode_put_attrib(y, "type", "cancel");
262 z = xmlnode_insert_tag(y, "feature-not-implemented");
263 xmlnode_put_attrib(z, "xmlns", NS_XMPP_STANZAS);
264
265 jab_send(conn, x);
266 xmlnode_free(x);
256 } 267 }
257 268
258 void handle_packet_iq(jconn conn, char *type, char *from, xmlnode xmldata) 269 void handle_packet_iq(jconn conn, char *type, char *from, xmlnode xmldata)
259 { 270 {
260 if (!type) 271 if (!type)