updates updates..
authorPekka Riikonen <priikone@silcnet.org>
Fri, 22 Jun 2001 09:51:51 +0000 (09:51 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 22 Jun 2001 09:51:51 +0000 (09:51 +0000)
CHANGES
TODO
apps/irssi/src/silc/core/silc-channels.c
apps/silcd/idlist.c
apps/silcd/packet_receive.c
lib/silcclient/command.c

diff --git a/CHANGES b/CHANGES
index eab51892fd26703057d548a849df5e1f66954a64..100ce2be1ee9e8a8a6e1d8426cd766fe1e5d2f39 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,21 @@
+Fri Jun 22 10:44:14 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Do not handle JOIN notify in the server if the target client
+         is not registered (idata->registered == FALSE).  The affected
+         file is silcd/packet_receive.c.
+
+       * Update the nickrec->founder in event_cumode in the Irssi SILC
+         client.  Affected file irssi/src/silc/core/silc-channels.c.
+
+       * Fixed the CUMODE_CHANGE notify handling in the server when
+         server and router are announcing their clients on channels.
+         Now the mode changes are saved and notified correctly.  The
+         affected file is /silcd/packet_receive.c.
+
+       * Fixed silc_idlit_replace_[server/client/channel]_id functions.
+         They really did not replace the cache entry in the ID Cache.
+         Now they do that.  Affected file silcd/idlist.c.
+
 Thu Jun 21 17:10:08 CEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
        * Fixed the silc_parse_command_line to remove extra spaces
diff --git a/TODO b/TODO
index ea16429bf5fd286abf7739289caf11d1f8b8d96f..bb6237b5a41581c04db7cc27f1a36a788e38e6ea 100644 (file)
--- a/TODO
+++ b/TODO
@@ -3,6 +3,12 @@ TODO/bugs in Irssi SILC client
 
  o LEAVE does not work correctly, it doesn't leave the channel for real!
 
+       o Remove the entire current_channel field from the client
+         library and handle the current channel thingy in the 
+         Irssi SILC client.  Requires short stub functions of all
+         commands that use current current_channel to the Irssi SILC
+         client which then calls the actual library command.
+
  o /KICK does not remove the client from Irssi's NAMES list.
 
  o Add PERL scripting support from Irssi CVS.
@@ -66,9 +72,6 @@ TODO/bugs In SILC Client Library
 TODO/bugs In SILC Server
 ========================
 
- o Seems that router does not announce its client to the connecting
-   server when server announces its clients on the channel.
-
  o When server quits and all clients of that server are removed from all
    channels the channel keys are re-generated for all clients.  This is
    a bug and should be done only once per channel after all clients of
index 71e597e2c1fc9fd049ef9884cd32e9a9685e89db..70db4f4f384b4d64a694e9a52e3d36379a7291a8 100644 (file)
@@ -349,6 +349,7 @@ static void event_cumode(SILC_SERVER_REC *server, va_list va)
     nick = silc_nicklist_find(chanrec, destclient);
     if (nick != NULL) {
       nick->op = (mode & SILC_CHANNEL_UMODE_CHANOP) != 0;
+      nick->founder = (mode & SILC_CHANNEL_UMODE_CHANFO) != 0;
       signal_emit("nick mode changed", 2, chanrec, nick);
     }
   }
