Merged SoC teaser tasks solutions
This commit is contained in:
parent
cf4730e69f
commit
e84ea9b102
4 changed files with 21 additions and 1 deletions
|
@ -56,6 +56,8 @@ class TemplatePlugin : public NetworkPlugin {
|
|||
|
||||
void handleLoginRequest(const std::string &user, const std::string &legacyName, const std::string &password) {
|
||||
handleConnected(user);
|
||||
LOG4CXX_INFO(logger, user << ": Added buddy - Echo.");
|
||||
handleBuddyChanged(user, "echo", "Echo", std::vector<std::string>(), pbnetwork::STATUS_ONLINE);
|
||||
}
|
||||
|
||||
void handleLogoutRequest(const std::string &user, const std::string &legacyName) {
|
||||
|
@ -63,6 +65,9 @@ class TemplatePlugin : public NetworkPlugin {
|
|||
|
||||
void handleMessageSendRequest(const std::string &user, const std::string &legacyName, const std::string &message, const std::string &xhtml = "") {
|
||||
LOG4CXX_INFO(logger, "Sending message from " << user << " to " << legacyName << ".");
|
||||
if (legacyName == "echo") {
|
||||
handleMessage(user, legacyName, message);
|
||||
}
|
||||
}
|
||||
|
||||
void handleBuddyUpdatedRequest(const std::string &user, const std::string &buddyName, const std::string &alias, const std::vector<std::string> &groups) {
|
||||
|
|
|
@ -257,6 +257,14 @@ void AdminInterface::handleMessageReceived(Swift::Message::ref message) {
|
|||
}
|
||||
message->setBody(lst);
|
||||
}
|
||||
else if (message->getBody() == "messages_from_xmpp") {
|
||||
int msgCount = m_userManager->getMessagesToBackend();
|
||||
message->setBody(boost::lexical_cast<std::string>(msgCount));
|
||||
}
|
||||
else if (message->getBody() == "messages_to_xmpp") {
|
||||
int msgCount = m_userManager->getMessagesToXMPP();
|
||||
message->setBody(boost::lexical_cast<std::string>(msgCount));
|
||||
}
|
||||
else if (message->getBody().find("help") == 0) {
|
||||
std::string help;
|
||||
help += "General:\n";
|
||||
|
@ -267,6 +275,9 @@ void AdminInterface::handleMessageReceived(Swift::Message::ref message) {
|
|||
help += " online_users_count - number of online users\n";
|
||||
help += " online_users_per_backend - shows online users per backends\n";
|
||||
help += " has_online_user <bare_JID> - returns 1 if user is online\n";
|
||||
help += "Messages:\n";
|
||||
help += " messages_from_xmpp - get number of messages received from XMPP users\n";
|
||||
help += " messages_to_xmpp - get number of messages sent to XMPP users\n";
|
||||
help += "Backends:\n";
|
||||
help += " backends_count - number of active backends\n";
|
||||
help += " crashed_backends - returns IDs of crashed backends\n";
|
||||
|
|
|
@ -99,6 +99,8 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
|
|||
("registration.local_username_label", value<std::string>()->default_value("Local username:"), "Label for local usernme field")
|
||||
("registration.local_account_server", value<std::string>()->default_value("localhost"), "The server on which the local accounts will be checked for validity")
|
||||
("registration.local_account_server_timeout", value<int>()->default_value(10000), "Timeout when checking local user on local_account_server (msecs)")
|
||||
("gateway_responder.prompt", value<std::string>()->default_value("Contact ID"), "Value of <prompt> </promt> field")
|
||||
("gateway_responder.label", value<std::string>()->default_value("Enter legacy network contact ID."), "Label for add contact ID field")
|
||||
("database.type", value<std::string>()->default_value("none"), "Database type.")
|
||||
("database.database", value<std::string>()->default_value("/var/lib/spectrum2/$jid/database.sql"), "Database used to store data")
|
||||
("database.server", value<std::string>()->default_value("localhost"), "Database server.")
|
||||
|
|
|
@ -45,7 +45,9 @@ GatewayResponder::~GatewayResponder() {
|
|||
}
|
||||
|
||||
bool GatewayResponder::handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::GatewayPayload> payload) {
|
||||
sendResponse(from, id, boost::shared_ptr<GatewayPayload>(new GatewayPayload(Swift::JID(), "Enter legacy network contact ID.", "Contact ID")));
|
||||
std::string prompt = CONFIG_STRING(m_userManager->getComponent()->getConfig(), "gateway_responder.prompt");
|
||||
std::string label = CONFIG_STRING(m_userManager->getComponent()->getConfig(), "gateway_responder.label");
|
||||
sendResponse(from, id, boost::shared_ptr<GatewayPayload>(new GatewayPayload(Swift::JID(), label, prompt)));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue