tupdates
authorPekka Riikonen <priikone@silcnet.org>
Sat, 16 Feb 2002 12:53:32 +0000 (12:53 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 16 Feb 2002 12:53:32 +0000 (12:53 +0000)
CHANGES
TODO
apps/irssi/src/silc/core/client_ops.c
apps/irssi/src/silc/core/silc-channels.c
lib/silcclient/client.c

diff --git a/CHANGES b/CHANGES
index af1728bec93876fc73dfdd3a57e5ac4be7083f7d..4189c1557d4621a2c2de4efa0edd72656106db6d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,13 @@
+Sat Feb 16 13:44:24 EET 2002  Johnny Mnemonic <johnny@themnemonic.org>
+
+       * Rewrote the notify handling in Irssi SILC client to not call
+         the events as signals.  Fixes problems with Perl support.
+         Affected files irssi/src/silc/core/client_ops.c, silc-channels.c.
+
+       * Send the auto-nicking NICK command in client library with
+         little timeout after connecting.  The affected file is
+         lib/silcclient/client.c.
+
 Sat Feb 16 02:46:43 CET 2002  Johnny Mnemonic <johnny@themnemonic.org>
 
        * Cleaned up the listening sockets code, preparing for the rehash
diff --git a/TODO b/TODO
index 00b2f3e2c52dd1c90afa489075281320b7b15034..eae63e9a808e6f2ee084364b59f21e9211ff382a 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,21 +1,17 @@
 TODO/bugs in Irssi SILC client
 ==============================
 
- o Rewrite the notify handling in the new Irssi SILC client.
-
- o /cumode for unknown nick does not give any error message.
+ o Fix the silc_channels_join to parse the command like, with fe.
+   silc_parse_command_line, because currently it ignores all options,
+   including passphrase which makes autojoin impossible to +a channels.
+   Other important options are ignored too.
 
  o Add local command to switch the channel's private key when channel has
    several private keys.  Currently sending channel messages with many
    keys is not possible because changing the key is not possible by the
    user.
 
- o JOINing to +a (requires passphrase to JOIN) does not work on autojoin.
-   Seems the passwords in the .silc/config has no effect.
-
- o Add local commands to list the current server and client public keys
-   that the user has.  And a local command to dump the contents of the
-   public key to the screen.  Something like LISTKEYS, SHOWKEY...
+ o /cumode for unknown nick does not give any error message.
 
 
 TODO/bugs In SILC Client Library
index 6d451459af572596f2dba76485f7bac4d04a888f..f86ff03d500364e74781f14a11b749f5ea7122cc 100644 (file)
@@ -148,54 +148,411 @@ void silc_private_message(SilcClient client, SilcClientConnection conn,
    for channel the channel entry is sent to application (even if server
    does not send it). */
 
-typedef struct {
-  int type;
-  const char *name;
-} NOTIFY_REC;
-
-#define MAX_NOTIFY (sizeof(notifies)/sizeof(notifies[0]))
-static NOTIFY_REC notifies[] = {
-  { SILC_NOTIFY_TYPE_NONE,             NULL },
-  { SILC_NOTIFY_TYPE_INVITE,           "invite" },
-  { SILC_NOTIFY_TYPE_JOIN,             "join" },
-  { SILC_NOTIFY_TYPE_LEAVE,            "leave" },
-  { SILC_NOTIFY_TYPE_SIGNOFF,          "signoff" },
-  { SILC_NOTIFY_TYPE_TOPIC_SET,                "topic" },
-  { SILC_NOTIFY_TYPE_NICK_CHANGE,      "nick" },
-  { SILC_NOTIFY_TYPE_CMODE_CHANGE,     "cmode" },
-  { SILC_NOTIFY_TYPE_CUMODE_CHANGE,    "cumode" },
-  { SILC_NOTIFY_TYPE_MOTD,             "motd" },
-  { SILC_NOTIFY_TYPE_CHANNEL_CHANGE,   "channel_change" },
-  { SILC_NOTIFY_TYPE_SERVER_SIGNOFF,   "server_signoff" },
-  { SILC_NOTIFY_TYPE_KICKED,           "kick" },
-  { SILC_NOTIFY_TYPE_KILLED,           "kill" },
-  { SILC_NOTIFY_TYPE_UMODE_CHANGE,      "umode" },
-  { SILC_NOTIFY_TYPE_BAN,               "ban" },
-};
-
 void silc_notify(SilcClient client, SilcClientConnection conn,
                 SilcNotifyType type, ...)
 {
-  SILC_SERVER_REC *server;
   va_list va;
-  
+  SILC_SERVER_REC *server;
+  SILC_CHANNEL_REC *chanrec;
+  SILC_NICK_REC *nickrec;
+  SilcClientEntry client_entry, client_entry2;
+  SilcChannelEntry channel;
+  SilcServerEntry server_entry;
+  SilcIdType idtype;
+  void *entry;
+  uint32 mode;
+  char userhost[512];
+  char *name, *tmp;
+  GSList *list1, *list_tmp;
+
   SILC_LOG_DEBUG(("Start"));
 
-  server = conn == NULL ? NULL : conn->context;
   va_start(va, type);
+
+  server = conn == NULL ? NULL : conn->context;
   
-  if (type == SILC_NOTIFY_TYPE_NONE) {
+  switch(type) {
+  case SILC_NOTIFY_TYPE_NONE:
     /* Some generic notice from server */
     printtext(server, NULL, MSGLEVEL_CRAP, "%s", (char *)va_arg(va, char *));
-  } else if (type < MAX_NOTIFY) {
-    /* Send signal about the notify event */
-    char signal[50];
-    g_snprintf(signal, sizeof(signal), "silc event %s", notifies[type].name);
-    signal_emit(signal, 2, server, va);
-  } else {
+    break;
+
+  case SILC_NOTIFY_TYPE_INVITE:
+    /*
+     * Invited or modified invite list.
+     */
+
+    SILC_LOG_DEBUG(("Notify: INVITE"));
+
+    channel = va_arg(va, SilcChannelEntry);
+    name = va_arg(va, char *);
+    client_entry = va_arg(va, SilcClientEntry);
+
+    memset(userhost, 0, sizeof(userhost));
+    snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
+            client_entry->username, client_entry->hostname);
+    signal_emit("message invite", 4, server, channel ? channel->channel_name :
+               name, client_entry->nickname, userhost);
+    break;
+
+  case SILC_NOTIFY_TYPE_JOIN:
+    /*
+     * Joined channel.
+     */
+    SILC_LOG_DEBUG(("Notify: JOIN"));
+
+    client_entry = va_arg(va, SilcClientEntry);
+    channel = va_arg(va, SilcChannelEntry);
+
+    if (client_entry == server->conn->local_entry) {
+      /* You joined to channel */
+      chanrec = silc_channel_find(server, channel->channel_name);
+      if (chanrec != NULL && !chanrec->joined)
+       chanrec->entry = channel;
+    } else {
+      chanrec = silc_channel_find_entry(server, channel);
+      if (chanrec != NULL) {
+       SilcChannelUser chu = silc_client_on_channel(channel, client_entry);
+       if (chu)
+         nickrec = silc_nicklist_insert(chanrec, chu, TRUE);
+      }
+    }
+    
+    memset(userhost, 0, sizeof(userhost));
+    if (client_entry->username)
+    snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
+            client_entry->username, client_entry->hostname);
+    signal_emit("message join", 4, server, channel->channel_name,
+               client_entry->nickname,
+               client_entry->username == NULL ? "" : userhost);
+    break;
+
+  case SILC_NOTIFY_TYPE_LEAVE:
+    /*
+     * Left a channel.
+     */
+
+    SILC_LOG_DEBUG(("Notify: LEAVE"));
+
+    client_entry = va_arg(va, SilcClientEntry);
+    channel = va_arg(va, SilcChannelEntry);
+    
+    memset(userhost, 0, sizeof(userhost));
+    if (client_entry->username)
+      snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
+              client_entry->username, client_entry->hostname);
+    signal_emit("message part", 5, server, channel->channel_name,
+               client_entry->nickname,  client_entry->username ? 
+               userhost : "", client_entry->nickname);
+    
+    chanrec = silc_channel_find_entry(server, channel);
+    if (chanrec != NULL) {
+      nickrec = silc_nicklist_find(chanrec, client_entry);
+      if (nickrec != NULL)
+       nicklist_remove(CHANNEL(chanrec), NICK(nickrec));
+    }
+    break;
+
+  case SILC_NOTIFY_TYPE_SIGNOFF:
+    /*
+     * Left the network.
+     */
+
+    SILC_LOG_DEBUG(("Notify: SIGNOFF"));
+
+    client_entry = va_arg(va, SilcClientEntry);
+    tmp = va_arg(va, char *);
+    
+    silc_server_free_ftp(server, client_entry);
+    
+    memset(userhost, 0, sizeof(userhost));
+    if (client_entry->username)
+      snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
+              client_entry->username, client_entry->hostname);
+    signal_emit("message quit", 4, server, client_entry->nickname,
+               client_entry->username ? userhost : "", 
+               tmp ? tmp : "");
+    
+    list1 = nicklist_get_same_unique(SERVER(server), client_entry);
+    for (list_tmp = list1; list_tmp != NULL; list_tmp = 
+          list_tmp->next->next) {
+      CHANNEL_REC *channel = list_tmp->data;
+      NICK_REC *nickrec = list_tmp->next->data;
+      
+      nicklist_remove(channel, nickrec);
+    }
+    break;
+
+  case SILC_NOTIFY_TYPE_TOPIC_SET:
+    /*
+     * Changed topic.
+     */
+
+    SILC_LOG_DEBUG(("Notify: TOPIC_SET"));
+
+    idtype = va_arg(va, int);
+    entry = va_arg(va, void *);
+    tmp = va_arg(va, char *);
+    channel = va_arg(va, SilcChannelEntry);
+    
+    chanrec = silc_channel_find_entry(server, channel);
+    if (chanrec != NULL) {
+      g_free_not_null(chanrec->topic);
+      chanrec->topic = *tmp == '\0' ? NULL : g_strdup(tmp);
+      signal_emit("channel topic changed", 1, chanrec);
+    }
+    
+    if (idtype == SILC_ID_CLIENT) {
+      client_entry = (SilcClientEntry)entry;
+      memset(userhost, 0, sizeof(userhost));
+      snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
+              client_entry->username, client_entry->hostname);
+      signal_emit("message topic", 5, server, channel->channel_name,
+                 tmp, client_entry->nickname, userhost);
+    } else if (idtype == SILC_ID_SERVER) {
+      server_entry = (SilcServerEntry)entry;
+      signal_emit("message topic", 5, server, channel->channel_name,
+                 tmp, server_entry->server_name, 
+                 server_entry->server_name);
+    } else {
+      channel = (SilcChannelEntry)entry;
+      signal_emit("message topic", 5, server, channel->channel_name,
+                 tmp, channel->channel_name, channel->channel_name);
+    }
+    break;
+
+  case SILC_NOTIFY_TYPE_NICK_CHANGE:
+    /*
+     * Changed nickname.
+     */
+
+    SILC_LOG_DEBUG(("Notify: NICK_CHANGE"));
+
+    client_entry = va_arg(va, SilcClientEntry);
+    client_entry2 = va_arg(va, SilcClientEntry);
+    
+    nicklist_rename_unique(SERVER(server),
+                          client_entry, client_entry->nickname,
+                          client_entry2, client_entry2->nickname);
+    
+    memset(userhost, 0, sizeof(userhost));
+    snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
+            client_entry2->username, client_entry2->hostname);
+    signal_emit("message nick", 4, server, client_entry2->nickname, 
+               client_entry2->nickname, userhost);
+    break;
+
+  case SILC_NOTIFY_TYPE_CMODE_CHANGE:
+    /*
+     * Changed channel mode.
+     */
+
+    SILC_LOG_DEBUG(("Notify: CMODE_CHANGE"));
+
+    idtype = va_arg(va, int);
+    entry = va_arg(va, void *);
+    mode = va_arg(va, uint32);
+    (void)va_arg(va, char *);
+    (void)va_arg(va, char *);
+    channel = va_arg(va, SilcChannelEntry);
+
+    tmp = silc_client_chmode(mode,
+                            channel->channel_key ? 
+                            channel->channel_key->cipher->name : "",
+                            channel->hmac ? 
+                            silc_hmac_get_name(channel->hmac) : "");
+    
+    chanrec = silc_channel_find_entry(server, channel);
+    if (chanrec != NULL) {
+      g_free_not_null(chanrec->mode);
+      chanrec->mode = g_strdup(tmp == NULL ? "" : tmp);
+      signal_emit("channel mode changed", 1, chanrec);
+    }
+    
+    if (idtype == SILC_ID_CLIENT) {
+      client_entry = (SilcClientEntry)entry;
+      printformat_module("fe-common/silc", server, channel->channel_name,
+                        MSGLEVEL_MODES, SILCTXT_CHANNEL_CMODE,
+                        channel->channel_name, tmp ? tmp : "removed all",
+                        client_entry->nickname);
+    } else if (idtype == SILC_ID_SERVER) {
+      server_entry = (SilcServerEntry)entry;
+      printformat_module("fe-common/silc", server, channel->channel_name,
+                        MSGLEVEL_MODES, SILCTXT_CHANNEL_CMODE,
+                        channel->channel_name, tmp ? tmp : "removed all",
+                        server_entry->server_name);
+    }
+
+    silc_free(tmp);
+    break;
+
+  case SILC_NOTIFY_TYPE_CUMODE_CHANGE:
+    /*
+     * Changed user's mode on channel.
+     */
+
+    SILC_LOG_DEBUG(("Notify: CUMODE_CHANGE"));
+
+    client_entry = va_arg(va, SilcClientEntry);
+    mode = va_arg(va, uint32);
+    client_entry2 = va_arg(va, SilcClientEntry);
+    channel = va_arg(va, SilcChannelEntry);
+    
+    tmp = silc_client_chumode(mode);
+    chanrec = silc_channel_find_entry(server, channel);
+    if (chanrec != NULL) {
+      SILC_NICK_REC *nick;
+      
+      if (client_entry2 == server->conn->local_entry)
+       chanrec->chanop = (mode & SILC_CHANNEL_UMODE_CHANOP) != 0;
+      
+      nick = silc_nicklist_find(chanrec, client_entry2);
+      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);
+      }
+    }
+  
+    printformat_module("fe-common/silc", server, channel->channel_name,
+                      MSGLEVEL_MODES, SILCTXT_CHANNEL_CUMODE,
+                      channel->channel_name, client_entry2->nickname, 
+                      tmp ? tmp : "removed all",
+                      client_entry->nickname);
+
+    if (mode & SILC_CHANNEL_UMODE_CHANFO)
+      printformat_module("fe-common/silc", 
+                        server, channel->channel_name, MSGLEVEL_CRAP,
+                        SILCTXT_CHANNEL_FOUNDER,
+                        channel->channel_name, client_entry2->nickname);
+    
+    silc_free(tmp);
+    break;
+
+  case SILC_NOTIFY_TYPE_MOTD:
+    /*
+     * Received MOTD.
+     */
+
+    SILC_LOG_DEBUG(("Notify: MOTD"));
+
+    tmp = va_arg(va, char *);
+
+    if (!settings_get_bool("skip_motd"))
+      printtext_multiline(server, NULL, MSGLEVEL_CRAP, "%s", tmp);
+    break;
+
+  case SILC_NOTIFY_TYPE_KICKED:
+    /*
+     * Someone was kicked from channel.
+     */
+
+    SILC_LOG_DEBUG(("Notify: KICKED"));
+
+    client_entry = va_arg(va, SilcClientEntry);
+    tmp = va_arg(va, char *);
+    client_entry2 = va_arg(va, SilcClientEntry);
+    channel = va_arg(va, SilcChannelEntry);
+
+    chanrec = silc_channel_find_entry(server, channel);
+  
+    if (client_entry == conn->local_entry) {
+      printformat_module("fe-common/silc", server, channel->channel_name,
+                        MSGLEVEL_CRAP, SILCTXT_CHANNEL_KICKED_YOU, 
+                        client_entry2->nickname,
+                        channel->channel_name, tmp ? tmp : "");
+      if (chanrec) {
+       chanrec->kicked = TRUE;
+       channel_destroy((CHANNEL_REC *)chanrec);
+      }
+    } else {
+      printformat_module("fe-common/silc", server, channel->channel_name,
+                        MSGLEVEL_CRAP, SILCTXT_CHANNEL_KICKED, 
+                        client_entry->nickname,
+                        client_entry2->nickname,
+                        channel->channel_name, tmp ? tmp : "");
+
+      if (chanrec) {
+       SILC_NICK_REC *nickrec = silc_nicklist_find(chanrec, client_entry);
+       if (nickrec != NULL)
+         nicklist_remove(CHANNEL(chanrec), NICK(nickrec));
+      }
+    }
+    break;
+
+  case SILC_NOTIFY_TYPE_KILLED:
+    /*
+     * Someone was killed from the network.
+     */
+
+    SILC_LOG_DEBUG(("Notify: KILLED"));
+
+    client_entry = va_arg(va, SilcClientEntry);
+    tmp = va_arg(va, char *);
+  
+    if (client_entry == conn->local_entry) {
+      printformat_module("fe-common/silc", server, NULL,
+                        MSGLEVEL_CRAP, SILCTXT_CHANNEL_KILLED_YOU, 
+                        tmp ? tmp : "");
+    } else {
+      list1 = nicklist_get_same_unique(SERVER(server), client_entry);
+      for (list_tmp = list1; list_tmp != NULL; list_tmp = 
+            list_tmp->next->next) {
+       CHANNEL_REC *channel = list_tmp->data;
+       NICK_REC *nickrec = list_tmp->next->data;
+       nicklist_remove(channel, nickrec);
+      }
+
+      printformat_module("fe-common/silc", server, NULL,
+                        MSGLEVEL_CRAP, SILCTXT_CHANNEL_KILLED, 
+                        client_entry->nickname,
+                        tmp ? tmp : "");
+    }
+    break;
+
+  case SILC_NOTIFY_TYPE_SERVER_SIGNOFF:
+    {
+      /*
+       * Server has quit the network.
+       */
+      int i;
+      SilcClientEntry *clients;
+      uint32 clients_count;
+
+      SILC_LOG_DEBUG(("Notify: SIGNOFF"));
+      
+      (void)va_arg(va, void *);
+      clients = va_arg(va, SilcClientEntry *);
+      clients_count = va_arg(va, uint32);
+  
+      for (i = 0; i < clients_count; i++) {
+       memset(userhost, 0, sizeof(userhost));
+       if (clients[i]->username)
+         snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
+                  clients[i]->username, clients[i]->hostname);
+       signal_emit("message quit", 4, server, clients[i]->nickname,
+                   clients[i]->username ? userhost : "", 
+                   "server signoff");
+
+       silc_server_free_ftp(server, clients[i]);
+       
+       list1 = nicklist_get_same_unique(SERVER(server), clients[i]);
+       for (list_tmp = list1; list_tmp != NULL; list_tmp = 
+              list_tmp->next->next) {
+         CHANNEL_REC *channel = list_tmp->data;
+         NICK_REC *nickrec = list_tmp->next->data;
+         nicklist_remove(channel, nickrec);
+       }
+      }
+    }
+    break;
+
+  default:
     /* Unknown notify */
     printformat_module("fe-common/silc", server, NULL,
                       MSGLEVEL_CRAP, SILCTXT_UNKNOWN_NOTIFY, type);
