Module: ngircd.git Branch: master Commit: 4602cb9891a0234e391d56ac4b2491d134020f1b URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=4602c...
Author: Alexander Barton alex@barton.de Date: Sat Apr 28 00:38:51 2012 +0200
"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
---
contrib/MacOSX/ngIRCd.xcodeproj/project.pbxproj | 2 +- src/ngircd/irc-info.c | 29 +++++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/contrib/MacOSX/ngIRCd.xcodeproj/project.pbxproj b/contrib/MacOSX/ngIRCd.xcodeproj/project.pbxproj index d89d379..23026c6 100644 --- a/contrib/MacOSX/ngIRCd.xcodeproj/project.pbxproj +++ b/contrib/MacOSX/ngIRCd.xcodeproj/project.pbxproj @@ -682,7 +682,7 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0420; + LastUpgradeCheck = 0430; }; buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "ngIRCd" */; compatibilityVersion = "Xcode 3.2"; diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c index 38b9a7d..0ea8587 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)) {