# HG changeset patch # User Mikael Berthe # Date 1144490672 -7200 # Node ID 898dd706cc5c3fe57ca738e91d96249ce206da69 # Parent 89ad7b530b3cad585942dcbdee2a7bc8e426198d 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. diff -r 89ad7b530b3c -r 898dd706cc5c mcabber/src/jabglue.c --- a/mcabber/src/jabglue.c Fri Apr 07 19:58:56 2006 +0200 +++ b/mcabber/src/jabglue.c Sat Apr 08 12:04:32 2006 +0200 @@ -552,18 +552,22 @@ { GSList *resources; GSList *roster_elt; + void (*request_fn)(const char *); + const char *strreqtype; - if (reqtype == iqreq_none) return; + if (reqtype == iqreq_version) { + request_fn = &request_version; + strreqtype = "version"; + } else if (reqtype == iqreq_time) { + request_fn = &request_time; + strreqtype = "time"; + } else + return; if (strchr(jid, '/')) { // This is a full JID - if (reqtype == iqreq_version) { - request_version(jid); - scr_LogPrint(LPRINT_NORMAL, "Sent version request to <%s>", jid); - } else if (reqtype == iqreq_time) { - request_time(jid); - scr_LogPrint(LPRINT_NORMAL, "Sent time request to <%s>", jid); - } + (*request_fn)(jid); + scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, jid); return; } @@ -571,22 +575,23 @@ roster_elt = roster_find(jid, jidsearch, ROSTER_TYPE_USER|ROSTER_TYPE_ROOM); if (!roster_elt) { scr_LogPrint(LPRINT_NORMAL, "No known resource for <%s>...", jid); - request_version(jid); // Let's send a request anyway... + (*request_fn)(jid); // Let's send a request anyway... + scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, jid); return; } // Send a request to each resource resources = buddy_getresources(roster_elt->data); + if (!resources) { + scr_LogPrint(LPRINT_NORMAL, "No known resource for <%s>...", jid); + (*request_fn)(jid); // Let's send a request anyway... + scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, jid); + } for ( ; resources ; resources = g_slist_next(resources) ) { gchar *fulljid; fulljid = g_strdup_printf("%s/%s", jid, (char*)resources->data); - if (reqtype == iqreq_version) { - request_version(fulljid); - scr_LogPrint(LPRINT_NORMAL, "Sent version request to <%s>", fulljid); - } else if (reqtype == iqreq_time) { - request_time(fulljid); - scr_LogPrint(LPRINT_NORMAL, "Sent time request to <%s>", fulljid); - } + (*request_fn)(fulljid); + scr_LogPrint(LPRINT_NORMAL, "Sent %s request to <%s>", strreqtype, fulljid); g_free(fulljid); } }