# HG changeset patch # User Mikael Berthe # Date 1196888741 -3600 # Node ID e20ab87c4c4c82ac6932ca5892a45f7a7dd176a2 # Parent 753a348c65c1604e4fef5f7fdceca886213b2f27 The command /room ban can be used with a nickname If the parameter doesn't look like a jid, check if it is a room member nickname. diff -r 753a348c65c1 -r e20ab87c4c4c mcabber/src/commands.c --- a/mcabber/src/commands.c Wed Dec 05 19:31:07 2007 +0100 +++ b/mcabber/src/commands.c Wed Dec 05 22:05:41 2007 +0100 @@ -2201,7 +2201,8 @@ static void room_ban(gpointer bud, char *arg) { char **paramlst; - gchar *fjid; + gchar *fjid, *bjid; + const gchar *banjid; gchar *jid_utf8, *reason_utf8; struct role_affil ra; const char *roomid = buddy_getjid(bud); @@ -2219,12 +2220,35 @@ ra.type = type_affil; ra.val.affil = affil_outcast; - jid_utf8 = to_utf8(fjid); + bjid = jidtodisp(fjid); + jid_utf8 = to_utf8(bjid); + + // If the argument doesn't look like a jid, we'll try to find a matching + // nickname. + if (!strchr(bjid, JID_DOMAIN_SEPARATOR) || check_jid_syntax(bjid)) { + const gchar *tmp; + // We want the initial argument, so the fjid variable, because + // we don't want to strip a resource-like string from the nickname! + g_free(jid_utf8); + jid_utf8 = to_utf8(fjid); + tmp = buddy_getrjid(bud, jid_utf8); + if (!tmp) { + scr_LogPrint(LPRINT_NORMAL, "Wrong JID or nickname"); + goto room_ban_return; + } + banjid = jidtodisp(tmp); + } else + banjid = jid_utf8; + + scr_LogPrint(LPRINT_NORMAL, "Requesting a ban for %s", banjid); + reason_utf8 = to_utf8(arg); - jb_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8); + jb_room_setattrib(roomid, banjid, NULL, ra, reason_utf8); + g_free(reason_utf8); + +room_ban_return: + g_free(bjid); g_free(jid_utf8); - g_free(reason_utf8); - free_arg_lst(paramlst); } diff -r 753a348c65c1 -r e20ab87c4c4c mcabber/src/jab_priv.h --- a/mcabber/src/jab_priv.h Wed Dec 05 19:31:07 2007 +0100 +++ b/mcabber/src/jab_priv.h Wed Dec 05 22:05:41 2007 +0100 @@ -38,7 +38,6 @@ extern time_t iqlast; /* last message/status change time */ -char *jidtodisp(const char *fjid); void handle_packet_iq(jconn conn, char *type, char *from, xmlnode xmldata); void display_server_error(xmlnode x); eviqs *iqs_new(guint8 type, const char *ns, const char *prefix, time_t timeout); diff -r 753a348c65c1 -r e20ab87c4c4c mcabber/src/jabglue.h --- a/mcabber/src/jabglue.h Wed Dec 05 19:31:07 2007 +0100 +++ b/mcabber/src/jabglue.h Wed Dec 05 22:05:41 2007 +0100 @@ -42,6 +42,7 @@ gchar *text; }; +char *jidtodisp(const char *fjid); char *compose_jid(const char *username, const char *servername, const char *resource); jconn jb_connect(const char *fjid, const char *server, unsigned int port,