+ SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
+ SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
+ SilcCommandStatus status;
+ unsigned char *tmp;
+ uint32 mode;
+ 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) {
+ 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 */
+ channel = silc_client_get_channel_by_id(cmd->client, conn, channel_id);
+ if (!channel) {
+ silc_free(channel_id);
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
+ /* 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);
+
+ out:
+ SILC_CLIENT_PENDING_EXEC(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;
+ SilcClientID *client_id;
+ SilcChannelID *channel_id;
+ SilcClientEntry client_entry;
+ SilcChannelEntry channel;
+ SilcChannelUser chu;
+ unsigned char *modev, *tmp, *id;
+ uint32 len, mode;
+
+ SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
+ if (status != SILC_STATUS_OK) {
+ SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+ "%s", silc_client_command_status_message(status));
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
+ /* Get channel mode */
+ modev = silc_argument_get_arg_type(cmd->args, 2, NULL);
+ if (!modev) {
+ 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 */
+ channel = silc_client_get_channel_by_id(cmd->client, conn, channel_id);
+ if (!channel) {
+ silc_free(channel_id);
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
+ /* 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 */
+ client_entry = silc_client_get_client_by_id(cmd->client, conn, client_id);
+ if (!client_entry) {
+ silc_free(channel_id);
+ silc_free(client_id);
+ COMMAND_REPLY_ERROR;
+ goto out;
+ }
+
+ /* Save the mode */
+ SILC_GET32_MSB(mode, modev);
+ chu = silc_client_on_channel(channel, client_entry);
+ if (chu)
+ chu->mode = mode;
+
+ /* Notify application */
+ COMMAND_REPLY((ARGS, mode, channel, client_entry));
+ silc_free(client_id);
+ silc_free(channel_id);
+
+ out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CUMODE);
+ silc_client_command_reply_free(cmd);