From bf0fb9f3275ab245b4f8f32ed87b482000b78243 Mon Sep 17 00:00:00 2001 From: TingPing Date: Tue, 12 Mar 2013 02:21:18 -0400 Subject: Add away-notify support --- src/common/hexchat.c | 4 ++-- src/common/hexchat.h | 1 + src/common/inbound.c | 19 +++++++++++++++++++ src/common/inbound.h | 1 + src/common/proto-irc.c | 15 +++++++++++++++ src/common/server.c | 1 + 6 files changed, 39 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/common/hexchat.c b/src/common/hexchat.c index 57e3fc86..a8e98c33 100644 --- a/src/common/hexchat.c +++ b/src/common/hexchat.c @@ -336,8 +336,8 @@ doover: list = list->next; } - /* done them all, reset done_away_check to FALSE and start over */ - if (full) + /* done them all, reset done_away_check to FALSE and start over unless we have away-notify*/ + if (full && !sess->server->have_awaynotify) { list = sess_list; while (list) diff --git a/src/common/hexchat.h b/src/common/hexchat.h index dfd2fd5a..4f5c82a8 100644 --- a/src/common/hexchat.h +++ b/src/common/hexchat.h @@ -569,6 +569,7 @@ typedef struct server unsigned int supports_watch:1; /* supports the WATCH command */ unsigned int bad_prefix:1; /* gave us a bad PREFIX= 005 number */ unsigned int have_namesx:1; /* 005 tokens NAMESX and UHNAMES */ + unsigned int have_awaynotify:1; unsigned int have_uhnames:1; unsigned int have_whox:1; /* have undernet's WHOX features */ unsigned int have_capab:1; /* supports CAPAB (005 tells us) */ diff --git a/src/common/inbound.c b/src/common/inbound.c index 54e5bff0..f807b783 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -977,6 +977,25 @@ inbound_away (server *serv, char *nick, char *msg) } } +void +inbound_away_notify (server *serv, char *nick, char *reason) +{ + session *sess = NULL; + GSList *list; + + list = sess_list; + while (list) + { + sess = list->data; + if (sess->server == serv) + if (!reason) + userlist_set_away (sess, nick, FALSE); + else + userlist_set_away (sess, nick, TRUE); + list = list->next; + } +} + int inbound_nameslist_end (server *serv, char *chan) { diff --git a/src/common/inbound.h b/src/common/inbound.h index e1e4e9bb..319996ed 100644 --- a/src/common/inbound.h +++ b/src/common/inbound.h @@ -23,6 +23,7 @@ void inbound_ping_reply (session *sess, char *timestring, char *from); void inbound_nameslist (server *serv, char *chan, char *names); int inbound_nameslist_end (server *serv, char *chan); void inbound_away (server *serv, char *nick, char *msg); +void inbound_away_notify (server *serv, char *nick, char *reason); void inbound_login_start (session *sess, char *nick, char *servname); void inbound_login_end (session *sess, char *text); void inbound_chanmsg (server *serv, session *sess, char *chan, char *from, char *text, char fromme, int id); diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index 18015607..699d068d 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -1016,6 +1016,11 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[]) inbound_quit (serv, nick, ip, (word_eol[3][0] == ':') ? word_eol[3] + 1 : word_eol[3]); return; + + case WORDL('A','W','A','Y'): + inbound_away_notify (serv, nick, + (word_eol[3][0] == ':') ? word_eol[3] + 1 : NULL); + return; } goto garbage; @@ -1153,6 +1158,11 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[]) serv->have_namesx = TRUE; } + if (strstr (word_eol[5], "away-notify") != 0) + { + serv->have_awaynotify = TRUE; + } + if (strstr (word_eol[5], "sasl") != 0) { serv->have_sasl = TRUE; @@ -1180,6 +1190,11 @@ 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], "away-notify") != 0) + { + want_cap ? strcat (buffer, " away-notify") : strcpy (buffer, "CAP REQ :away-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) { diff --git a/src/common/server.c b/src/common/server.c index 6ddaa18d..ca873042 100644 --- a/src/common/server.c +++ b/src/common/server.c @@ -1908,6 +1908,7 @@ server_set_defaults (server *serv) serv->bad_prefix = FALSE; serv->use_who = TRUE; serv->have_namesx = FALSE; + serv->have_awaynotify = FALSE; serv->have_uhnames = FALSE; serv->have_whox = FALSE; serv->have_capab = FALSE; -- cgit 1.4.1 From eb5313f8503091017ecb81ad8d48be576a666a81 Mon Sep 17 00:00:00 2001 From: TingPing Date: Tue, 12 Mar 2013 23:54:55 -0400 Subject: Clean up away-notify patch --- src/common/hexchat.c | 7 ++++--- src/common/inbound.c | 5 +---- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/common/hexchat.c b/src/common/hexchat.c index a8e98c33..b6c12ce2 100644 --- a/src/common/hexchat.c +++ b/src/common/hexchat.c @@ -336,14 +336,15 @@ doover: list = list->next; } - /* done them all, reset done_away_check to FALSE and start over unless we have away-notify*/ - if (full && !sess->server->have_awaynotify) + /* done them all, reset done_away_check to FALSE and start over unless we have away-notify */ + if (full) { list = sess_list; while (list) { sess = list->data; - sess->done_away_check = FALSE; + if (!sess->server->have_awaynotify) + sess->done_away_check = FALSE; list = list->next; } loop++; diff --git a/src/common/inbound.c b/src/common/inbound.c index f807b783..d44fbef6 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -988,10 +988,7 @@ inbound_away_notify (server *serv, char *nick, char *reason) { sess = list->data; if (sess->server == serv) - if (!reason) - userlist_set_away (sess, nick, FALSE); - else - userlist_set_away (sess, nick, TRUE); + userlist_set_away (sess, nick, reason ? TRUE : FALSE); list = list->next; } } -- cgit 1.4.1