Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:znc/znc

  • Loading branch information...
commit 48a013f758be8316041f5739809e9e4f1901dedd 2 parents 3fd0429 + 3945d43
Alexey Sokolov authored
4 include/znc/IRCNetwork.h
View
@@ -30,10 +30,10 @@ class CIRCNetwork {
static bool IsValidNetwork(const CString& sNetwork);
CIRCNetwork(CUser *pUser, const CString& sName);
- CIRCNetwork(CUser *pUser, const CIRCNetwork& Network, bool bCloneChans = true);
+ CIRCNetwork(CUser *pUser, const CIRCNetwork& Network);
~CIRCNetwork();
- void Clone(const CIRCNetwork& Network, bool bCloneChans = true);
+ void Clone(const CIRCNetwork& Network);
CString GetNetworkPath();
2  include/znc/User.h
View
@@ -91,7 +91,7 @@ class CUser {
CString AddTimestamp(const CString& sStr) const;
CString AddTimestamp(time_t tm, const CString& sStr) const;
- bool Clone(const CUser& User, CString& sErrorRet, bool bCloneChans = true);
+ bool Clone(const CUser& User, CString& sErrorRet, bool bCloneNetworks = true);
void BounceAllClients();
void AddBytesRead(unsigned long long u) { m_uBytesRead += u; }
9 src/IRCNetwork.cpp
View
@@ -54,7 +54,7 @@ CIRCNetwork::CIRCNetwork(CUser *pUser, const CString& sName) {
m_QueryBuffer.SetLineCount(250, true);
}
-CIRCNetwork::CIRCNetwork(CUser *pUser, const CIRCNetwork &Network, bool bCloneChans) {
+CIRCNetwork::CIRCNetwork(CUser *pUser, const CIRCNetwork &Network) {
m_pUser = NULL;
SetUser(pUser);
@@ -70,10 +70,10 @@ CIRCNetwork::CIRCNetwork(CUser *pUser, const CIRCNetwork &Network, bool bCloneCh
m_MotdBuffer.SetLineCount(200, true); // This should be more than enough motd lines
m_QueryBuffer.SetLineCount(250, true);
- Clone(Network, bCloneChans);
+ Clone(Network);
}
-void CIRCNetwork::Clone(const CIRCNetwork& Network, bool bCloneChans) {
+void CIRCNetwork::Clone(const CIRCNetwork& Network) {
m_sName = Network.GetName();
SetNick(Network.GetNick());
@@ -136,8 +136,7 @@ void CIRCNetwork::Clone(const CIRCNetwork& Network, bool bCloneChans) {
if (!pNewChan) {
pChan->SetInConfig(false);
} else {
- if (bCloneChans)
- pChan->Clone(*pNewChan);
+ pChan->Clone(*pNewChan);
}
}
// !Chans
58 src/User.cpp
View
@@ -563,7 +563,7 @@ void CUser::UserDisconnected(CClient* pClient) {
}
}
-bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneChans) {
+bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneNetworks) {
unsigned int a = 0;
sErrorRet.clear();
@@ -615,40 +615,42 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneChans) {
// !Allowed Hosts
// Networks
- const vector<CIRCNetwork*>& vNetworks = User.GetNetworks();
- for (vector<CIRCNetwork*>::const_iterator it = vNetworks.begin(); it != vNetworks.end(); ++it) {
- CIRCNetwork *pNetwork = FindNetwork((*it)->GetName());
+ if (bCloneNetworks) {
+ const vector<CIRCNetwork*>& vNetworks = User.GetNetworks();
+ for (vector<CIRCNetwork*>::const_iterator it = vNetworks.begin(); it != vNetworks.end(); ++it) {
+ CIRCNetwork *pNetwork = FindNetwork((*it)->GetName());
- if (pNetwork) {
- pNetwork->Clone(*(*it), bCloneChans);
- } else {
- new CIRCNetwork(this, *(*it), bCloneChans);
+ if (pNetwork) {
+ pNetwork->Clone(*(*it));
+ } else {
+ new CIRCNetwork(this, *(*it));
+ }
}
- }
- set<CString> ssDeleteNetworks;
- for (vector<CIRCNetwork*>::const_iterator it = m_vIRCNetworks.begin(); it != m_vIRCNetworks.end(); ++it) {
- if (!(User.FindNetwork((*it)->GetName()))) {
- ssDeleteNetworks.insert((*it)->GetName());
+ set<CString> ssDeleteNetworks;
+ for (vector<CIRCNetwork*>::const_iterator it = m_vIRCNetworks.begin(); it != m_vIRCNetworks.end(); ++it) {
+ if (!(User.FindNetwork((*it)->GetName()))) {
+ ssDeleteNetworks.insert((*it)->GetName());
+ }
}
- }
- for (set<CString>::const_iterator it = ssDeleteNetworks.begin(); it != ssDeleteNetworks.end(); ++it) {
- // The following will move all the clients to the user.
- // So the clients are not disconnected. The client could
- // have requested the rehash. Then when we do
- // client->PutStatus("Rehashing succeeded!") we would
- // crash if there was no client anymore.
- vector<CClient*>& vClients = FindNetwork(*it)->GetClients();
+ for (set<CString>::const_iterator it = ssDeleteNetworks.begin(); it != ssDeleteNetworks.end(); ++it) {
+ // The following will move all the clients to the user.
+ // So the clients are not disconnected. The client could
+ // have requested the rehash. Then when we do
+ // client->PutStatus("Rehashing succeeded!") we would
+ // crash if there was no client anymore.
+ vector<CClient*>& vClients = FindNetwork(*it)->GetClients();
+
+ while (vClients.begin() != vClients.end()) {
+ CClient *pClient = vClients.front();
+ // This line will remove pClient from vClients,
+ // because it's a reference to the internal Network's vector.
+ pClient->SetNetwork(NULL);
+ }
- while (vClients.begin() != vClients.end()) {
- CClient *pClient = vClients.front();
- // This line will remove pClient from vClients,
- // because it's a reference to the internal Network's vector.
- pClient->SetNetwork(NULL);
+ DeleteNetwork(*it);
}
-
- DeleteNetwork(*it);
}
// !Networks
Please sign in to comment.
Something went wrong with that request. Please try again.