mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Revise CChan::JoinUser() & AttachUser()
The old AttachUser() that sent JOIN without topic or names replies would leave clients in incomplete/broken state. JoinUser() was doing two things; depending on passed arguments it was either joining user on the channel on IRC, or attaching clients (properly). Now JoinUser() joins the user on IRC, and AttachUser() attaches as expected from the method names.
This commit is contained in:
@@ -63,9 +63,9 @@ public:
|
||||
CConfig ToConfig() const;
|
||||
void Clone(CChan& chan);
|
||||
void Cycle() const;
|
||||
void JoinUser(bool bForce = false, const CString& sKey = "", CClient* pClient = NULL);
|
||||
void JoinUser(const CString& sKey = "");
|
||||
void AttachUser(CClient* pClient = NULL);
|
||||
void DetachUser();
|
||||
void AttachUser();
|
||||
|
||||
void OnWho(const CString& sNick, const CString& sIdent, const CString& sHost);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
if (pChan)
|
||||
{
|
||||
pChan->JoinUser(true, "", GetClient());
|
||||
pChan->JoinUser();
|
||||
return HALT;
|
||||
}
|
||||
}
|
||||
|
||||
20
src/Chan.cpp
20
src/Chan.cpp
@@ -116,7 +116,7 @@ void CChan::Clone(CChan& chan) {
|
||||
// and only attach if we are on the channel)
|
||||
if (IsOn()) {
|
||||
if (IsDetached()) {
|
||||
JoinUser(false, "");
|
||||
AttachUser();
|
||||
} else {
|
||||
DetachUser();
|
||||
}
|
||||
@@ -129,13 +129,18 @@ void CChan::Cycle() const {
|
||||
m_pNetwork->PutIRC("PART " + GetName() + "\r\nJOIN " + GetName() + " " + GetKey());
|
||||
}
|
||||
|
||||
void CChan::JoinUser(bool bForce, const CString& sKey, CClient* pClient) {
|
||||
if (!bForce && (!IsOn() || !IsDetached())) {
|
||||
m_pNetwork->PutIRC("JOIN " + GetName() + " " + ((sKey.empty()) ? GetKey() : sKey));
|
||||
void CChan::JoinUser(const CString& sKey) {
|
||||
if (!sKey.empty()) {
|
||||
SetKey(sKey);
|
||||
}
|
||||
if (!IsOn() || !IsDetached()) {
|
||||
m_pNetwork->PutIRC("JOIN " + GetName() + " " + GetKey());
|
||||
SetDetached(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CChan::AttachUser(CClient* pClient) {
|
||||
m_pNetwork->PutUser(":" + m_pNetwork->GetIRCNick().GetNickMask() + " JOIN :" + GetName(), pClient);
|
||||
|
||||
if (!GetTopic().empty()) {
|
||||
@@ -199,13 +204,6 @@ void CChan::DetachUser() {
|
||||
}
|
||||
}
|
||||
|
||||
void CChan::AttachUser() {
|
||||
if (m_bDetached) {
|
||||
m_pNetwork->PutUser(":" + m_pNetwork->GetIRCNick().GetNickMask() + " JOIN " + GetName());
|
||||
m_bDetached = false;
|
||||
}
|
||||
}
|
||||
|
||||
CString CChan::GetModeString() const {
|
||||
CString sModes, sArgs;
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ void CClient::ReadLine(const CString& sData) {
|
||||
|
||||
CChan* pChan = m_pNetwork->FindChan(sChannel);
|
||||
if (pChan) {
|
||||
pChan->JoinUser(false, sKey);
|
||||
pChan->JoinUser(sKey);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -621,7 +621,7 @@ void CIRCNetwork::ClientConnected(CClient *pClient) {
|
||||
const vector<CChan*>& vChans = GetChans();
|
||||
for (size_t a = 0; a < vChans.size(); a++) {
|
||||
if ((vChans[a]->IsOn()) && (!vChans[a]->IsDetached())) {
|
||||
vChans[a]->JoinUser(true, "", pClient);
|
||||
vChans[a]->AttachUser(pClient);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user