index 3de0c40e854f5cb86b6c0e5f76be07924d6433af..e973a1d6d2bd09d66191b7ba30d410caa877c5a1 100644 (file)
@@ -237,11 +237,14 @@ silc_idlist_replace_server_id(SilcIDList id_list, SilcServerID *old_id,
     return NULL;
 
   server = (SilcServerEntry)id_cache->context;
+
+  /* Remove the old entry and add a new one */
+
+  silc_idcache_del_by_id(id_list->servers, (void *)server->id);
+
   silc_free(server->id);
   server->id = new_id;
 
-  /* Remove the old entry and add a new one */
-  silc_idcache_del_by_context(id_list->servers, server);
   silc_idcache_add(id_list->servers, server->server_name, server->id, 
                   server, FALSE);
 
@@ -496,11 +499,14 @@ silc_idlist_replace_client_id(SilcIDList id_list, SilcClientID *old_id,
     return NULL;
 
   client = (SilcClientEntry)id_cache->context;
+
+  /* Remove the old entry and add a new one */
+
+  silc_idcache_del_by_id(id_list->clients, (void *)client->id);
+
   silc_free(client->id);
   client->id = new_id;
 
-  /* Remove the old entry and add a new one */
-  silc_idcache_del_by_context(id_list->clients, client);
   silc_idcache_add(id_list->clients, client->nickname, client->id, 
                   client, FALSE);
 
@@ -708,11 +714,14 @@ silc_idlist_replace_channel_id(SilcIDList id_list, SilcChannelID *old_id,
     return NULL;
 
   channel = (SilcChannelEntry)id_cache->context;
+
+  /* Remove the old entry and add a new one */
+
+  silc_idcache_del_by_id(id_list->channels, (void *)channel->id);
+
   silc_free(channel->id);
   channel->id = new_id;
 
-  /* Remove the old entry and add a new one */
-  silc_idcache_del_by_context(id_list->channels, channel);
   silc_idcache_add(id_list->channels, channel->channel_name, channel->id, 
                   channel, FALSE);
 
index f207289903b432154ca047fc228dcecbcec00437..7ac6826faf0ad46138e6ad46e6bf09324f41ed71 100644 (file)
@@ -163,6 +163,10 @@ void silc_server_notify(SilcServer server,
       }
     }
 
+    /* Do not process the notify if the client is not registered */
+    if (client->data.registered == FALSE)
+      break;
+
     /* Do not add client to channel if it is there already */
     if (silc_server_client_on_channel(client, channel))
       break;
@@ -462,100 +466,119 @@ void silc_server_notify(SilcServer server,
     break;
 
   case SILC_NOTIFY_TYPE_CUMODE_CHANGE:
-    /* 
-     * Distribute the notify to local clients on the channel
-     */
-
-    SILC_LOG_DEBUG(("CUMODE CHANGE notify"));
-
-    channel_id = silc_id_str2id(packet->dst_id, packet->dst_id_len,
-                               packet->dst_id_type);
-    if (!channel_id)
-      goto out;
+    {
+      /* 
+       * Distribute the notify to local clients on the channel
+       */
+      SilcChannelClientEntry chl2 = NULL;
+      bool notify_sent = FALSE;
+      
+      SILC_LOG_DEBUG(("CUMODE CHANGE notify"));
+      
+      channel_id = silc_id_str2id(packet->dst_id, packet->dst_id_len,
+                                 packet->dst_id_type);
+      if (!channel_id)
+       goto out;
 
-    /* Get channel entry */
-    channel = silc_idlist_find_channel_by_id(server->global_list, 
-                                            channel_id, NULL);
-    if (!channel) {
-      channel = silc_idlist_find_channel_by_id(server->local_list, 
+      /* Get channel entry */
+      channel = silc_idlist_find_channel_by_id(server->global_list, 
                                               channel_id, NULL);
       if (!channel) {
+       channel = silc_idlist_find_channel_by_id(server->local_list, 
+                                                channel_id, NULL);
+       if (!channel) {
+         silc_free(channel_id);
+         goto out;
+       }
+      }
+
+      /* Get the mode */
+      tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
+      if (!tmp) {
        silc_free(channel_id);
        goto out;
       }
-    }
-
-    /* Get the mode */
-    tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
-    if (!tmp) {
-      silc_free(channel_id);
-      goto out;
-    }
       
-    SILC_GET32_MSB(mode, tmp);
-
-    /* Get target client */
-    tmp = silc_argument_get_arg_type(args, 3, &tmp_len);
-    if (!tmp)
-      goto out;
-    client_id = silc_id_payload_parse_id(tmp, tmp_len);
-    if (!client_id)
-      goto out;
-    
-    /* Get client entry */
-    client = silc_idlist_find_client_by_id(server->global_list, 
-                                          client_id, NULL);
-    if (!client) {
-      client = silc_idlist_find_client_by_id(server->local_list, 
-                                            client_id, NULL);
-      if (!client) {
-       silc_free(client_id);
+      SILC_GET32_MSB(mode, tmp);
+      
+      /* Get target client */
+      tmp = silc_argument_get_arg_type(args, 3, &tmp_len);
+      if (!tmp)
        goto out;
-      }
-    }
-    silc_free(client_id);
-
-    /* Get entry to the channel user list */
-    silc_hash_table_list(channel->user_list, &htl);
-    while (silc_hash_table_get(&htl, NULL, (void *)&chl)) {
-      SilcChannelClientEntry chl2 = NULL;
-
-      /* If the mode is channel founder and we already find a client 
-        to have that mode on the channel we will enforce the sender
-        to change the channel founder mode away. There can be only one
-        channel founder on the channel. */
-      if (server->server_type == SILC_ROUTER &&
-         mode & SILC_CHANNEL_UMODE_CHANFO &&
-         chl->mode & SILC_CHANNEL_UMODE_CHANFO) {
-       silc_server_send_notify_cumode(server, sock, FALSE, channel,
-                                      (mode & (~SILC_CHANNEL_UMODE_CHANFO)),
-                                      server->id, SILC_ID_SERVER, 
-                                      client->id);
-       silc_free(channel_id);
-
-       /* Change the mode back if we changed it */
-       if (chl2)
-         chl2->mode &= ~SILC_CHANNEL_UMODE_CHANFO;
+      client_id = silc_id_payload_parse_id(tmp, tmp_len);
+      if (!client_id)
        goto out;
+      
+      /* Get client entry */
+      client = silc_idlist_find_client_by_id(server->global_list, 
+                                            client_id, NULL);
+      if (!client) {
+       client = silc_idlist_find_client_by_id(server->local_list, 
+                                              client_id, NULL);
+       if (!client) {
+         silc_free(client_id);
+         goto out;
+       }
       }
+      silc_free(client_id);
 
-      if (chl->client == client) {
-       /* Change the mode */
-       chl->mode = mode;
-       if (!(mode & SILC_CHANNEL_UMODE_CHANFO))
-         break;
-
-       chl2 = chl;
+      /* Get entry to the channel user list */
+      silc_hash_table_list(channel->user_list, &htl);
+      while (silc_hash_table_get(&htl, NULL, (void *)&chl)) {
+       /* If the mode is channel founder and we already find a client 
+          to have that mode on the channel we will enforce the sender
+          to change the channel founder mode away. There can be only one
+          channel founder on the channel. */
+       if (server->server_type == SILC_ROUTER &&
+           mode & SILC_CHANNEL_UMODE_CHANFO &&
+           chl->mode & SILC_CHANNEL_UMODE_CHANFO) {
+         SilcBuffer idp;
+         unsigned char cumode[4];
+
+         mode &= ~SILC_CHANNEL_UMODE_CHANFO;
+         silc_server_send_notify_cumode(server, sock, FALSE, channel, mode,
+                                        client->id, SILC_ID_CLIENT,
+                                        client->id);
+         
+         idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
+         SILC_PUT32_MSB(mode, cumode);
+         silc_server_send_notify_to_channel(server, sock, channel, FALSE, 
+                                            SILC_NOTIFY_TYPE_CUMODE_CHANGE,
+                                            3, idp->data, idp->len,
+                                            cumode, 4,
+                                            idp->data, idp->len);
+         silc_buffer_free(idp);
+         notify_sent = TRUE;
+
+         /* Force the mode change if we alredy set the mode */
+         if (chl2) {
+           chl2->mode = mode;
+           silc_free(channel_id);
+           goto out;
+         }
+       }
+       
+       if (chl->client == client) {
+         /* Change the mode */
+         chl->mode = mode;
+         if (!(mode & SILC_CHANNEL_UMODE_CHANFO))
+           break;
+         
+         chl2 = chl;
+       }
       }
+      
+      /* Send the same notify to the channel */
+      if (!notify_sent)
+       silc_server_packet_send_to_channel(server, sock, channel, 
+                                          packet->type, 
+                                          FALSE, packet->buffer->data, 
+                                          packet->buffer->len, FALSE);
+      
+      silc_free(channel_id);
+      break;
     }
 
-    /* Send the same notify to the channel */
-    silc_server_packet_send_to_channel(server, sock, channel, packet->type, 
-                                      FALSE, packet->buffer->data, 
-                                      packet->buffer->len, FALSE);
-    silc_free(channel_id);
-    break;
-
   case SILC_NOTIFY_TYPE_INVITE:
 
     if (packet->dst_id_type == SILC_ID_CLIENT)
index ee12b1ea27fe48ede6136042b0603ae49cf9006e..cd395be1dedfb6bb53545d766324783d92af6bb6 100644 (file)
@@ -2004,12 +2004,6 @@ SILC_CLIENT_CMD_FUNC(leave)
     name = cmd->argv[1];
   }
 
-  if (!conn->current_channel) {
-    cmd->client->ops->say(cmd->client, conn, "You are not on that channel");
-    COMMAND_ERROR;
-    goto out;
-  }
-
   /* Get the Channel ID of the channel */
   if (!silc_idcache_find_by_name_one(conn->channel_cache, name, &id_cache)) {
     cmd->client->ops->say(cmd->client, conn, "You are not on that channel");
@@ -2031,7 +2025,8 @@ SILC_CLIENT_CMD_FUNC(leave)
   /* Notify application */
   COMMAND;
 
-  conn->current_channel = NULL;
+  if (conn->current_channel == channel)
+    conn->current_channel = NULL;
 
   silc_idcache_del_by_id(conn->channel_cache, channel->id);
   silc_free(channel->channel_name);