Merge commit 'origin/silc.1.1.branch'
[silc.git] / lib / silcclient / command_reply.c
index 29e05e73fe086b419299d922f1e196da594b2cfa..ede887535fdcdc97b6219d0c8d73f11b45867021 100644 (file)
@@ -1113,6 +1113,29 @@ silc_client_command_reply_join_resolved(SilcClient client,
 {
   SilcClientCommandContext cmd = context;
   SilcChannelEntry channel = cmd->context;
+  SilcCommandPayload payload = silc_fsm_get_state_context(&cmd->thread);
+  SilcArgumentPayload args = silc_command_get_args(payload);
+  SilcUInt32 list_count;
+  unsigned char *tmp;
+  char msg[512];
+
+  if (!clients) {
+    silc_snprintf(msg, sizeof(msg), "Error resolving channel %s user list",
+                 channel->channel_name);
+    SAY(client, conn, SILC_CLIENT_MESSAGE_COMMAND_ERROR, msg);
+  } else {
+    tmp = silc_argument_get_arg_type(args, 12, NULL);
+    if (tmp) {
+      SILC_GET32_MSB(list_count, tmp);
+      if (list_count - silc_dlist_count(clients) > 5) {
+       silc_snprintf(msg, sizeof(msg),
+                     "Channel %s user list was not fully resolved. "
+                     "The channel may not be fully synced.",
+                     channel->channel_name);
+       SAY(client, conn, SILC_CLIENT_MESSAGE_WARNING, msg);
+      }
+    }
+  }
 
   channel->internal.resolve_cmd_ident = 0;
   silc_client_unref_channel(client, conn, channel);
@@ -1174,7 +1197,7 @@ SILC_FSM_STATE(silc_client_command_reply_join)
 
   /* Get the list count */
   tmp = silc_argument_get_arg_type(args, 12, &len);
-  if (!tmp) {
+  if (!tmp || len != 4) {
     ERROR_CALLBACK(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
     goto out;
   }
@@ -1212,7 +1235,6 @@ SILC_FSM_STATE(silc_client_command_reply_join)
   /* Add clients we received in the reply to the channel */
   for (i = 0; i < list_count; i++) {
     SilcUInt16 idp_len;
-    SilcUInt32 mode;
     SilcID id;
     SilcClientEntry client_entry;
 
@@ -1489,6 +1511,20 @@ SILC_FSM_STATE(silc_client_command_reply_cmode)
   silc_client_command_callback(cmd, channel, mode, public_key,
                               channel->channel_pubkeys, channel->user_limit);
 
+  silc_rwlock_wrlock(channel->internal.lock);
+
+  /* If founder key changed, update it */
+  if (public_key &&
+      (!channel->founder_key ||
+       !silc_pkcs_public_key_compare(public_key, channel->founder_key))) {
+    if (channel->founder_key)
+      silc_pkcs_public_key_free(channel->founder_key);
+    channel->founder_key = public_key;
+    public_key = NULL;
+  }
+
+  silc_rwlock_unlock(channel->internal.lock);
+
  out:
   silc_client_unref_channel(client, conn, channel);
   if (public_key)