updates.
authorPekka Riikonen <priikone@silcnet.org>
Sat, 26 May 2001 20:50:52 +0000 (20:50 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 26 May 2001 20:50:52 +0000 (20:50 +0000)
CHANGES
apps/irssi/default.theme
apps/irssi/src/fe-common/silc/module-formats.c
apps/irssi/src/fe-common/silc/module-formats.h
apps/irssi/src/silc/core/silc-channels.c
apps/irssi/src/silc/core/silc-core.c
apps/silcd/server.c
lib/silcutil/silcnet.c

diff --git a/CHANGES b/CHANGES
index cde90157bf0b63e230da933e34a42e2761ef130d..cf2daaaa7bc363955a686103ff58e0984a3c0697 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,17 @@ Sat May 26 17:43:42 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
          that SILC specific message hilighting, colors etc is possible.
          Affected file irssi/src/fe-common/silc/module-formats.[ch].
 
+         Added channel mode, channel user mode, actions, notices,
+         whois and whowas printing to the the module-formats.c.
+
+       * Fixed a bug in channel deletion in the server.  The channel
+         is not left to the cache even if the channel founder auth mode
+         is set when there are no users anymore on the channel.  Affected
+         file silcd/server.c.
+
+       * The silc_net_localhost now resolves the entire hostname including
+         the domain name.  Affected file lib/silcutil/silcnet.c.
+
 Sat May 26 12:13:37 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
        * Changed the ask_passphrase client operation to be ascynchronous.
index dc2bc8f2909173b68e76739d3de51a5c6e80ff7b..45570475285e3d64b5a58fab9e54fad3df986a8c 100644 (file)
@@ -93,8 +93,8 @@ abstracts = {
   # reason for something is printed (part, quit, kick, ..)
   reason = "{comment $0-}";
 
-  # mode change is printed ([+o nick])
-  mode = "{comment $0-}";
+  # mode change is printed
+  mode = "[$0-]";
 
   ##
   ## channel specific messages
@@ -114,6 +114,27 @@ abstracts = {
   # ban/ban exception/invite list mask is printed
   ban = "$0-";
 
+  ##
+  ## Action (/ME command)
+  ##
+
+  # Generic action
+  action = "%Y* $0-";
+
+  # Own sent action
+  ownaction = "%c* $0-";
+
+  ##
+  ## Notice (/NOTICE command)
+  ##
+
+  # Generic notice
+  notice = "%C- $0-";
+
+  # Own sent notice
+  ownnotice = "%g- $0";
+
+
   ##
   ## messages
   ##
@@ -169,41 +190,11 @@ abstracts = {
   # private message in query
   privmsgnick = "{msgnick  $0-%n}";
 
-  ##
-  ## Actions (/ME stuff)
-  ##
-
-  # used internally by this theme
-  action_core = "%Y* $0-";
-
-  # generic one that's used by most actions
-  action = "{action_core $0-} ";
-
-  # own action, both private/public
-  ownaction = "{action $0-}";
-
-  # own action with target, both private/public
-  ownaction_target = "{action_core $0}{msgchannel $1} ";
-
-  # private action sent by others
-  pvtaction = " (*) $0- ";
-  pvtaction_query = "{action $0-}";
-
-  # public action sent by others
-  pubaction = "{action $0-}";
-
 
   ##
   ## other IRC events
   ##
 
-  # notices
-  ownnotice = "-%c$1-%n- ";
-  notice = "-%C$0-%n- ";
-  pubnotice_channel = "{msgchannel $0}";
-  pvtnotice_host = "";
-  servernotice = "{notice $0-}";
-
   # CTCPs
   ownctcp = "[$0$1-] ";
   ctcp = "$0-";
@@ -218,8 +209,8 @@ abstracts = {
   netjoin = "%C$0-%n";
 
   # /names list
-  names_nick = "%n%_$0%_$1- | ";
-  names_users = "($0-)";
+  names_nick = "[ %n%_$0%_$1- ] ";
+  names_users = "$0-";
   names_channel = "{channel $0-}";
 
   # DCC
index 25ae7a86c4cb396b38e0ae233381ef7c02878b53..c70ff98d66b79f8defdaebced1c417e8c08e3091 100644 (file)
 FORMAT_REC fecommon_silc_formats[] = {
        { MODULE_NAME, "SILC", 0 },
 
-       /* ---- */
+       /* Channel related messages */
        { NULL, "Channel", 0 },
 
        { "channel_founder_you", "You are channel founder on {channel $0}", 1, { 0 } },
-       { "channel_founder", "Channel founder on {channel $0} is: {channick_hilight $1}", 2, { 0, 0 } },
+       { "channel_founder", "channel founder on {channel $0} is: {channick_hilight $1}", 2, { 0, 0 } },
        { "channel_topic", "Topic for {channel $0} is: $1", 2, { 0, 0 } },
+       { "cmode", "channel mode/{channel $0} {mode $1} by {nick $2}", 3, { 0, 0, 0 } },
+       { "cumode", "channel user mode/{channel $0}/{nick $1} {mode $2} by {nick $3}", 4, { 0, 0, 0, 0 } },
+       { "action", "{action $0}", 1, { 0 } },
+       { "notice", "{notice $0}", 1, { 0 } },
+       { "ownaction", "{ownaction $0}", 1, { 0 } },
+       { "ownnotice", "{ownnotice $0}", 1, { 0 } },
+
+       /* WHOIS and WHOWAS messages */
+       { NULL, "Who Queries", 0 },
+
+       { "whois", "{nick $0} {nickhost $1}%: realname : $2", 3, { 0, 0, 0 } },
+       { "whois_channels", " channels : $0", 1, { 0 } },
+       { "whois_modes", " modes    : $0", 1, { 0 } },
+       { "whois_idle", " idle     : $0", 1, { 0 } },
+       { "whowas", "{nick $0} was {nickhost $1} ($2)", 3, { 0, 0, 0 } },
 
        { NULL, NULL, 0 }
 };
+
index a61547eeafad9386c5ad3c2bb381a4fd3eabae3f..f2c5a1fcb424a9a68b9a5d4e11e4b178c74899b9 100644 (file)
@@ -28,6 +28,20 @@ enum {
   SILCTXT_CHANNEL_FOUNDER_YOU,
   SILCTXT_CHANNEL_FOUNDER,
   SILCTXT_CHANNEL_TOPIC,
+  SILCTXT_CHANNEL_CMODE,
+  SILCTXT_CHANNEL_CUMODE,
+  SILCTXT_CHANNEL_ACTION,
+  SILCTXT_CHANNEL_NOTICE,
+  SILCTXT_CHANNEL_OWNACTION,
+  SILCTXT_CHANNEL_OWNNOTICE,
+
+  SILCTXT_FILL_2,
+
+  SILCTXT_WHOIS_USERINFO,
+  SILCTXT_WHOIS_CHANNELS,
+  SILCTXT_WHOIS_MODES,
+  SILCTXT_WHOIS_IDLE,
+  SILCTXT_WHOWAS_USERINFO,
 };
 
 extern FORMAT_REC fecommon_silc_formats[];
index 3f99c37dce6e13d22871b5a22a137a5dcfb986b7..85255669809a30b43f467da031af41bba6530fca 100644 (file)
@@ -41,6 +41,7 @@
 #include "window-item-def.h"
 
 #include "fe-common/core/printtext.h"
+#include "fe-common/silc/module-formats.h"
 
 SILC_CHANNEL_REC *silc_channel_create(SILC_SERVER_REC *server,
                                      const char *name, int automatic)
@@ -284,7 +285,10 @@ static void event_cmode(SILC_SERVER_REC *server, va_list va)
 
   client = va_arg(va, SilcClientEntry);
   modei = va_arg(va, uint32);
+  (void)va_arg(va, char *);
+  (void)va_arg(va, char *);
   channel = va_arg(va, SilcChannelEntry);
+
   mode = silc_client_chmode(modei, channel);
   
   chanrec = silc_channel_find_entry(server, channel);
@@ -294,9 +298,10 @@ static void event_cmode(SILC_SERVER_REC *server, va_list va)
     signal_emit("channel mode changed", 1, chanrec);
   }
   
-  printtext(server, channel->channel_name, MSGLEVEL_MODES,
-           "cmode/%s [%s] by %s", channel->channel_name, mode,
-           client->nickname);
+  printformat_module("fe-common/silc", server, channel->channel_name,
+                    MSGLEVEL_MODES, SILCTXT_CHANNEL_CMODE,
+                    channel->channel_name, mode ? mode : "removed all",
+                    client->nickname);
   
   g_free(mode);
 }
@@ -327,7 +332,7 @@ static void event_cumode(SILC_SERVER_REC *server, va_list va)
       chanrec->chanop =
        (mode & SILC_CHANNEL_UMODE_CHANOP) != 0;
     }
-    
+
     nick = silc_nicklist_find(chanrec, destclient);
     if (nick != NULL) {
       nick->op = (mode & SILC_CHANNEL_UMODE_CHANOP) != 0;
@@ -335,10 +340,18 @@ static void event_cumode(SILC_SERVER_REC *server, va_list va)
     }
   }
   
-  printtext(server, channel->channel_name, MSGLEVEL_MODES,
-           "cumode/%s/%s [%s] by %s", destclient->nickname, 
-           channel->channel_name, modestr, client->nickname);
-  
+  printformat_module("fe-common/silc", server, channel->channel_name,
+                    MSGLEVEL_MODES, SILCTXT_CHANNEL_CUMODE,
+                    channel->channel_name, destclient->nickname, 
+                    modestr ? modestr : "removed all",
+                    client->nickname);
+
+  if (mode & SILC_CHANNEL_UMODE_CHANFO)
+    printformat_module("fe-common/silc", 
+                      server, channel->channel_name, MSGLEVEL_CRAP,
+                      SILCTXT_CHANNEL_FOUNDER,
+                      channel->channel_name, destclient->nickname);
+
   g_free(modestr);
 }
 
