MUC: Add "nickname" option variable
The nickname is now optional in the "/room join" command. The default
nickname is the "nickname" option value; if there is none, the jid username
is used.
--- a/mcabber/mcabberrc.example Sat Jan 07 23:12:22 2006 +0100
+++ b/mcabber/mcabberrc.example Sun Jan 08 01:25:58 2006 +0100
@@ -23,6 +23,12 @@
set resource = mcabber
#set priority = 3
+# Conference nickname
+# This nickname is used when joining a room, when no nick is explicitly
+# specified by the user. Note that when the nickname option is not set,
+# the username variable can be used.
+#set nickname = Abitbol
+
# Proxy
# mcabber can use a proxy if it supports the CONNECT method
# The proxy_user/proxy_pass variables are optional.
--- a/mcabber/src/commands.c Sat Jan 07 23:12:22 2006 +0100
+++ b/mcabber/src/commands.c Sun Jan 08 01:25:58 2006 +0100
@@ -1303,6 +1303,7 @@
{
char **paramlst;
char *roomname, *nick;
+ char *tmpnick = NULL;
paramlst = split_arg(arg, 2, 0); // roomid, nickname
roomname = *paramlst;
@@ -1315,6 +1316,21 @@
return;
}
+ // If no nickname is provided with the /join command,
+ // we try the "nickname" option, then the username part of the jid.
+ if (!nick || !*nick) {
+ nick = (char*)settings_opt_get("nickname");
+ if (!nick) {
+ nick = (char*)settings_opt_get("username");
+ if (nick && (strchr(nick, '@') > nick)) {
+ char *p;
+ nick = tmpnick = g_strdup(nick);
+ p = strchr(nick, '@');
+ *p = 0;
+ }
+ }
+ }
+ // If we still have no nickname, give up
if (!nick || !*nick) {
scr_LogPrint(LPRINT_NORMAL, "Missing parameter (nickname)");
free_arg_lst(paramlst);
@@ -1331,6 +1347,8 @@
buddylist_build();
update_roster = TRUE;
free_arg_lst(paramlst);
+ if (tmpnick)
+ g_free(tmpnick);
}
static void room_invite(gpointer bud, char *arg)