diff --git a/Modules.cpp b/Modules.cpp index 5b6e9395..4dfeb1e0 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -100,7 +100,6 @@ const CString& CTimer::GetDescription() const { return m_sDescription; } CModule::CModule(ModHandle pDLL, CUser* pUser, const CString& sModName, const CString& sDataDir) { - m_eType = CModInfo::UserModule; m_pDLL = pDLL; m_pManager = &(CZNC::Get().GetManager());; m_pUser = pUser; @@ -110,19 +109,9 @@ CModule::CModule(ModHandle pDLL, CUser* pUser, const CString& sModName, const CS if (m_pUser) { m_sSavePath = m_pUser->GetUserPath() + "/moddata/" + m_sModName; - LoadRegistry(); + } else { + m_sSavePath = CZNC::Get().GetZNCPath() + "/moddata/" + m_sModName; } -} - -CModule::CModule(ModHandle pDLL, const CString& sModName, const CString& sDataDir) { - m_pDLL = pDLL; - m_pManager = &(CZNC::Get().GetManager()); - m_pUser = NULL; - m_pClient = NULL; - m_sModName = sModName; - m_sDataDir = sDataDir; - - m_sSavePath = CZNC::Get().GetZNCPath() + "/moddata/" + m_sModName; LoadRegistry(); } diff --git a/Modules.h b/Modules.h index 5c8b55dd..2ceddfba 100644 --- a/Modules.h +++ b/Modules.h @@ -49,7 +49,7 @@ template CModule* TModLoad(ModHandle p, CUser* pUser, } template CModule* TModLoadGlobal(ModHandle p, const CString& sModName, const CString& sModPath) { - return new M(p, sModName, sModPath); + return new M(p, NULL, sModName, sModPath); } #if HAVE_VISIBILITY @@ -86,7 +86,6 @@ template CModule* TModLoadGlobal(ModHandle p, * \endcode * * @param CLASS The name of your module's class. - * @see For global modules you need GLOBALMODCONSTRUCTOR. */ #define MODCONSTRUCTOR(CLASS) \ CLASS(ModHandle pDLL, CUser* pUser, const CString& sModName, \ @@ -104,11 +103,6 @@ template CModule* TModLoadGlobal(ModHandle p, // !User Module Macros // Global Module Macros -/** This works exactly like MODCONSTRUCTOR, but for global modules. */ -#define GLOBALMODCONSTRUCTOR(CLASS) \ - CLASS(ModHandle pDLL, const CString& sModName, const CString& sModPath) \ - : CModule(pDLL, sModName, sModPath) - /** This works exactly like MODULEDEFS, but for global modules. */ #define GLOBALMODULEDEFS(CLASS, DESCRIPTION) \ MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::GlobalModule, Info.SetGlobalLoader(TModLoadGlobal)) @@ -312,7 +306,6 @@ class CModule { public: CModule(ModHandle pDLL, CUser* pUser, const CString& sModName, const CString& sDataDir); - CModule(ModHandle pDLL, const CString& sModName, const CString& sDataDir); virtual ~CModule(); /** This enum is just used for return from module hooks. Based on this diff --git a/main.h b/main.h index af4b66ed..af4563ef 100644 --- a/main.h +++ b/main.h @@ -79,8 +79,7 @@ * call #MODULEDEFS at the end of your source file. * Congratulations, you just wrote your first module.
* For global modules, the procedure is similar. Instead of CModule you inherit - * from CModule. The two macros are replaced by #GLOBALMODCONSTRUCTOR and - * #GLOBALMODULEDEFS. + * from CModule. * * If you want your module to actually do something, you should override some * of the hooks from CModule. These are the functions whose names start with diff --git a/modules/adminlog.cpp b/modules/adminlog.cpp index e6bdf6a7..ea316758 100644 --- a/modules/adminlog.cpp +++ b/modules/adminlog.cpp @@ -15,7 +15,7 @@ class CAdminLogMod : public CModule { public: - GLOBALMODCONSTRUCTOR(CAdminLogMod) { + MODCONSTRUCTOR(CAdminLogMod) { openlog("znc", LOG_PID, LOG_DAEMON); } diff --git a/modules/blockuser.cpp b/modules/blockuser.cpp index 71f37fd3..51d420b6 100644 --- a/modules/blockuser.cpp +++ b/modules/blockuser.cpp @@ -14,7 +14,7 @@ class CBlockUser : public CModule { public: - GLOBALMODCONSTRUCTOR(CBlockUser) {} + MODCONSTRUCTOR(CBlockUser) {} virtual ~CBlockUser() {} diff --git a/modules/certauth.cpp b/modules/certauth.cpp index d3747ffc..547dd140 100644 --- a/modules/certauth.cpp +++ b/modules/certauth.cpp @@ -15,7 +15,7 @@ class CSSLClientCertMod : public CModule { public: - GLOBALMODCONSTRUCTOR(CSSLClientCertMod) { + MODCONSTRUCTOR(CSSLClientCertMod) { AddHelpCommand(); AddCommand("Add", static_cast(&CSSLClientCertMod::HandleAddCommand), "[pubkey]", "If pubkey is not provided will use the current key"); diff --git a/modules/extra/droproot.cpp b/modules/extra/droproot.cpp index 9cc3c364..7cbbf8d0 100644 --- a/modules/extra/droproot.cpp +++ b/modules/extra/droproot.cpp @@ -21,7 +21,7 @@ class CDroproot : public CModule { public: - GLOBALMODCONSTRUCTOR(CDroproot) { + MODCONSTRUCTOR(CDroproot) { } virtual ~CDroproot() { diff --git a/modules/extra/imapauth.cpp b/modules/extra/imapauth.cpp index 5545bee7..4572e3c5 100644 --- a/modules/extra/imapauth.cpp +++ b/modules/extra/imapauth.cpp @@ -41,7 +41,7 @@ protected: class CIMAPAuthMod : public CModule { public: - GLOBALMODCONSTRUCTOR(CIMAPAuthMod) { + MODCONSTRUCTOR(CIMAPAuthMod) { m_Cache.SetTTL(60000); m_sServer = "localhost"; m_uPort = 143; diff --git a/modules/extra/motdfile.cpp b/modules/extra/motdfile.cpp index fc1afba2..92b76444 100644 --- a/modules/extra/motdfile.cpp +++ b/modules/extra/motdfile.cpp @@ -12,7 +12,7 @@ class CMotdFileMod : public CModule { public: - GLOBALMODCONSTRUCTOR(CMotdFileMod) {} + MODCONSTRUCTOR(CMotdFileMod) {} virtual ~CMotdFileMod() {} virtual bool OnLoad(const CString& sArgs, CString& sMessage) { diff --git a/modules/extra/notify_connect.cpp b/modules/extra/notify_connect.cpp index 70d023d4..87180faa 100644 --- a/modules/extra/notify_connect.cpp +++ b/modules/extra/notify_connect.cpp @@ -11,7 +11,7 @@ class CNotifyConnectMod : public CModule { public: - GLOBALMODCONSTRUCTOR(CNotifyConnectMod) {} + MODCONSTRUCTOR(CNotifyConnectMod) {} virtual void OnClientLogin() { SendAdmins(m_pUser->GetUserName() + " attached (from " + m_pClient->GetRemoteIP() + ")"); diff --git a/modules/extra/saslauth.cpp b/modules/extra/saslauth.cpp index b2f61687..0b610a3c 100644 --- a/modules/extra/saslauth.cpp +++ b/modules/extra/saslauth.cpp @@ -17,7 +17,7 @@ class CSASLAuthMod : public CModule { public: - GLOBALMODCONSTRUCTOR(CSASLAuthMod) { + MODCONSTRUCTOR(CSASLAuthMod) { m_Cache.SetTTL(60000/*ms*/); } virtual ~CSASLAuthMod() {} diff --git a/modules/fail2ban.cpp b/modules/fail2ban.cpp index a232d4c8..80c579f9 100644 --- a/modules/fail2ban.cpp +++ b/modules/fail2ban.cpp @@ -10,7 +10,7 @@ class CFailToBanMod : public CModule { public: - GLOBALMODCONSTRUCTOR(CFailToBanMod) {} + MODCONSTRUCTOR(CFailToBanMod) {} virtual ~CFailToBanMod() {} virtual bool OnLoad(const CString& sArgs, CString& sMessage) { diff --git a/modules/identfile.cpp b/modules/identfile.cpp index d0961db0..b51e9543 100644 --- a/modules/identfile.cpp +++ b/modules/identfile.cpp @@ -17,7 +17,7 @@ class CIdentFileModule : public CModule { CIRCSock *m_pIRCSock; public: - GLOBALMODCONSTRUCTOR(CIdentFileModule) { + MODCONSTRUCTOR(CIdentFileModule) { AddHelpCommand(); AddCommand("GetFile", static_cast(&CIdentFileModule::GetFile)); AddCommand("SetFile", static_cast(&CIdentFileModule::SetFile), diff --git a/modules/lastseen.cpp b/modules/lastseen.cpp index 048a32e2..957c5c5d 100644 --- a/modules/lastseen.cpp +++ b/modules/lastseen.cpp @@ -61,7 +61,7 @@ private: } public: - GLOBALMODCONSTRUCTOR(CLastSeenMod) { + MODCONSTRUCTOR(CLastSeenMod) { AddHelpCommand(); AddCommand("Show", static_cast(&CLastSeenMod::ShowCommand)); } diff --git a/modules/modperl.cpp b/modules/modperl.cpp index 3ab00458..a79ff620 100644 --- a/modules/modperl.cpp +++ b/modules/modperl.cpp @@ -34,7 +34,7 @@ extern "C" { class CModPerl: public CModule { PerlInterpreter *m_pPerl; public: - GLOBALMODCONSTRUCTOR(CModPerl) { + MODCONSTRUCTOR(CModPerl) { m_pPerl = NULL; } diff --git a/modules/modpython.cpp b/modules/modpython.cpp index 9b0c2153..f4b858e5 100644 --- a/modules/modpython.cpp +++ b/modules/modpython.cpp @@ -69,7 +69,7 @@ public: return result; } - GLOBALMODCONSTRUCTOR(CModPython) { + MODCONSTRUCTOR(CModPython) { Py_Initialize(); m_PyFormatException = NULL; m_PyZNCModule = NULL; diff --git a/modules/modpython/module.h b/modules/modpython/module.h index 02b828c0..7e8df7c2 100644 --- a/modules/modpython/module.h +++ b/modules/modpython/module.h @@ -25,7 +25,7 @@ class CPyModule : public CModule { public: CPyModule(const CString& sModName, const CString& sDataPath, PyObject* pyObj, CModule* pModPython) - : CModule(NULL, sModName, sDataPath) { + : CModule(NULL, NULL, sModName, sDataPath) { m_pyObj = pyObj; Py_INCREF(pyObj); m_pModPython = reinterpret_cast(pModPython); diff --git a/modules/partyline.cpp b/modules/partyline.cpp index f37add05..20877af8 100644 --- a/modules/partyline.cpp +++ b/modules/partyline.cpp @@ -43,7 +43,7 @@ protected: class CPartylineMod : public CModule { public: - GLOBALMODCONSTRUCTOR(CPartylineMod) {} + MODCONSTRUCTOR(CPartylineMod) {} virtual ~CPartylineMod() { while (m_ssChannels.size()) { diff --git a/modules/webadmin.cpp b/modules/webadmin.cpp index 0b5973d1..4a41e63b 100644 --- a/modules/webadmin.cpp +++ b/modules/webadmin.cpp @@ -53,7 +53,7 @@ inline bool FOR_EACH_MODULE_CanContinue(FOR_EACH_MODULE_Type& state, CModules::i class CWebAdminMod : public CModule { public: - GLOBALMODCONSTRUCTOR(CWebAdminMod) { + MODCONSTRUCTOR(CWebAdminMod) { VPair vParams; vParams.push_back(make_pair("user", "")); AddSubPage(new CWebSubPage("settings", "Global Settings", CWebSubPage::F_ADMIN));