diff options
-rw-r--r-- | src/core/wee-hook.c | 3 | ||||
-rw-r--r-- | src/gui/gui-bar-item.c | 6 | ||||
-rw-r--r-- | src/plugins/irc/irc-channel.c | 10 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 61 | ||||
-rw-r--r-- | src/plugins/irc/irc-nick.c | 43 | ||||
-rw-r--r-- | src/plugins/irc/irc-nick.h | 3 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 4 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 13 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.h | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-upgrade.c | 3 | ||||
-rw-r--r-- | src/plugins/irc/irc.c | 15 |
11 files changed, 97 insertions, 65 deletions
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index 0de375a52..e872f67c4 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -522,6 +522,9 @@ hook_timer (struct t_weechat_plugin *plugin, long interval, int align_second, struct t_hook_timer *new_hook_timer; struct timezone tz; + if (interval <= 0) + return NULL; + new_hook = malloc (sizeof (*new_hook)); if (!new_hook) return NULL; diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index 078e5515d..0061ccae0 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -1196,7 +1196,11 @@ gui_bar_item_default_buffer_nicklist (void *data, struct t_gui_bar_item *item, str_prefix[0] = ptr_nick->prefix; str_prefix[1] = '\0'; strcat (buf, str_prefix); - strcat (buf, GUI_COLOR_CUSTOM_BAR_FG); + config_file_search_with_string (ptr_nick->color, + NULL, NULL, &ptr_option, + NULL); + if (ptr_option) + strcat (buf, gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(ptr_option)))); strcat (buf, ptr_nick->name); } else diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index 9ca7f2501..9ec40406e 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -311,13 +311,10 @@ irc_channel_check_away (struct t_irc_server *server, */ void -irc_channel_set_away (struct t_irc_channel *channel, const char *nick, int is_away) +irc_channel_set_away (struct t_irc_channel *channel, const char *nick, + int is_away) { - (void) channel; - (void) nick; - (void) is_away; - - /*struct t_irc_nick *ptr_nick; + struct t_irc_nick *ptr_nick; if (channel->type == IRC_CHANNEL_TYPE_CHANNEL) { @@ -325,7 +322,6 @@ irc_channel_set_away (struct t_irc_channel *channel, const char *nick, int is_aw if (ptr_nick) irc_nick_set_away (channel, ptr_nick, is_away); } - */ } /* diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index db2e33a3f..240a6a842 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -146,8 +146,13 @@ irc_config_get_server_from_option_name (const char *name) */ void -irc_config_change_one_server_buffer () +irc_config_change_one_server_buffer (void *data, + struct t_config_option *option) { + /* make C compiler happy */ + (void) data; + (void) option; + if (weechat_config_boolean (irc_config_look_one_server_buffer)) irc_buffer_merge_servers (); else @@ -160,8 +165,13 @@ irc_config_change_one_server_buffer () */ void -irc_config_change_display_channel_modes () +irc_config_change_display_channel_modes (void *data, + struct t_config_option *option) { + /* make C compiler happy */ + (void) data; + (void) option; + weechat_bar_item_update ("buffer_name"); } @@ -171,8 +181,13 @@ irc_config_change_display_channel_modes () */ void -irc_config_change_smart_filter () +irc_config_change_smart_filter (void *data, + struct t_config_option *option) { + /* make C compiler happy */ + (void) data; + (void) option; + if (weechat_config_boolean (irc_config_look_smart_filter)) { weechat_printf (NULL, @@ -186,23 +201,30 @@ irc_config_change_smart_filter () */ void -irc_config_change_away_check () +irc_config_change_away_check (void *data, + struct t_config_option *option) { + /* make C compiler happy */ + (void) data; + (void) option; + if (irc_hook_timer_check_away) { weechat_unhook (irc_hook_timer_check_away); irc_hook_timer_check_away = NULL; } - if (weechat_config_integer (irc_config_network_away_check) == 0) + if (weechat_config_integer (irc_config_network_away_check) > 0) + { + irc_hook_timer_check_away = weechat_hook_timer (weechat_config_integer (irc_config_network_away_check) * 60 * 1000, + 0, 0, + &irc_server_timer_check_away_cb, + NULL); + } + else { /* reset away flag for all nicks/chans/servers */ - //irc_server_remove_away (); + irc_server_remove_away (); } - /*irc_hook_timer_check_away = weechat_hook_timer (weechat_config_integer (irc_config_irc_away_check) * 60 * 1000, - 0, - irc_server_timer_check_away, - NULL); - */ } /* @@ -211,8 +233,13 @@ irc_config_change_away_check () */ void -irc_config_change_log () +irc_config_change_log (void *data, + struct t_config_option *option) { + /* make C compiler happy */ + (void) data; + (void) option; + /*t_gui_buffer *ptr_buffer; t_irc_server *ptr_server; t_irc_channel *ptr_channel; @@ -1219,7 +1246,15 @@ irc_config_init () int irc_config_read () { - return weechat_config_read (irc_config_file); + int rc; + + rc = weechat_config_read (irc_config_file); + if (rc == WEECHAT_CONFIG_READ_OK) + { + irc_config_change_away_check (NULL, NULL); + } + + return rc; } /* diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index 96312fc58..65cd8a62e 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -181,7 +181,7 @@ struct t_irc_nick * irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel, const char *nick_name, int is_chanowner, int is_chanadmin, int is_chanadmin2, int is_op, int is_halfop, int has_voice, - int is_chanuser) + int is_chanuser, int is_away) { struct t_irc_nick *new_nick, *ptr_nick; char prefix, str_prefix_color[64]; @@ -208,6 +208,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel, IRC_NICK_SET_FLAG(ptr_nick, is_halfop, IRC_NICK_HALFOP); IRC_NICK_SET_FLAG(ptr_nick, has_voice, IRC_NICK_VOICE); IRC_NICK_SET_FLAG(ptr_nick, is_chanuser, IRC_NICK_CHANUSER); + IRC_NICK_SET_FLAG(ptr_nick, is_away, IRC_NICK_AWAY); /* add new nick in nicklist */ irc_nick_get_gui_infos (ptr_nick, &prefix, @@ -216,7 +217,9 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel, "weechat.color.nicklist_prefix%d", prefix_color); weechat_nicklist_add_nick (channel->buffer, ptr_group, - ptr_nick->name, "weechat.color.nicklist", + ptr_nick->name, + (is_away) ? + "weechat.color.nicklist_away" : "weechat.color.nicklist", prefix, str_prefix_color, 1); return ptr_nick; @@ -237,11 +240,12 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel, IRC_NICK_SET_FLAG(new_nick, is_halfop, IRC_NICK_HALFOP); IRC_NICK_SET_FLAG(new_nick, has_voice, IRC_NICK_VOICE); IRC_NICK_SET_FLAG(new_nick, is_chanuser, IRC_NICK_CHANUSER); + IRC_NICK_SET_FLAG(new_nick, is_away, IRC_NICK_AWAY); if (weechat_strcasecmp (new_nick->name, server->nick) == 0) new_nick->color = IRC_COLOR_CHAT_NICK_SELF; else new_nick->color = irc_nick_find_color (new_nick); - + /* add nick to end of list */ new_nick->prev_nick = channel->last_nick; if (channel->nicks) @@ -262,7 +266,9 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel, "weechat.color.nicklist_prefix%d", prefix_color); weechat_nicklist_add_nick (channel->buffer, ptr_group, - new_nick->name, "weechat.color.nicklist", + new_nick->name, + (is_away) ? + "weechat.color.nicklist_away" : "weechat.color.nicklist", prefix, str_prefix_color, 1); /* all is ok, return address of new nick */ @@ -348,7 +354,9 @@ irc_nick_set (struct t_irc_channel *channel, "weechat.color.nicklist_prefix%d", prefix_color); weechat_nicklist_add_nick (channel->buffer, ptr_group, - nick->name, "weechat.color.nicklist", + nick->name, + (nick->flags & IRC_NICK_AWAY) ? + "weechat.color.nicklist_away" : "weechat.color.nicklist", prefix, str_prefix_color, 1); } @@ -489,33 +497,16 @@ void irc_nick_set_away (struct t_irc_channel *channel, struct t_irc_nick *nick, int is_away) { - (void) channel; - (void) nick; - (void) is_away; - - /* - t_gui_nick *ptr_nick; - - if ((irc_cfg_irc_away_check > 0) - && ((irc_cfg_irc_away_check_max_nicks == 0) || - (channel->nicks_count <= irc_cfg_irc_away_check_max_nicks))) + if ((weechat_config_integer (irc_config_network_away_check) > 0) + && ((weechat_config_integer (irc_config_network_away_check_max_nicks) == 0) || + (channel->nicks_count <= weechat_config_integer (irc_config_network_away_check_max_nicks)))) { if (((is_away) && (!(nick->flags & IRC_NICK_AWAY))) || ((!is_away) && (nick->flags & IRC_NICK_AWAY))) { - IRC_NICK_SET_FLAG(nick, is_away, IRC_NICK_AWAY); - ptr_nick = gui_nicklist_search (channel->buffer, nick->nick); - if (ptr_nick) - gui_nicklist_update (channel->buffer, ptr_nick, NULL, - ptr_nick->sort_index, - (is_away) ? GUI_COLOR_NICKLIST_AWAY : - GUI_COLOR_NICKLIST, - ptr_nick->prefix, - ptr_nick->color_prefix); - gui_nicklist_draw (channel->buffer, 0, 0); + irc_nick_set (channel, nick, is_away, IRC_NICK_AWAY); } } - */ } /* diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h index 1e3ec41a2..501fdbc9e 100644 --- a/src/plugins/irc/irc-nick.h +++ b/src/plugins/irc/irc-nick.h @@ -63,7 +63,8 @@ extern struct t_irc_nick *irc_nick_new (struct t_irc_server *server, const char *nick_name, int is_chanowner, int is_chanadmin, int is_chanadmin2, int is_op, int is_halfop, - int has_voice, int is_chanuser); + int has_voice, int is_chanuser, + int is_away); extern void irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel, struct t_irc_nick *nick, const char *new_nick); diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 6a91259e2..1e7257609 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -332,7 +332,7 @@ irc_protocol_cmd_join (struct t_irc_server *server, const char *command, } /* add nick in channel */ - ptr_nick = irc_nick_new (server, ptr_channel, nick, 0, 0, 0, 0, 0, 0, 0); + ptr_nick = irc_nick_new (server, ptr_channel, nick, 0, 0, 0, 0, 0, 0, 0, 0); if (ptr_nick) ptr_nick->host = strdup (address); @@ -3713,7 +3713,7 @@ irc_protocol_cmd_353 (struct t_irc_server *server, const char *command, { if (!irc_nick_new (server, ptr_channel, pos_nick, is_chanowner, is_chanadmin, is_chanadmin2, - is_op, is_halfop, has_voice, is_chanuser)) + is_op, is_halfop, has_voice, is_chanuser, 0)) { weechat_printf (server->buffer, _("%s%s: cannot create nick \"%s\" " diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 4f9ea7916..3e298c0ab 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -1832,17 +1832,20 @@ irc_server_timer_cb (void *data) } /* - * irc_server_timer_check_away: timer called to check away on servers - * (according to option "irc_check_away") + * irc_server_timer_check_away_cb: timer called to check away on servers + * (according to option "irc_check_away") */ -void -irc_server_timer_check_away (void *empty) +int +irc_server_timer_check_away_cb (void *data) { - (void) empty; + /* make C compiler happy */ + (void) data; if (weechat_config_integer (irc_config_network_away_check) > 0) irc_server_check_away (); + + return WEECHAT_RC_OK; } /* diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h index 15fba5ed9..44a12eb13 100644 --- a/src/plugins/irc/irc-server.h +++ b/src/plugins/irc/irc-server.h @@ -185,6 +185,7 @@ extern void irc_server_auto_connect (int auto_connect); extern void irc_server_autojoin_channels (); extern int irc_server_recv_cb (void *arg_server); extern int irc_server_timer_cb (void *data); +extern int irc_server_timer_check_away_cb (void *data); extern void irc_server_outqueue_free_all (struct t_irc_server *server); extern int irc_server_get_channel_count (struct t_irc_server *server); extern int irc_server_get_pv_count (struct t_irc_server *server); diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c index c2a04000a..04c84b459 100644 --- a/src/plugins/irc/irc-upgrade.c +++ b/src/plugins/irc/irc-upgrade.c @@ -314,7 +314,8 @@ irc_upgrade_read_cb (int object_id, flags & IRC_NICK_OP, flags & IRC_NICK_HALFOP, flags & IRC_NICK_VOICE, - flags & IRC_NICK_CHANUSER); + flags & IRC_NICK_CHANUSER, + flags & IRC_NICK_AWAY); if (ptr_nick) { str = weechat_infolist_string (infolist, "host"); diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c index ae567ff26..07cafdc73 100644 --- a/src/plugins/irc/irc.c +++ b/src/plugins/irc/irc.c @@ -173,15 +173,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) irc_server_auto_connect (auto_connect); irc_hook_timer = weechat_hook_timer (1 * 1000, 0, 0, - &irc_server_timer_cb, NULL); - - /* - if (irc_cfg_irc_away_check != 0) - irc_hook_timer_check_away = weechat_hook_timer (irc_cfg_irc_away_check * 60 * 1000, - 0, - &irc_server_timer_check_away, - NULL); - */ + &irc_server_timer_cb, NULL); return WEECHAT_RC_OK; } @@ -196,6 +188,11 @@ weechat_plugin_end (struct t_weechat_plugin *plugin) /* make C compiler happy */ (void) plugin; + if (irc_hook_timer) + weechat_unhook (irc_hook_timer); + if (irc_hook_timer_check_away) + weechat_unhook (irc_hook_timer_check_away); + irc_config_write (); if (irc_signal_upgrade_received) |