Remove KeepNick

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1151 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-07-24 11:34:11 +00:00
parent 3ec3f07523
commit 03e34ac6e6
11 changed files with 5 additions and 146 deletions
+2 -34
View File
@@ -84,26 +84,9 @@ void CClient::ReadLine(const CString& sData) {
}
if (!m_pIRCSock) {
// No need to check against IRC nick or to forward it
// No need to forward it
return;
}
if ((m_pUser) && (sNick.CaseCmp(m_pUser->GetNick()) == 0)) {
m_uKeepNickCounter++;
// If the user is changing his nick to the conifg nick, set keepnick to the config value
if (m_pUser->GetKeepNick() && !m_pIRCSock->GetKeepNick()) {
m_pIRCSock->SetKeepNick(true);
PutStatusNotice("Reset KeepNick back to true");
}
}
if (m_pUser && GetNick().CaseCmp(m_pUser->GetNick()) == 0) {
// If the user changes his nick away from the config nick, we shut off keepnick for this session
if (m_pUser->GetKeepNick()) {
m_pIRCSock->SetKeepNick(false);
PutStatusNotice("Set KeepNick to false");
}
}
} else if (sCommand.CaseCmp("USER") == 0) {
if (!IsAttached()) {
if (m_sUser.empty()) {
@@ -593,22 +576,7 @@ void CClient::ReadLine(const CString& sData) {
}
void CClient::SetNick(const CString& s) {
m_sNick = s;
if (m_pUser) {
if (m_sNick.CaseCmp(m_pUser->GetNick()) == 0) {
m_uKeepNickCounter = 0;
}
}
}
bool CClient::DecKeepNickCounter() {
if (!m_uKeepNickCounter) {
return false;
}
m_uKeepNickCounter--;
return true;
m_sNick = s;
}
void CClient::StatusCTCP(const CString& sLine) {
-3
View File
@@ -84,7 +84,6 @@ public:
m_bGotUser = false;
m_bNamesx = false;
m_bUHNames = false;
m_uKeepNickCounter = 0;
EnableReadLine();
}
@@ -98,7 +97,6 @@ public:
bool HasNamesx() const { return m_bNamesx; }
bool HasUHNames() const { return m_bUHNames; }
bool DecKeepNickCounter();
void UserCommand(const CString& sCommand);
void StatusCTCP(const CString& sCommand);
void IRCConnected(CIRCSock* pIRCSock);
@@ -138,7 +136,6 @@ protected:
CString m_sPass;
CString m_sUser;
CIRCSock* m_pIRCSock;
unsigned int m_uKeepNickCounter;
CSmartPtr<CAuthBase> m_spAuth;
CClientTimeout* m_pTimeout;
};
-33
View File
@@ -16,9 +16,7 @@
CIRCSock::CIRCSock(CUser* pUser) : Csock() {
m_pUser = pUser;
m_bISpoofReleased = false;
m_bKeepNick = true;
m_bAuthed = false;
m_bOrigNickPending = false;
m_bNamesx = false;
m_bUHNames = false;
EnableReadLine();
@@ -181,22 +179,6 @@ void CIRCSock::ReadLine(const CString& sData) {
if (sNick == "*") {
SendAltNick(sBadNick);
return;
} else {
// :irc.server.net 433 mynick badnick :Nickname is already in use.
if ((m_bKeepNick) && (m_pUser->GetKeepNick())) {
if (sBadNick.CaseCmp(sConfNick) == 0) {
vector<CClient*>& vClients = m_pUser->GetClients();
for (unsigned int a = 0; a < vClients.size(); a++) {
CClient* pClient = vClients[a];
if (!pClient || !pClient->DecKeepNickCounter()) {
SetOrigNickPending(false);
return;
}
}
}
}
}
break;
}
@@ -369,8 +351,6 @@ void CIRCSock::ReadLine(const CString& sData) {
// We are changing our own nick, the clients always must see this!
bIsVisible = true;
SetNick(sNewNick);
} else if (Nick.GetNick().CaseCmp(m_pUser->GetNick()) == 0) {
KeepNick(true);
}
MODULECALL(OnNick(Nick, sNewNick, vFoundChans), m_pUser, NULL, );
@@ -407,10 +387,6 @@ void CIRCSock::ReadLine(const CString& sData) {
}
}
if (Nick.GetNick().CaseCmp(m_pUser->GetNick()) == 0) {
KeepNick(true);
}
MODULECALL(OnQuit(Nick, sMessage, vFoundChans), m_pUser, NULL, );
if (!bIsVisible) {
@@ -649,15 +625,6 @@ void CIRCSock::ReadLine(const CString& sData) {
m_pUser->PutUser(sLine);
}
void CIRCSock::KeepNick(bool bForce) {
const CString& sConfNick = m_pUser->GetNick();
if (m_bAuthed && m_bKeepNick && (!IsOrigNickPending() || bForce) && m_pUser->GetKeepNick() && GetNick().CaseCmp(sConfNick) != 0) {
PutIRC("NICK " + sConfNick);
SetOrigNickPending(true);
}
}
bool CIRCSock::OnCTCPReply(CNick& Nick, CString& sMessage) {
MODULECALL(OnCTCPReply(Nick, sMessage), m_pUser, NULL, return true);
-7
View File
@@ -47,19 +47,15 @@ public:
virtual void SockError(int iErrno);
virtual void Timeout();
void KeepNick(bool bForce = false);
void PutIRC(const CString& sLine);
void ResetChans();
void Quit();
// Setters
void SetPass(const CString& s) { m_sPass = s; }
void SetKeepNick(bool b) { m_bKeepNick = b; }
void SetOrigNickPending(bool b) { m_bOrigNickPending = b; }
// !Setters
// Getters
bool GetKeepNick() const { return m_bKeepNick; }
unsigned int GetMaxNickLen() const { return m_uMaxNickLen; }
EChanModeArgs GetModeType(unsigned char uMode) const;
unsigned char GetPermFromMode(unsigned char uMode) const;
@@ -71,7 +67,6 @@ public:
CString GetNickMask() const { return m_Nick.GetNickMask(); }
const CString& GetNick() const { return m_Nick.GetNick(); }
const CString& GetPass() const { return m_sPass; }
bool IsOrigNickPending() const { return m_bOrigNickPending; }
CUser* GetUser() const { return m_pUser; }
bool HasNamesx() const { return m_bNamesx; }
bool HasUHNames() const { return m_bUHNames; }
@@ -88,8 +83,6 @@ private:
protected:
bool m_bISpoofReleased;
bool m_bAuthed;
bool m_bKeepNick;
bool m_bOrigNickPending;
bool m_bNamesx;
bool m_bUHNames;
CString m_sPerms;
-29
View File
@@ -13,35 +13,6 @@
#include "IRCSock.h"
#include "User.h"
class CKeepNickTimer : public CCron {
public:
CKeepNickTimer(CUser* pUser) : CCron() {
m_pUser = pUser;
m_uTrys = 0;
SetName("CKeepNickTimer::" + m_pUser->GetUserName());
Start(5);
}
virtual ~CKeepNickTimer() {}
private:
protected:
virtual void RunJob() {
CIRCSock* pSock = m_pUser->GetIRCSock();
if (pSock) {
if (m_uTrys++ >= 40) {
pSock->SetOrigNickPending(false);
m_uTrys = 0;
}
pSock->KeepNick();
}
}
CUser* m_pUser;
unsigned int m_uTrys;
};
class CMiscTimer : public CCron {
public:
CMiscTimer(CUser* pUser) : CCron() {
-8
View File
@@ -34,7 +34,6 @@ CUser::CUser(const CString& sUserName) {
m_bBounceDCCs = true;
m_bPassHashed = false;
m_bUseClientIP = false;
m_bKeepNick = false;
m_bDenyLoadMod = false;
m_bAdmin= false;
m_bDenySetVHost= false;
@@ -49,10 +48,8 @@ CUser::CUser(const CString& sUserName) {
m_bAppendTimestamp = false;
m_bPrependTimestamp = true;
m_bIRCConnectEnabled = true;
m_pKeepNickTimer = new CKeepNickTimer(this);
m_pJoinTimer = new CJoinTimer(this);
m_pMiscTimer = new CMiscTimer(this);
CZNC::Get().GetManager().AddCron(m_pKeepNickTimer);
CZNC::Get().GetManager().AddCron(m_pJoinTimer);
CZNC::Get().GetManager().AddCron(m_pMiscTimer);
m_sUserPath = CZNC::Get().GetUserPath() + "/" + sUserName;
@@ -72,7 +69,6 @@ CUser::~CUser() {
delete m_vChans[b];
}
CZNC::Get().GetManager().DelCronByAddr(m_pKeepNickTimer);
CZNC::Get().GetManager().DelCronByAddr(m_pJoinTimer);
CZNC::Get().GetManager().DelCronByAddr(m_pMiscTimer);
}
@@ -424,7 +420,6 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneChans) {
// Flags
SetKeepBuffer(User.KeepBuffer());
SetAutoCycle(User.AutoCycle());
SetKeepNick(User.GetKeepNick());
SetMultiClients(User.MultiClients());
SetBounceDCCs(User.BounceDCCs());
SetUseClientIP(User.UseClientIP());
@@ -579,7 +574,6 @@ bool CUser::WriteConfig(CFile& File) {
PrintLine(File, "StatusPrefix", GetStatusPrefix());
PrintLine(File, "ChanModes", GetDefaultChanModes());
PrintLine(File, "Buffer", CString(GetBufferCount()));
PrintLine(File, "KeepNick", CString((GetKeepNick()) ? "true" : "false"));
PrintLine(File, "KeepBuffer", CString((KeepBuffer()) ? "true" : "false"));
PrintLine(File, "MultiClients", CString((MultiClients()) ? "true" : "false"));
PrintLine(File, "BounceDCCs", CString((BounceDCCs()) ? "true" : "false"));
@@ -1028,7 +1022,6 @@ void CUser::SetPass(const CString& s, bool bHashed, const CString& sSalt) {
void CUser::SetMultiClients(bool b) { m_bMultiClients = b; }
void CUser::SetBounceDCCs(bool b) { m_bBounceDCCs = b; }
void CUser::SetUseClientIP(bool b) { m_bUseClientIP = b; }
void CUser::SetKeepNick(bool b) { m_bKeepNick = b; }
void CUser::SetDenyLoadMod(bool b) { m_bDenyLoadMod = b; }
void CUser::SetAdmin(bool b) { m_bAdmin = b; }
void CUser::SetDenySetVHost(bool b) { m_bDenySetVHost = b; }
@@ -1100,7 +1093,6 @@ bool CUser::ConnectPaused() {
}
bool CUser::UseClientIP() const { return m_bUseClientIP; }
bool CUser::GetKeepNick() const { return m_bKeepNick; }
bool CUser::DenyLoadMod() const { return m_bDenyLoadMod; }
bool CUser::IsAdmin() const { return m_bAdmin; }
bool CUser::DenySetVHost() const { return m_bDenySetVHost; }
-5
View File
@@ -26,7 +26,6 @@ class CChan;
class CClient;
class CIRCSock;
class CJoinTimer;
class CKeepNickTimer;
class CMiscTimer;
class CServer;
@@ -123,7 +122,6 @@ public:
void SetBounceDCCs(bool b);
void SetMultiClients(bool b);
void SetUseClientIP(bool b);
void SetKeepNick(bool b);
void SetDenyLoadMod(bool b);
void SetAdmin(bool b);
void SetDenySetVHost(bool b);
@@ -173,7 +171,6 @@ public:
const CString& GetDLPath() const { if (!CFile::Exists(m_sDLPath)) { CDir::MakeDir(m_sDLPath); } return m_sDLPath; }
bool UseClientIP() const;
bool GetKeepNick() const;
bool DenyLoadMod() const;
bool IsAdmin() const;
bool DenySetVHost() const;
@@ -231,7 +228,6 @@ protected:
bool m_bBounceDCCs;
bool m_bPassHashed;
bool m_bUseClientIP;
bool m_bKeepNick;
bool m_bDenyLoadMod;
bool m_bAdmin;
bool m_bDenySetVHost;
@@ -243,7 +239,6 @@ protected:
bool m_bIRCConnectEnabled;
CIRCSock* m_pIRCSock;
CKeepNickTimer* m_pKeepNickTimer;
CJoinTimer* m_pJoinTimer;
CMiscTimer* m_pMiscTimer;
-13
View File
@@ -59,14 +59,6 @@ public:
SetNV("nick", m_sFormat);
if (m_pUser->GetKeepNick()) {
sMessage = "KeepNick disabled";
PutModule("You have KeepNick enabled. "
"This won't work together with awaynick.");
PutModule("Disabling KeepNick for you...");
m_pUser->SetKeepNick(false);
}
return true;
}
@@ -103,11 +95,6 @@ public:
}
virtual void OnUserAttached() {
if (m_pUser->GetKeepNick()) {
PutModule("WARNING: You have KeepNick enabled. "
"This won't work with awaynick.");
}
StartBackNickTimer();
}
-6
View File
@@ -893,11 +893,6 @@ bool CWebAdminSock::UserPage(CString& sPageRet, CUser* pUser) {
o2["DisplayName"] = "Auto Cycle";
if (!pUser || pUser->AutoCycle()) { o2["Checked"] = "true"; }
CTemplate& o3 = m_Template.AddRow("OptionLoop");
o3["Name"] = "keepnick";
o3["DisplayName"] = "Keep Nick";
if (!pUser || pUser->GetKeepNick()) { o3["Checked"] = "true"; }
CTemplate& o4 = m_Template.AddRow("OptionLoop");
o4["Name"] = "multiclients";
o4["DisplayName"] = "Multi Clients";
@@ -1115,7 +1110,6 @@ CUser* CWebAdminSock::GetNewUser(CString& sPageRet, CUser* pUser) {
pNewUser->SetMultiClients(GetParam("multiclients").ToBool());
pNewUser->SetBounceDCCs(GetParam("bouncedccs").ToBool());
pNewUser->SetAutoCycle(GetParam("autocycle").ToBool());
pNewUser->SetKeepNick(GetParam("keepnick").ToBool());
pNewUser->SetUseClientIP(GetParam("useclientip").ToBool());
pNewUser->SetTimestampAppend(GetParam("appendtimestamp").ToBool());
pNewUser->SetTimestampPrepend(GetParam("prependtimestamp").ToBool());
-1
View File
@@ -50,7 +50,6 @@ StatusPrefix = *
QuitMsg = ZNC by prozac - http://znc.sourceforge.net
CTCPReply = VERSION ZNC by prozac - http://znc.sourceforge.net
ChanModes = +stn
KeepNick = true
// You may use multiple Allow lines to restrict access to this user. All connections are denied by default unless they match an ip below.
// Note: IPs only!
+3 -7
View File
@@ -691,12 +691,6 @@ bool CZNC::WriteNewConfig(const CString& sConfig) {
}
// todo: Possibly add motd
if (CUtils::GetBoolInput("Would you like ZNC to keep trying for your primary nick?", false)) {
vsLines.push_back("\tKeepNick = true");
} else {
vsLines.push_back("\tKeepNick = false");
}
unsigned int uBufferCount = 0;
CUtils::GetNumInput("Number of lines to buffer per channel", uBufferCount, 0, ~0, 50);
@@ -1229,7 +1223,9 @@ bool CZNC::DoRehash(CString& sError)
pUser->SetRealName(sValue);
continue;
} else if (sName.CaseCmp("KeepNick") == 0) {
pUser->SetKeepNick((sValue.CaseCmp("true") == 0));
if (sValue.CaseCmp("true") == 0) {
CUtils::PrintError("WARNING: KeepNick has been deprecated, instead try -> LoadModule = keepnick");
}
continue;
} else if (sName.CaseCmp("ChanModes") == 0) {
pUser->SetDefaultChanModes(sValue);