X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/1b2ab8e6d556a8ed30d4feadc72263b3f4c86665..05e29980ab6ee71b0436f7ca58d109a79a512b0f:/stglibs/srvconf.lib/servconf.cpp?ds=sidebyside

diff --git a/stglibs/srvconf.lib/servconf.cpp b/stglibs/srvconf.lib/servconf.cpp
index 430de3c1..0f91a563 100644
--- a/stglibs/srvconf.lib/servconf.cpp
+++ b/stglibs/srvconf.lib/servconf.cpp
@@ -60,6 +60,7 @@ class SERVCONF::IMPL
 public:
     IMPL(const std::string & server, uint16_t port,
          const std::string & login, const std::string & password);
+    ~IMPL() { XML_ParserFree(parser); }
 
     const std::string & GetStrError() const;
     static void Start(void * data, const char * el, const char ** attr);
@@ -224,9 +225,15 @@ int SERVCONF::DelUser(const std::string & login, SIMPLE::CALLBACK f, void * data
 return pImpl->Exec<SIMPLE::PARSER>("DelUser", "<DelUser login=\"" + login + "\"/>", f, data);
 }
 
-int SERVCONF::AddUser(const std::string & login, SIMPLE::CALLBACK f, void * data)
+int SERVCONF::AddUser(const std::string & login,
+                      const USER_CONF_RES & conf,
+                      const USER_STAT_RES & stat,
+                      SIMPLE::CALLBACK f, void * data)
 {
-return pImpl->Exec<SIMPLE::PARSER>("AddUser", "<AddUser><Login value=\"" + login + "\"/></AddUser>", f, data);
+int res = pImpl->Exec<SIMPLE::PARSER>("AddUser", "<AddUser><Login value=\"" + login + "\"/></AddUser>", f, data);
+if (res != st_ok)
+    return res;
+return pImpl->Exec<CHG_USER::PARSER>("<SetUser><Login value=\"" + login + "\"/>" + CHG_USER::Serialize(conf, stat) + "</SetUser>", f, data);
 }
 
 int SERVCONF::AuthBy(const std::string & login, AUTH_BY::CALLBACK f, void * data)
@@ -236,7 +243,7 @@ return pImpl->Exec<AUTH_BY::PARSER>("<GetUserAuthBy login=\"" + login + "\"/>",
 
 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)
@@ -348,11 +355,13 @@ int ret = 0;
 if ((ret = nt.Connect()) != st_ok)
     {
     errorMsg = nt.GetError();
+    cp.Failure(errorMsg);
     return ret;
     }
 if ((ret = nt.Transact(request, ParserRecv, this)) != st_ok)
     {
     errorMsg = nt.GetError();
+    cp.Failure(errorMsg);
     return ret;
     }