diff options
author | TingPing <tingping@tingping.se> | 2013-04-03 18:51:54 -0400 |
---|---|---|
committer | TingPing <tingping@tingping.se> | 2013-04-03 18:51:54 -0400 |
commit | 496ed18e85147a167a2841e078e974e988eeb006 (patch) | |
tree | 9c71c5cd5075393b2e832d0ab85e9fe4d97363ae | |
parent | 86cf7de430ce9d1d255ec82476aca5ffd5146dd9 (diff) |
Add MONITOR support
-rw-r--r-- | src/common/hexchat.h | 1 | ||||
-rw-r--r-- | src/common/inbound.c | 2 | ||||
-rw-r--r-- | src/common/modes.c | 3 | ||||
-rw-r--r-- | src/common/notify.c | 25 | ||||
-rw-r--r-- | src/common/proto-irc.c | 16 | ||||
-rw-r--r-- | src/common/server.c | 1 |
6 files changed, 38 insertions, 10 deletions
diff --git a/src/common/hexchat.h b/src/common/hexchat.h index 958228ff..06bd3d4d 100644 --- a/src/common/hexchat.h +++ b/src/common/hexchat.h @@ -587,6 +587,7 @@ typedef struct server unsigned int reconnect_away:1; /* whether to reconnect in is_away state */ unsigned int dont_use_proxy:1; /* to proxy or not to proxy */ unsigned int supports_watch:1; /* supports the WATCH command */ + unsigned int supports_monitor:1; /* supports the MONITOR 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; diff --git a/src/common/inbound.c b/src/common/inbound.c index 47dd0678..58a458b0 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -1391,7 +1391,7 @@ inbound_login_end (session *sess, char *text) check_autojoin_channels, serv); else check_autojoin_channels (serv); - if (serv->supports_watch) + if (serv->supports_watch || serv->supports_monitor) notify_send_watches (serv); serv->end_of_motd = TRUE; } diff --git a/src/common/modes.c b/src/common/modes.c index 419b704a..0486b532 100644 --- a/src/common/modes.c +++ b/src/common/modes.c @@ -776,6 +776,9 @@ inbound_005 (server * serv, char *word[]) } else if (strncmp (word[w], "WATCH=", 6) == 0) { serv->supports_watch = TRUE; + } else if (strncmp (word[w], "MONITOR=", 8) == 0) + { + serv->supports_monitor = TRUE; } else if (strncmp (word[w], "NETWORK=", 8) == 0) { /* if (serv->networkname) diff --git a/src/common/notify.c b/src/common/notify.c index 849220ca..301bb393 100644 --- a/src/common/notify.c +++ b/src/common/notify.c @@ -283,10 +283,18 @@ static void notify_watch (server * serv, char *nick, int add) { char tbuf[256]; + char addchar = '+'; - snprintf (tbuf, sizeof (tbuf), "WATCH +%s", nick); if (!add) - tbuf[6] = '-'; + addchar = '-'; + + if (serv->supports_monitor) + snprintf (tbuf, sizeof (tbuf), "MONITOR %c %s", addchar, nick); + else if (serv->supports_watch) + snprintf (tbuf, sizeof (tbuf), "WATCH %c%s", addchar, nick); + else + return; + serv->p_raw (serv, tbuf); } @@ -298,8 +306,7 @@ notify_watch_all (struct notify *notify, int add) while (list) { serv = list->data; - if (serv->connected && serv->end_of_motd && serv->supports_watch && - notify_do_network (notify, serv)) + if (serv->connected && serv->end_of_motd && notify_do_network (notify, serv)) notify_watch (serv, notify->name, add); list = list->next; } @@ -312,13 +319,13 @@ notify_flush_watches (server * serv, GSList *from, GSList *end) GSList *list; struct notify *notify; - strcpy (tbuf, "WATCH"); + serv->supports_monitor ? strcpy (tbuf, "MONITOR + ") : strcpy (tbuf, "WATCH"); list = from; while (list != end) { notify = list->data; - strcat (tbuf, " +"); + serv->supports_monitor ? strcat (tbuf, ",") : strcat (tbuf, " +"); strcat (tbuf, notify->name); list = list->next; } @@ -343,11 +350,11 @@ notify_send_watches (server * serv) if (notify_do_network (notify, serv)) { - len += strlen (notify->name) + 2 /* + and space */; + len += strlen (notify->name) + serv->supports_monitor ? 1 : 2; /* just , for monitor or + and space for watch */; if (len > 500) { notify_flush_watches (serv, point, list); - len = strlen (notify->name) + 2; + len = strlen (notify->name) + serv->supports_monitor ? 1 : 2; point = list; } } @@ -450,7 +457,7 @@ notify_checklist (void) /* check ISON list */ while (list) { serv = list->data; - if (serv->connected && serv->end_of_motd && !serv->supports_watch) + if (serv->connected && serv->end_of_motd && !serv->supports_watch && !serv->supports_monitor) { notify_checklist_for_server (serv); } diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index db770511..4fd8deb7 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -466,6 +466,8 @@ process_numeric (session * sess, int n, if (prefs.hex_irc_whois_front) whois_sess = serv->front_session; + char *ex; + switch (n) { case 1: @@ -898,6 +900,20 @@ process_numeric (session * sess, int n, goto def; break; + case 730: /* RPL_MONONLINE */ + ex = strchr (word[4], '!'); /* only send the nick */ + if (ex) + ex[0] = 0; + notify_set_online (serv, word[4] + 1); + break; + + case 731: /* RPL_MONOFFLINE */ + ex = strchr (word[4], '!'); /* only send the nick */ + if (ex) + ex[0] = 0; + notify_set_offline (serv, word[4] + 1, FALSE); + break; + case 903: /* successful SASL auth */ case 904: /* aborted SASL auth */ case 905: /* failed SASL auth */ diff --git a/src/common/server.c b/src/common/server.c index f1de11fa..05aa6f8a 100644 --- a/src/common/server.c +++ b/src/common/server.c @@ -1881,6 +1881,7 @@ server_set_defaults (server *serv) serv->end_of_motd = FALSE; serv->is_away = FALSE; serv->supports_watch = FALSE; + serv->supports_monitor = FALSE; serv->bad_prefix = FALSE; serv->use_who = TRUE; serv->have_namesx = FALSE; |