Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/jab_iq.c @ 691:3c0a0a993de8
Implement IQ:time requests
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Thu, 09 Feb 2006 23:21:49 +0100 |
parents | 3e965a1186c7 |
children | d3511f846d47 |
comparison
equal
deleted
inserted
replaced
690:3e965a1186c7 | 691:3c0a0a993de8 |
---|---|
302 if (utf8_jid) g_free(utf8_jid); | 302 if (utf8_jid) g_free(utf8_jid); |
303 iqn->callback = &iqscallback_version; | 303 iqn->callback = &iqscallback_version; |
304 jab_send(jc, iqn->xmldata); | 304 jab_send(jc, iqn->xmldata); |
305 } | 305 } |
306 | 306 |
307 void iqscallback_time(iqs *iqp, xmlnode xml_result) | |
308 { | |
309 xmlnode ansqry; | |
310 char *p, *p_noutf8; | |
311 | |
312 // xml_result is null for timeouts and errors | |
313 if (!xml_result) return; | |
314 | |
315 ansqry = xmlnode_get_tag(xml_result, "query"); | |
316 if (!ansqry) { | |
317 scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:time result!"); | |
318 return; | |
319 } | |
320 // Display IQ result sender... | |
321 p = xmlnode_get_attrib(xml_result, "from"); | |
322 if (!p) { | |
323 scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:time result (no sender name)."); | |
324 return; | |
325 } | |
326 p_noutf8 = from_utf8(p); | |
327 if (p_noutf8) { | |
328 scr_LogPrint(LPRINT_LOGNORM, "IQ:time from <%s>", p_noutf8); | |
329 g_free(p_noutf8); | |
330 } | |
331 // Get result data... | |
332 p = xmlnode_get_tag_data(ansqry, "utc"); | |
333 if (p) { | |
334 p_noutf8 = from_utf8(p); | |
335 if (p_noutf8) { | |
336 scr_LogPrint(LPRINT_LOGNORM, "UTC: %s", p_noutf8); | |
337 g_free(p_noutf8); | |
338 } | |
339 } | |
340 p = xmlnode_get_tag_data(ansqry, "tz"); | |
341 if (p) { | |
342 p_noutf8 = from_utf8(p); | |
343 if (p_noutf8) { | |
344 scr_LogPrint(LPRINT_LOGNORM, "TZ: %s", p_noutf8); | |
345 g_free(p_noutf8); | |
346 } | |
347 } | |
348 p = xmlnode_get_tag_data(ansqry, "display"); | |
349 if (p) { | |
350 p_noutf8 = from_utf8(p); | |
351 if (p_noutf8) { | |
352 scr_LogPrint(LPRINT_LOGNORM, "Time: %s", p_noutf8); | |
353 g_free(p_noutf8); | |
354 } | |
355 } | |
356 } | |
357 | |
358 void request_time(const char *fulljid) | |
359 { | |
360 iqs *iqn; | |
361 gchar *utf8_jid = to_utf8(fulljid); | |
362 | |
363 iqn = iqs_new(JPACKET__GET, NS_TIME, "time", IQS_DEFAULT_TIMEOUT); | |
364 xmlnode_put_attrib(iqn->xmldata, "to", utf8_jid); | |
365 if (utf8_jid) g_free(utf8_jid); | |
366 iqn->callback = &iqscallback_time; | |
367 jab_send(jc, iqn->xmldata); | |
368 } | |
369 | |
307 void iqscallback_auth(iqs *iqp, xmlnode xml_result) | 370 void iqscallback_auth(iqs *iqp, xmlnode xml_result) |
308 { | 371 { |
309 if (jstate == STATE_GETAUTH) { | 372 if (jstate == STATE_GETAUTH) { |
310 iqs *iqn; | 373 iqs *iqn; |
311 | 374 |