updates.
authorPekka Riikonen <priikone@silcnet.org>
Mon, 18 Jun 2001 17:04:40 +0000 (17:04 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 18 Jun 2001 17:04:40 +0000 (17:04 +0000)
13 files changed:
CHANGES
TODO
apps/irssi/src/fe-common/silc/module-formats.c
apps/irssi/src/fe-common/silc/module-formats.h
apps/irssi/src/silc/core/client_ops.c
apps/irssi/src/silc/core/silc-channels.c
apps/silcd/command.c
apps/silcd/packet_receive.c
apps/silcd/server.c
doc/draft-riikonen-silc-commands-01.nroff
lib/silcclient/client_prvmsg.c
lib/silcclient/command.c
lib/silcclient/command_reply.c

diff --git a/CHANGES b/CHANGES
index baf0e550251adc7995070c315c73e4296e8b938a..5613f68387567c04588881224d73423c059d9eeb 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -33,6 +33,22 @@ Mon Jun 18 18:49:07 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
          but check whether the channel by that name already exists.
          Affected file irssi/silc/core/silc-channels.c.
 
+       * Do not send the SERVER_SIGNOFF to router if the disconnected
+         entity was the router.  Affected file silcd/server.c.
+
+       * Added the handling of the SERVER_SIGNOFF notify to the Irssi
+         SILC client as it was missing from there.
+
+         Added the handling of the KICK notify to the Irssi SILC client
+         as it was missing.  Added "you have been kicked" message to
+         Irssi SILC client's message modules formats.
+
+         Added the handing of the KILL notify to the Irssi SILC client
+         as it was missing.  Added the kill message module formats 
+         as well.
+
+         The affected file is irssi/src/silc/core/silc-channels.c.
+
 Sun Jun 17 15:26:05 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
        * Fixed the GETKEY command in the server to check also the
diff --git a/TODO b/TODO
index 94fae2a478a6e8c4a970124105bd24522bc329e4..c3a9335967b04bb14e0e098b8e43a7039a36eceb 100644 (file)
--- a/TODO
+++ b/TODO
@@ -59,14 +59,6 @@ TODO/bugs In SILC Client Library
 TODO/bugs In SILC Server
 ========================
 
- o Normal server seemed not to distribute the SERVER_SIGNOFF properly
-   when its router disconnected.
-
- o Router seemed not to force the channel mode change if the normal
-   server announced different modes than what the router had.  For example
-   if router crashed and then reconnected the server had different
-   modes 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 58d1462b0bc6e6f58527be93e4c3316d091b37bf..7e5c7df37dae4b7dcd3d738b80c0b9c6fa7e5504 100644 (file)
@@ -43,6 +43,10 @@ FORMAT_REC fecommon_silc_formats[] = {
        { "ban_list", "channel {channel $0} ban list: $1", 2, { 0, 0 } },
        { "no_ban_list", "channel {channel $0} ban list not set", 1, { 0 } },
        { "inviting", "Inviting {nick $0} to channel {channel $1}", 2, { 0, 0 } },
+       { "kicked_you", "You have been kicked off channel {channel $0} ($1}", 2, { 0, 0 } },
+       { "kicked", "{nick $0} has been kicked off channel {channel $1} ($2)", 3, { 0, 0, 0 } },
+       { "killed_you", "You have been killed from the SILC Network", 0 },
+       { "killed", "{nick $0} has been killed from the SILC Network ($1)", 2, { 0, 0 } },
 
        /* WHOIS, WHOWAS and USERS (alias WHO) messages */
        { NULL, "Who Queries", 0 },
index eb36f1551f918e95011b0f7f1ba87a18add03cf9..c4e0930b3f525c6041098727b87f82b8a27baec9 100644 (file)
@@ -40,6 +40,10 @@ enum {
   SILCTXT_CHANNEL_BAN_LIST,
   SILCTXT_CHANNEL_NO_BAN_LIST,
   SILCTXT_CHANNEL_INVITING,
+  SILCTXT_CHANNEL_KICKED_YOU,
+  SILCTXT_CHANNEL_KICKED,
+  SILCTXT_CHANNEL_KILLED_YOU,
+  SILCTXT_CHANNEL_KILLED,
 
   SILCTXT_FILL_2,
 
index f3ae6de00c31f22f77e617bec630ee8e687966c9..f80deb805012c02bc71eb421056a174bcf7bb14a 100644 (file)
@@ -223,6 +223,23 @@ void silc_command(SilcClient client, SilcClientConnection conn,
                  SilcClientCommandContext cmd_context, int success,
                  SilcCommand command)
 {
+  SILC_SERVER_REC *server = conn->context;
+
+  if (!success)
+    return;
+
+  switch(command) {
+  case SILC_COMMAND_INVITE:
+    printformat_module("fe-common/silc", server, NULL,
+                      MSGLEVEL_CRAP, SILCTXT_CHANNEL_INVITING,
+                      cmd_context->argv[2], 
+                      (cmd_context->argv[1][0] == '*' ?
+                       (char *)conn->current_channel->channel_name :
+                       (char *)cmd_context->argv[1]));
+    break;
+  default:
+    break;
+  }
 }
 
 /* Client info resolving callback when JOIN command reply is received.
@@ -431,18 +448,24 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
     {
       SilcChannelEntry channel;
       char *invite_list;
+      SilcArgumentPayload args;
+      int argc = 0;
       
       if (!success)
        return;
       
       channel = va_arg(vp, SilcChannelEntry);
       invite_list = va_arg(vp, char *);
-      
+
+      args = silc_command_get_args(cmd_payload);
+      if (args)
+       argc = silc_argument_get_arg_num(args);
+
       if (invite_list)
        printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
                           SILCTXT_CHANNEL_INVITE_LIST, channel->channel_name,
                           invite_list);
-      else
+      else if (argc == 3)
        printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
                           SILCTXT_CHANNEL_NO_INVITE_LIST, 
                           channel->channel_name);
index 2762014ad7edfe60a93eccccaaa0c62880d10764..04d56233eba1917fe5c841b747ff08de26ba2552 100644 (file)
@@ -386,7 +386,7 @@ static void event_motd(SILC_SERVER_REC *server, va_list va)
 
 static void event_channel_change(SILC_SERVER_REC *server, va_list va)
 {
-
+  /* Nothing interesting to do */
 }
 
 /*
@@ -395,7 +395,18 @@ static void event_channel_change(SILC_SERVER_REC *server, va_list va)
 
 static void event_server_signoff(SILC_SERVER_REC *server, va_list va)
 {
-
+  SilcClientEntry *clients;
+  uint32 clients_count;
+  int i;
+  
+  (void)va_arg(va, void *);
+  clients = va_arg(va, SilcClientEntry *);
+  clients_count = va_arg(va, uint32);
+  
+  for (i = 0; i < clients_count; i++)
+    signal_emit("message quit", 4, server, clients[i]->nickname,
+               clients[i]->username ? clients[i]->username : "", 
+               "server signoff");
 }
 
 /*
@@ -404,7 +415,25 @@ static void event_server_signoff(SILC_SERVER_REC *server, va_list va)
 
 static void event_kick(SILC_SERVER_REC *server, va_list va)
 {
+  SilcClientConnection conn = server->conn;
+  SilcClientEntry client_entry;
+  SilcChannelEntry channel_entry;
+  char *tmp;
 
+  client_entry = va_arg(va, SilcClientEntry);
+  tmp = va_arg(va, char *);
+  channel_entry = va_arg(va, SilcChannelEntry);
+  
+  if (client_entry == conn->local_entry) {
+    printformat_module("fe-common/silc", server, channel_entry->channel_name,
+                      MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_KICKED_YOU, 
+                      channel_entry->channel_name, tmp ? tmp : "");
+  } else {
+    printformat_module("fe-common/silc", server, channel_entry->channel_name,
+                      MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_KICKED, 
+                      client_entry->nickname,
+                      channel_entry->channel_name, tmp ? tmp : "");
+  }
 }
 
 /*
@@ -413,16 +442,25 @@ static void event_kick(SILC_SERVER_REC *server, va_list va)
 
 static void event_kill(SILC_SERVER_REC *server, va_list va)
 {
+  SilcClientConnection conn = server->conn;
+  SilcClientEntry client_entry;
+  SilcChannelEntry channel_entry;
+  char *tmp;
 
-}
-
-/*
- * "event ban". Someone was banned or ban list was modified.
- */
-
-static void event_ban(SILC_SERVER_REC *server, va_list va)
-{
-
+  client_entry = va_arg(va, SilcClientEntry);
+  tmp = va_arg(va, char *);
+  channel_entry = va_arg(va, SilcChannelEntry);
+  
+  if (client_entry == conn->local_entry) {
+    printformat_module("fe-common/silc", server, channel_entry->channel_name,
+                      MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_KILLED_YOU, 
+                      channel_entry->channel_name, tmp ? tmp : "");
+  } else {
+    printformat_module("fe-common/silc", server, channel_entry->channel_name,
+                      MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_KILLED, 
+                      client_entry->nickname,
+                      channel_entry->channel_name, tmp ? tmp : "");
+  }
 }
 
 /* PART (LEAVE) command. */
@@ -1117,7 +1155,6 @@ void silc_channels_init(void)
   signal_add("silc event server_signoff", (SIGNAL_FUNC) event_server_signoff);
   signal_add("silc event kick", (SIGNAL_FUNC) event_kick);
   signal_add("silc event kill", (SIGNAL_FUNC) event_kill);
-  signal_add("silc event ban", (SIGNAL_FUNC) event_ban);
   
   command_bind("part", MODULE_NAME, (SIGNAL_FUNC) command_part);
   command_bind("me", MODULE_NAME, (SIGNAL_FUNC) command_me);
@@ -1150,7 +1187,6 @@ void silc_channels_deinit(void)
                (SIGNAL_FUNC) event_server_signoff);
   signal_remove("silc event kick", (SIGNAL_FUNC) event_kick);
   signal_remove("silc event kill", (SIGNAL_FUNC) event_kill);
-  signal_remove("silc event ban", (SIGNAL_FUNC) event_ban);
   
   command_unbind("part", (SIGNAL_FUNC) command_part);
   command_unbind("me", (SIGNAL_FUNC) command_me);
index 83a22f11a165fecf0faab1d44139b54439b9540f..2d0f493e7b928c462e1ffdcc69fd5ba3eccca9ea 100644 (file)
@@ -2654,13 +2654,20 @@ SILC_SERVER_CMD_FUNC(info)
   server_name = entry->server_name;
 
   /* Send the reply */
-  packet = silc_command_reply_payload_encode_va(SILC_COMMAND_INFO,
-                                               SILC_STATUS_OK, ident, 3,
-                                               2, idp->data, idp->len,
-                                               3, server_name, 
-                                               strlen(server_name),
-                                               4, server_info, 
-                                               strlen(server_info));
+  if (server_info)
+    packet = silc_command_reply_payload_encode_va(SILC_COMMAND_INFO,
+                                                 SILC_STATUS_OK, ident, 3,
+                                                 2, idp->data, idp->len,
+                                                 3, server_name, 
+                                                 strlen(server_name),
+                                                 4, server_info, 
+                                                 strlen(server_info));
+  else
+    packet = silc_command_reply_payload_encode_va(SILC_COMMAND_INFO,
+                                                 SILC_STATUS_OK, ident, 2,
+                                                 2, idp->data, idp->len,
+                                                 3, server_name, 
+                                                 strlen(server_name));
   silc_server_packet_send(server, cmd->sock, SILC_PACKET_COMMAND_REPLY, 0, 
                          packet->data, packet->len, FALSE);
     
index dc38962f82a9f2bcf1f74d0323b56db3498b67b0..d4899345a514001b22b1d0e8a0d2ef5e5d741692 100644 (file)
@@ -1881,6 +1881,9 @@ void silc_server_new_channel(SilcServer server,
        return;
       }
 
+      /* Get the mode and set it to the channel */
+      channel->mode = silc_channel_get_mode(payload);
+
       /* Send the new channel key to the server */
       chk = silc_channel_key_payload_encode(id_len, id,
                                            strlen(channel->channel_key->
index 9914f962bd0e08a0fc4807bacc315ecde62db50d..d20df0767481e7418b6f2ce4355f7e40f9451d74 100644 (file)
@@ -2406,7 +2406,8 @@ int silc_server_remove_clients_by_server(SilcServer server,
     SilcBuffer args;
 
     /* Send SERVER_SIGNOFF notify to our primary router */
-    if (!server->standalone && server->router) {
+    if (!server->standalone && server->router &&
+       server->router != entry) {
       args = silc_argument_payload_encode(1, argv, argv_lens,
                                          argv_types);
       silc_server_send_notify_args(server, 
index 47a5afcc728d3a51f83b3e39ef900a04103ac7d0..bf1aa6008364c9688054760ea1be1f27c4338f87 100644 (file)
@@ -586,7 +586,8 @@ List of all defined commands in SILC follows.
                         (3) [<invite list>]
 
        This command replies with the invite list of the channel if it
-       exists.
+       exists.  The <invite list> may be omitted if the list was not
+        altered.
 
         Status messages:
 
index 98ccd69954258a499fbbfbfacd76b6d4c066dafc..c5a41b11ec70b86e934e30c91bb01e8a2a7aab3f 100644 (file)
@@ -142,6 +142,7 @@ void silc_client_private_message(SilcClient client,
   SilcIDCacheEntry id_cache;
   SilcClientID *remote_id = NULL;
   SilcClientEntry remote_client;
+  SilcMessageFlags flags;
 
   if (packet->src_id_type != SILC_ID_CLIENT)
     goto out;
@@ -173,22 +174,24 @@ void silc_client_private_message(SilcClient client,
     return;
   }
 
+  flags = silc_private_message_get_flags(payload);
+
   /* Pass the private message to application */
-  client->ops->private_message(client, conn, remote_client,
-                              silc_private_message_get_flags(payload),
+  client->ops->private_message(client, conn, remote_client, flags,
                               silc_private_message_get_message(payload, 
                                                                NULL));
 
   /* See if we are away (gone). If we are away we will reply to the
      sender with the set away message. */
-  if (conn->away && conn->away->away) {
+  if (conn->away && conn->away->away && !(flags & SILC_MESSAGE_FLAG_NOREPLY)) {
     /* If it's me, ignore */
     if (SILC_ID_CLIENT_COMPARE(remote_id, conn->local_id))
       goto out;
 
     /* Send the away message */
     silc_client_send_private_message(client, conn, remote_client,
-                                    SILC_MESSAGE_FLAG_AUTOREPLY,
+                                    SILC_MESSAGE_FLAG_AUTOREPLY |
+                                    SILC_MESSAGE_FLAG_NOREPLY,
                                     conn->away->away,
                                     strlen(conn->away->away), TRUE);
   }
index ac2324cbd87ef896598059f79cd164f3e32a101b..6b90b3698c136d85fedc86de62a9e46cb767e921 100644 (file)
@@ -367,6 +367,12 @@ SILC_CLIENT_CMD_FUNC(nick)
     goto out;
   }
 
+  if (cmd->argc < 2) {
+    cmd->client->ops->say(cmd->client, conn, "Usage: /NICK <nickname>");
+    COMMAND_ERROR;
+    goto out;
+  }
+
   if (!strcmp(conn->nickname, cmd->argv[1]))
     goto out;
 
@@ -613,10 +619,6 @@ SILC_CLIENT_CMD_FUNC(invite)
        cmd->pending = 1;
        return;
       }
-      
-      cmd->client->ops->say(cmd->client, conn, 
-                           "Inviting %s to channel %s", cmd->argv[2], 
-                           channel->channel_name);
     } else {
       invite = cmd->argv[2];
       invite++;
@@ -1209,6 +1211,12 @@ SILC_CLIENT_CMD_FUNC(cmode)
        int ll;
        mode |= SILC_CHANNEL_MODE_ULIMIT;
        type = 3;
+       if (cmd->argc < 4) {
+         cmd->client->ops->say(cmd->client, conn, 
+              "Usage: /CMODE <channel> +|-<modes> [{ <arguments>}]");
+         COMMAND_ERROR;
+         goto out;
+       }
        ll = atoi(cmd->argv[3]);
        SILC_PUT32_MSB(ll, tmp);
        arg = tmp;
@@ -1221,6 +1229,12 @@ SILC_CLIENT_CMD_FUNC(cmode)
       if (add) {
        mode |= SILC_CHANNEL_MODE_PASSPHRASE;
        type = 4;
+       if (cmd->argc < 4) {
+         cmd->client->ops->say(cmd->client, conn, 
+              "Usage: /CMODE <channel> +|-<modes> [{ <arguments>}]");
+         COMMAND_ERROR;
+         goto out;
+       }
        arg = cmd->argv[3];
        arg_len = cmd->argv_lens[3];
       } else {
@@ -1231,6 +1245,12 @@ SILC_CLIENT_CMD_FUNC(cmode)
       if (add) {
        mode |= SILC_CHANNEL_MODE_CIPHER;
        type = 5;
+       if (cmd->argc < 4) {
+         cmd->client->ops->say(cmd->client, conn, 
+              "Usage: /CMODE <channel> +|-<modes> [{ <arguments>}]");
+         COMMAND_ERROR;
+         goto out;
+       }
        arg = cmd->argv[3];
        arg_len = cmd->argv_lens[3];
       } else {
@@ -1241,6 +1261,12 @@ SILC_CLIENT_CMD_FUNC(cmode)
       if (add) {
        mode |= SILC_CHANNEL_MODE_HMAC;
        type = 6;
+       if (cmd->argc < 4) {
+         cmd->client->ops->say(cmd->client, conn, 
+              "Usage: /CMODE <channel> +|-<modes> [{ <arguments>}]");
+         COMMAND_ERROR;
+         goto out;
+       }
        arg = cmd->argv[3];
        arg_len = cmd->argv_lens[3];
       } else {
@@ -1252,6 +1278,13 @@ SILC_CLIENT_CMD_FUNC(cmode)
        mode |= SILC_CHANNEL_MODE_FOUNDER_AUTH;
        type = 7;
 
+       if (cmd->argc < 4) {
+         cmd->client->ops->say(cmd->client, conn, 
+              "Usage: /CMODE <channel> +|-<modes> [{ <arguments>}]");
+         COMMAND_ERROR;
+         goto out;
+       }
+
        if (!strcasecmp(cmd->argv[3], "-pubkey")) {
          auth = silc_auth_public_key_auth_generate(cmd->client->public_key,
                                                    cmd->client->private_key,
@@ -1276,11 +1309,6 @@ SILC_CLIENT_CMD_FUNC(cmode)
     }
   }
 
-  if (type && cmd->argc < 3) {
-    COMMAND_ERROR;
-    goto out;
-  }
-
   chidp = silc_id_payload_encode(channel->id, SILC_ID_CHANNEL);
   SILC_PUT32_MSB(mode, modebuf);
 
index caaabee5a18bebb61d3692ae0ecbbf06901e4054..8f2dff66a498e4ef0e3cfb1b554f4d5cf1156c8d 100644 (file)
@@ -82,8 +82,8 @@ const SilcCommandStatusMessage silc_command_status_messages[] = {
   { 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" },