diff --git a/modules/adminlog.cpp b/modules/adminlog.cpp index 77577b18..06ba032f 100644 --- a/modules/adminlog.cpp +++ b/modules/adminlog.cpp @@ -50,11 +50,11 @@ public: } virtual void OnIRCConnected() { - Log("[" + m_pUser->GetUserName() + "/" + m_pNetwork->GetName() + "] connected to IRC: " + m_pNetwork->GetCurrentServer()->GetName()); + Log("[" + GetUser()->GetUserName() + "/" + GetNetwork()->GetName() + "] connected to IRC: " + GetNetwork()->GetCurrentServer()->GetName()); } virtual void OnIRCDisconnected() { - Log("[" + m_pUser->GetUserName() + "/" + m_pNetwork->GetName() + "] disconnected from IRC"); + Log("[" + GetUser()->GetUserName() + "/" + GetNetwork()->GetName() + "] disconnected from IRC"); } virtual EModRet OnRaw(CString& sLine) { @@ -64,18 +64,18 @@ public: CString sError(sLine.substr(6)); if (sError.Left(1) == ":") sError.LeftChomp(); - Log("[" + m_pUser->GetUserName() + "/" + m_pNetwork->GetName() + "] disconnected from IRC: " + - m_pNetwork->GetCurrentServer()->GetName() + " [" + sError + "]", LOG_NOTICE); + Log("[" + GetUser()->GetUserName() + "/" + GetNetwork()->GetName() + "] disconnected from IRC: " + + GetNetwork()->GetCurrentServer()->GetName() + " [" + sError + "]", LOG_NOTICE); } return CONTINUE; } virtual void OnClientLogin() { - Log("[" + m_pUser->GetUserName() + "] connected to ZNC from " + m_pClient->GetRemoteIP()); + Log("[" + GetUser()->GetUserName() + "] connected to ZNC from " + GetClient()->GetRemoteIP()); } virtual void OnClientDisconnect() { - Log("[" + m_pUser->GetUserName() + "] disconnected from ZNC from " + m_pClient->GetRemoteIP()); + Log("[" + GetUser()->GetUserName() + "] disconnected from ZNC from " + GetClient()->GetRemoteIP()); } virtual void OnFailedLogin(const CString& sUsername, const CString& sRemoteIP) { diff --git a/modules/autocycle.cpp b/modules/autocycle.cpp index e8b0b44c..0b815b98 100644 --- a/modules/autocycle.cpp +++ b/modules/autocycle.cpp @@ -142,7 +142,7 @@ protected: // Is that person us and we don't have op? const CNick& pNick = Channel.GetNicks().begin()->second; - if (!pNick.HasPerm(CChan::Op) && pNick.NickEquals(m_pNetwork->GetCurNick())) { + if (!pNick.HasPerm(CChan::Op) && pNick.NickEquals(GetNetwork()->GetCurNick())) { Channel.Cycle(); m_recentlyCycled.AddItem(Channel.GetName()); } diff --git a/modules/autoop.cpp b/modules/autoop.cpp index 9b0cf20b..b840c2f0 100644 --- a/modules/autoop.cpp +++ b/modules/autoop.cpp @@ -218,7 +218,7 @@ public: } virtual void OnOp2(const CNick* pOpNick, const CNick& Nick, CChan& Channel, bool bNoChange) { - if (Nick.GetNick() == m_pNetwork->GetIRCNick().GetNick()) { + if (Nick.GetNick() == GetNetwork()->GetIRCNick().GetNick()) { const map& msNicks = Channel.GetNicks(); for (map::const_iterator it = msNicks.begin(); it != msNicks.end(); ++it) { @@ -420,7 +420,7 @@ public: // First verify that the person who challenged us matches a user's host if (pUser->HostMatches(Nick.GetHostMask())) { - const vector& Chans = m_pNetwork->GetChans(); + const vector& Chans = GetNetwork()->GetChans(); bMatchedHost = true; // Also verify that they are opped in at least one of the user's chans @@ -515,7 +515,7 @@ public: } void OpUser(const CNick& Nick, const CAutoOpUser& User) { - const vector& Chans = m_pNetwork->GetChans(); + const vector& Chans = GetNetwork()->GetChans(); for (size_t a = 0; a < Chans.size(); a++) { const CChan& Chan = *Chans[a]; diff --git a/modules/autoreply.cpp b/modules/autoreply.cpp index 1f104a25..227a04bb 100644 --- a/modules/autoreply.cpp +++ b/modules/autoreply.cpp @@ -49,7 +49,7 @@ public: } void Handle(const CString& sNick) { - CIRCSock *pIRCSock = m_pNetwork->GetIRCSock(); + CIRCSock *pIRCSock = GetNetwork()->GetIRCSock(); if (!pIRCSock) // WTF? return; @@ -58,7 +58,7 @@ public: if (m_Messaged.HasItem(sNick)) return; - if (m_pNetwork->IsUserAttached()) + if (GetNetwork()->IsUserAttached()) return; m_Messaged.AddItem(sNick); diff --git a/modules/awaynick.cpp b/modules/awaynick.cpp index 453afa21..20c25d0a 100644 --- a/modules/awaynick.cpp +++ b/modules/awaynick.cpp @@ -84,10 +84,10 @@ public: } void StartBackNickTimer() { - CIRCSock* pIRCSock = m_pNetwork->GetIRCSock(); + CIRCSock* pIRCSock = GetNetwork()->GetIRCSock(); if (pIRCSock) { - CString sConfNick = m_pNetwork->GetNick(); + CString sConfNick = GetNetwork()->GetNick(); if (pIRCSock->GetNick().Equals(m_sAwayNick.Left(pIRCSock->GetNick().length()))) { RemTimer("BackNickTimer"); @@ -98,7 +98,8 @@ public: virtual EModRet OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName) { - if (m_pNetwork && !m_pNetwork->IsUserAttached()) { + CIRCNetwork* pNetwork = GetNetwork(); + if (pNetwork && !pNetwork->IsUserAttached()) { m_sAwayNick = m_sFormat; // ExpandString doesn't know our nick yet, so do it by hand. @@ -106,7 +107,7 @@ public: // We don't limit this to NICKLEN, because we dont know // NICKLEN yet. - sNick = m_sAwayNick = m_pNetwork->ExpandString(m_sAwayNick); + sNick = m_sAwayNick = pNetwork->ExpandString(m_sAwayNick); } return CONTINUE; } @@ -121,7 +122,7 @@ public: } virtual void OnClientDisconnect() { - if (!m_pNetwork->IsUserAttached()) { + if (!GetNetwork()->IsUserAttached()) { StartAwayNickTimer(); } } @@ -139,7 +140,7 @@ public: SetNV("nick", m_sFormat); } - if (m_pNetwork) { + if (GetNetwork()) { CString sExpanded = GetAwayNick(); CString sMsg = "AwayNick is set to [" + m_sFormat + "]"; @@ -150,7 +151,7 @@ public: PutModule(sMsg); } } else if (sCommand.Equals("SHOW")) { - if (m_pNetwork) { + if (GetNetwork()) { CString sExpanded = GetAwayNick(); CString sMsg = "AwayNick is set to [" + m_sFormat + "]"; @@ -167,13 +168,13 @@ public: CString GetAwayNick() { unsigned int uLen = 9; - CIRCSock* pIRCSock = m_pNetwork->GetIRCSock(); + CIRCSock* pIRCSock = GetNetwork()->GetIRCSock(); if (pIRCSock) { uLen = pIRCSock->GetMaxNickLen(); } - m_sAwayNick = m_pNetwork->ExpandString(m_sFormat).Left(uLen); + m_sAwayNick = GetNetwork()->ExpandString(m_sFormat).Left(uLen); return m_sAwayNick; } diff --git a/modules/awaystore.cpp b/modules/awaystore.cpp index 272922d6..776abd3c 100644 --- a/modules/awaystore.cpp +++ b/modules/awaystore.cpp @@ -57,10 +57,10 @@ class CAway : public CModule time(&curtime); if (sCommand.Token(1) != "-quiet") { - sReason = CUtils::FormatTime(curtime, sCommand.Token(1, true), m_pUser->GetTimezone()); + sReason = CUtils::FormatTime(curtime, sCommand.Token(1, true), GetUser()->GetTimezone()); PutModNotice("You have been marked as away"); } else { - sReason = CUtils::FormatTime(curtime, sCommand.Token(2, true), m_pUser->GetTimezone()); + sReason = CUtils::FormatTime(curtime, sCommand.Token(2, true), GetUser()->GetTimezone()); } Away(false, sReason); @@ -340,7 +340,7 @@ public: CString GetPath() { - CString sBuffer = m_pUser->GetUserName(); + CString sBuffer = GetUser()->GetUserName(); CString sRet = GetSavePath(); sRet += "/.znc-away-" + CBlowfish::MD5(sBuffer, true); return(sRet); @@ -476,7 +476,7 @@ private: void AddMessage(time_t iTime, const CNick & Nick, const CString & sMessage) { - if (Nick.GetNick() == m_pNetwork->GetIRCNick().GetNick()) + if (Nick.GetNick() == GetNetwork()->GetIRCNick().GetNick()) return; // ignore messages from self AddMessage(CString(iTime) + " " + Nick.GetNickMask() + " " + sMessage); } @@ -500,7 +500,7 @@ private: void CAwayJob::RunJob() { - CAway *p = (CAway *)m_pModule; + CAway *p = (CAway *)GetModule(); p->SaveBufferToDisk(); if (!p->IsAway()) diff --git a/modules/blockuser.cpp b/modules/blockuser.cpp index 234b8998..7470606b 100644 --- a/modules/blockuser.cpp +++ b/modules/blockuser.cpp @@ -63,7 +63,7 @@ public: void OnModCommand(const CString& sCommand) { CString sCmd = sCommand.Token(0); - if (!m_pUser->IsAdmin()) { + if (!GetUser()->IsAdmin()) { PutModule("Access denied"); return; } @@ -84,7 +84,7 @@ public: } else if (sCmd.Equals("block")) { CString sUser = sCommand.Token(1, true); - if (m_pUser->GetUserName().Equals(sUser)) { + if (GetUser()->GetUserName().Equals(sUser)) { PutModule("You can't block yourself"); return; } diff --git a/modules/bouncedcc.cpp b/modules/bouncedcc.cpp index 564162e2..e1c6ed6c 100644 --- a/modules/bouncedcc.cpp +++ b/modules/bouncedcc.cpp @@ -151,7 +151,7 @@ public: virtual ~CBounceDCCMod() {} CString GetLocalDCCIP() { - return m_pUser->GetLocalDCCIP(); + return GetUser()->GetLocalDCCIP(); } bool UseClientIP() { @@ -168,7 +168,7 @@ public: CString sIP = GetLocalDCCIP(); if (!UseClientIP()) { - uLongIP = CUtils::GetLongIP(m_pClient->GetRemoteIP()); + uLongIP = CUtils::GetLongIP(GetClient()->GetRemoteIP()); } if (sType.Equals("CHAT")) { @@ -213,7 +213,8 @@ public: } virtual EModRet OnPrivCTCP(CNick& Nick, CString& sMessage) { - if (sMessage.Equals("DCC ", false, 4) && m_pNetwork->IsUserAttached()) { + CIRCNetwork* pNetwork = GetNetwork(); + if (sMessage.Equals("DCC ", false, 4) && pNetwork->IsUserAttached()) { // DCC CHAT chat 2453612361 44592 CString sType = sMessage.Token(1, false, " ", false, "\"", "\"", true); CString sFile = sMessage.Token(2, false, " ", false, "\"", "\"", false); @@ -226,14 +227,14 @@ public: unsigned short uBNCPort = CDCCBounce::DCCRequest(FromNick.GetNick(), uLongIP, uPort, "", true, this, CUtils::GetIP(uLongIP)); if (uBNCPort) { CString sIP = GetLocalDCCIP(); - PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + m_pNetwork->GetCurNick() + " :\001DCC CHAT chat " + CString(CUtils::GetLongIP(sIP)) + " " + CString(uBNCPort) + "\001"); + PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + pNetwork->GetCurNick() + " :\001DCC CHAT chat " + CString(CUtils::GetLongIP(sIP)) + " " + CString(uBNCPort) + "\001"); } } else if (sType.Equals("SEND")) { // DCC SEND readme.txt 403120438 5550 1104 unsigned short uBNCPort = CDCCBounce::DCCRequest(Nick.GetNick(), uLongIP, uPort, sFile, false, this, CUtils::GetIP(uLongIP)); if (uBNCPort) { CString sIP = GetLocalDCCIP(); - PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + m_pNetwork->GetCurNick() + " :\001DCC SEND " + sFile + " " + CString(CUtils::GetLongIP(sIP)) + " " + CString(uBNCPort) + " " + CString(uFileSize) + "\001"); + PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + pNetwork->GetCurNick() + " :\001DCC SEND " + sFile + " " + CString(CUtils::GetLongIP(sIP)) + " " + CString(uBNCPort) + " " + CString(uFileSize) + "\001"); } } else if (sType.Equals("RESUME")) { // Need to lookup the connection by port, filter the port, and forward to the user @@ -244,7 +245,7 @@ public: CDCCBounce* pSock = (CDCCBounce*) *it; if (pSock->GetLocalPort() == uResumePort) { - PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + m_pNetwork->GetCurNick() + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetUserPort()) + " " + sMessage.Token(4) + "\001"); + PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + pNetwork->GetCurNick() + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetUserPort()) + " " + sMessage.Token(4) + "\001"); } } } else if (sType.Equals("ACCEPT")) { @@ -254,7 +255,7 @@ public: CDCCBounce* pSock = (CDCCBounce*) *it; if (pSock->GetUserPort() == sMessage.Token(3).ToUShort()) { - PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + m_pNetwork->GetCurNick() + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetLocalPort()) + " " + sMessage.Token(4) + "\001"); + PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + pNetwork->GetCurNick() + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetLocalPort()) + " " + sMessage.Token(4) + "\001"); } } } diff --git a/modules/buffextras.cpp b/modules/buffextras.cpp index 7ab81661..5b9eee80 100644 --- a/modules/buffextras.cpp +++ b/modules/buffextras.cpp @@ -27,7 +27,7 @@ public: void AddBuffer(CChan& Channel, const CString& sMessage) { // If they have AutoClearChanBuffer enabled, only add messages if no client is connected - if (Channel.AutoClearChanBuffer() && m_pNetwork->IsUserOnline()) + if (Channel.AutoClearChanBuffer() && GetNetwork()->IsUserOnline()) return; Channel.AddBuffer(":" + GetModNick() + "!" + GetModName() + "@znc.in PRIVMSG " + _NAMEDFMT(Channel.GetName()) + " :{text}", sMessage); diff --git a/modules/cert.cpp b/modules/cert.cpp index 1d33a6f5..b2c8aead 100644 --- a/modules/cert.cpp +++ b/modules/cert.cpp @@ -36,7 +36,7 @@ public: PutModule("You have a certificate in: " + PemFile()); } else { PutModule("You do not have a certificate. Please use the web interface to add a certificate"); - if (m_pUser->IsAdmin()) { + if (GetUser()->IsAdmin()) { PutModule("Alternatively you can either place one at " + PemFile()); } } diff --git a/modules/certauth.cpp b/modules/certauth.cpp index e9f53beb..8b2b600e 100644 --- a/modules/certauth.cpp +++ b/modules/certauth.cpp @@ -137,7 +137,7 @@ public: } void HandleShowCommand(const CString& sLine) { - const CString sPubKey = GetKey(m_pClient); + const CString sPubKey = GetKey(GetClient()); if (sPubKey.empty()) { PutModule("You are not connected with any valid public key"); @@ -150,13 +150,13 @@ public: CString sPubKey = sLine.Token(1); if (sPubKey.empty()) { - sPubKey = GetKey(m_pClient); + sPubKey = GetKey(GetClient()); } if (sPubKey.empty()) { PutModule("You did not supply a public key or connect with one."); } else { - if (AddKey(m_pUser, sPubKey)) { + if (AddKey(GetUser(), sPubKey)) { PutModule("'" + sPubKey + "' added."); } else { PutModule("The key '" + sPubKey + "' is already added."); @@ -170,7 +170,7 @@ public: Table.AddColumn("Id"); Table.AddColumn("Key"); - MSCString::const_iterator it = m_PubKeys.find(m_pUser->GetUserName()); + MSCString::const_iterator it = m_PubKeys.find(GetUser()->GetUserName()); if (it == m_PubKeys.end()) { PutModule("No keys set for your user"); return; @@ -192,7 +192,7 @@ public: void HandleDelCommand(const CString& sLine) { unsigned int id = sLine.Token(1, true).ToUInt(); - MSCString::iterator it = m_PubKeys.find(m_pUser->GetUserName()); + MSCString::iterator it = m_PubKeys.find(GetUser()->GetUserName()); if (it == m_PubKeys.end()) { PutModule("No keys set for your user"); diff --git a/modules/chansaver.cpp b/modules/chansaver.cpp index e005b7ed..ffd03f24 100644 --- a/modules/chansaver.cpp +++ b/modules/chansaver.cpp @@ -92,14 +92,14 @@ public: } virtual void OnJoin(const CNick& Nick, CChan& Channel) { - if (Nick.GetNick() == m_pNetwork->GetIRCNick().GetNick() && !Channel.InConfig()) { + if (Nick.GetNick() == GetNetwork()->GetIRCNick().GetNick() && !Channel.InConfig()) { Channel.SetInConfig(true); CZNC::Get().WriteConfig(); } } virtual void OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage) { - if (Nick.GetNick() == m_pNetwork->GetIRCNick().GetNick() && Channel.InConfig()) { + if (Nick.GetNick() == GetNetwork()->GetIRCNick().GetNick() && Channel.InConfig()) { Channel.SetInConfig(false); CZNC::Get().WriteConfig(); } diff --git a/modules/clearbufferonmsg.cpp b/modules/clearbufferonmsg.cpp index 42d03d51..d3cdca84 100644 --- a/modules/clearbufferonmsg.cpp +++ b/modules/clearbufferonmsg.cpp @@ -25,8 +25,9 @@ public: MODCONSTRUCTOR(CClearBufferOnMsgMod) {} void ClearAllBuffers() { - if (m_pNetwork) { - const vector& vChans = m_pNetwork->GetChans(); + CIRCNetwork* pNetwork = GetNetwork(); + if (pNetwork) { + const vector& vChans = pNetwork->GetChans(); for (vector::const_iterator it = vChans.begin(); it != vChans.end(); ++it) { // Skip detached channels, they weren't read yet @@ -39,10 +40,10 @@ public: (*it)->SetAutoClearChanBuffer(false); } - vector VQueries = m_pNetwork->GetQueries(); + vector VQueries = pNetwork->GetQueries(); for (vector::const_iterator it = VQueries.begin(); it != VQueries.end(); ++it) { - m_pNetwork->DelQuery((*it)->GetName()); + pNetwork->DelQuery((*it)->GetName()); } } } diff --git a/modules/clientnotify.cpp b/modules/clientnotify.cpp index d34010a0..64fface8 100644 --- a/modules/clientnotify.cpp +++ b/modules/clientnotify.cpp @@ -35,10 +35,10 @@ protected: void SendNotification(const CString& sMessage) { if(m_sMethod == "message") { - m_pUser->PutStatus(sMessage, NULL, m_pClient); + GetUser()->PutStatus(sMessage, NULL, GetClient()); } else if(m_sMethod == "notice") { - m_pUser->PutStatusNotice(sMessage, NULL, m_pClient); + GetUser()->PutStatusNotice(sMessage, NULL, GetClient()); } } @@ -62,13 +62,14 @@ public: } void OnClientLogin() { - if(!m_bNewOnly || m_sClientsSeen.find(m_pClient->GetRemoteIP()) == m_sClientsSeen.end()) { + CString sRemoteIP = GetClient()->GetRemoteIP(); + if(!m_bNewOnly || m_sClientsSeen.find(sRemoteIP) == m_sClientsSeen.end()) { SendNotification("Another client authenticated as your user. " "Use the 'ListClients' command to see all " + - CString(m_pUser->GetAllClients().size()) + " clients."); + CString(GetUser()->GetAllClients().size()) + " clients."); // the set<> will automatically disregard duplicates: - m_sClientsSeen.insert(m_pClient->GetRemoteIP()); + m_sClientsSeen.insert(sRemoteIP); } } @@ -76,7 +77,7 @@ public: if(m_bOnDisconnect) { SendNotification("A client disconnected from your user. " "Use the 'ListClients' command to see the " + - CString(m_pUser->GetAllClients().size()) + " remaining client(s)."); + CString(GetUser()->GetAllClients().size()) + " remaining client(s)."); } } diff --git a/modules/controlpanel.cpp b/modules/controlpanel.cpp index 575bd459..d1b28b51 100644 --- a/modules/controlpanel.cpp +++ b/modules/controlpanel.cpp @@ -165,13 +165,13 @@ class CAdminMod : public CModule { CUser* FindUser(const CString& sUsername) { if (sUsername.Equals("$me")) - return m_pUser; + return GetUser(); CUser *pUser = CZNC::Get().FindUser(sUsername); if (!pUser) { PutModule("Error: User [" + sUsername + "] not found."); return NULL; } - if (pUser != m_pUser && !m_pUser->IsAdmin()) { + if (pUser != GetUser() && !GetUser()->IsAdmin()) { PutModule("Error: You need to have admin rights to modify other users!"); return NULL; } @@ -189,7 +189,7 @@ class CAdminMod : public CModule { } if (sUsername.empty()) { - pUser = m_pUser; + pUser = GetUser(); } else { pUser = FindUser(sUsername); } @@ -286,14 +286,14 @@ class CAdminMod : public CModule { PutModule("RealName = " + sValue); } else if (sVar == "bindhost") { - if(!pUser->DenySetBindHost() || m_pUser->IsAdmin()) { - if (sValue.Equals(m_pUser->GetBindHost())) { + if(!pUser->DenySetBindHost() || GetUser()->IsAdmin()) { + if (sValue.Equals(GetUser()->GetBindHost())) { PutModule("This bind host is already set!"); return; } const VCString& vsHosts = CZNC::Get().GetBindHosts(); - if (!m_pUser->IsAdmin() && !vsHosts.empty()) { + if (!GetUser()->IsAdmin() && !vsHosts.empty()) { VCString::const_iterator it; bool bFound = false; @@ -305,7 +305,7 @@ class CAdminMod : public CModule { } if (!bFound) { - PutModule("You may not use this bind host. See /msg " + m_pUser->GetStatusPrefix() + "status ListBindHosts for a list"); + PutModule("You may not use this bind host. See /msg " + GetUser()->GetStatusPrefix() + "status ListBindHosts for a list"); return; } } @@ -322,7 +322,7 @@ class CAdminMod : public CModule { PutModule("MultiClients = " + CString(b)); } else if (sVar == "denyloadmod") { - if(m_pUser->IsAdmin()) { + if(GetUser()->IsAdmin()) { bool b = sValue.ToBool(); pUser->SetDenyLoadMod(b); PutModule("DenyLoadMod = " + CString(b)); @@ -331,7 +331,7 @@ class CAdminMod : public CModule { } } else if (sVar == "denysetbindhost") { - if(m_pUser->IsAdmin()) { + if(GetUser()->IsAdmin()) { bool b = sValue.ToBool(); pUser->SetDenySetBindHost(b); PutModule("DenySetBindHost = " + CString(b)); @@ -350,7 +350,7 @@ class CAdminMod : public CModule { else if (sVar == "buffercount") { unsigned int i = sValue.ToUInt(); // Admins don't have to honour the buffer limit - if (pUser->SetBufferCount(i, m_pUser->IsAdmin())) { + if (pUser->SetBufferCount(i, GetUser()->IsAdmin())) { PutModule("BufferCount = " + sValue); } else { PutModule("Setting failed, limit is " + @@ -384,7 +384,7 @@ class CAdminMod : public CModule { PutModule("MaxJoins = " + CString(pUser->MaxJoins())); } else if (sVar == "maxnetworks") { - if(m_pUser->IsAdmin()) { + if(GetUser()->IsAdmin()) { unsigned int i = sValue.ToUInt(); pUser->SetMaxNetworks(i); PutModule("MaxNetworks = " + sValue); @@ -407,7 +407,7 @@ class CAdminMod : public CModule { PutModule("Timezone = " + pUser->GetTimezone()); } else if (sVar == "admin") { - if(m_pUser->IsAdmin() && pUser != m_pUser) { + if(GetUser()->IsAdmin() && pUser != GetUser()) { bool b = sValue.ToBool(); pUser->SetAdmin(b); PutModule("Admin = " + CString(pUser->IsAdmin())); @@ -430,7 +430,7 @@ class CAdminMod : public CModule { PutModule("TimestampFormat = " + sValue); } else if (sVar == "dccbindhost") { - if(!pUser->DenySetBindHost() || m_pUser->IsAdmin()) { + if(!pUser->DenySetBindHost() || GetUser()->IsAdmin()) { pUser->SetDCCBindHost(sValue); PutModule("DCCBindHost = " + sValue); } else { @@ -464,8 +464,8 @@ class CAdminMod : public CModule { CIRCNetwork *pNetwork = NULL; if (sUsername.empty()) { - pUser = m_pUser; - pNetwork = m_pNetwork; + pUser = GetUser(); + pNetwork = CModule::GetNetwork(); } else { pUser = FindUser(sUsername); if (!pUser) { @@ -519,8 +519,8 @@ class CAdminMod : public CModule { CIRCNetwork *pNetwork = NULL; if (sUsername.empty()) { - pUser = m_pUser; - pNetwork = m_pNetwork; + pUser = GetUser(); + pNetwork = CModule::GetNetwork(); } else { pUser = FindUser(sUsername); if (!pUser) { @@ -552,14 +552,14 @@ class CAdminMod : public CModule { pNetwork->SetRealName(sValue); PutModule("RealName = " + pNetwork->GetRealName()); } else if (sVar.Equals("bindhost")) { - if(!pUser->DenySetBindHost() || m_pUser->IsAdmin()) { + if(!pUser->DenySetBindHost() || GetUser()->IsAdmin()) { if (sValue.Equals(pNetwork->GetBindHost())) { PutModule("This bind host is already set!"); return; } const VCString& vsHosts = CZNC::Get().GetBindHosts(); - if (!m_pUser->IsAdmin() && !vsHosts.empty()) { + if (!GetUser()->IsAdmin() && !vsHosts.empty()) { VCString::const_iterator it; bool bFound = false; @@ -571,7 +571,7 @@ class CAdminMod : public CModule { } if (!bFound) { - PutModule("You may not use this bind host. See /msg " + m_pUser->GetStatusPrefix() + "status ListBindHosts for a list"); + PutModule("You may not use this bind host. See /msg " + GetUser()->GetStatusPrefix() + "status ListBindHosts for a list"); return; } } @@ -761,7 +761,7 @@ class CAdminMod : public CModule { } else if (sVar == "buffer") { unsigned int i = sValue.ToUInt(); // Admins don't have to honour the buffer limit - if (pChan->SetBufferCount(i, m_pUser->IsAdmin())) { + if (pChan->SetBufferCount(i, GetUser()->IsAdmin())) { PutModule(pChan->GetName() + ": Buffer = " + sValue); } else { PutModule("Setting failed, limit is " + @@ -800,7 +800,7 @@ class CAdminMod : public CModule { } void ListUsers(const CString&) { - if (!m_pUser->IsAdmin()) + if (!GetUser()->IsAdmin()) return; const map& msUsers = CZNC::Get().GetUserMap(); @@ -831,7 +831,7 @@ class CAdminMod : public CModule { } void AddUser(const CString& sLine) { - if (!m_pUser->IsAdmin()) { + if (!GetUser()->IsAdmin()) { PutModule("Error: You need to have admin rights to add new users!"); return; } @@ -865,7 +865,7 @@ class CAdminMod : public CModule { } void DelUser(const CString& sLine) { - if (!m_pUser->IsAdmin()) { + if (!GetUser()->IsAdmin()) { PutModule("Error: You need to have admin rights to delete users!"); return; } @@ -883,7 +883,7 @@ class CAdminMod : public CModule { return; } - if (pUser == m_pUser) { + if (pUser == GetUser()) { PutModule("Error: You can't delete yourself!"); return; } @@ -899,7 +899,7 @@ class CAdminMod : public CModule { } void CloneUser(const CString& sLine) { - if (!m_pUser->IsAdmin()) { + if (!GetUser()->IsAdmin()) { PutModule("Error: You need to have admin rights to add new users!"); return; } @@ -941,7 +941,7 @@ class CAdminMod : public CModule { void AddNetwork(const CString& sLine) { CString sUser = sLine.Token(1); CString sNetwork = sLine.Token(2); - CUser *pUser = m_pUser; + CUser *pUser = GetUser(); if (sNetwork.empty()) { sNetwork = sUser; @@ -958,7 +958,7 @@ class CAdminMod : public CModule { return; } - if (!m_pUser->IsAdmin() && !pUser->HasSpaceForNewNetwork()) { + if (!GetUser()->IsAdmin() && !pUser->HasSpaceForNewNetwork()) { PutStatus("Network number limit reached. Ask an admin to increase the limit for you, or delete unneeded networks using /znc DelNetwork "); return; } @@ -979,7 +979,7 @@ class CAdminMod : public CModule { void DelNetwork(const CString& sLine) { CString sUser = sLine.Token(1); CString sNetwork = sLine.Token(2); - CUser *pUser = m_pUser; + CUser *pUser = GetUser(); if (sNetwork.empty()) { sNetwork = sUser; @@ -1002,8 +1002,8 @@ class CAdminMod : public CModule { return; } - if (pNetwork == m_pNetwork) { - PutModule("The currently active network can be deleted via " + m_pUser->GetStatusPrefix() + "status"); + if (pNetwork == CModule::GetNetwork()) { + PutModule("The currently active network can be deleted via " + GetUser()->GetStatusPrefix() + "status"); return; } @@ -1016,7 +1016,7 @@ class CAdminMod : public CModule { void ListNetworks(const CString& sLine) { CString sUser = sLine.Token(1); - CUser *pUser = m_pUser; + CUser *pUser = GetUser(); if (!sUser.empty()) { pUser = FindUser(sUser); @@ -1145,7 +1145,7 @@ class CAdminMod : public CModule { CString sUserName = sLine.Token(1, true); if (sUserName.empty()) { - sUserName = m_pUser->GetUserName(); + sUserName = GetUser()->GetUserName(); } CUser* pUser = FindUser(sUserName); if (!pUser) @@ -1177,7 +1177,7 @@ class CAdminMod : public CModule { if (sCTCPRequest.empty()) { sCTCPRequest = sUserName; sCTCPReply = sLine.Token(2, true); - sUserName = m_pUser->GetUserName(); + sUserName = GetUser()->GetUserName(); } if (sCTCPRequest.empty()) { PutModule("Usage: AddCTCP [user] [request] [reply]"); @@ -1202,7 +1202,7 @@ class CAdminMod : public CModule { if (sCTCPRequest.empty()) { sCTCPRequest = sUserName; - sUserName = m_pUser->GetUserName(); + sUserName = GetUser()->GetUserName(); } CUser* pUser = FindUser(sUserName); if (!pUser) @@ -1220,7 +1220,7 @@ class CAdminMod : public CModule { } void LoadModuleFor(CModules& Modules, const CString& sModName, const CString& sArgs, CModInfo::EModuleType eType, CUser* pUser, CIRCNetwork* pNetwork) { - if (pUser->DenyLoadMod() && !m_pUser->IsAdmin()) { + if (pUser->DenyLoadMod() && !GetUser()->IsAdmin()) { PutModule("Loading modules has been disabled."); return; } @@ -1286,7 +1286,7 @@ class CAdminMod : public CModule { } void UnLoadModuleFor(CModules& Modules, const CString& sModName, CUser* pUser) { - if (pUser->DenyLoadMod() && !m_pUser->IsAdmin()) { + if (pUser->DenyLoadMod() && !GetUser()->IsAdmin()) { PutModule("Loading modules has been disabled."); return; } diff --git a/modules/crypt.cpp b/modules/crypt.cpp index fcc664bb..0daccf15 100644 --- a/modules/crypt.cpp +++ b/modules/crypt.cpp @@ -58,11 +58,12 @@ public: MCString::iterator it = FindNV(sTarget.AsLower()); if (it != EndNV()) { - CChan* pChan = m_pNetwork->FindChan(sTarget); + CChan* pChan = GetNetwork()->FindChan(sTarget); + CString sNickMask = GetNetwork()->GetIRCNick().GetNickMask(); if (pChan) { if (!pChan->AutoClearChanBuffer()) - pChan->AddBuffer(":" + NickPrefix() + _NAMEDFMT(m_pNetwork->GetIRCNick().GetNickMask()) + " PRIVMSG " + _NAMEDFMT(sTarget) + " :{text}", sMessage); - m_pUser->PutUser(":" + NickPrefix() + m_pNetwork->GetIRCNick().GetNickMask() + " PRIVMSG " + sTarget + " :" + sMessage, NULL, m_pClient); + pChan->AddBuffer(":" + NickPrefix() + _NAMEDFMT(sNickMask) + " PRIVMSG " + _NAMEDFMT(sTarget) + " :{text}", sMessage); + GetUser()->PutUser(":" + NickPrefix() + sNickMask + " PRIVMSG " + sTarget + " :" + sMessage, NULL, GetClient()); } CString sMsg = MakeIvec() + sMessage; diff --git a/modules/cyrusauth.cpp b/modules/cyrusauth.cpp index 515c6012..8e4d8069 100644 --- a/modules/cyrusauth.cpp +++ b/modules/cyrusauth.cpp @@ -44,7 +44,7 @@ public: } void OnModCommand(const CString& sCommand) { - if (m_pUser->IsAdmin()) { + if (GetUser()->IsAdmin()) { HandleCommand(sCommand); } else { PutModule("Access denied"); diff --git a/modules/dcc.cpp b/modules/dcc.cpp index b571afd4..166d6cb7 100644 --- a/modules/dcc.cpp +++ b/modules/dcc.cpp @@ -87,7 +87,7 @@ public: #ifndef MOD_DCC_ALLOW_EVERYONE virtual bool OnLoad(const CString& sArgs, CString& sMessage) { - if (!m_pUser->IsAdmin()) { + if (!GetUser()->IsAdmin()) { sMessage = "You must be admin to use the DCC module"; return false; } @@ -107,13 +107,14 @@ public: return false; } - unsigned short uPort = CZNC::Get().GetManager().ListenRand("DCC::LISTEN::" + sRemoteNick, m_pUser->GetLocalDCCIP(), false, SOMAXCONN, pSock, 120); + CString sLocalDCCIP = GetUser()->GetLocalDCCIP(); + unsigned short uPort = CZNC::Get().GetManager().ListenRand("DCC::LISTEN::" + sRemoteNick, sLocalDCCIP, false, SOMAXCONN, pSock, 120); - if (m_pUser->GetNick().Equals(sRemoteNick)) { - PutUser(":*dcc!znc@znc.in PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString(CUtils::GetLongIP(m_pUser->GetLocalDCCIP())) + " " + if (GetUser()->GetNick().Equals(sRemoteNick)) { + PutUser(":*dcc!znc@znc.in PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString(CUtils::GetLongIP(sLocalDCCIP)) + " " + CString(uPort) + " " + CString(pFile->GetSize()) + "\001"); } else { - PutIRC("PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString(CUtils::GetLongIP(m_pUser->GetLocalDCCIP())) + " " + PutIRC("PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString(CUtils::GetLongIP(sLocalDCCIP)) + " " + CString(uPort) + " " + CString(pFile->GetSize()) + "\001"); } @@ -134,7 +135,7 @@ public: return false; } - CZNC::Get().GetManager().Connect(sRemoteIP, uRemotePort, "DCC::GET::" + sRemoteNick, 60, false, m_pUser->GetLocalDCCIP(), pSock); + CZNC::Get().GetManager().Connect(sRemoteIP, uRemotePort, "DCC::GET::" + sRemoteNick, 60, false, GetUser()->GetLocalDCCIP(), pSock); PutModule("DCC <- [" + sRemoteNick + "][" + sFileName + "] - Attempting to connect to [" + sRemoteIP + "]"); return true; @@ -178,7 +179,7 @@ public: return; } - SendFile(m_pUser->GetNick(), sFile); + SendFile(GetUser()->GetNick(), sFile); } void ListTransfersCommand(const CString& sLine) { @@ -231,9 +232,9 @@ public: if (pSock->GetLocalPort() == uResumePort) { if (pSock->Seek(uResumeSize)) { PutModule("DCC -> [" + pSock->GetRemoteNick() + "][" + pSock->GetFileName() + "] - Attempting to resume from file position [" + CString(uResumeSize) + "]"); - PutUser(":*dcc!znc@znc.in PRIVMSG " + m_pUser->GetNick() + " :\001DCC ACCEPT " + sFile + " " + CString(uResumePort) + " " + CString(uResumeSize) + "\001"); + PutUser(":*dcc!znc@znc.in PRIVMSG " + GetUser()->GetNick() + " :\001DCC ACCEPT " + sFile + " " + CString(uResumePort) + " " + CString(uResumeSize) + "\001"); } else { - PutModule("DCC -> [" + m_pUser->GetNick() + "][" + sFile + "] Unable to find send to initiate resume."); + PutModule("DCC -> [" + GetUser()->GetNick() + "][" + sFile + "] Unable to find send to initiate resume."); } } @@ -246,7 +247,7 @@ public: unsigned long uLongIP = sMessage.Token(3).ToULong(); unsigned short uPort = sMessage.Token(4).ToUShort(); unsigned long uFileSize = sMessage.Token(5).ToULong(); - GetFile(m_pClient->GetNick(), CUtils::GetIP(uLongIP), uPort, sLocalFile, uFileSize); + GetFile(GetClient()->GetNick(), CUtils::GetIP(uLongIP), uPort, sLocalFile, uFileSize); } } }; diff --git a/modules/disconkick.cpp b/modules/disconkick.cpp index 8ec94da9..fca267bd 100644 --- a/modules/disconkick.cpp +++ b/modules/disconkick.cpp @@ -25,12 +25,12 @@ public: void OnIRCDisconnected() { - const vector& vChans = m_pNetwork->GetChans(); + const vector& vChans = GetNetwork()->GetChans(); for(vector::const_iterator it = vChans.begin(); it != vChans.end(); ++it) { if((*it)->IsOn()) { - PutUser(":ZNC!znc@znc.in KICK " + (*it)->GetName() + " " + m_pNetwork->GetIRCNick().GetNick() + PutUser(":ZNC!znc@znc.in KICK " + (*it)->GetName() + " " + GetNetwork()->GetIRCNick().GetNick() + " :You have been disconnected from the IRC server"); } } diff --git a/modules/flooddetach.cpp b/modules/flooddetach.cpp index 2c17d519..7522c615 100644 --- a/modules/flooddetach.cpp +++ b/modules/flooddetach.cpp @@ -77,7 +77,7 @@ public: if (it->second.first + (time_t)m_iThresholdSecs >= now) continue; - CChan *pChan = m_pNetwork->FindChan(it->first); + CChan *pChan = GetNetwork()->FindChan(it->first); if (it->second.second >= m_iThresholdMsgs && pChan && pChan->IsDetached()) { // The channel is detached and it is over the diff --git a/modules/identfile.cpp b/modules/identfile.cpp index c08e4022..4d2342c7 100644 --- a/modules/identfile.cpp +++ b/modules/identfile.cpp @@ -74,7 +74,7 @@ public: } void OnModCommand(const CString& sCommand) { - if (m_pUser->IsAdmin()) { + if (GetUser()->IsAdmin()) { HandleCommand(sCommand); } else { PutModule("Access denied"); @@ -121,10 +121,10 @@ public: // If the format doesn't contain anything expandable, we'll // assume this is an "old"-style format string. if (sData == GetNV("Format")) { - sData.Replace("%", m_pUser->GetIdent()); + sData.Replace("%", GetUser()->GetIdent()); } - DEBUG("Writing [" + sData + "] to ident spoof file [" + m_pISpoofLockFile->GetLongName() + "] for user/network [" + m_pUser->GetUserName() + "/" + m_pNetwork->GetName() + "]"); + DEBUG("Writing [" + sData + "] to ident spoof file [" + m_pISpoofLockFile->GetLongName() + "] for user/network [" + GetUser()->GetUserName() + "/" + GetNetwork()->GetName() + "]"); m_pISpoofLockFile->Write(sData + "\n"); @@ -180,7 +180,7 @@ public: } virtual void OnIRCConnected() { - if (m_pIRCSock == m_pNetwork->GetIRCSock()) { + if (m_pIRCSock == GetNetwork()->GetIRCSock()) { ReleaseISpoof(); } } @@ -192,7 +192,7 @@ public: } virtual void OnIRCDisconnected() { - if (m_pIRCSock == m_pNetwork->GetIRCSock()) { + if (m_pIRCSock == GetNetwork()->GetIRCSock()) { ReleaseISpoof(); } } diff --git a/modules/keepnick.cpp b/modules/keepnick.cpp index 9c8cae68..9d178da7 100644 --- a/modules/keepnick.cpp +++ b/modules/keepnick.cpp @@ -42,7 +42,7 @@ public: m_pTimer = NULL; // Check if we need to start the timer - if (m_pNetwork->IsIRCConnected()) + if (GetNetwork()->IsIRCConnected()) OnIRCConnected(); return true; @@ -53,7 +53,7 @@ public: // No timer means we are turned off return; - CIRCSock* pIRCSock = m_pNetwork->GetIRCSock(); + CIRCSock* pIRCSock = GetNetwork()->GetIRCSock(); if (!pIRCSock) return; @@ -66,8 +66,8 @@ public: } CString GetNick() { - CString sConfNick = m_pNetwork->GetNick(); - CIRCSock* pIRCSock = m_pNetwork->GetIRCSock(); + CString sConfNick = GetNetwork()->GetNick(); + CIRCSock* pIRCSock = GetNetwork()->GetIRCSock(); if (pIRCSock) sConfNick = sConfNick.Left(pIRCSock->GetMaxNickLen()); @@ -76,7 +76,7 @@ public: } void OnNick(const CNick& Nick, const CString& sNewNick, const vector& vChans) { - if (sNewNick == m_pNetwork->GetIRCSock()->GetNick()) { + if (sNewNick == GetNetwork()->GetIRCSock()->GetNick()) { // We are changing our own nick if (Nick.NickEquals(GetNick())) { // We are changing our nick away from the conf setting. @@ -110,7 +110,7 @@ public: } void OnIRCConnected() { - if (!m_pNetwork->GetIRCSock()->GetNick().Equals(GetNick())) { + if (!GetNetwork()->GetIRCSock()->GetNick().Equals(GetNick())) { // We don't have the nick we want, try to get it Enable(); } @@ -135,7 +135,7 @@ public: virtual EModRet OnUserRaw(CString& sLine) { // We dont care if we are not connected to IRC - if (!m_pNetwork->IsIRCConnected()) + if (!GetNetwork()->IsIRCConnected()) return CONTINUE; // We are trying to get the config nick and this is a /nick? @@ -154,7 +154,7 @@ public: // Indeed trying to change to this nick, generate a 433 for it. // This way we can *always* block incoming 433s from the server. - PutUser(":" + m_pNetwork->GetIRCServer() + " 433 " + m_pNetwork->GetIRCNick().GetNick() + PutUser(":" + GetNetwork()->GetIRCServer() + " 433 " + GetNetwork()->GetIRCNick().GetNick() + " " + sNick + " :ZNC is already trying to get this nickname"); return CONTINUE; } diff --git a/modules/kickrejoin.cpp b/modules/kickrejoin.cpp index 004d82c2..d9e42cc9 100644 --- a/modules/kickrejoin.cpp +++ b/modules/kickrejoin.cpp @@ -35,7 +35,7 @@ public: protected: virtual void RunJob() { - CIRCNetwork* pNetwork = m_pModule->GetNetwork(); + CIRCNetwork* pNetwork = GetModule()->GetNetwork(); CChan* pChan = pNetwork->FindChan(GetName().Token(1, true)); if (pChan) { @@ -105,7 +105,7 @@ public: } virtual void OnKick(const CNick& OpNick, const CString& sKickedNick, CChan& pChan, const CString& sMessage) { - if (m_pNetwork->GetCurNick().Equals(sKickedNick)) { + if (GetNetwork()->GetCurNick().Equals(sKickedNick)) { if (!delay) { PutIRC("JOIN " + pChan.GetName() + " " + pChan.GetKey()); pChan.Enable(); diff --git a/modules/listsockets.cpp b/modules/listsockets.cpp index 93bb2177..6b883eaa 100644 --- a/modules/listsockets.cpp +++ b/modules/listsockets.cpp @@ -69,7 +69,7 @@ public: virtual bool OnLoad(const CString& sArgs, CString& sMessage) { #ifndef MOD_LISTSOCKETS_ALLOW_EVERYONE - if (!m_pUser->IsAdmin()) { + if (!GetUser()->IsAdmin()) { sMessage = "You must be admin to use this module"; return false; } @@ -163,7 +163,7 @@ public: CString GetCreatedTime(Csock* pSocket) { unsigned long long iStartTime = pSocket->GetStartTime(); time_t iTime = iStartTime / 1000; - return CUtils::FormatTime(iTime, "%Y-%m-%d %H:%M:%S", m_pUser->GetTimezone()); + return CUtils::FormatTime(iTime, "%Y-%m-%d %H:%M:%S", GetUser()->GetTimezone()); } CString GetLocalHost(Csock* pSocket, bool bShowHosts) { diff --git a/modules/log.cpp b/modules/log.cpp index af4f2a59..24155944 100644 --- a/modules/log.cpp +++ b/modules/log.cpp @@ -75,7 +75,7 @@ void CLogMod::PutLog(const CString& sLine, const CString& sWindow /*= "Status"*/ time(&curtime); // Generate file name - sPath = CUtils::FormatTime(curtime, m_sLogPath, m_pUser->GetTimezone()); + sPath = CUtils::FormatTime(curtime, m_sLogPath, GetUser()->GetTimezone()); if (sPath.empty()) { DEBUG("Could not format log path [" << sPath << "]"); @@ -84,8 +84,8 @@ void CLogMod::PutLog(const CString& sLine, const CString& sWindow /*= "Status"*/ // TODO: Properly handle IRC case mapping // $WINDOW has to be handled last, since it can contain % - sPath.Replace("$USER", CString((m_pUser ? m_pUser->GetUserName() : "UNKNOWN")).AsLower()); - sPath.Replace("$NETWORK", CString((m_pNetwork ? m_pNetwork->GetName() : "znc")).AsLower()); + sPath.Replace("$USER", CString((GetUser() ? GetUser()->GetUserName() : "UNKNOWN")).AsLower()); + sPath.Replace("$NETWORK", CString((GetNetwork() ? GetNetwork()->GetName() : "znc")).AsLower()); sPath.Replace("$WINDOW", CString(sWindow.Replace_n("/", "-").Replace_n("\\", "-")).AsLower()); // Check if it's allowed to write in this specific path @@ -103,7 +103,7 @@ void CLogMod::PutLog(const CString& sLine, const CString& sWindow /*= "Status"*/ if (!CFile::Exists(sLogDir)) CDir::MakeDir(sLogDir, ModDirInfo.st_mode); if (LogFile.Open(O_WRONLY | O_APPEND | O_CREAT)) { - LogFile.Write(CUtils::FormatTime(curtime, "[%H:%M:%S] ", m_pUser->GetTimezone()) + (m_bSanitize ? sLine.StripControls_n() : sLine) + "\n"); + LogFile.Write(CUtils::FormatTime(curtime, "[%H:%M:%S] ", GetUser()->GetTimezone()) + (m_bSanitize ? sLine.StripControls_n() : sLine) + "\n"); } else DEBUG("Could not open log file [" << sPath << "]: " << strerror(errno)); } @@ -120,7 +120,7 @@ void CLogMod::PutLog(const CString& sLine, const CNick& Nick) CString CLogMod::GetServer() { - CServer* pServer = m_pNetwork->GetCurrentServer(); + CServer* pServer = GetNetwork()->GetCurrentServer(); CString sSSL; if (!pServer) @@ -238,8 +238,9 @@ CModule::EModRet CLogMod::OnTopic(CNick& Nick, CChan& Channel, CString& sTopic) /* notices */ CModule::EModRet CLogMod::OnUserNotice(CString& sTarget, CString& sMessage) { - if (m_pNetwork) { - PutLog("-" + m_pNetwork->GetCurNick() + "- " + sMessage, sTarget); + CIRCNetwork* pNetwork = GetNetwork(); + if (pNetwork) { + PutLog("-" + pNetwork->GetCurNick() + "- " + sMessage, sTarget); } return CONTINUE; @@ -260,8 +261,9 @@ CModule::EModRet CLogMod::OnChanNotice(CNick& Nick, CChan& Channel, CString& sMe /* actions */ CModule::EModRet CLogMod::OnUserAction(CString& sTarget, CString& sMessage) { - if (m_pNetwork) { - PutLog("* " + m_pNetwork->GetCurNick() + " " + sMessage, sTarget); + CIRCNetwork* pNetwork = GetNetwork(); + if (pNetwork) { + PutLog("* " + pNetwork->GetCurNick() + " " + sMessage, sTarget); } return CONTINUE; @@ -282,8 +284,9 @@ CModule::EModRet CLogMod::OnChanAction(CNick& Nick, CChan& Channel, CString& sMe /* msgs */ CModule::EModRet CLogMod::OnUserMsg(CString& sTarget, CString& sMessage) { - if (m_pNetwork) { - PutLog("<" + m_pNetwork->GetCurNick() + "> " + sMessage, sTarget); + CIRCNetwork* pNetwork = GetNetwork(); + if (pNetwork) { + PutLog("<" + pNetwork->GetCurNick() + "> " + sMessage, sTarget); } return CONTINUE; diff --git a/modules/modtcl.cpp b/modules/modtcl.cpp index 6bf5f408..9938add8 100644 --- a/modules/modtcl.cpp +++ b/modules/modtcl.cpp @@ -72,7 +72,7 @@ public: virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) { #ifndef MOD_MODTCL_ALLOW_EVERYONE - if (!m_pUser->IsAdmin()) { + if (!GetUser()->IsAdmin()) { sErrorMsg = "You must be admin to use the modtcl module"; return false; } @@ -262,25 +262,25 @@ private: static int tcl_GetCurNick STDVAR { CModTcl *mod = static_cast(cd); - Tcl_SetResult(irp, (char *)mod->m_pNetwork->GetCurNick().c_str(), TCL_VOLATILE); + Tcl_SetResult(irp, (char *)mod->GetNetwork()->GetCurNick().c_str(), TCL_VOLATILE); return TCL_OK; } static int tcl_GetUsername STDVAR { CModTcl *mod = static_cast(cd); - Tcl_SetResult(irp, (char *)mod->m_pUser->GetUserName().c_str(), TCL_VOLATILE); + Tcl_SetResult(irp, (char *)mod->GetUser()->GetUserName().c_str(), TCL_VOLATILE); return TCL_OK; } static int tcl_GetRealName STDVAR { CModTcl *mod = static_cast(cd); - Tcl_SetResult(irp, (char *)mod->m_pUser->GetRealName().c_str(), TCL_VOLATILE); + Tcl_SetResult(irp, (char *)mod->GetUser()->GetRealName().c_str(), TCL_VOLATILE); return TCL_OK; } static int tcl_GetBindHost STDVAR { CModTcl *mod = static_cast(cd); - Tcl_SetResult(irp, (char *)mod->m_pUser->GetBindHost().c_str(), TCL_VOLATILE); + Tcl_SetResult(irp, (char *)mod->GetUser()->GetBindHost().c_str(), TCL_VOLATILE); return TCL_OK; } @@ -291,7 +291,7 @@ private: BADARGS(1, 1, ""); - const vector& Channels = mod->m_pNetwork->GetChans(); + const vector& Channels = mod->GetNetwork()->GetChans(); for (unsigned int c = 0; c < Channels.size(); c++) { CChan* pChan = Channels[c]; l[0] = pChan->GetName().c_str(); @@ -311,7 +311,7 @@ private: BADARGS(2, 999, " channel"); CString sChannel = argvit(argv, argc, 1, " "); - CChan *pChannel = mod->m_pNetwork->FindChan(sChannel); + CChan *pChannel = mod->GetNetwork()->FindChan(sChannel); if (!pChannel) { CString sMsg = "invalid channel: " + sChannel; @@ -340,7 +340,7 @@ private: BADARGS(2, 999, " channel"); CString sChannel = argvit(argv, argc, 1, " "); - CChan *pChannel = mod->m_pNetwork->FindChan(sChannel); + CChan *pChannel = mod->GetNetwork()->FindChan(sChannel); CString sMsg; if (!pChannel) { @@ -356,7 +356,7 @@ private: static int tcl_GetServer STDVAR { CModTcl *mod = static_cast(cd); - CServer* pServer = mod->m_pNetwork->GetCurrentServer(); + CServer* pServer = mod->GetNetwork()->GetCurrentServer(); CString sMsg; if (pServer) sMsg = pServer->GetName() + ":" + CString(pServer->GetPort()); @@ -366,7 +366,7 @@ private: static int tcl_GetServerOnline STDVAR { CModTcl *mod = static_cast(cd); - CIRCSock* pIRCSock = mod->m_pNetwork->GetIRCSock(); + CIRCSock* pIRCSock = mod->GetNetwork()->GetIRCSock(); CString sMsg = "0"; if (pIRCSock) sMsg = CString(pIRCSock->GetStartTime()); @@ -382,7 +382,7 @@ private: BADARGS(1, 1, ""); CModules& GModules = CZNC::Get().GetModules(); - CModules& Modules = mod->m_pUser->GetModules(); + CModules& Modules = mod->GetUser()->GetModules(); for (unsigned int b = 0; b < GModules.size(); b++) { l[0] = GModules[b]->GetModName().c_str(); @@ -406,7 +406,7 @@ private: static int tcl_GetClientCount STDVAR { CModTcl *mod = static_cast(cd); - Tcl_SetResult(irp, (char *)CString(mod->m_pNetwork->GetClients().size()).c_str(), TCL_VOLATILE); + Tcl_SetResult(irp, (char *)CString(mod->GetNetwork()->GetClients().size()).c_str(), TCL_VOLATILE); return TCL_OK; } @@ -416,7 +416,7 @@ private: BADARGS(2, 999, " string"); sMsg = argvit(argv, argc, 1, " "); - mod->m_pNetwork->PutIRC(sMsg); + mod->GetNetwork()->PutIRC(sMsg); return TCL_OK; } @@ -451,7 +451,7 @@ private: BADARGS(2, 999, " string"); sMsg = argvit(argv, argc, 1, " "); - mod->m_pUser->PutStatusNotice(sMsg); + mod->GetUser()->PutStatusNotice(sMsg); return TCL_OK; } @@ -461,7 +461,7 @@ private: BADARGS(2, 999, " string"); sMsg = argvit(argv, argc, 1, " "); - mod->m_pUser->PutUser(sMsg); + mod->GetUser()->PutUser(sMsg); return TCL_OK; } @@ -471,7 +471,7 @@ private: BADARGS(1, 2, " ?reason?"); - if (! mod->m_pUser->IsAdmin()) { + if (! mod->GetUser()->IsAdmin()) { sMsg = "You need to be administrator to shutdown the bnc."; Tcl_SetResult(irp, (char*)sMsg.c_str(), TCL_VOLATILE); return TCL_ERROR; @@ -489,13 +489,13 @@ private: }; void CModTclTimer::RunJob() { - CModTcl *p = (CModTcl *)m_pModule; + CModTcl *p = (CModTcl *)GetModule(); if (p) p->TclUpdate(); } void CModTclStartTimer::RunJob() { - CModTcl *p = (CModTcl *)m_pModule; + CModTcl *p = (CModTcl *)GetModule(); if (p) p->Start(); } diff --git a/modules/modules_online.cpp b/modules/modules_online.cpp index eecb53cf..0da3da41 100644 --- a/modules/modules_online.cpp +++ b/modules/modules_online.cpp @@ -24,14 +24,14 @@ public: virtual ~CFOModule() {} bool IsOnlineModNick(const CString& sNick) { - const CString& sPrefix = m_pUser->GetStatusPrefix(); + const CString& sPrefix = GetUser()->GetStatusPrefix(); if (!sNick.Equals(sPrefix, false, sPrefix.length())) return false; CString sModNick = sNick.substr(sPrefix.length()); if (sModNick.Equals("status") || - m_pNetwork->GetModules().FindModule(sModNick) || - m_pUser->GetModules().FindModule(sModNick) || + GetNetwork()->GetModules().FindModule(sModNick) || + GetUser()->GetModules().FindModule(sModNick) || CZNC::Get().GetModules().FindModule(sModNick)) return true; return false; @@ -55,10 +55,10 @@ public: // Remove the leading space sBNCNicks.LeftChomp(); - if (!m_pNetwork->GetIRCSock()) { + if (!GetNetwork()->GetIRCSock()) { // if we are not connected to any IRC server, send // an empty or module-nick filled response. - PutUser(":irc.znc.in 303 " + m_pClient->GetNick() + " :" + sBNCNicks); + PutUser(":irc.znc.in 303 " + GetClient()->GetNick() + " :" + sBNCNicks); } else { // We let the server handle this request and then act on // the 303 response from the IRC server. @@ -71,9 +71,10 @@ public: CString sNick = sLine.Token(1); if (IsOnlineModNick(sNick)) { - PutUser(":znc.in 311 " + m_pNetwork->GetCurNick() + " " + sNick + " " + sNick + " znc.in * :" + sNick); - PutUser(":znc.in 312 " + m_pNetwork->GetCurNick() + " " + sNick + " *.znc.in :Bouncer"); - PutUser(":znc.in 318 " + m_pNetwork->GetCurNick() + " " + sNick + " :End of /WHOIS list."); + CIRCNetwork* pNetwork = GetNetwork(); + PutUser(":znc.in 311 " + pNetwork->GetCurNick() + " " + sNick + " " + sNick + " znc.in * :" + sNick); + PutUser(":znc.in 312 " + pNetwork->GetCurNick() + " " + sNick + " *.znc.in :Bouncer"); + PutUser(":znc.in 318 " + pNetwork->GetCurNick() + " " + sNick + " :End of /WHOIS list."); return HALT; } diff --git a/modules/notify_connect.cpp b/modules/notify_connect.cpp index 6eb7b431..df928b00 100644 --- a/modules/notify_connect.cpp +++ b/modules/notify_connect.cpp @@ -22,11 +22,11 @@ public: MODCONSTRUCTOR(CNotifyConnectMod) {} virtual void OnClientLogin() { - SendAdmins(m_pUser->GetUserName() + " attached (from " + m_pClient->GetRemoteIP() + ")"); + SendAdmins(GetUser()->GetUserName() + " attached (from " + GetClient()->GetRemoteIP() + ")"); } virtual void OnClientDisconnect() { - SendAdmins(m_pUser->GetUserName() + " detached (from " + m_pClient->GetRemoteIP() + ")"); + SendAdmins(GetUser()->GetUserName() + " detached (from " + GetClient()->GetRemoteIP() + ")"); } private: diff --git a/modules/partyline.cpp b/modules/partyline.cpp index 18e7d27e..87232dd0 100644 --- a/modules/partyline.cpp +++ b/modules/partyline.cpp @@ -198,7 +198,7 @@ public: sLine.append(CHAN_PREFIX_1); else sLine.insert(uPos, CHAN_PREFIX_1); - m_spInjectedPrefixes.insert(m_pNetwork); + m_spInjectedPrefixes.insert(GetNetwork()); } } @@ -206,58 +206,62 @@ public: } virtual void OnIRCDisconnected() { - m_spInjectedPrefixes.erase(m_pNetwork); + m_spInjectedPrefixes.erase(GetNetwork()); } virtual void OnClientLogin() { - if (m_spInjectedPrefixes.find(m_pNetwork) == m_spInjectedPrefixes.end() && m_pNetwork && !m_pNetwork->GetChanPrefixes().empty()) { - m_pClient->PutClient(":" + GetIRCServer(m_pNetwork) + " 005 " + m_pClient->GetNick() + " CHANTYPES=" + m_pNetwork->GetChanPrefixes() + CHAN_PREFIX_1 " :are supported by this server."); + CUser* pUser = GetUser(); + CClient* pClient = GetClient(); + CIRCNetwork* pNetwork = GetNetwork(); + if (m_spInjectedPrefixes.find(pNetwork) == m_spInjectedPrefixes.end() && pNetwork && !pNetwork->GetChanPrefixes().empty()) { + pClient->PutClient(":" + GetIRCServer(pNetwork) + " 005 " + pClient->GetNick() + " CHANTYPES=" + pNetwork->GetChanPrefixes() + CHAN_PREFIX_1 " :are supported by this server."); } // Make sure this user is in the default channels for (set::iterator a = m_ssDefaultChans.begin(); a != m_ssDefaultChans.end(); ++a) { CPartylineChannel* pChannel = GetChannel(*a); - const CString& sNick = m_pUser->GetUserName(); + const CString& sNick = pUser->GetUserName(); if (pChannel->IsInChannel(sNick)) continue; - CString sHost = m_pUser->GetBindHost(); + CString sHost = pUser->GetBindHost(); const set& ssNicks = pChannel->GetNicks(); if (sHost.empty()) { sHost = "znc.in"; } - PutChan(ssNicks, ":" + NICK_PREFIX + sNick + "!" + m_pUser->GetIdent() + "@" + sHost + " JOIN " + *a, false); + PutChan(ssNicks, ":" + NICK_PREFIX + sNick + "!" + pUser->GetIdent() + "@" + sHost + " JOIN " + *a, false); pChannel->AddNick(sNick); } - CString sNickMask = m_pClient->GetNickMask(); + CString sNickMask = pClient->GetNickMask(); for (set::iterator it = m_ssChannels.begin(); it != m_ssChannels.end(); ++it) { const set& ssNicks = (*it)->GetNicks(); - if ((*it)->IsInChannel(m_pUser->GetUserName())) { + if ((*it)->IsInChannel(pUser->GetUserName())) { - m_pClient->PutClient(":" + sNickMask + " JOIN " + (*it)->GetName()); + pClient->PutClient(":" + sNickMask + " JOIN " + (*it)->GetName()); if (!(*it)->GetTopic().empty()) { - m_pClient->PutClient(":" + GetIRCServer(m_pNetwork) + " 332 " + m_pClient->GetNickMask() + " " + (*it)->GetName() + " :" + (*it)->GetTopic()); + pClient->PutClient(":" + GetIRCServer(pNetwork) + " 332 " + pClient->GetNickMask() + " " + (*it)->GetName() + " :" + (*it)->GetTopic()); } - SendNickList(m_pUser, m_pNetwork, ssNicks, (*it)->GetName()); - PutChan(ssNicks, ":*" + GetModName() + "!znc@znc.in MODE " + (*it)->GetName() + " +" + CString(m_pUser->IsAdmin() ? "o" : "v") + " " + NICK_PREFIX + m_pUser->GetUserName(), false); + SendNickList(pUser, pNetwork, ssNicks, (*it)->GetName()); + PutChan(ssNicks, ":*" + GetModName() + "!znc@znc.in MODE " + (*it)->GetName() + " +" + CString(pUser->IsAdmin() ? "o" : "v") + " " + NICK_PREFIX + pUser->GetUserName(), false); } } } virtual void OnClientDisconnect() { - if (!m_pUser->IsUserAttached() && !m_pUser->IsBeingDeleted()) { + CUser* pUser = GetUser(); + if (!pUser->IsUserAttached() && !pUser->IsBeingDeleted()) { for (set::iterator it = m_ssChannels.begin(); it != m_ssChannels.end(); ++it) { const set& ssNicks = (*it)->GetNicks(); - if (ssNicks.find(m_pUser->GetUserName()) != ssNicks.end()) { - PutChan(ssNicks, ":*" + GetModName() + "!znc@znc.in MODE " + (*it)->GetName() + " -ov " + NICK_PREFIX + m_pUser->GetUserName() + " " + NICK_PREFIX + m_pUser->GetUserName(), false); + if (ssNicks.find(pUser->GetUserName()) != ssNicks.end()) { + PutChan(ssNicks, ":*" + GetModName() + "!znc@znc.in MODE " + (*it)->GetName() + " -ov " + NICK_PREFIX + pUser->GetUserName() + " " + NICK_PREFIX + pUser->GetUserName(), false); } } } @@ -274,29 +278,31 @@ public: sTopic.TrimPrefix(":"); + CUser* pUser = GetUser(); + CClient* pClient = GetClient(); CPartylineChannel* pChannel = FindChannel(sChannel); - if (pChannel && pChannel->IsInChannel(m_pUser->GetUserName())) { + if (pChannel && pChannel->IsInChannel(pUser->GetUserName())) { const set& ssNicks = pChannel->GetNicks(); if (!sTopic.empty()) { - if (m_pUser->IsAdmin()) { - PutChan(ssNicks, ":" + m_pClient->GetNickMask() + " TOPIC " + sChannel + " :" + sTopic); + if (pUser->IsAdmin()) { + PutChan(ssNicks, ":" + pClient->GetNickMask() + " TOPIC " + sChannel + " :" + sTopic); pChannel->SetTopic(sTopic); SaveTopic(pChannel); } else { - m_pUser->PutUser(":irc.znc.in 482 " + m_pClient->GetNick() + " " + sChannel + " :You're not channel operator"); + pUser->PutUser(":irc.znc.in 482 " + pClient->GetNick() + " " + sChannel + " :You're not channel operator"); } } else { sTopic = pChannel->GetTopic(); if (sTopic.empty()) { - m_pUser->PutUser(":irc.znc.in 331 " + m_pClient->GetNick() + " " + sChannel + " :No topic is set."); + pUser->PutUser(":irc.znc.in 331 " + pClient->GetNick() + " " + sChannel + " :No topic is set."); } else { - m_pUser->PutUser(":irc.znc.in 332 " + m_pClient->GetNick() + " " + sChannel + " :" + sTopic); + pUser->PutUser(":irc.znc.in 332 " + pClient->GetNick() + " " + sChannel + " :" + sTopic); } } } else { - m_pUser->PutUser(":irc.znc.in 442 " + m_pClient->GetNick() + " " + sChannel + " :You're not on that channel"); + pUser->PutUser(":irc.znc.in 442 " + pClient->GetNick() + " " + sChannel + " :You're not on that channel"); } return HALT; } @@ -310,13 +316,13 @@ public: } if (sChannel.Left(2) != CHAN_PREFIX) { - m_pClient->PutClient(":" + GetIRCServer(m_pNetwork) + " 401 " + m_pClient->GetNick() + " " + sChannel + " :No such channel"); + GetClient()->PutClient(":" + GetIRCServer(GetNetwork()) + " 401 " + GetClient()->GetNick() + " " + sChannel + " :No such channel"); return HALT; } CPartylineChannel* pChannel = FindChannel(sChannel); - PartUser(m_pUser, pChannel); + PartUser(GetUser(), pChannel); return HALT; } @@ -385,14 +391,14 @@ public: } if (sChannel.Left(2) != CHAN_PREFIX) { - m_pClient->PutClient(":" + GetIRCServer(m_pNetwork) + " 403 " + m_pClient->GetNick() + " " + sChannel + " :Channels look like " CHAN_PREFIX "znc"); + GetClient()->PutClient(":" + GetIRCServer(GetNetwork()) + " 403 " + GetClient()->GetNick() + " " + sChannel + " :Channels look like " CHAN_PREFIX "znc"); return HALT; } sChannel = sChannel.Left(32); CPartylineChannel* pChannel = GetChannel(sChannel); - JoinUser(m_pUser, pChannel); + JoinUser(GetUser(), pChannel); return HALT; } @@ -448,7 +454,10 @@ public: return CONTINUE; } - CString sHost = m_pUser->GetBindHost(); + CUser* pUser = GetUser(); + CClient* pClient = GetClient(); + CIRCNetwork* pNetwork = GetNetwork(); + CString sHost = pUser->GetBindHost(); if (sHost.empty()) { sHost = "znc.in"; @@ -456,30 +465,30 @@ public: if (cPrefix == CHAN_PREFIX_1C) { if (FindChannel(sTarget) == NULL) { - m_pClient->PutClient(":" + GetIRCServer(m_pNetwork) + " 401 " + m_pClient->GetNick() + " " + sTarget + " :No such channel"); + pClient->PutClient(":" + GetIRCServer(pNetwork) + " 401 " + pClient->GetNick() + " " + sTarget + " :No such channel"); return HALT; } - PutChan(sTarget, ":" + NICK_PREFIX + m_pUser->GetUserName() + "!" + m_pUser->GetIdent() + "@" + sHost + " " + sCmd + " " + sTarget + " :" + sMessage, true, false); + PutChan(sTarget, ":" + NICK_PREFIX + pUser->GetUserName() + "!" + pUser->GetIdent() + "@" + sHost + " " + sCmd + " " + sTarget + " :" + sMessage, true, false); } else { CString sNick = sTarget.LeftChomp_n(1); - CUser* pUser = CZNC::Get().FindUser(sNick); + CUser* pTargetUser = CZNC::Get().FindUser(sNick); - if (pUser) { - vector vClients = pUser->GetAllClients(); + if (pTargetUser) { + vector vClients = pTargetUser->GetAllClients(); if (vClients.empty()) { - m_pClient->PutClient(":" + GetIRCServer(m_pNetwork) + " 401 " + m_pClient->GetNick() + " " + sTarget + " :User is not attached: " + sNick + ""); + pClient->PutClient(":" + GetIRCServer(pNetwork) + " 401 " + pClient->GetNick() + " " + sTarget + " :User is not attached: " + sNick + ""); return HALT; } for (vector::const_iterator it = vClients.begin(); it != vClients.end(); ++it) { - CClient* pClient = *it; + CClient* pTarget = *it; - pClient->PutClient(":" + NICK_PREFIX + m_pUser->GetUserName() + "!" + m_pUser->GetIdent() + "@" + sHost + " " + sCmd + " " + pClient->GetNick() + " :" + sMessage); + pTarget->PutClient(":" + NICK_PREFIX + pUser->GetUserName() + "!" + pUser->GetIdent() + "@" + sHost + " " + sCmd + " " + pTarget->GetNick() + " :" + sMessage); } } else { - m_pClient->PutClient(":" + GetIRCServer(m_pNetwork) + " 401 " + m_pClient->GetNick() + " " + sTarget + " :No such znc user: " + sNick + ""); + pClient->PutClient(":" + GetIRCServer(pNetwork) + " 401 " + pClient->GetNick() + " " + sTarget + " :No such znc user: " + sNick + ""); } } @@ -532,9 +541,9 @@ public: const map& msUsers = CZNC::Get().GetUserMap(); if (!pUser) - pUser = m_pUser; + pUser = GetUser(); if (!pClient) - pClient = m_pClient; + pClient = GetClient(); for (map::const_iterator it = msUsers.begin(); it != msUsers.end(); ++it) { if (ssNicks.find(it->first) != ssNicks.end()) { diff --git a/modules/q.cpp b/modules/q.cpp index a4e70956..44004dac 100644 --- a/modules/q.cpp +++ b/modules/q.cpp @@ -56,7 +56,7 @@ public: if (IsIRCConnected()) { // check for usermode +x if we are already connected - set scUserModes = m_pNetwork->GetIRCSock()->GetUserModes(); + set scUserModes = GetNetwork()->GetIRCSock()->GetUserModes(); if (scUserModes.find('x') != scUserModes.end()) m_bCloaked = true; @@ -260,7 +260,7 @@ public: // Join channels immediately after our spoof is set. if (m_bJoinAfterCloaked) { - m_pNetwork->JoinChans(); + GetNetwork()->JoinChans(); } } return CONTINUE; @@ -300,7 +300,7 @@ public: if (!Nick.NickEquals("Q") || !Nick.GetHost().Equals("CServe.quakenet.org")) return CONTINUE; if (m_bJoinOnInvite) - m_pNetwork->AddChan(sChan, false); + GetNetwork()->AddChan(sChan, false); return CONTINUE; } @@ -388,7 +388,7 @@ private: return; PutModule("Cloak: Trying to cloak your hostname, setting +x..."); - PutIRC("MODE " + m_pNetwork->GetIRCSock()->GetNick() + " +x"); + PutIRC("MODE " + GetNetwork()->GetIRCSock()->GetNick() + " +x"); } void WhoAmI() { @@ -538,12 +538,12 @@ private: /* Utility Functions */ bool IsIRCConnected() { - CIRCSock* pIRCSock = m_pNetwork->GetIRCSock(); + CIRCSock* pIRCSock = GetNetwork()->GetIRCSock(); return pIRCSock && pIRCSock->IsAuthed(); } bool IsSelf(const CNick& Nick) { - return Nick.NickEquals(m_pNetwork->GetCurNick()); + return Nick.NickEquals(GetNetwork()->GetCurNick()); } bool PackHex(const CString& sHex, CString& sPackedHex) { diff --git a/modules/route_replies.cpp b/modules/route_replies.cpp index f0d86bc2..0c89304f 100644 --- a/modules/route_replies.cpp +++ b/modules/route_replies.cpp @@ -255,7 +255,7 @@ public: { requestQueue::iterator it; - if (m_pClient == m_pDoing) { + if (GetClient() == m_pDoing) { // The replies which aren't received yet will be // broadcasted to everyone, but at least nothing breaks RemTimer("RouteTimeout"); @@ -263,7 +263,7 @@ public: m_pReplies = NULL; } - it = m_vsPending.find(m_pClient); + it = m_vsPending.find(GetClient()); if (it != m_vsPending.end()) m_vsPending.erase(it); @@ -311,7 +311,7 @@ public: { CString sCmd = sLine.Token(0).AsUpper(); - if (!m_pNetwork->GetIRCSock()) + if (!GetNetwork()->GetIRCSock()) return CONTINUE; if (sCmd.Equals("MODE")) { @@ -354,7 +354,7 @@ public: struct queued_req req = { sLine, vRouteReplies[i].vReplies }; - m_vsPending[m_pClient].push_back(req); + m_vsPending[GetClient()].push_back(req); SendRequest(); return HALTCORE; @@ -397,7 +397,7 @@ private: // 353 needs special treatment due to NAMESX and UHNAMES if (bIsRaw353) - m_pNetwork->GetIRCSock()->ForwardRaw353(sLine, m_pDoing); + GetNetwork()->GetIRCSock()->ForwardRaw353(sLine, m_pDoing); else m_pDoing->PutClient(sLine); @@ -469,7 +469,7 @@ private: void CRouteTimeout::RunJob() { - CRouteRepliesMod *pMod = (CRouteRepliesMod *) m_pModule; + CRouteRepliesMod *pMod = (CRouteRepliesMod *) GetModule(); pMod->Timeout(); } diff --git a/modules/sample.cpp b/modules/sample.cpp index 043bc8e5..94a1800b 100644 --- a/modules/sample.cpp +++ b/modules/sample.cpp @@ -26,14 +26,14 @@ public: ~CSampleJob() { if (wasCancelled()) { - m_pModule->PutModule("Sample job cancelled"); + GetModule()->PutModule("Sample job cancelled"); } else { - m_pModule->PutModule("Sample job destroyed"); + GetModule()->PutModule("Sample job destroyed"); } } virtual void runThread() { - // Cannot safely use m_pModule in here, because this runs in its + // Cannot safely use GetModule() in here, because this runs in its // own thread and such an access would require synchronisation // between this thread and the main thread! @@ -46,7 +46,7 @@ public: } virtual void runMain() { - m_pModule->PutModule("Sample job done"); + GetModule()->PutModule("Sample job done"); } }; @@ -59,7 +59,7 @@ public: private: protected: virtual void RunJob() { - m_pModule->PutModule("TEST!!!!"); + GetModule()->PutModule("TEST!!!!"); } }; @@ -234,7 +234,7 @@ public: } virtual EModRet OnUserTopic(CString& sTarget, CString& sTopic) { - PutModule("* " + m_pClient->GetNick() + " changed topic on " + sTarget + " to '" + sTopic + "'"); + PutModule("* " + GetClient()->GetNick() + " changed topic on " + sTarget + " to '" + sTopic + "'"); return CONTINUE; } diff --git a/modules/sasl.cpp b/modules/sasl.cpp index 8eae4f9f..55a769f9 100644 --- a/modules/sasl.cpp +++ b/modules/sasl.cpp @@ -488,7 +488,7 @@ public: return; } - m_pNetwork->GetIRCSock()->PauseCap(); + GetNetwork()->GetIRCSock()->PauseCap(); m_Mechanisms.SetIndex(0); PutIRC("AUTHENTICATE " + m_Mechanisms.GetCurrent()); @@ -503,7 +503,7 @@ public: Authenticate(sLine.Token(1, true)); } else if (sLine.Token(1).Equals("903")) { /* SASL success! */ - m_pNetwork->GetIRCSock()->ResumeCap(); + GetNetwork()->GetIRCSock()->ResumeCap(); m_bAuthenticated = true; DEBUG("sasl: Authenticated with mechanism [" << m_Mechanisms.GetCurrent() << "]"); } else if (sLine.Token(1).Equals("904") || sLine.Token(1).Equals("905")) { @@ -515,7 +515,7 @@ public: PutIRC("AUTHENTICATE " + m_Mechanisms.GetCurrent()); } else { CheckRequireAuth(); - m_pNetwork->GetIRCSock()->ResumeCap(); + GetNetwork()->GetIRCSock()->ResumeCap(); } } else if (sLine.Token(1).Equals("906")) { /* CAP wasn't paused? */ @@ -523,7 +523,7 @@ public: CheckRequireAuth(); } else if (sLine.Token(1).Equals("907")) { m_bAuthenticated = true; - m_pNetwork->GetIRCSock()->ResumeCap(); + GetNetwork()->GetIRCSock()->ResumeCap(); DEBUG("sasl: Received 907 -- We are already registered"); } else { return CONTINUE; diff --git a/modules/savebuff.cpp b/modules/savebuff.cpp index 9ac4da09..d023d886 100644 --- a/modules/savebuff.cpp +++ b/modules/savebuff.cpp @@ -97,7 +97,7 @@ public: { m_bFirstLoad = true; AddTimer(new CSaveBuffJob(this, 60, 0, "SaveBuff", "Saves the current buffer to disk every 1 minute")); - const vector& vChans = m_pNetwork->GetChans(); + const vector& vChans = GetNetwork()->GetChans(); for (u_int a = 0; a < vChans.size(); a++) { if (vChans[a]->AutoClearChanBuffer()) @@ -108,7 +108,7 @@ public: PutUser(":***!znc@znc.in PRIVMSG " + vChans[a]->GetName() + " :Failed to decrypt this channel, did you change the encryption pass?"); } } - const vector& vQueries = m_pNetwork->GetQueries(); + const vector& vQueries = GetNetwork()->GetQueries(); for (u_int a = 0; a < vQueries.size(); a++) { if (!BootStrap(vQueries[a])) @@ -170,7 +170,7 @@ public: { if (!m_sPassword.empty()) { - const vector& vChans = m_pNetwork->GetChans(); + const vector& vChans = GetNetwork()->GetChans(); for (u_int a = 0; a < vChans.size(); a++) { CString sPath = GetPath(vChans[a]->GetName()); @@ -276,7 +276,7 @@ public: CString GetPath(const CString & sChannel) { - CString sBuffer = m_pUser->GetUserName() + sChannel.AsLower(); + CString sBuffer = GetUser()->GetUserName() + sChannel.AsLower(); CString sRet = GetSavePath(); sRet += "/" + CBlowfish::MD5(sBuffer, true); return(sRet); @@ -292,7 +292,7 @@ public: void AddBuffer(CChan& chan, const CString &sLine) { // If they have AutoClearChanBuffer enabled, only add messages if no client is connected - if (chan.AutoClearChanBuffer() && m_pNetwork->IsUserAttached()) + if (chan.AutoClearChanBuffer() && GetNetwork()->IsUserAttached()) return; chan.AddBuffer(sLine); } @@ -307,7 +307,7 @@ public: { AddBuffer(*vChans[a], SpoofChanMsg(vChans[a]->GetName(), cNick.GetNickMask() + " QUIT " + sMessage)); } - if (cNick.NickEquals(m_pUser->GetNick())) + if (cNick.NickEquals(GetUser()->GetNick())) SaveBufferToDisk(); // need to force a save here to see this! } @@ -324,7 +324,7 @@ public: } virtual void OnJoin(const CNick& cNick, CChan& cChannel) { - if (cNick.NickEquals(m_pUser->GetNick()) && cChannel.GetBuffer().empty()) + if (cNick.NickEquals(GetUser()->GetNick()) && cChannel.GetBuffer().empty()) { BootStrap((CChan *)&cChannel); if (!cChannel.GetBuffer().empty()) @@ -335,7 +335,7 @@ public: virtual void OnPart(const CNick& cNick, CChan& cChannel) { AddBuffer(cChannel, SpoofChanMsg(cChannel.GetName(), cNick.GetNickMask() + " PART")); - if (cNick.NickEquals(m_pUser->GetNick())) + if (cNick.NickEquals(GetUser()->GetNick())) SaveBufferToDisk(); // need to force a save here to see this! } #endif /* LEGACY_SAVEBUFF */ @@ -377,7 +377,7 @@ private: void CSaveBuffJob::RunJob() { - CSaveBuff *p = (CSaveBuff *)m_pModule; + CSaveBuff *p = (CSaveBuff *)GetModule(); p->SaveBufferToDisk(); } diff --git a/modules/schat.cpp b/modules/schat.cpp index 98d03b47..8fe67a57 100644 --- a/modules/schat.cpp +++ b/modules/schat.cpp @@ -181,8 +181,8 @@ public: pSock->SetCipher("HIGH"); pSock->SetPemLocation(m_sPemFile); - u_short iPort = m_pManager->ListenRand(pSock->GetSockName() + "::LISTENER", - m_pUser->GetLocalDCCIP(), true, SOMAXCONN, pSock, 60); + u_short iPort = GetManager()->ListenRand(pSock->GetSockName() + "::LISTENER", + GetUser()->GetLocalDCCIP(), true, SOMAXCONN, pSock, 60); if (iPort == 0) { PutModule("Failed to start chat!"); @@ -192,7 +192,7 @@ public: stringstream s; s << "PRIVMSG " << sArgs << " :\001"; s << "DCC SCHAT chat "; - s << CUtils::GetLongIP(m_pUser->GetLocalDCCIP()); + s << CUtils::GetLongIP(GetUser()->GetLocalDCCIP()); s << " " << iPort << "\001"; PutIRC(s.str()); @@ -253,7 +253,7 @@ public: } } PutModule("No Such Chat [" + sArgs + "]"); - } else if (sCom.Equals("showsocks") && m_pUser->IsAdmin()) { + } else if (sCom.Equals("showsocks") && GetUser()->IsAdmin()) { CTable Table; Table.AddColumn("SockName"); Table.AddColumn("Created"); @@ -310,7 +310,7 @@ public: PutModule(" list - List current chats."); PutModule(" close - Close a chat to a nick."); PutModule(" timers - Shows related timers."); - if (m_pUser->IsAdmin()) { + if (GetUser()->IsAdmin()) { PutModule(" showsocks - Shows all socket connections."); } } else if (sCom.Equals("timers")) @@ -352,8 +352,8 @@ public: void AcceptSDCC(const CString & sNick, u_long iIP, u_short iPort) { CSChatSock *p = new CSChatSock(this, sNick, CUtils::GetIP(iIP), iPort, 60); - m_pManager->Connect(CUtils::GetIP(iIP), iPort, p->GetSockName(), 60, - true, m_pUser->GetLocalDCCIP(), p); + GetManager()->Connect(CUtils::GetIP(iIP), iPort, p->GetSockName(), 60, + true, GetUser()->GetLocalDCCIP(), p); RemTimer("Remove " + sNick); // delete any associated timer to this nick } @@ -396,13 +396,13 @@ public: void SendToUser(const CString & sFrom, const CString & sText) { //:*schat!znc@znc.in PRIVMSG Jim : - CString sSend = ":" + sFrom + " PRIVMSG " + m_pNetwork->GetCurNick() + " :" + sText; + CString sSend = ":" + sFrom + " PRIVMSG " + GetNetwork()->GetCurNick() + " :" + sText; PutUser(sSend); } bool IsAttached() { - return(m_pNetwork->IsUserAttached()); + return(GetNetwork()->IsUserAttached()); } private: @@ -470,7 +470,7 @@ void CSChatSock::Timeout() void CRemMarkerJob::RunJob() { - CSChat *p = (CSChat *)m_pModule; + CSChat *p = (CSChat *)GetModule(); p->RemoveMarker(m_sNick); // store buffer diff --git a/modules/send_raw.cpp b/modules/send_raw.cpp index 622a0eb7..428360c0 100644 --- a/modules/send_raw.cpp +++ b/modules/send_raw.cpp @@ -57,14 +57,14 @@ class CSendRaw_Mod: public CModule { void CurrentClient(const CString& sLine) { CString sData = sLine.Token(1, true); - m_pClient->PutClient(sData); + GetClient()->PutClient(sData); } public: virtual ~CSendRaw_Mod() {} virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg) { - if (!m_pUser->IsAdmin()) { + if (!GetUser()->IsAdmin()) { sErrorMsg = "You must have admin privileges to load this module"; return false; } diff --git a/modules/shell.cpp b/modules/shell.cpp index af320ff9..382576aa 100644 --- a/modules/shell.cpp +++ b/modules/shell.cpp @@ -60,17 +60,17 @@ public: } virtual ~CShellMod() { - vector vSocks = m_pManager->FindSocksByName("SHELL"); + vector vSocks = GetManager()->FindSocksByName("SHELL"); for (unsigned int a = 0; a < vSocks.size(); a++) { - m_pManager->DelSockByAddr(vSocks[a]); + GetManager()->DelSockByAddr(vSocks[a]); } } virtual bool OnLoad(const CString& sArgs, CString& sMessage) { #ifndef MOD_SHELL_ALLOW_EVERYONE - if (!m_pUser->IsAdmin()) { + if (!GetUser()->IsAdmin()) { sMessage = "You must be admin to use the shell module"; return false; } @@ -103,12 +103,12 @@ public: void PutShell(const CString& sMsg) { CString sPath = m_sPath.Replace_n(" ", "_"); CString sSource = ":" + GetModNick() + "!shell@" + sPath; - CString sLine = sSource + " PRIVMSG " + m_pClient->GetNick() + " :" + sMsg; - m_pClient->PutClient(sLine); + CString sLine = sSource + " PRIVMSG " + GetClient()->GetNick() + " :" + sMsg; + GetClient()->PutClient(sLine); } void RunCommand(const CString& sCommand) { - m_pManager->AddSock(new CShellSock(this, m_pClient, "cd " + m_sPath + " && " + sCommand), "SHELL"); + GetManager()->AddSock(new CShellSock(this, GetClient(), "cd " + m_sPath + " && " + sCommand), "SHELL"); } private: CString m_sPath; diff --git a/modules/simple_away.cpp b/modules/simple_away.cpp index a1e59277..506a2fe7 100644 --- a/modules/simple_away.cpp +++ b/modules/simple_away.cpp @@ -82,7 +82,7 @@ public: } virtual void OnIRCConnected() { - if (m_pNetwork->IsUserAttached()) + if (GetNetwork()->IsUserAttached()) SetBack(); else SetAway(false); @@ -94,7 +94,7 @@ public: virtual void OnClientDisconnect() { /* There might still be other clients */ - if (!m_pNetwork->IsUserAttached()) + if (!GetNetwork()->IsUserAttached()) SetAway(); } @@ -198,7 +198,7 @@ private: sReason = SIMPLE_AWAY_DEFAULT_REASON; time_t iTime = time(NULL); - CString sTime = CUtils::CTime(iTime, m_pUser->GetTimezone()); + CString sTime = CUtils::CTime(iTime, GetUser()->GetTimezone()); sReason.Replace("%s", sTime); return sReason; @@ -220,7 +220,7 @@ private: }; void CSimpleAwayJob::RunJob() { - ((CSimpleAway*)m_pModule)->SetAway(false); + ((CSimpleAway*)GetModule())->SetAway(false); } template<> void TModInfo(CModInfo& Info) { diff --git a/modules/stickychan.cpp b/modules/stickychan.cpp index 0e26ccd7..2783ed48 100644 --- a/modules/stickychan.cpp +++ b/modules/stickychan.cpp @@ -35,11 +35,11 @@ public: { if (sChannel.Equals(it->first)) { - CChan* pChan = m_pNetwork->FindChan(sChannel); + CChan* pChan = GetNetwork()->FindChan(sChannel); if (pChan) { - pChan->JoinUser(true, "", m_pClient); + pChan->JoinUser(true, "", GetClient()); return HALT; } } @@ -86,24 +86,25 @@ public: virtual void RunJob() { - if (!m_pNetwork->GetIRCSock()) + CIRCNetwork* pNetwork = GetNetwork(); + if (!pNetwork->GetIRCSock()) return; for (MCString::iterator it = BeginNV(); it != EndNV(); ++it) { - CChan *pChan = m_pNetwork->FindChan(it->first); + CChan *pChan = pNetwork->FindChan(it->first); if (!pChan) { - pChan = new CChan(it->first, m_pNetwork, true); + pChan = new CChan(it->first, pNetwork, true); if (!it->second.empty()) pChan->SetKey(it->second); - if (!m_pNetwork->AddChan(pChan)) { + if (!pNetwork->AddChan(pChan)) { /* AddChan() deleted that channel */ PutModule("Could not join [" + it->first + "] (# prefix missing?)"); continue; } } - if (!pChan->IsOn() && m_pNetwork->IsIRCConnected()) { + if (!pChan->IsOn() && pNetwork->IsIRCConnected()) { PutModule("Joining [" + pChan->GetName() + "]"); PutIRC("JOIN " + pChan->GetName() + (pChan->GetKey().empty() ? "" : " " + pChan->GetKey())); @@ -117,7 +118,7 @@ public: if (sPageName == "index") { bool bSubmitted = (WebSock.GetParam("submitted").ToInt() != 0); - const vector& Channels = m_pNetwork->GetChans(); + const vector& Channels = GetNetwork()->GetChans(); for (unsigned int c = 0; c < Channels.size(); c++) { const CString sChan = Channels[c]->GetName(); bool bStick = FindNV(sChan) != EndNV(); diff --git a/modules/watch.cpp b/modules/watch.cpp index 0c7aa1f5..25bbd09e 100644 --- a/modules/watch.cpp +++ b/modules/watch.cpp @@ -184,7 +184,7 @@ public: virtual void OnClientLogin() { MCString msParams; - msParams["target"] = m_pNetwork->GetCurNick(); + msParams["target"] = GetNetwork()->GetCurNick(); size_t uSize = m_Buffer.Size(); for (unsigned int uIdx = 0; uIdx < uSize; uIdx++) { @@ -321,12 +321,13 @@ public: private: void Process(const CNick& Nick, const CString& sMessage, const CString& sSource) { set sHandledTargets; - CChan* pChannel = m_pNetwork->FindChan(sSource); + CIRCNetwork* pNetwork = GetNetwork(); + CChan* pChannel = pNetwork->FindChan(sSource); for (list::iterator it = m_lsWatchers.begin(); it != m_lsWatchers.end(); ++it) { CWatchEntry& WatchEntry = *it; - if (m_pNetwork->IsUserAttached() && WatchEntry.IsDetachedClientOnly()) { + if (pNetwork->IsUserAttached() && WatchEntry.IsDetachedClientOnly()) { continue; } @@ -334,10 +335,10 @@ private: continue; } - if (WatchEntry.IsMatch(Nick, sMessage, sSource, m_pNetwork) && + if (WatchEntry.IsMatch(Nick, sMessage, sSource, pNetwork) && sHandledTargets.count(WatchEntry.GetTarget()) < 1) { - if (m_pNetwork->IsUserAttached()) { - m_pNetwork->PutUser(":" + WatchEntry.GetTarget() + "!watch@znc.in PRIVMSG " + m_pNetwork->GetCurNick() + " :" + sMessage); + if (pNetwork->IsUserAttached()) { + pNetwork->PutUser(":" + WatchEntry.GetTarget() + "!watch@znc.in PRIVMSG " + pNetwork->GetCurNick() + " :" + sMessage); } else { m_Buffer.AddLine(":" + _NAMEDFMT(WatchEntry.GetTarget()) + "!watch@znc.in PRIVMSG {target} :{text}", sMessage); }