updates
authorPekka Riikonen <priikone@silcnet.org>
Thu, 2 May 2002 06:45:09 +0000 (06:45 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 2 May 2002 06:45:09 +0000 (06:45 +0000)
CHANGES
apps/irssi/src/silc/core/client_ops.c
apps/silcd/command.c
doc/draft-riikonen-silc-commands-03.nroff
lib/silcclient/command.c
lib/silcclient/command_reply.c

diff --git a/CHANGES b/CHANGES
index f147c67d341bcef5a5cb09682ac644b74dda732e..603b64b2aebd4dec7390ab4a92c2d3606e3c496b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,12 @@
+Thu May  2 08:45:11 CEST 2002 Pekka Riikonen <priikone@silcnet.org>
+
+       * Defined that the NICK command replies with thew changed
+         nickname too, to make the nickname changing simpler at
+         the client's end.  Updated protocol specs and the code
+         in client and server.  Affected files are
+         silcd/command.c, lib/silcclient/command_reply.c and
+         lib/silcclient/command.c.
+
 Mon Apr 29 20:10:42 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
 
        * Added `Compressed' packet flag to indicate that the packet
index 846f910faa909e6f302b8491474c3ee64cfd05d5..cd5979dd4f92cbb4e64135f751f50a6e0391d2db 100644 (file)
@@ -1262,8 +1262,8 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
 
   case SILC_COMMAND_NICK: 
     {
-      SilcClientEntry client = va_arg(vp, SilcClientEntry);
       char *old;
+      SilcClientEntry client = va_arg(vp, SilcClientEntry);
       
       if (!success)
        return;
index e1ab042c4f23d324bc3147c4de7a3d11b992d76c..aeecb572eaa4f552a072f1c6f41affb25a348017 100644 (file)
@@ -2085,8 +2085,9 @@ SILC_SERVER_CMD_FUNC(nick)
  send_reply:
   /* Send the new Client ID as reply command back to client */
   packet = silc_command_reply_payload_encode_va(SILC_COMMAND_NICK, 
-                                               SILC_STATUS_OK, 0, ident, 1, 
-                                               2, nidp->data, nidp->len);
+                                               SILC_STATUS_OK, 0, ident, 2,
+                                               2, nidp->data, nidp->len,
+                                               3, nick, strlen(nick));
   silc_server_packet_send(cmd->server, cmd->sock, SILC_PACKET_COMMAND_REPLY,
                          0, packet->data, packet->len, FALSE);
 
index 2552fed9eade2585a939d78e9e010ea081ad8532..2de56b4685bcfb66a5aa0bb8407cafda85c11e27 100644 (file)
@@ -471,14 +471,16 @@ List of all defined commands in SILC follows.
 
         Reply messages to the command:
 
-        Max Arguments:  2
+        Max Arguments:  3
             Arguments:  (1) <Status Payload>  (2) <New ID Payload>
+                        (3) <nickname>
 
         This command is replied always with New ID Payload that is
         generated by the server every time user changes their nickname.
         Client receiving this payload MUST start using the received
         Client ID as its current valid Client ID.  The New ID Payload
-        is described in [SILC2].
+        is described in [SILC2].  The <nickname> is the user's new
+        nickname.
 
         Status messages:
 
index fe1abaf0440b8f61d35b8e954f1420bfb1bac755..913530b2ba44cbfa56aa859763936964021b568f 100644 (file)
@@ -355,37 +355,6 @@ SILC_CLIENT_CMD_FUNC(identify)
   silc_client_command_free(cmd);
 }
 
-/* Pending callbcak that will be called after the NICK command was
-   replied by the server.  This sets the nickname if there were no
-   errors. */
-
-SILC_CLIENT_CMD_FUNC(nick_change)
-{
-  SilcClientCommandContext cmd = (SilcClientCommandContext)context;
-  SilcClientConnection conn = cmd->conn;
-  SilcClientCommandReplyContext reply = 
-    (SilcClientCommandReplyContext)context2;
-  SilcStatus status;
-
-  silc_command_get_status(reply->payload, &status, NULL);
-  if (status == SILC_STATUS_OK) {
-    /* Set the nickname */
-    silc_idcache_del_by_context(conn->client_cache, conn->local_entry);
-    if (conn->nickname)
-      silc_free(conn->nickname);
-    conn->nickname = strdup(cmd->argv[1]);
-    conn->local_entry->nickname = conn->nickname;
-    silc_client_nickname_format(cmd->client, conn, conn->local_entry);
-    silc_idcache_add(conn->client_cache, strdup(cmd->argv[1]), 
-                    conn->local_entry->id, conn->local_entry, 0, NULL);
-    COMMAND(SILC_STATUS_OK);
-  } else {
-    COMMAND_ERROR(status);
-  }
-
-  silc_client_command_free(cmd);
-}
-
 /* Command NICK. Shows current nickname/sets new nickname on current
    window. */
 
@@ -440,14 +409,6 @@ SILC_CLIENT_CMD_FUNC(nick)
                          buffer->data, buffer->len, TRUE);
   silc_buffer_free(buffer);
 
-  /* Register pending callback that will actually set the new nickname
-     if there were no errors returned by the server. */
-  silc_client_command_pending(conn, SILC_COMMAND_NICK, 
-                             cmd->conn->cmd_ident,
-                             silc_client_command_nick_change,
-                             silc_client_command_dup(cmd));
-  cmd->pending = TRUE;
-
  out:
   silc_client_command_free(cmd);
 }
index 43376be33248cbe3706aba68a4ac69f40e540061..35a7e87c261aca18f7401924ae632cc1a213fc62 100644 (file)
@@ -514,12 +514,22 @@ SILC_CLIENT_CMD_REPLY_FUNC(nick)
     goto out;
   }
   silc_client_receive_new_id(cmd->client, cmd->sock, idp);
+
+  /* Take the new nickname too */
+  tmp = silc_argument_get_arg_type(cmd->args, 3, &len);
+  if (tmp) {
+    silc_idcache_del_by_context(conn->client_cache, conn->local_entry);
+    if (conn->nickname)
+      silc_free(conn->nickname);
+    conn->nickname = strdup(tmp);
+    conn->local_entry->nickname = conn->nickname;
+    silc_client_nickname_format(cmd->client, conn, conn->local_entry);
+    silc_idcache_add(conn->client_cache, strdup(tmp),
+                     conn->local_entry->id, conn->local_entry, 0, NULL);
+  }
     
   /* Notify application */
-  SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_NICK);
-  COMMAND_REPLY((ARGS, conn->local_entry));
-  silc_client_command_reply_free(cmd);
-  return;
+  COMMAND_REPLY((ARGS, conn->local_entry, conn->local_entry->nickname));
 
  out:
   SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_NICK);