Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add account-notify and extended-join support #451

Closed
wants to merge 2 commits into from

2 participants

@TingPing
Owner

account-notify capability - http://ircv3.atheme.org/extensions/account-notify-3.1
extended-join - http://ircv3.atheme.org/extensions/extended-join-3.1
allows tracking of users accounts and can replace the identify-msg capability

@RichardHitt RichardHitt was assigned
@TingPing TingPing closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 14, 2013
  1. @TingPing

    Add account-notify support

    TingPing authored
  2. @TingPing

    Add extended-join support

    TingPing authored
This page is out of date. Refresh to see the latest.
View
2  src/common/hexchat.h
@@ -573,6 +573,8 @@ typedef struct server
unsigned int have_whox:1; /* have undernet's WHOX features */
unsigned int have_capab:1; /* supports CAPAB (005 tells us) */
unsigned int have_idmsg:1; /* freenode's IDENTIFY-MSG */
+ unsigned int have_accountnotify:1;
+ unsigned int have_extjoin:1;
unsigned int have_sasl:1; /* SASL capability */
unsigned int have_except:1; /* ban exemptions +e */
unsigned int using_cp1255:1; /* encoding is CP1255/WINDOWS-1255? */
View
41 src/common/inbound.c
@@ -137,7 +137,7 @@ static void
inbound_make_idtext (server *serv, char *idtext, int max, int id)
{
idtext[0] = 0;
- if (serv->have_idmsg)
+ if (serv->have_idmsg || serv->have_accountnotify)
{
if (id)
{
@@ -156,6 +156,7 @@ inbound_privmsg (server *serv, char *from, char *ip, char *text, int id)
{
session *sess;
char idtext[64];
+ struct User *user;
sess = find_dialog (serv, from);
@@ -188,6 +189,10 @@ inbound_privmsg (server *serv, char *from, char *ip, char *text, int id)
return;
}
+ user = userlist_find (sess, from);
+ if (user && user->account)
+ id = TRUE;
+
inbound_make_idtext (serv, idtext, sizeof (idtext), id);
sess = find_session_from_nick (from, serv);
@@ -373,6 +378,8 @@ inbound_action (session *sess, char *chan, char *from, char *ip, char *text, int
user = userlist_find (sess, from);
if (user)
{
+ if (user->account)
+ id = TRUE;
nickchar[0] = user->prefix[0];
user->lasttalk = time (0);
}
@@ -431,6 +438,8 @@ inbound_chanmsg (server *serv, session *sess, char *chan, char *from, char *text
user = userlist_find (sess, from);
if (user)
{
+ if (user->account)
+ id = TRUE;
nickchar[0] = user->prefix[0];
user->lasttalk = time (0);
}
@@ -650,12 +659,12 @@ inbound_nameslist (server *serv, char *chan, char *names)
case 0:
name[pos] = 0;
if (pos != 0)
- userlist_add (sess, name, 0);
+ userlist_add (sess, name, 0, NULL, NULL);
return;
case ' ':
name[pos] = 0;
pos = 0;
- userlist_add (sess, name, 0);
+ userlist_add (sess, name, 0, NULL, NULL);
break;
default:
name[pos] = *names;
@@ -700,13 +709,13 @@ inbound_topicnew (server *serv, char *nick, char *chan, char *topic)
}
void
-inbound_join (server *serv, char *chan, char *user, char *ip)
+inbound_join (server *serv, char *chan, char *user, char *ip, char *account, char *realname)
{
session *sess = find_channel (serv, chan);
if (sess)
{
EMIT_SIGNAL (XP_TE_JOIN, sess, user, chan, ip, NULL, 0);
- userlist_add (sess, user, ip);
+ userlist_add (sess, user, ip, account, realname);
}
}
@@ -779,6 +788,22 @@ inbound_quit (server *serv, char *nick, char *ip, char *reason)
}
void
+inbound_account (server *serv, char *nick, char *account)
+{
+ session *sess = NULL;
+ GSList *list;
+
+ list = sess_list;
+ while (list)
+ {
+ sess = list->data;
+ if (sess->server == serv)
+ userlist_set_account (sess, nick, account);
+ list = list->next;
+ }
+}
+
+void
inbound_ping_reply (session *sess, char *timestring, char *from)
{
unsigned long tim, nowtim, dif;
@@ -1227,7 +1252,7 @@ inbound_user_info_start (session *sess, char *nick)
void
inbound_user_info (session *sess, char *chan, char *user, char *host,
char *servname, char *nick, char *realname,
- unsigned int away)
+ char *account, unsigned int away)
{
server *serv = sess->server;
session *who_sess;
@@ -1244,7 +1269,7 @@ inbound_user_info (session *sess, char *chan, char *user, char *host,
{
who_sess = find_channel (serv, chan);
if (who_sess)
- userlist_add_hostname (who_sess, nick, uhost, realname, servname, away);
+ userlist_add_hostname (who_sess, nick, uhost, realname, servname, account, away);
else
{
if (serv->doing_dns && nick && host)
@@ -1259,7 +1284,7 @@ inbound_user_info (session *sess, char *chan, char *user, char *host,
sess = list->data;
if (sess->type == SESS_CHANNEL && sess->server == serv)
{
- userlist_add_hostname (sess, nick, uhost, realname, servname, away);
+ userlist_add_hostname (sess, nick, uhost, realname, servname, account, away);
}
}
}
View
5 src/common/inbound.h
@@ -4,6 +4,7 @@
void inbound_next_nick (session *sess, char *nick);
void inbound_uback (server *serv);
void inbound_uaway (server *serv);
+void inbound_account (server *serv, char *nick, char *account);
void inbound_part (server *serv, char *chan, char *user, char *ip, char *reason);
void inbound_upart (server *serv, char *chan, char *ip, char *reason);
void inbound_ukick (server *serv, char *chan, char *kicker, char *reason);
@@ -11,12 +12,12 @@ void inbound_kick (server *serv, char *chan, char *user, char *kicker, char *rea
void inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, int id);
void inbound_quit (server *serv, char *nick, char *ip, char *reason);
void inbound_topicnew (server *serv, char *nick, char *chan, char *topic);
-void inbound_join (server *serv, char *chan, char *user, char *ip);
+void inbound_join (server *serv, char *chan, char *user, char *ip, char *account, char *realname);
void inbound_ujoin (server *serv, char *chan, char *nick, char *ip);
void inbound_topictime (server *serv, char *chan, char *nick, time_t stamp);
void inbound_topic (server *serv, char *chan, char *topic_text);
void inbound_user_info_start (session *sess, char *nick);
-void inbound_user_info (session *sess, char *chan, char *user, char *host, char *servname, char *nick, char *realname, unsigned int away);
+void inbound_user_info (session *sess, char *chan, char *user, char *host, char *servname, char *nick, char *realname, char *account, unsigned int away);
void inbound_foundip (session *sess, char *ip);
int inbound_banlist (session *sess, time_t stamp, char *chan, char *mask, char *banner, int is_exemption);
void inbound_ping_reply (session *sess, char *timestring, char *from);
View
46 src/common/proto-irc.c
@@ -328,7 +328,7 @@ static void
irc_away_status (server *serv, char *channel)
{
if (serv->have_whox)
- tcp_sendf (serv, "WHO %s %%ctnf,152\r\n", channel);
+ tcp_sendf (serv, "WHO %s %%chtsunfra,152\r\n", channel);
else
tcp_sendf (serv, "WHO %s\r\n", channel);
}
@@ -568,7 +568,7 @@ process_numeric (session * sess, int n,
if (!serv->skip_next_whois)
EMIT_SIGNAL (XP_TE_WHOIS3, whois_sess, word[4], word_eol[5], NULL, NULL, 0);
else
- inbound_user_info (sess, NULL, NULL, NULL, word[5], word[4], NULL, 0xff);
+ inbound_user_info (sess, NULL, NULL, NULL, word[5], word[4], NULL, NULL, 0xff);
break;
case 311: /* WHOIS 1st line */
@@ -579,7 +579,7 @@ process_numeric (session * sess, int n,
word[6], word_eol[8] + 1, 0);
else
inbound_user_info (sess, NULL, word[5], word[6], NULL, word[4],
- word_eol[8][0] == ':' ? word_eol[8] + 1 : word_eol[8], 0xff);
+ word_eol[8][0] == ':' ? word_eol[8] + 1 : word_eol[8], NULL, 0xff);
break;
case 314: /* WHOWAS */
@@ -724,7 +724,7 @@ process_numeric (session * sess, int n,
away = 1;
inbound_user_info (sess, word[4], word[5], word[6], word[7],
- word[8], word_eol[11], away);
+ word[8], word_eol[11], word[10], away);
/* try to show only user initiated whos */
if (!who_sess || !who_sess->doing_who)
@@ -743,11 +743,12 @@ process_numeric (session * sess, int n,
{
who_sess = find_channel (serv, word[5]);
- if (*word[7] == 'G')
+ if (*word[10] == 'G')
away = 1;
- /* :SanJose.CA.us.undernet.org 354 z1 152 #zed1 z1 H@ */
- inbound_user_info (sess, word[5], 0, 0, 0, word[6], 0, away);
+ /* :server 354 yournick 152 #channel ~ident host servname nick H account :realname */
+ inbound_user_info (sess, word[5], word[6], word[7], word[8],
+ word[9], word_eol[12], word[11], away);
/* try to show only user initiated whos */
if (!who_sess || !who_sess->doing_who)
@@ -952,13 +953,15 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[])
case WORDL('J','O','I','N'):
{
char *chan = word[3];
+ char *account = word[4];
+ char *realname = word_eol[5] + 1;
if (*chan == ':')
chan++;
if (!serv->p_cmp (nick, serv->nick))
inbound_ujoin (serv, chan, nick, ip);
else
- inbound_join (serv, chan, nick, ip);
+ inbound_join (serv, chan, nick, ip, account, realname);
}
return;
@@ -1029,6 +1032,11 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[])
/* this should compile to a bunch of: CMP.L, JE ... nice & fast */
switch (t)
{
+
+ case WORDL('A','C','C','O'):
+ inbound_account (serv, nick, word[3]);
+ return;
+
case WORDL('I','N','V','I'):
if (ignore_check (word[1], IG_INVI))
return;
@@ -1153,6 +1161,16 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[])
serv->have_namesx = TRUE;
}
+ if (strstr (word_eol[5], "account-notify") != 0)
+ {
+ serv->have_accountnotify = TRUE;
+ }
+
+ if (strstr (word_eol[5], "extended-join") != 0)
+ {
+ serv->have_extjoin = TRUE;
+ }
+
if (strstr (word_eol[5], "sasl") != 0)
{
serv->have_sasl = TRUE;
@@ -1180,6 +1198,18 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[])
want_cap ? strcat (buffer, " multi-prefix") : strcpy (buffer, "CAP REQ :multi-prefix");
want_cap = 1;
}
+
+ if (strstr (word_eol[5], "account-notify") != 0)
+ {
+ want_cap ? strcat (buffer, " account-notify") : strcpy (buffer, "CAP REQ :account-notify");
+ want_cap = 1;
+ }
+
+ if (strstr (word_eol[5], "extended-join") != 0)
+ {
+ want_cap ? strcat (buffer, " extended-join") : strcpy (buffer, "CAP REQ :extended-join");
+ want_cap = 1;
+ }
/* if the SASL password is set, request SASL auth */
if (strstr (word_eol[5], "sasl") != 0 && strlen (sess->server->saslpassword) != 0)
{
View
2  src/common/server.c
@@ -1912,6 +1912,8 @@ server_set_defaults (server *serv)
serv->have_whox = FALSE;
serv->have_capab = FALSE;
serv->have_idmsg = FALSE;
+ serv->have_accountnotify = FALSE;
+ serv->have_extjoin = FALSE;
serv->have_sasl = FALSE;
serv->have_except = FALSE;
}
View
39 src/common/userlist.c
@@ -113,9 +113,27 @@ userlist_set_away (struct session *sess, char *nick, unsigned int away)
}
}
+void
+userlist_set_account (struct session *sess, char *nick, char *account)
+{
+ struct User *user;
+
+ user = userlist_find (sess, nick);
+ if (user)
+ {
+ if (strcmp (account, "*") == 0)
+ user->account = NULL;
+ else if (user->account != account)
+ user->account = strdup (account);
+
+ /* gui doesnt currently reflect login status, maybe later
+ fe_userlist_rehash (sess, user); */
+ }
+}
+
int
userlist_add_hostname (struct session *sess, char *nick, char *hostname,
- char *realname, char *servername, unsigned int away)
+ char *realname, char *servername, char *account, unsigned int away)
{
struct User *user;
@@ -128,6 +146,8 @@ userlist_add_hostname (struct session *sess, char *nick, char *hostname,
user->realname = strdup (realname);
if (!user->servername && servername)
user->servername = strdup (servername);
+ if (!user->account && account && strcmp (account, ":0") != 0)
+ user->account = strdup (account);
if (away != 0xff)
{
@@ -155,6 +175,8 @@ free_user (struct User *user, gpointer data)
free (user->hostname);
if (user->servername)
free (user->servername);
+ if (user->account)
+ free (user->account);
free (user);
return TRUE;
@@ -358,7 +380,7 @@ userlist_remove_user (struct session *sess, struct User *user)
}
void
-userlist_add (struct session *sess, char *name, char *hostname)
+userlist_add (struct session *sess, char *name, char *hostname, char *account, char *realname)
{
struct User *user;
int row, prefix_chars;
@@ -384,6 +406,15 @@ userlist_add (struct session *sess, char *name, char *hostname)
/* is it me? */
if (!sess->server->p_cmp (user->nick, sess->server->nick))
user->me = TRUE;
+ /* extended join info */
+ if (sess->server->have_extjoin)
+ {
+ if (account && strcmp (account, "*") != 0)
+ user->account = strdup (account);
+ if (realname)
+ user->realname = strdup (realname);
+ }
+
row = userlist_insertname (sess, user);
/* duplicate? some broken servers trigger this */
@@ -391,6 +422,10 @@ userlist_add (struct session *sess, char *name, char *hostname)
{
if (user->hostname)
free (user->hostname);
+ if (user->account)
+ free (user->account);
+ if (user->realname)
+ free (user->realname);
free (user);
return;
}
View
6 src/common/userlist.h
@@ -9,6 +9,7 @@ struct User
char *hostname;
char *realname;
char *servername;
+ char *account;
time_t lasttalk;
unsigned int access; /* axs bit field */
char prefix[2]; /* @ + % */
@@ -24,13 +25,14 @@ struct User
int userlist_add_hostname (session *sess, char *nick,
char *hostname, char *realname,
- char *servername, unsigned int away);
+ char *servername, char *account, unsigned int away);
void userlist_set_away (session *sess, char *nick, unsigned int away);
+void userlist_set_account (session *sess, char *nick, char *account);
struct User *userlist_find (session *sess, const char *name);
struct User *userlist_find_global (server *serv, char *name);
void userlist_clear (session *sess);
void userlist_free (session *sess);
-void userlist_add (session *sess, char *name, char *hostname);
+void userlist_add (session *sess, char *name, char *hostname, char *account, char *realname);
int userlist_remove (session *sess, char *name);
void userlist_remove_user (session *sess, struct User *user);
int userlist_change (session *sess, char *oldname, char *newname);
View
7 src/fe-gtk/menu.c
@@ -636,6 +636,13 @@ menu_create_nickinfo_menu (struct User *user, GtkWidget *submenu)
g_signal_connect (G_OBJECT (item), "activate",
G_CALLBACK (copy_to_clipboard_cb),
user->hostname ? user->hostname : unknown);
+
+ snprintf (buf, sizeof (buf), fmt, _("Account:"),
+ user->account ? user->account : unknown);
+ item = menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0);
+ g_signal_connect (G_OBJECT (item), "activate",
+ G_CALLBACK (copy_to_clipboard_cb),
+ user->account ? user->account : unknown);
snprintf (buf, sizeof (buf), fmt, _("Country:"),
user->hostname ? country(user->hostname) : unknown);
Something went wrong with that request. Please try again.