diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/irc/irc-channel.c | 20 | ||||
-rw-r--r-- | src/plugins/irc/irc-command.c | 29 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 21 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 35 |
4 files changed, 49 insertions, 56 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index 58e847d4d..b0bed60d7 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -475,7 +475,6 @@ irc_channel_create_buffer (struct t_irc_server *server, } if (channel_name_lower) { - weechat_hashtable_remove (server->join_manual, channel_name_lower); weechat_hashtable_remove (server->join_noswitch, channel_name_lower); free (channel_name_lower); } @@ -502,7 +501,8 @@ irc_channel_new (struct t_irc_server *server, int channel_type, { struct t_irc_channel *new_channel; struct t_gui_buffer *ptr_buffer; - const char *ptr_chanmode; + const char *ptr_chanmode, *ptr_channel_key; + char *channel_name_lower; /* create buffer for channel (or use existing one) */ ptr_buffer = irc_channel_create_buffer (server, channel_type, @@ -526,15 +526,15 @@ irc_channel_new (struct t_irc_server *server, int channel_type, new_channel->topic = NULL; new_channel->modes = NULL; new_channel->limit = 0; - if (weechat_hashtable_has_key (server->join_channel_key, channel_name)) + new_channel->key = NULL; + channel_name_lower = weechat_string_tolower (channel_name); + if (channel_name_lower) { - new_channel->key = strdup ( - weechat_hashtable_get (server->join_channel_key, channel_name)); - weechat_hashtable_remove (server->join_channel_key, channel_name); - } - else - { - new_channel->key = NULL; + ptr_channel_key = weechat_hashtable_get (server->join_channel_key, + channel_name_lower); + if (ptr_channel_key) + new_channel->key = strdup (ptr_channel_key); + free (channel_name_lower); } new_channel->join_msg_received = weechat_hashtable_new ( 32, diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 135a8f109..7e7058bc7 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -2872,8 +2872,8 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments, int manual_join, int noswitch) { char *new_args, **channels, **keys, *pos_space, *pos_keys, *pos_channel; - char *channel_name, *ptr_key; - int i, num_channels, num_keys, length, save_autojoin; + char *channel_name_lower; + int i, num_channels, num_keys, length; time_t time_now; struct t_irc_channel *ptr_channel; @@ -2886,9 +2886,6 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments, return; } - save_autojoin = IRC_SERVER_OPTION_BOOLEAN(server, - IRC_SERVER_OPTION_AUTOJOIN_DYNAMIC); - /* split channels and keys */ channels = NULL; num_channels = 0; @@ -2955,30 +2952,27 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments, strcat (new_args, irc_channel_get_auto_chantype (server, channels[i])); strcat (new_args, channels[i]); + channel_name_lower = weechat_string_tolower (pos_channel); if (manual_join || noswitch) { - channel_name = weechat_string_tolower (pos_channel); - if (channel_name) + if (channel_name_lower) { if (manual_join) { weechat_hashtable_set (server->join_manual, - channel_name, + channel_name_lower, &time_now); } if (noswitch) { weechat_hashtable_set (server->join_noswitch, - channel_name, + channel_name_lower, &time_now); } - free (channel_name); } } - ptr_key = NULL; if (keys && (i < num_keys)) { - ptr_key = keys[i]; ptr_channel = irc_channel_search (server, pos_channel); if (ptr_channel) { @@ -2986,10 +2980,10 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments, free (ptr_channel->key); ptr_channel->key = strdup (keys[i]); } - else + else if (channel_name_lower) { weechat_hashtable_set (server->join_channel_key, - pos_channel, keys[i]); + channel_name_lower, keys[i]); } } if (manual_join @@ -3006,12 +3000,9 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments, server, IRC_CHANNEL_TYPE_CHANNEL, pos_channel, 1, 1); } - if (save_autojoin) - { - irc_join_add_channel_to_autojoin (server, pos_channel, - ptr_key); - } } + if (channel_name_lower) + free (channel_name_lower); } if (pos_space) strcat (new_args, pos_space); diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 22b1f3614..52bb8f0ff 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -1710,7 +1710,7 @@ IRC_PROTOCOL_CALLBACK(join) struct t_irc_nick *ptr_nick; struct t_irc_channel_speaking *ptr_nick_speaking; const char *pos_account, *pos_realname; - char str_account[512], str_realname[512]; + char str_account[512], str_realname[512], *channel_name_lower; int local_join, display_host, smart_filter; IRC_PROTOCOL_MIN_PARAMS(1); @@ -1871,6 +1871,25 @@ IRC_PROTOCOL_CALLBACK(join) { irc_server_set_host (server, address); irc_bar_item_update_channel (); + + /* add channel to autojoin option (on manual join only) */ + channel_name_lower = weechat_string_tolower (params[0]); + if (channel_name_lower) + { + if (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTOJOIN_DYNAMIC) + && weechat_hashtable_has_key (server->join_manual, + channel_name_lower)) + { + irc_join_add_channel_to_autojoin ( + server, + params[0], + weechat_hashtable_get (server->join_channel_key, + channel_name_lower)); + } + weechat_hashtable_remove (server->join_manual, channel_name_lower); + weechat_hashtable_remove (server->join_channel_key, channel_name_lower); + free (channel_name_lower); + } } return WEECHAT_RC_OK; diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 525e3a603..e76627007 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -3863,31 +3863,14 @@ irc_server_timer_sasl_cb (const void *pointer, void *data, int remaining_calls) } /* - * Callback called for each manual join of a server: deletes old channels in the - * hashtable. + * Callback called for each channel: remove old key from the hashtable if it's + * too old. */ void -irc_server_check_join_manual_cb (void *data, - struct t_hashtable *hashtable, - const void *key, const void *value) -{ - /* make C compiler happy */ - (void) data; - - if (*((time_t *)value) + (60 * 10) < time (NULL)) - weechat_hashtable_remove (hashtable, key); -} - -/* - * Callback called for each join without switch of a server: deletes old channel - * in the hashtable. - */ - -void -irc_server_check_join_noswitch_cb (void *data, - struct t_hashtable *hashtable, - const void *key, const void *value) +irc_server_check_channel_cb (void *data, + struct t_hashtable *hashtable, + const void *key, const void *value) { /* make C compiler happy */ (void) data; @@ -4101,11 +4084,11 @@ irc_server_timer_cb (const void *pointer, void *data, int remaining_calls) if (current_time > ptr_server->last_data_purge + (60 * 10)) { weechat_hashtable_map (ptr_server->join_manual, - &irc_server_check_join_manual_cb, - NULL); + &irc_server_check_channel_cb, NULL); + weechat_hashtable_map (ptr_server->join_channel_key, + &irc_server_check_channel_cb, NULL); weechat_hashtable_map (ptr_server->join_noswitch, - &irc_server_check_join_noswitch_cb, - NULL); + &irc_server_check_channel_cb, NULL); for (ptr_channel = ptr_server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { |