Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add away-notify support #448

Merged
merged 2 commits into from

2 participants

@TingPing
Owner

With this HexChat won't have to call who every 30 seconds to track users.

@RichardHitt RichardHitt was assigned
@RichardHitt

The capability "away-notify" appears to be documented at:
http://ircv3.atheme.org/extensions/away-notify-3.1
See also http://ircv3.atheme.org/ for the "IRC V3.1 Specifications"

src/common/hexchat.c
@@ -336,8 +336,8 @@
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*/

From my build on Fedora 17, this warning message:
hexchat.c: In function ‘away_check’:
hexchat.c:340:19: warning: ‘sess’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@RichardHitt RichardHitt commented on the diff
src/common/inbound.c
@@ -977,6 +977,25 @@
}
}
+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)

From my build on Fedora 17, this warning message:
inbound.c: In function ‘inbound_away_notify’:
inbound.c:990:6: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses]

Dammit, I can't get the stupid github to indent the following nicely, like my above suggestion for hexchat.c. But anyway, the following fixes the warning message and also slightly shortens the code:

986 list = sess_list;
987 while (list)
988 {
989 sess = list->data;
990 if ((sess->server == serv))
991 userlist_set_away (sess, nick, reason? TRUE: FALSE);
992 list = list->next;
993 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
src/common/hexchat.c
@@ -336,8 +336,8 @@
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)

I don't think this is right. Don't you want to test sess->server->haveawaynotify for every session on the list?
Here's what I think this section should look like:

340    if (full)
341    {
342       list = sess_list;
343       while (list)
344       {
345          sess = list->data;
346          if (!sess->server->have_awaynotify)
347             sess->done_away_check = FALSE;
348          list = list->next;
349       }
350       loop++;
351       if (loop < 2)
352          goto doover;
353    }

That would also fix the warning in my first comment, above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@TingPing TingPing merged commit 4c217d4 into hexchat:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 12, 2013
  1. @TingPing

    Add away-notify support

    TingPing authored
Commits on Mar 13, 2013
  1. @TingPing

    Clean up away-notify patch

    TingPing authored
This page is out of date. Refresh to see the latest.
View
5 src/common/hexchat.c
@@ -336,14 +336,15 @@ away_check (void)
list = list->next;
}
- /* done them all, reset done_away_check to FALSE and start over */
+ /* 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++;
View
1  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) */
View
16 src/common/inbound.c
@@ -977,6 +977,22 @@ 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)

From my build on Fedora 17, this warning message:
inbound.c: In function ‘inbound_away_notify’:
inbound.c:990:6: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses]

Dammit, I can't get the stupid github to indent the following nicely, like my above suggestion for hexchat.c. But anyway, the following fixes the warning message and also slightly shortens the code:

986 list = sess_list;
987 while (list)
988 {
989 sess = list->data;
990 if ((sess->server == serv))
991 userlist_set_away (sess, nick, reason? TRUE: FALSE);
992 list = list->next;
993 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ userlist_set_away (sess, nick, reason ? TRUE : FALSE);
+ list = list->next;
+ }
+}
+
int
inbound_nameslist_end (server *serv, char *chan)
{
View
1  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);
View
15 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)
{
View
1  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;
Something went wrong with that request. Please try again.