Moved GetDescription() into second argument of MODULEDEFS()

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@366 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
prozacx
2005-05-26 20:42:13 +00:00
parent 1c90fd9beb
commit c52542e469
12 changed files with 53 additions and 59 deletions

View File

@@ -280,8 +280,6 @@ void CModule::ListTimers() {
const CString& CModule::GetModName() { return m_sModName; }
CString CModule::GetModNick() { return ((m_pUser) ? m_pUser->GetStatusPrefix() : "*") + m_sModName; }
CString CModule::GetDescription() { return "Unknown"; }
bool CModule::OnLoad(const CString& sArgs) { return true; }
bool CModule::OnBoot() { return true; }
void CModule::OnUserAttached() {}
@@ -595,6 +593,15 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* p
return false;
}
typedef CString (*sFP)();
sFP GetDesc = (sFP) dlsym(p, "GetDescription");
if (!GetDesc) {
dlclose(p);
sRetMsg = "Could not find GetDescription() in module [" + sModule + "]";
return false;
}
bool bIsGlobal = IsGlobal();
if ((pUser == NULL) != bIsGlobal) {
dlclose(p);
@@ -630,6 +637,7 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* p
pModule = Load(p, m_pZNC, sModule);
}
pModule->SetDescription(GetDesc());
push_back(pModule);
if (!pModule->OnLoad(sArgs)) {
@@ -759,15 +767,16 @@ bool CModules::GetModInfo(CModInfo& ModInfo, const CString& sModule) {
return false;
}
typedef CModule* (*fp)(void*, CZNC*, const CString&);
fp Load = (fp) dlsym(p, "Load");
typedef CString (*sFP)();
sFP GetDescription = (sFP) dlsym(p, "GetDescription");
if (!Load) {
if (!GetDescription) {
dlclose(p);
return false;
}
ModInfo.SetGlobal(IsGlobal());
ModInfo.SetDescription(GetDescription());
ModInfo.SetName(sModule);
ModInfo.SetPath(sModPath);
dlclose(p);

View File

@@ -11,8 +11,9 @@ using std::set;
// User Module Macros
#define MODCONSTRUCTOR(CLASS) \
CLASS(void *pDLL, CUser* pUser, const CString& sModName) : CModule(pDLL, pUser, sModName)
#define MODULEDEFS(CLASS) \
#define MODULEDEFS(CLASS, DESCRIPTION) \
extern "C" { \
CString GetDescription() { return DESCRIPTION; } \
bool IsGlobal() { return false; } \
CModule* Load(void* p, CUser* pUser, const CString& sModName); \
void Unload(CModule* pMod); double GetVersion(); } \
@@ -25,8 +26,9 @@ using std::set;
// Global Module Macros
#define GLOBALMODCONSTRUCTOR(CLASS) \
CLASS(void *pDLL, CZNC* pZNC, const CString& sModName) : CGlobalModule(pDLL, pZNC, sModName)
#define GLOBALMODULEDEFS(CLASS) \
#define GLOBALMODULEDEFS(CLASS, DESCRIPTION) \
extern "C" { \
CString GetDescription() { return DESCRIPTION; } \
bool IsGlobal() { return true; } \
CGlobalModule* Load(void* p, CZNC* pZNC, const CString& sModName); \
void Unload(CGlobalModule* pMod); double GetVersion(); } \
@@ -36,6 +38,7 @@ using std::set;
}
// !Global Module Macros
//const char* GetDescription() { static char sz[] = DESCRIPTION; return sz; }
// Forward Declarations
class CZNC;
class CUser;
@@ -111,6 +114,7 @@ public:
// Getters
const CString& GetName() const { return m_sName; }
const CString& GetPath() const { return m_sPath; }
const CString& GetDescription() const { return m_sDescription; }
bool IsSystem() const { return m_bSystem; }
bool IsGlobal() const { return m_bGlobal; }
// !Getters
@@ -118,6 +122,7 @@ public:
// 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 SetSystem(bool b) { m_bSystem = b; }
void SetGlobal(bool b) { m_bGlobal = b; }
// !Setters
@@ -127,6 +132,7 @@ protected:
bool m_bGlobal;
CString m_sName;
CString m_sPath;
CString m_sDescription;
};
class CModule {
@@ -148,7 +154,6 @@ public:
void SetUser(CUser* pUser);
void Unload();
virtual CString GetDescription();
virtual bool OnLoad(const CString& sArgs);
virtual bool OnBoot();
@@ -223,7 +228,16 @@ public:
MCString::iterator BeginNV() { return m_mssRegistry.begin(); }
void DelNV(MCString::iterator it) { m_mssRegistry.erase(it); }
// Setters
void SetDescription(const CString& s) { m_sDescription = s; }
// !Setters
// Getters
const CString& GetDescription() const { return m_sDescription; }
// !Getters
protected:
CString m_sDescription;
vector<CTimer*> m_vTimers;
void* m_pDLL;
TSocketManager<Csock>* m_pManager;

View File

@@ -20,6 +20,9 @@
*
*
* $Log$
* Revision 1.14 2005/05/26 20:42:13 prozacx
* Moved GetDescription() into second argument of MODULEDEFS()
*
* Revision 1.13 2005/05/15 08:27:27 prozacx
* Changed return value from bool to EModRet on most hooks
*
@@ -182,11 +185,6 @@ public:
Away();
}
virtual CString GetDescription()
{
return ( "Stores messages while away, also auto away" );
}
virtual void OnModCommand( const CString& sCommand )
{
CString sCmdName = sCommand.Token(0);
@@ -443,5 +441,5 @@ void CAwayJob::RunJob()
}
}
MODULEDEFS(CAway)
MODULEDEFS(CAway, "Stores messages while away, also auto away")

