diff --git a/lib/server/CConfig.cpp b/lib/server/CConfig.cpp index 3359d9f1..b125206f 100644 --- a/lib/server/CConfig.cpp +++ b/lib/server/CConfig.cpp @@ -244,42 +244,69 @@ CConfig::setHTTPAddress(const CNetworkAddress& addr) bool CConfig::addOption(const CString& name, OptionID option, OptionValue value) { - // find cell - CCellMap::iterator index = m_map.find(name); - if (index == m_map.end()) { + // find options + CScreenOptions* options = NULL; + if (name.empty()) { + options = &m_globalOptions; + } + else { + CCellMap::iterator index = m_map.find(name); + if (index != m_map.end()) { + options = &index->second.m_options; + } + } + if (options == NULL) { return false; } // add option - index->second.m_options.insert(std::make_pair(option, value)); + options->insert(std::make_pair(option, value)); return true; } bool CConfig::removeOption(const CString& name, OptionID option) { - // find cell - CCellMap::iterator index = m_map.find(name); - if (index == m_map.end()) { + // find options + CScreenOptions* options = NULL; + if (name.empty()) { + options = &m_globalOptions; + } + else { + CCellMap::iterator index = m_map.find(name); + if (index != m_map.end()) { + options = &index->second.m_options; + } + } + if (options == NULL) { return false; } // remove option - index->second.m_options.erase(option); + options->erase(option); return true; } bool CConfig::removeOptions(const CString& name) { - // find cell - CCellMap::iterator index = m_map.find(name); - if (index == m_map.end()) { + // find options + CScreenOptions* options = NULL; + if (name.empty()) { + options = &m_globalOptions; + } + else { + CCellMap::iterator index = m_map.find(name); + if (index != m_map.end()) { + options = &index->second.m_options; + } + } + if (options == NULL) { return false; } - // remove option - index->second.m_options.clear(); + // remove options + options->clear(); return true; } @@ -405,14 +432,20 @@ CConfig::getHTTPAddress() const const CConfig::CScreenOptions* CConfig::getOptions(const CString& name) const { - // find cell - CCellMap::const_iterator index = m_map.find(name); - if (index == m_map.end()) { - return NULL; + // find options + const CScreenOptions* options = NULL; + if (name.empty()) { + options = &m_globalOptions; + } + else { + CCellMap::const_iterator index = m_map.find(name); + if (index != m_map.end()) { + options = &index->second.m_options; + } } // return options - return &index->second.m_options; + return options; } bool @@ -433,6 +466,11 @@ CConfig::operator==(const CConfig& x) const return false; } + // compare global options + if (m_globalOptions != x.m_globalOptions) { + return false; + } + for (CCellMap::const_iterator index1 = m_map.begin(), index2 = x.m_map.begin(); index1 != m_map.end(); ++index1, ++index2) { diff --git a/lib/server/CConfig.h b/lib/server/CConfig.h index a2fd31b3..ea0fcd5e 100644 --- a/lib/server/CConfig.h +++ b/lib/server/CConfig.h @@ -308,6 +308,7 @@ private: CNameMap m_nameToCanonicalName; CNetworkAddress m_synergyAddress; CNetworkAddress m_httpAddress; + CScreenOptions m_globalOptions; }; //! Configuration stream read exception