@@ -465,6 +478,9 @@ static void command_me(const char *data, SILC_SERVER_REC *server,
                                   SILC_MESSAGE_FLAG_ACTION, 
                                   argv[1], argv_lens[1], TRUE);
 
+  printformat_module("fe-common/silc", server, chanrec->entry->channel_name,
+                    MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_OWNACTION, argv[1]);
+
   for (i = 0; i < argc; i++)
     silc_free(argv[i]);
   silc_free(argv_lens);
@@ -508,12 +524,27 @@ static void command_notice(const char *data, SILC_SERVER_REC *server,
                                   SILC_MESSAGE_FLAG_NOTICE, 
                                   argv[1], argv_lens[1], TRUE);
 
+  printformat_module("fe-common/silc", server, chanrec->entry->channel_name,
+                    MSGLEVEL_NOTICES, SILCTXT_CHANNEL_OWNNOTICE, argv[1]);
+
   for (i = 0; i < argc; i++)
     silc_free(argv[i]);
   silc_free(argv_lens);
   silc_free(argv_types);
 }
 
+/* AWAY local command.  Sends UMODE command that sets the SILC_UMODE_GONE
+   flag. */
+
+static void command_away(const char *data, SILC_SERVER_REC *server,
+                        WI_ITEM_REC *item)
+{
+  if (!IS_SILC_SERVER(server) || !server->connected)
+    cmd_return_error(CMDERR_NOT_CONNECTED);
+
+  /* XXX TODO */
+}
+
 void silc_channels_init(void)
 {
   signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
@@ -538,7 +569,8 @@ void silc_channels_init(void)
   command_bind("part", MODULE_NAME, (SIGNAL_FUNC) command_part);
   command_bind("me", MODULE_NAME, (SIGNAL_FUNC) command_me);
   command_bind("notice", MODULE_NAME, (SIGNAL_FUNC) command_notice);
-  
+  command_bind("away", MODULE_NAME, (SIGNAL_FUNC) command_away);
+
   silc_nicklist_init();
 }
 