View File

@@ -15,6 +15,9 @@
* Author: imaginos <imaginos@imaginos.net>
*
* $Log$
* Revision 1.8 2005/05/26 20:42:13 prozacx
* Moved GetDescription() into second argument of MODULEDEFS()
*
* Revision 1.7 2005/05/08 06:42:02 prozacx
* Moved CUtils::ToString() into CString class
*
@@ -108,11 +111,6 @@ public:
}
}
virtual CString GetDescription()
{
return ( "Monitors Email activity on local disk /var/mail/user" );
}
virtual void OnModCommand( const CString& sCommand );
void StartParser();
@@ -287,5 +285,5 @@ void CEmailJob::RunJob()
CEmail *p = (CEmail *)m_pModule;
p->StartParser();
}
MODULEDEFS(CEmail)
MODULEDEFS(CEmail, "Monitors Email activity on local disk /var/mail/user")

View File

@@ -489,7 +489,7 @@ private:
};
GLOBALMODULEDEFS( CModPerl )
GLOBALMODULEDEFS( CModPerl, "Loads perl scripts as ZNC modules" )

View File

@@ -9,10 +9,6 @@ public:
MODCONSTRUCTOR(CRawMod) {}
virtual ~CRawMod() {}
virtual CString GetDescription() {
return "View all of the raw traffic.";
}
virtual EModRet OnRaw(CString& sLine) {
PutModule("IRC -> [" + sLine + "]");
return CONTINUE;
@@ -24,5 +20,5 @@ public:
}
};
MODULEDEFS(CRawMod)
MODULEDEFS(CRawMod, "View all of the raw traffic")

View File

@@ -38,10 +38,6 @@ public:
return true;
}
virtual CString GetDescription() {
return "To be used as a sample for writing modules.";
}
virtual void OnIRCConnected() {
PutModule("You got connected BoyOh.");
}
@@ -200,5 +196,5 @@ public:
}
};
MODULEDEFS(CSampleMod)
MODULEDEFS(CSampleMod, "To be used as a sample for writing modules")

