+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
case SILC_COMMAND_NICK:
{
- SilcClientEntry client = va_arg(vp, SilcClientEntry);
char *old;
+ SilcClientEntry client = va_arg(vp, SilcClientEntry);
if (!success)
return;
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);
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:
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. */
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);
}
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);