From 4602cb9891a0234e391d56ac4b2491d134020f1b Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Sat, 28 Apr 2012 00:38:51 +0200 Subject: [PATCH] "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 --- .../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 d89d3792..23026c64 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 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)) { -- 2.39.2