Command reply handling fixed for KICK and KILL.
authorPekka Riikonen <priikone@silcnet.org>
Wed, 1 Oct 2003 17:35:40 +0000 (17:35 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Wed, 1 Oct 2003 17:35:40 +0000 (17:35 +0000)
lib/doc/command_reply_args.html
lib/silcclient/command_reply.c
lib/silcclient/silcclient.h

index 0601489a42d55ab13e05cc5cf87c26d8799697a8..bec1383e4adb16135da2c0d456024dd32a19612b 100644 (file)
@@ -174,9 +174,10 @@ parsed with silc_argument_payload_parse function.
 <tr>
 <td><small>SILC_COMMAND_KILL</td>
 <td><small>
-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.
 </td>
-<td width="50%"><small>none
+<td width="50%"><small>SilcClientEntry client_entry
 </td>
 </tr>
 
@@ -297,9 +298,10 @@ SilcClientEntry target_client
 <tr>
 <td><small>SILC_COMMAND_KICK</td>
 <td><small>
-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.
 </td>
-<td width="50%"><small>none
+<td width="50%"><small>SilcChannelEntry channel, SilcClientEntry client_entry
 </td>
 </tr>
 
index fb90b2707ec5bbc4a882ae527ccf394cfb21427c..df78d5aea86e92a9a8d7490ceed4ba82c25c28f8 100644 (file)
@@ -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;
     }
index 75cd26c7f779de4fa4c70b071fcc21bf9ad0a563..bcfa8ea5ca9f40520c03a9f8b5f4a0fa32fcf5b3 100644 (file)
@@ -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
  *