diff --git a/Chan.cpp b/Chan.cpp index 2e2ba5fb..d254e5f5 100644 --- a/Chan.cpp +++ b/Chan.cpp @@ -44,10 +44,11 @@ void CChan::Cycle() const { m_pUser->PutIRC("PART " + GetName() + "\r\nJOIN " + GetName() + " " + GetKey()); } -void CChan::JoinUser(bool bForce) { +void CChan::JoinUser(bool bForce, const CString& sKey) { if (!bForce && (!IsOn() || !IsDetached())) { IncClientRequests(); - m_pUser->PutIRC("JOIN " + GetName()); + + m_pUser->PutIRC("JOIN " + GetName() + " " + ((sKey.empty()) ? GetKey() : sKey)); return; } @@ -124,7 +125,7 @@ CString CChan::GetModeString() const { void CChan::SetModes(const CString& sModes) { m_musModes.clear(); m_uLimit = 0; - m_sKey = ""; + m_sCurKey = ""; ModeChange(sModes); } @@ -244,6 +245,10 @@ void CChan::ModeChange(const CString& sModes, const CString& sOpNick) { break; } + if (uMode == M_Key) { + m_sCurKey = (bAdd) ? sArg : ""; + } + (bAdd) ? AddMode(uMode, sArg) : RemMode(uMode, sArg); } } diff --git a/Chan.h b/Chan.h index fb207f54..439e8d49 100644 --- a/Chan.h +++ b/Chan.h @@ -1,6 +1,7 @@ #ifndef _CHAN_H #define _CHAN_H +#include "main.h" #include "Nick.h" #include "String.h" #include @@ -45,7 +46,7 @@ public: void Reset(); void Joined(); void Cycle() const; - void JoinUser(bool bForce = false); + void JoinUser(bool bForce = false, const CString& sKey = ""); void DetachUser(); void SendBuffer(); @@ -110,7 +111,7 @@ public: const bool IsOn() const { return m_bIsOn; } const CString& GetName() const { return m_sName; } const map& GetModes() const { return m_musModes; } - const CString& GetKey() const { return m_sKey; } + const CString& GetKey() const { return (!m_sCurKey.empty()) ? m_sCurKey : m_sKey; } unsigned int GetLimit() const { return m_uLimit; } const CString& GetTopic() const { return m_sTopic; } const CString& GetTopicOwner() const { return m_sTopicOwner; } @@ -134,6 +135,7 @@ protected: bool m_bAutoCycle; CString m_sName; CString m_sKey; + CString m_sCurKey; CString m_sTopic; CString m_sTopicOwner; unsigned long m_ulTopicDate; diff --git a/UserSock.cpp b/UserSock.cpp index 96196aa3..f90250c9 100644 --- a/UserSock.cpp +++ b/UserSock.cpp @@ -112,6 +112,8 @@ void CUserSock::ReadLine(const CString& sData) { return; // Don't forward this msg. ZNC has already registered us. } else if (sCommand.CaseCmp("JOIN") == 0) { CString sChan = sLine.Token(1); + CString sKey = sLine.Token(2); + if (sChan.Left(1) == ":") { sChan.LeftChomp(); } @@ -120,7 +122,7 @@ void CUserSock::ReadLine(const CString& sData) { CChan* pChan = m_pUser->FindChan(sChan); if (pChan) { - pChan->JoinUser(); + pChan->JoinUser(false, sKey); return; } } @@ -524,11 +526,11 @@ void CUserSock::UserCommand(const CString& sLine) { Table.SetCell("Buf", CString((pChan->KeepBuffer()) ? "*" : "") + CString::ToString(pChan->GetBufferCount())); CString sModes = pChan->GetModeString(); - unsigned int uLimit = pChan->GetLimit(); + /*unsigned int uLimit = pChan->GetLimit(); const CString& sKey = pChan->GetKey(); if (uLimit) { sModes += " " + CString::ToString(uLimit); } - if (!sKey.empty()) { sModes += " " + sKey; } + if (!sKey.empty()) { sModes += " " + sKey; }*/ Table.SetCell("Modes", sModes); Table.SetCell("Users", CString::ToString(pChan->GetNickCount()));