/* $Id$ */
#include "clientlibincludes.h"
+#include "client_internal.h"
/* Client command list. */
SilcClientCommand silc_command_list[] =
SILC_CLIENT_CMD(ping, PING, "PING", SILC_CF_LAG | SILC_CF_REG, 2),
SILC_CLIENT_CMD(oper, OPER, "OPER",
SILC_CF_LAG | SILC_CF_REG | SILC_CF_OPER, 2),
- SILC_CLIENT_CMD(join, JOIN, "JOIN", SILC_CF_LAG | SILC_CF_REG, 4),
+ SILC_CLIENT_CMD(join, JOIN, "JOIN", SILC_CF_LAG | SILC_CF_REG, 5),
SILC_CLIENT_CMD(motd, MOTD, "MOTD", SILC_CF_LAG | SILC_CF_REG, 2),
SILC_CLIENT_CMD(umode, UMODE, "UMODE", SILC_CF_LAG | SILC_CF_REG, 2),
SILC_CLIENT_CMD(cmode, CMODE, "CMODE", SILC_CF_LAG | SILC_CF_REG, 4),
cmd, FALSE, cmd->command->cmd)
/* Generic function to send any command. The arguments must be sent already
- encoded into correct form in correct order. */
+ encoded into correct form and in correct order. */
void silc_client_send_command(SilcClient client, SilcClientConnection conn,
SilcCommand command, unsigned short ident,
/* Duplicate Command Context by adding reference counter. The context won't
be free'd untill it hits zero. */
-SilcClientCommandContext
-silc_client_command_dup(SilcClientCommandContext ctx)
+SilcClientCommandContext silc_client_command_dup(SilcClientCommandContext ctx)
{
ctx->users++;
SILC_LOG_DEBUG(("Command context %p refcnt %d->%d", ctx, ctx->users - 1,
silc_client_command_free((SilcClientCommandContext)context);
}
+/* silc_client_get_client completion callback */
+void silc_client_command_completion(SilcClient client,
+ SilcClientConnection conn,
+ SilcClientEntry clients,
+ unsigned int clients_count,
+ void *context)
+{
+
+}
+
/* Command WHOIS. This command is used to query information about
specific user. */
silc_client_command_free(cmd);
}
+/* Command WHOWAS. This command is used to query history information about
+ specific user that used to exist in the network. */
+
SILC_CLIENT_CMD_FUNC(whowas)
{
+ SilcClientCommandContext cmd = (SilcClientCommandContext)context;
+ SilcClientConnection conn = cmd->conn;
+ SilcBuffer buffer;
+
+ if (!cmd->conn) {
+ SILC_NOT_CONNECTED(cmd->client, cmd->conn);
+ COMMAND_ERROR;
+ goto out;
+ }
+
+ if (cmd->argc < 2 || cmd->argc > 3) {
+ cmd->client->ops->say(cmd->client, conn,
+ "Usage: /WHOWAS <nickname>[@<server>] [<count>]");
+ COMMAND_ERROR;
+ goto out;
+ }
+
+ buffer = silc_command_payload_encode(SILC_COMMAND_WHOWAS,
+ cmd->argc - 1, ++cmd->argv,
+ ++cmd->argv_lens, ++cmd->argv_types,
+ 0);
+ silc_client_packet_send(cmd->client, cmd->conn->sock,
+ SILC_PACKET_COMMAND, NULL, 0, NULL, NULL,
+ buffer->data, buffer->len, TRUE);
+ silc_buffer_free(buffer);
+ cmd->argv--;
+ cmd->argv_lens--;
+ cmd->argv_types--;
+
+ /* Notify application */
+ COMMAND;
+
+ out:
+ silc_client_command_free(cmd);
}
/* Command IDENTIFY. This command is used to query information about
buffer = silc_command_payload_encode(SILC_COMMAND_NICK,
cmd->argc - 1, ++cmd->argv,
++cmd->argv_lens, ++cmd->argv_types,
- 0);
+ ++cmd->conn->cmd_ident);
silc_client_packet_send(cmd->client, cmd->conn->sock,
SILC_PACKET_COMMAND, NULL, 0, NULL, NULL,
buffer->data, buffer->len, TRUE);
}
/* Find channel entry */
- channel_entry = silc_idlist_get_channel(client, conn, cmd->argv[2]);
+ channel_entry = silc_client_get_channel(client, conn, cmd->argv[2]);
if (!channel_entry) {
cmd->client->ops->say(cmd->client, conn, "You are not on that channel");
COMMAND_ERROR;
/* Close connection */
q->client->ops->disconnect(q->client, q->conn);
- silc_client_close_connection(q->client, q->conn->sock);
+ silc_client_close_connection(q->client, q->conn->sock->user_data);
silc_free(q);
}
} else {
name = cmd->argv[1];
- channel = silc_idlist_get_channel(cmd->client, conn, name);
+ channel = silc_client_get_channel(cmd->client, conn, name);
if (!channel) {
cmd->client->ops->say(cmd->client, conn, "You are on that channel");
COMMAND_ERROR;
} else {
name = cmd->argv[1];
- channel = silc_idlist_get_channel(cmd->client, conn, name);
+ channel = silc_client_get_channel(cmd->client, conn, name);
if (!channel) {
cmd->client->ops->say(cmd->client, conn, "You are on that channel");
COMMAND_ERROR;