X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/1b2ab8e6d556a8ed30d4feadc72263b3f4c86665..fe97f14f9caa463e2bc6b81124ce5e9553bc924d:/projects/stargazer/plugins/configuration/sgconfig/parser_user_info.cpp diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_user_info.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser_user_info.cpp index 72c3c6ec..a4a808d2 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_user_info.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_user_info.cpp @@ -20,51 +20,43 @@ #include "parser_user_info.h" +#include "stg/users.h" #include "stg/user.h" #include "stg/common.h" #include // strcasecmp -int PARSER_USER_INFO::ParseStart(void * /*data*/, const char *el, const char **attr) -{ -login.clear(); -if (strcasecmp(el, "GetUserInfo") != 0) - return -1; - -if (!attr[0] || !attr[1] || strcasecmp(attr[0], "login") != 0) - return -1; +using STG::PARSER::USER_INFO; -login = attr[1]; -return 0; -} +const char * USER_INFO::tag = "GetUserInfo"; -int PARSER_USER_INFO::ParseEnd(void * /*data*/, const char *el) +int USER_INFO::Start(void * /*data*/, const char *el, const char **attr) { -if (strcasecmp(el, "GetUserInfo") != 0) - return -1; + if (strcasecmp(el, m_tag.c_str()) != 0) + return -1; -CreateAnswer(); -return 0; + if (!attr[1]) + return -1; + + m_login = attr[1]; + return 0; } -void PARSER_USER_INFO::CreateAnswer() +void USER_INFO::CreateAnswer() { -answerList->clear(); - -CONST_USER_PTR u; -if (users->FindByName(login, &u)) + CONST_USER_PTR u; + if (m_users.FindByName(m_login, &u)) { - answerList->push_back(""); - return; + m_answer = ""; + return; } -std::string s = "GetAuthorizedModificationTime()) + "\"" + - " lastDisconnectTime=\"" + x2str(u->GetConnectedModificationTime()) + "\"" + - " connected=\"" + (u->GetConnected() ? "true" : "false") + "\"" + - " lastDisconnectReason=\"" + u->GetLastDisconnectReason() + "\">"; -std::vector list(u->GetAuthorizers()); -for (std::vector::const_iterator it = list.begin(); it != list.end(); ++it) - s += ""; -s += ""; -answerList->push_back(s); + m_answer = "GetAuthorizedModificationTime()) + "\"" + + " lastDisconnectTime=\"" + x2str(u->GetConnectedModificationTime()) + "\"" + + " connected=\"" + (u->GetConnected() ? "true" : "false") + "\"" + + " lastDisconnectReason=\"" + u->GetLastDisconnectReason() + "\">"; + std::vector list(u->GetAuthorizers()); + for (std::vector::const_iterator it = list.begin(); it != list.end(); ++it) + m_answer += ""; + m_answer += ""; }