SilcClientConnection conn,
char *nickname,
char *server,
- unsigned int num)
+ unsigned int num,
+ int query)
{
SilcIDCacheEntry id_cache;
SilcIDCacheList list = NULL;
/* Find ID from cache */
if (!silc_idcache_find_by_data_loose(conn->client_cache, nickname, &list)) {
- SilcClientCommandContext ctx;
- char ident[512];
-
identify:
- SILC_LOG_DEBUG(("Requesting Client ID from server"));
-
- /* No ID found. Do query from the server. The query is done by
- sending simple IDENTIFY command to the server. */
- ctx = silc_calloc(1, sizeof(*ctx));
- ctx->client = client;
- ctx->conn = conn;
- ctx->command = silc_client_command_find("IDENTIFY");
- memset(ident, 0, sizeof(ident));
- snprintf(ident, sizeof(ident), "IDENTIFY %s", nickname);
- silc_parse_command_line(ident, &ctx->argv, &ctx->argv_lens,
- &ctx->argv_types, &ctx->argc, 2);
- ctx->command->cb(ctx);
-
- if (list)
- silc_idcache_list_free(list);
-
+ if (query) {
+ SilcClientCommandContext ctx;
+ char ident[512];
+
+ SILC_LOG_DEBUG(("Requesting Client ID from server"));
+
+ /* No ID found. Do query from the server. The query is done by
+ sending simple IDENTIFY command to the server. */
+ ctx = silc_client_command_alloc();
+ ctx->client = client;
+ ctx->conn = conn;
+ ctx->command = silc_client_command_find("IDENTIFY");
+ memset(ident, 0, sizeof(ident));
+ snprintf(ident, sizeof(ident), "IDENTIFY %s", nickname);
+ silc_parse_command_line(ident, &ctx->argv, &ctx->argv_lens,
+ &ctx->argv_types, &ctx->argc, 2);
+ ctx->command->cb(ctx);
+
+ if (list)
+ silc_idcache_list_free(list);
+
+ return NULL;
+ }
return NULL;
}
return entry;
}
-/* Finds client entry from cache by Client ID. If the entry is not found
- from the cache this function can query it from the server. */
+/* Finds client entry from cache by Client ID. */
SilcClientEntry silc_idlist_get_client_by_id(SilcClient client,
SilcClientConnection conn,
- SilcClientID *client_id,
- int query)
+ SilcClientID *client_id)
{
SilcIDCacheEntry id_cache;
/* Find ID from cache */
if (!silc_idcache_find_by_id_one(conn->client_cache, client_id,
- SILC_ID_CLIENT, &id_cache)) {
- if (!query) {
- return NULL;
- } else {
- SilcBuffer idp = silc_id_payload_encode(client_id, SILC_ID_CLIENT);
- silc_client_send_command(client, conn, SILC_COMMAND_WHOIS, 1,
- 3, idp->data, idp->len);
- return NULL;
- }
- }
+ SILC_ID_CLIENT, &id_cache))
+ return NULL;
+
+ SILC_LOG_DEBUG(("Found"));
return (SilcClientEntry)id_cache->context;
}