# HG changeset patch
# User William Pitcock <nenolod@dereferenced.org>
# Date 1332702511 18000
# Node ID cc309e25fec9686ddf37076813665944fe87f6d4
# Parent  bcf167fa19c361978a7a75c8406b886be7ca774a
- Add support for account-notify client capability (#4098).  This capability
  can be used to request passive notifications for accountname changes.

diff -r bcf167fa19c3 -r cc309e25fec9 Changes
--- a/Changes	Sun Mar 25 13:50:40 2012 -0500
+++ b/Changes	Sun Mar 25 14:08:31 2012 -0500
@@ -2410,3 +2410,5 @@
 - Add support for away-notify client capability (#4097).  This capability can
   be used to reduce bandwidth consumed by polling for AWAY state.  This is
   especially useful with "cloud" IRC providers like Mibbit and IRCCloud.
+- Add support for account-notify client capability (#4098).  This capability
+  can be used to request passive notifications for accountname changes.
diff -r bcf167fa19c3 -r cc309e25fec9 include/struct.h
--- a/include/struct.h	Sun Mar 25 13:50:40 2012 -0500
+++ b/include/struct.h	Sun Mar 25 14:08:31 2012 -0500
@@ -371,6 +371,7 @@
 #define PROTO_STARTTLS	0x40000	 /* client supports STARTTLS */
 #define PROTO_SASL	0x80000  /* client is doing SASL */
 #define PROTO_AWAY_NOTIFY	0x100000	/* client supports away-notify */
+#define PROTO_ACCOUNT_NOTIFY	0x200000	/* client supports account-notify */
 
 /*
  * flags macros.
diff -r bcf167fa19c3 -r cc309e25fec9 src/modules/m_cap.c
--- a/src/modules/m_cap.c	Sun Mar 25 13:50:40 2012 -0500
+++ b/src/modules/m_cap.c	Sun Mar 25 14:08:31 2012 -0500
@@ -72,6 +72,7 @@
 #define CLICAP_FLAGS_CLIACK		0x2
 
 static struct clicap clicap_table[] = {
+	{"account-notify", PROTO_ACCOUNT_NOTIFY, CLICAP_FLAGS_NONE},
 	{"away-notify", PROTO_AWAY_NOTIFY, CLICAP_FLAGS_NONE},
 	{"multi-prefix", PROTO_NAMESX, CLICAP_FLAGS_NONE},
 	{"sasl", PROTO_SASL, CLICAP_FLAGS_NONE},
diff -r bcf167fa19c3 -r cc309e25fec9 src/modules/m_svsmode.c
--- a/src/modules/m_svsmode.c	Sun Mar 25 13:50:40 2012 -0500
+++ b/src/modules/m_svsmode.c	Sun Mar 25 14:08:31 2012 -0500
@@ -514,7 +514,12 @@
 				goto setmodex;
 			case 'd':
 				if (parv[3])
+				{
 					strlcpy(acptr->user->svid, parv[3], sizeof(acptr->user->svid));
+					sendto_common_channels_local_butone(acptr, PROTO_ACCOUNT_NOTIFY, ":%s!%s@%s ACCOUNT %s",
+									    acptr->name, acptr->user->username, GetHost(acptr),
+									    !isdigit(*acptr->user->svid) ? acptr->user->svid : "*");
+				}
 				break;
 			case 'x':
 				if (what == MODE_DEL)
