Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/jabglue.c @ 793:898dd706cc5c
Fix up /request command
The /request command didn't inform the user when the buddy wasn't online and
had no resource.
Querying a buddy who was not in the roster, for time, didn't work.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 08 Apr 2006 12:04:32 +0200 |
parents | 46304b773a44 |
children | 55cd45481a07 |
comparison
equal
deleted
inserted
replaced
792:89ad7b530b3c | 793:898dd706cc5c |
---|---|
550 | 550 |
551 void jb_request(const char *jid, enum iqreq_type reqtype) | 551 void jb_request(const char *jid, enum iqreq_type reqtype) |
552 { | 552 { |
553 GSList *resources; | 553 GSList *resources; |
554 GSList *roster_elt; | 554 GSList *roster_elt; |
555 | 555 void (*request_fn)(const char *); |
556 if (reqtype == iqreq_none) return; | 556 const char *strreqtype; |
557 | |
558 if (reqtype == iqreq_version) { | |
559 request_fn = &request_version; | |
560 strreqtype = "version"; | |
561 } else if (reqtype == iqreq_time) { | |
562 request_fn = &request_time; | |
563 strreqtype = "time"; | |
564 } else | |
565 return; | |
557 | 566 |
558 if (strchr(jid, '/')) { | 567 if (strchr(jid, '/')) { |
559 // This is a full JID | 568 // This is a full JID |
560 if (reqtype == iqreq_version) { | 569 (*request_fn)(jid); |
561 request_version(jid); | 570 scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, jid); |
562 scr_LogPrint(LPRINT_NORMAL, "Sent version request to <%s>", jid); | |
563 } else if (reqtype == iqreq_time) { | |
564 request_time(jid); | |
565 scr_LogPrint(LPRINT_NORMAL, "Sent time request to <%s>", jid); | |
566 } | |
567 return; | 571 return; |
568 } | 572 } |
569 | 573 |
570 // The resource has not been specified | 574 // The resource has not been specified |
571 roster_elt = roster_find(jid, jidsearch, ROSTER_TYPE_USER|ROSTER_TYPE_ROOM); | 575 roster_elt = roster_find(jid, jidsearch, ROSTER_TYPE_USER|ROSTER_TYPE_ROOM); |
572 if (!roster_elt) { | 576 if (!roster_elt) { |
573 scr_LogPrint(LPRINT_NORMAL, "No known resource for <%s>...", jid); | 577 scr_LogPrint(LPRINT_NORMAL, "No known resource for <%s>...", jid); |
574 request_version(jid); // Let's send a request anyway... | 578 (*request_fn)(jid); // Let's send a request anyway... |
579 scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, jid); | |
575 return; | 580 return; |
576 } | 581 } |
577 | 582 |
578 // Send a request to each resource | 583 // Send a request to each resource |
579 resources = buddy_getresources(roster_elt->data); | 584 resources = buddy_getresources(roster_elt->data); |
585 if (!resources) { | |
586 scr_LogPrint(LPRINT_NORMAL, "No known resource for <%s>...", jid); | |
587 (*request_fn)(jid); // Let's send a request anyway... | |
588 scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, jid); | |
589 } | |
580 for ( ; resources ; resources = g_slist_next(resources) ) { | 590 for ( ; resources ; resources = g_slist_next(resources) ) { |
581 gchar *fulljid; | 591 gchar *fulljid; |
582 fulljid = g_strdup_printf("%s/%s", jid, (char*)resources->data); | 592 fulljid = g_strdup_printf("%s/%s", jid, (char*)resources->data); |
583 if (reqtype == iqreq_version) { | 593 (*request_fn)(fulljid); |
584 request_version(fulljid); | 594 scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, fulljid); |
585 scr_LogPrint(LPRINT_NORMAL, "Sent version request to <%s>", fulljid); | |
586 } else if (reqtype == iqreq_time) { | |
587 request_time(fulljid); | |
588 scr_LogPrint(LPRINT_NORMAL, "Sent time request to <%s>", fulljid); | |
589 } | |
590 g_free(fulljid); | 595 g_free(fulljid); |
591 } | 596 } |
592 } | 597 } |
593 | 598 |
594 // Join a MUC room | 599 // Join a MUC room |