summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Boström <pbos@kth.se>2012-09-18 18:08:21 +0200
committerSebastien Helleu <flashcode@flashtux.org>2012-09-18 18:08:21 +0200
commita80635c8b2329bc2cdc5192c2e2be61d43a320d6 (patch)
tree0ccda663b62b521fd7ed47a8eeaa2d9fb26f8313
parentb5f7c124ea73d480b76ee3e339237c12a0ebcaf4 (diff)
downloadweechat-a80635c8b2329bc2cdc5192c2e2be61d43a320d6.zip
irc: fix rejoin of channels with a key, ignore value "*" sent by server for key (bug #24131)
-rw-r--r--ChangeLog4
-rw-r--r--doc/de/autogen/plugin_api/hdata.txt1
-rw-r--r--doc/en/autogen/plugin_api/hdata.txt1
-rw-r--r--doc/fr/autogen/plugin_api/hdata.txt1
-rw-r--r--doc/it/autogen/plugin_api/hdata.txt1
-rw-r--r--doc/ja/autogen/plugin_api/hdata.txt1
-rw-r--r--src/plugins/irc/irc-channel.c11
-rw-r--r--src/plugins/irc/irc-command.c36
-rw-r--r--src/plugins/irc/irc-mode.c15
-rw-r--r--src/plugins/irc/irc-server.c13
-rw-r--r--src/plugins/irc/irc-server.h1
11 files changed, 76 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 6f99911f8..82c9f5d7f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
-v0.3.9-rc1, 2012-09-17
+v0.3.9-rc1, 2012-09-18
Version 0.3.9 (under dev!)
@@ -68,6 +68,8 @@ Version 0.3.9 (under dev!)
* fifo: ignore read failing with error EAGAIN (bug #37019)
* guile: fix crash when unloading a script without pointer to interpreter
* guile: fix path of guile include dirs in cmake build (patch #7790)
+* irc: fix rejoin of channels with a key, ignore value "*" sent by server for
+ key (bug #24131)
* irc: fix SASL mechanism "external" (bug #37274)
* irc: fix parsing of message 346 when no nick/time are given (bug #37266)
* irc: switch to next address after a timeout when connecting to server
diff --git a/doc/de/autogen/plugin_api/hdata.txt b/doc/de/autogen/plugin_api/hdata.txt
index f953f3453..9e43e1739 100644
--- a/doc/de/autogen/plugin_api/hdata.txt
+++ b/doc/de/autogen/plugin_api/hdata.txt
@@ -189,6 +189,7 @@
'notify_list' (pointer, hdata: "irc_notify") +
'last_notify' (pointer, hdata: "irc_notify") +
'manual_joins' (hashtable) +
+ 'channel_join_key' (hashtable) +
'buffer' (pointer, hdata: "buffer") +
'buffer_as_string' (string) +
'channels' (pointer, hdata: "irc_channel") +
diff --git a/doc/en/autogen/plugin_api/hdata.txt b/doc/en/autogen/plugin_api/hdata.txt
index ef3435557..cb5887d6b 100644
--- a/doc/en/autogen/plugin_api/hdata.txt
+++ b/doc/en/autogen/plugin_api/hdata.txt
@@ -189,6 +189,7 @@
'notify_list' (pointer, hdata: "irc_notify") +
'last_notify' (pointer, hdata: "irc_notify") +
'manual_joins' (hashtable) +
+ 'channel_join_key' (hashtable) +
'buffer' (pointer, hdata: "buffer") +
'buffer_as_string' (string) +
'channels' (pointer, hdata: "irc_channel") +
diff --git a/doc/fr/autogen/plugin_api/hdata.txt b/doc/fr/autogen/plugin_api/hdata.txt
index 15a2fc6c6..f74739214 100644
--- a/doc/fr/autogen/plugin_api/hdata.txt
+++ b/doc/fr/autogen/plugin_api/hdata.txt
@@ -189,6 +189,7 @@
'notify_list' (pointer, hdata: "irc_notify") +
'last_notify' (pointer, hdata: "irc_notify") +
'manual_joins' (hashtable) +
+ 'channel_join_key' (hashtable) +
'buffer' (pointer, hdata: "buffer") +
'buffer_as_string' (string) +
'channels' (pointer, hdata: "irc_channel") +
diff --git a/doc/it/autogen/plugin_api/hdata.txt b/doc/it/autogen/plugin_api/hdata.txt
index 8a04b30bf..a6c487d15 100644
--- a/doc/it/autogen/plugin_api/hdata.txt
+++ b/doc/it/autogen/plugin_api/hdata.txt
@@ -189,6 +189,7 @@
'notify_list' (pointer, hdata: "irc_notify") +
'last_notify' (pointer, hdata: "irc_notify") +
'manual_joins' (hashtable) +
+ 'channel_join_key' (hashtable) +
'buffer' (pointer, hdata: "buffer") +
'buffer_as_string' (string) +
'channels' (pointer, hdata: "irc_channel") +
diff --git a/doc/ja/autogen/plugin_api/hdata.txt b/doc/ja/autogen/plugin_api/hdata.txt
index 9061f28bc..e62c79bf0 100644
--- a/doc/ja/autogen/plugin_api/hdata.txt
+++ b/doc/ja/autogen/plugin_api/hdata.txt
@@ -189,6 +189,7 @@
'notify_list' (pointer, hdata: "irc_notify") +
'last_notify' (pointer, hdata: "irc_notify") +
'manual_joins' (hashtable) +
+ 'channel_join_key' (hashtable) +
'buffer' (pointer, hdata: "buffer") +
'buffer_as_string' (string) +
'channels' (pointer, hdata: "irc_channel") +
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index 638b92ac7..2fcf4bae6 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -265,7 +265,16 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
new_channel->topic = NULL;
new_channel->modes = NULL;
new_channel->limit = 0;
- new_channel->key = NULL;
+ if (weechat_hashtable_has_key (server->channel_join_key, channel_name))
+ {
+ new_channel->key = strdup (weechat_hashtable_get (server->channel_join_key,
+ channel_name));
+ weechat_hashtable_remove (server->channel_join_key, channel_name);
+ }
+ else
+ {
+ new_channel->key = NULL;
+ }
new_channel->names_received = 0;
new_channel->checking_away = 0;
new_channel->away_message = NULL;
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index a8463732a..319976a4b 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -1858,8 +1858,8 @@ void
irc_command_join_server (struct t_irc_server *server, const char *arguments,
int manual_join)
{
- char *new_args, **channels, *pos_space;
- int i, num_channels, length;
+ char *new_args, **channels, **keys, *pos_space, *pos_keys, *pos_channel;
+ int i, num_channels, num_keys, length;
int time_now;
struct t_irc_channel *ptr_channel;
@@ -1873,13 +1873,27 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments,
return;
}
- /* split channels */
+ /* split channels and keys */
channels = NULL;
+ num_channels = 0;
+ keys = NULL;
+ num_keys = 0;
pos_space = strchr (arguments, ' ');
+ pos_keys = NULL;
if (pos_space)
+ {
new_args = weechat_strndup (arguments, pos_space - arguments);
+ pos_keys = pos_space + 1;
+ while (pos_keys[0] == ' ')
+ {
+ pos_keys++;
+ }
+ if (pos_keys[0])
+ keys = weechat_string_split (pos_keys, ",", 0, 0, &num_keys);
+ }
else
new_args = strdup (arguments);
+
if (new_args)
{
channels = weechat_string_split (new_args, ",", 0, 0,
@@ -1916,6 +1930,7 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments,
{
if (i > 0)
strcat (new_args, ",");
+ pos_channel = new_args + strlen (new_args);
if (((num_channels > 1) || (strcmp (channels[i], "0") != 0))
&& !irc_channel_is_channel (server, channels[i]))
{
@@ -1929,6 +1944,21 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments,
channels[i],
&time_now);
}
+ if (keys && (i < num_keys))
+ {
+ ptr_channel = irc_channel_search (server, pos_channel);
+ if (ptr_channel)
+ {
+ if (ptr_channel->key)
+ free (ptr_channel->key);
+ ptr_channel->key = strdup (keys[i]);
+ }
+ else
+ {
+ weechat_hashtable_set (server->channel_join_key,
+ pos_channel, keys[i]);
+ }
+ }
}
if (pos_space)
strcat (new_args, pos_space);
diff --git a/src/plugins/irc/irc-mode.c b/src/plugins/irc/irc-mode.c
index 39faa7b83..6ca1efef2 100644
--- a/src/plugins/irc/irc-mode.c
+++ b/src/plugins/irc/irc-mode.c
@@ -345,13 +345,20 @@ irc_mode_channel_set (struct t_irc_server *server,
if (pos[0] == 'k')
{
/* channel key */
- if (channel->key)
+ if (set_flag == '-')
{
- free (channel->key);
- channel->key = NULL;
+ if (channel->key)
+ {
+ free (channel->key);
+ channel->key = NULL;
+ }
}
- if ((set_flag == '+') && ptr_arg)
+ else if ((set_flag == '+')
+ && ptr_arg && (strcmp (ptr_arg, "*") != 0))
{
+ /* replace key for +k, but ignore "*" as new key */
+ if (channel->key)
+ free (channel->key);
channel->key = strdup (ptr_arg);
}
}
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 764d19acb..55d8fdd6f 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -916,6 +916,11 @@ irc_server_alloc (const char *name)
WEECHAT_HASHTABLE_INTEGER,
NULL,
NULL);
+ new_server->channel_join_key = weechat_hashtable_new (4,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
new_server->buffer = NULL;
new_server->buffer_as_string = NULL;
new_server->channels = NULL;
@@ -1363,6 +1368,7 @@ irc_server_free_data (struct t_irc_server *server)
}
irc_notify_free_all (server);
weechat_hashtable_free (server->manual_joins);
+ weechat_hashtable_free (server->channel_join_key);
irc_redirect_free_all (server);
if (server->channels)
irc_channel_free_all (server);
@@ -2817,6 +2823,9 @@ irc_server_close_connection (struct t_irc_server *server)
/* remove all manual joins */
weechat_hashtable_remove_all (server->manual_joins);
+ /* remove all keys for pending joins */
+ weechat_hashtable_remove_all (server->channel_join_key);
+
/* server is now disconnected */
server->is_connected = 0;
server->ssl_connected = 0;
@@ -4442,6 +4451,7 @@ irc_server_hdata_server_cb (void *data, const char *hdata_name)
WEECHAT_HDATA_VAR(struct t_irc_server, notify_list, POINTER, 0, NULL, "irc_notify");
WEECHAT_HDATA_VAR(struct t_irc_server, last_notify, POINTER, 0, NULL, "irc_notify");
WEECHAT_HDATA_VAR(struct t_irc_server, manual_joins, HASHTABLE, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_server, channel_join_key, HASHTABLE, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, buffer, POINTER, 0, NULL, "buffer");
WEECHAT_HDATA_VAR(struct t_irc_server, buffer_as_string, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, channels, POINTER, 0, NULL, "irc_channel");
@@ -4962,6 +4972,9 @@ irc_server_print_log ()
weechat_log_printf (" manual_joins . . . . : 0x%lx (hashtable: '%s')",
ptr_server->manual_joins,
weechat_hashtable_get_string (ptr_server->manual_joins, "keys_values"));
+ weechat_log_printf (" channel_join_key . . : 0x%lx (hashtable: '%s')",
+ ptr_server->channel_join_key,
+ weechat_hashtable_get_string (ptr_server->channel_join_key, "keys_values"));
weechat_log_printf (" buffer . . . . . . . : 0x%lx", ptr_server->buffer);
weechat_log_printf (" buffer_as_string . . : 0x%lx", ptr_server->buffer_as_string);
weechat_log_printf (" channels . . . . . . : 0x%lx", ptr_server->channels);
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index 09856a160..1dfddf764 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -197,6 +197,7 @@ struct t_irc_server
struct t_irc_notify *notify_list; /* list of notify */
struct t_irc_notify *last_notify; /* last notify */
struct t_hashtable *manual_joins; /* manual joins pending */
+ struct t_hashtable *channel_join_key; /* keys pending for joins */
struct t_gui_buffer *buffer; /* GUI buffer allocated for server */
char *buffer_as_string; /* used to return buffer info */
struct t_irc_channel *channels; /* opened channels on server */