mirror of
https://github.com/znc/znc.git
synced 2026-06-30 06:51:26 +02:00
Use GetIRCSock() instead of m_pIRCSock directly
This patch makes the code in CClient use a wrapper function for accessing the IRC socket. Wait and see for why I do this. ;) git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1724 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
+10
-10
@@ -186,7 +186,7 @@ void CClient::ReadLine(const CString& sData) {
|
||||
// If the client meant to ping us or we can be sure the server
|
||||
// won't answer the ping (=no server connected) -> PONG back.
|
||||
// else: It's the server's job to send a PONG.
|
||||
if (sTarget.Equals("irc.znc.in") || !m_pIRCSock) {
|
||||
if (sTarget.Equals("irc.znc.in") || !GetIRCSock()) {
|
||||
PutClient("PONG " + sLine.substr(5));
|
||||
return;
|
||||
}
|
||||
@@ -323,7 +323,7 @@ void CClient::ReadLine(const CString& sData) {
|
||||
// make sense. Comment this out and wait for complaints.
|
||||
#if 0
|
||||
if (sMsg.WildCmp("DCC * (*)")) {
|
||||
sMsg = "DCC " + sLine.Token(3) + " (" + ((m_pIRCSock) ? m_pIRCSock->GetLocalIP() : GetLocalIP()) + ")";
|
||||
sMsg = "DCC " + sLine.Token(3) + " (" + ((GetIRCSock()) ? GetIRCSock()->GetLocalIP() : GetLocalIP()) + ")";
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -341,7 +341,7 @@ void CClient::ReadLine(const CString& sData) {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!m_pIRCSock) {
|
||||
if (!GetIRCSock()) {
|
||||
// Some lagmeters do a NOTICE to their own nick, ignore those.
|
||||
if (!sTarget.Equals(m_sNick))
|
||||
PutStatus("Your notice to [" + sTarget + "] got lost, "
|
||||
@@ -528,7 +528,7 @@ void CClient::ReadLine(const CString& sData) {
|
||||
|
||||
MODULECALL(OnUserMsg(sTarget, sMsg), m_pUser, this, return);
|
||||
|
||||
if (!m_pIRCSock) {
|
||||
if (!GetIRCSock()) {
|
||||
// Some lagmeters do a PRIVMSG to their own nick, ignore those.
|
||||
if (!sTarget.Equals(m_sNick))
|
||||
PutStatus("Your message to [" + sTarget + "] got lost, "
|
||||
@@ -743,8 +743,8 @@ void CClient::IRCDisconnected() {
|
||||
}
|
||||
|
||||
void CClient::PutIRC(const CString& sLine) {
|
||||
if (m_pIRCSock) {
|
||||
m_pIRCSock->PutIRC(sLine);
|
||||
if (GetIRCSock()) {
|
||||
GetIRCSock()->PutIRC(sLine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -790,16 +790,16 @@ void CClient::PutModule(const CString& sModule, const CString& sLine) {
|
||||
CString CClient::GetNick(bool bAllowIRCNick) const {
|
||||
CString sRet;
|
||||
|
||||
if ((bAllowIRCNick) && (IsAttached()) && (m_pIRCSock)) {
|
||||
sRet = m_pIRCSock->GetNick();
|
||||
if ((bAllowIRCNick) && (IsAttached()) && (GetIRCSock())) {
|
||||
sRet = GetIRCSock()->GetNick();
|
||||
}
|
||||
|
||||
return (sRet.empty()) ? m_sNick : sRet;
|
||||
}
|
||||
|
||||
CString CClient::GetNickMask() const {
|
||||
if (m_pIRCSock && m_pIRCSock->IsAuthed()) {
|
||||
return m_pIRCSock->GetNickMask();
|
||||
if (GetIRCSock() && GetIRCSock()->IsAuthed()) {
|
||||
return GetIRCSock()->GetNickMask();
|
||||
}
|
||||
|
||||
CString sHost = m_pUser->GetVHost();
|
||||
|
||||
@@ -130,6 +130,8 @@ public:
|
||||
|
||||
void SetNick(const CString& s);
|
||||
CUser* GetUser() const { return m_pUser; }
|
||||
const CIRCSock* GetIRCSock() const { return m_pIRCSock; }
|
||||
CIRCSock* GetIRCSock() { return m_pIRCSock; }
|
||||
private:
|
||||
|
||||
protected:
|
||||
|
||||
+4
-4
@@ -231,8 +231,8 @@ void CClient::UserCommand(CString& sLine) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_pIRCSock) {
|
||||
m_pIRCSock->Quit();
|
||||
if (GetIRCSock()) {
|
||||
GetIRCSock()->Quit();
|
||||
PutStatus("Jumping to the next server in the list...");
|
||||
} else {
|
||||
PutStatus("Connecting...");
|
||||
@@ -245,8 +245,8 @@ void CClient::UserCommand(CString& sLine) {
|
||||
// m_pIRCSock is only set after the low level connection
|
||||
// to the IRC server was established. Before this we can
|
||||
// only find the IRC socket by its name.
|
||||
if (m_pIRCSock) {
|
||||
m_pIRCSock->Quit();
|
||||
if (GetIRCSock()) {
|
||||
GetIRCSock()->Quit();
|
||||
} else {
|
||||
Csock* pIRCSock;
|
||||
CString sSockName = "IRC::" + m_pUser->GetUserName();
|
||||
|
||||
Reference in New Issue
Block a user