Tue Oct 3 21:22:00 CEST 2006 Jochen Eisinger <coffee@silcnet.org>
authorJochen Eisinger <coffee@silcnet.org>
Tue, 3 Oct 2006 19:24:08 +0000 (19:24 +0000)
committerJochen Eisinger <coffee@silcnet.org>
Tue, 3 Oct 2006 19:24:08 +0000 (19:24 +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 eb3f1721d834a779c04c51923c405d1949a410bc..cbd0df1c2fb531253e292f198348b231a785d8b5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,11 @@
+Tue Oct  3 21:22:00 CEST 2006  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 Oct  1 20:39:34 CEST 2006  Jochen Eisinger <coffee@silcnet.org>
 
        * Always return a valid username.  Affected file
index 9c8028b56393a761eeb467bd84688cecc5b3c090..160e86cb9ce1266f6325af2a519be610feff14c2 100644 (file)
@@ -113,7 +113,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++) {
@@ -121,7 +124,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->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 476205d450e0cfcf3c00b81e9f4da307873bf1b2..dcaf1d65519e9b716bf264c31fcac9532ac992f6 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"
@@ -399,8 +400,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;
-
-    g_string_sprintfa(chans, "%s,", channel->name);
+    CHANNEL_SETUP_REC *schannel;
+    
+    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)