summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorMax Teufel <max@teufelsnetz.com>2015-03-07 15:12:48 +0100
committerMax Teufel <max@teufelsnetz.com>2015-03-07 15:46:02 +0100
commite00d7f2bfd628f77d59f6aa73a485bf2a8786725 (patch)
tree69a0c501197a4776850313ef78f0cfadfe92efc4 /src/plugins
parenta83ad08c485d203ee7e54bc95e6a5d79fde85659 (diff)
downloadweechat-e00d7f2bfd628f77d59f6aa73a485bf2a8786725.zip
irc: track realnames using extended-join and WHO
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/irc/irc-nick.c13
-rw-r--r--src/plugins/irc/irc-nick.h4
-rw-r--r--src/plugins/irc/irc-protocol.c27
-rw-r--r--src/plugins/irc/irc-server.c6
-rw-r--r--src/plugins/irc/irc-server.h1
-rw-r--r--src/plugins/irc/irc-upgrade.c4
6 files changed, 50 insertions, 5 deletions
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index b9df84bf9..9fbf853c0 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -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, const char *account)
+ int away, const char *account, const char *realname)
{
struct t_irc_nick *new_nick, *ptr_nick;
int length;
@@ -648,6 +648,9 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
if (ptr_nick->account)
free (ptr_nick->account);
ptr_nick->account = (account) ? strdup (account) : NULL;
+ if (ptr_nick->realname)
+ free (ptr_nick->realname);
+ ptr_nick->realname = (realname) ? strdup (realname) : NULL;
/* add new nick in nicklist */
irc_nick_nicklist_add (server, channel, ptr_nick);
@@ -663,6 +666,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
new_nick->name = strdup (nickname);
new_nick->host = (host) ? strdup (host) : NULL;
new_nick->account = (account) ? strdup (account) : NULL;
+ new_nick->realname = (realname) ? strdup (realname) : NULL;
length = strlen (irc_server_get_prefix_chars (server));
new_nick->prefixes = malloc (length + 1);
if (!new_nick->name || !new_nick->prefixes)
@@ -673,6 +677,8 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
free (new_nick->host);
if (new_nick->account)
free (new_nick->account);
+ if (new_nick->realname)
+ free (new_nick->realname);
if (new_nick->prefixes)
free (new_nick->prefixes);
free (new_nick);
@@ -815,6 +821,8 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel,
free (nick->prefixes);
if (nick->account)
free (nick->account);
+ if (nick->realname)
+ free (nick->realname);
if (nick->color)
free (nick->color);
@@ -1135,6 +1143,7 @@ irc_nick_hdata_nick_cb (void *data, const char *hdata_name)
WEECHAT_HDATA_VAR(struct t_irc_nick, prefix, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_nick, away, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_nick, account, STRING, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_nick, realname, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_nick, color, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_nick, prev_nick, POINTER, 0, NULL, hdata_name);
WEECHAT_HDATA_VAR(struct t_irc_nick, next_nick, POINTER, 0, NULL, hdata_name);
@@ -1175,6 +1184,8 @@ irc_nick_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "account", nick->account))
return 0;
+ if (!weechat_infolist_new_var_string (ptr_item, "realname", nick->realname))
+ return 0;
if (!weechat_infolist_new_var_string (ptr_item, "color", nick->color))
return 0;
diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h
index 3079a437b..ecc2fc43a 100644
--- a/src/plugins/irc/irc-nick.h
+++ b/src/plugins/irc/irc-nick.h
@@ -39,6 +39,7 @@ struct t_irc_nick
/* prefixes) */
int away; /* 1 if nick is away */
char *account; /* account name of the user */
+ char *realname; /* realname (aka gecos) 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 */
@@ -66,7 +67,8 @@ extern struct t_irc_nick *irc_nick_new (struct t_irc_server *server,
const char *host,
const char *prefixes,
int away,
- const char *account);
+ const char *account,
+ const char *realname);
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 96bffaf2b..c78b036df 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -473,6 +473,10 @@ IRC_PROTOCOL_CALLBACK(cap)
{
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);
}
@@ -743,7 +747,7 @@ IRC_PROTOCOL_CALLBACK(join)
/* add nick in channel */
ptr_nick = irc_nick_new (server, ptr_channel, nick, address, NULL, 0,
- (pos_account) ? pos_account : "*");
+ (pos_account) ? pos_account : "*", (pos_realname) ? pos_realname : NULL);
/* rename the nick if it was in list with a different case */
irc_channel_nick_speaking_rename_if_present (server, ptr_channel, nick);
@@ -4085,6 +4089,15 @@ IRC_PROTOCOL_CALLBACK(352)
(pos_attr[0] == 'G') ? 1 : 0);
}
+ /* update realname flag for nick */
+ if (ptr_channel && ptr_nick && pos_realname)
+ {
+ if (ptr_nick->realname)
+ free (ptr_nick->realname);
+ ptr_nick->realname = (pos_realname && server->cap_extended_join) ?
+ strdup (pos_realname) : NULL;
+ }
+
/* display output of who (manual who from user) */
if (!ptr_channel || (ptr_channel->checking_whox <= 0))
{
@@ -4195,7 +4208,7 @@ IRC_PROTOCOL_CALLBACK(353)
if (ptr_channel && ptr_channel->nicks)
{
if (!irc_nick_new (server, ptr_channel, nickname, pos_host,
- prefixes, 0, "*"))
+ prefixes, 0, "*", NULL))
{
weechat_printf (
server->buffer,
@@ -4335,6 +4348,16 @@ IRC_PROTOCOL_CALLBACK(354)
strdup (pos_account) : strdup ("*");
}
+ /* update realname flag for nick */
+ if (ptr_nick)
+ {
+ if (ptr_nick->realname)
+ free (ptr_nick->realname);
+ ptr_nick->realname = (ptr_channel && pos_realname
+ && server->cap_extended_join) ?
+ strdup (pos_realname) : NULL;
+ }
+
/* display output of who (manual who from user) */
if (!ptr_channel || (ptr_channel->checking_whox <= 0))
{
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index da64054bc..224cbb501 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -994,6 +994,7 @@ irc_server_alloc (const char *name)
new_server->nick_modes = NULL;
new_server->cap_away_notify = 0;
new_server->cap_account_notify = 0;
+ new_server->cap_extended_join = 0;
new_server->isupport = NULL;
new_server->prefix_modes = NULL;
new_server->prefix_chars = NULL;
@@ -4527,6 +4528,7 @@ irc_server_disconnect (struct t_irc_server *server, int switch_address,
}
server->cap_away_notify = 0;
server->cap_account_notify = 0;
+ server->cap_extended_join = 0;
server->is_away = 0;
server->away_time = 0;
server->lag = 0;
@@ -5109,6 +5111,7 @@ irc_server_hdata_server_cb (void *data, const char *hdata_name)
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, cap_extended_join, 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);
@@ -5327,6 +5330,8 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "cap_account_notify", server->cap_account_notify))
return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "cap_extended_join", server->cap_extended_join))
+ 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))
@@ -5688,6 +5693,7 @@ irc_server_print_log ()
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 (" cap_extended_join. . : %d", ptr_server->cap_extended_join);
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);
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index 215dfa7df..fe2188c8c 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -186,6 +186,7 @@ struct t_irc_server
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 */
+ int cap_extended_join; /* 1 if CAP extended-join 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 "@%+") */
diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c
index 95b464f69..3f20eb1cc 100644
--- a/src/plugins/irc/irc-upgrade.c
+++ b/src/plugins/irc/irc-upgrade.c
@@ -363,6 +363,7 @@ irc_upgrade_read_cb (void *data,
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");
+ irc_upgrade_current_server->cap_extended_join = weechat_infolist_integer (infolist, "cap_extended_join");
str = weechat_infolist_string (infolist, "isupport");
if (str)
irc_upgrade_current_server->isupport = strdup (str);
@@ -563,7 +564,8 @@ irc_upgrade_read_cb (void *data,
weechat_infolist_string (infolist, "host"),
weechat_infolist_string (infolist, "prefixes"),
weechat_infolist_integer (infolist, "away"),
- weechat_infolist_string (infolist, "account"));
+ weechat_infolist_string (infolist, "account"),
+ weechat_infolist_string (infolist, "realname"));
if (ptr_nick)
{
/*