From: <cf...@us...> - 2010-03-09 20:24:52
|
Revision: 1820 http://znc.svn.sourceforge.net/znc/?rev=1820&view=rev Author: cflakes Date: 2010-03-09 20:24:43 +0000 (Tue, 09 Mar 2010) Log Message: ----------- Added a new module hook EModRet OnAddUser(CUser& User, CString& sErrorRet) for global modules. Idea by BrianC. Modified Paths: -------------- trunk/Modules.cpp trunk/Modules.h trunk/znc.cpp Modified: trunk/Modules.cpp =================================================================== --- trunk/Modules.cpp 2010-03-09 19:44:24 UTC (rev 1819) +++ trunk/Modules.cpp 2010-03-09 20:24:43 UTC (rev 1820) @@ -498,6 +498,7 @@ 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 @@ GLOBALMODCALL(OnWriteChanConfig(Config, Chan)); } +bool CGlobalModules::OnAddUser(CUser& User, CString& sErrorRet) { + GLOBALMODHALTCHK(OnAddUser(User, sErrorRet)); +} + bool CGlobalModules::OnDeleteUser(CUser& User) { GLOBALMODHALTCHK(OnDeleteUser(User)); } Modified: trunk/Modules.h =================================================================== --- trunk/Modules.h 2010-03-09 19:44:24 UTC (rev 1819) +++ trunk/Modules.h 2010-03-09 20:24:43 UTC (rev 1820) @@ -888,6 +888,13 @@ * @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 @@ 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); Modified: trunk/znc.cpp =================================================================== --- trunk/znc.cpp 2010-03-09 19:44:24 UTC (rev 1819) +++ trunk/znc.cpp 2010-03-09 20:24:43 UTC (rev 1820) @@ -1803,6 +1803,11 @@ << 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; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |