Move OnWrite{User,Chan}Config() to CModule

That way, user modules can write stuff to the user section, too.

OnWriteConfig() is still a global module call. A later commit will have to make
OnConfigLine() a user module hook...


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1848 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2010-03-29 19:04:37 +00:00
parent be130f2034
commit 027404e05b
4 changed files with 24 additions and 30 deletions
+1 -1
View File
@@ -63,7 +63,7 @@ bool CChan::WriteConfig(CFile& File) {
if (!GetDefaultModes().empty())
m_pUser->PrintLine(File, "\tModes", GetDefaultModes());
CZNC::Get().GetModules().OnWriteChanConfig(File, *this);
MODULECALL(OnWriteChanConfig(File, *this), m_pUser, NULL,);
File.Write("\t</Chan>\n");
return true;
+4 -10
View File
@@ -401,6 +401,8 @@ void CModule::OnIRCConnected() {}
CModule::EModRet CModule::OnIRCConnecting(CIRCSock *IRCSock) { return CONTINUE; }
CModule::EModRet CModule::OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName) { return CONTINUE; }
CModule::EModRet CModule::OnBroadcast(CString& sMessage) { 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; }
@@ -497,8 +499,6 @@ bool CModule::PutModNotice(const CString& sLine, const CString& sIdent, const CS
///////////////////
CModule::EModRet CGlobalModule::OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan) { return CONTINUE; }
CModule::EModRet CGlobalModule::OnWriteConfig(CFile& Config) { return CONTINUE; }
void CGlobalModule::OnWriteUserConfig(CFile& Config, CUser& User) {}
void CGlobalModule::OnWriteChanConfig(CFile& Config, CChan& Chan) {}
CModule::EModRet CGlobalModule::OnAddUser(CUser& User, CString& sErrorRet) { return CONTINUE; }
CModule::EModRet CGlobalModule::OnDeleteUser(CUser& User) { return CONTINUE; }
void CGlobalModule::OnClientConnect(CClient* pClient, const CString& sHost, unsigned short uPort) {}
@@ -546,6 +546,8 @@ bool CModules::OnIRCConnected() { MODUNLOADCHK(OnIRCConnected()); return false;
bool CModules::OnIRCConnecting(CIRCSock *pIRCSock) { MODHALTCHK(OnIRCConnecting(pIRCSock)); }
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::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; }
@@ -606,14 +608,6 @@ bool CGlobalModules::OnWriteConfig(CFile& Config) {
GLOBALMODHALTCHK(OnWriteConfig(Config));
}
void CGlobalModules::OnWriteUserConfig(CFile& Config, CUser& User) {
GLOBALMODCALL(OnWriteUserConfig(Config, User));
}
void CGlobalModules::OnWriteChanConfig(CFile& Config, CChan& Chan) {
GLOBALMODCALL(OnWriteChanConfig(Config, Chan));
}
bool CGlobalModules::OnAddUser(CUser& User, CString& sErrorRet) {
GLOBALMODHALTCHK(OnAddUser(User, sErrorRet));
}
+18 -18
View File
@@ -345,6 +345,22 @@ public:
*/
virtual EModRet OnBroadcast(CString& sMessage);
/** 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.
*/
@@ -790,6 +806,8 @@ public:
bool OnIRCConnecting(CIRCSock *pIRCSock);
bool OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName);
bool OnBroadcast(CString& sMessage);
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);
@@ -906,22 +924,6 @@ public:
* @return See CModule::EModRet.
*/
virtual EModRet OnWriteConfig(CFile& Config);
/** 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.
* @param User The user which is being written.
*/
virtual void OnWriteUserConfig(CFile& Config, CUser& User);
/** 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 is being added.
* @param User The user which will be added.
* @param sErrorRet A message that may be displayed to the user if
@@ -972,8 +974,6 @@ public:
bool OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan);
bool OnWriteConfig(CFile& Config);
void OnWriteUserConfig(CFile& Config, CUser& User);
void OnWriteChanConfig(CFile& Config, CChan& Chan);
bool OnAddUser(CUser& User, CString& sErrorRet);
bool OnDeleteUser(CUser& User);
void OnClientConnect(CClient* pClient, const CString& sHost, unsigned short uPort);
+1 -1
View File
@@ -707,7 +707,7 @@ bool CUser::WriteConfig(CFile& File) {
}
}
CZNC::Get().GetModules().OnWriteUserConfig(File, *this);
MODULECALL(OnWriteUserConfig(File), this, NULL,);
File.Write("</User>\n");