changeset 470:eaa2ad773192

Add "/room nick"
author Mikael Berthe <mikael@lilotux.net>
date Sun, 02 Oct 2005 00:37:16 +0200
parents a926523d2392
children 82a27508fb85
files mcabber/doc/mcabber.1 mcabber/doc/mcabber.1.html mcabber/doc/mcabber.1.txt mcabber/src/commands.c mcabber/src/jabglue.c
diffstat 5 files changed, 40 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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)
 
--- 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).
 </dd>
 <dt><b>
-/room join|leave|names|remove|unlock
+/room join|leave|names|nick|remove|unlock
 </b></dt>
 <dd>
         The <b>room</b> command handles Multi-User Chat room actions.
@@ -469,6 +469,14 @@
 </tr>
 <tr valign="top">
 <td>
+<b>nick</b> nick
+</td>
+<td>
+change your nickname in the current room
+</td>
+</tr>
+<tr valign="top">
+<td>
 <b>remove</b>
 </td>
 <td>
@@ -637,7 +645,7 @@
 <div id="footer">
 <p>
 Version 0.6.9-dev<br />
-Last updated 01-Oct-2005 15:56:26 CEST
+Last updated 02-Oct-2005 00:35:54 CEST
 </p>
 </div>
 </div>
--- 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)
 
--- 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");
--- 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);
           }