@@ -568,6 +600,7 @@ void silc_channels_deinit(void)
   command_unbind("part", (SIGNAL_FUNC) command_part);
   command_unbind("me", (SIGNAL_FUNC) command_me);
   command_unbind("notice", (SIGNAL_FUNC) command_notice);
-  
+  command_unbind("away", (SIGNAL_FUNC) command_away);
+
   silc_nicklist_deinit();
 }
index 8448245fb2693c3c8d7e43fe22522123c5ed42d5..2b823ed244d920ad43c127bac8647aae11635733 100644 (file)
@@ -158,9 +158,11 @@ silc_channel_message(SilcClient client, SilcClientConnection conn,
   nick = silc_nicklist_find(chanrec, sender);
 
   if (flags & SILC_MESSAGE_FLAG_ACTION)
-    ;
+    printformat_module("fe-common/silc", server, channel->channel_name,
+                      MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_ACTION, msg);
   else if (flags & SILC_MESSAGE_FLAG_NOTICE)
-    ;
+    printformat_module("fe-common/silc", server, channel->channel_name,
+                      MSGLEVEL_NOTICES, SILCTXT_CHANNEL_NOTICE, msg);
   else
     signal_emit("message public", 6, server, msg,
                nick == NULL ? "[<unknown>]" : nick->nick,
@@ -377,23 +379,19 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
   case SILC_COMMAND_WHOIS:
     {
       char buf[1024], *nickname, *username, *realname;
-      int len;
       uint32 idle, mode;
       SilcBuffer channels;
       
-      /* XXX should use irssi routines */
-      
       if (status == SILC_STATUS_ERR_NO_SUCH_NICK ||
          status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
        char *tmp;
        tmp = silc_argument_get_arg_type(silc_command_get_args(cmd_payload),
                                         3, NULL);
        if (tmp)
-         client->ops->say(client, conn, "%s: %s", tmp,
-                          silc_client_command_status_message(status));
+         silc_say_error("%s: %s", tmp, 
+                        silc_client_command_status_message(status));
        else
-         client->ops->say(client, conn, "%s",
-                          silc_client_command_status_message(status));
+         silc_say_error("%s", silc_client_command_status_message(status));
        break;
       }
       
@@ -408,34 +406,15 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
       mode = va_arg(vp, uint32);
       idle = va_arg(vp, uint32);
       
-      memset(buf, 0, sizeof(buf));
-      
-      if (nickname) {
-       len = strlen(nickname);
-       strncat(buf, nickname, len);
-       strncat(buf, " is ", 4);
-      }
-       
-      if (username) {
-       strncat(buf, username, strlen(username));
-      }
-       
-      if (realname) {
-       strncat(buf, " (", 2);
-       strncat(buf, realname, strlen(realname));
-       strncat(buf, ")", 1);
-      }
-      
-      client->ops->say(client, conn, "%s", buf);
-      
+      printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
+                        SILCTXT_WHOIS_USERINFO, nickname, username, 
+                        realname);
+
       if (channels) {
        SilcDList list = silc_channel_payload_parse_list(channels);
        if (list) {
          SilcChannelPayload entry;
-         
          memset(buf, 0, sizeof(buf));
-         strcat(buf, "on channels: ");
-         
          silc_dlist_start(list);
          while ((entry = silc_dlist_get(list)) != SILC_LIST_END) {
            char *m = silc_client_chumode_char(silc_channel_get_mode(entry));
@@ -449,38 +428,44 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
            silc_free(m);
          }
 
-         client->ops->say(client, conn, "%s", buf);
+         printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
+                            SILCTXT_WHOIS_CHANNELS, buf);
          silc_channel_payload_list_free(list);
        }
       }
       
       if (mode) {
+       memset(buf, 0, sizeof(buf));
+
        if ((mode & SILC_UMODE_SERVER_OPERATOR) ||
-           (mode & SILC_UMODE_ROUTER_OPERATOR))
-         client->ops->say(client, conn, "%s is %s", nickname,
-                          (mode & SILC_UMODE_SERVER_OPERATOR) ?
-                          "Server Operator" :
-                          (mode & SILC_UMODE_ROUTER_OPERATOR) ?
-                          "SILC Operator" : "[Unknown mode]");
-       
+           (mode & SILC_UMODE_ROUTER_OPERATOR)) {
+         strcat(buf, (mode & SILC_UMODE_SERVER_OPERATOR) ?
+                "Server Operator " :
+                (mode & SILC_UMODE_ROUTER_OPERATOR) ?
+                "SILC Operator " : "[Unknown mode] ");
+       }
        if (mode & SILC_UMODE_GONE)
-         client->ops->say(client, conn, "%s is gone", nickname);
+         strcat(buf, "away");
+
+       printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
+                          SILCTXT_WHOIS_MODES, buf);
       }
       
