diff --git a/Chan.cpp b/Chan.cpp index 50350734..9d677c0b 100644 --- a/Chan.cpp +++ b/Chan.cpp @@ -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\n"); return true; diff --git a/Modules.cpp b/Modules.cpp index 06e7d405..5de5a1e8 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -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)); } diff --git a/Modules.h b/Modules.h index ce2e6677..756aa510 100644 --- a/Modules.h +++ b/Modules.h @@ -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); diff --git a/User.cpp b/User.cpp index 202fac29..6f2aeb87 100644 --- a/User.cpp +++ b/User.cpp @@ -707,7 +707,7 @@ bool CUser::WriteConfig(CFile& File) { } } - CZNC::Get().GetModules().OnWriteUserConfig(File, *this); + MODULECALL(OnWriteUserConfig(File), this, NULL,); File.Write("\n");