Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/jab_iq.c @ 596:6c7fd289648f
Clean up handle_iq_result()
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Tue, 13 Dec 2005 22:16:27 +0100 |
parents | 0c1d37300862 |
children | 96831b222903 |
comparison
equal
deleted
inserted
replaced
595:0c1d37300862 | 596:6c7fd289648f |
---|---|
156 static void handle_iq_result(jconn conn, char *from, xmlnode xmldata) | 156 static void handle_iq_result(jconn conn, char *from, xmlnode xmldata) |
157 { | 157 { |
158 xmlnode x; | 158 xmlnode x; |
159 char *p; | 159 char *p; |
160 char *ns; | 160 char *ns; |
161 | 161 int iid; |
162 if ((p = xmlnode_get_attrib(xmldata, "id")) != NULL) { | 162 |
163 int iid = atoi(p); | 163 p = xmlnode_get_attrib(xmldata, "id"); |
164 | 164 if (!p) { |
165 //scr_LogPrint(LPRINT_DEBUG, "iid = %d", iid); | 165 scr_LogPrint(LPRINT_LOG, "IQ result stanza with no ID, ignored."); |
166 if (iid == s_id) { // Authentication | 166 return; |
167 if (jstate == STATE_GETAUTH) { | 167 } |
168 if ((x = xmlnode_get_tag(xmldata, "query")) != NULL) | 168 |
169 if (!xmlnode_get_tag(x, "digest")) { | 169 iid = atoi(p); // XXX |
170 jc->sid = 0; | 170 if (iid == s_id) { // Authentication |
171 } | 171 if (jstate == STATE_GETAUTH) { |
172 | 172 if ((x = xmlnode_get_tag(xmldata, "query")) != NULL) |
173 s_id = atoi(jab_auth(jc)); | 173 if (!xmlnode_get_tag(x, "digest")) { |
174 jstate = STATE_SENDAUTH; | 174 jc->sid = 0; |
175 } else if (jstate == STATE_SENDAUTH) { | 175 } |
176 gotloggedin(); | 176 |
177 jstate = STATE_LOGGED; | 177 s_id = atoi(jab_auth(jc)); |
178 } | 178 jstate = STATE_SENDAUTH; |
179 return; | 179 } else if (jstate == STATE_SENDAUTH) { |
180 } | 180 gotloggedin(); |
181 | 181 jstate = STATE_LOGGED; |
182 if (!strcmp(p, "VCARDreq")) { | 182 } |
183 x = xmlnode_get_firstchild(xmldata); | 183 return; |
184 if (!x) x = xmldata; | 184 } |
185 | 185 |
186 scr_LogPrint(LPRINT_LOGNORM, "Got VCARD"); // TODO | 186 if (!strcmp(p, "VCARDreq")) { |
187 return; | 187 x = xmlnode_get_firstchild(xmldata); |
188 } else if (!strcmp(p, "versionreq")) { | 188 if (!x) x = xmldata; |
189 scr_LogPrint(LPRINT_LOGNORM, "Got version"); // TODO | 189 |
190 return; | 190 scr_LogPrint(LPRINT_LOGNORM, "Got VCARD"); // TODO |
191 } | 191 return; |
192 } else if (!strcmp(p, "versionreq")) { | |
193 scr_LogPrint(LPRINT_LOGNORM, "Got version"); // TODO | |
194 return; | |
192 } | 195 } |
193 | 196 |
194 x = xmlnode_get_tag(xmldata, "query"); | 197 x = xmlnode_get_tag(xmldata, "query"); |
195 if (!x) return; | 198 if (!x) return; |
196 | 199 |
237 y = xmlnode_insert_tag(x, TMSG_ERROR); | 240 y = xmlnode_insert_tag(x, TMSG_ERROR); |
238 xmlnode_put_attrib(y, "code", "501"); | 241 xmlnode_put_attrib(y, "code", "501"); |
239 xmlnode_put_attrib(y, "type", "cancel"); | 242 xmlnode_put_attrib(y, "type", "cancel"); |
240 z = xmlnode_insert_tag(y, "feature-not-implemented"); | 243 z = xmlnode_insert_tag(y, "feature-not-implemented"); |
241 xmlnode_put_attrib(z, "xmlns", NS_XMPP_STANZAS); | 244 xmlnode_put_attrib(z, "xmlns", NS_XMPP_STANZAS); |
245 | |
242 jab_send(conn, x); | 246 jab_send(conn, x); |
243 xmlnode_free(x); | 247 xmlnode_free(x); |
244 } | 248 } |
245 | 249 |
246 static void handle_iq_set(jconn conn, char *from, xmlnode xmldata) | 250 static void handle_iq_set(jconn conn, char *from, xmlnode xmldata) |