+    break;
   }
 
   va_end(va);
index e718e61a4d491b3dab91e219cf7de1802cb911e5..870c1f4343e1e862e36af5b9f2df353fa97dcf24 100644 (file)
@@ -105,9 +105,7 @@ static void sig_server_quit(SILC_SERVER_REC *server, const char *msg)
     silc_command_exec(server, "QUIT", msg);
 }
 
-/*
- * "event join". Joined to a channel.
- */
+/* Find Irssi channel entry by SILC channel entry */
 
 SILC_CHANNEL_REC *silc_channel_find_entry(SILC_SERVER_REC *server,
                                          SilcChannelEntry entry)
@@ -126,431 +124,6 @@ SILC_CHANNEL_REC *silc_channel_find_entry(SILC_SERVER_REC *server,
   return NULL;
 }
 
-static void event_join(SILC_SERVER_REC *server, va_list va)
-{
-  SILC_CHANNEL_REC *chanrec;
-  SILC_NICK_REC *nickrec;
-  SilcClientEntry client;
-  SilcChannelEntry channel;
-  char userhost[256];
-
-  client = va_arg(va, SilcClientEntry);
-  channel = va_arg(va, SilcChannelEntry);
-
-  if (client == server->conn->local_entry) {
-    /* You joined to channel */
-    chanrec = silc_channel_find(server, channel->channel_name);
-    if (chanrec != NULL && !chanrec->joined)
-      chanrec->entry = channel;
-  } else {
-    chanrec = silc_channel_find_entry(server, channel);
-    if (chanrec != NULL) {
-      SilcChannelUser chu = silc_client_on_channel(channel, client);
-      if (chu)
-       nickrec = silc_nicklist_insert(chanrec, chu, TRUE);
-    }
-  }
-
-  memset(userhost, 0, sizeof(userhost));
-  if (client->username)
-    snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
-            client->username, client->hostname);
-  signal_emit("message join", 4, server, channel->channel_name,
-             client->nickname,
-             client->username == NULL ? "" : userhost);
-}
-
-/*
- * "event leave". Left a channel.
- */
-
-static void event_leave(SILC_SERVER_REC *server, va_list va)
-{
-  SILC_CHANNEL_REC *chanrec;
-  SILC_NICK_REC *nickrec;
-  SilcClientEntry client;
-  SilcChannelEntry channel;
-  char userhost[256];
-
-  client = va_arg(va, SilcClientEntry);
-  channel = va_arg(va, SilcChannelEntry);
-
-  memset(userhost, 0, sizeof(userhost));
-  if (client->username)
-    snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
-            client->username, client->hostname);
-  signal_emit("message part", 5, server, channel->channel_name,
-             client->nickname,  client->username ?  userhost : "", 
-             client->nickname);
-
-  chanrec = silc_channel_find_entry(server, channel);
-  if (chanrec != NULL) {
-    nickrec = silc_nicklist_find(chanrec, client);
-    if (nickrec != NULL)
-      nicklist_remove(CHANNEL(chanrec), NICK(nickrec));
-  }
-}
-
-/*
- * "event signoff". Left the network.
- */
-
-static void event_signoff(SILC_SERVER_REC *server, va_list va)
-{
-  SilcClientEntry client;
-  GSList *nicks, *tmp;
-  char *message;
-  char userhost[256];
-
-  client = va_arg(va, SilcClientEntry);
-  message = va_arg(va, char *);
-
-  silc_server_free_ftp(server, client);
-
-  memset(userhost, 0, sizeof(userhost));
-  if (client->username)
-    snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
-            client->username, client->hostname);
-  signal_emit("message quit", 4, server, client->nickname,
-             client->username ? userhost : "", 
-             message ? message : "");
-
-  nicks = nicklist_get_same_unique(SERVER(server), client);
-  for (tmp = nicks; tmp != NULL; tmp = tmp->next->next) {
-    CHANNEL_REC *channel = tmp->data;
-    NICK_REC *nickrec = tmp->next->data;
-    
-    nicklist_remove(channel, nickrec);
-  }
-}
-
-/*
- * "event topic". Changed topic.
- */
-
-static void event_topic(SILC_SERVER_REC *server, va_list va)
-{
-  SILC_CHANNEL_REC *chanrec;
-  void *entry;
-  SilcClientEntry client;
-  SilcServerEntry server_entry;
-  SilcChannelEntry channel;
-  char *topic;
-  char userhost[256];
-  SilcIdType idtype;
-
-  idtype = va_arg(va, int);
-  entry = va_arg(va, void *);
-  topic = va_arg(va, char *);
-  channel = va_arg(va, SilcChannelEntry);
-
-  chanrec = silc_channel_find_entry(server, channel);
-  if (chanrec != NULL) {
-    g_free_not_null(chanrec->topic);
-    chanrec->topic = *topic == '\0' ? NULL : g_strdup(topic);
-    signal_emit("channel topic changed", 1, chanrec);
-  }
-
-  if (idtype == SILC_ID_CLIENT) {
-    client = (SilcClientEntry)entry;
-    memset(userhost, 0, sizeof(userhost));
-    snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
-            client->username, client->hostname);
-    signal_emit("message topic", 5, server, channel->channel_name,
-               topic, client->nickname, userhost);
-  } else if (idtype == SILC_ID_SERVER) {
-    server_entry = (SilcServerEntry)entry;
-    signal_emit("message topic", 5, server, channel->channel_name,
-               topic, server_entry->server_name, 
-               server_entry->server_name);
-  } else {
-    channel = (SilcChannelEntry)entry;
-    signal_emit("message topic", 5, server, channel->channel_name,
-               topic, channel->channel_name, channel->channel_name);
-  }
-}
-
-/*
- * "event invite". Invited or modified invite list.
- */
-
-static void event_invite(SILC_SERVER_REC *server, va_list va)
-{
-  SilcClientEntry client;
-  SilcChannelEntry channel;
-  char *channel_name;
-  char userhost[256];
-  
-  channel = va_arg(va, SilcChannelEntry);
-  channel_name = va_arg(va, char *);
-  client = va_arg(va, SilcClientEntry);
-
-  memset(userhost, 0, sizeof(userhost));
-  snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
-          client->username, client->hostname);
-  signal_emit("message invite", 4, server, channel ? channel->channel_name :
-             channel_name, client->nickname, userhost);
-}
-
-/*
- * "event nick". Changed nickname.
- */
-
-static void event_nick(SILC_SERVER_REC *server, va_list va)
-{
-  SilcClientEntry oldclient, newclient;
-  char userhost[256];
-
-  oldclient = va_arg(va, SilcClientEntry);
-  newclient = va_arg(va, SilcClientEntry);
-
-  nicklist_rename_unique(SERVER(server),
-                        oldclient, oldclient->nickname,
-                        newclient, newclient->nickname);
-
-  memset(userhost, 0, sizeof(userhost));
-  snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
-          newclient->username, newclient->hostname);
-  signal_emit("message nick", 4, server, newclient->nickname, 
-             oldclient->nickname, userhost);
-}
-
-/*
- * "event cmode". Changed channel mode.
- */
-
-static void event_cmode(SILC_SERVER_REC *server, va_list va)
-{
-  SILC_CHANNEL_REC *chanrec;
-  void *entry;
-  SilcClientEntry client;
-  SilcServerEntry server_entry;
-  SilcChannelEntry channel;
-  char *mode;
-  uint32 modei;
-  SilcIdType idtype;
-
-  idtype = va_arg(va, int);
-  entry = va_arg(va, void *);
-  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->channel_key ? 
-                           channel->channel_key->cipher->name : "",
-                           channel->hmac ? 
-                           silc_hmac_get_name(channel->hmac) : "");
-
-  chanrec = silc_channel_find_entry(server, channel);
-  if (chanrec != NULL) {
-    g_free_not_null(chanrec->mode);
-    chanrec->mode = g_strdup(mode == NULL ? "" : mode);
-    signal_emit("channel mode changed", 1, chanrec);
-  }
-  
-  if (idtype == SILC_ID_CLIENT) {
-    client = (SilcClientEntry)entry;
-    printformat_module("fe-common/silc", server, channel->channel_name,
-                      MSGLEVEL_MODES, SILCTXT_CHANNEL_CMODE,
-                      channel->channel_name, mode ? mode : "removed all",
-                      client->nickname);
-  } else {
-    server_entry = (SilcServerEntry)entry;
-    printformat_module("fe-common/silc", server, channel->channel_name,
-                      MSGLEVEL_MODES, SILCTXT_CHANNEL_CMODE,
-                      channel->channel_name, mode ? mode : "removed all",
-                      server_entry->server_name);
-  }
-  
-  g_free(mode);
-}
-
-/*
- * "event cumode". Changed user's mode on channel.
- */
-
-static void event_cumode(SILC_SERVER_REC *server, va_list va)
-{
-  SILC_CHANNEL_REC *chanrec;
-  SilcClientEntry client, destclient;
-  SilcChannelEntry channel;
-  int mode;
-  char *modestr;
-  
-  client = va_arg(va, SilcClientEntry);
-  mode = va_arg(va, uint32);
-  destclient = va_arg(va, SilcClientEntry);
-  channel = va_arg(va, SilcChannelEntry);
-  
-  modestr = silc_client_chumode(mode);
-  chanrec = silc_channel_find_entry(server, channel);
-  if (chanrec != NULL) {
-    SILC_NICK_REC *nick;
-    
-    if (destclient == server->conn->local_entry) {
-      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;
-      nick->founder = (mode & SILC_CHANNEL_UMODE_CHANFO) != 0;
-      signal_emit("nick mode changed", 2, chanrec, nick);
-    }
-  }
-  
-  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);
-}
-
-/*
- * "event motd". Received MOTD.
- */
-
-static void event_motd(SILC_SERVER_REC *server, va_list va)
-{
-  char *text = va_arg(va, char *);
-
-  if (!settings_get_bool("skip_motd"))
-    printtext_multiline(server, NULL, MSGLEVEL_CRAP, "%s", text);
-}
-
-/*
- * "event channel_change". Channel ID has changed.
- */
-
-static void event_channel_change(SILC_SERVER_REC *server, va_list va)
-{
-  /* Nothing interesting to do */
-}
-
-/*
- * "event server_signoff". Server has quit the network.
- */
-
-static void event_server_signoff(SILC_SERVER_REC *server, va_list va)
-{
-  SilcClientEntry *clients;
-  uint32 clients_count;
-  int i;
-  char userhost[256];
-  
-  (void)va_arg(va, void *);
-  clients = va_arg(va, SilcClientEntry *);
-  clients_count = va_arg(va, uint32);
-  
-  for (i = 0; i < clients_count; i++) {
-    GSList *nicks, *tmp;
-
-    memset(userhost, 0, sizeof(userhost));
-    if (clients[i]->username)
-      snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
-              clients[i]->username, clients[i]->hostname);
-    signal_emit("message quit", 4, server, clients[i]->nickname,
-               clients[i]->username ? userhost : "", 
-               "server signoff");
-
-    silc_server_free_ftp(server, clients[i]);
-
-    nicks = nicklist_get_same_unique(SERVER(server), clients[i]);
-    for (tmp = nicks; tmp != NULL; tmp = tmp->next->next) {
-      CHANNEL_REC *channel = tmp->data;
-      NICK_REC *nickrec = tmp->next->data;
-      nicklist_remove(channel, nickrec);
-    }
-  }
-}
-
-/*
- * "event kick". Someone was kicked from channel.
- */
-
-static void event_kick(SILC_SERVER_REC *server, va_list va)
-{
-  SilcClientConnection conn = server->conn;
-  SilcClientEntry client_entry, kicker;
-  SilcChannelEntry channel_entry;
-  char *tmp;
-  SILC_CHANNEL_REC *chanrec;
-
-  client_entry = va_arg(va, SilcClientEntry);
-  tmp = va_arg(va, char *);
-  kicker = va_arg(va, SilcClientEntry);
-  channel_entry = va_arg(va, SilcChannelEntry);
-
-  chanrec = silc_channel_find_entry(server, channel_entry);
-  
-  if (client_entry == conn->local_entry) {
-    printformat_module("fe-common/silc", server, channel_entry->channel_name,
-                      MSGLEVEL_CRAP, SILCTXT_CHANNEL_KICKED_YOU, 
-                      kicker->nickname,
-                      channel_entry->channel_name, tmp ? tmp : "");
-    if (chanrec) {
-      chanrec->kicked = TRUE;
-      channel_destroy((CHANNEL_REC *)chanrec);
-    }
-  } else {
-    printformat_module("fe-common/silc", server, channel_entry->channel_name,
-                      MSGLEVEL_CRAP, SILCTXT_CHANNEL_KICKED, 
-                      client_entry->nickname,
-                      kicker->nickname,
-                      channel_entry->channel_name, tmp ? tmp : "");
-
-    if (chanrec) {
-      SILC_NICK_REC *nickrec = silc_nicklist_find(chanrec, client_entry);
-      if (nickrec != NULL)
-       nicklist_remove(CHANNEL(chanrec), NICK(nickrec));
-    }
-  }
-}
-
-/*
- * "event kill". Someone was killed from the network.
- */
-
-static void event_kill(SILC_SERVER_REC *server, va_list va)
-{
-  SilcClientConnection conn = server->conn;
-  SilcClientEntry client_entry;
-  char *tmp;
-
-  client_entry = va_arg(va, SilcClientEntry);
-  tmp = va_arg(va, char *);
-  
-  if (client_entry == conn->local_entry) {
-    printformat_module("fe-common/silc", server, NULL,
-                      MSGLEVEL_CRAP, SILCTXT_CHANNEL_KILLED_YOU, 
-                      tmp ? tmp : "");
-  } else {
-    GSList *nicks, *tmpn;
-    nicks = nicklist_get_same_unique(SERVER(server), client_entry);
-    for (tmpn = nicks; tmpn != NULL; tmpn = tmpn->next->next) {
-      CHANNEL_REC *channel = tmpn->data;
-      NICK_REC *nickrec = tmpn->next->data;
-      nicklist_remove(channel, nickrec);
-    }
-
-    printformat_module("fe-common/silc", server, NULL,
-                      MSGLEVEL_CRAP, SILCTXT_CHANNEL_KILLED, 
-                      client_entry->nickname,
-                      tmp ? tmp : "");
-  }
-}
-
 /* PART (LEAVE) command. */
 
 static void command_part(const char *data, SILC_SERVER_REC *server,
@@ -1250,9 +823,11 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
     printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
                       SILCTXT_KEY_AGREEMENT, argv[2]);
     internal->responder = TRUE;
