# HG changeset patch # User Mikael Berthe # Date 1128206236 -7200 # Node ID eaa2ad7731929edd25bb37b1592344755b15119f # Parent a926523d2392c3a36059cf9ce1c09542b05948b2 Add "/room nick" diff -r a926523d2392 -r eaa2ad773192 mcabber/doc/mcabber.1 --- a/mcabber/doc/mcabber.1 Sat Oct 01 23:17:05 2005 +0200 +++ b/mcabber/doc/mcabber.1 Sun Oct 02 00:37:16 2005 +0200 @@ -206,6 +206,7 @@ \fBjoin\fR room nick join "room", using "nick" as nickname \fBleave\fR leave the current room \fBnames\fR display members of the current room + \fBnick\fR nick change your nickname in the current room \fBremove\fR remove the current room from the roster (you must have left this room before) \fBunlock\fR unlock current room (if you are the owner) diff -r a926523d2392 -r eaa2ad773192 mcabber/doc/mcabber.1.html --- a/mcabber/doc/mcabber.1.html Sat Oct 01 23:17:05 2005 +0200 +++ b/mcabber/doc/mcabber.1.html Sun Oct 02 00:37:16 2005 +0200 @@ -438,7 +438,7 @@ the buddies to another group with the "/move" command).
-/room join|leave|names|remove|unlock +/room join|leave|names|nick|remove|unlock
The room command handles Multi-User Chat room actions. @@ -469,6 +469,14 @@ +nick nick + + +change your nickname in the current room + + + + remove @@ -637,7 +645,7 @@ diff -r a926523d2392 -r eaa2ad773192 mcabber/doc/mcabber.1.txt --- a/mcabber/doc/mcabber.1.txt Sat Oct 01 23:17:05 2005 +0200 +++ b/mcabber/doc/mcabber.1.txt Sun Oct 02 00:37:16 2005 +0200 @@ -176,12 +176,13 @@ This command does not work for groups, at the moment (but you can move the buddies to another group with the "/move" command). -/room join|leave|names|remove|unlock:: +/room join|leave|names|nick|remove|unlock:: The 'room' command handles Multi-User Chat room actions. 'join' room nick;; join "room", using "nick" as nickname 'leave';; leave the current room 'names';; display members of the current room + 'nick' nick;; change your nickname in the current room 'remove';; remove the current room from the roster (you must have left this room before) 'unlock';; unlock current room (if you are the owner) diff -r a926523d2392 -r eaa2ad773192 mcabber/src/commands.c --- a/mcabber/src/commands.c Sat Oct 01 23:17:05 2005 +0200 +++ b/mcabber/src/commands.c Sun Oct 02 00:37:16 2005 +0200 @@ -154,6 +154,7 @@ compl_add_category_word(COMPL_ROOM, "join"); compl_add_category_word(COMPL_ROOM, "leave"); compl_add_category_word(COMPL_ROOM, "names"); + compl_add_category_word(COMPL_ROOM, "nick"); compl_add_category_word(COMPL_ROOM, "remove"); compl_add_category_word(COMPL_ROOM, "unlock"); } @@ -1017,6 +1018,22 @@ return; } do_info(NULL); + } else if (!strncasecmp(arg, "nick", 4)) { + gchar *cmd; + arg += 4; + if (*arg++ != ' ') { + scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter"); + return; + } + for (; *arg && *arg == ' '; arg++) + ; + if (!(buddy_gettype(bud) & ROSTER_TYPE_ROOM)) { + scr_LogPrint(LPRINT_NORMAL, "This isn't a chatroom"); + return; + } + cmd = g_strdup_printf("join %s %s", buddy_getjid(bud), arg); + do_room(cmd); + g_free(cmd); } else if (!strcasecmp(arg, "remove")) { if (!(buddy_gettype(bud) & ROSTER_TYPE_ROOM)) { scr_LogPrint(LPRINT_NORMAL, "This isn't a chatroom"); diff -r a926523d2392 -r eaa2ad773192 mcabber/src/jabglue.c --- a/mcabber/src/jabglue.c Sat Oct 01 23:17:05 2005 +0200 +++ b/mcabber/src/jabglue.c Sun Oct 02 00:37:16 2005 +0200 @@ -476,7 +476,6 @@ { xmlnode x, y; gchar *roomid, *utf8_nickname; - GSList *roster_usr; if (!online || !room || !nickname) return; @@ -490,11 +489,6 @@ return; } - // We need to save the nickname for future use - roster_usr = roster_add_user(room, NULL, NULL, ROSTER_TYPE_ROOM); - if (roster_usr) - buddy_setnickname(roster_usr->data, nickname); - // Send the XML request x = jutil_presnew(JPACKET__UNKNOWN, 0, 0); xmlnode_put_attrib(x, "from", jid_full(jc->user)); @@ -1104,6 +1098,9 @@ g_free(mbuf); if (newname_noutf8) { buddy_resource_setname(room_elt->data, rname, newname_noutf8); + m = buddy_getnickname(room_elt->data); + if (m && !strcmp(rname, m)) + buddy_setnickname(room_elt->data, newname_noutf8); g_free(newname_noutf8); } } @@ -1116,7 +1113,13 @@ g_free(mbuf); } else if (buddy_getstatus(room_elt->data, rname) == offline && ust != offline) { - gchar *mbuf = g_strdup_printf("%s has joined", rname); + gchar *mbuf; + if (buddy_getnickname(room_elt->data) == NULL) { + buddy_setnickname(room_elt->data, rname); + mbuf = g_strdup_printf("You have joined as \"%s\"", rname); + } else { + mbuf = g_strdup_printf("%s has joined", rname); + } scr_WriteIncomingMessage(r, mbuf, 0, HBB_PREFIX_INFO); g_free(mbuf); }