mirror of
https://github.com/znc/znc.git
synced 2026-06-28 14:01:35 +02:00
Allow a client to become "away"
The result of CIRCNetwork::IsUserOnline() will only show clients which do not have the away state set. This value is not set from the IRC command AWAY, but a future module could use this behaviour. Some CIRCNetwork::IsUserAttached() checks are now moved into of CIRCNetwork::IsUserOnline() checks. This allows "away" clients to store buffer even if KeepBuffer is false.
This commit is contained in:
@@ -84,6 +84,7 @@ public:
|
||||
m_bInCap = false;
|
||||
m_bNamesx = false;
|
||||
m_bUHNames = false;
|
||||
m_bAway = false;
|
||||
EnableReadLine();
|
||||
// RFC says a line can have 512 chars max, but we are
|
||||
// a little more gentle ;)
|
||||
@@ -101,6 +102,7 @@ public:
|
||||
CString GetNickMask() const;
|
||||
bool HasNamesx() const { return m_bNamesx; }
|
||||
bool HasUHNames() const { return m_bUHNames; }
|
||||
bool IsAway() const { return m_bAway; }
|
||||
|
||||
void UserCommand(CString& sLine);
|
||||
void UserPortCommand(CString& sLine);
|
||||
@@ -129,6 +131,7 @@ public:
|
||||
virtual void ReachedMaxBuffer();
|
||||
|
||||
void SetNick(const CString& s);
|
||||
void SetAway(bool bAway) { m_bAway = bAway; }
|
||||
CUser* GetUser() const { return m_pUser; }
|
||||
void SetNetwork(CIRCNetwork* pNetwork, bool bDisconnect=true, bool bReconnect=true);
|
||||
CIRCNetwork* GetNetwork() const { return m_pNetwork; }
|
||||
@@ -147,6 +150,7 @@ protected:
|
||||
bool m_bInCap;
|
||||
bool m_bNamesx;
|
||||
bool m_bUHNames;
|
||||
bool m_bAway;
|
||||
CUser* m_pUser;
|
||||
CIRCNetwork* m_pNetwork;
|
||||
CString m_sNick;
|
||||
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
void BounceAllClients();
|
||||
|
||||
bool IsUserAttached() const { return !m_vClients.empty(); }
|
||||
bool IsUserOnline() const;
|
||||
void ClientConnected(CClient *pClient);
|
||||
void ClientDisconnected(CClient *pClient);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
|
||||
void AddBuffer(CChan& Channel, const CString& sMessage) {
|
||||
// If they have keep buffer disabled, only add messages if no client is connected
|
||||
if (!Channel.KeepBuffer() && m_pUser->IsUserAttached())
|
||||
if (!Channel.KeepBuffer() && m_pUser->IsUserOnline())
|
||||
return;
|
||||
|
||||
CString s = ":" + GetModNick() + "!" + GetModName() + "@znc.in PRIVMSG "
|
||||
|
||||
@@ -325,6 +325,18 @@ void CIRCNetwork::BounceAllClients() {
|
||||
m_vClients.clear();
|
||||
}
|
||||
|
||||
bool CIRCNetwork::IsUserOnline() const {
|
||||
vector<CClient*>::const_iterator it;
|
||||
for (it = m_vClients.begin(); it != m_vClients.end(); ++it) {
|
||||
CClient *pClient = *it;
|
||||
if (!pClient->IsAway()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CIRCNetwork::ClientConnected(CClient *pClient) {
|
||||
if (!m_pUser->MultiClients()) {
|
||||
BounceAllClients();
|
||||
|
||||
+7
-7
@@ -652,7 +652,7 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
// :blub!dummy@rox-8DBEFE92 WALLOPS :this is a test
|
||||
CString sMsg = sRest.Token(0, true).TrimPrefix_n();
|
||||
|
||||
if (!m_pNetwork->IsUserAttached()) {
|
||||
if (!m_pNetwork->IsUserOnline()) {
|
||||
m_pNetwork->AddQueryBuffer(":" + Nick.GetNickMask() + " WALLOPS ", ":" + m_pNetwork->GetUser()->AddTimestamp(sMsg), false);
|
||||
}
|
||||
} else if (sCmd.Equals("CAP")) {
|
||||
@@ -758,7 +758,7 @@ bool CIRCSock::OnPrivCTCP(CNick& Nick, CString& sMessage) {
|
||||
if (sMessage.TrimPrefix("ACTION ")) {
|
||||
NETWORKMODULECALL(OnPrivAction(Nick, sMessage), m_pNetwork->GetUser(), m_pNetwork, NULL, return true);
|
||||
|
||||
if (!m_pNetwork->IsUserAttached()) {
|
||||
if (!m_pNetwork->IsUserOnline()) {
|
||||
// If the user is detached, add to the buffer
|
||||
m_pNetwork->AddQueryBuffer(":" + Nick.GetNickMask() + " PRIVMSG ", " :\001ACTION " + m_pNetwork->GetUser()->AddTimestamp(sMessage) + "\001");
|
||||
}
|
||||
@@ -813,7 +813,7 @@ bool CIRCSock::OnGeneralCTCP(CNick& Nick, CString& sMessage) {
|
||||
bool CIRCSock::OnPrivNotice(CNick& Nick, CString& sMessage) {
|
||||
NETWORKMODULECALL(OnPrivNotice(Nick, sMessage), m_pNetwork->GetUser(), m_pNetwork, NULL, return true);
|
||||
|
||||
if (!m_pNetwork->IsUserAttached()) {
|
||||
if (!m_pNetwork->IsUserOnline()) {
|
||||
// If the user is detached, add to the buffer
|
||||
m_pNetwork->AddQueryBuffer(":" + Nick.GetNickMask() + " NOTICE ", " :" + m_pNetwork->GetUser()->AddTimestamp(sMessage));
|
||||
}
|
||||
@@ -824,7 +824,7 @@ bool CIRCSock::OnPrivNotice(CNick& Nick, CString& sMessage) {
|
||||
bool CIRCSock::OnPrivMsg(CNick& Nick, CString& sMessage) {
|
||||
NETWORKMODULECALL(OnPrivMsg(Nick, sMessage), m_pNetwork->GetUser(), m_pNetwork, NULL, return true);
|
||||
|
||||
if (!m_pNetwork->IsUserAttached()) {
|
||||
if (!m_pNetwork->IsUserOnline()) {
|
||||
// If the user is detached, add to the buffer
|
||||
m_pNetwork->AddQueryBuffer(":" + Nick.GetNickMask() + " PRIVMSG ", " :" + m_pNetwork->GetUser()->AddTimestamp(sMessage));
|
||||
}
|
||||
@@ -840,7 +840,7 @@ bool CIRCSock::OnChanCTCP(CNick& Nick, const CString& sChan, CString& sMessage)
|
||||
// Record a /me
|
||||
if (sMessage.TrimPrefix("ACTION ")) {
|
||||
NETWORKMODULECALL(OnChanAction(Nick, *pChan, sMessage), m_pNetwork->GetUser(), m_pNetwork, NULL, return true);
|
||||
if (pChan->KeepBuffer() || !m_pNetwork->IsUserAttached() || pChan->IsDetached()) {
|
||||
if (pChan->KeepBuffer() || !m_pNetwork->IsUserOnline() || pChan->IsDetached()) {
|
||||
pChan->AddBuffer(":" + Nick.GetNickMask() + " PRIVMSG " + sChan + " :\001ACTION " + m_pNetwork->GetUser()->AddTimestamp(sMessage) + "\001");
|
||||
}
|
||||
sMessage = "ACTION " + sMessage;
|
||||
@@ -858,7 +858,7 @@ bool CIRCSock::OnChanNotice(CNick& Nick, const CString& sChan, CString& sMessage
|
||||
if (pChan) {
|
||||
NETWORKMODULECALL(OnChanNotice(Nick, *pChan, sMessage), m_pNetwork->GetUser(), m_pNetwork, NULL, return true);
|
||||
|
||||
if (pChan->KeepBuffer() || !m_pNetwork->IsUserAttached() || pChan->IsDetached()) {
|
||||
if (pChan->KeepBuffer() || !m_pNetwork->IsUserOnline() || pChan->IsDetached()) {
|
||||
pChan->AddBuffer(":" + Nick.GetNickMask() + " NOTICE " + sChan + " :" + m_pNetwork->GetUser()->AddTimestamp(sMessage));
|
||||
}
|
||||
}
|
||||
@@ -871,7 +871,7 @@ bool CIRCSock::OnChanMsg(CNick& Nick, const CString& sChan, CString& sMessage) {
|
||||
if (pChan) {
|
||||
NETWORKMODULECALL(OnChanMsg(Nick, *pChan, sMessage), m_pNetwork->GetUser(), m_pNetwork, NULL, return true);
|
||||
|
||||
if (pChan->KeepBuffer() || !m_pNetwork->IsUserAttached() || pChan->IsDetached()) {
|
||||
if (pChan->KeepBuffer() || !m_pNetwork->IsUserOnline() || pChan->IsDetached()) {
|
||||
pChan->AddBuffer(":" + Nick.GetNickMask() + " PRIVMSG " + sChan + " :" + m_pNetwork->GetUser()->AddTimestamp(sMessage));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user