Sun Mar 11 17:43:18 CET 2007 Jochen Eisinger <coffee@silcnet.org>
authorJochen Eisinger <coffee@silcnet.org>
Sun, 11 Mar 2007 16:44:12 +0000 (16:44 +0000)
committerJochen Eisinger <coffee@silcnet.org>
Sun, 11 Mar 2007 16:44:12 +0000 (16:44 +0000)
* When joining channels with a password given in the config file,
  use it.  Also use it when cycling (it would be better to get
  the password from the server, but this isn't possible in SILC).
  Affected files apps/irssi/src/silc/core/silc-servers.c,
  apps/irssi/src/silc/core/silc-channels.c

CHANGES
apps/irssi/src/silc/core/silc-channels.c
apps/irssi/src/silc/core/silc-servers.c

diff --git a/CHANGES b/CHANGES
index 183039dd1bdf2ae669637d95164376e785e94080..e30615e3e7ec33eff57f7a57e208441c5d8076f9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,11 @@
+Sun Mar 11 17:43:18 CET 2007  Jochen Eisinger <coffee@silcnet.org>
+
+       * When joining channels with a password given in the config file,
+         use it.  Also use it when cycling (it would be better to get
+         the password from the server, but this isn't possible in SILC).
+         Affected files apps/irssi/src/silc/core/silc-servers.c,
+         apps/irssi/src/silc/core/silc-channels.c
+
 Sun Mar 11 15:22:42 CET 2007  Jochen Eisinger <coffee@silcnet.org>
 
        * Import perl script for sign_messages from silc-plugin.  Affected
index 5cc7807c42696df88002e5ba76a75af8ba47e9f0..189b1c9a616f02ccfc492e8ba01ced9b6ed7dce9 100644 (file)
@@ -111,7 +111,10 @@ static void silc_channels_join(SILC_SERVER_REC *server,
                               const char *channels, int automatic)
 {
   char **list, **tmp;
+  char *channel, *key;
   SILC_CHANNEL_REC *chanrec;
+  CHANNEL_SETUP_REC *schannel;
+  GString *tmpstr;
 
   list = g_strsplit(channels, ",", -1);
   for (tmp = list; *tmp != NULL; tmp++) {
@@ -119,7 +122,25 @@ static void silc_channels_join(SILC_SERVER_REC *server,
     if (chanrec)
       continue;
 
-    silc_command_exec(server, "JOIN", *tmp);
+    channel = *tmp;
+    key = strchr(channel, ' ');
+    if (key != NULL) {
+      *key = '\0';
+      key++;
+    }
+    tmpstr = g_string_new(NULL);
+
+    schannel = channel_setup_find(channel, server->connrec->chatnet);
+    if (key && *key != '\0')
+      g_string_sprintfa(tmpstr, "%s %s", channel, key);
+    else if (schannel && schannel->password && schannel->password[0] != '\0')
+      g_string_sprintfa(tmpstr, "%s %s", channel, schannel->password);
+    else
+      g_string_sprintfa(tmpstr, "%s", channel);
+
+
+    silc_command_exec(server, "JOIN", tmpstr->str);
+    g_string_free(tmpstr, FALSE);
   }
 
   g_strfreev(list);
index b2317f8da2dece0001306ecc90596d5415a0da62..7f34ac9f2d1be12a8318b16b99782fa67d4fb311 100644 (file)
@@ -33,6 +33,7 @@
 #include "settings.h"
 
 #include "servers-setup.h"
+#include "channels-setup.h"
 
 #include "client_ops.h"
 #include "silc-servers.h"
@@ -534,8 +535,14 @@ char *silc_server_get_channels(SILC_SERVER_REC *server)
   chans = g_string_new(NULL);
   for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
     CHANNEL_REC *channel = tmp->data;
+    CHANNEL_SETUP_REC *schannel;
 
-    g_string_sprintfa(chans, "%s,", channel->name);
+    if ((schannel = channel_setup_find(channel->name, server->connrec->chatnet)) && 
+        schannel->password) 
+      g_string_sprintfa(chans, "%s %s,", channel->name,
+                       schannel->password);
+    else
+      g_string_sprintfa(chans, "%s,", channel->name);
   }
 
   if (chans->len > 0)