+ SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
+ 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, 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, 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, channel, mode));
+ silc_free(channel_id);
+
+ /* Execute any pending command callbacks */
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CMODE);
+
+ out:
+ SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_CMODE);
+ silc_client_command_reply_free(cmd);
+}
+
+/* Received reply for CUMODE command */
+
+SILC_CLIENT_CMD_REPLY_FUNC(cumode)
+{
+ SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
+ SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
+ 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, 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, SILC_CLIENT_MESSAGE_ERROR,
+ "%s", silc_client_command_status_message(status));
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
+ /* Get channel mode */
+ tmp = silc_argument_get_arg_type(cmd->args, 2, NULL);
+ if (!tmp) {
+ COMMAND_REPLY_ERROR;
+ 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, 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;
+ }
+
+ /* Get client entry */
+ if (!silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)client_id,
+ 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, 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);
+
+ out:
+ SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_CUMODE);
+ silc_client_command_reply_free(cmd);