void silc_client_command_pending(SilcClientConnection conn,
SilcCommand reply_cmd,
uint16 ident,
- SilcClientPendingDestructor destructor,
SilcCommandCb callback,
void *context)
{
reply->ident = ident;
reply->context = context;
reply->callback = callback;
- reply->destructor = destructor;
silc_dlist_add(conn->pending_commands, reply);
}
if (r->reply_cmd == command && r->ident == ident) {
ctx->context = r->context;
ctx->callback = r->callback;
- ctx->destructor = r->destructor;
ctx->ident = ident;
return TRUE;
}
return ctx;
}
-/* Pending command destructor. */
-
-static void silc_client_command_destructor(void *context)
-{
- silc_client_command_free((SilcClientCommandContext)context);
-}
-
/* Command WHOIS. This command is used to query information about
specific user. */
if there were no errors returned by the server. */
silc_client_command_pending(conn, SILC_COMMAND_NICK,
cmd->conn->cmd_ident,
- silc_client_command_destructor,
silc_client_command_nick_change,
silc_client_command_dup(cmd));
cmd->pending = TRUE;
- return;
out:
silc_client_command_free(cmd);
pending command. */
silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY,
conn->cmd_ident,
- silc_client_command_destructor,
silc_client_command_invite,
silc_client_command_dup(cmd));
cmd->pending = 1;
- return;
+ goto out;
}
} else {
invite = cmd->argv[2];
pending command. */
silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY,
conn->cmd_ident,
- silc_client_command_destructor,
silc_client_command_kill,
silc_client_command_dup(cmd));
cmd->pending = 1;
- return;
+ goto out;
}
/* Send the KILL command to the server */
/* Register a pending callback that will actually remove the killed
client from our cache. */
silc_client_command_pending(conn, SILC_COMMAND_KILL, conn->cmd_ident,
- NULL, silc_client_command_kill_remove,
+ silc_client_command_kill_remove,
silc_client_command_dup(cmd));
out:
pending command. */
silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY,
conn->cmd_ident,
- silc_client_command_destructor,
silc_client_command_cumode,
silc_client_command_dup(cmd));
cmd->pending = 1;
- return;
+ goto out;
}
/* Get the current mode */
char *nickname = NULL;
SilcBuffer idp, buffer;
+ SILC_LOG_DEBUG(("Start"));
+
if (!cmd->conn) {
SILC_NOT_CONNECTED(cmd->client, cmd->conn);
COMMAND_ERROR;
goto out;
}
- if (cmd->pending) {
- SilcClientCommandReplyContext reply =
- (SilcClientCommandReplyContext)context2;
- SilcCommandStatus status;
- unsigned char *tmp = silc_argument_get_arg_type(reply->args, 1, NULL);
- SILC_GET16_MSB(status, tmp);
-
- if (status == SILC_STATUS_ERR_NO_SUCH_NICK ||
- status == SILC_STATUS_ERR_NO_SUCH_SERVER) {
- SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s",
- silc_client_command_status_message(status));
- COMMAND_ERROR;
- goto out;
- }
- }
-
/* Parse the typed nickname. */
if (client->internal->params->nickname_parse)
client->internal->params->nickname_parse(cmd->argv[1], &nickname);
server_entry = silc_client_get_server(client, conn, cmd->argv[1]);
if (!server_entry) {
- if (cmd->pending) {
+ /* No. what ever user wants we don't have it, so resolve it. We
+ will first try to resolve the client, and if that fails then
+ we'll try to resolve the server. */
+
+ if (!cmd->pending) {
+ /* This will send the IDENTIFY command for nickname */
+ silc_idlist_get_client(client, conn, nickname, cmd->argv[1], TRUE);
+ silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY,
+ conn->cmd_ident,
+ silc_client_command_getkey,
+ silc_client_command_dup(cmd));
+ cmd->pending = 1;
+ goto out;
+ } else {
+ SilcClientCommandReplyContext reply =
+ (SilcClientCommandReplyContext)context2;
+ SilcCommandStatus status;
+ unsigned char *tmp = silc_argument_get_arg_type(reply->args, 1, NULL);
+ SILC_GET16_MSB(status, tmp);
+
+ /* If nickname was not found, then resolve the server. */
+ if (status == SILC_STATUS_ERR_NO_SUCH_NICK) {
+ /* This sends the IDENTIFY command to resolve the server. */
+ silc_client_command_register(client, SILC_COMMAND_IDENTIFY,
+ NULL, NULL,
+ silc_client_command_reply_identify_i, 0,
+ ++conn->cmd_ident);
+ silc_client_command_send(client, conn, SILC_COMMAND_IDENTIFY,
+ conn->cmd_ident, 1,
+ 2, cmd->argv[1], cmd->argv_lens[1]);
+ silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY,
+ conn->cmd_ident,
+ silc_client_command_getkey,
+ silc_client_command_dup(cmd));
+ goto out;
+ }
+
+ /* If server was not found, then we've resolved both nickname and
+ server and did not find anybody. */
+ if (status == SILC_STATUS_ERR_NO_SUCH_SERVER) {
+ SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s",
+ silc_client_command_status_message(SILC_STATUS_ERR_NO_SUCH_NICK));
+ SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s",
+ silc_client_command_status_message(status));
+ COMMAND_ERROR;
+ goto out;
+ }
+
COMMAND_ERROR;
goto out;
}
-
- /* No. what ever user wants we don't have it, so resolve it. We
- will try to resolve both client and server, one of them is
- bound to be wrong. */
-
- /* This will send the IDENTIFY command */
- silc_idlist_get_client(client, conn, nickname, cmd->argv[1], TRUE);
- silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY,
- conn->cmd_ident,
- silc_client_command_destructor,
- silc_client_command_getkey,
- silc_client_command_dup(cmd));
-
- /* This sends the IDENTIFY command to resolve the server. */
- silc_client_command_register(client, SILC_COMMAND_IDENTIFY, NULL, NULL,
- silc_client_command_reply_identify_i, 0,
- ++conn->cmd_ident);
- silc_client_command_send(client, conn, SILC_COMMAND_IDENTIFY,
- conn->cmd_ident, 1,
- 2, cmd->argv[1], cmd->argv_lens[1]);
- silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY,
- conn->cmd_ident, NULL,
- silc_client_command_getkey,
- silc_client_command_dup(cmd));
-
- cmd->pending = 1;
- silc_free(nickname);
- return;
}
idp = silc_id_payload_encode(server_entry->server_id, SILC_ID_SERVER);