about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2012-04-28 00:38:51 +0200
committerAlexander Barton <alex@barton.de>2012-04-28 00:39:21 +0200
commit4602cb9891a0234e391d56ac4b2491d134020f1b (patch)
tree2472437fe00cc4242aeec501924e121631fdceac /src
parent1d7e99531a6f713a04bbc91a6f7f2963c9ece75c (diff)
downloadngircd-4602cb9891a0234e391d56ac4b2491d134020f1b.tar.gz
ngircd-4602cb9891a0234e391d56ac4b2491d134020f1b.zip
"multi-prefix" capability 2/2: adjust NAME and WHO handlers
The NAME and WHO commands now return multiple usermode prfixes when
the "multi-prefix" capability is in effect for the requesting client.

See <http://ircv3.atheme.org/extensions/multi-prefix-3.1>
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/irc-info.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c
index 38b9a7d6..0ea85874 100644
--- a/src/ngircd/irc-info.c
+++ b/src/ngircd/irc-info.c
@@ -39,6 +39,7 @@
 #include "parse.h"
 #include "irc.h"
 #include "irc-write.h"
+#include "client-cap.h"
 
 #include "exp.h"
 #include "irc-info.h"
@@ -807,8 +808,16 @@ who_flags_status(const char *client_modes)
 
 
 static const char *
-who_flags_qualifier(const char *chan_user_modes)
+who_flags_qualifier(CLIENT *Client, const char *chan_user_modes)
 {
+	assert(Client != NULL);
+
+	if (Client_Cap(Client) & CLIENT_CAP_MULTI_PREFIX) {
+		if (strchr(chan_user_modes, 'o') &&
+		    strchr(chan_user_modes, 'v'))
+			return "@+";
+	}
+
 	if (strchr(chan_user_modes, 'o'))
 		return "@";
 	else if (strchr(chan_user_modes, 'v'))
@@ -865,7 +874,7 @@ IRC_WHO_Channel(CLIENT *Client, CHANNEL *Chan, bool OnlyOps)
 				strlcat(flags, "*", sizeof(flags));
 
 			chan_user_modes = Channel_UserModes(Chan, c);
-			strlcat(flags, who_flags_qualifier(chan_user_modes),
+			strlcat(flags, who_flags_qualifier(c, chan_user_modes),
 				sizeof(flags));
 
 			if (!write_whoreply(Client, c, Channel_Name(Chan),
@@ -1078,7 +1087,7 @@ IRC_WHOIS_SendReply(CLIENT *Client, CLIENT *from, CLIENT *c)
 		if (str[strlen(str) - 1] != ':')
 			strlcat(str, " ", sizeof(str));
 
-		strlcat(str, who_flags_qualifier(Channel_UserModes(chan, c)),
+		strlcat(str, who_flags_qualifier(c, Channel_UserModes(chan, c)),
 						 sizeof(str));
 		strlcat(str, Channel_Name(chan), sizeof(str));
 
@@ -1569,10 +1578,16 @@ IRC_Send_NAMES(CLIENT * Client, CHANNEL * Chan)
 		if (is_member || is_visible) {
 			if (str[strlen(str) - 1] != ':')
 				strlcat(str, " ", sizeof(str));
-			if (strchr(Channel_UserModes(Chan, cl), 'o'))
-				strlcat(str, "@", sizeof(str));
-			else if (strchr(Channel_UserModes(Chan, cl), 'v'))
-				strlcat(str, "+", sizeof(str));
+			if (Client_Cap(cl) & CLIENT_CAP_MULTI_PREFIX) {
+				if (strchr(Channel_UserModes(Chan, cl), 'o') &&
+				    strchr(Channel_UserModes(Chan, cl), 'v'))
+					strlcat(str, "@+", sizeof(str));
+			} else {
+				if (strchr(Channel_UserModes(Chan, cl), 'o'))
+					strlcat(str, "@", sizeof(str));
+				else if (strchr(Channel_UserModes(Chan, cl), 'v'))
+					strlcat(str, "+", sizeof(str));
+			}
 			strlcat(str, Client_ID(cl), sizeof(str));
 
 			if (strlen(str) > (LINE_LEN - CLIENT_NICK_LEN - 4)) {