Merged from silc_1_0_branch.
[silc.git] / lib / silcclient / command_reply.c
index 7d703787709a5f744b545dfab1386efc3e223a24..0ae2890bf8c233eee94188c01c2014e99e75a909 100644 (file)
@@ -721,6 +721,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(invite)
   SilcChannelID *channel_id;
   unsigned char *tmp;
   SilcUInt32 len;
+  SilcBufferStruct buf;
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
@@ -748,9 +749,11 @@ SILC_CLIENT_CMD_REPLY_FUNC(invite)
 
   /* Get the invite list */
   tmp = silc_argument_get_arg_type(cmd->args, 3, &len);
-
+  if (tmp)
+    silc_buffer_set(&buf, tmp, len);
+  
   /* Notify application */
-  COMMAND_REPLY((SILC_ARGS, channel, tmp));
+  COMMAND_REPLY((SILC_ARGS, channel, tmp ? &buf : NULL));
 
  out:
   SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_INVITE);
@@ -1461,6 +1464,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(ban)
   SilcChannelID *channel_id;
   unsigned char *tmp;
   SilcUInt32 len;
+  SilcBufferStruct buf;
 
   if (cmd->error != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
@@ -1488,9 +1492,11 @@ SILC_CLIENT_CMD_REPLY_FUNC(ban)
   
   /* Get the ban list */
   tmp = silc_argument_get_arg_type(cmd->args, 3, &len);
-
+  if (tmp)
+    silc_buffer_set(&buf, tmp, len);
+  
   /* Notify application */
-  COMMAND_REPLY((SILC_ARGS, channel, tmp));
+  COMMAND_REPLY((SILC_ARGS, channel, tmp ? &buf : NULL));
 
  out:
   SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_BAN);
@@ -1738,6 +1744,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(users)
 {
   SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
   SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
+  SilcClientCommandReplyContext r = (SilcClientCommandReplyContext)context2;
 
   SILC_LOG_DEBUG(("Start"));
 
@@ -1748,6 +1755,13 @@ SILC_CLIENT_CMD_REPLY_FUNC(users)
     goto out;
   }
 
+  if (r && !silc_command_get_status(r->payload, NULL, &cmd->error)) {
+    SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+       "%s", silc_get_status_message(cmd->error));
+    COMMAND_REPLY_ERROR;
+    goto out;
+  }
+
   if (silc_client_command_reply_users_save(cmd, cmd->status, TRUE,
                                           silc_client_command_reply_users_cb,
                                           silc_client_command_reply_users))
@@ -1812,6 +1826,14 @@ SILC_CLIENT_CMD_REPLY_FUNC(getkey)
       goto out;
     }
 
+    /* Save fingerprint */
+    if (!client_entry->fingerprint) {
+      client_entry->fingerprint = silc_calloc(20, sizeof(unsigned char));
+      client_entry->fingerprint_len = 20;
+      silc_hash_make(cmd->client->sha1hash, tmp + 4, len - 4,
+                    client_entry->fingerprint);
+    }
+
     /* Notify application */
     COMMAND_REPLY((SILC_ARGS, id_type, client_entry, public_key));
   } else if (id_type == SILC_ID_SERVER) {