mirror of
https://github.com/znc/znc.git
synced 2026-05-06 21:42:28 +02:00
Merge pull request #694 from jpnurmi/cleanup
Operation codebase cleanup
This commit is contained in:
@@ -60,7 +60,7 @@ public:
|
||||
~CChan();
|
||||
|
||||
void Reset();
|
||||
CConfig ToConfig();
|
||||
CConfig ToConfig() const;
|
||||
void Clone(CChan& chan);
|
||||
void Cycle() const;
|
||||
void JoinUser(bool bForce = false, const CString& sKey = "", CClient* pClient = NULL);
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
// Buffer
|
||||
const CBuffer& GetBuffer() const { return m_Buffer; }
|
||||
unsigned int GetBufferCount() const { return m_Buffer.GetLineCount(); }
|
||||
bool SetBufferCount(unsigned int u, bool bForce = false) { m_bHasBufferCountSet = true; return m_Buffer.SetLineCount(u, bForce); };
|
||||
bool SetBufferCount(unsigned int u, bool bForce = false) { m_bHasBufferCountSet = true; return m_Buffer.SetLineCount(u, bForce); }
|
||||
void InheritBufferCount(unsigned int u, bool bForce = false) { if (!m_bHasBufferCountSet) m_Buffer.SetLineCount(u, bForce); }
|
||||
size_t AddBuffer(const CString& sFormat, const CString& sText = "", const timeval* ts = NULL) { return m_Buffer.AddLine(sFormat, sText, ts); }
|
||||
void ClearBuffer() { m_Buffer.Clear(); }
|
||||
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
void PutModule(const CString& sModule, const CString& sLine);
|
||||
void PutModNotice(const CString& sModule, const CString& sLine);
|
||||
|
||||
bool IsCapEnabled(const CString& sCap) { return 1 == m_ssAcceptedCaps.count(sCap); }
|
||||
bool IsCapEnabled(const CString& sCap) const { return 1 == m_ssAcceptedCaps.count(sCap); }
|
||||
|
||||
virtual void ReadLine(const CString& sData);
|
||||
bool SendMotd();
|
||||
@@ -148,10 +148,10 @@ public:
|
||||
CUser* GetUser() const { return m_pUser; }
|
||||
void SetNetwork(CIRCNetwork* pNetwork, bool bDisconnect=true, bool bReconnect=true);
|
||||
CIRCNetwork* GetNetwork() const { return m_pNetwork; }
|
||||
std::vector<CClient*>& GetClients();
|
||||
const std::vector<CClient*>& GetClients() const;
|
||||
const CIRCSock* GetIRCSock() const;
|
||||
CIRCSock* GetIRCSock();
|
||||
CString GetFullName();
|
||||
CString GetFullName() const;
|
||||
private:
|
||||
void HandleCap(const CString& sLine);
|
||||
void RespondCap(const CString& sResponse);
|
||||
|
||||
@@ -238,8 +238,8 @@ public:
|
||||
return uRet;
|
||||
}
|
||||
|
||||
CFile::EFileAttr GetSortAttr() { return m_eSortAttr; }
|
||||
bool IsDescending() { return m_bDesc; }
|
||||
CFile::EFileAttr GetSortAttr() const { return m_eSortAttr; }
|
||||
bool IsDescending() const { return m_bDesc; }
|
||||
|
||||
// Check if sPath + "/" + sAdd (~/ is handled) is an absolute path which
|
||||
// resides under sPath. Returns absolute path on success, else "".
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
void ParseURI();
|
||||
void GetPage();
|
||||
static CString GetDate(time_t tm = 0);
|
||||
virtual CString GetRemoteIP();
|
||||
virtual CString GetRemoteIP() const;
|
||||
|
||||
// Cookies
|
||||
CString GetRequestCookie(const CString& sKey) const;
|
||||
|
||||
@@ -57,12 +57,12 @@ public:
|
||||
|
||||
void Clone(const CIRCNetwork& Network, bool bCloneName = true);
|
||||
|
||||
CString GetNetworkPath();
|
||||
CString GetNetworkPath() const;
|
||||
|
||||
void DelServers();
|
||||
|
||||
bool ParseConfig(CConfig *pConfig, CString& sError, bool bUpgrade = false);
|
||||
CConfig ToConfig();
|
||||
CConfig ToConfig() const;
|
||||
|
||||
void BounceAllClients();
|
||||
|
||||
@@ -71,10 +71,10 @@ public:
|
||||
void ClientConnected(CClient *pClient);
|
||||
void ClientDisconnected(CClient *pClient);
|
||||
|
||||
CUser* GetUser();
|
||||
CUser* GetUser() const;
|
||||
const CString& GetName() const;
|
||||
bool IsNetworkAttached() const { return !m_vClients.empty(); };
|
||||
std::vector<CClient*>& GetClients() { return m_vClients; }
|
||||
bool IsNetworkAttached() const { return !m_vClients.empty(); }
|
||||
const std::vector<CClient*>& GetClients() const { return m_vClients; }
|
||||
|
||||
void SetUser(CUser *pUser);
|
||||
bool SetName(const CString& sName);
|
||||
@@ -103,8 +103,8 @@ public:
|
||||
CQuery* AddQuery(const CString& sName);
|
||||
bool DelQuery(const CString& sName);
|
||||
|
||||
const CString& GetChanPrefixes() const { return m_sChanPrefixes; };
|
||||
void SetChanPrefixes(const CString& s) { m_sChanPrefixes = s; };
|
||||
const CString& GetChanPrefixes() const { return m_sChanPrefixes; }
|
||||
void SetChanPrefixes(const CString& s) { m_sChanPrefixes = s; }
|
||||
bool IsChan(const CString& sChan) const;
|
||||
|
||||
const std::vector<CServer*>& GetServers() const;
|
||||
|
||||
@@ -978,13 +978,13 @@ public:
|
||||
* except when we are in a user-specific module hook in which
|
||||
* case this is the user pointer.
|
||||
*/
|
||||
CUser* GetUser() { return m_pUser; }
|
||||
CUser* GetUser() const { return m_pUser; }
|
||||
/** @returns NULL except when we are in a client-specific module hook in
|
||||
* which case this is the client for which the hook is called.
|
||||
*/
|
||||
CIRCNetwork* GetNetwork() { return m_pNetwork; }
|
||||
CClient* GetClient() { return m_pClient; }
|
||||
CSockManager* GetManager() { return m_pManager; }
|
||||
CIRCNetwork* GetNetwork() const { return m_pNetwork; }
|
||||
CClient* GetClient() const { return m_pClient; }
|
||||
CSockManager* GetManager() const { return m_pManager; }
|
||||
// !Getters
|
||||
|
||||
// Global Modules
|
||||
@@ -1114,9 +1114,9 @@ public:
|
||||
void SetUser(CUser* pUser) { m_pUser = pUser; }
|
||||
void SetNetwork(CIRCNetwork* pNetwork) { m_pNetwork = pNetwork; }
|
||||
void SetClient(CClient* pClient) { m_pClient = pClient; }
|
||||
CUser* GetUser() { return m_pUser; }
|
||||
CIRCNetwork* GetNetwork() { return m_pNetwork; }
|
||||
CClient* GetClient() { return m_pClient; }
|
||||
CUser* GetUser() const { return m_pUser; }
|
||||
CIRCNetwork* GetNetwork() const { return m_pNetwork; }
|
||||
CClient* GetClient() const { return m_pClient; }
|
||||
|
||||
void UnloadAll();
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
return CUtils::SaltedSHA256Hash(sPass, sSalt);
|
||||
}
|
||||
|
||||
CConfig ToConfig();
|
||||
CConfig ToConfig() const;
|
||||
bool CheckPass(const CString& sPass) const;
|
||||
bool AddAllowedHost(const CString& sHostMask);
|
||||
bool IsHostAllowed(const CString& sHostMask) const;
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
void UserConnected(CClient* pClient);
|
||||
void UserDisconnected(CClient* pClient);
|
||||
|
||||
CString GetLocalDCCIP();
|
||||
CString GetLocalDCCIP() const;
|
||||
|
||||
CString ExpandString(const CString& sStr) const;
|
||||
CString& ExpandString(const CString& sStr, CString& sRet) const;
|
||||
@@ -141,8 +141,8 @@ public:
|
||||
// !Setters
|
||||
|
||||
// Getters
|
||||
std::vector<CClient*>& GetUserClients() { return m_vClients; }
|
||||
std::vector<CClient*> GetAllClients();
|
||||
const std::vector<CClient*>& GetUserClients() const { return m_vClients; }
|
||||
std::vector<CClient*> GetAllClients() const;
|
||||
const CString& GetUserName() const;
|
||||
const CString& GetCleanUserName() const;
|
||||
const CString& GetNick(bool bAllowDefault = true) const;
|
||||
|
||||
@@ -135,7 +135,6 @@ public:
|
||||
|
||||
virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort);
|
||||
static CString GetSkinPath(const CString& sSkinName);
|
||||
CModule* GetModule() const { return (CModule*) m_pModule; }
|
||||
void GetAvailSkins(VCString& vRet) const;
|
||||
CString GetSkinName();
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ void CChan::Reset() {
|
||||
ResetJoinTries();
|
||||
}
|
||||
|
||||
CConfig CChan::ToConfig() {
|
||||
CConfig CChan::ToConfig() const {
|
||||
CConfig config;
|
||||
|
||||
if (m_bHasBufferCountSet)
|
||||
@@ -141,8 +141,8 @@ void CChan::JoinUser(bool bForce, const CString& sKey, CClient* pClient) {
|
||||
CString sLine = sPre;
|
||||
CString sPerm, sNick;
|
||||
|
||||
vector<CClient*>& vpClients = m_pNetwork->GetClients();
|
||||
for (vector<CClient*>::iterator it = vpClients.begin(); it != vpClients.end(); ++it) {
|
||||
const vector<CClient*>& vpClients = m_pNetwork->GetClients();
|
||||
for (vector<CClient*>::const_iterator it = vpClients.begin(); it != vpClients.end(); ++it) {
|
||||
CClient* pThisClient;
|
||||
if (!pClient)
|
||||
pThisClient = *it;
|
||||
|
||||
@@ -271,7 +271,7 @@ void CClient::ReadLine(const CString& sData) {
|
||||
|
||||
// Relay to the rest of the clients that may be connected to this user
|
||||
if (m_pNetwork->IsChan(sTarget)) {
|
||||
vector<CClient*>& vClients = GetClients();
|
||||
const vector<CClient*>& vClients = GetClients();
|
||||
|
||||
for (unsigned int a = 0; a < vClients.size(); a++) {
|
||||
CClient* pClient = vClients[a];
|
||||
@@ -325,7 +325,7 @@ void CClient::ReadLine(const CString& sData) {
|
||||
}
|
||||
|
||||
// Relay to the rest of the clients that may be connected to this user
|
||||
vector<CClient*>& vClients = GetClients();
|
||||
const vector<CClient*>& vClients = GetClients();
|
||||
|
||||
for (unsigned int a = 0; a < vClients.size(); a++) {
|
||||
CClient* pClient = vClients[a];
|
||||
@@ -394,7 +394,7 @@ void CClient::ReadLine(const CString& sData) {
|
||||
// Relay to the rest of the clients that may be connected to this user
|
||||
|
||||
if (m_pNetwork->IsChan(sTarget)) {
|
||||
vector<CClient*>& vClients = GetClients();
|
||||
const vector<CClient*>& vClients = GetClients();
|
||||
|
||||
for (unsigned int a = 0; a < vClients.size(); a++) {
|
||||
CClient* pClient = vClients[a];
|
||||
@@ -575,7 +575,7 @@ void CClient::SetNetwork(CIRCNetwork* pNetwork, bool bDisconnect, bool bReconnec
|
||||
}
|
||||
}
|
||||
|
||||
vector<CClient*>& CClient::GetClients() {
|
||||
const vector<CClient*>& CClient::GetClients() const {
|
||||
if (m_pNetwork) {
|
||||
return m_pNetwork->GetClients();
|
||||
}
|
||||
@@ -775,7 +775,7 @@ void CClient::PutIRC(const CString& sLine) {
|
||||
}
|
||||
}
|
||||
|
||||
CString CClient::GetFullName() {
|
||||
CString CClient::GetFullName() const {
|
||||
if (!m_pUser)
|
||||
return GetRemoteIP();
|
||||
if (!m_pNetwork)
|
||||
|
||||
@@ -181,7 +181,7 @@ void CHTTPSock::ReadLine(const CString& sData) {
|
||||
}
|
||||
}
|
||||
|
||||
CString CHTTPSock::GetRemoteIP() {
|
||||
CString CHTTPSock::GetRemoteIP() const {
|
||||
if (!m_sForwardedIP.empty()) {
|
||||
return m_sForwardedIP;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ protected:
|
||||
pIRCSock->PutIRC("PING :ZNC");
|
||||
}
|
||||
|
||||
vector<CClient*>& vClients = m_pNetwork->GetClients();
|
||||
const vector<CClient*>& vClients = m_pNetwork->GetClients();
|
||||
for (size_t b = 0; b < vClients.size(); b++) {
|
||||
CClient* pClient = vClients[b];
|
||||
|
||||
@@ -305,7 +305,7 @@ void CIRCNetwork::DelServers() {
|
||||
m_vServers.clear();
|
||||
}
|
||||
|
||||
CString CIRCNetwork::GetNetworkPath() {
|
||||
CString CIRCNetwork::GetNetworkPath() const {
|
||||
CString sNetworkPath = m_pUser->GetUserPath() + "/networks/" + m_sName;
|
||||
|
||||
if (!CFile::Exists(sNetworkPath)) {
|
||||
@@ -455,7 +455,7 @@ bool CIRCNetwork::ParseConfig(CConfig *pConfig, CString& sError, bool bUpgrade)
|
||||
return true;
|
||||
}
|
||||
|
||||
CConfig CIRCNetwork::ToConfig() {
|
||||
CConfig CIRCNetwork::ToConfig() const {
|
||||
CConfig config;
|
||||
|
||||
if (!m_sNick.empty()) {
|
||||
@@ -487,7 +487,7 @@ CConfig CIRCNetwork::ToConfig() {
|
||||
}
|
||||
|
||||
// Modules
|
||||
CModules& Mods = GetModules();
|
||||
const CModules& Mods = GetModules();
|
||||
|
||||
if (!Mods.empty()) {
|
||||
for (unsigned int a = 0; a < Mods.size(); a++) {
|
||||
@@ -638,7 +638,7 @@ void CIRCNetwork::ClientDisconnected(CClient *pClient) {
|
||||
}
|
||||
}
|
||||
|
||||
CUser* CIRCNetwork::GetUser() {
|
||||
CUser* CIRCNetwork::GetUser() const {
|
||||
return m_pUser;
|
||||
}
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
m_bAuthed = true;
|
||||
m_pNetwork->PutStatus("Connected!");
|
||||
|
||||
vector<CClient*>& vClients = m_pNetwork->GetClients();
|
||||
const vector<CClient*>& vClients = m_pNetwork->GetClients();
|
||||
|
||||
for (unsigned int a = 0; a < vClients.size(); a++) {
|
||||
CClient* pClient = vClients[a];
|
||||
@@ -354,8 +354,8 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
if (m_bNamesx && (sNick.size() > 1) && IsPermChar(sNick[1])) {
|
||||
// sLine uses multi-prefix
|
||||
|
||||
vector<CClient*>& vClients = m_pNetwork->GetClients();
|
||||
vector<CClient*>::iterator it;
|
||||
const vector<CClient*>& vClients = m_pNetwork->GetClients();
|
||||
vector<CClient*>::const_iterator it;
|
||||
for (it = vClients.begin(); it != vClients.end(); ++it) {
|
||||
CClient *pClient = *it;
|
||||
|
||||
@@ -1233,8 +1233,8 @@ CString CIRCSock::GetISupport(const CString& sKey, const CString& sDefault) cons
|
||||
}
|
||||
|
||||
void CIRCSock::ForwardRaw353(const CString& sLine) const {
|
||||
vector<CClient*>& vClients = m_pNetwork->GetClients();
|
||||
vector<CClient*>::iterator it;
|
||||
const vector<CClient*>& vClients = m_pNetwork->GetClients();
|
||||
vector<CClient*>::const_iterator it;
|
||||
|
||||
for (it = vClients.begin(); it != vClients.end(); ++it) {
|
||||
ForwardRaw353(sLine, *it);
|
||||
|
||||
14
src/User.cpp
14
src/User.cpp
@@ -37,7 +37,7 @@ public:
|
||||
private:
|
||||
protected:
|
||||
virtual void RunJob() {
|
||||
vector<CClient*>& vUserClients = m_pUser->GetUserClients();
|
||||
const vector<CClient*>& vUserClients = m_pUser->GetUserClients();
|
||||
for (size_t c = 0; c < vUserClients.size(); ++c) {
|
||||
CClient* pUserClient = vUserClients[c];
|
||||
|
||||
@@ -659,7 +659,7 @@ void CUser::CloneNetworks(const CUser& User) {
|
||||
// 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();
|
||||
const vector<CClient*>& vClients = FindNetwork(*it)->GetClients();
|
||||
|
||||
while (vClients.begin() != vClients.end()) {
|
||||
CClient *pClient = vClients.front();
|
||||
@@ -859,7 +859,7 @@ bool CUser::IsValid(CString& sErrMsg, bool bSkipPass) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
CConfig CUser::ToConfig() {
|
||||
CConfig CUser::ToConfig() const {
|
||||
CConfig config;
|
||||
CConfig passConfig;
|
||||
|
||||
@@ -923,7 +923,7 @@ CConfig CUser::ToConfig() {
|
||||
}
|
||||
|
||||
// Modules
|
||||
CModules& Mods = GetModules();
|
||||
const CModules& Mods = GetModules();
|
||||
|
||||
if (!Mods.empty()) {
|
||||
for (unsigned int a = 0; a < Mods.size(); a++) {
|
||||
@@ -976,11 +976,11 @@ bool CUser::CheckPass(const CString& sPass) const {
|
||||
return (CClient*) CZNC::Get().GetManager().FindSockByName(sSockName);
|
||||
}*/
|
||||
|
||||
CString CUser::GetLocalDCCIP() {
|
||||
CString CUser::GetLocalDCCIP() const {
|
||||
if (!GetDCCBindHost().empty())
|
||||
return GetDCCBindHost();
|
||||
|
||||
for (vector<CIRCNetwork*>::iterator it = m_vIRCNetworks.begin(); it != m_vIRCNetworks.end(); ++it) {
|
||||
for (vector<CIRCNetwork*>::const_iterator it = m_vIRCNetworks.begin(); it != m_vIRCNetworks.end(); ++it) {
|
||||
CIRCNetwork *pNetwork = *it;
|
||||
CIRCSock* pIRCSock = pNetwork->GetIRCSock();
|
||||
if (pIRCSock) {
|
||||
@@ -1167,7 +1167,7 @@ bool CUser::SetStatusPrefix(const CString& s) {
|
||||
// !Setters
|
||||
|
||||
// Getters
|
||||
vector<CClient*> CUser::GetAllClients() {
|
||||
vector<CClient*> CUser::GetAllClients() const {
|
||||
vector<CClient*> vClients;
|
||||
|
||||
for (unsigned int a = 0; a < m_vIRCNetworks.size(); a++) {
|
||||
|
||||
Reference in New Issue
Block a user