From: Pekka Riikonen Date: Wed, 1 Oct 2003 17:35:40 +0000 (+0000) Subject: Command reply handling fixed for KICK and KILL. X-Git-Tag: silc.toolkit.0.9.10~31 X-Git-Url: http://git.silcnet.org/gitweb/?a=commitdiff_plain;h=526248b14ab5c0d06d04af88f9bf7edc8c6c5d4f;p=silc.git Command reply handling fixed for KICK and KILL. --- diff --git a/lib/doc/command_reply_args.html b/lib/doc/command_reply_args.html index 0601489a..bec1383e 100644 --- a/lib/doc/command_reply_args.html +++ b/lib/doc/command_reply_args.html @@ -174,9 +174,10 @@ parsed with silc_argument_payload_parse function. SILC_COMMAND_KILL -Called after killing a client. There is no arguments to this reply. +Called after killing a client. Returns the client that was killed. +The `client_entry' may be NULL. -none +SilcClientEntry client_entry @@ -297,9 +298,10 @@ SilcClientEntry target_client SILC_COMMAND_KICK -Called after kicking a client. There is no arguments to this reply. +Called after kicking a client. Returns the client that was kicked from +the 'channel'. The `client_entry' and 'channel' may be NULL. -none +SilcChannelEntry channel, SilcClientEntry client_entry diff --git a/lib/silcclient/command_reply.c b/lib/silcclient/command_reply.c index fb90b270..df78d5ae 100644 --- a/lib/silcclient/command_reply.c +++ b/lib/silcclient/command_reply.c @@ -675,7 +675,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(topic) if (cmd->error != SILC_STATUS_OK) { SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_get_status_message(cmd->error)); + "Cannot set topic: %s", silc_get_status_message(cmd->error)); COMMAND_REPLY_ERROR; goto out; } @@ -730,7 +730,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(invite) if (cmd->error != SILC_STATUS_OK) { SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_get_status_message(cmd->error)); + "Cannot invite: %s", silc_get_status_message(cmd->error)); COMMAND_REPLY_ERROR; goto out; } @@ -771,16 +771,33 @@ SILC_CLIENT_CMD_REPLY_FUNC(kill) { SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context; SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data; + SilcClientID *client_id; + SilcClientEntry client_entry = NULL; + SilcUInt32 len; + unsigned char *id_data; if (cmd->error != SILC_STATUS_OK) { SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_get_status_message(cmd->error)); + "Cannot kill: %s", silc_get_status_message(cmd->error)); COMMAND_REPLY_ERROR; goto out; } + id_data = silc_argument_get_arg_type(cmd->args, 2, &len); + if (id_data) { + client_id = silc_id_payload_parse_id(id_data, len, NULL); + if (!client_id) { + COMMAND_REPLY_ERROR; + goto out; + } + + /* Get the client entry, if exists */ + client_entry = silc_client_get_client_by_id(cmd->client, conn, client_id); + silc_free(client_id); + } + /* Notify application */ - COMMAND_REPLY((SILC_ARGS)); + COMMAND_REPLY((SILC_ARGS, client_entry)); out: SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_KILL); @@ -955,7 +972,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(join) if (cmd->error != SILC_STATUS_OK) { if (cmd->error != SILC_STATUS_ERR_USER_ON_CHANNEL) SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_get_status_message(cmd->error)); + "Cannot join channel: %s", silc_get_status_message(cmd->error)); COMMAND_REPLY_ERROR; goto out; } @@ -1199,7 +1216,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(umode) if (cmd->error != SILC_STATUS_OK) { SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_get_status_message(cmd->error)); + "Cannot change mode: %s", silc_get_status_message(cmd->error)); COMMAND_REPLY_ERROR; goto out; } @@ -1237,7 +1254,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(cmode) if (cmd->error != SILC_STATUS_OK) { SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_get_status_message(cmd->error)); + "Cannot change mode: %s", silc_get_status_message(cmd->error)); COMMAND_REPLY_ERROR; goto out; } @@ -1311,7 +1328,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(cumode) if (cmd->error != SILC_STATUS_OK) { SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_get_status_message(cmd->error)); + "Cannot change mode: %s", silc_get_status_message(cmd->error)); COMMAND_REPLY_ERROR; goto out; } @@ -1382,18 +1399,60 @@ SILC_CLIENT_CMD_REPLY_FUNC(kick) { SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context; SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data; + SilcClientID *client_id = NULL; + SilcChannelID *channel_id = NULL; + SilcClientEntry client_entry = NULL; + SilcChannelEntry channel = NULL; + unsigned char *tmp; + SilcUInt32 len; if (cmd->error != SILC_STATUS_OK) { SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_get_status_message(cmd->error)); + "Cannot kick: %s", silc_get_status_message(cmd->error)); COMMAND_REPLY_ERROR; goto out; } + /* Take Channel ID */ + tmp = silc_argument_get_arg_type(cmd->args, 2, &len); + if (tmp) { + channel_id = silc_id_payload_parse_id(tmp, len, NULL); + if (!channel_id) { + COMMAND_REPLY_ERROR; + goto out; + } + + /* Get the channel entry */ + channel = silc_client_get_channel_by_id(cmd->client, conn, channel_id); + if (!channel) { + COMMAND_REPLY_ERROR; + goto out; + } + } + + /* Get Client ID */ + tmp = silc_argument_get_arg_type(cmd->args, 3, &len); + if (tmp) { + client_id = silc_id_payload_parse_id(tmp, len, NULL); + if (!client_id) { + COMMAND_REPLY_ERROR; + goto out; + } + + /* Get client entry */ + client_entry = silc_client_get_client_by_id(cmd->client, conn, client_id); + if (!client_entry) { + COMMAND_REPLY_ERROR; + goto out; + } + } + /* Notify application */ - COMMAND_REPLY((SILC_ARGS)); + COMMAND_REPLY((SILC_ARGS, channel, client_entry)); out: + silc_free(channel_id); + silc_free(client_id); SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_KICK); silc_client_command_reply_free(cmd); } @@ -1798,7 +1857,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(users) if (cmd->error != SILC_STATUS_OK) { SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_get_status_message(cmd->error)); + "Query failed: %s", silc_get_status_message(cmd->error)); COMMAND_REPLY_ERROR; goto out; } @@ -1814,7 +1873,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(users) goto out; } else { SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, - "%s", silc_get_status_message(cmd->error)); + "Query failed: %s", silc_get_status_message(cmd->error)); COMMAND_REPLY_ERROR; goto out; } diff --git a/lib/silcclient/silcclient.h b/lib/silcclient/silcclient.h index 75cd26c7..bcfa8ea5 100644 --- a/lib/silcclient/silcclient.h +++ b/lib/silcclient/silcclient.h @@ -1230,7 +1230,7 @@ typedef void (*SilcGetClientCallback)(SilcClient client, * completion callback will be called when the client entries has been * found. After the server returns the client information it is cached * and can be accesses locally at a later time. The resolving is done - * with IDENTIFY command. + * with IDENTIFY command. The `server' may be NULL. * * NOTES *