if (!client || !conn || !nickname)
return NULL;
+ SILC_LOG_DEBUG(("Find clients by nickname %s", nickname));
+
/* Normalize nickname for search */
nicknamec = silc_identifier_check(nickname, strlen(nickname),
SILC_STRING_UTF8, 128, NULL);
if (!nicknamec)
- silc_free(nicknamec);
return NULL;
clients = silc_dlist_init();
silc_mutex_lock(conn->internal->lock);
/* Find from cache */
+ silc_list_init(list, struct SilcIDCacheEntryStruct, next);
if (!silc_idcache_find_by_name(conn->internal->client_cache, nicknamec,
&list)) {
silc_mutex_unlock(conn->internal->lock);
void *context)
{
SilcClientGetChannelInternal i;
- SilcChannelEntry channel;
SilcBuffer idp;
SilcUInt16 cmd_ident;
if (!cmd_ident && completion)
completion(client, conn, SILC_STATUS_ERR_RESOURCE_LIMIT, NULL, context);
- silc_client_unref_channel(client, conn, channel);
-
return cmd_ident;
}
SilcClientCommandContext cmd = fsm_context;
SilcClientConnection conn = cmd->conn;
- if (cmd->argc < 2) {
- COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- return SILC_FSM_FINISH;
- }
-
/* Send the command */
silc_client_command_send_va(conn, cmd, cmd->cmd, NULL, NULL, 1,
1, silc_buffer_datalen(conn->internal->
/* Check whether user requested server */
server_entry = silc_client_get_server(client, conn, cmd->argv[1]);
if (!server_entry) {
+ if (cmd->resolved) {
+ /* Resolving didn't find anything. We should never get here as
+ errors are handled in the resolving callback. */
+ COMMAND_ERROR(SILC_STATUS_ERR_NO_SUCH_NICK);
+ COMMAND_ERROR(SILC_STATUS_ERR_NO_SUCH_SERVER);
+ return SILC_FSM_FINISH;
+ }
+
/* No client or server exist with this name, query for both. */
+ cmd->resolved = TRUE;
SILC_FSM_CALL(silc_client_command_send(client, conn,
SILC_COMMAND_IDENTIFY,
silc_client_command_continue,
strlen(cmd->argv[1]),
2, cmd->argv[1],
strlen(cmd->argv[1])));
+ /* NOT REACHED */
}
idp = silc_id_payload_encode(&server_entry->id, SILC_ID_SERVER);
} else {
msg "%s", silc_get_status_message(cmd->error)); \
ERROR_CALLBACK(cmd->error); \
silc_client_command_process_error(cmd, state_context, cmd->error); \
- silc_fsm_next(fsm, silc_client_command_reply_process); \
+ silc_fsm_next(fsm, silc_client_command_reply_processed); \
return SILC_FSM_CONTINUE; \
}
if (silc_argument_get_arg_num(args) < min || \
silc_argument_get_arg_num(args) > max) { \
ERROR_CALLBACK(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS); \
- silc_fsm_next(fsm, silc_client_command_reply_process); \
+ silc_fsm_next(fsm, silc_client_command_reply_processed); \
return SILC_FSM_CONTINUE; \
}
silc_mutex_unlock(conn->internal->lock);
if (!cmd) {
- SILC_LOG_DEBUG(("Unknown command reply"));
+ SILC_LOG_DEBUG(("Unknown command reply %s, ident %d",
+ silc_get_command_name(command), cmd_ident));
silc_command_payload_free(payload);
return SILC_FSM_FINISH;
}
ERROR_CALLBACK(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
goto out;
}
+ silc_client_ref_server(client, conn, server_entry);
} else {
silc_client_update_server(client, conn, server_entry, name, info);
}
/* Notify application */
silc_client_command_callback(cmd, server_entry, name, info);
+ silc_client_unref_server(client, conn, server_entry);
break;
case SILC_ID_CHANNEL:
ERROR_CALLBACK(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
goto out;
}
+ silc_client_ref_channel(client, conn, channel_entry);
}
/* Notify application */
silc_client_command_callback(cmd, channel_entry, name, info);
+ silc_client_unref_channel(client, conn, channel_entry);
break;
}
SilcArgumentPayload args = silc_command_get_args(payload);
unsigned char *tmp, *name, *topic;
SilcUInt32 usercount = 0;
- SilcChannelEntry channel_entry;
+ SilcChannelEntry channel_entry = NULL;
SilcID id;
/* Sanity checks */
ERROR_CALLBACK(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
goto out;
}
+ silc_client_ref_channel(client, conn, channel_entry);
}
/* Notify application */
silc_client_command_callback(cmd, channel_entry, name, topic, usercount);
out:
+ silc_client_unref_channel(client, conn, channel_entry);
silc_fsm_next(fsm, silc_client_command_reply_processed);
return SILC_FSM_CONTINUE;
}