{ STAT(NO_SERVER_ID), "No Server ID given" },
{ STAT(BAD_CLIENT_ID), "Bad Client ID" },
{ STAT(BAD_CHANNEL_ID), "Bad Channel ID" },
- { STAT(NO_SUCH_CLIENT_ID), "No such Client ID" },
- { STAT(NO_SUCH_CHANNEL_ID),"No such Channel ID" },
+ { STAT(NO_SUCH_CLIENT_ID), "There was no such client" },
+ { STAT(NO_SUCH_CHANNEL_ID),"There was no such channel" },
{ STAT(NICKNAME_IN_USE), "Nickname already exists" },
{ STAT(NOT_ON_CHANNEL), "You are not on that channel" },
{ STAT(USER_NOT_ON_CHANNEL),"They are not on the channel" },
return;
}
- cmd->cb(ctx);
+ cmd->cb(ctx, NULL);
}
/* Returns status message string */
SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn, "Cannot set nickname: %s",
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+ "Cannot set nickname: %s",
silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
argc = silc_argument_get_arg_num(cmd->args);
if (argc < 2 || argc > 2) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Cannot set nickname: bad reply to command");
COMMAND_REPLY_ERROR;
goto out;
SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_TOPIC);
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_INVITE);
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
{
SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
- SilcClient client = cmd->client;
SilcCommandStatus status;
unsigned char *tmp;
+ SilcIDCacheEntry id_cache;
+ SilcServerEntry server;
+ SilcServerID *server_id = NULL;
+ char *server_name, *server_info;
+ uint32 len;
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_INFO);
}
/* Get server ID */
- tmp = silc_argument_get_arg_type(cmd->args, 2, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
if (!tmp)
goto out;
- /* XXX save server id */
+ server_id = silc_id_payload_parse_id(tmp, len);
+ if (!server_id)
+ goto out;
/* Get server name */
- tmp = silc_argument_get_arg_type(cmd->args, 3, NULL);
- if (!tmp)
+ server_name = silc_argument_get_arg_type(cmd->args, 3, NULL);
+ if (!server_name)
goto out;
/* Get server info */
- tmp = silc_argument_get_arg_type(cmd->args, 4, NULL);
- if (!tmp)
+ server_info = silc_argument_get_arg_type(cmd->args, 4, NULL);
+ if (!server_info)
goto out;
- client->ops->say(cmd->client, conn, "Info: %s", tmp);
+ /* See whether we have this server cached. If not create it. */
+ if (!silc_idcache_find_by_id_one(conn->server_cache, (void *)server_id,
+ &id_cache)) {
+ SILC_LOG_DEBUG(("New server entry"));
+
+ server = silc_calloc(1, sizeof(*server));
+ server->server_name = strdup(server_name);
+ server->server_info = strdup(server_info);
+ server->server_id = silc_id_dup(server_id, SILC_ID_SERVER);
+ /* Add it to the cache */
+ silc_idcache_add(conn->server_cache, server->server_name,
+ server->server_id, (void *)server, FALSE);
+ } else {
+ server = (SilcServerEntry)id_cache->context;
+ }
+
/* Notify application */
- COMMAND_REPLY((ARGS, NULL, (char *)tmp));
+ COMMAND_REPLY((ARGS, server, server->server_name, server->server_info));
/* Execute any pending command callbacks */
SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_INFO);
out:
+ if (server_id)
+ silc_free(server_id);
SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_INFO);
silc_client_command_reply_free(cmd);
}
SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
for (i = 0; i < conn->ping_count; i++) {
if (SILC_ID_SERVER_COMPARE(conn->ping[i].dest_id, id)) {
diff = curtime - conn->ping[i].start_time;
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO,
"Ping reply from %s: %d second%s",
conn->ping[i].dest_name, diff,
diff == 1 ? "" : "s");
SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
argc = silc_argument_get_arg_num(cmd->args);
if (argc < 7 || argc > 14) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Cannot join channel: Bad reply packet");
COMMAND_REPLY_ERROR;
goto out;
/* Get channel name */
tmp = silc_argument_get_arg_type(cmd->args, 2, NULL);
if (!tmp) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Cannot join channel: Bad reply packet");
COMMAND_REPLY_ERROR;
goto out;
/* Get Channel ID */
tmp = silc_argument_get_arg_type(cmd->args, 3, &len);
if (!tmp) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Cannot join channel: Bad reply packet");
COMMAND_REPLY_ERROR;
silc_free(channel_name);
hmac = silc_argument_get_arg_type(cmd->args, 11, NULL);
if (hmac) {
if (!silc_hmac_alloc(hmac, NULL, &channel->hmac)) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Cannot join channel: Unsupported HMAC `%s'",
hmac);
COMMAND_REPLY_ERROR;
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
return;
if (i == 2)
line[0] = ' ';
- cmd->client->ops->say(cmd->client, conn, "%s", line);
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO,
+ "%s", line);
if (!strlen(cp))
break;
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
SilcCommandStatus status;
unsigned char *tmp;
+ uint32 mode;
+ SilcIDCacheEntry id_cache;
+ SilcChannelID *channel_id;
+ SilcChannelEntry channel;
+ uint32 len;
SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
}
+ /* Take Channel ID */
+ tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
+ if (!tmp)
+ goto out;
+ channel_id = silc_id_payload_parse_id(tmp, len);
+ if (!channel_id)
+ goto out;
+
+ /* Get the channel entry */
+ if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
+ &id_cache)) {
+ silc_free(channel_id);
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
+ channel = (SilcChannelEntry)id_cache->context;
+
/* Get channel mode */
- tmp = silc_argument_get_arg_type(cmd->args, 2, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 3, NULL);
if (!tmp) {
+ silc_free(channel_id);
COMMAND_REPLY_ERROR;
goto out;
}
+ /* Save the mode */
+ SILC_GET32_MSB(mode, tmp);
+ channel->mode = mode;
+
/* Notify application */
- COMMAND_REPLY((ARGS, tmp));
+ COMMAND_REPLY((ARGS, channel, mode));
+ silc_free(channel_id);
/* Execute any pending command callbacks */
SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CMODE);
SilcCommandStatus status;
SilcIDCacheEntry id_cache = NULL;
SilcClientID *client_id;
+ SilcChannelID *channel_id;
+ SilcClientEntry client_entry;
+ SilcChannelEntry channel;
+ SilcChannelUser chu;
unsigned char *tmp, *id;
- uint32 len;
+ uint32 len, mode;
SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
goto out;
}
+ /* Take Channel ID */
+ tmp = silc_argument_get_arg_type(cmd->args, 3, &len);
+ if (!tmp)
+ goto out;
+ channel_id = silc_id_payload_parse_id(tmp, len);
+ if (!channel_id)
+ goto out;
+
+ /* Get the channel entry */
+ if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
+ &id_cache)) {
+ silc_free(channel_id);
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
+ channel = (SilcChannelEntry)id_cache->context;
+
/* Get Client ID */
- id = silc_argument_get_arg_type(cmd->args, 3, &len);
+ id = silc_argument_get_arg_type(cmd->args, 4, &len);
if (!id) {
+ silc_free(channel_id);
COMMAND_REPLY_ERROR;
goto out;
}
client_id = silc_id_payload_parse_id(id, len);
if (!client_id) {
+ silc_free(channel_id);
COMMAND_REPLY_ERROR;
goto out;
}
NULL, NULL,
silc_hash_client_id_compare, NULL,
&id_cache)) {
+ silc_free(channel_id);
+ silc_free(client_id);
COMMAND_REPLY_ERROR;
goto out;
}
+ client_entry = (SilcClientEntry)id_cache->context;
+
+ /* Save the mode */
+ SILC_GET32_MSB(mode, tmp);
+ while ((chu = silc_list_get(channel->clients)) != SILC_LIST_END) {
+ if (chu->client == client_entry) {
+ chu->mode = mode;
+ break;
+ }
+ }
+
/* Notify application */
- COMMAND_REPLY((ARGS, tmp, (SilcClientEntry)id_cache->context));
+ COMMAND_REPLY((ARGS, mode, channel, client_entry));
silc_free(client_id);
+ silc_free(channel_id);
/* Execute any pending command callbacks */
SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CUMODE);
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;
tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
- cmd->client->ops->say(cmd->client, conn,
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
"%s", silc_client_command_status_message(status));
COMMAND_REPLY_ERROR;
goto out;