Added a new module hook

EModRet OnAddUser(CUser& User, CString& sErrorRet)
for global modules. Idea by BrianC.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1820 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
cflakes
2010-03-09 20:24:43 +00:00
parent cbb6e14c3a
commit 28022ca771
3 changed files with 18 additions and 0 deletions
+5
View File
@@ -498,6 +498,7 @@ CModule::EModRet CGlobalModule::OnConfigLine(const CString& sName, const CString
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) {}
CModule::EModRet CGlobalModule::OnLoginAttempt(CSmartPtr<CAuthBase> Auth) { return CONTINUE; }
@@ -612,6 +613,10 @@ void CGlobalModules::OnWriteChanConfig(CFile& Config, CChan& Chan) {
GLOBALMODCALL(OnWriteChanConfig(Config, Chan));
}
bool CGlobalModules::OnAddUser(CUser& User, CString& sErrorRet) {
GLOBALMODHALTCHK(OnAddUser(User, sErrorRet));
}
bool CGlobalModules::OnDeleteUser(CUser& User) {
GLOBALMODHALTCHK(OnDeleteUser(User));
}
+8
View File
@@ -888,6 +888,13 @@ public:
* @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
* the module stops adding the user.
* @return See CModule::EModRet.
*/
virtual EModRet OnAddUser(CUser& User, CString& sErrorRet);
/** This module hook is called when a user is deleted.
* @param User The user which will be deleted.
* @return See CModule::EModRet.
@@ -933,6 +940,7 @@ public:
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);
bool OnLoginAttempt(CSmartPtr<CAuthBase> Auth);
+5
View File
@@ -1803,6 +1803,11 @@ bool CZNC::AddUser(CUser* pUser, CString& sErrorRet) {
<< sErrorRet << "]");
return false;
}
if (!GetModules().OnAddUser(*pUser, sErrorRet)) {
DEBUG("AddUser [" << pUser->GetUserName() << "] aborted by a module ["
<< sErrorRet << "]");
return false;
}
m_msUsers[pUser->GetUserName()] = pUser;
return true;
}