Replace in portfile option

This commit is contained in:
Jan Kaluza 2012-07-30 10:05:35 +02:00
parent f75c6e8a70
commit dc478a0cfa
2 changed files with 10 additions and 0 deletions

View file

@ -20,6 +20,7 @@ protocol=prpl-msn
#protocol=any
#protocol=prpl-icq
working_dir=./
portfile=$jid.port
[backend]
#default_avatar=catmelonhead.jpg

View file

@ -134,6 +134,7 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
bool found_working = false;
bool found_pidfile = false;
bool found_portfile = false;
bool found_backend_port = false;
bool found_database = false;
std::string jid = "";
@ -159,6 +160,9 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
else if (opt.string_key == "service.pidfile") {
found_pidfile = true;
}
else if (opt.string_key == "service.portfile") {
found_portfile = true;
}
else if (opt.string_key == "database.database") {
found_database = true;
}
@ -174,6 +178,11 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
value.push_back("/var/run/spectrum2/$jid.pid");
parsed.options.push_back(boost::program_options::basic_option<char>("service.pidfile", value));
}
if (!found_portfile) {
std::vector<std::string> value;
value.push_back("/var/run/spectrum2/$jid.port");
parsed.options.push_back(boost::program_options::basic_option<char>("service.portfile", value));
}
if (!found_backend_port) {
std::vector<std::string> value;
std::string p = boost::lexical_cast<std::string>(getRandomPort(_jid.empty() ? jid : _jid));