mirror of
https://github.com/znc/znc.git
synced 2026-08-10 02:43:05 +02:00
Remove config-related module hooks
This removes the following module hooks: OnConfigLine() OnWriteConfig() OnWriteUserConfig() OnWriteChanConfig() Modules could use these hooks for writing/reading their own stuff to/from znc.conf. However, no module (ever?) did this and IMHO no module should ever do this either. Modules can save stuff via SetNV(), module arguments (SetArgs()) and in their GetSavePath(). Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
@@ -63,8 +63,6 @@ bool CChan::WriteConfig(CFile& File) {
|
||||
if (!GetDefaultModes().empty())
|
||||
m_pUser->PrintLine(File, "\tModes", GetDefaultModes());
|
||||
|
||||
MODULECALL(OnWriteChanConfig(File, *this), m_pUser, NULL, NOTHING);
|
||||
|
||||
File.Write("\t</Chan>\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
-11
@@ -464,9 +464,6 @@ CModule::EModRet CModule::OnIRCConnecting(CIRCSock *IRCSock) { return CONTINUE;
|
||||
void CModule::OnIRCConnectionError(CIRCSock *IRCSock) {}
|
||||
CModule::EModRet CModule::OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName) { return CONTINUE; }
|
||||
CModule::EModRet CModule::OnBroadcast(CString& sMessage) { return CONTINUE; }
|
||||
CModule::EModRet CModule::OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan) { return CONTINUE; }
|
||||
void CModule::OnWriteUserConfig(CFile& Config) {}
|
||||
void CModule::OnWriteChanConfig(CFile& Config, CChan& Chan) {}
|
||||
|
||||
CModule::EModRet CModule::OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize) { return CONTINUE; }
|
||||
|
||||
@@ -564,7 +561,6 @@ bool CModule::PutModNotice(const CString& sLine) {
|
||||
///////////////////
|
||||
// CGlobalModule //
|
||||
///////////////////
|
||||
CModule::EModRet CGlobalModule::OnWriteConfig(CFile& Config) { return CONTINUE; }
|
||||
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) {}
|
||||
@@ -624,9 +620,6 @@ bool CModules::OnIRCConnecting(CIRCSock *pIRCSock) { MODHALTCHK(OnIRCConnecting(
|
||||
bool CModules::OnIRCConnectionError(CIRCSock *pIRCSock) { MODUNLOADCHK(OnIRCConnectionError(pIRCSock)); return false; }
|
||||
bool CModules::OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName) { MODHALTCHK(OnIRCRegistration(sPass, sNick, sIdent, sRealName)); }
|
||||
bool CModules::OnBroadcast(CString& sMessage) { MODHALTCHK(OnBroadcast(sMessage)); }
|
||||
bool CModules::OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan) { MODHALTCHK(OnConfigLine(sName, sValue, pUser, pChan)); }
|
||||
bool CModules::OnWriteUserConfig(CFile& Config) { MODUNLOADCHK(OnWriteUserConfig(Config)); return false; }
|
||||
bool CModules::OnWriteChanConfig(CFile& Config, CChan& Chan) { MODUNLOADCHK(OnWriteChanConfig(Config, Chan)); return false; }
|
||||
bool CModules::OnIRCDisconnected() { MODUNLOADCHK(OnIRCDisconnected()); return false; }
|
||||
bool CModules::OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize) { MODHALTCHK(OnDCCUserSend(RemoteNick, uLongIP, uPort, sFile, uFileSize)); }
|
||||
bool CModules::OnChanPermission(const CNick& OpNick, const CNick& Nick, CChan& Channel, unsigned char uMode, bool bAdded, bool bNoChange) { MODUNLOADCHK(OnChanPermission(OpNick, Nick, Channel, uMode, bAdded, bNoChange)); return false; }
|
||||
@@ -708,10 +701,6 @@ bool CModules::OnServerCapResult(const CString& sCap, bool bSuccess) { MODUNLOAD
|
||||
////////////////////
|
||||
// CGlobalModules //
|
||||
////////////////////
|
||||
bool CGlobalModules::OnWriteConfig(CFile& Config) {
|
||||
GLOBALMODHALTCHK(OnWriteConfig(Config));
|
||||
}
|
||||
|
||||
bool CGlobalModules::OnAddUser(CUser& User, CString& sErrorRet) {
|
||||
GLOBALMODHALTCHK(OnAddUser(User, sErrorRet));
|
||||
}
|
||||
|
||||
@@ -414,33 +414,6 @@ public:
|
||||
*/
|
||||
virtual EModRet OnBroadcast(CString& sMessage);
|
||||
|
||||
/** Called when a module-specific config line is read from znc.conf.
|
||||
* Module specific config lines are always prefixed with "GM:".
|
||||
* @param sName Name of the config entry without the "GM:" prefix.
|
||||
* @param sValue The value of the config entry.
|
||||
* @param pUser If this line was found in a user section, then this is
|
||||
* the corresponding CUser instance.
|
||||
* @param pChan If this line was found in a chan section, then this is
|
||||
* the corresponding CChan instance.
|
||||
* @return See CModule::EModRet.
|
||||
*/
|
||||
virtual EModRet OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan);
|
||||
/** Called just before ZNC finishes a user section in the config file.
|
||||
* This can be used to re-write the "GM:" lines for OnConfigLine()
|
||||
* which would get lost otherwise.
|
||||
* @param Config Reference to the CFile which will be used for writing
|
||||
* the config file.
|
||||
*/
|
||||
virtual void OnWriteUserConfig(CFile& Config);
|
||||
/** Called just before ZNC finishes a chan section in the config file.
|
||||
* This can be used to re-write the "GM:" lines for OnConfigLine()
|
||||
* which would get lost otherwise.
|
||||
* @param Config Reference to the CFile which will be used for writing
|
||||
* the config file.
|
||||
* @param Chan The channel which is being written.
|
||||
*/
|
||||
virtual void OnWriteChanConfig(CFile& Config, CChan& Chan);
|
||||
|
||||
/** This module hook is called when a user sends a DCC SEND request to
|
||||
* your module fake-nickname.
|
||||
*/
|
||||
@@ -921,9 +894,6 @@ public:
|
||||
bool OnIRCConnectionError(CIRCSock *pIRCSock);
|
||||
bool OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName);
|
||||
bool OnBroadcast(CString& sMessage);
|
||||
bool OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan);
|
||||
bool OnWriteUserConfig(CFile& Config);
|
||||
bool OnWriteChanConfig(CFile& Config, CChan& Chan);
|
||||
|
||||
bool OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize);
|
||||
|
||||
@@ -1024,14 +994,6 @@ public:
|
||||
const CString &sDataDir) : CModule(pDLL, sModName, sDataDir) {}
|
||||
virtual ~CGlobalModule() {}
|
||||
|
||||
/** Called when ZNC starts rewriting the config file. This can be used
|
||||
* re-write the "GM:" lines for OnConfigLine() which would get lost
|
||||
* otherwise.
|
||||
* @param Config Reference to the CFile which will be used for writing
|
||||
* the config file.
|
||||
* @return See CModule::EModRet.
|
||||
*/
|
||||
virtual EModRet OnWriteConfig(CFile& Config);
|
||||
/** 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
|
||||
@@ -1129,7 +1091,6 @@ public:
|
||||
CGlobalModules() : CModules() {}
|
||||
~CGlobalModules() {}
|
||||
|
||||
bool OnWriteConfig(CFile& Config);
|
||||
bool OnAddUser(CUser& User, CString& sErrorRet);
|
||||
bool OnDeleteUser(CUser& User);
|
||||
bool OnClientConnect(CZNCSock* pSock, const CString& sHost, unsigned short uPort);
|
||||
|
||||
@@ -720,8 +720,6 @@ bool CUser::WriteConfig(CFile& File) {
|
||||
}
|
||||
}
|
||||
|
||||
MODULECALL(OnWriteUserConfig(File), this, NULL, NOTHING);
|
||||
|
||||
File.Write("</User>\n");
|
||||
|
||||
return true;
|
||||
|
||||
@@ -13,9 +13,6 @@ EModRet OnIRCConnecting(CIRCSock *pIRCSock)
|
||||
void OnIRCConnectionError(CIRCSock *pIRCSock)
|
||||
EModRet OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName)
|
||||
EModRet OnBroadcast(CString& sMessage)
|
||||
EModRet OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan)
|
||||
void OnWriteUserConfig(CFile& Config)
|
||||
void OnWriteChanConfig(CFile& Config, CChan& Chan)
|
||||
EModRet OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize)
|
||||
void OnChanPermission(const CNick& OpNick, const CNick& Nick, CChan& Channel, unsigned char uMode, bool bAdded, bool bNoChange)
|
||||
void OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange)
|
||||
|
||||
@@ -36,9 +36,6 @@ public:
|
||||
virtual void OnIRCConnectionError(CIRCSock *pIRCSock);
|
||||
virtual EModRet OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName);
|
||||
virtual EModRet OnBroadcast(CString& sMessage);
|
||||
virtual EModRet OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan);
|
||||
virtual void OnWriteUserConfig(CFile& Config);
|
||||
virtual void OnWriteChanConfig(CFile& Config, CChan& Chan);
|
||||
virtual EModRet OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize);
|
||||
virtual void OnChanPermission(const CNick& OpNick, const CNick& Nick, CChan& Channel, unsigned char uMode, bool bAdded, bool bNoChange);
|
||||
virtual void OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
|
||||
|
||||
@@ -298,9 +298,6 @@ sub OnIRCConnecting {}
|
||||
sub OnIRCConnectionError {}
|
||||
sub OnIRCRegistration {}
|
||||
sub OnBroadcast {}
|
||||
sub OnConfigLine {}
|
||||
sub OnWriteUserConfig {}
|
||||
sub OnWriteChanConfig {}
|
||||
sub OnDCCUserSend {}
|
||||
sub OnChanPermission {}
|
||||
sub OnOp {}
|
||||
|
||||
@@ -13,9 +13,6 @@ EModRet OnIRCConnecting(CIRCSock *pIRCSock)
|
||||
void OnIRCConnectionError(CIRCSock *pIRCSock)
|
||||
EModRet OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName)
|
||||
EModRet OnBroadcast(CString& sMessage)
|
||||
EModRet OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan)
|
||||
void OnWriteUserConfig(CFile& Config)
|
||||
void OnWriteChanConfig(CFile& Config, CChan& Chan)
|
||||
EModRet OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize)
|
||||
void OnChanPermission(const CNick& OpNick, const CNick& Nick, CChan& Channel, unsigned char uMode, bool bAdded, bool bNoChange)
|
||||
void OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange)
|
||||
|
||||
@@ -58,9 +58,6 @@ public:
|
||||
virtual void OnIRCConnectionError(CIRCSock *pIRCSock);
|
||||
virtual EModRet OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName);
|
||||
virtual EModRet OnBroadcast(CString& sMessage);
|
||||
virtual EModRet OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan);
|
||||
virtual void OnWriteUserConfig(CFile& Config);
|
||||
virtual void OnWriteChanConfig(CFile& Config, CChan& Chan);
|
||||
virtual EModRet OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize);
|
||||
virtual void OnChanPermission(const CNick& OpNick, const CNick& Nick, CChan& Channel, unsigned char uMode, bool bAdded, bool bNoChange);
|
||||
virtual void OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange);
|
||||
|
||||
@@ -142,9 +142,6 @@ class Module:
|
||||
def OnIRCConnectionError(self, IRCSock): pass
|
||||
def OnIRCRegistration(self, sPass, sNick, sIdent, sRealName): pass
|
||||
def OnBroadcast(self, sMessage): pass
|
||||
def OnConfigLine(self, sName, sValue, pUser, pChan): pass
|
||||
def OnWriteUserConfig(self, Config): pass
|
||||
def OnWriteChanConfig(self, Config, Chan): pass
|
||||
def OnDCCUserSend(self, RemoteNick, uLongIP, uPort, sFile, uFileSize): pass
|
||||
def OnChanPermission(self, OpNick, Nick, Channel, uMode, bAdded, bNoChange): pass
|
||||
def OnOp(self, OpNick, Nick, Channel, bNoChange): pass
|
||||
|
||||
@@ -14,17 +14,6 @@
|
||||
#include "Listener.h"
|
||||
#include <list>
|
||||
|
||||
namespace
|
||||
{ // private namespace for local things
|
||||
struct CGlobalModuleConfigLine
|
||||
{
|
||||
CString m_sName;
|
||||
CString m_sValue;
|
||||
CUser *m_pUser;
|
||||
CChan *m_pChan;
|
||||
};
|
||||
}
|
||||
|
||||
static inline CString FormatBindError() {
|
||||
CString sError = (errno == 0 ? CString("unknown error, check the host name") : CString(strerror(errno)));
|
||||
return "Unable to bind [" + sError + "]";
|
||||
@@ -435,8 +424,6 @@ bool CZNC::WriteConfig() {
|
||||
|
||||
m_LockFile.Write(MakeConfigHeader() + "\n");
|
||||
|
||||
GLOBALMODULECALL(OnWriteConfig(m_LockFile), NULL, NULL, return false);
|
||||
|
||||
m_LockFile.Write("AnonIPLimit = " + CString(m_uiAnonIPLimit) + "\n");
|
||||
m_LockFile.Write("MaxBufferSize= " + CString(m_uiMaxBufferSize) + "\n");
|
||||
m_LockFile.Write("SSLCertFile = " + CString(m_sSSLCertFile) + "\n");
|
||||
@@ -1014,8 +1001,6 @@ bool CZNC::DoRehash(CString& sError)
|
||||
unsigned int uLineNum = 0;
|
||||
MCString msModules; // Modules are queued for later loading
|
||||
|
||||
std::list<CGlobalModuleConfigLine> lGlobalModuleConfigLine;
|
||||
|
||||
while (File.ReadLine(sLine)) {
|
||||
uLineNum++;
|
||||
|
||||
@@ -1605,16 +1590,6 @@ bool CZNC::DoRehash(CString& sError)
|
||||
|
||||
}
|
||||
|
||||
if (sName.Equals("GM:", false, 3))
|
||||
{ // GM: prefix is a pass through to config lines for global modules
|
||||
CGlobalModuleConfigLine cTmp;
|
||||
cTmp.m_sName = sName.substr(3, CString::npos);
|
||||
cTmp.m_sValue = sValue;
|
||||
cTmp.m_pChan = pChan;
|
||||
cTmp.m_pUser = pUser;
|
||||
lGlobalModuleConfigLine.push_back(cTmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
sError = "Unhandled line " + CString(uLineNum) + " in config: [" + sLine + "]";
|
||||
CUtils::PrintError(sError);
|
||||
@@ -1638,22 +1613,6 @@ bool CZNC::DoRehash(CString& sError)
|
||||
CUtils::PrintMessage("Could not unload [" + *it + "]");
|
||||
}
|
||||
|
||||
// last step, throw unhandled config items at global config
|
||||
for (std::list<CGlobalModuleConfigLine>::iterator it = lGlobalModuleConfigLine.begin(); it != lGlobalModuleConfigLine.end(); ++it)
|
||||
{
|
||||
if ((pChan && pChan == it->m_pChan) || (pUser && pUser == it->m_pUser))
|
||||
continue; // skip unclosed user or chan
|
||||
bool bHandled = false;
|
||||
if (it->m_pUser) {
|
||||
MODULECALL(OnConfigLine(it->m_sName, it->m_sValue, it->m_pUser, it->m_pChan), it->m_pUser, NULL, bHandled = true);
|
||||
} else {
|
||||
GLOBALMODULECALL(OnConfigLine(it->m_sName, it->m_sValue, it->m_pUser, it->m_pChan), it->m_pUser, NULL, bHandled = true);
|
||||
}
|
||||
if (!bHandled) {
|
||||
CUtils::PrintMessage("unhandled global module config line [GM:" + it->m_sName + "] = [" + it->m_sValue + "]");
|
||||
}
|
||||
}
|
||||
|
||||
if (pChan) {
|
||||
sError = "Last <Chan> section not properly closed. File truncated?";
|
||||
CUtils::PrintError(sError);
|
||||
|
||||
Reference in New Issue
Block a user