-      if (idle && nickname)
-       client->ops->say(client, conn, "%s has been idle %d %s",
-                        nickname,
-                        idle > 60 ? (idle / 60) : idle,
-                        idle > 60 ? "minutes" : "seconds");
+      if (idle && nickname) {
+       memset(buf, 0, sizeof(buf));
+       snprintf(buf, sizeof(buf) - 1, "%lu %s",
+                idle > 60 ? (idle / 60) : idle,
+                idle > 60 ? "minutes" : "seconds");
+
+       printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
+                          SILCTXT_WHOIS_IDLE, buf);
+      }
     }
     break;
     
   case SILC_COMMAND_WHOWAS:
     {
-      char buf[1024], *nickname, *username, *realname;
-      int len;
-      
-      /* XXX should use irssi routines */
+      char *nickname, *username, *realname;
       
       if (status == SILC_STATUS_ERR_NO_SUCH_NICK ||
          status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
@@ -488,11 +473,10 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
        tmp = silc_argument_get_arg_type(silc_command_get_args(cmd_payload),
                                         3, NULL);
        if (tmp)
-         client->ops->say(client, conn, "%s: %s", tmp,
-                          silc_client_command_status_message(status));
+         silc_say_error("%s: %s", tmp, 
+                        silc_client_command_status_message(status));
        else
-         client->ops->say(client, conn, "%s",
-                          silc_client_command_status_message(status));
+         silc_say_error("%s", silc_client_command_status_message(status));
        break;
       }
       
@@ -504,25 +488,9 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
       username = va_arg(vp, char *);
       realname = va_arg(vp, char *);
       
-      memset(buf, 0, sizeof(buf));
-      
-      if (nickname) {
-       len = strlen(nickname);
-       strncat(buf, nickname, len);
-       strncat(buf, " was ", 5);
-      }
-      
-      if (username) {
-       strncat(buf, username, strlen(nickname));
-      }
-       
-      if (realname) {
-       strncat(buf, " (", 2);
-       strncat(buf, realname, strlen(realname));
-       strncat(buf, ")", 1);
-      }
-      
-      client->ops->say(client, conn, "%s", buf);
+      printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
+                        SILCTXT_WHOWAS_USERINFO, nickname, username, 
+                        realname ? realname : "");
     }
     break;
     
