Skip to content
Browse files

Add account-notify support

  • Loading branch information...
1 parent d1e2048 commit 4e88e9c683573e89e832fee461a603f3bbe5940d @TingPing committed
Showing with 91 additions and 14 deletions.
  1. +1 −0 src/common/hexchat.h
  2. +32 −4 src/common/inbound.c
  3. +2 −1 src/common/inbound.h
  4. +24 −7 src/common/proto-irc.c
  5. +1 −0 src/common/server.c
  6. +21 −1 src/common/userlist.c
  7. +3 −1 src/common/userlist.h
  8. +7 −0 src/fe-gtk/menu.c
View
1 src/common/hexchat.h
@@ -573,6 +573,7 @@ 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_sasl:1; /* SASL capability */
unsigned int have_except:1; /* ban exemptions +e */
unsigned int using_cp1255:1; /* encoding is CP1255/WINDOWS-1255? */
View
36 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);
}
@@ -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;
@@ -1240,11 +1265,14 @@ inbound_user_info (session *sess, char *chan, char *user, char *host,
sprintf (uhost, "%s@%s", user, host);
}
+ if (strcmp (account, "*") == 0 || strcmp (account, ":0") == 0)
+ account = NULL;
+
if (chan)
{
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 +1287,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
3 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);
@@ -16,7 +17,7 @@ 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
31 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)
@@ -1029,6 +1030,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 +1159,11 @@ 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], "sasl") != 0)
{
serv->have_sasl = TRUE;
@@ -1180,6 +1191,12 @@ 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 the SASL password is set, request SASL auth */
if (strstr (word_eol[5], "sasl") != 0 && strlen (sess->server->saslpassword) != 0)
{
View
1 src/common/server.c
@@ -1912,6 +1912,7 @@ server_set_defaults (server *serv)
serv->have_whox = FALSE;
serv->have_capab = FALSE;
serv->have_idmsg = FALSE;
+ serv->have_accountnotify = FALSE;
serv->have_sasl = FALSE;
serv->have_except = FALSE;
}
View
22 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)
+ user->account = strdup (account);
if (away != 0xff)
{
View
4 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,8 +25,9 @@ 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);
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);

0 comments on commit 4e88e9c

Please sign in to comment.
Something went wrong with that request. Please try again.