1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 10:05:42 +02:00

Merge remote-tracking branch 'origin/pr/246' into irc-account-notify

This commit is contained in:
Sébastien Helleu
2015-01-25 14:56:47 +01:00
8 changed files with 215 additions and 23 deletions
+32 -9
View File
@@ -463,7 +463,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
new_channel->checking_away = 0;
new_channel->checking_whox = 0;
new_channel->away_message = NULL;
new_channel->has_quit_server = 0;
new_channel->cycle = 0;
@@ -678,6 +678,25 @@ irc_channel_get_auto_chantype (struct t_irc_server *server,
return chantype;
}
/*
* Removes account for all nicks on a channel.
*/
void
irc_channel_remove_account (struct t_irc_server *server,
struct t_irc_channel *channel)
{
struct t_irc_nick *ptr_nick;
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
{
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
{
ptr_nick->account = strdup ("*");
}
}
}
/*
* Removes away for all nicks on a channel.
*/
@@ -698,26 +717,30 @@ irc_channel_remove_away (struct t_irc_server *server,
}
/*
* Checks for away on a channel.
* Checks for WHOX information on a channel.
*/
void
irc_channel_check_away (struct t_irc_server *server,
irc_channel_check_whox (struct t_irc_server *server,
struct t_irc_channel *channel)
{
if ((channel->type == IRC_CHANNEL_TYPE_CHANNEL) && channel->nicks)
{
if (server->cap_away_notify
|| server->cap_account_notify
|| ((IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK) > 0)
&& ((IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS) == 0)
|| (channel->nicks_count <= IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS)))))
{
channel->checking_away++;
channel->checking_whox++;
irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL,
"WHO %s", channel->name);
"WHO %s %%cuhsnfdar", channel->name);
}
else
irc_channel_remove_away (server, channel);
{
irc_channel_remove_account(server, channel);
irc_channel_remove_away(server, channel);
}
}
}
@@ -1456,7 +1479,7 @@ irc_channel_hdata_channel_cb (void *data, const char *hdata_name)
WEECHAT_HDATA_VAR(struct t_irc_channel, limit, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_channel, key, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_channel, join_msg_received, HASHTABLE, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_channel, checking_away, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_channel, checking_whox, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_channel, away_message, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_channel, has_quit_server, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_channel, cycle, INTEGER, 0, NULL, NULL);
@@ -1553,7 +1576,7 @@ irc_channel_add_to_infolist (struct t_infolist *infolist,
if (!weechat_infolist_new_var_string (ptr_item, "join_msg_received",
weechat_hashtable_get_string (channel->join_msg_received, "keys")))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "checking_away", channel->checking_away))
if (!weechat_infolist_new_var_integer (ptr_item, "checking_whox", channel->checking_whox))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "away_message", channel->away_message))
return 0;
@@ -1637,7 +1660,7 @@ irc_channel_print_log (struct t_irc_channel *channel)
channel->join_msg_received,
weechat_hashtable_get_string (channel->join_msg_received,
"keys_values"));
weechat_log_printf (" checking_away. . . . . . : %d", channel->checking_away);
weechat_log_printf (" checking_whox. . . . . . : %d", channel->checking_whox);
weechat_log_printf (" away_message . . . . . . : '%s'", channel->away_message);
weechat_log_printf (" has_quit_server. . . . . : %d", channel->has_quit_server);
weechat_log_printf (" cycle. . . . . . . . . . : %d", channel->cycle);
+4 -2
View File
@@ -50,7 +50,7 @@ struct t_irc_channel
struct t_hashtable *join_msg_received; /* messages received after join: */
/* 353=names, 366=names count, */
/* 332/333=topic, 329=creation date */
int checking_away; /* = 1 if checking away with WHO cmd */
int checking_whox; /* = 1 if checking WHOX */
char *away_message; /* to display away only once in pv */
int has_quit_server; /* =1 if nick has quit (pv only), to */
/* display message when he's back */
@@ -107,9 +107,11 @@ extern int irc_channel_is_channel (struct t_irc_server *server,
const char *string);
extern const char *irc_channel_get_auto_chantype (struct t_irc_server *server,
const char *channel_name);
extern void irc_channel_remove_account (struct t_irc_server *server,
struct t_irc_channel *channel);
extern void irc_channel_remove_away (struct t_irc_server *server,
struct t_irc_channel *channel);
extern void irc_channel_check_away (struct t_irc_server *server,
extern void irc_channel_check_whox (struct t_irc_server *server,
struct t_irc_channel *channel);
extern void irc_channel_set_away (struct t_irc_server *server,
struct t_irc_channel *channel,
+12 -1
View File
@@ -624,7 +624,7 @@ irc_nick_nicklist_set_color_all ()
struct t_irc_nick *
irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
const char *nickname, const char *host, const char *prefixes,
int away)
int away, char *account)
{
struct t_irc_nick *new_nick, *ptr_nick;
int length;
@@ -642,12 +642,16 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
/* save away status from existing nick (before removing it) */
away = ptr_nick->away;
/* save account from existing nick (before removing it) */
account = ptr_nick->account;
/* remove old nick from nicklist */
irc_nick_nicklist_remove (server, channel, ptr_nick);
/* update nick */
irc_nick_set_prefixes (server, ptr_nick, prefixes);
ptr_nick->away = away;
ptr_nick->account = account;
/* add new nick in nicklist */
irc_nick_nicklist_add (server, channel, ptr_nick);
@@ -662,6 +666,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
/* initialize new nick */
new_nick->name = strdup (nickname);
new_nick->host = (host) ? strdup (host) : NULL;
new_nick->account = (account) ? strdup (account) : NULL;
length = strlen (irc_server_get_prefix_chars (server));
new_nick->prefixes = malloc (length + 1);
if (!new_nick->name || !new_nick->prefixes)
@@ -670,6 +675,8 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
free (new_nick->name);
if (new_nick->host)
free (new_nick->host);
if (new_nick->account)
free (new_nick->account);
if (new_nick->prefixes)
free (new_nick->prefixes);
free (new_nick);
@@ -810,6 +817,8 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel,
free (nick->host);
if (nick->prefixes)
free (nick->prefixes);
if (nick->account)
free (nick->account);
if (nick->color)
free (nick->color);
@@ -1167,6 +1176,8 @@ irc_nick_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "away", nick->away))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "account", nick->account))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "color", nick->color))
return 0;
+3 -1
View File
@@ -38,6 +38,7 @@ struct t_irc_nick
char prefix[2]; /* current prefix (higher prefix set in */
/* prefixes) */
int away; /* 1 if nick is away */
char *account; /* account name of the user */
char *color; /* color for nickname */
struct t_irc_nick *prev_nick; /* link to previous nick on channel */
struct t_irc_nick *next_nick; /* link to next nick on channel */
@@ -64,7 +65,8 @@ extern struct t_irc_nick *irc_nick_new (struct t_irc_server *server,
const char *nickname,
const char *host,
const char *prefixes,
int away);
int away,
char *account);
extern void irc_nick_change (struct t_irc_server *server,
struct t_irc_channel *channel,
struct t_irc_nick *nick, const char *new_nick);
File diff suppressed because it is too large Load Diff
+7 -1
View File
@@ -993,6 +993,7 @@ irc_server_alloc (const char *name)
new_server->nick = NULL;
new_server->nick_modes = NULL;
new_server->cap_away_notify = 0;
new_server->cap_account_notify = 0;
new_server->isupport = NULL;
new_server->prefix_modes = NULL;
new_server->prefix_chars = NULL;
@@ -4525,6 +4526,7 @@ irc_server_disconnect (struct t_irc_server *server, int switch_address,
weechat_bar_item_update ("irc_nick_modes");
}
server->cap_away_notify = 0;
server->cap_account_notify = 0;
server->is_away = 0;
server->away_time = 0;
server->lag = 0;
@@ -4795,7 +4797,7 @@ irc_server_check_away (struct t_irc_server *server)
ptr_channel = ptr_channel->next_channel)
{
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
irc_channel_check_away (server, ptr_channel);
irc_channel_check_whox (server, ptr_channel);
}
server->last_away_check = time (NULL);
}
@@ -5106,6 +5108,7 @@ irc_server_hdata_server_cb (void *data, const char *hdata_name)
WEECHAT_HDATA_VAR(struct t_irc_server, nick, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, nick_modes, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, cap_away_notify, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, cap_account_notify, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, isupport, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, prefix_modes, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, prefix_chars, STRING, 0, NULL, NULL);
@@ -5322,6 +5325,8 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "cap_away_notify", server->cap_away_notify))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "cap_account_notify", server->cap_account_notify))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "isupport", server->isupport))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "prefix_modes", server->prefix_modes))
@@ -5682,6 +5687,7 @@ irc_server_print_log ()
weechat_log_printf (" nick . . . . . . . . : '%s'", ptr_server->nick);
weechat_log_printf (" nick_modes . . . . . : '%s'", ptr_server->nick_modes);
weechat_log_printf (" cap_away_notify. . . : %d", ptr_server->cap_away_notify);
weechat_log_printf (" cap_account_notify . : %d", ptr_server->cap_account_notify);
weechat_log_printf (" isupport . . . . . . : '%s'", ptr_server->isupport);
weechat_log_printf (" prefix_modes . . . . : '%s'", ptr_server->prefix_modes);
weechat_log_printf (" prefix_chars . . . . : '%s'", ptr_server->prefix_chars);
+1
View File
@@ -185,6 +185,7 @@ struct t_irc_server
char *nick; /* current nickname */
char *nick_modes; /* nick modes */
int cap_away_notify; /* 1 if capability away-notify is enabled*/
int cap_account_notify; /* 1 if CAP account-notify is enabled */
char *isupport; /* copy of message 005 (ISUPPORT) */
char *prefix_modes; /* prefix modes from msg 005 (eg "ohv") */
char *prefix_chars; /* prefix chars from msg 005 (eg "@%+") */
+4 -2
View File
@@ -362,6 +362,7 @@ irc_upgrade_read_cb (void *data,
if (str)
irc_upgrade_current_server->nick_modes = strdup (str);
irc_upgrade_current_server->cap_away_notify = weechat_infolist_integer (infolist, "cap_away_notify");
irc_upgrade_current_server->cap_account_notify = weechat_infolist_integer (infolist, "cap_account_notify");
str = weechat_infolist_string (infolist, "isupport");
if (str)
irc_upgrade_current_server->isupport = strdup (str);
@@ -477,7 +478,7 @@ irc_upgrade_read_cb (void *data,
weechat_string_free_split (items);
}
}
irc_upgrade_current_channel->checking_away = weechat_infolist_integer (infolist, "checking_away");
irc_upgrade_current_channel->checking_whox = weechat_infolist_integer (infolist, "checking_whox");
str = weechat_infolist_string (infolist, "away_message");
if (str)
irc_upgrade_current_channel->away_message = strdup (str);
@@ -561,7 +562,8 @@ irc_upgrade_read_cb (void *data,
weechat_infolist_string (infolist, "name"),
weechat_infolist_string (infolist, "host"),
weechat_infolist_string (infolist, "prefixes"),
weechat_infolist_integer (infolist, "away"));
weechat_infolist_integer (infolist, "away"),
weechat_infolist_string (infolist, "account"));
if (ptr_nick)
{
/*