Fix option irc.network.away_check

This commit is contained in:
Sebastien Helleu 2008-10-26 20:00:50 +01:00
parent b5730ec025
commit f126daa896
11 changed files with 97 additions and 65 deletions

View File

@ -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;

View File

@ -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

View File

@ -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);
}
*/
}
/*

View File

@ -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;
}
/*

View File

@ -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);
}
}
*/
}
/*

View File

@ -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);

View File

@ -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\" "

View File

@ -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;
}
/*

View File

@ -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);

View File

@ -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");

View File

@ -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)