Added global/user level skin settings which will be used by a future commit of webmods

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1742 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
prozacx
2010-02-07 05:06:40 +00:00
parent d2881ee9d1
commit 166f08e671
4 changed files with 42 additions and 1 deletions
+4
View File
@@ -645,6 +645,8 @@ bool CUser::WriteConfig(CFile& File) {
PrintLine(File, "QuitMsg", GetQuitMsg());
if (CZNC::Get().GetStatusPrefix() != GetStatusPrefix())
PrintLine(File, "StatusPrefix", GetStatusPrefix());
if (CZNC::Get().GetSkinName() != GetSkinName())
PrintLine(File, "Skin", GetSkinName());
PrintLine(File, "ChanModes", GetDefaultChanModes());
PrintLine(File, "Buffer", CString(GetBufferCount()));
PrintLine(File, "KeepBuffer", CString(KeepBuffer()));
@@ -1247,4 +1249,6 @@ CString CUser::GetQuitMsg() const { return (!m_sQuitMsg.Trim_n().empty()) ? m_sQ
const MCString& CUser::GetCTCPReplies() const { return m_mssCTCPReplies; }
unsigned int CUser::GetBufferCount() const { return m_uBufferCount; }
bool CUser::KeepBuffer() const { return m_bKeepBuffer; }
CString CUser::GetSkinName() const { return (!m_sSkinName.empty()) ? m_sSkinName : CZNC::Get().GetSkinName(); }
//CString CUser::GetSkinName() const { return m_sSkinName; }
// !Getters
+3
View File
@@ -169,6 +169,7 @@ public:
void SetTimezoneOffset(float b) { m_fTimezoneOffset = b; }
void SetJoinTries(unsigned int i) { m_uMaxJoinTries = i; }
void SetMaxJoins(unsigned int i) { m_uMaxJoins = i; }
void SetSkinName(const CString& s) { m_sSkinName = s; }
void SetIRCConnectEnabled(bool b) { m_bIRCConnectEnabled = b; }
void SetIRCAway(bool b) { m_bIRCAway = b; }
// !Setters
@@ -223,6 +224,7 @@ public:
unsigned long long BytesWritten() const { return m_uBytesWritten; }
unsigned int JoinTries() const { return m_uMaxJoinTries; }
unsigned int MaxJoins() const { return m_uMaxJoins; }
CString GetSkinName() const;
// !Getters
private:
protected:
@@ -284,6 +286,7 @@ protected:
unsigned long long m_uBytesWritten;
unsigned int m_uMaxJoinTries;
unsigned int m_uMaxJoins;
CString m_sSkinName;
#ifdef _MODULES
CModules* m_pModules;
+29
View File
@@ -575,6 +575,11 @@ bool CZNC::WriteConfig() {
if (!m_sPidFile.empty()) {
m_LockFile.Write("PidFile = " + m_sPidFile.FirstLine() + "\n");
}
if (!m_sSkinName.empty()) {
m_LockFile.Write("Skin = " + m_sSkinName.FirstLine() + "\n");
}
if (!m_sStatusPrefix.empty()) {
m_LockFile.Write("StatusPrefix = " + m_sStatusPrefix.FirstLine() + "\n");
}
@@ -1418,6 +1423,9 @@ bool CZNC::DoRehash(CString& sError)
} else if (sName.Equals("MaxJoins")) {
pUser->SetMaxJoins(sValue.ToUInt());
continue;
} else if (sName.Equals("Skin")) {
pUser->SetSkinName(sValue);
continue;
} else if (sName.Equals("LoadModule")) {
CString sModName = sValue.Token(0);
CUtils::PrintAction("Loading Module [" + sModName + "]");
@@ -1570,6 +1578,9 @@ bool CZNC::DoRehash(CString& sError)
} else if (sName.Equals("PidFile")) {
m_sPidFile = sValue;
continue;
} else if (sName.Equals("Skin")) {
SetSkinName(sValue);
continue;
} else if (sName.Equals("StatusPrefix")) {
m_sStatusPrefix = sValue;
continue;
@@ -1751,6 +1762,24 @@ void CZNC::Broadcast(const CString& sMessage, bool bAdminOnly,
}
}
CModule* CZNC::FindModule(const CString& sModName, const CString& sUsername) {
if (sUsername.empty()) {
return CZNC::Get().GetModules().FindModule(sModName);
}
CUser* pUser = FindUser(sUsername);
return (!pUser) ? NULL : pUser->GetModules().FindModule(sModName);
}
CModule* CZNC::FindModule(const CString& sModName, CUser* pUser) {
if (pUser) {
return pUser->GetModules().FindModule(sModName);
}
return CZNC::Get().GetModules().FindModule(sModName);
}
CUser* CZNC::FindUser(const CString& sUsername) {
map<CString,CUser*>::iterator it = m_msUsers.find(sUsername);
+6 -1
View File
@@ -82,6 +82,7 @@ public:
// Setters
void SetConfigState(enum ConfigState e) { m_eConfigState = e; }
void SetSkinName(const CString& s) { m_sSkinName = s; }
void SetStatusPrefix(const CString& s) { m_sStatusPrefix = (s.empty()) ? "*" : s; }
void SetISpoofFile(const CString& s) { m_sISpoofFile = s; }
void SetISpoofFormat(const CString& s) { m_sISpoofFormat = (s.empty()) ? "global { reply \"%\" }" : s; }
@@ -95,6 +96,7 @@ public:
CGlobalModules& GetModules() { return *m_pModules; }
size_t FilterUncommonModules(set<CModInfo>& ssModules);
#endif
CString GetSkinName() const { return m_sSkinName; }
const CString& GetStatusPrefix() const { return m_sStatusPrefix; }
const CString& GetCurPath() const { if (!CFile::Exists(m_sCurPath)) { CDir::MakeDir(m_sCurPath); } return m_sCurPath; }
const CString& GetHomePath() const { if (!CFile::Exists(m_sHomePath)) { CDir::MakeDir(m_sHomePath); } return m_sHomePath; }
@@ -115,6 +117,8 @@ public:
// Static allocator
static CZNC& Get();
CUser* FindUser(const CString& sUsername);
CModule* FindModule(const CString& sModName, const CString& sUsername);
CModule* FindModule(const CString& sModName, CUser* pUser);
bool DeleteUser(const CString& sUsername);
bool AddUser(CUser* pUser, CString& sErrorRet);
const map<CString,CUser*> & GetUserMap() const { return(m_msUsers); }
@@ -154,6 +158,7 @@ protected:
CString m_sZNCPath;
CString m_sConfigFile;
CString m_sSkinName;
CString m_sStatusPrefix;
CString m_sISpoofFile;
CString m_sOrigISpoof;
@@ -263,7 +268,7 @@ protected:
bool m_bIPV6;
unsigned short m_uPort;
CString m_sBindHost;
CRealListener* m_pListener;
CRealListener* m_pListener;
};
#endif // !_ZNC_H