Split up CIRCSock::ForwardRaw353() into two function, one which is per-client

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1810 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2010-03-07 13:16:17 +00:00
parent 835df7e84e
commit 9ac3d94e64
2 changed files with 40 additions and 32 deletions
+38 -32
View File
@@ -988,48 +988,54 @@ void CIRCSock::ParseISupport(const CString& sLine) {
void CIRCSock::ForwardRaw353(const CString& sLine) const {
vector<CClient*>& vClients = m_pUser->GetClients();
vector<CClient*>::iterator it;
for (it = vClients.begin(); it != vClients.end(); ++it) {
ForwardRaw353(sLine, *it);
}
}
void CIRCSock::ForwardRaw353(const CString& sLine, CClient* pClient) const {
CString sNicks = sLine.Token(5, true);
if (sNicks.Left(1) == ":")
sNicks.LeftChomp();
for (unsigned int a = 0; a < vClients.size(); a++) {
if ((!m_bNamesx || vClients[a]->HasNamesx()) && (!m_bUHNames || vClients[a]->HasUHNames())) {
// Client and server have both the same UHNames and Namesx stuff enabled
m_pUser->PutUser(sLine, vClients[a]);
} else {
// Get everything except the actual user list
CString sTmp = sLine.Token(0, false, " :") + " :";
if ((!m_bNamesx || pClient->HasNamesx()) && (!m_bUHNames || pClient->HasUHNames())) {
// Client and server have both the same UHNames and Namesx stuff enabled
m_pUser->PutUser(sLine, pClient);
} else {
// Get everything except the actual user list
CString sTmp = sLine.Token(0, false, " :") + " :";
VCString vsNicks;
VCString::const_iterator it;
VCString vsNicks;
VCString::const_iterator it;
// This loop runs once for every nick on the channel
sNicks.Split(" ", vsNicks, false);
for (it = vsNicks.begin(); it != vsNicks.end(); ++it) {
CString sNick = *it;
if (sNick.empty())
break;
// This loop runs once for every nick on the channel
sNicks.Split(" ", vsNicks, false);
for (it = vsNicks.begin(); it != vsNicks.end(); ++it) {
CString sNick = *it;
if (sNick.empty())
break;
if (m_bNamesx && !vClients[a]->HasNamesx() && IsPermChar(sNick[0])) {
// Server has, client doesn't have NAMESX, so we just use the first perm char
size_t pos = sNick.find_first_not_of(GetPerms());
if (pos >= 2 && pos != CString::npos) {
sNick = sNick[0] + sNick.substr(pos);
}
if (m_bNamesx && !pClient->HasNamesx() && IsPermChar(sNick[0])) {
// Server has, client doesn't have NAMESX, so we just use the first perm char
size_t pos = sNick.find_first_not_of(GetPerms());
if (pos >= 2 && pos != CString::npos) {
sNick = sNick[0] + sNick.substr(pos);
}
if (m_bUHNames && !vClients[a]->HasUHNames()) {
// Server has, client hasnt UHNAMES,
// so we strip away ident and host.
sNick = sNick.Token(0, false, "!");
}
sTmp += sNick + " ";
}
// Strip away the spaces we inserted at the end
sTmp.TrimRight(" ");
m_pUser->PutUser(sTmp, vClients[a]);
if (m_bUHNames && !pClient->HasUHNames()) {
// Server has, client hasnt UHNAMES,
// so we strip away ident and host.
sNick = sNick.Token(0, false, "!");
}
sTmp += sNick + " ";
}
// Strip away the spaces we inserted at the end
sTmp.TrimRight(" ");
m_pUser->PutUser(sTmp, pClient);
}
}
+2
View File
@@ -15,6 +15,7 @@
// Forward Declarations
class CChan;
class CUser;
class CClient;
// !Forward Declarations
class CIRCSock : public CZNCSock {
@@ -79,6 +80,7 @@ private:
void SetNick(const CString& sNick);
void ParseISupport(const CString& sLine);
void ForwardRaw353(const CString& sLine) const;
void ForwardRaw353(const CString& sLine, CClient* pClient) const;
// This is called when we connect and the nick we want is already taken
void SendAltNick(const CString& sBadNick);
protected: