mirror of
https://github.com/znc/znc.git
synced 2026-08-06 17:03:14 +02:00
Add new global module hooks, which allow global modules to be 'module providers'.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2119 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
+38
@@ -507,6 +507,14 @@ CModule::EModRet CGlobalModule::OnUnknownUserRaw(CString& sLine) { return CONTIN
|
||||
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,
|
||||
bool& bSuccess, CString& sRetMsg) { return CONTINUE; }
|
||||
CModule::EModRet CGlobalModule::OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg) {
|
||||
return CONTINUE;
|
||||
}
|
||||
CModule::EModRet CGlobalModule::OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
|
||||
bool& bSuccess, CString& sRetMsg) { return CONTINUE; }
|
||||
void CGlobalModule::OnGetAvailableMods(set<CModInfo>& ssMods, bool bGlobal) {}
|
||||
|
||||
|
||||
CModules::CModules() {
|
||||
@@ -699,6 +707,25 @@ bool CGlobalModules::OnClientCapRequest(const CString& sCap, bool bState) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CGlobalModules::OnModuleLoading(const CString& sModName, const CString& sArgs,
|
||||
bool& bSuccess, CString& sRetMsg) {
|
||||
GLOBALMODHALTCHK(OnModuleLoading(sModName, sArgs, bSuccess, sRetMsg));
|
||||
}
|
||||
|
||||
bool CGlobalModules::OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg) {
|
||||
GLOBALMODHALTCHK(OnModuleUnloading(pModule, bSuccess, sRetMsg));
|
||||
}
|
||||
|
||||
bool CGlobalModules::OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
|
||||
bool& bSuccess, CString& sRetMsg) {
|
||||
GLOBALMODHALTCHK(OnGetModInfo(ModInfo, sModule, bSuccess, sRetMsg));
|
||||
}
|
||||
|
||||
bool CGlobalModules::OnGetAvailableMods(set<CModInfo>& ssMods, bool bGlobal) {
|
||||
GLOBALMODCALL(OnGetAvailableMods(ssMods, bGlobal));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
CModule* CModules::FindModule(const CString& sModule) const {
|
||||
for (unsigned int a = 0; a < size(); a++) {
|
||||
@@ -718,6 +745,9 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* p
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bSuccess;
|
||||
GLOBALMODULECALL(OnModuleLoading(sModule, sArgs, bSuccess, sRetMsg), pUser, NULL, return bSuccess);
|
||||
|
||||
CString sModPath, sDataPath;
|
||||
CString sDesc;
|
||||
bool bVersionMismatch;
|
||||
@@ -821,6 +851,9 @@ bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bSuccess;
|
||||
GLOBALMODULECALL(OnModuleUnloading(pModule, bSuccess, sRetMsg), pModule->GetUser(), NULL, return bSuccess);
|
||||
|
||||
ModHandle p = pModule->GetDLL();
|
||||
|
||||
if (p) {
|
||||
@@ -869,6 +902,9 @@ bool CModules::ReloadModule(const CString& sModule, const CString& sArgs, CUser*
|
||||
bool CModules::GetModInfo(CModInfo& ModInfo, const CString& sModule, CString& sRetMsg) {
|
||||
CString sModPath, sTmp;
|
||||
|
||||
bool bSuccess;
|
||||
GLOBALMODULECALL(OnGetModInfo(ModInfo, sModule, bSuccess, sRetMsg), NULL, NULL, return bSuccess);
|
||||
|
||||
if (!FindModPath(sModule, sModPath, sTmp)) {
|
||||
sRetMsg = "Unable to find module [" + sModule + "]";
|
||||
return false;
|
||||
@@ -928,6 +964,8 @@ void CModules::GetAvailableMods(set<CModInfo>& ssMods, bool bGlobal) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GLOBALMODULECALL(OnGetAvailableMods(ssMods, bGlobal), NULL, NULL, );
|
||||
}
|
||||
|
||||
bool CModules::FindModPath(const CString& sModule, CString& sModPath,
|
||||
|
||||
@@ -991,6 +991,39 @@ public:
|
||||
* @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] bRetMsg 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, bool bGlobal);
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -1009,6 +1042,12 @@ public:
|
||||
bool OnClientCapLs(SCString& ssCaps);
|
||||
bool IsClientCapSupported(const CString& sCap, bool bState);
|
||||
bool OnClientCapRequest(const CString& sCap, bool bState);
|
||||
bool OnModuleLoading(const CString& sModName, const CString& sArgs,
|
||||
bool& bSuccess, CString& sRetMsg);
|
||||
bool OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg);
|
||||
bool OnGetModInfo(CModInfo& ModInfo, const CString& sModule,
|
||||
bool& bSuccess, CString& sRetMsg);
|
||||
bool OnGetAvailableMods(set<CModInfo>& ssMods, bool bGlobal);
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user