From d18601180b82fe12a3ccbad21bc7b8c216be397a Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 14 Jul 2015 16:49:57 +0200 Subject: [PATCH 1/3] Align server-side cap handling code with the client-side Based on d7a6a136dbdd04af2c9f403a362f63d010fb00af - to make it more straight-forward to add support for more server-side capabilities. --- src/IRCSock.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index eae144d4..e76a8351 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -805,24 +805,27 @@ void CIRCSock::ReadLine(const CString& sData) { sArgs = sRest.Token(2, true).TrimPrefix_n(); } + std::map> mSupportedCaps = { + {"multi-prefix", [this](bool bVal) { m_bNamesx = bVal; }}, + {"userhost-in-names", [this](bool bVal) { m_bUHNames = bVal; }}, + {"away-notify", [this](bool bVal) { m_bAwayNotify = bVal; }}, + }; + if (sSubCmd == "LS") { VCString vsTokens; sArgs.Split(" ", vsTokens, false); for (const CString& sCap : vsTokens) { - if (OnServerCapAvailable(sCap) || sCap == "multi-prefix" || sCap == "userhost-in-names" || sCap == "away-notify") { + if (OnServerCapAvailable(sCap) || mSupportedCaps.count(sCap)) { m_ssPendingCaps.insert(sCap); } } } else if (sSubCmd == "ACK") { sArgs.Trim(); IRCSOCKMODULECALL(OnServerCapResult(sArgs, true), NOTHING); - if ("multi-prefix" == sArgs) { - m_bNamesx = true; - } else if ("userhost-in-names" == sArgs) { - m_bUHNames = true; - } else if ("away-notify" == sArgs) { - m_bAwayNotify = true; + const auto& it = mSupportedCaps.find(sArgs); + if (it != mSupportedCaps.end()) { + it->second(true); } m_ssAcceptedCaps.insert(sArgs); } else if (sSubCmd == "NAK") { From d070a6e644349dd75222b32f24c06168db777181 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 14 Jul 2015 14:26:20 +0200 Subject: [PATCH 2/3] Add support for account-notify (#316) --- include/znc/Client.h | 4 ++++ include/znc/IRCSock.h | 2 ++ src/IRCSock.cpp | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/include/znc/Client.h b/include/znc/Client.h index 70a31b24..f58f3f9a 100644 --- a/include/znc/Client.h +++ b/include/znc/Client.h @@ -97,6 +97,7 @@ public: m_bInCap(false), m_bCapNotify(false), m_bAwayNotify(false), + m_bAccountNotify(false), m_bNamesx(false), m_bUHNames(false), m_bAway(false), @@ -121,6 +122,7 @@ public: {"batch", {false, [this](bool bVal) { m_bBatch = bVal; }}}, {"cap-notify", {false, [this](bool bVal) { m_bCapNotify = bVal; }}}, {"away-notify", {true, [this](bool bVal) { m_bAwayNotify = bVal; }}}, + {"account-notify", {true, [this](bool bVal) { m_bAccountNotify = bVal; }}}, }) { EnableReadLine(); @@ -148,6 +150,7 @@ public: CString GetIdentifier() const { return m_sIdentifier; } bool HasCapNotify() const { return m_bCapNotify; } bool HasAwayNotify() const { return m_bAwayNotify; } + bool HasAccountNotify() const { return m_bAccountNotify; } bool HasNamesx() const { return m_bNamesx; } bool HasUHNames() const { return m_bUHNames; } bool IsAway() const { return m_bAway; } @@ -213,6 +216,7 @@ protected: bool m_bInCap; bool m_bCapNotify; bool m_bAwayNotify; + bool m_bAccountNotify; bool m_bNamesx; bool m_bUHNames; bool m_bAway; diff --git a/include/znc/IRCSock.h b/include/znc/IRCSock.h index 5ff736a5..db197b1d 100644 --- a/include/znc/IRCSock.h +++ b/include/znc/IRCSock.h @@ -102,6 +102,7 @@ public: bool HasNamesx() const { return m_bNamesx; } bool HasUHNames() const { return m_bUHNames; } bool HasAwayNotify() const { return m_bAwayNotify; } + bool HasAccountNotify() const { return m_bAccountNotify; } const std::set& GetUserModes() const { return m_scUserModes; } // This is true if we are past raw 001 bool IsAuthed() const { return m_bAuthed; } @@ -129,6 +130,7 @@ protected: bool m_bNamesx; bool m_bUHNames; bool m_bAwayNotify; + bool m_bAccountNotify; CString m_sPerms; CString m_sPermModes; std::set m_scUserModes; diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index e76a8351..2e6ab49c 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -61,6 +61,7 @@ CIRCSock::CIRCSock(CIRCNetwork* pNetwork) m_bNamesx(false), m_bUHNames(false), m_bAwayNotify(false), + m_bAccountNotify(false), m_sPerms("*!@%+"), m_sPermModes("qaohv"), m_scUserModes(), @@ -809,6 +810,7 @@ void CIRCSock::ReadLine(const CString& sData) { {"multi-prefix", [this](bool bVal) { m_bNamesx = bVal; }}, {"userhost-in-names", [this](bool bVal) { m_bUHNames = bVal; }}, {"away-notify", [this](bool bVal) { m_bAwayNotify = bVal; }}, + {"account-notify", [this](bool bVal) { m_bAccountNotify = bVal; }}, }; if (sSubCmd == "LS") { @@ -850,6 +852,14 @@ void CIRCSock::ReadLine(const CString& sData) { } } return; + } else if (sCmd.Equals("ACCOUNT")) { + const vector& vClients = m_pNetwork->GetClients(); + for (CClient* pClient : vClients) { + if (pClient->HasAccountNotify()) { + m_pNetwork->PutUser(sLine, pClient); + } + } + return; } } From 6246899c56e7b69797bd000b68eda0d503fcd73d Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 14 Jul 2015 18:29:33 +0200 Subject: [PATCH 3/3] Add support for extended-join (#316) --- include/znc/Client.h | 4 ++++ include/znc/IRCSock.h | 2 ++ src/IRCSock.cpp | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/include/znc/Client.h b/include/znc/Client.h index f58f3f9a..f9ae87c2 100644 --- a/include/znc/Client.h +++ b/include/znc/Client.h @@ -98,6 +98,7 @@ public: m_bCapNotify(false), m_bAwayNotify(false), m_bAccountNotify(false), + m_bExtendedJoin(false), m_bNamesx(false), m_bUHNames(false), m_bAway(false), @@ -123,6 +124,7 @@ public: {"cap-notify", {false, [this](bool bVal) { m_bCapNotify = bVal; }}}, {"away-notify", {true, [this](bool bVal) { m_bAwayNotify = bVal; }}}, {"account-notify", {true, [this](bool bVal) { m_bAccountNotify = bVal; }}}, + {"extended-join", {true, [this](bool bVal) { m_bExtendedJoin = bVal; }}}, }) { EnableReadLine(); @@ -151,6 +153,7 @@ public: bool HasCapNotify() const { return m_bCapNotify; } bool HasAwayNotify() const { return m_bAwayNotify; } bool HasAccountNotify() const { return m_bAccountNotify; } + bool HasExtendedJoin() const { return m_bExtendedJoin; } bool HasNamesx() const { return m_bNamesx; } bool HasUHNames() const { return m_bUHNames; } bool IsAway() const { return m_bAway; } @@ -217,6 +220,7 @@ protected: bool m_bCapNotify; bool m_bAwayNotify; bool m_bAccountNotify; + bool m_bExtendedJoin; bool m_bNamesx; bool m_bUHNames; bool m_bAway; diff --git a/include/znc/IRCSock.h b/include/znc/IRCSock.h index db197b1d..a6949529 100644 --- a/include/znc/IRCSock.h +++ b/include/znc/IRCSock.h @@ -103,6 +103,7 @@ public: bool HasUHNames() const { return m_bUHNames; } bool HasAwayNotify() const { return m_bAwayNotify; } bool HasAccountNotify() const { return m_bAccountNotify; } + bool HasExtendedJoin() const { return m_bExtendedJoin; } const std::set& GetUserModes() const { return m_scUserModes; } // This is true if we are past raw 001 bool IsAuthed() const { return m_bAuthed; } @@ -131,6 +132,7 @@ protected: bool m_bUHNames; bool m_bAwayNotify; bool m_bAccountNotify; + bool m_bExtendedJoin; CString m_sPerms; CString m_sPermModes; std::set m_scUserModes; diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index 2e6ab49c..64fd091f 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -62,6 +62,7 @@ CIRCSock::CIRCSock(CIRCNetwork* pNetwork) m_bUHNames(false), m_bAwayNotify(false), m_bAccountNotify(false), + m_bExtendedJoin(false), m_sPerms("*!@%+"), m_sPermModes("qaohv"), m_scUserModes(), @@ -591,6 +592,21 @@ void CIRCSock::ReadLine(const CString& sData) { if (pChan->IsDetached()) { return; } + + if (HasExtendedJoin()) { + CString sExtendedLine = sLine; + sLine = ":" + Nick.GetNickMask() + " JOIN " + pChan->GetName(); + + const vector& vClients = m_pNetwork->GetClients(); + for (CClient* pClient : vClients) { + if (pClient->HasExtendedJoin()) { + m_pNetwork->PutUser(sExtendedLine, pClient); + } else { + m_pNetwork->PutUser(sLine, pClient); + } + } + return; + } } } else if (sCmd.Equals("PART")) { CString sChan = sRest.Token(0).TrimPrefix_n(); @@ -811,6 +827,7 @@ void CIRCSock::ReadLine(const CString& sData) { {"userhost-in-names", [this](bool bVal) { m_bUHNames = bVal; }}, {"away-notify", [this](bool bVal) { m_bAwayNotify = bVal; }}, {"account-notify", [this](bool bVal) { m_bAccountNotify = bVal; }}, + {"extended-join", [this](bool bVal) { m_bExtendedJoin = bVal; }}, }; if (sSubCmd == "LS") {