]> arthur.barton.de Git - ngircd-alex.git/commitdiff
"multi-prefix" capability 2/2: adjust NAME and WHO handlers capabilities
authorAlexander Barton <alex@barton.de>
Fri, 27 Apr 2012 22:38:51 +0000 (00:38 +0200)
committerAlexander Barton <alex@barton.de>
Fri, 27 Apr 2012 22:39:21 +0000 (00:39 +0200)
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>

contrib/MacOSX/ngIRCd.xcodeproj/project.pbxproj
src/ngircd/irc-info.c

index d89d3792aa9778dcc7bd9575cb5ebb495c568157..23026c64269f09db09947d9148cf26dcdba3ed8b 100644 (file)
                08FB7793FE84155DC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        attributes = {
-                               LastUpgradeCheck = 0420;
+                               LastUpgradeCheck = 0430;
                        };
                        buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "ngIRCd" */;
                        compatibilityVersion = "Xcode 3.2";
index 38b9a7d64f8cb89bd45f0b3ac34a291c3afa193c..0ea85874862b7114b6cd355d59467371055a4013 100644 (file)
@@ -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)) {