Mercurial > hg
changeset 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 | 89ad7b530b3c |
children | 32d5298f9f8d |
files | mcabber/src/jabglue.c |
diffstat | 1 files changed, 21 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- 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); } }