New config variables

This commit is contained in:
HanzZ 2011-06-12 17:22:56 +02:00
parent 83bf526fbc
commit d9fd5794d8
5 changed files with 14 additions and 11 deletions

View file

@ -633,9 +633,6 @@ static PurpleCoreUiOps coreUiOps =
};
static void signed_on(PurpleConnection *gc, gpointer unused) {
for (int i = 0; i<1500; i++) {
std::cout << "A\n";
}
PurpleAccount *account = purple_connection_get_account(gc);
np->handleConnected(np->m_accounts[account]);
}

View file

@ -4,6 +4,9 @@ password = secret
server = 127.0.0.1
port = 5222
server_mode = 1
backend_host=localhost # < this option doesn't work yet
backend_port=10001
users_per_backend=2
backend=../../backends/libpurple/libpurple_backend
#backend=../../backends/libircclient-qt/libircclient-qt_backend
protocol=prpl-jabber

View file

@ -39,6 +39,9 @@ bool Config::load(const std::string &configfile, boost::program_options::options
("service.protocol", value<std::string>()->default_value(""), "Protocol")
("service.allowed_servers", value<std::string>()->default_value(""), "Only users from these servers can connect")
("service.server_mode", value<bool>()->default_value(false), "True if Spectrum should behave as server")
("service.users_per_backend", value<int>()->default_value(100), "Number of users per one legacy network backend")
("service.backend_host", value<std::string>()->default_value("localhost"), "Host to bind backend server to")
("service.backend_port", value<std::string>()->default_value("10000"), "Port to bind backend server to")
("registration.enable_public_registration", value<bool>()->default_value(true), "True if users should be able to register.")
("registration.language", value<std::string>()->default_value("en"), "Default language for registration form")
("registration.instructions", value<std::string>()->default_value(""), "Instructions showed to user in registration form")

View file

@ -37,8 +37,8 @@ ConversationManager::ConversationManager(User *user, Component *component){
ConversationManager::~ConversationManager() {
while(!m_convs.empty()) {
m_convs.erase(m_convs.begin());
delete (*m_convs.begin()).second;
m_convs.erase(m_convs.begin());
}
}

View file

@ -133,13 +133,13 @@ NetworkPluginServer::NetworkPluginServer(Component *component, Config *config, U
m_rosterResponder->onBuddyUpdated.connect(boost::bind(&NetworkPluginServer::handleBuddyUpdated, this, _1, _2));
m_rosterResponder->start();
m_server = component->getNetworkFactories()->getConnectionFactory()->createConnectionServer(10000);
m_server = component->getNetworkFactories()->getConnectionFactory()->createConnectionServer(boost::lexical_cast<int>(CONFIG_STRING(m_config, "service.backend_port")));
m_server->onNewConnection.connect(boost::bind(&NetworkPluginServer::handleNewClientConnection, this, _1));
m_server->start();
signal(SIGCHLD, SigCatcher);
exec_(CONFIG_STRING(m_config, "service.backend").c_str(), "localhost", "10000", m_config->getConfigFile().c_str());
exec_(CONFIG_STRING(m_config, "service.backend").c_str(), CONFIG_STRING(m_config, "service.backend_host").c_str(), CONFIG_STRING(m_config, "service.backend_port").c_str(), m_config->getConfigFile().c_str());
}
NetworkPluginServer::~NetworkPluginServer() {
@ -176,7 +176,7 @@ void NetworkPluginServer::handleSessionFinished(Client *c) {
return;
}
}
exec_(CONFIG_STRING(m_config, "service.backend").c_str(), "localhost", "10000", m_config->getConfigFile().c_str());
exec_(CONFIG_STRING(m_config, "service.backend").c_str(), CONFIG_STRING(m_config, "service.backend_host").c_str(), CONFIG_STRING(m_config, "service.backend_port").c_str(), m_config->getConfigFile().c_str());
}
void NetworkPluginServer::handleConnectedPayload(const std::string &data) {
@ -428,7 +428,7 @@ void NetworkPluginServer::pingTimeout() {
m_pingTimer->start();
}
else {
exec_(CONFIG_STRING(m_config, "service.backend").c_str(), "localhost", "10000", m_config->getConfigFile().c_str());
exec_(CONFIG_STRING(m_config, "service.backend").c_str(), CONFIG_STRING(m_config, "service.backend_host").c_str(), CONFIG_STRING(m_config, "service.backend_port").c_str(), m_config->getConfigFile().c_str());
}
}
}
@ -683,9 +683,9 @@ void NetworkPluginServer::sendPing(Client *c) {
NetworkPluginServer::Client *NetworkPluginServer::getFreeClient() {
for (std::list<Client *>::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) {
if ((*it)->users.size() < 1) {
if ((*it)->users.size() + 1 == 1) {
exec_(CONFIG_STRING(m_config, "service.backend").c_str(), "localhost", "10000", m_config->getConfigFile().c_str());
if ((*it)->users.size() < CONFIG_INT(m_config, "service.users_per_backend")) {
if ((*it)->users.size() + 1 == CONFIG_INT(m_config, "service.users_per_backend")) {
exec_(CONFIG_STRING(m_config, "service.backend").c_str(), CONFIG_STRING(m_config, "service.backend_host").c_str(), CONFIG_STRING(m_config, "service.backend_port").c_str(), m_config->getConfigFile().c_str());
}
return (*it);
}