@@ -679,27 +647,11 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
     break;
     
   case SILC_COMMAND_OPER:
-#if 0
-    if (status == SILC_STATUS_OK) {
-      conn->local_entry->mode |= SILC_UMODE_SERVER_OPERATOR;
-      if (app->screen->bottom_line->umode)
-       silc_free(app->screen->bottom_line->umode);
-      app->screen->bottom_line->umode = strdup("Server Operator");;
-      silc_screen_print_bottom_line(app->screen, 0);
-    }
-#endif
+    silc_say(client, conn, "You are now server operator");
     break;
     
   case SILC_COMMAND_SILCOPER:
-#if 0
-    if (status == SILC_STATUS_OK) {
-      conn->local_entry->mode |= SILC_UMODE_ROUTER_OPERATOR;
-      if (app->screen->bottom_line->umode)
-       silc_free(app->screen->bottom_line->umode);
-      app->screen->bottom_line->umode = strdup("SILC Operator");;
-      silc_screen_print_bottom_line(app->screen, 0);
-    }
-#endif
+    silc_say(client, conn, "You are now SILC operator");
     break;
     
   case SILC_COMMAND_USERS: 
@@ -835,12 +787,17 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
       channel = va_arg(vp, SilcChannelEntry);
       topic = va_arg(vp, char *);
       
