From 8b5d7715bf0eb81d5627267b7bcb42cbc5d5e2f0 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Thu, 29 May 2014 18:05:42 +0300 Subject: [PATCH] Implemented send-message. --- projects/sgconf/users.cpp | 21 +++++++++++++++++---- stglibs/srvconf.lib/servconf.cpp | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/projects/sgconf/users.cpp b/projects/sgconf/users.cpp index 680625c2..8b341b6f 100644 --- a/projects/sgconf/users.cpp +++ b/projects/sgconf/users.cpp @@ -216,12 +216,25 @@ return proto.CheckUser(arg, it->second, SimpleCallback, NULL) == STG::st_ok; } bool SendMessageFunction(const SGCONF::CONFIG & config, - const std::string & arg, + const std::string & /*arg*/, const std::map & options) { -// TODO -std::cerr << "Unimplemented.\n"; -return false; +std::map::const_iterator it(options.find("logins")); +if (it == options.end()) + throw SGCONF::ACTION::ERROR("Logins are not specified."); +std::string logins = it->second; +for (size_t i = 0; i < logins.length(); ++i) + if (logins[i] == ',') + logins[i] = ':'; +it = options.find("text"); +if (it == options.end()) + throw SGCONF::ACTION::ERROR("Message text is not specified."); +std::string text = it->second; +STG::SERVCONF proto(config.server.data(), + config.port.data(), + config.userName.data(), + config.userPass.data()); +return proto.SendMessage(logins, text, SimpleCallback, NULL) == STG::st_ok; } } // namespace anonymous diff --git a/stglibs/srvconf.lib/servconf.cpp b/stglibs/srvconf.lib/servconf.cpp index e7ecfdf4..915691cf 100644 --- a/stglibs/srvconf.lib/servconf.cpp +++ b/stglibs/srvconf.lib/servconf.cpp @@ -237,7 +237,7 @@ return pImpl->Exec("", int SERVCONF::SendMessage(const std::string & login, const std::string & text, SIMPLE::CALLBACK f, void * data) { -return pImpl->Exec("SendMessage", "", f, data); +return pImpl->Exec("SendMessageResult", "", f, data); } int SERVCONF::CheckUser(const std::string & login, const std::string & password, SIMPLE::CALLBACK f, void * data) -- 2.44.2