-    silc_client_send_key_agreement(silc_client, conn, client_entry, hostname, 
-                                  bindhost, port, 120, keyagr_completion, 
-                                  internal);
+    silc_client_send_key_agreement(
+                          silc_client, conn, client_entry, hostname, 
+                          bindhost, port, 
+                          settings_get_int("key_exchange_timeout_secs"), 
+                          keyagr_completion, internal);
     if (!hostname)
       silc_free(internal);
     goto out;
@@ -1286,20 +861,6 @@ void silc_channels_init(void)
   signal_add("server connected", (SIGNAL_FUNC) sig_connected);
   signal_add("server quit", (SIGNAL_FUNC) sig_server_quit);
 
-  signal_add("silc event join", (SIGNAL_FUNC) event_join);
-  signal_add("silc event leave", (SIGNAL_FUNC) event_leave);
-  signal_add("silc event signoff", (SIGNAL_FUNC) event_signoff);
-  signal_add("silc event topic", (SIGNAL_FUNC) event_topic);
-  signal_add("silc event invite", (SIGNAL_FUNC) event_invite);
-  signal_add("silc event nick", (SIGNAL_FUNC) event_nick);
-  signal_add("silc event cmode", (SIGNAL_FUNC) event_cmode);
-  signal_add("silc event cumode", (SIGNAL_FUNC) event_cumode);
-  signal_add("silc event motd", (SIGNAL_FUNC) event_motd);
-  signal_add("silc event channel_change", (SIGNAL_FUNC) event_channel_change);
-  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);
-  
   command_bind("part", MODULE_NAME, (SIGNAL_FUNC) command_part);
   command_bind("me", MODULE_NAME, (SIGNAL_FUNC) command_me);
   command_bind("action", MODULE_NAME, (SIGNAL_FUNC) command_action);
@@ -1317,22 +878,6 @@ void silc_channels_deinit(void)
   signal_remove("server connected", (SIGNAL_FUNC) sig_connected);
   signal_remove("server quit", (SIGNAL_FUNC) sig_server_quit);
 
-  signal_remove("silc event join", (SIGNAL_FUNC) event_join);
-  signal_remove("silc event leave", (SIGNAL_FUNC) event_leave);
-  signal_remove("silc event signoff", (SIGNAL_FUNC) event_signoff);
-  signal_remove("silc event topic", (SIGNAL_FUNC) event_topic);
-  signal_remove("silc event invite", (SIGNAL_FUNC) event_invite);
-  signal_remove("silc event nick", (SIGNAL_FUNC) event_nick);
-  signal_remove("silc event cmode", (SIGNAL_FUNC) event_cmode);
-  signal_remove("silc event cumode", (SIGNAL_FUNC) event_cumode);
-  signal_remove("silc event motd", (SIGNAL_FUNC) event_motd);
-  signal_remove("silc event channel_change", 
-               (SIGNAL_FUNC) event_channel_change);
-  signal_remove("silc event server_signoff", 
-               (SIGNAL_FUNC) event_server_signoff);
-  signal_remove("silc event kick", (SIGNAL_FUNC) event_kick);
-  signal_remove("silc event kill", (SIGNAL_FUNC) event_kill);
-  
   command_unbind("part", (SIGNAL_FUNC) command_part);
   command_unbind("me", (SIGNAL_FUNC) command_me);
   command_unbind("action", (SIGNAL_FUNC) command_action);
index ddd1285283653f8c688ca5d3b01f22587ebe6c3b..a49973f429df5f64fd2c134465812ad440215ce2 100644 (file)
@@ -1469,6 +1469,18 @@ void silc_client_error_by_server(SilcClient client,
   silc_free(msg);
 }
 
+/* Auto-nicking callback to send NICK command to server. */
+
+SILC_TASK_CALLBACK(silc_client_send_auto_nick)
+{
+  SilcClientConnection conn = (SilcClientConnection)context;
+  SilcClient client = conn->client;
+
+  silc_client_command_send(client, conn, SILC_COMMAND_NICK, 
+                          ++conn->cmd_ident, 1, 1, 
+                          client->nickname, strlen(client->nickname));
+}
+
 /* Processes the received new Client ID from server. Old Client ID is
    deleted from cache and new one is added. */
 
@@ -1526,11 +1538,11 @@ void silc_client_receive_new_id(SilcClient client,
 
   if (connecting) {
     /* Send NICK command if the nickname was set by the application (and is
-       not same as the username). */
+       not same as the username). Send this with little timeout. */
     if (client->nickname && strcmp(client->nickname, client->username))
-      silc_client_command_send(client, conn, SILC_COMMAND_NICK, 
-                              ++conn->cmd_ident, 1, 1, 
-                              client->nickname, strlen(client->nickname));
+      silc_schedule_task_add(client->schedule, 0,
+                            silc_client_send_auto_nick, conn,
+                            1, 0, SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
 
     /* Issue INFO command to fetch the real server name and server information
        and other stuff. */