Mercurial > hg
diff mcabber/src/jabglue.c @ 693:e98abd3ce28c
Add /request command
Usage: /request version|time [jid]
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 11 Feb 2006 15:18:45 +0100 |
parents | 3c0a0a993de8 |
children | c299035ccb9f |
line wrap: on
line diff
--- a/mcabber/src/jabglue.c Thu Feb 09 23:25:25 2006 +0100 +++ b/mcabber/src/jabglue.c Sat Feb 11 15:18:45 2006 +0100 @@ -571,9 +571,46 @@ g_free(cleanjid); } -void jb_request_time(const char *fulljid) +void jb_request(const char *jid, enum iqreq_type reqtype) { - request_time(fulljid); + GSList *resources; + GSList *roster_elt; + + if (reqtype == iqreq_none) 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); + } + return; + } + + // The resource has not been specified + roster_elt = roster_find(jid, jidsearch, ROSTER_TYPE_USER|ROSTER_TYPE_ROOM); + if (!roster_elt) { + scr_LogPrint(LPRINT_NORMAL, "User <%s> isn't in the roster."); + return; + } + + // Send a request to each resource + resources = buddy_getresources(roster_elt->data); + 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); + } + g_free(fulljid); + } } // Join a MUC room