# HG changeset patch # User Mikael Berthe # Date 1135764519 -3600 # Node ID f6946251acdf595dcbf3dacba724e82e781ee524 # Parent aff6df4b408bde903a4823f9d45de1bbcb515d77 "/add" can be used with no jid (it will use the current buddy's jid) diff -r aff6df4b408b -r f6946251acdf mcabber/src/commands.c --- a/mcabber/src/commands.c Mon Dec 26 19:42:57 2005 +0100 +++ b/mcabber/src/commands.c Wed Dec 28 11:08:39 2005 +0100 @@ -530,13 +530,28 @@ id = *paramlst; nick = *(paramlst+1); - if (check_jid_syntax(id)) { + if (!id) + nick = NULL; // Allow things like: /add "" nick + else if (!*id) + id = NULL; + + if (id) { + // The JID has been specified. Quick check... + if (check_jid_syntax(id)) { + scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", id); + id = NULL; + } else { + mc_strtolower(id); + } + } else { + // Add the current buddy + if (current_buddy) + id = (char*)buddy_getjid(BUDDATA(current_buddy)); if (!id) - scr_LogPrint(LPRINT_NORMAL, "Wrong usage"); - else - scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", id); - } else { - mc_strtolower(id); + scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber id"); + } + + if (id) { // 2nd parameter = optional nickname jb_addbuddy(id, nick, NULL); scr_LogPrint(LPRINT_LOGNORM, "Sent presence notification request to <%s>",