parse unregistered config options and working [purple] options parsing
This commit is contained in:
parent
2e0b797ae0
commit
b2fd4a4563
4 changed files with 27 additions and 1 deletions
|
@ -231,6 +231,15 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
|||
purple_account_set_bool(account, "custom_smileys", FALSE);
|
||||
purple_account_set_bool(account, "direct_connect", FALSE);
|
||||
|
||||
for (std::map<std::string,std::string>::const_iterator it = config->getUnregistered().begin();
|
||||
it != config->getUnregistered().end(); it++) {
|
||||
if ((*it).first.find("purple.") == 0) {
|
||||
std::string key = (*it).first.substr((*it).first.find(".") + 1);
|
||||
LOG4CXX_INFO(logger, "Setting account string '" << key << "'='" << (*it).second << "'");
|
||||
purple_account_set_string(account, key.c_str(), (*it).second.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
purple_account_set_privacy_type(account, PURPLE_PRIVACY_DENY_USERS);
|
||||
|
||||
const PurpleStatusType *status_type = purple_account_get_status_type_with_primitive(account, PURPLE_STATUS_AVAILABLE);
|
||||
|
|
|
@ -82,11 +82,16 @@ class Config {
|
|||
/// Returns path to config file from which data were loaded.
|
||||
const std::string &getConfigFile() { return m_file; }
|
||||
|
||||
const std::map<std::string, std::string> &getUnregistered() {
|
||||
return m_unregistered;
|
||||
}
|
||||
|
||||
/// This signal is emitted when config is loaded/reloaded.
|
||||
boost::signal<void ()> onConfigReloaded;
|
||||
|
||||
private:
|
||||
Variables m_variables;
|
||||
std::map<std::string, std::string> m_unregistered;
|
||||
std::string m_file;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@ protocol=any
|
|||
|
||||
[backend]
|
||||
default_avatar=catmelonhead.jpg
|
||||
[purple]
|
||||
test=test1
|
||||
test2=test3
|
||||
|
||||
[logging]
|
||||
#config=logging.cfg # log4cxx/log4j logging configuration file
|
||||
|
|
|
@ -26,6 +26,7 @@ using namespace boost::program_options;
|
|||
namespace Transport {
|
||||
|
||||
bool Config::load(const std::string &configfile, boost::program_options::options_description &opts) {
|
||||
m_unregistered.clear();
|
||||
std::ifstream ifs(configfile.c_str());
|
||||
if (!ifs.is_open())
|
||||
return false;
|
||||
|
@ -71,7 +72,15 @@ bool Config::load(const std::string &configfile, boost::program_options::options
|
|||
("backend.avatars_directory", value<std::string>()->default_value(""), "Path to directory with avatars")
|
||||
;
|
||||
|
||||
store(parse_config_file(ifs, opts), m_variables);
|
||||
parsed_options parsed = parse_config_file(ifs, opts, true);
|
||||
|
||||
BOOST_FOREACH(option opt, parsed.options) {
|
||||
if (opt.unregistered) {
|
||||
m_unregistered[opt.string_key] = opt.value[0];
|
||||
}
|
||||
}
|
||||
|
||||
store(parsed, m_variables);
|
||||
notify(m_variables);
|
||||
|
||||
m_file = configfile;
|
||||
|
|
Loading…
Add table
Reference in a new issue