1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 08:13:14 +02:00

irc: add hashtables to keep track of all capabilities

This commit is contained in:
Simmo Saan
2015-12-13 10:45:11 +02:00
parent 48a3baedd5
commit 453434644a
6 changed files with 49 additions and 51 deletions
+12 -25
View File
@@ -207,11 +207,14 @@ IRC_PROTOCOL_CALLBACK(account)
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
char *pos_account;
int cap_account_notify;
IRC_PROTOCOL_MIN_ARGS(3);
pos_account = (strcmp (argv[2], "*") != 0) ? argv[2] : NULL;
cap_account_notify = weechat_hashtable_has_key (server->cap_list, "account-notify");
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
@@ -220,7 +223,7 @@ IRC_PROTOCOL_CALLBACK(account)
{
if (ptr_nick->account)
free (ptr_nick->account);
ptr_nick->account = (server->cap_account_notify && pos_account) ?
ptr_nick->account = (cap_account_notify && pos_account) ?
strdup (pos_account) : NULL;
}
}
@@ -478,23 +481,13 @@ IRC_PROTOCOL_CALLBACK(cap)
{
for (i = 0; i < num_caps_supported; i++)
{
weechat_hashtable_set (server->cap_list, caps_supported[i], NULL);
if (strcmp (caps_supported[i], "sasl") == 0)
{
sasl_to_do = 1;
break;
}
else if (strcmp (caps_supported[i], "away-notify") == 0)
{
server->cap_away_notify = 1;
}
else if (strcmp (caps_supported[i], "account-notify") == 0)
{
server->cap_account_notify = 1;
}
else if (strcmp (caps_supported[i], "extended-join") == 0)
{
server->cap_extended_join = 1;
}
}
weechat_string_free_split (caps_supported);
}
@@ -620,14 +613,7 @@ IRC_PROTOCOL_CALLBACK(cap)
{
for (i = 0; i < num_caps_removed; i++)
{
if (strcmp (caps_removed[i], "away-notify") == 0)
{
server->cap_away_notify = 0;
}
else if (strcmp (caps_removed[i], "account-notify") == 0)
{
server->cap_account_notify = 0;
}
weechat_hashtable_remove (server->cap_list, caps_removed[i]);
}
weechat_string_free_split (caps_removed);
}
@@ -4229,7 +4215,8 @@ IRC_PROTOCOL_CALLBACK(352)
{
if (ptr_nick->realname)
free (ptr_nick->realname);
ptr_nick->realname = (pos_realname && server->cap_extended_join) ?
ptr_nick->realname = (pos_realname &&
weechat_hashtable_has_key (server->cap_list, "extended-join")) ?
strdup (pos_realname) : NULL;
}
@@ -4456,7 +4443,7 @@ IRC_PROTOCOL_CALLBACK(354)
if (ptr_channel && ptr_nick)
{
if (pos_attr
&& (server->cap_away_notify
&& (weechat_hashtable_has_key (server->cap_list, "away-notify")
|| ((IRC_SERVER_OPTION_INTEGER(
server, IRC_SERVER_OPTION_AWAY_CHECK) > 0)
&& ((IRC_SERVER_OPTION_INTEGER(
@@ -4479,7 +4466,7 @@ IRC_PROTOCOL_CALLBACK(354)
if (ptr_nick->account)
free (ptr_nick->account);
ptr_nick->account = (ptr_channel && pos_account
&& server->cap_account_notify) ?
&& weechat_hashtable_has_key (server->cap_list, "account-notify")) ?
strdup (pos_account) : NULL;
}
@@ -4489,7 +4476,7 @@ IRC_PROTOCOL_CALLBACK(354)
if (ptr_nick->realname)
free (ptr_nick->realname);
ptr_nick->realname = (ptr_channel && pos_realname
&& server->cap_extended_join) ?
&& weechat_hashtable_has_key (server->cap_list, "extended-join")) ?
strdup (pos_realname) : NULL;
}