Merge pull request #448 from TingPing/awaynotify2

Add away-notify support
This commit is contained in:
TingPing 2013-04-03 12:12:26 -07:00
commit 4c217d4ba3
6 changed files with 37 additions and 2 deletions

View File

@ -336,14 +336,15 @@ doover:
list = list->next; 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) if (full)
{ {
list = sess_list; list = sess_list;
while (list) while (list)
{ {
sess = list->data; sess = list->data;
sess->done_away_check = FALSE; if (!sess->server->have_awaynotify)
sess->done_away_check = FALSE;
list = list->next; list = list->next;
} }
loop++; loop++;

View File

@ -589,6 +589,7 @@ typedef struct server
unsigned int supports_watch:1; /* supports the WATCH command */ unsigned int supports_watch:1; /* supports the WATCH command */
unsigned int bad_prefix:1; /* gave us a bad PREFIX= 005 number */ 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_namesx:1; /* 005 tokens NAMESX and UHNAMES */
unsigned int have_awaynotify:1;
unsigned int have_uhnames:1; unsigned int have_uhnames:1;
unsigned int have_whox:1; /* have undernet's WHOX features */ unsigned int have_whox:1; /* have undernet's WHOX features */
unsigned int have_idmsg:1; /* freenode's IDENTIFY-MSG */ unsigned int have_idmsg:1; /* freenode's IDENTIFY-MSG */

View File

@ -986,6 +986,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)
userlist_set_away (sess, nick, reason ? TRUE : FALSE);
list = list->next;
}
}
int int
inbound_nameslist_end (server *serv, char *chan) inbound_nameslist_end (server *serv, char *chan)
{ {

View File

@ -42,6 +42,7 @@ void inbound_ping_reply (session *sess, char *timestring, char *from);
void inbound_nameslist (server *serv, char *chan, char *names); void inbound_nameslist (server *serv, char *chan, char *names);
int inbound_nameslist_end (server *serv, char *chan); int inbound_nameslist_end (server *serv, char *chan);
void inbound_away (server *serv, char *nick, char *msg); 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_start (session *sess, char *nick, char *servname);
void inbound_login_end (session *sess, char *text); 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); void inbound_chanmsg (server *serv, session *sess, char *chan, char *from, char *text, char fromme, int id);

View File

@ -1029,6 +1029,11 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[])
inbound_quit (serv, nick, ip, inbound_quit (serv, nick, ip,
(word_eol[3][0] == ':') ? word_eol[3] + 1 : word_eol[3]); (word_eol[3][0] == ':') ? word_eol[3] + 1 : word_eol[3]);
return; return;
case WORDL('A','W','A','Y'):
inbound_away_notify (serv, nick,
(word_eol[3][0] == ':') ? word_eol[3] + 1 : NULL);
return;
} }
goto garbage; goto garbage;
@ -1166,6 +1171,11 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[])
serv->have_namesx = TRUE; serv->have_namesx = TRUE;
} }
if (strstr (word_eol[5], "away-notify") != 0)
{
serv->have_awaynotify = TRUE;
}
if (strstr (word_eol[5], "sasl") != 0) if (strstr (word_eol[5], "sasl") != 0)
{ {
serv->have_sasl = TRUE; serv->have_sasl = TRUE;
@ -1193,6 +1203,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 ? strcat (buffer, " multi-prefix") : strcpy (buffer, "CAP REQ :multi-prefix");
want_cap = 1; 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 the SASL password is set, request SASL auth */
if (strstr (word_eol[5], "sasl") != 0 && strlen (sess->server->saslpassword) != 0) if (strstr (word_eol[5], "sasl") != 0 && strlen (sess->server->saslpassword) != 0)
{ {

View File

@ -1884,6 +1884,7 @@ server_set_defaults (server *serv)
serv->bad_prefix = FALSE; serv->bad_prefix = FALSE;
serv->use_who = TRUE; serv->use_who = TRUE;
serv->have_namesx = FALSE; serv->have_namesx = FALSE;
serv->have_awaynotify = FALSE;
serv->have_uhnames = FALSE; serv->have_uhnames = FALSE;
serv->have_whox = FALSE; serv->have_whox = FALSE;
serv->have_idmsg = FALSE; serv->have_idmsg = FALSE;