Changeset - d9fd5794d8a3
[Not reviewed]
0 5 0
HanzZ - 14 years ago 2011-06-12 17:22:56
hanzz.k@gmail.com
New config variables
5 files changed with 14 insertions and 11 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/main.cpp
Show inline comments
 
@@ -630,15 +630,12 @@ static PurpleCoreUiOps coreUiOps =
 
	NULL,
 
	NULL,
 
	NULL
 
};
 

	
 
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]);
 
}
 

	
 
static void printDebug(PurpleDebugLevel level, const char *category, const char *arg_s) {
 
	std::string c("[LIBPURPLE");
spectrum/src/sample.cfg
Show inline comments
 
[service]
 
jid = localhost
 
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
 
#protocol=prpl-msn
 
#protocol=prpl-icq
 

	
src/config.cpp
Show inline comments
 
@@ -36,12 +36,15 @@ bool Config::load(const std::string &configfile, boost::program_options::options
 
		("service.password", value<std::string>()->default_value(""), "Password used to auth the server")
 
		("service.port", value<int>()->default_value(0), "Port the server is listening on")
 
		("service.backend", value<std::string>()->default_value("libpurple_backend"), "Backend")
 
		("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")
 
		("registration.username_field", value<std::string>()->default_value(""), "Label for username field")
 
		("registration.username_mask", value<std::string>()->default_value(""), "Username mask")
 
		("registration.encoding", value<std::string>()->default_value("en"), "Default encoding in registration form")
src/conversationmanager.cpp
Show inline comments
 
@@ -34,14 +34,14 @@ ConversationManager::ConversationManager(User *user, Component *component){
 
	m_user = user;
 
	m_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());
 
	}
 
}
 

	
 
void ConversationManager::addConversation(Conversation *conv) {
 
	m_convs[conv->getLegacyName()] = conv;
 
}
src/networkpluginserver.cpp
Show inline comments
 
@@ -130,19 +130,19 @@ NetworkPluginServer::NetworkPluginServer(Component *component, Config *config, U
 
	m_rosterResponder = new RosterResponder(component->getIQRouter(), userManager);
 
	m_rosterResponder->onBuddyAdded.connect(boost::bind(&NetworkPluginServer::handleBuddyAdded, this, _1, _2));
 
	m_rosterResponder->onBuddyRemoved.connect(boost::bind(&NetworkPluginServer::handleBuddyRemoved, this, _1));
 
	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() {
 
	m_pingTimer->stop();
 
	delete m_vcardResponder;
 
	delete m_rosterResponder;
 
@@ -173,13 +173,13 @@ void NetworkPluginServer::handleSessionFinished(Client *c) {
 
	// Execute new session only if there's no free one after this crash/disconnection
 
	for (std::list<Client *>::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) {
 
		if ((*it)->users.size() < 1) {
 
			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) {
 
	pbnetwork::Connected payload;
 
	std::cout << "CONNECTED LOGIN 2 " << payload.user() << "\n";
 
	if (payload.ParseFromString(data) == false) {
 
@@ -425,13 +425,13 @@ void NetworkPluginServer::pingTimeout() {
 
	for (std::list<Client *>::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) {
 
		if ((*it)->pongReceived) {
 
			sendPing((*it));
 
			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());
 
		}
 
	}
 
}
 

	
 
void NetworkPluginServer::handleUserCreated(User *user) {
 
	Client *c = getFreeClient();
 
@@ -680,15 +680,15 @@ void NetworkPluginServer::sendPing(Client *c) {
 
	c->pongReceived = false;
 
	std::cout << "SENDING PING\n";
 
}
 

	
 
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);
 
		}
 
	}
 
	return NULL;
 
}
0 comments (0 inline, 0 general)