From b1a49687af6bbac5dd64e3ff18650a9d1685e993 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Thu, 2 May 2002 06:45:09 +0000 Subject: [PATCH] updates --- CHANGES | 9 ++++++ apps/irssi/src/silc/core/client_ops.c | 2 +- apps/silcd/command.c | 5 +-- doc/draft-riikonen-silc-commands-03.nroff | 6 ++-- lib/silcclient/command.c | 39 ----------------------- lib/silcclient/command_reply.c | 18 ++++++++--- 6 files changed, 31 insertions(+), 48 deletions(-) diff --git a/CHANGES b/CHANGES index f147c67d..603b64b2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,12 @@ +Thu May 2 08:45:11 CEST 2002 Pekka Riikonen + + * 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 * Added `Compressed' packet flag to indicate that the packet diff --git a/apps/irssi/src/silc/core/client_ops.c b/apps/irssi/src/silc/core/client_ops.c index 846f910f..cd5979dd 100644 --- a/apps/irssi/src/silc/core/client_ops.c +++ b/apps/irssi/src/silc/core/client_ops.c @@ -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; diff --git a/apps/silcd/command.c b/apps/silcd/command.c index e1ab042c..aeecb572 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -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); diff --git a/doc/draft-riikonen-silc-commands-03.nroff b/doc/draft-riikonen-silc-commands-03.nroff index 2552fed9..2de56b46 100644 --- a/doc/draft-riikonen-silc-commands-03.nroff +++ b/doc/draft-riikonen-silc-commands-03.nroff @@ -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) (2) + (3) 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 is the user's new + nickname. Status messages: diff --git a/lib/silcclient/command.c b/lib/silcclient/command.c index fe1abaf0..913530b2 100644 --- a/lib/silcclient/command.c +++ b/lib/silcclient/command.c @@ -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); } diff --git a/lib/silcclient/command_reply.c b/lib/silcclient/command_reply.c index 43376be3..35a7e87c 100644 --- a/lib/silcclient/command_reply.c +++ b/lib/silcclient/command_reply.c @@ -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); -- 2.24.0