mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Add module calls for client CAPs
This commit adds new module calls which make it possibly to announce new capabilities from a module. Thanks to DarthGandalf for the patch and for not going mad from my comments. :) git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2071 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
55
Client.cpp
55
Client.cpp
@@ -783,33 +783,29 @@ void CClient::HandleCap(const CString& sLine)
|
||||
CString sSubCmd = sLine.Token(1);
|
||||
|
||||
if (sSubCmd.Equals("LS")) {
|
||||
RespondCap("LS :userhost-in-names multi-prefix");
|
||||
SCString ssOfferCaps;
|
||||
CZNC::Get().GetModules().OnClientCapLs(ssOfferCaps);
|
||||
CString sRes;
|
||||
for (SCString::iterator i = ssOfferCaps.begin(); i != ssOfferCaps.end(); ++i) {
|
||||
sRes += *i + " ";
|
||||
}
|
||||
RespondCap("LS :" + sRes + "userhost-in-names multi-prefix");
|
||||
m_bInCap = true;
|
||||
} else if (sSubCmd.Equals("END")) {
|
||||
m_bInCap = false;
|
||||
AuthUser();
|
||||
} else if (sSubCmd.Equals("REQ")) {
|
||||
bool bReqUHNames = false;
|
||||
bool bReqNamesx = false;
|
||||
bool bValueUHNames = false;
|
||||
bool bValueNamesx = false;
|
||||
|
||||
VCString vsTokens;
|
||||
VCString::iterator it;
|
||||
sLine.Token(2, true).TrimPrefix_n(":").Split(" ", vsTokens, false);
|
||||
|
||||
for (it = vsTokens.begin(); it != vsTokens.end(); ++it) {
|
||||
bool bVal = true;
|
||||
if (it->TrimPrefix("-"))
|
||||
CString sCap = *it;
|
||||
if (sCap.TrimPrefix("-"))
|
||||
bVal = false;
|
||||
|
||||
if (*it == "multi-prefix") {
|
||||
bReqNamesx = true;
|
||||
bValueNamesx = bVal;
|
||||
} else if (*it == "userhost-in-names") {
|
||||
bReqUHNames = true;
|
||||
bValueUHNames = bVal;
|
||||
} else {
|
||||
if ("multi-prefix" != sCap && "userhost-in-names" != sCap && !CZNC::Get().GetModules().IsClientCapSupported(sCap, bVal)) {
|
||||
// Some unsupported capability is requested
|
||||
RespondCap("NAK :" + sLine.Token(2, true).TrimPrefix_n(":"));
|
||||
return;
|
||||
@@ -817,17 +813,32 @@ void CClient::HandleCap(const CString& sLine)
|
||||
}
|
||||
|
||||
// All is fine, we support what was requested
|
||||
for (it = vsTokens.begin(); it != vsTokens.end(); ++it) {
|
||||
bool bVal = true;
|
||||
if (it->TrimPrefix("-"))
|
||||
bVal = false;
|
||||
|
||||
if ("multi-prefix" == *it) {
|
||||
m_bNamesx = bVal;
|
||||
} else if ("userhost-in-names" == *it) {
|
||||
m_bUHNames = bVal;
|
||||
} else {
|
||||
CZNC::Get().GetModules().OnClientCapRequest(this, *it, bVal);
|
||||
}
|
||||
|
||||
if (bVal) {
|
||||
m_ssAcceptedCaps.insert(*it);
|
||||
} else {
|
||||
m_ssAcceptedCaps.erase(*it);
|
||||
}
|
||||
}
|
||||
|
||||
RespondCap("ACK :" + sLine.Token(2, true).TrimPrefix_n(":"));
|
||||
if (bReqUHNames)
|
||||
m_bUHNames = bValueUHNames;
|
||||
if (bReqNamesx)
|
||||
m_bNamesx = bValueNamesx;
|
||||
} else if (sSubCmd.Equals("LIST")) {
|
||||
CString sList = "";
|
||||
if (m_bNamesx)
|
||||
sList += "multi-prefix ";
|
||||
if (m_bUHNames)
|
||||
sList += "userhost-in-names ";
|
||||
for (SCString::iterator i = m_ssAcceptedCaps.begin(); i != m_ssAcceptedCaps.end(); ++i) {
|
||||
sList += *i + " ";
|
||||
}
|
||||
RespondCap("LIST :" + sList.TrimSuffix_n(" "));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user