}
bool SendMessageFunction(const SGCONF::CONFIG & config,
- const std::string & arg,
+ const std::string & /*arg*/,
const std::map<std::string, std::string> & options)
{
-// TODO
-std::cerr << "Unimplemented.\n";
-return false;
+std::map<std::string, std::string>::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
int SERVCONF::SendMessage(const std::string & login, const std::string & text, SIMPLE::CALLBACK f, void * data)
{
-return pImpl->Exec<SIMPLE::PARSER>("SendMessage", "<Message login=\"" + login + "\" msgver=\"1\" msgtype=\"1\" repeat=\"0\" repeatperiod=\"0\" showtime=\"0\" text=\"" + Encode12str(text) + "\"/>", f, data);
+return pImpl->Exec<SIMPLE::PARSER>("SendMessageResult", "<Message login=\"" + login + "\" msgver=\"1\" msgtype=\"1\" repeat=\"0\" repeatperiod=\"0\" showtime=\"0\" text=\"" + Encode12str(text) + "\"/>", f, data);
}
int SERVCONF::CheckUser(const std::string & login, const std::string & password, SIMPLE::CALLBACK f, void * data)