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

This commit is contained in:
Alexey Sokolov
2011-11-19 11:49:19 +07:00
4 changed files with 41 additions and 40 deletions
+2 -2
View File
@@ -30,10 +30,10 @@ public:
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();
+1 -1
View File
@@ -91,7 +91,7 @@ public:
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; }
+4 -5
View File
@@ -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
+34 -32
View File
@@ -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);
}
}
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();
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);
if (pNetwork) {
pNetwork->Clone(*(*it));
} else {
new CIRCNetwork(this, *(*it));
}
}
DeleteNetwork(*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());
}
}
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);
}
DeleteNetwork(*it);
}
}
// !Networks