Code cleanup

Since now there are no server-dependent caps defined in the core
This commit is contained in:
Alexey Sokolov
2024-01-13 23:45:30 +00:00
parent f7ff0ee3f3
commit b1009bd809
9 changed files with 66 additions and 198 deletions

View File

@@ -227,23 +227,7 @@ class CClient : public CIRCSocket {
/** Notifies client about one specific cap which server has just notified us about.
*/
void NotifyServerDependentCap(const CString& sCap, bool bValue, const CString& sValue,
const std::function<void(CClient*, bool)>& handler);
/** Notifies client if the cap is server-dependent, otherwise noop.
*/
void PotentiallyNotifyServerDependentCap(const CString& sCap, bool bValue, const CString& sValue);
/** Notifies client that all these caps are now available.
*
* This function will internally filter only those which are server-dependent.
* This is when new client connects to an already connected server, and
* when server has just connected and finished negotiating caps.
*/
void NotifyServerDependentCaps(const SCString& ssCaps);
/** Notifies client that all server-dependent caps are not available anymore.
*
* Called when server disconnects.
*/
void ClearServerDependentCaps();
void NotifyServerDependentCap(const CString& sCap, bool bValue, const CString& sValue);
void ReadLine(const CString& sData) override;
bool SendMotd();
@@ -323,16 +307,11 @@ class CClient : public CIRCSocket {
std::shared_ptr<CAuthBase> m_spAuth;
SCString m_ssAcceptedCaps;
SCString m_ssSupportedTags;
// The capabilities supported by the ZNC core - capability names mapped
// to a pair which contains a bool describing whether the capability is
// server-dependent, and a capability value change handler.
static const std::map<CString, std::pair<bool, std::function<void(CClient*, bool bVal)>>>&
CoreCaps();
// A subset of CIRCSock::GetAcceptedCaps(), the caps that can be listed
// in CAP LS and may be notified to the client with CAP NEW (cap-notify).
// TODO: come up with a way for modules to work with this, and with
// =values in NEW.
SCString m_ssServerDependentCaps;
// The capabilities supported by the ZNC core - capability names mapped to
// change handler. Note: this lists caps which don't require support on IRC
// server.
static const std::map<CString, std::function<void(CClient*, bool bVal)>>&
CoreCaps();
friend class ClientTest;
friend class CCoreCaps;

View File

@@ -156,8 +156,7 @@ class CIRCNetwork : private CCoreTranslationMixin {
void IRCConnected();
void IRCDisconnected();
void CheckIRCConnect();
void PotentiallyNotifyServerDependentCap(const CString& sCap, bool bValue);
void NotifyClientsAboutServerDependentCap(const CString& sCap, bool bValue, const std::function<void(CClient*, bool)>& handler);
void NotifyClientsAboutServerDependentCap(const CString& sCap, bool bValue);
bool IsServerCapAccepted(const CString& sCap) const;
bool PutIRC(const CString& sLine);

View File

@@ -1312,7 +1312,7 @@ class CModule {
virtual void OnClientDetached();
#ifndef SWIG
void AddCapability(const CString& sName, std::unique_ptr<CCapability> pCap);
void AddServerDependentCapability(const CString& sName, std::unique_ptr<CCapability> pCap);
#endif
/** Called when a client told us CAP LS. Use ssCaps.insert("cap-name")
@@ -1410,7 +1410,7 @@ class CModule {
CString m_sArgs;
CString m_sModPath;
CTranslationDomainRefHolder m_Translation;
std::map<CString, std::unique_ptr<CCapability>> m_mCaps;
std::map<CString, std::unique_ptr<CCapability>> m_mServerDependentCaps;
private:
MCString