Browse files

Merge branch 'modinfo'

  • Loading branch information...
2 parents 5ca6291 + f7c4f54 commit d683aea48d453c39aab40f154d51bf62df046a65 Alexey Sokolov committed Jun 11, 2011
View
102 Modules.cpp
@@ -816,16 +816,15 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* p
GLOBALMODULECALL(OnModuleLoading(sModule, sArgs, bSuccess, sRetMsg), pUser, NULL, return bSuccess);
CString sModPath, sDataPath;
- CString sDesc;
bool bVersionMismatch;
- bool bIsGlobal;
+ CModInfo* Info;
if (!FindModPath(sModule, sModPath, sDataPath)) {
sRetMsg = "Unable to find module [" + sModule + "]";
return false;
}
- ModHandle p = OpenModule(sModule, sModPath, bVersionMismatch, bIsGlobal, sDesc, sRetMsg);
+ ModHandle p = OpenModule(sModule, sModPath, bVersionMismatch, Info, sRetMsg);
if (!p)
return false;
@@ -836,48 +835,31 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* p
return false;
}
- if ((pUser == NULL) != bIsGlobal) {
+ if ((pUser == NULL) != Info->IsGlobal()) {
+ delete Info;
dlclose(p);
sRetMsg = "Module [" + sModule + "] is ";
- sRetMsg += (bIsGlobal) ? "" : "not ";
+ sRetMsg += Info->IsGlobal() ? "" : "not ";
sRetMsg += "a global module.";
return false;
}
CModule* pModule = NULL;
if (pUser) {
- typedef CModule* (*fp)(ModHandle, CUser* pUser,
- const CString& sModName, const CString& sDataPath);
- fp Load = (fp) dlsym(p, "ZNCModLoad");
-
- if (!Load) {
- dlclose(p);
- sRetMsg = "Could not find ZNCModLoad() in module [" + sModule + "]";
- return false;
- }
-
- pModule = Load(p, pUser, sModule, sDataPath);
+ pModule = Info->GetLoader()(p, pUser, sModule, sDataPath);
} else {
- typedef CModule* (*fp)(ModHandle, const CString& sModName,
- const CString& sDataPath);
- fp Load = (fp) dlsym(p, "ZNCModLoad");
-
- if (!Load) {
- dlclose(p);
- sRetMsg = "Could not find ZNCModLoad() in module [" + sModule + "]";
- return false;
- }
-
- pModule = Load(p, sModule, sDataPath);
+ pModule = Info->GetGlobalLoader()(p, sModule, sDataPath);
}
- pModule->SetDescription(sDesc);
- pModule->SetGlobal(bIsGlobal);
+ pModule->SetDescription(Info->GetDescription());
+ pModule->SetGlobal(Info->IsGlobal());
pModule->SetArgs(sArgs);
pModule->SetModPath(CDir::ChangeDir(CZNC::Get().GetCurPath(), sModPath));
push_back(pModule);
+ delete Info;
+
bool bLoaded;
try {
bLoaded = pModule->OnLoad(sArgs, sRetMsg);
@@ -923,27 +905,19 @@ bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) {
ModHandle p = pModule->GetDLL();
if (p) {
- typedef void (*fp)(CModule*);
- fp Unload = (fp)dlsym(p, "ZNCModUnload");
+ delete pModule;
- if (Unload) {
- Unload(pModule);
-
- for (iterator it = begin(); it != end(); ++it) {
- if (*it == pModule) {
- erase(it);
- break;
- }
+ for (iterator it = begin(); it != end(); ++it) {
+ if (*it == pModule) {
+ erase(it);
+ break;
}
+ }
- dlclose(p);
- sRetMsg = "Module [" + sMod + "] unloaded";
+ dlclose(p);
+ sRetMsg = "Module [" + sMod + "] unloaded";
- return true;
- } else {
- sRetMsg = "Unable to unload module [" + sMod + "] could not find ZNCModUnload()";
- return false;
- }
+ return true;
}
sRetMsg = "Unable to unload module [" + sMod + "]";
@@ -980,24 +954,25 @@ bool CModules::GetModInfo(CModInfo& ModInfo, const CString& sModule, CString& sR
}
bool CModules::GetModPathInfo(CModInfo& ModInfo, const CString& sModule, const CString& sModPath, CString& sRetMsg) {
- CString sDesc;
bool bVersionMismatch;
- bool bIsGlobal;
+ CModInfo* Info;
- ModHandle p = OpenModule(sModule, sModPath, bVersionMismatch, bIsGlobal, sDesc, sRetMsg);
+ ModHandle p = OpenModule(sModule, sModPath, bVersionMismatch, Info, sRetMsg);
if (!p)
return false;
- ModInfo.SetGlobal(bIsGlobal);
- ModInfo.SetDescription(sDesc);
+ if (Info) {
+ ModInfo = *Info;
+ }
ModInfo.SetName(sModule);
ModInfo.SetPath(sModPath);
if (bVersionMismatch) {
ModInfo.SetDescription("--- Version mismatch, recompile this module. ---");
}
+ delete Info;
dlclose(p);
return true;
@@ -1082,11 +1057,10 @@ CModules::ModDirList CModules::GetModDirs() {
}
ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath, bool &bVersionMismatch,
- bool &bIsGlobal, CString& sDesc, CString& sRetMsg) {
+ CModInfo*& Info, CString& sRetMsg) {
// Some sane defaults in case anything errors out below
bVersionMismatch = false;
- bIsGlobal = false;
- sDesc.clear();
+ Info = NULL;
sRetMsg.clear();
for (unsigned int a = 0; a < sModule.length(); a++) {
@@ -1124,32 +1098,22 @@ ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath,
return NULL;
}
- typedef bool (*bFP)();
- bFP IsGlobal = (bFP) dlsym(p, "ZNCModGlobal");
-
- if (!IsGlobal) {
- dlclose(p);
- sRetMsg = "Could not find ZNCModGlobal() in module [" + sModule + "]";
- return NULL;
- }
-
- typedef const char *(*sFP)();
- sFP GetDesc = (sFP) dlsym(p, "ZNCModDescription");
+ typedef CModInfo* (*InfoFP)();
+ InfoFP ZNCModInfo = (InfoFP) dlsym(p, "ZNCModInfo");
- if (!GetDesc) {
+ if (!ZNCModInfo) {
dlclose(p);
- sRetMsg = "Could not find ZNCModDescription() in module [" + sModule + "]";
+ sRetMsg = "Could not find ZNCModInfo() in module [" + sModule + "]";
return NULL;
}
if (CModule::GetCoreVersion() != Version()) {
bVersionMismatch = true;
sRetMsg = "Version mismatch, recompile this module.";
} else {
+ Info = ZNCModInfo();
sRetMsg = "";
bVersionMismatch = false;
- bIsGlobal = IsGlobal();
- sDesc = GetDesc();
}
return p;
View
88 Modules.h
@@ -24,6 +24,9 @@ class CClient;
class CWebSock;
class CTemplate;
class CIRCSock;
+class CModule;
+class CGlobalModule;
+class CModInfo;
// !Forward Declarations
// User Module Macros
@@ -39,13 +42,31 @@ class CIRCSock;
typedef void* ModHandle;
-#define MODCOMMONDEFS(DESCRIPTION, GLOBAL) \
- const char *ZNCModDescription(); \
- bool ZNCModGlobal(); \
- double ZNCModVersion(); \
- const char *ZNCModDescription() { return DESCRIPTION; } \
- double ZNCModVersion() { return VERSION; } \
- bool ZNCModGlobal() { return GLOBAL; } \
+template<class M> void TModInfo(CModInfo& Info) {}
+
+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,
+ const CString& sModName, const CString& sModPath) {
+ return new M(p, sModName, sModPath);
+}
+
+#define MODCOMMONDEFS(CLASS, DESCRIPTION, GLOBAL, LOADER) \
+ extern "C" { \
+ double ZNCModVersion(); \
+ double ZNCModVersion() { return VERSION; } \
+ CModInfo* ZNCModInfo(); \
+ CModInfo* ZNCModInfo() { \
+ CModInfo* Info = new CModInfo(); \
+ Info->SetDescription(DESCRIPTION); \
+ Info->SetGlobal(GLOBAL); \
+ LOADER; \
+ TModInfo<CLASS>(*Info); \
+ return Info; \
+ } \
+ }
/** Instead of writing a constructor, you should call this macro. It accepts all
* the necessary arguments and passes them on to CModule's constructor. You
@@ -75,17 +96,7 @@ typedef void* ModHandle;
* @see For global modules you need GLOBALMODULEDEFS.
*/
#define MODULEDEFS(CLASS, DESCRIPTION) \
- extern "C" { \
- MODCOMMONDEFS(DESCRIPTION, false) \
- /* First the definitions to shut up some compiler warnings */ \
- CModule* ZNCModLoad(ModHandle p, CUser* pUser, const CString& sModName, \
- const CString& sModPath); \
- void ZNCModUnload(CModule* pMod); \
- CModule* ZNCModLoad(ModHandle p, CUser* pUser, const CString& sModName, \
- const CString& sModPath) \
- { return new CLASS(p, pUser, sModName, sModPath); } \
- void ZNCModUnload(CModule* pMod) { if (pMod) { delete pMod; } } \
- }
+ MODCOMMONDEFS(CLASS, DESCRIPTION, false, Info->SetLoader(TModLoad<CLASS>))
// !User Module Macros
// Global Module Macros
@@ -96,17 +107,7 @@ typedef void* ModHandle;
/** This works exactly like MODULEDEFS, but for global modules. */
#define GLOBALMODULEDEFS(CLASS, DESCRIPTION) \
- extern "C" { \
- MODCOMMONDEFS(DESCRIPTION, true) \
- /* First the definitions to shut up some compiler warnings */ \
- CGlobalModule* ZNCModLoad(ModHandle p, const CString& sModName, \
- const CString& sModPath); \
- void ZNCModUnload(CGlobalModule* pMod); \
- CGlobalModule* ZNCModLoad(ModHandle p, const CString& sModName, \
- const CString& sModPath) \
- { return new CLASS(p, sModName, sModPath); } \
- void ZNCModUnload(CGlobalModule* pMod) { if (pMod) { delete pMod; } } \
- }
+ MODCOMMONDEFS(CLASS, DESCRIPTION, true, Info->SetGlobalLoader(TModLoadGlobal<CLASS>))
// !Global Module Macros
// Forward Declarations
@@ -166,11 +167,19 @@ class CFPTimer : public CTimer {
class CModInfo {
public:
- CModInfo() {}
+ typedef CModule* (*ModLoader)(ModHandle p, CUser* pUser, const CString& sModName, const CString& sModPath);
+ typedef CGlobalModule* (*GlobalModLoader)(ModHandle p, const CString& sModName, const CString& sModPath);
+
+ CModInfo() {
+ m_fGlobalLoader = NULL;
+ m_fLoader = NULL;
+ }
CModInfo(const CString& sName, const CString& sPath, bool bGlobal) {
m_bGlobal = bGlobal;
m_sName = sName;
m_sPath = sPath;
+ m_fGlobalLoader = NULL;
+ m_fLoader = NULL;
}
~CModInfo() {}
@@ -182,21 +191,30 @@ class CModInfo {
const CString& GetName() const { return m_sName; }
const CString& GetPath() const { return m_sPath; }
const CString& GetDescription() const { return m_sDescription; }
+ const CString& GetWikiPage() const { return m_sWikiPage; }
bool IsGlobal() const { return m_bGlobal; }
+ ModLoader GetLoader() const { return m_fLoader; }
+ GlobalModLoader GetGlobalLoader() const { return m_fGlobalLoader; }
// !Getters
// Setters
void SetName(const CString& s) { m_sName = s; }
void SetPath(const CString& s) { m_sPath = s; }
void SetDescription(const CString& s) { m_sDescription = s; }
+ void SetWikiPage(const CString& s) { m_sWikiPage = s; }
void SetGlobal(bool b) { m_bGlobal = b; }
+ void SetLoader(ModLoader fLoader) { m_fLoader = fLoader; }
+ void SetGlobalLoader(GlobalModLoader fGlobalLoader) { m_fGlobalLoader = fGlobalLoader; }
// !Setters
private:
protected:
- bool m_bGlobal;
- CString m_sName;
- CString m_sPath;
- CString m_sDescription;
+ bool m_bGlobal;
+ CString m_sName;
+ CString m_sPath;
+ CString m_sDescription;
+ CString m_sWikiPage;
+ ModLoader m_fLoader;
+ GlobalModLoader m_fGlobalLoader;
};
/** A helper class for handling commands in modules. */
@@ -964,7 +982,7 @@ class CModules : public vector<CModule*> {
private:
static ModHandle OpenModule(const CString& sModule, const CString& sModPath,
- bool &bVersionMismatch, bool &bIsGlobal, CString& sDesc, CString& sRetMsg);
+ bool &bVersionMismatch, CModInfo*& Info, CString& sRetMsg);
protected:
CUser* m_pUser;
View
4 modules/admin.cpp
@@ -857,4 +857,8 @@ class CAdminMod : public CModule {
virtual ~CAdminMod() {}
};
+template<> void TModInfo<CAdminMod>(CModInfo& Info) {
+ Info.SetWikiPage("admin");
+}
+
MODULEDEFS(CAdminMod, "Dynamic configuration of users/settings through IRC")
View
4 modules/adminlog.cpp
@@ -163,4 +163,8 @@ class CAdminLogMod : public CGlobalModule {
CString m_sLogFile;
};
+template<> void TModInfo<CAdminLogMod>(CModInfo& Info) {
+ Info.SetWikiPage("adminlog");
+}
+
GLOBALMODULEDEFS(CAdminLogMod, "Log ZNC events to file and/or syslog.")
View
4 modules/autoattach.cpp
@@ -246,4 +246,8 @@ class CChanAttach : public CModule {
VAttachMatch m_vMatches;
};
+template<> void TModInfo<CChanAttach>(CModInfo& Info) {
+ Info.SetWikiPage("autoattach");
+}
+
MODULEDEFS(CChanAttach, "Reattaches you to channels on activity.")
View
4 modules/autocycle.cpp
@@ -224,4 +224,8 @@ class CAutoCycleMod : public CModule {
vector<CString> m_vsNegChans;
};
+template<> void TModInfo<CAutoCycleMod>(CModInfo& Info) {
+ Info.SetWikiPage("autocycle");
+}
+
MODULEDEFS(CAutoCycleMod, "Rejoins channels to gain Op if you're the only user left")
View
4 modules/autoop.cpp
@@ -463,4 +463,8 @@ void CAutoOpTimer::RunJob() {
m_pParent->ProcessQueue();
}
+template<> void TModInfo<CAutoOpMod>(CModInfo& Info) {
+ Info.SetWikiPage("autoop");
+}
+
MODULEDEFS(CAutoOpMod, "Auto op the good guys")
View
4 modules/autoreply.cpp
@@ -88,5 +88,9 @@ class CAutoReplyMod : public CModule {
TCacheMap<CString> m_Messaged;
};
+template<> void TModInfo<CAutoReplyMod>(CModInfo& Info) {
+ Info.SetWikiPage("autoreply");
+}
+
MODULEDEFS(CAutoReplyMod, "Reply to queries when you are away")
View
4 modules/awaynick.cpp
@@ -186,4 +186,8 @@ void CAwayNickTimer::RunJob() {
}
}
+template<> void TModInfo<CAwayNickMod>(CModInfo& Info) {
+ Info.SetWikiPage("awaynick");
+}
+
MODULEDEFS(CAwayNickMod, "Change your nick while you are away")
View
4 modules/blockuser.cpp
@@ -168,4 +168,8 @@ class CBlockUser : public CGlobalModule {
}
};
+template<> void TModInfo<CBlockUser>(CModInfo& Info) {
+ Info.SetWikiPage("blockuser");
+}
+
GLOBALMODULEDEFS(CBlockUser, "Block certain users from logging in")
View
4 modules/buffextras.cpp
@@ -66,5 +66,9 @@ class CBuffExtras : public CModule {
}
};
+template<> void TModInfo<CBuffExtras>(CModInfo& Info) {
+ Info.SetWikiPage("buffextras");
+}
+
MODULEDEFS(CBuffExtras, "Add joins, parts etc. to the playback buffer")
View
4 modules/cert.cpp
@@ -85,4 +85,8 @@ class CCertMod : public CModule {
}
};
+template<> void TModInfo<CCertMod>(CModInfo& Info) {
+ Info.SetWikiPage("cert");
+}
+
MODULEDEFS(CCertMod, "Use a ssl certificate to connect to a server")
View
4 modules/certauth.cpp
@@ -276,4 +276,8 @@ class CSSLClientCertMod : public CGlobalModule {
MSCString m_PubKeys;
};
+template<> void TModInfo<CSSLClientCertMod>(CModInfo& Info) {
+ Info.SetWikiPage("certauth");
+}
+
GLOBALMODULEDEFS(CSSLClientCertMod, "Allow users to authenticate via SSL client certificates")
View
4 modules/chansaver.cpp
@@ -72,4 +72,8 @@ class CChanSaverMod : public CModule {
bool m_bWriteConf;
};
+template<> void TModInfo<CChanSaverMod>(CModInfo& Info) {
+ Info.SetWikiPage("chansaver");
+}
+
MODULEDEFS(CChanSaverMod, "Keep config up-to-date when user joins/parts")
View
4 modules/clientnotify.cpp
@@ -102,5 +102,9 @@ class CClientNotifyMod : public CModule {
}
};
+template<> void TModInfo<CClientNotifyMod>(CModInfo& Info) {
+ Info.SetWikiPage("clientnotify");
+}
+
MODULEDEFS(CClientNotifyMod, "Notifies you when another IRC client logs into or out of your account. Configurable.")
View
4 modules/crypt.cpp
@@ -151,4 +151,8 @@ class CCryptMod : public CModule {
}
};
+template<> void TModInfo<CCryptMod>(CModInfo& Info) {
+ Info.SetWikiPage("crypt");
+}
+
MODULEDEFS(CCryptMod, "Encryption for channel/private messages")
View
2 modules/data/webadmin/tmpl/add_edit_user.tmpl
@@ -136,7 +136,7 @@
<? LOOP ModuleLoop ?>
<tr class="<? IF __EVEN__ ?>evenrow<? ELSE ?>oddrow<? ENDIF ?>">
<td class="mod_name">
- <input type="checkbox" name="loadmod" id="lm_<? VAR Name ?>" value="<? VAR Name ?>"<? IF Checked ?> checked="checked"<? ENDIF ?><? IF Disabled ?> disabled="disabled"<? ENDIF ?> /><label for="lm_<? VAR Name ?>"> <? VAR Name ?></label>
+ <input type="checkbox" name="loadmod" id="lm_<? VAR Name ?>" value="<? VAR Name ?>"<? IF Checked ?> checked="checked"<? ENDIF ?><? IF Disabled ?> disabled="disabled"<? ENDIF ?> /><label for="lm_<? VAR Name ?>"> <? IF Wiki ?><a href="http://wiki.znc.in/<? VAR Wiki ?>"><? VAR Name ?></a> <? ELSE ?> <? VAR Name ?> <? ENDIF ?></label>
</td>
<td class="mod_args">
<? IF Disabled ?><? VAR Args ?><? ELSE ?><input class="third" type="text" name="modargs_<? VAR Name ?>" value="<? VAR Args ?>" /><? ENDIF ?>
View
2 modules/data/webadmin/tmpl/settings.tmpl
@@ -132,7 +132,7 @@
<tbody>
<? LOOP ModuleLoop ?>
<tr class="<? IF __EVEN__ ?>evenrow<? ELSE ?>oddrow<? ENDIF ?>">
- <td class="mod_name"><input type="checkbox" name="loadmod" id="lm_<? VAR Name ?>" value="<? VAR Name ?>"<? IF Checked ?> checked="checked"<? ENDIF ?><? IF Disabled ?> disabled="disabled"<? ENDIF ?> /><label for="lm_<? VAR Name ?>"> <? VAR Name ?></label></td>
+ <td class="mod_name"><input type="checkbox" name="loadmod" id="lm_<? VAR Name ?>" value="<? VAR Name ?>"<? IF Checked ?> checked="checked"<? ENDIF ?><? IF Disabled ?> disabled="disabled"<? ENDIF ?> /><label for="lm_<? VAR Name ?>"> <? IF Wiki ?> <a href="http://wiki.znc.in/<? VAR Wiki ?>"><? VAR Name ?></a> <? ELSE ?> <? VAR Name ?> <? ENDIF ?></label></td>
<td class="mod_args"><input type="text" name="modargs_<? VAR Name ?>" value="<? VAR Args ?>" /></td>
<td class="mod_descr"><? VAR Description ?></td>
</tr>
View
4 modules/disconkick.cpp
@@ -29,4 +29,8 @@ class CKickClientOnIRCDisconnect: public CModule {
}
};
+template<> void TModInfo<CKickClientOnIRCDisconnect>(CModInfo& Info) {
+ Info.SetWikiPage("disconkick");
+}
+
MODULEDEFS(CKickClientOnIRCDisconnect, "Kicks the client from all channels when the connection to the IRC server is lost")
View
4 modules/fail2ban.cpp
@@ -95,4 +95,8 @@ class CFailToBanMod : public CGlobalModule {
unsigned int m_uiAllowedFailed;
};
+template<> void TModInfo<CFailToBanMod>(CModInfo& Info) {
+ Info.SetWikiPage("fail2ban");
+}
+
GLOBALMODULEDEFS(CFailToBanMod, "Block IPs for some time after a failed login")
View
4 modules/fixfreenode.cpp
@@ -22,4 +22,8 @@ class CPreventIdMsgMod : public CModule {
}
};
+template<> void TModInfo<CPreventIdMsgMod>(CModInfo& Info) {
+ Info.SetWikiPage("fixfreenode");
+}
+
MODULEDEFS(CPreventIdMsgMod, "Prevent client from sending IDENTIFY-MSG to server")
View
4 modules/identfile.cpp
@@ -162,4 +162,8 @@ class CIdentFileModule : public CGlobalModule {
}
};
+template<> void TModInfo<CIdentFileModule>(CModInfo& Info) {
+ Info.SetWikiPage("identfile");
+}
+
GLOBALMODULEDEFS(CIdentFileModule, "Write the ident of a user to a file when they are trying to connect")
View
4 modules/keepnick.cpp
@@ -192,4 +192,8 @@ void CKeepNickTimer::RunJob() {
m_pMod->KeepNick();
}
+template<> void TModInfo<CKeepNickMod>(CModInfo& Info) {
+ Info.SetWikiPage("keepnick");
+}
+
MODULEDEFS(CKeepNickMod, "Keep trying for your primary nick")
View
4 modules/kickrejoin.cpp
@@ -108,4 +108,8 @@ class CRejoinMod : public CModule {
}
};
+template<> void TModInfo<CRejoinMod>(CModInfo& Info) {
+ Info.SetWikiPage("kickrejoin");
+}
+
MODULEDEFS(CRejoinMod, "Autorejoin on kick")
View
4 modules/lastseen.cpp
@@ -148,4 +148,8 @@ class CLastSeenMod : public CGlobalModule {
};
+template<> void TModInfo<CLastSeenMod>(CModInfo& Info) {
+ Info.SetWikiPage("lastseen");
+}
+
GLOBALMODULEDEFS(CLastSeenMod, "Collects data about when a user last logged in")
View
10 modules/modperl.cpp
@@ -147,11 +147,12 @@ class CModPerl: public CGlobalModule {
break;
case Perl_Loaded:
result = HALT;
- if (3 == ret) {
+ if (4 == ret) {
ModInfo.SetGlobal(false);
ModInfo.SetDescription(PString(ST(2)));
ModInfo.SetName(sModule);
ModInfo.SetPath(PString(ST(1)));
+ ModInfo.SetWikiPage(PString(ST(3)));
bSuccess = true;
} else {
bSuccess = false;
@@ -201,11 +202,12 @@ class CModPerl: public CGlobalModule {
PUSH_STR(sPath);
PUSH_STR(sName);
PCALL("ZNC::Core::ModInfoByPath");
- if (!SvTRUE(ERRSV) && ret == 1) {
+ if (!SvTRUE(ERRSV) && ret == 2) {
ModInfo.SetGlobal(false);
ModInfo.SetDescription(PString(ST(0)));
ModInfo.SetName(sName);
ModInfo.SetPath(sPath);
+ ModInfo.SetWikiPage(PString(ST(1)));
ssMods.insert(ModInfo);
}
PEND;
@@ -316,4 +318,8 @@ CPerlSocket::~CPerlSocket() {
}
}
+template<> void TModInfo<CModPerl>(CModInfo& Info) {
+ Info.SetWikiPage("modperl");
+}
+
GLOBALMODULEDEFS(CModPerl, "Loads perl scripts as ZNC modules")
View
8 modules/modperl/startup.pl
@@ -154,15 +154,15 @@ sub GetModInfo {
return ($ZNC::Perl_LoadError, "Incorrect perl module.") unless IsModule $modpath, $modname;
require $modpath;
my $pmod = bless {}, $modname;
- return ($ZNC::Perl_Loaded, $modpath, $pmod->description)
+ return ($ZNC::Perl_Loaded, $modpath, $pmod->description, $pmod->wiki_page)
}
sub ModInfoByPath {
my ($modpath, $modname) = @_;
die "Incorrect perl module." unless IsModule $modpath, $modname;
require $modpath;
my $pmod = bless {}, $modname;
- return ($pmod->description)
+ return ($pmod->description, $pmod->wiki_page)
}
sub CallModFunc {
@@ -279,6 +279,10 @@ sub description {
"< Placeholder for a description >"
}
+sub wiki_page {
+ ''
+}
+
# Default implementations for module hooks. They can be overriden in derived modules.
sub OnLoad {1}
sub OnBoot {}
View
4 modules/modpython.cpp
@@ -478,4 +478,8 @@ PyObject* CPySocket::WriteBytes(PyObject* data) {
}
}
+template<> void TModInfo<CModPython>(CModInfo& Info) {
+ Info.SetWikiPage("modpython");
+}
+
GLOBALMODULEDEFS(CModPython, "Loads python scripts as ZNC modules")
View
6 modules/modpython/znc.py
@@ -151,6 +151,8 @@ def __len__(self):
class Module:
description = '< Placeholder for a description >'
+ wiki_page = ''
+
def __str__(self):
return self.GetModName()
@@ -498,6 +500,7 @@ def get_mod_info(modname, retmsg, modinfo):
cl = pymodule.__dict__[modname]
modinfo.SetGlobal(False)
modinfo.SetDescription(cl.description)
+ modinfo.SetWikiPage(cl.wiki_page)
modinfo.SetName(modname)
modinfo.SetPath(pymodule.__file__)
return 2
@@ -524,7 +527,8 @@ def get_mod_info_path(path, modname, modinfo):
return 0
cl = pymodule.__dict__[modname]
modinfo.SetGlobal(False)
- modinfo.SetDescription(get_descr(cl))
+ modinfo.SetDescription(cl.description)
+ modinfo.SetWikiPage(cl.wiki_page)
modinfo.SetName(modname)
modinfo.SetPath(pymodule.__file__)
return 1
View
4 modules/modtcl.cpp
@@ -494,4 +494,8 @@ void CModTclStartTimer::RunJob() {
p->Start();
}
+template<> void TModInfo<CModTcl>(CModInfo& Info) {
+ Info.SetWikiPage("modtcl");
+}
+
MODULEDEFS(CModTcl, "Loads Tcl scripts as ZNC modules")
View
4 modules/nickserv.cpp
@@ -76,4 +76,8 @@ class CNickServ : public CModule
CString m_sPass;
};
+template<> void TModInfo<CNickServ>(CModInfo& Info) {
+ Info.SetWikiPage("nickserv");
+}
+
MODULEDEFS(CNickServ, "Auths you with NickServ")
View
4 modules/notes.cpp
@@ -212,4 +212,8 @@ class CNotesMod : public CModule {
}
};
+template<> void TModInfo<CNotesMod>(CModInfo& Info) {
+ Info.SetWikiPage("notes");
+}
+
MODULEDEFS(CNotesMod, "Keep and replay notes")
View
4 modules/partyline.cpp
@@ -715,4 +715,8 @@ class CPartylineMod : public CGlobalModule {
set<CString> m_ssDefaultChans;
};
+template<> void TModInfo<CPartylineMod>(CModInfo& Info) {
+ Info.SetWikiPage("partyline");
+}
+
GLOBALMODULEDEFS(CPartylineMod, "Internal channels and queries for users connected to znc")
View
4 modules/perform.cpp
@@ -166,4 +166,8 @@ class CPerform : public CModule {
VCString m_vPerform;
};
+template<> void TModInfo<CPerform>(CModInfo& Info) {
+ Info.SetWikiPage("perform");
+}
+
MODULEDEFS(CPerform, "Keeps a list of commands to be executed when ZNC connects to IRC.")
View
4 modules/perleval.pm
@@ -8,6 +8,10 @@ sub description {
'Evaluates perl code'
}
+sub wiki_page {
+ 'perleval'
+}
+
sub OnLoad {
my $self = shift;
if (!$self->GetUser->IsAdmin) {
View
4 modules/q.cpp
@@ -483,4 +483,8 @@ class CQModule : public CModule {
}
};
+template<> void TModInfo<CQModule>(CModInfo& Info) {
+ Info.SetWikiPage("Q");
+}
+
MODULEDEFS(CQModule, "Auths you with QuakeNet's Q bot.")
View
4 modules/raw.cpp
@@ -28,5 +28,9 @@ class CRawMod : public CModule {
}
};
+template<> void TModInfo<CRawMod>(CModInfo& Info) {
+ Info.SetWikiPage("raw");
+}
+
MODULEDEFS(CRawMod, "View all of the raw traffic")
View
4 modules/route_replies.cpp
@@ -422,4 +422,8 @@ void CRouteTimeout::RunJob()
pMod->Timeout();
}
+template<> void TModInfo<CRouteRepliesMod>(CModInfo& Info) {
+ Info.SetWikiPage("route_replies");
+}
+
MODULEDEFS(CRouteRepliesMod, "Send replies (e.g. to /who) to the right client only")
View
4 modules/sample.cpp
@@ -230,5 +230,9 @@ class CSampleMod : public CModule {
}
};
+template<> void TModInfo<CSampleMod>(CModInfo& Info) {
+ Info.SetWikiPage("sample");
+}
+
MODULEDEFS(CSampleMod, "To be used as a sample for writing modules")
View
4 modules/savebuff.cpp
@@ -335,5 +335,9 @@ void CSaveBuffJob::RunJob()
p->SaveBufferToDisk();
}
+template<> void TModInfo<CSaveBuff>(CModInfo& Info) {
+ Info.SetWikiPage("savebuff");
+}
+
MODULEDEFS(CSaveBuff, "Stores channel buffers to disk, encrypted")
View
5 modules/schat.cpp
@@ -463,5 +463,10 @@ void CRemMarkerJob::RunJob()
// store buffer
}
+
+template<> void TModInfo<CSChat>(CModInfo& Info) {
+ Info.SetWikiPage("schat");
+}
+
MODULEDEFS(CSChat, "Secure cross platform (:P) chat system")
View
3 modules/simple_away.cpp
@@ -216,5 +216,8 @@ void CSimpleAwayJob::RunJob() {
((CSimpleAway*)m_pModule)->SetAway(false);
}
+template<> void TModInfo<CSimpleAway>(CModInfo& Info) {
+ Info.SetWikiPage("simple_away");
+}
MODULEDEFS(CSimpleAway, "Auto away when last client disconnects")
View
4 modules/stickychan.cpp
@@ -187,4 +187,8 @@ bool CStickyChan::OnLoad(const CString& sArgs, CString& sMessage)
return(true);
}
+template<> void TModInfo<CStickyChan>(CModInfo& Info) {
+ Info.SetWikiPage("stickychan");
+}
+
MODULEDEFS(CStickyChan, "configless sticky chans, keeps you there very stickily even")
View
4 modules/watch.cpp
@@ -550,4 +550,8 @@ class CWatcherMod : public CModule {
CBuffer m_Buffer;
};
+template<> void TModInfo<CWatcherMod>(CModInfo& Info) {
+ Info.SetWikiPage("watch");
+}
+
MODULEDEFS(CWatcherMod, "Copy activity from a specific user into a separate window")
View
6 modules/webadmin.cpp
@@ -745,6 +745,7 @@ class CWebAdminMod : public CGlobalModule {
l["Name"] = Info.GetName();
l["Description"] = Info.GetDescription();
l["Args"] = GetModArgs(pUser, Info.GetName());
+ l["Wiki"] = Info.GetWikiPage();
if (pUser && pUser->GetModules().FindModule(Info.GetName())) {
l["Checked"] = "true";
@@ -1039,6 +1040,7 @@ class CWebAdminMod : public CGlobalModule {
l["Name"] = Info.GetName();
l["Description"] = Info.GetDescription();
l["Args"] = GetModArgs(NULL, Info.GetName(), true);
+ l["Wiki"] = Info.GetWikiPage();
}
return true;
@@ -1124,4 +1126,8 @@ class CWebAdminMod : public CGlobalModule {
}
};
+template<> void TModInfo<CWebAdminMod>(CModInfo& Info) {
+ Info.SetWikiPage("webadmin");
+}
+
GLOBALMODULEDEFS(CWebAdminMod, "Web based administration module")

0 comments on commit d683aea

Please sign in to comment.