Changeset - c4eda8c23b75
[Not reviewed]
0 3 0
Jan Kaluza - 9 years ago 2016-02-01 18:18:28
jkaluza@redhat.com
Web interface: Use [identity] name instead of hostname when set
3 files changed with 17 insertions and 7 deletions:
0 comments (0 inline, 0 general)
spectrum_manager/src/APIServer.cpp
Show inline comments
 
@@ -91,13 +91,21 @@ void APIServer::serve_instances(Server *server, Server::session *session, struct
 

	
 
	Value instances(kArrayType);
 
	BOOST_FOREACH(std::string &id, list) {
 
		Value instance;
 
		instance.SetObject();
 
		instance.AddMember("id", id.c_str(), json.GetAllocator());
 
		instance.AddMember("name", id.c_str(), json.GetAllocator());
 

	
 
		std::string name = get_config(m_config, id, "identity.name");
 
		if (name.empty() || name == "Spectrum 2 Transport") {
 
			instance.AddMember("name", id.c_str(), json.GetAllocator());
 
		}
 
		else {
 
			statuses.push_back(name);
 
			instance.AddMember("name", statuses.back().c_str(), json.GetAllocator());
 
		}
 

	
 
		std::string status = server->send_command(id, "status");
 
		if (status.empty()) {
 
			status = "Cannot get the instance status.";
 
		}
 

	
 
@@ -116,13 +124,15 @@ void APIServer::serve_instances(Server *server, Server::session *session, struct
 
		int type = (int) TYPE_STRING;
 
		m_storage->getUserSetting(info.id, id, type, username);
 

	
 
		usernames.push_back(username);
 
		instance.AddMember("registered", !username.empty(), json.GetAllocator());
 
		instance.AddMember("username", usernames.back().c_str(), json.GetAllocator());
 
		instance.AddMember("frontend", is_slack(m_config, id) ? "slack" : "xmpp", json.GetAllocator());
 

	
 
		usernames.push_back(get_config(m_config, id, "service.frontend"));
 
		instance.AddMember("frontend", usernames.back().c_str(), json.GetAllocator());
 

	
 
		instances.PushBack(instance, json.GetAllocator());
 
	}
 

	
 
	json.AddMember("instances", instances, json.GetAllocator());
 
	send_json(conn, json);
spectrum_manager/src/methods.cpp
Show inline comments
 
@@ -498,13 +498,13 @@ static void handleConnected(boost::shared_ptr<Swift::Connection> m_conn, const s
 
		
 
		// send header together with wrapper message
 
		m_conn->write(Swift::createSafeByteArray(std::string(header, 4) + message));
 
	}
 
}
 

	
 
bool is_slack(ManagerConfig *config, const std::string &jid) {
 
std::string get_config(ManagerConfig *config, const std::string &jid, const std::string &key) {
 
	path p(CONFIG_STRING(config, "service.config_directory"));
 

	
 
	try {
 
		if (!exists(p)) {
 
			std::cerr << "Config directory " << CONFIG_STRING(config, "service.config_directory") << " does not exist\n";
 
			exit(6);
 
@@ -525,22 +525,22 @@ bool is_slack(ManagerConfig *config, const std::string &jid) {
 
				}
 

	
 
				if (CONFIG_STRING(&cfg, "service.jid") != jid) {
 
					continue;
 
				}
 

	
 
				return CONFIG_STRING(&cfg, "service.frontend") == "slack";
 
				return CONFIG_STRING(&cfg, key);
 
			}
 
		}
 

	
 
	}
 
	catch (const filesystem_error& ex) {
 
		return false;
 
		return "";
 
	}
 

	
 
	return false;
 
	return "";
 
}
 

	
 
void ask_local_server(ManagerConfig *config, Swift::BoostNetworkFactories &networkFactories, const std::string &jid, const std::string &message) {
 
	response = "";
 
	path p(CONFIG_STRING(config, "service.config_directory"));
 

	
spectrum_manager/src/methods.h
Show inline comments
 
@@ -48,11 +48,11 @@ int start_instances(ManagerConfig *config, const std::string &_jid = "");
 
int restart_instances(ManagerConfig *config, const std::string &_jid = "");
 
void stop_instances(ManagerConfig *config, const std::string &_jid = "");
 

	
 
int show_status(ManagerConfig *config);
 

	
 
void ask_local_server(ManagerConfig *config, Swift::BoostNetworkFactories &networkFactories, const std::string &jid, const std::string &message);
 
bool is_slack(ManagerConfig *config, const std::string &jid);
 
std::string get_config(ManagerConfig *config, const std::string &jid, const std::string &key);
 

	
 
std::vector<std::string> show_list(ManagerConfig *config, bool show = true);
 

	
 
std::string get_response();
0 comments (0 inline, 0 general)