Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge CGlobalModule(s) into CModule(s)

  • Loading branch information...
commit c456d20b216d4284ddd88f7e91798b5c5886608c 1 parent a4b1559
@kylef kylef authored
View
95 Modules.cpp
@@ -19,10 +19,10 @@
# warning "your crap box doesnt define RTLD_LOCAL !?"
#endif
-#define _MODUNLOADCHK(func, type) \
+#define MODUNLOADCHK(func) \
for (unsigned int a = 0; a < size(); a++) { \
try { \
- type* pMod = (type *) (*this)[a]; \
+ CModule* pMod = (CModule *) (*this)[a]; \
CClient* pOldClient = pMod->GetClient(); \
pMod->SetClient(m_pClient); \
if (m_pUser) { \
@@ -41,14 +41,12 @@
} \
}
-#define MODUNLOADCHK(func) _MODUNLOADCHK(func, CModule)
-#define GLOBALMODCALL(func) _MODUNLOADCHK(func, CGlobalModule)
-#define _MODHALTCHK(func, type) \
+#define MODHALTCHK(func) \
bool bHaltCore = false; \
for (unsigned int a = 0; a < size(); a++) { \
try { \
- type* pMod = (type*) (*this)[a]; \
+ CModule* pMod = (CModule*) (*this)[a]; \
CModule::EModRet e = CModule::CONTINUE; \
CClient* pOldClient = pMod->GetClient(); \
pMod->SetClient(m_pClient); \
@@ -77,9 +75,6 @@
} \
return bHaltCore;
-#define MODHALTCHK(func) _MODHALTCHK(func, CModule)
-#define GLOBALMODHALTCHK(func) _MODHALTCHK(func, CGlobalModule)
-
/////////////////// Timer ///////////////////
CTimer::CTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription) : CCron() {
SetName(sLabel);
@@ -570,25 +565,25 @@ bool CModule::PutModNotice(const CString& sLine) {
}
///////////////////
-// CGlobalModule //
+// Global Module //
///////////////////
-CModule::EModRet CGlobalModule::OnAddUser(CUser& User, CString& sErrorRet) { return CONTINUE; }
-CModule::EModRet CGlobalModule::OnDeleteUser(CUser& User) { return CONTINUE; }
-void CGlobalModule::OnClientConnect(CZNCSock* pClient, const CString& sHost, unsigned short uPort) {}
-CModule::EModRet CGlobalModule::OnLoginAttempt(CSmartPtr<CAuthBase> Auth) { return CONTINUE; }
-void CGlobalModule::OnFailedLogin(const CString& sUsername, const CString& sRemoteIP) {}
-CModule::EModRet CGlobalModule::OnUnknownUserRaw(CString& sLine) { return CONTINUE; }
-void CGlobalModule::OnClientCapLs(SCString& ssCaps) {}
-bool CGlobalModule::IsClientCapSupported(const CString& sCap, bool bState) { return false; }
-void CGlobalModule::OnClientCapRequest(const CString& sCap, bool bState) {}
-CModule::EModRet CGlobalModule::OnModuleLoading(const CString& sModName, const CString& sArgs,
+CModule::EModRet CModule::OnAddUser(CUser& User, CString& sErrorRet) { return CONTINUE; }
+CModule::EModRet CModule::OnDeleteUser(CUser& User) { return CONTINUE; }
+void CModule::OnClientConnect(CZNCSock* pClient, const CString& sHost, unsigned short uPort) {}
+CModule::EModRet CModule::OnLoginAttempt(CSmartPtr<CAuthBase> Auth) { return CONTINUE; }
+void CModule::OnFailedLogin(const CString& sUsername, const CString& sRemoteIP) {}
+CModule::EModRet CModule::OnUnknownUserRaw(CString& sLine) { return CONTINUE; }
+void CModule::OnClientCapLs(SCString& ssCaps) {}
+bool CModule::IsClientCapSupported(const CString& sCap, bool bState) { return false; }
+void CModule::OnClientCapRequest(const CString& sCap, bool bState) {}
+CModule::EModRet CModule::OnModuleLoading(const CString& sModName, const CString& sArgs,
bool& bSuccess, CString& sRetMsg) { return CONTINUE; }
-CModule::EModRet CGlobalModule::OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg) {
+CModule::EModRet CModule::OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg) {
return CONTINUE;
}
-CModule::EModRet CGlobalModule::OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
+CModule::EModRet CModule::OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
bool& bSuccess, CString& sRetMsg) { return CONTINUE; }
-void CGlobalModule::OnGetAvailableMods(set<CModInfo>& ssMods, EModuleType eType) {}
+void CModule::OnGetAvailableMods(set<CModInfo>& ssMods, EModuleType eType) {}
CModules::CModules() {
@@ -709,45 +704,45 @@ bool CModules::OnServerCapAvailable(const CString& sCap) {
bool CModules::OnServerCapResult(const CString& sCap, bool bSuccess) { MODUNLOADCHK(OnServerCapResult(sCap, bSuccess)); return false; }
////////////////////
-// CGlobalModules //
+// Global Modules //
////////////////////
-bool CGlobalModules::OnAddUser(CUser& User, CString& sErrorRet) {
- GLOBALMODHALTCHK(OnAddUser(User, sErrorRet));
+bool CModules::OnAddUser(CUser& User, CString& sErrorRet) {
+ MODHALTCHK(OnAddUser(User, sErrorRet));
}
-bool CGlobalModules::OnDeleteUser(CUser& User) {
- GLOBALMODHALTCHK(OnDeleteUser(User));
+bool CModules::OnDeleteUser(CUser& User) {
+ MODHALTCHK(OnDeleteUser(User));
}
-bool CGlobalModules::OnClientConnect(CZNCSock* pClient, const CString& sHost, unsigned short uPort) {
- GLOBALMODCALL(OnClientConnect(pClient, sHost, uPort));
+bool CModules::OnClientConnect(CZNCSock* pClient, const CString& sHost, unsigned short uPort) {
+ MODUNLOADCHK(OnClientConnect(pClient, sHost, uPort));
return false;
}
-bool CGlobalModules::OnLoginAttempt(CSmartPtr<CAuthBase> Auth) {
- GLOBALMODHALTCHK(OnLoginAttempt(Auth));
+bool CModules::OnLoginAttempt(CSmartPtr<CAuthBase> Auth) {
+ MODHALTCHK(OnLoginAttempt(Auth));
}
-bool CGlobalModules::OnFailedLogin(const CString& sUsername, const CString& sRemoteIP) {
- GLOBALMODCALL(OnFailedLogin(sUsername, sRemoteIP));
+bool CModules::OnFailedLogin(const CString& sUsername, const CString& sRemoteIP) {
+ MODUNLOADCHK(OnFailedLogin(sUsername, sRemoteIP));
return false;
}
-bool CGlobalModules::OnUnknownUserRaw(CString& sLine) {
- GLOBALMODHALTCHK(OnUnknownUserRaw(sLine));
+bool CModules::OnUnknownUserRaw(CString& sLine) {
+ MODHALTCHK(OnUnknownUserRaw(sLine));
}
-bool CGlobalModules::OnClientCapLs(SCString& ssCaps) {
- GLOBALMODCALL(OnClientCapLs(ssCaps));
+bool CModules::OnClientCapLs(SCString& ssCaps) {
+ MODUNLOADCHK(OnClientCapLs(ssCaps));
return false;
}
// Maybe create new macro for this?
-bool CGlobalModules::IsClientCapSupported(const CString& sCap, bool bState) {
+bool CModules::IsClientCapSupported(const CString& sCap, bool bState) {
bool bResult = false;
for (unsigned int a = 0; a < size(); ++a) {
try {
- CGlobalModule* pMod = (CGlobalModule*) (*this)[a];
+ CModule* pMod = (CModule*) (*this)[a];
CClient* pOldClient = pMod->GetClient();
pMod->SetClient(m_pClient);
if (m_pUser) {
@@ -769,27 +764,27 @@ bool CGlobalModules::IsClientCapSupported(const CString& sCap, bool bState) {
return bResult;
}
-bool CGlobalModules::OnClientCapRequest(const CString& sCap, bool bState) {
- GLOBALMODCALL(OnClientCapRequest(sCap, bState));
+bool CModules::OnClientCapRequest(const CString& sCap, bool bState) {
+ MODUNLOADCHK(OnClientCapRequest(sCap, bState));
return false;
}
-bool CGlobalModules::OnModuleLoading(const CString& sModName, const CString& sArgs,
+bool CModules::OnModuleLoading(const CString& sModName, const CString& sArgs,
bool& bSuccess, CString& sRetMsg) {
- GLOBALMODHALTCHK(OnModuleLoading(sModName, sArgs, bSuccess, sRetMsg));
+ MODHALTCHK(OnModuleLoading(sModName, sArgs, bSuccess, sRetMsg));
}
-bool CGlobalModules::OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg) {
- GLOBALMODHALTCHK(OnModuleUnloading(pModule, bSuccess, sRetMsg));
+bool CModules::OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg) {
+ MODHALTCHK(OnModuleUnloading(pModule, bSuccess, sRetMsg));
}
-bool CGlobalModules::OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
+bool CModules::OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
bool& bSuccess, CString& sRetMsg) {
- GLOBALMODHALTCHK(OnGetModInfo(ModInfo, sModule, bSuccess, sRetMsg));
+ MODHALTCHK(OnGetModInfo(ModInfo, sModule, bSuccess, sRetMsg));
}
-bool CGlobalModules::OnGetAvailableMods(set<CModInfo>& ssMods, EModuleType eType) {
- GLOBALMODCALL(OnGetAvailableMods(ssMods, eType));
+bool CModules::OnGetAvailableMods(set<CModInfo>& ssMods, EModuleType eType) {
+ MODUNLOADCHK(OnGetAvailableMods(ssMods, eType));
return false;
}
View
229 Modules.h
@@ -25,7 +25,6 @@ class CWebSock;
class CTemplate;
class CIRCSock;
class CModule;
-class CGlobalModule;
class CModInfo;
// !Forward Declarations
@@ -53,7 +52,7 @@ template<class M> CModule* TModLoad(ModHandle p, CUser* pUser,
const CString& sModName, const CString& sModPath) {
return new M(p, pUser, sModName, sModPath);
}
-template<class M> CGlobalModule* TModLoadGlobal(ModHandle p,
+template<class M> CModule* TModLoadGlobal(ModHandle p,
const CString& sModName, const CString& sModPath) {
return new M(p, sModName, sModPath);
}
@@ -113,7 +112,7 @@ template<class M> CGlobalModule* TModLoadGlobal(ModHandle p,
/** This works exactly like MODCONSTRUCTOR, but for global modules. */
#define GLOBALMODCONSTRUCTOR(CLASS) \
CLASS(ModHandle pDLL, const CString& sModName, const CString& sModPath) \
- : CGlobalModule(pDLL, sModName, sModPath)
+ : CModule(pDLL, sModName, sModPath)
/** This works exactly like MODULEDEFS, but for global modules. */
#define GLOBALMODULEDEFS(CLASS, DESCRIPTION) \
@@ -178,7 +177,7 @@ class CFPTimer : public CTimer {
class CModInfo {
public:
typedef CModule* (*ModLoader)(ModHandle p, CUser* pUser, const CString& sModName, const CString& sModPath);
- typedef CGlobalModule* (*GlobalModLoader)(ModHandle p, const CString& sModName, const CString& sModPath);
+ typedef CModule* (*GlobalModLoader)(ModHandle p, const CString& sModName, const CString& sModPath);
CModInfo() {
m_fGlobalLoader = NULL;
@@ -874,6 +873,98 @@ class CModule {
CSockManager* GetManager() { return m_pManager; }
// !Getters
+ // Global Modules
+ /** This module hook is called when a user is being added.
+ * @param User The user which will be added.
+ * @param sErrorRet A message that may be displayed to the user if
+ * the module stops adding the user.
+ * @return See CModule::EModRet.
+ */
+ virtual EModRet OnAddUser(CUser& User, CString& sErrorRet);
+ /** This module hook is called when a user is deleted.
+ * @param User The user which will be deleted.
+ * @return See CModule::EModRet.
+ */
+ virtual EModRet OnDeleteUser(CUser& User);
+ /** This module hook is called when there is an incoming connection on
+ * any of ZNC's listening sockets.
+ * @param pSock The incoming client socket.
+ * @param sHost The IP the client is connecting from.
+ * @param uPort The port the client is connecting from.
+ */
+ virtual void OnClientConnect(CZNCSock* pSock, const CString& sHost, unsigned short uPort);
+ /** This module hook is called when a client tries to login. If your
+ * module wants to handle the login attempt, it must return
+ * CModule::EModRet::HALT;
+ * @param Auth The necessary authentication info for this login attempt.
+ * @return See CModule::EModRet.
+ */
+ virtual EModRet OnLoginAttempt(CSmartPtr<CAuthBase> Auth);
+ /** Called after a client login was rejected.
+ * @param sUsername The username that tried to log in.
+ * @param sRemoteIP The IP address from which the client tried to login.
+ */
+ virtual void OnFailedLogin(const CString& sUsername, const CString& sRemoteIP);
+ /** This function behaves like CModule::OnRaw(), but is also called
+ * before the client successfully logged in to ZNC. You should always
+ * prefer to use CModule::OnRaw() if possible.
+ * @param sLine The raw traffic line which the client sent.
+ * @todo Why doesn't this use m_pUser and m_pClient?
+ * (Well, ok, m_pUser isn't known yet...)
+ */
+ virtual EModRet OnUnknownUserRaw(CString& sLine);
+
+ /** Called when a client told us CAP LS. Use ssCaps.insert("cap-name")
+ * for announcing capabilities which your module supports.
+ * @param ssCaps set of caps which will be sent to client.
+ */
+ virtual void OnClientCapLs(SCString& ssCaps);
+ /** Called only to check if your module supports turning on/off named capability.
+ * @param sCap name of capability.
+ * @param bState On or off, depending on which case is interesting for client.
+ * @return true if your module supports this capability in the specified state.
+ */
+ virtual bool IsClientCapSupported(const CString& sCap, bool bState);
+ /** Called when we actually need to turn a capability on or off for a client.
+ * @param sCap name of wanted capability.
+ * @param bState On or off, depending on which case client needs.
+ */
+ virtual void OnClientCapRequest(const CString& sCap, bool bState);
+
+ /** Called when a module is going to be loaded.
+ * @param sModName name of the module.
+ * @param sArgs arguments of the module.
+ * @param[out] bSuccess the module was loaded successfully
+ * as result of this module hook?
+ * @param[out] sRetMsg text about loading of the module.
+ * @return See CModule::EModRet.
+ */
+ virtual EModRet OnModuleLoading(const CString& sModName, const CString& sArgs,
+ bool& bSuccess, CString& sRetMsg);
+ /** Called when a module is going to be unloaded.
+ * @param pModule the module.
+ * @param[out] bSuccess the module was unloaded successfully
+ * as result of this module hook?
+ * @param[out] sRetMsg text about unloading of the module.
+ * @return See CModule::EModRet.
+ */
+ virtual EModRet OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg);
+ /** Called when info about a module is needed.
+ * @param[out] ModInfo put result here, if your module knows it.
+ * @param sModule name of the module.
+ * @param bSuccess this module provided info about the module.
+ * @param sRetMsg text describing possible issues.
+ * @return See CModule::EModRet.
+ */
+ virtual EModRet OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
+ bool& bSuccess, CString& sRetMsg);
+ /** Called when list of available mods is requested.
+ * @param ssMods put new modules here.
+ * @param bGlobal true if global modules are needed.
+ */
+ virtual void OnGetAvailableMods(set<CModInfo>& ssMods, EModuleType eType);
+ // !Global Modules
+
protected:
EModuleType m_eType;
CString m_sDescription;
@@ -989,127 +1080,7 @@ class CModules : public vector<CModule*> {
typedef std::queue<std::pair<CString, CString> > ModDirList;
static ModDirList GetModDirs();
-private:
- static ModHandle OpenModule(const CString& sModule, const CString& sModPath,
- bool &bVersionMismatch, CModInfo& Info, CString& sRetMsg);
-
-protected:
- CUser* m_pUser;
- CClient* m_pClient;
-};
-
-/** Base class for global modules. If you want to write a global module, your
- * module class has to derive from CGlobalModule instead of CModule.
- *
- * All the module hooks from CModule work here, too. The difference is that
- * they are now called for all users instead of just a specific one.
- *
- * Instead of MODCONSTRUCTOR and MODULEDEFS, you will have to use
- * GLOBALMODCONSTRUCTOR and GLOBALMODULEDEFS.
- */
-class CGlobalModule : public CModule {
-public:
- CGlobalModule(ModHandle pDLL, const CString& sModName,
- const CString &sDataDir) : CModule(pDLL, sModName, sDataDir) {}
- virtual ~CGlobalModule() {}
-
- /** This module hook is called when a user is being added.
- * @param User The user which will be added.
- * @param sErrorRet A message that may be displayed to the user if
- * the module stops adding the user.
- * @return See CModule::EModRet.
- */
- virtual EModRet OnAddUser(CUser& User, CString& sErrorRet);
- /** This module hook is called when a user is deleted.
- * @param User The user which will be deleted.
- * @return See CModule::EModRet.
- */
- virtual EModRet OnDeleteUser(CUser& User);
- /** This module hook is called when there is an incoming connection on
- * any of ZNC's listening sockets.
- * @param pSock The incoming client socket.
- * @param sHost The IP the client is connecting from.
- * @param uPort The port the client is connecting from.
- */
- virtual void OnClientConnect(CZNCSock* pSock, const CString& sHost, unsigned short uPort);
- /** This module hook is called when a client tries to login. If your
- * module wants to handle the login attempt, it must return
- * CModule::EModRet::HALT;
- * @param Auth The necessary authentication info for this login attempt.
- * @return See CModule::EModRet.
- */
- virtual EModRet OnLoginAttempt(CSmartPtr<CAuthBase> Auth);
- /** Called after a client login was rejected.
- * @param sUsername The username that tried to log in.
- * @param sRemoteIP The IP address from which the client tried to login.
- */
- virtual void OnFailedLogin(const CString& sUsername, const CString& sRemoteIP);
- /** This function behaves like CModule::OnRaw(), but is also called
- * before the client successfully logged in to ZNC. You should always
- * prefer to use CModule::OnRaw() if possible.
- * @param sLine The raw traffic line which the client sent.
- * @todo Why doesn't this use m_pUser and m_pClient?
- * (Well, ok, m_pUser isn't known yet...)
- */
- virtual EModRet OnUnknownUserRaw(CString& sLine);
-
- /** Called when a client told us CAP LS. Use ssCaps.insert("cap-name")
- * for announcing capabilities which your module supports.
- * @param ssCaps set of caps which will be sent to client.
- */
- virtual void OnClientCapLs(SCString& ssCaps);
- /** Called only to check if your module supports turning on/off named capability.
- * @param sCap name of capability.
- * @param bState On or off, depending on which case is interesting for client.
- * @return true if your module supports this capability in the specified state.
- */
- virtual bool IsClientCapSupported(const CString& sCap, bool bState);
- /** Called when we actually need to turn a capability on or off for a client.
- * @param sCap name of wanted capability.
- * @param bState On or off, depending on which case client needs.
- */
- virtual void OnClientCapRequest(const CString& sCap, bool bState);
-
- /** Called when a module is going to be loaded.
- * @param sModName name of the module.
- * @param sArgs arguments of the module.
- * @param[out] bSuccess the module was loaded successfully
- * as result of this module hook?
- * @param[out] sRetMsg text about loading of the module.
- * @return See CModule::EModRet.
- */
- virtual EModRet OnModuleLoading(const CString& sModName, const CString& sArgs,
- bool& bSuccess, CString& sRetMsg);
- /** Called when a module is going to be unloaded.
- * @param pModule the module.
- * @param[out] bSuccess the module was unloaded successfully
- * as result of this module hook?
- * @param[out] sRetMsg text about unloading of the module.
- * @return See CModule::EModRet.
- */
- virtual EModRet OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg);
- /** Called when info about a module is needed.
- * @param[out] ModInfo put result here, if your module knows it.
- * @param sModule name of the module.
- * @param bSuccess this module provided info about the module.
- * @param sRetMsg text describing possible issues.
- * @return See CModule::EModRet.
- */
- virtual EModRet OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
- bool& bSuccess, CString& sRetMsg);
- /** Called when list of available mods is requested.
- * @param ssMods put new modules here.
- * @param bGlobal true if global modules are needed.
- */
- virtual void OnGetAvailableMods(set<CModInfo>& ssMods, EModuleType eType);
-private:
-};
-
-class CGlobalModules : public CModules {
-public:
- CGlobalModules() : CModules() {}
- ~CGlobalModules() {}
-
+ // Global Modules
bool OnAddUser(CUser& User, CString& sErrorRet);
bool OnDeleteUser(CUser& User);
bool OnClientConnect(CZNCSock* pSock, const CString& sHost, unsigned short uPort);
@@ -1125,7 +1096,15 @@ class CGlobalModules : public CModules {
bool OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
bool& bSuccess, CString& sRetMsg);
bool OnGetAvailableMods(set<CModInfo>& ssMods, EModuleType eType);
+ // !Global Modules
+
private:
+ static ModHandle OpenModule(const CString& sModule, const CString& sModPath,
+ bool &bVersionMismatch, CModInfo& Info, CString& sRetMsg);
+
+protected:
+ CUser* m_pUser;
+ CClient* m_pClient;
};
#endif // !_MODULES_H
View
2  WebModules.cpp
@@ -334,7 +334,7 @@ void CWebSock::SetVars() {
GetSession()->ClearMessageLoops();
// Global Mods
- CGlobalModules& vgMods = CZNC::Get().GetModules();
+ CModules& vgMods = CZNC::Get().GetModules();
for (unsigned int a = 0; a < vgMods.size(); a++) {
AddModLoop("GlobalModLoop", *vgMods[a]);
}
View
6 main.h
@@ -26,7 +26,7 @@
#define ALLMODULECALL(macFUNC, macEXITER) \
do { \
- CGlobalModules& GMods = CZNC::Get().GetModules(); \
+ CModules& GMods = CZNC::Get().GetModules(); \
if (GMods.macFUNC) { \
macEXITER; \
} else { \
@@ -44,7 +44,7 @@
#define GLOBALMODULECALL(macFUNC, macUSER, macCLIENT, macEXITER) \
do { \
- CGlobalModules& GMods = CZNC::Get().GetModules(); \
+ CModules& GMods = CZNC::Get().GetModules(); \
CUser* pOldGUser = GMods.GetUser(); \
CClient* pOldGClient = GMods.GetClient(); \
GMods.SetUser(macUSER); \
@@ -79,7 +79,7 @@
* call #MODULEDEFS at the end of your source file.
* Congratulations, you just wrote your first module. <br>
* For global modules, the procedure is similar. Instead of CModule you inherit
- * from CGlobalModule. The two macros are replaced by #GLOBALMODCONSTRUCTOR and
+ * from CModule. The two macros are replaced by #GLOBALMODCONSTRUCTOR and
* #GLOBALMODULEDEFS.
*
* If you want your module to actually do something, you should override some
View
2  modules/adminlog.cpp
@@ -13,7 +13,7 @@
#include <syslog.h>
-class CAdminLogMod : public CGlobalModule {
+class CAdminLogMod : public CModule {
public:
GLOBALMODCONSTRUCTOR(CAdminLogMod) {
openlog("znc", LOG_PID, LOG_DAEMON);
View
2  modules/blockuser.cpp
@@ -12,7 +12,7 @@
#define MESSAGE "Your account has been disabled. Contact your administrator."
-class CBlockUser : public CGlobalModule {
+class CBlockUser : public CModule {
public:
GLOBALMODCONSTRUCTOR(CBlockUser) {}
View
2  modules/certauth.cpp
@@ -13,7 +13,7 @@
#include "Listener.h"
#include "znc.h"
-class CSSLClientCertMod : public CGlobalModule {
+class CSSLClientCertMod : public CModule {
public:
GLOBALMODCONSTRUCTOR(CSSLClientCertMod) {
AddHelpCommand();
View
2  modules/extra/droproot.cpp
@@ -18,7 +18,7 @@
#include <pwd.h>
#include <grp.h>
-class CDroproot : public CGlobalModule {
+class CDroproot : public CModule {
public:
GLOBALMODCONSTRUCTOR(CDroproot) {
View
2  modules/extra/imapauth.cpp
@@ -39,7 +39,7 @@ class CIMAPSock : public CSocket {
};
-class CIMAPAuthMod : public CGlobalModule {
+class CIMAPAuthMod : public CModule {
public:
GLOBALMODCONSTRUCTOR(CIMAPAuthMod) {
m_Cache.SetTTL(60000);
View
2  modules/extra/motdfile.cpp
@@ -10,7 +10,7 @@
#include "Client.h"
#include "FileUtils.h"
-class CMotdFileMod : public CGlobalModule {
+class CMotdFileMod : public CModule {
public:
GLOBALMODCONSTRUCTOR(CMotdFileMod) {}
virtual ~CMotdFileMod() {}
View
2  modules/extra/notify_connect.cpp
@@ -9,7 +9,7 @@
#include "znc.h"
#include "User.h"
-class CNotifyConnectMod : public CGlobalModule {
+class CNotifyConnectMod : public CModule {
public:
GLOBALMODCONSTRUCTOR(CNotifyConnectMod) {}
View
2  modules/extra/saslauth.cpp
@@ -15,7 +15,7 @@
#include "znc.h"
#include <sasl/sasl.h>
-class CSASLAuthMod : public CGlobalModule {
+class CSASLAuthMod : public CModule {
public:
GLOBALMODCONSTRUCTOR(CSASLAuthMod) {
m_Cache.SetTTL(60000/*ms*/);
View
2  modules/fail2ban.cpp
@@ -8,7 +8,7 @@
#include "znc.h"
-class CFailToBanMod : public CGlobalModule {
+class CFailToBanMod : public CModule {
public:
GLOBALMODCONSTRUCTOR(CFailToBanMod) {}
virtual ~CFailToBanMod() {}
View
2  modules/identfile.cpp
@@ -11,7 +11,7 @@
#include "User.h"
#include "znc.h"
-class CIdentFileModule : public CGlobalModule {
+class CIdentFileModule : public CModule {
CString m_sOrigISpoof;
CFile* m_pISpoofLockFile;
CIRCSock *m_pIRCSock;
View
2  modules/lastseen.cpp
@@ -14,7 +14,7 @@ using std::map;
using std::pair;
using std::multimap;
-class CLastSeenMod : public CGlobalModule {
+class CLastSeenMod : public CModule {
private:
time_t GetTime(const CUser *pUser) {
return GetNV(pUser->GetUserName()).ToULong();
View
2  modules/modperl.cpp
@@ -31,7 +31,7 @@ extern "C" {
}
}
-class CModPerl: public CGlobalModule {
+class CModPerl: public CModule {
PerlInterpreter *m_pPerl;
public:
GLOBALMODCONSTRUCTOR(CModPerl) {
View
4 modules/modpython.cpp
@@ -20,7 +20,7 @@
#include "modpython/module.h"
#include "modpython/retstring.h"
-class CModPython: public CGlobalModule {
+class CModPython: public CModule {
PyObject* m_PyZNCModule;
PyObject* m_PyFormatException;
@@ -140,7 +140,7 @@ class CModPython: public CGlobalModule {
sArgs.c_str(),
SWIG_NewInstanceObj(GetUser(), SWIG_TypeQuery("CUser*"), 0),
CPyRetString::wrap(sRetMsg),
- SWIG_NewInstanceObj(reinterpret_cast<CGlobalModule*>(this), SWIG_TypeQuery("CGlobalModule*"), 0));
+ SWIG_NewInstanceObj(reinterpret_cast<CModule*>(this), SWIG_TypeQuery("CModule*"), 0));
if (!pyRes) {
sRetMsg = GetPyExceptionStr();
DEBUG("modpython: " << sRetMsg);
View
4 modules/modpython/module.h
@@ -24,7 +24,7 @@ class CPyModule : public CModule {
VWebSubPages* _GetSubPages();
public:
CPyModule(CUser* pUser, const CString& sModName, const CString& sDataPath,
- PyObject* pyObj, CGlobalModule* pModPython)
+ PyObject* pyObj, CModule* pModPython)
: CModule(NULL, pUser, sModName, sDataPath) {
m_pyObj = pyObj;
Py_INCREF(pyObj);
@@ -114,7 +114,7 @@ static inline CPyModule* AsPyModule(CModule* p) {
return dynamic_cast<CPyModule*>(p);
}
-inline CPyModule* CreatePyModule(CUser* pUser, const CString& sModName, const CString& sDataPath, PyObject* pyObj, CGlobalModule* pModPython) {
+inline CPyModule* CreatePyModule(CUser* pUser, const CString& sModName, const CString& sDataPath, PyObject* pyObj, CModule* pModPython) {
return new CPyModule(pUser, sModName, sDataPath, pyObj, pModPython);
}
View
7 modules/modpython/znc.py
@@ -443,7 +443,12 @@ def load_module(modname, args, user, retmsg, modpython):
module.SetDescription(cl.description)
module.SetArgs(args)
module.SetModPath(pymodule.__file__)
- user.GetModules().push_back(module._cmod)
+
+ if user:
+ user.GetModules().push_back(module._cmod)
+ else:
+ CZNC.Get().GetModules().push_back(module._cmod)
+
try:
loaded = True
if not module.OnLoad(args, retmsg):
View
2  modules/partyline.cpp
@@ -41,7 +41,7 @@ class CPartylineChannel {
set<CString> m_ssFixedNicks;
};
-class CPartylineMod : public CGlobalModule {
+class CPartylineMod : public CModule {
public:
GLOBALMODCONSTRUCTOR(CPartylineMod) {}
View
2  modules/webadmin.cpp
@@ -51,7 +51,7 @@ inline bool FOR_EACH_MODULE_CanContinue(FOR_EACH_MODULE_Type& state, CModules::i
if (FOR_EACH_MODULE_Type FOR_EACH_MODULE_Var = pUser) {} else\
for (CModules::iterator I = CZNC::Get().GetModules().begin(); FOR_EACH_MODULE_CanContinue(FOR_EACH_MODULE_Var, I); ++I)
-class CWebAdminMod : public CGlobalModule {
+class CWebAdminMod : public CModule {
public:
GLOBALMODCONSTRUCTOR(CWebAdminMod) {
VPair vParams;
View
4 znc.cpp
@@ -27,7 +27,7 @@ CZNC::CZNC() {
exit(-1);
}
- m_pModules = new CGlobalModules();
+ m_pModules = new CModules();
m_uiConnectDelay = 5;
m_uiAnonIPLimit = 10;
m_uBytesRead = 0;
@@ -496,7 +496,7 @@ bool CZNC::WriteConfig() {
pFile->Write("BindHost = " + m_vsBindHosts[v].FirstLine() + "\n");
}
- CGlobalModules& Mods = GetModules();
+ CModules& Mods = GetModules();
for (unsigned int a = 0; a < Mods.size(); a++) {
CString sName = Mods[a]->GetModName();
View
4 znc.h
@@ -92,7 +92,7 @@ class CZNC {
enum ConfigState GetConfigState() const { return m_eConfigState; }
CSockManager& GetManager() { return m_Manager; }
const CSockManager& GetManager() const { return m_Manager; }
- CGlobalModules& GetModules() { return *m_pModules; }
+ CModules& GetModules() { return *m_pModules; }
size_t FilterUncommonModules(set<CModInfo>& ssModules);
CString GetSkinName() const { return m_sSkinName; }
const CString& GetStatusPrefix() const { return m_sStatusPrefix; }
@@ -178,7 +178,7 @@ class CZNC {
unsigned int m_uiConnectDelay;
unsigned int m_uiAnonIPLimit;
unsigned int m_uiMaxBufferSize;
- CGlobalModules* m_pModules;
+ CModules* m_pModules;
unsigned long long m_uBytesRead;
unsigned long long m_uBytesWritten;
CConnectUserTimer *m_pConnectUserTimer;
Please sign in to comment.
Something went wrong with that request. Please try again.