Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/jab_iq.c @ 686:98de2d166a11
Use the new IQ system for authentication
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 06 Feb 2006 21:06:19 +0100 |
parents | f033345d1315 |
children | 426145046b93 |
comparison
equal
deleted
inserted
replaced
685:f033345d1315 | 686:98de2d166a11 |
---|---|
31 #include "utils.h" | 31 #include "utils.h" |
32 #include "screen.h" | 32 #include "screen.h" |
33 #include "settings.h" | 33 #include "settings.h" |
34 | 34 |
35 | 35 |
36 int s_id; // XXX | |
37 | |
38 static GSList *iqs_list; | 36 static GSList *iqs_list; |
39 | 37 |
40 | 38 |
41 // iqs_new(type, namespace, prefix, timeout) | 39 // iqs_new(type, namespace, prefix, timeout) |
42 // Create a query (GET, SET) IQ structure. This function should not be used | 40 // Create a query (GET, SET) IQ structure. This function should not be used |
228 update_roster = TRUE; | 226 update_roster = TRUE; |
229 if (need_refresh) | 227 if (need_refresh) |
230 scr_ShowBuddyWindow(); | 228 scr_ShowBuddyWindow(); |
231 } | 229 } |
232 | 230 |
231 void iqscallback_auth(iqs *iqp, xmlnode xml_result) | |
232 { | |
233 if (jstate == STATE_GETAUTH) { | |
234 iqs *iqn; | |
235 | |
236 if (xml_result) { | |
237 xmlnode x = xmlnode_get_tag(xml_result, "query"); | |
238 if (x && !xmlnode_get_tag(x, "digest")) | |
239 jc->sid = 0; | |
240 } | |
241 | |
242 iqn = iqs_new(JPACKET__SET, NS_AUTH, "auth", IQS_DEFAULT_TIMEOUT); | |
243 iqn->callback = &iqscallback_auth; | |
244 jab_auth_mcabber(jc, iqn->xmldata); | |
245 jab_send(jc, iqn->xmldata); | |
246 jstate = STATE_SENDAUTH; | |
247 } else if (jstate == STATE_SENDAUTH) { | |
248 request_roster(); | |
249 jstate = STATE_LOGGED; | |
250 } | |
251 } | |
252 | |
233 static void handle_iq_result(jconn conn, char *from, xmlnode xmldata) | 253 static void handle_iq_result(jconn conn, char *from, xmlnode xmldata) |
234 { | 254 { |
235 xmlnode x; | 255 xmlnode x; |
236 char *id; | 256 char *id; |
237 char *ns; | 257 char *ns; |
238 | 258 |
239 id = xmlnode_get_attrib(xmldata, "id"); | 259 id = xmlnode_get_attrib(xmldata, "id"); |
240 if (!id) { | 260 if (!id) { |
241 scr_LogPrint(LPRINT_LOG, "IQ result stanza with no ID, ignored."); | 261 scr_LogPrint(LPRINT_LOG, "IQ result stanza with no ID, ignored."); |
242 return; | |
243 } | |
244 | |
245 if (atoi(id) == s_id) { // Authentication XXX | |
246 if (jstate == STATE_GETAUTH) { | |
247 if ((x = xmlnode_get_tag(xmldata, "query")) != NULL) | |
248 if (!xmlnode_get_tag(x, "digest")) { | |
249 jc->sid = 0; | |
250 } | |
251 | |
252 s_id = atoi(jab_auth(jc)); | |
253 jstate = STATE_SENDAUTH; | |
254 } else if (jstate == STATE_SENDAUTH) { | |
255 request_roster(); | |
256 jstate = STATE_LOGGED; | |
257 } | |
258 return; | 262 return; |
259 } | 263 } |
260 | 264 |
261 if (!iqs_callback(id, xmldata)) | 265 if (!iqs_callback(id, xmldata)) |
262 return; | 266 return; |