Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/jab_iq.c @ 995:c89e7993c4d9
Answer IQ disco#info queries
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Wed, 01 Nov 2006 23:40:48 +0100 |
parents | 5b01de4ac5e1 |
children | dd9e7eb5f8a8 |
comparison
equal
deleted
inserted
replaced
994:eb416c9633b5 | 995:c89e7993c4d9 |
---|---|
443 // so we should be there only once. (That's ugly, however) | 443 // so we should be there only once. (That's ugly, however) |
444 jb_setstatus(available, NULL, NULL); | 444 jb_setstatus(available, NULL, NULL); |
445 } | 445 } |
446 } | 446 } |
447 | 447 |
448 static void handle_iq_disco_info(jconn conn, char *from, const char *id, | |
449 xmlnode xmldata) | |
450 { | |
451 xmlnode x, y; | |
452 xmlnode myquery; | |
453 | |
454 x = jutil_iqnew(JPACKET__RESULT, NS_DISCO_INFO); | |
455 xmlnode_put_attrib(x, "id", id); | |
456 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); | |
457 myquery = xmlnode_get_tag(x, "query"); | |
458 | |
459 y = xmlnode_insert_tag(myquery, "identity"); | |
460 xmlnode_put_attrib(y, "category", "client"); | |
461 xmlnode_put_attrib(y, "type", "pc"); | |
462 xmlnode_put_attrib(y, "name", PACKAGE_NAME); | |
463 | |
464 xmlnode_put_attrib(xmlnode_insert_tag(myquery, "feature"), | |
465 "var", NS_DISCO_INFO); | |
466 xmlnode_put_attrib(xmlnode_insert_tag(myquery, "feature"), | |
467 "var", NS_MUC); | |
468 xmlnode_put_attrib(xmlnode_insert_tag(myquery, "feature"), | |
469 "var", NS_CHATSTATES); | |
470 xmlnode_put_attrib(xmlnode_insert_tag(myquery, "feature"), | |
471 "var", NS_TIME); | |
472 xmlnode_put_attrib(xmlnode_insert_tag(myquery, "feature"), | |
473 "var", NS_VERSION); | |
474 | |
475 jab_send(jc, x); | |
476 xmlnode_free(x); | |
477 } | |
478 | |
448 static void handle_iq_version(jconn conn, char *from, const char *id, | 479 static void handle_iq_version(jconn conn, char *from, const char *id, |
449 xmlnode xmldata) | 480 xmlnode xmldata) |
450 { | 481 { |
451 xmlnode senderquery, x; | 482 xmlnode x; |
452 xmlnode myquery; | 483 xmlnode myquery; |
453 char *os = NULL; | 484 char *os = NULL; |
454 char *ver = mcabber_version(); | 485 char *ver = mcabber_version(); |
455 | 486 |
456 // "from" has already been converted to user locale | |
457 scr_LogPrint(LPRINT_LOGNORM, "Received an IQ version request from <%s>", | 487 scr_LogPrint(LPRINT_LOGNORM, "Received an IQ version request from <%s>", |
458 from); | 488 from); |
459 | 489 |
460 senderquery = xmlnode_get_tag(xmldata, "query"); | |
461 if (!settings_opt_get_int("iq_version_hide_os")) { | 490 if (!settings_opt_get_int("iq_version_hide_os")) { |
462 struct utsname osinfo; | 491 struct utsname osinfo; |
463 uname(&osinfo); | 492 uname(&osinfo); |
464 os = g_strdup_printf("%s %s %s", osinfo.sysname, osinfo.release, | 493 os = g_strdup_printf("%s %s %s", osinfo.sysname, osinfo.release, |
465 osinfo.machine); | 494 osinfo.machine); |
484 | 513 |
485 // This function borrows some code from the Gaim project | 514 // This function borrows some code from the Gaim project |
486 static void handle_iq_time(jconn conn, char *from, const char *id, | 515 static void handle_iq_time(jconn conn, char *from, const char *id, |
487 xmlnode xmldata) | 516 xmlnode xmldata) |
488 { | 517 { |
489 xmlnode senderquery, x; | 518 xmlnode x; |
490 xmlnode myquery; | 519 xmlnode myquery; |
491 char *buf, *utf8_buf; | 520 char *buf, *utf8_buf; |
492 time_t now_t; | 521 time_t now_t; |
493 struct tm *now; | 522 struct tm *now; |
494 | 523 |
495 time(&now_t); | 524 time(&now_t); |
496 | 525 |
497 // "from" has already been converted to user locale | |
498 scr_LogPrint(LPRINT_LOGNORM, "Received an IQ time request from <%s>", from); | 526 scr_LogPrint(LPRINT_LOGNORM, "Received an IQ time request from <%s>", from); |
499 | 527 |
500 buf = g_new0(char, 512); | 528 buf = g_new0(char, 512); |
501 senderquery = xmlnode_get_tag(xmldata, "query"); | |
502 | 529 |
503 x = jutil_iqnew(JPACKET__RESULT, NS_TIME); | 530 x = jutil_iqnew(JPACKET__RESULT, NS_TIME); |
504 xmlnode_put_attrib(x, "id", id); | 531 xmlnode_put_attrib(x, "id", id); |
505 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); | 532 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); |
506 myquery = xmlnode_get_tag(x, "query"); | 533 myquery = xmlnode_get_tag(x, "query"); |
542 return; | 569 return; |
543 } | 570 } |
544 | 571 |
545 x = xmlnode_get_tag(xmldata, "query"); | 572 x = xmlnode_get_tag(xmldata, "query"); |
546 ns = xmlnode_get_attrib(x, "xmlns"); | 573 ns = xmlnode_get_attrib(x, "xmlns"); |
547 if (ns && !strcmp(ns, NS_VERSION)) { | 574 if (ns && !strcmp(ns, NS_DISCO_INFO)) { |
575 handle_iq_disco_info(conn, from, id, xmldata); | |
576 } else if (ns && !strcmp(ns, NS_VERSION)) { | |
548 handle_iq_version(conn, from, id, xmldata); | 577 handle_iq_version(conn, from, id, xmldata); |
549 } else if (ns && !strcmp(ns, NS_TIME)) { | 578 } else if (ns && !strcmp(ns, NS_TIME)) { |
550 handle_iq_time(conn, from, id, xmldata); | 579 handle_iq_time(conn, from, id, xmldata); |
551 } else { | 580 } else { |
552 iq_not_implemented = TRUE; | 581 iq_not_implemented = TRUE; |