Change second argument to module in OnLoad() from sErrorMsg to sMessage.

This message is always displayed when the module returns (well, screw webadmin)
and this way a module can notify the user if it loaded but something unexpected
happened.

As you might guess, no one uses this ATM :)

Proposal comes from prozac


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@855 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2007-10-28 17:57:07 +00:00
parent 52534f2d1f
commit ee350ab744
18 changed files with 38 additions and 25 deletions
+7 -2
View File
@@ -475,7 +475,7 @@ void CModule::ListSockets() {
const CString& CModule::GetModName() const { return m_sModName; }
CString CModule::GetModNick() const { return ((m_pUser) ? m_pUser->GetStatusPrefix() : "*") + m_sModName; }
bool CModule::OnLoad(const CString& sArgs, CString& sErrorMsg) { sErrorMsg = ""; return true; }
bool CModule::OnLoad(const CString& sArgs, CString& sMessage) { sMessage = ""; return true; }
bool CModule::OnBoot() { return true; }
void CModule::OnIRCDisconnected() {}
void CModule::OnIRCConnected() {}
@@ -787,7 +787,12 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* p
}
pModule->SetArgs(sArgs);
sRetMsg = "Loaded module [" + sModule + "] [" + sModPath + "]";
if (!sRetMsg.empty()) {
sRetMsg = "Loaded module [" + sModule + "] [" + sRetMsg + "] [" + sModPath + "]";
} else {
sRetMsg = "Loaded module [" + sModule + "] [" + sModPath + "]";
}
return true;
#endif // !_MODULES
}
+1 -1
View File
@@ -214,7 +214,7 @@ public:
void SetClient(CClient* pClient);
void Unload();
virtual bool OnLoad(const CString& sArgsi, CString& sErrorMsg);
virtual bool OnLoad(const CString& sArgsi, CString& sMessage);
virtual bool OnBoot();
virtual void OnIRCDisconnected();
virtual void OnIRCConnected();
+1 -1
View File
@@ -19,7 +19,7 @@ public:
virtual ~CChanAttach() {
}
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) {
virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
unsigned int a = 0;
CString sChan = sArgs.Token(a++);
+1 -1
View File
@@ -132,7 +132,7 @@ class CAutoOpMod : public CModule {
public:
MODCONSTRUCTOR(CAutoOpMod) {}
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) {
virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
AddTimer(new CAutoOpTimer(this));
// Load the users
+1 -1
View File
@@ -135,7 +135,7 @@ public:
SaveBufferToDisk();
}
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg)
virtual bool OnLoad(const CString& sArgs, CString& sMessage)
{
CString sMyArgs = sArgs;
if (sMyArgs.Token(0) == "-notimer")
+1 -1
View File
@@ -51,7 +51,7 @@ class CAwayNickMod : public CModule {
public:
MODCONSTRUCTOR(CAwayNickMod) {}
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) {
virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
m_sFormat = sArgs;
if (m_sFormat.empty()) {
+1 -1
View File
@@ -101,7 +101,7 @@ public:
m_pManager->DelSockByAddr( vSocks[a] );
}
virtual bool OnLoad(const CString & sArgs, CString& sErrorMsg) {
virtual bool OnLoad(const CString & sArgs, CString& sMessage) {
m_sMailPath = sArgs;
StartParser();
+1 -1
View File
@@ -61,7 +61,7 @@ public:
return true;
}
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) {
virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
if (sArgs.Trim_n().empty()) {
return true; // use defaults
}
+2 -2
View File
@@ -295,7 +295,7 @@ public:
}
void UnSetUser() { m_pUser = NULL; }
virtual bool OnLoad( const CString & sArgs, CString & sErrorMsg );
virtual bool OnLoad( const CString & sArgs, CString & sMessage );
virtual void OnUserAttached() { CBNone( "OnUserAttached" ); }
virtual void OnUserDetached() { CBNone( "OnUserDetached" ); }
virtual void OnIRCDisconnected() { CBNone( "OnIRCDisconnected" ); }
@@ -976,7 +976,7 @@ CModPerl::EModRet CModPerl::CallBack( const PString & sHookName, const VPString
// special case this, required for perl modules that are dynamic
EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
bool CModPerl::OnLoad( const CString & sArgs, CString & sErrorMsg )
bool CModPerl::OnLoad( const CString & sArgs, CString & sMessage )
{
m_pPerl = perl_alloc();
perl_construct( m_pPerl );
+1 -1
View File
@@ -27,7 +27,7 @@ public:
{
}
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg)
virtual bool OnLoad(const CString& sArgs, CString& sMessage)
{
if (sArgs.empty())
m_sPass = GetNV("Password");
+1 -1
View File
@@ -57,7 +57,7 @@ public:
return true;
}
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) {
virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
const map<CString, CUser*>& msUsers = CZNC::Get().GetUserMap();
for (map<CString, CUser*>::const_iterator it = msUsers.begin(); it != msUsers.end(); it++) {
+1 -1
View File
@@ -27,7 +27,7 @@ public:
{
}
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg)
virtual bool OnLoad(const CString& sArgs, CString& sMessage)
{
GetNV("Perform").Split("\n", m_vPerform, false);
+1 -1
View File
@@ -29,7 +29,7 @@ class CSampleMod : public CModule {
public:
MODCONSTRUCTOR(CSampleMod) {}
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) {
virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
PutModule("I'm being loaded with the arguments: [" + sArgs + "]");
//AddTimer(new CSampleTimer(this, 300, 0, "Sample", "Sample timer for sample things."));
//AddTimer(new CSampleTimer(this, 5, 20, "Another", "Another sample timer."));
+1 -1
View File
@@ -162,7 +162,7 @@ public:
}
}
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg)
virtual bool OnLoad(const CString& sArgs, CString& sMessage)
{
if (!sArgs.empty())
{
+2 -2
View File
@@ -209,7 +209,7 @@ public:
MODCONSTRUCTOR(CSChat) {}
virtual ~CSChat() { CleanSocks(); }
virtual bool OnLoad( const CString & sArgs, CString & sErrorMsg )
virtual bool OnLoad( const CString & sArgs, CString & sMessage )
{
m_sPemFile = sArgs;
@@ -219,7 +219,7 @@ public:
}
if (!CFile::Exists(m_sPemFile)) {
sErrorMsg = "Unable to load pem file [" + m_sPemFile + "]";
sMessage = "Unable to load pem file [" + m_sPemFile + "]";
return false;
}
+2 -2
View File
@@ -25,7 +25,7 @@ public:
{
}
virtual bool OnLoad( const CString& sArgs, CString& sErrorMsg );
virtual bool OnLoad( const CString& sArgs, CString& sMessage );
virtual EModRet OnUserPart( CString& sChannel, CString& sMessage )
{
@@ -95,7 +95,7 @@ static void RunTimer( CModule * pModule, CFPTimer *pTimer )
((CStickyChan *)pModule)->RunJob();
}
bool CStickyChan::OnLoad(const CString& sArgs, CString& sErrorMsg)
bool CStickyChan::OnLoad(const CString& sArgs, CString& sMessage)
{
AddTimer( RunTimer, "StickyChanTimer", 15 );
return( true );
+3 -3
View File
@@ -121,7 +121,7 @@ public:
return true;
}
virtual bool OnLoad(const CString& sArgStr, CString& sErrorMsg) {
virtual bool OnLoad(const CString& sArgStr, CString& sMessage) {
bool bSSL = false;
bool bIPv6 = false;
CString sArgs(sArgStr);
@@ -137,7 +137,7 @@ public:
} else if (sOpt.CaseCmp("-IPV4") == 0) {
bIPv6 = false;
} else {
sErrorMsg = "Unknown option [" + sOpt + "] valid options are -ipv4 or -ipv6";
sMessage = "Unknown option [" + sOpt + "] valid options are -ipv4 or -ipv6";
return false;
}
}
@@ -171,7 +171,7 @@ public:
bool b = m_pManager->ListenHost(m_uPort, "WebAdmin::Listener", m_sListenHost, bSSL, SOMAXCONN, pListenSock, 0, bIPv6);
if (!b) {
sErrorMsg = "Could not bind to port " + CString(m_uPort) + ": " + CString(strerror(errno));
sMessage = "Could not bind to port " + CString(m_uPort) + ": " + CString(strerror(errno));
}
return b;
}
+10 -2
View File
@@ -1053,7 +1053,11 @@ bool CZNC::ParseConfig(const CString& sConfig) {
try {
bool bModRet = pUser->GetModules().LoadModule(sModName, sArgs, pUser, sModRet);
CUtils::PrintStatus(bModRet, (bModRet) ? "" : sModRet);
if (bModRet)
sModRet = sModRet.Token(1, true, sModName + "] ");
CUtils::PrintStatus(bModRet, sModRet);
if (!bModRet) {
return false;
}
@@ -1159,7 +1163,11 @@ bool CZNC::ParseConfig(const CString& sConfig) {
try {
bool bModRet = GetModules().LoadModule(sModName, sArgs, NULL, sModRet);
CUtils::PrintStatus(bModRet, (bModRet) ? "" : sModRet);
if (bModRet)
sModRet = sModRet.Token(1, true, sModName + "] ");
CUtils::PrintStatus(bModRet, sModRet);
if (!bModRet) {
return false;
}