mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
irc: fix rejoin of channels with a key, ignore value "*" sent by server for key (bug #24131)
This commit is contained in:
committed by
Sebastien Helleu
parent
b5f7c124ea
commit
a80635c8b2
@@ -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
|
||||
|
||||
@@ -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") +
|
||||
|
||||
@@ -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") +
|
||||
|
||||
@@ -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") +
|
||||
|
||||
@@ -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") +
|
||||
|
||||
@@ -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") +
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user