-      /* XXX should use irssi routines */
-      
-      if (topic)
-       silc_say(client, conn, 
-                "Topic on channel %s: %s", channel->channel_name,
-                topic);
+      if (topic) {
+       chanrec = silc_channel_find_entry(server, channel);
+       if (chanrec) {
+         g_free_not_null(chanrec->topic);
+         chanrec->topic = *topic == '\0' ? NULL : g_strdup(topic);
+         signal_emit("channel topic changed", 1, chanrec);
+       }
+       printformat_module("fe-common/silc", server, channel->channel_name,
+                          MSGLEVEL_CRAP, SILCTXT_CHANNEL_TOPIC,
+                          channel->channel_name, topic);
+      }
     }
     break;
   }
index b56817765c41e3e86e58410189dbf60c0e75f38d..da3f7df43daae2fcbeeff2c183fa6d7fa1ee5483 100644 (file)
@@ -2508,27 +2508,8 @@ void silc_server_remove_from_channels(SilcServer server,
     /* Remove channel if there is no users anymore */
     if (server->server_type == SILC_ROUTER &&
        silc_hash_table_count(channel->user_list) < 2) {
-
       if (channel->rekey)
        silc_task_unregister_by_context(server->timeout_queue, channel->rekey);
-
-      if (channel->founder_key) {
-       /* The founder auth data exists, do not remove the channel entry */
-       SilcChannelClientEntry chl2;
-       SilcHashTableList htl2;
-
-       channel->id = NULL;
-
-       silc_hash_table_list(channel->user_list, &htl2);
-       while (silc_hash_table_get(&htl2, NULL, (void *)&chl2)) {
-         silc_hash_table_del(chl2->client->channels, channel);
-         silc_hash_table_del(channel->user_list, chl2->client);
-         silc_free(chl2);
-       }
-       continue;
-      }
-
-      /* Remove the channel entry */
       if (!silc_idlist_del_channel(server->local_list, channel))
        silc_idlist_del_channel(server->global_list, channel);
       server->stat.my_channels--;
@@ -2791,6 +2772,8 @@ SilcChannelEntry silc_server_create_new_channel(SilcServer server,
                                  NULL, key, newhmac);
   if (!entry) {
     silc_free(channel_name);
+    silc_cipher_free(key);
+    silc_hmac_free(newhmac);
     return NULL;
   }
 
index 0f240b7c9c1fa51639b9d72ba16ebbcc516d6bcf..683890ba97feb67cf8fc4d1009dc10e385aacc01 100644 (file)
@@ -399,7 +399,14 @@ uint16 silc_net_get_local_port(int sock)
 char *silc_net_localhost()
 {
   char hostname[256];
-  if (!gethostname(hostname, sizeof(hostname)))
+  struct hostent *dest;
+
+  if (gethostname(hostname, sizeof(hostname)))
+    return NULL;
+
+  dest = gethostbyname(hostname);
+  if (!dest)
     return strdup(hostname);
-  return NULL;
+
+  return strdup(dest->h_name);
 }