From: Maxim Mamontov Date: Tue, 8 Oct 2013 15:20:15 +0000 (+0300) Subject: Changes in SendMessage method. X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/2a1f23881feba670f3bb614e19409b5f4e90b211 Changes in SendMessage method. --- diff --git a/projects/sgconf/common_sg.cpp b/projects/sgconf/common_sg.cpp index cf0469a3..b899fc06 100644 --- a/projects/sgconf/common_sg.cpp +++ b/projects/sgconf/common_sg.cpp @@ -460,12 +460,12 @@ return true; //----------------------------------------------------------------------------- bool ProcessSendMessage(const std::string & server, uint16_t port, const std::string & login, const std::string & password, - const std::string & requestString) + const std::string & user, const std::string & text) { SERVCONF sc(server, port, login, password); ResultData data; -int res = sc.SendMessage(requestString.c_str(), ResultCallback, &data); +int res = sc.SendMessage(user, text, ResultCallback, &data); if (res == st_ok && data.result) { diff --git a/projects/sgconf/common_sg.h b/projects/sgconf/common_sg.h index 87b8509b..59e27a37 100644 --- a/projects/sgconf/common_sg.h +++ b/projects/sgconf/common_sg.h @@ -67,6 +67,6 @@ bool ProcessSetUser(const std::string & server, bool ProcessSendMessage(const std::string & server, uint16_t port, const std::string & login, const std::string & password, - const std::string & requestString); + const std::string & user, const std::string & text); #endif diff --git a/projects/sgconf/main.cpp b/projects/sgconf/main.cpp index df1cca4b..8fc66b5c 100644 --- a/projects/sgconf/main.cpp +++ b/projects/sgconf/main.cpp @@ -1084,7 +1084,7 @@ memset(rstr, 0, rLen); CreateRequestSet(&req, rstr); if (isMessage) - return ProcessSendMessage(req.server.data(), req.port.data(), req.admLogin.data(), req.admPasswd.data(), rstr); + return ProcessSendMessage(req.server.data(), req.port.data(), req.admLogin.data(), req.admPasswd.data(), req.login.data(), req.usrMsg.data()); return ProcessSetUser(req.server.data(), req.port.data(), req.admLogin.data(), req.admPasswd.data(), rstr); } diff --git a/stglibs/common.lib/common.cpp b/stglibs/common.lib/common.cpp index 763df532..b871b36b 100644 --- a/stglibs/common.lib/common.cpp +++ b/stglibs/common.lib/common.cpp @@ -347,6 +347,20 @@ for (size_t i = 0; i < src.length() / 2; i++) } } //--------------------------------------------------------------------------- +std::string Encode12str(const std::string & src) +{ +std::string res; +Encode12str(res, src); +return res; +} +//--------------------------------------------------------------------------- +std::string Decode21str(const std::string & src) +{ +std::string res; +Decode21str(res, src); +return res; +} +//--------------------------------------------------------------------------- void Encode12(char * dst, const char * src, size_t srcLen) { for (size_t i = 0; i <= srcLen; i++) diff --git a/stglibs/common.lib/include/stg/common.h b/stglibs/common.lib/include/stg/common.h index 6c71289b..524a3431 100644 --- a/stglibs/common.lib/include/stg/common.h +++ b/stglibs/common.lib/include/stg/common.h @@ -65,6 +65,8 @@ void Decode21(char * dst, const char * src); void Encode12str(std::string & dst, const std::string & src); void Decode21str(std::string & dst, const std::string & src); +std::string Encode12str(const std::string & src); +std::string Decode21str(const std::string & src); int ParseIPString(const char * str, uint32_t * ips, int maxIP); void KOIToWin(const char * s1, char * s2, int l); diff --git a/stglibs/srvconf.lib/include/stg/servconf.h b/stglibs/srvconf.lib/include/stg/servconf.h index 0b929317..63987fd8 100644 --- a/stglibs/srvconf.lib/include/stg/servconf.h +++ b/stglibs/srvconf.lib/include/stg/servconf.h @@ -55,8 +55,10 @@ public: int GetUsers(GET_USERS::CALLBACK f, void * data); int GetUser(const std::string & login, GET_USER::CALLBACK f, void * data); int ChgUser(const std::string & request, SIMPLE::CALLBACK f, void * data); + int DelUser(const std::string & login, SIMPLE::CALLBACK f, void * data); + int AddUser(const std::string & login, SIMPLE::CALLBACK f, void * data); int AuthBy(const std::string & login, AUTH_BY::CALLBACK f, void * data); - int SendMessage(const std::string & request, SIMPLE::CALLBACK f, void * data); + int SendMessage(const std::string & login, const std::string & text, SIMPLE::CALLBACK f, void * data); int CheckUser(const std::string & login, const std::string & password, SIMPLE::CALLBACK f, void * data); const std::string & GetStrError() const; diff --git a/stglibs/srvconf.lib/servconf.cpp b/stglibs/srvconf.lib/servconf.cpp index d885fae6..950669f2 100644 --- a/stglibs/srvconf.lib/servconf.cpp +++ b/stglibs/srvconf.lib/servconf.cpp @@ -159,14 +159,24 @@ int SERVCONF::ChgUser(const std::string & request, SIMPLE::CALLBACK f, void * da return pImpl->Exec(request, f, data); } +int SERVCONF::DelUser(const std::string & login, SIMPLE::CALLBACK f, void * data) +{ +return pImpl->Exec("DelUser", "", f, data); +} + +int SERVCONF::AddUser(const std::string & login, SIMPLE::CALLBACK f, void * data) +{ +return pImpl->Exec("AddUser", "", f, data); +} + int SERVCONF::AuthBy(const std::string & login, AUTH_BY::CALLBACK f, void * data) { return pImpl->Exec("", f, data); } -int SERVCONF::SendMessage(const std::string & request, SIMPLE::CALLBACK f, void * data) +int SERVCONF::SendMessage(const std::string & login, const std::string & text, SIMPLE::CALLBACK f, void * data) { -return pImpl->Exec("SendMessage", request, f, data); +return pImpl->Exec("SendMessage", "", f, data); } int SERVCONF::CheckUser(const std::string & login, const std::string & password, SIMPLE::CALLBACK f, void * data)