View File

@@ -26,6 +26,9 @@
* better solution then plain text.
*
* $Log$
* Revision 1.25 2005/05/26 20:42:13 prozacx
* Moved GetDescription() into second argument of MODULEDEFS()
*
* Revision 1.24 2005/05/17 17:18:35 prozacx
* Changed CChan reference to non-const in all hooks
*
@@ -242,11 +245,6 @@ public:
}
}
virtual CString GetDescription()
{
return ( "Stores channel buffers to disk, encrypted." );
}
virtual void OnModCommand( const CString& sCommand )
{
CString::size_type iPos = sCommand.find( " " );
@@ -414,5 +412,5 @@ void CSaveBuffJob::RunJob()
p->SaveBufferToDisk();
}
MODULEDEFS(CSaveBuff)
MODULEDEFS(CSaveBuff, "Stores channel buffers to disk, encrypted")

View File

@@ -18,6 +18,9 @@ using std::pair;
* Author: imaginos <imaginos@imaginos.net>
*
* $Log$
* Revision 1.15 2005/05/26 20:42:13 prozacx
* Moved GetDescription() into second argument of MODULEDEFS()
*
* Revision 1.14 2005/05/18 03:22:52 imaginos
* bring Csocket up to date, includes new needed function GetSockByFD()
*
@@ -215,11 +218,6 @@ public:
m_pManager->DelSock( a-- );
}
}
virtual CString GetDescription()
{
return ( "Secure cross platform (:P) chat system" );
}
virtual EModRet OnUserRaw( CString & sLine )
{
@@ -569,5 +567,5 @@ void CRemMarkerJob::RunJob()
// store buffer
}
MODULEDEFS(CSChat)
MODULEDEFS(CSChat, "Secure cross platform (:P) chat system")

View File

@@ -98,10 +98,6 @@ public:
}
}
virtual CString GetDescription() {
return "Gives shell access.";
}
virtual void OnModCommand(const CString& sCommand) {
if ((strcasecmp(sCommand.c_str(), "cd") == 0) || (strncasecmp(sCommand.c_str(), "cd ", 3) == 0)) {
CString sPath = CUtils::ChangeDir(m_sPath, ((sCommand.length() == 2) ? CString(m_pUser->GetHomePath()) : CString(sCommand.substr(3))), m_pUser->GetHomePath());
@@ -214,5 +210,5 @@ void CExecSock::Disconnected() {
m_pParent->PutShell("znc$");
}
MODULEDEFS(CShellMod)
MODULEDEFS(CShellMod, "Gives shell access")

View File

@@ -20,11 +20,6 @@ public:
virtual bool OnLoad(const CString& sArgs);
virtual CString GetDescription()
{
return ( "configless sticky chans, keeps you there very stickily even" );
}
virtual void OnModCommand( const CString& sCommand )
{
CString sCmdName = sCommand.Token(0);
@@ -80,4 +75,4 @@ bool CStickyChan::OnLoad(const CString& sArgs)
return( true );
}
MODULEDEFS(CStickyChan)
MODULEDEFS(CStickyChan, "configless sticky chans, keeps you there very stickily even")

View File

@@ -160,10 +160,6 @@ public:
virtual ~CWatcherMod() {
}
virtual CString GetDescription() {
return "Copy activity from a specific user into a separate window.";
}
virtual void OnRawMode(const CNick& OpNick, CChan& Channel, const CString& sModes, const CString& sArgs) {
Process(OpNick, "* " + OpNick.GetNick() + " sets mode: " + sModes + " " + sArgs + " on " + Channel.GetName(), Channel.GetName());
}
@@ -506,4 +502,4 @@ private:
CBuffer m_Buffer;
};
MODULEDEFS(CWatcherMod)
MODULEDEFS(CWatcherMod, "Copy activity from a specific user into a separate window")