Preparations for Requested Attributes support.
[silc.git] / apps / silcd / command_reply.c
index ecf6f3c22ff8614c6801093b7cee17d2ed9cc8c6..55d62bb5921a59b8ca4e93471e23147387df0040 100644 (file)
@@ -66,7 +66,6 @@ void silc_server_command_reply_process(SilcServer server,
   SilcServerCommandReplyContext ctx;
   SilcCommandPayload payload;
   SilcCommand command;
-  SilcUInt16 ident;
 
   SILC_LOG_DEBUG(("Start"));
 
@@ -85,13 +84,12 @@ void silc_server_command_reply_process(SilcServer server,
   ctx->sock = silc_socket_dup(sock);
   ctx->payload = payload;
   ctx->args = silc_command_get_args(ctx->payload);
-  ident = silc_command_get_ident(ctx->payload);
+  ctx->ident = silc_command_get_ident(ctx->payload);
       
   /* Check for pending commands and mark to be exeucted */
   ctx->callbacks = 
-    silc_server_command_pending_check(server, ctx, 
-                                     silc_command_get(ctx->payload), 
-                                     ident, &ctx->callbacks_count);
+    silc_server_command_pending_check(server, silc_command_get(ctx->payload), 
+                                     ctx->ident, &ctx->callbacks_count);
 
   /* Execute command reply */
   command = silc_command_get(ctx->payload);
@@ -282,6 +280,13 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
   if (fingerprint && flen == sizeof(client->data.fingerprint))
     memcpy(client->data.fingerprint, fingerprint, flen);
 
+  /* Take Requested Attributes if set. */
+  tmp = silc_argument_get_arg_type(cmd->args, 11, &len);
+  if (tmp) {
+    silc_free(client->attrs);
+    client->attrs = silc_memdup(tmp, len);
+  }
+
   return TRUE;
 }
 
@@ -378,6 +383,8 @@ silc_server_command_reply_whowas_save(SilcServerCommandReplyContext cmd)
       return FALSE;
     }
 
+    client->data.status |= SILC_IDLIST_STATUS_RESOLVED;
+    client->data.status &= ~SILC_IDLIST_STATUS_RESOLVING;
     client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED; 
     client->servername = servername;
   } else {
@@ -388,10 +395,13 @@ silc_server_command_reply_whowas_save(SilcServerCommandReplyContext cmd)
 
     silc_free(client->nickname);
     silc_free(client->username);
+    silc_free(client->servername);
     
     client->nickname = nick;
     client->username = strdup(username);
     client->servername = servername;
+    client->data.status |= SILC_IDLIST_STATUS_RESOLVED;
+    client->data.status &= ~SILC_IDLIST_STATUS_RESOLVING;
 
     /* Remove the old cache entry and create a new one */
     silc_idcache_del_by_context(global ? server->global_list->clients :
@@ -438,8 +448,13 @@ SILC_SERVER_CMD_REPLY_FUNC(whowas)
   }
 
  out:
+  silc_server_command_process_error(cmd, error);
   SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_WHOWAS);
+  silc_server_command_reply_free(cmd);
+  return;
+
  err:
+  silc_server_command_process_error(cmd, error);
   silc_server_command_reply_free(cmd);
 }