From: Maxim Mamontov Date: Wed, 28 May 2014 15:42:41 +0000 (+0300) Subject: Added user-related params. X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/1cabba873c9409b7c01280d9839499e955d3bf58 Added user-related params. --- diff --git a/projects/sgconf/api_action.h b/projects/sgconf/api_action.h index e10840cf..e5f95b2c 100644 --- a/projects/sgconf/api_action.h +++ b/projects/sgconf/api_action.h @@ -108,6 +108,14 @@ ACTION * MakeAPIAction(COMMANDS & commands, return new API_ACTION(commands, paramDescription, true, params, funPtr); } +inline +ACTION * MakeAPIAction(COMMANDS & commands, + const std::vector & params, + API_FUNCTION funPtr) +{ +return new API_ACTION(commands, "", false, params, funPtr); +} + inline ACTION * MakeAPIAction(COMMANDS & commands, const std::string & paramDescription, diff --git a/projects/sgconf/users.cpp b/projects/sgconf/users.cpp index 3e366066..45603199 100644 --- a/projects/sgconf/users.cpp +++ b/projects/sgconf/users.cpp @@ -46,7 +46,6 @@ std::cout << Indent(level, true) << "login: " << info.login << "\n" << Indent(level) << "name: " << info.name << "\n" << Indent(level) << "address: " << info.address << "\n" << Indent(level) << "phone: " << info.phone << "\n" - << Indent(level) << "free mb: " << info.stat.freeMb << "\n" << Indent(level) << "last ping time: " << TimeToString(info.pingTime) << "\n" << Indent(level) << "last activity time: " << TimeToString(info.lastActivityTime) << "\n" << Indent(level) << "traffic:\n"; @@ -69,6 +68,48 @@ if (!info.authBy.empty()) } } +std::vector GetUserParams() +{ +std::vector params; +params.push_back({"password", "", "\tuser's password"}); +params.push_back({"cash", "", "\t\tuser's cash"}); +params.push_back({"credit", "", "\tuser's credit"}); +params.push_back({"credit-expire", "", "\tcredit expiration"}); +params.push_back({"free", "", "\tprepaid traffic"}); +params.push_back({"disabled", "", "\tdisable user (y|n)"}); +params.push_back({"passive", "", "\tmake user passive (y|n)"}); +params.push_back({"disable-detail-stat", "", "disable detail stat (y|n)"}); +params.push_back({"always-online", "", "\tmake user always online (y|n)"}); +params.push_back({"ips", "", "\t\tcoma-separated list of ips"}); +params.push_back({"tariff", "", "\tcurrent tariff"}); +params.push_back({"next-tariff", "", "tariff starting from the next month"}); +params.push_back({"group", "", "\t\tuser's group"}); +params.push_back({"note", "", "\t\tuser's note"}); +params.push_back({"email", "", "\t\tuser's email"}); +params.push_back({"name", "", "\tuser's real name"}); +params.push_back({"address", "
", "\tuser's postal address"}); +params.push_back({"phone", "", "\t\tuser's phone number"}); +params.push_back({"session-traffic", "", "coma-separated session upload and download"}); +params.push_back({"month-traffic", "", "coma-separated month upload and download"}); +params.push_back({"user-data", "", "coma-separated user data values"}); +return params; +} + +std::vector GetCheckParams() +{ +std::vector params; +params.push_back({"password", "", "\tuser's password"}); +return params; +} + +std::vector GetMessageParams() +{ +std::vector params; +params.push_back({"logins", "", "\tlist of logins to send a message"}); +params.push_back({"text", "", "\t\tmessage text"}); +return params; +} + void SimpleCallback(bool result, const std::string & reason, void * /*data*/) @@ -182,12 +223,13 @@ return false; void SGCONF::AppendUsersOptionBlock(COMMANDS & commands, OPTION_BLOCKS & blocks) { +std::vector params(GetUserParams()); blocks.Add("User management options") .Add("get-users", SGCONF::MakeAPIAction(commands, GetUsersFunction), "\tget user list") .Add("get-user", SGCONF::MakeAPIAction(commands, "", GetUserFunction), "get user") - .Add("add-user", SGCONF::MakeAPIAction(commands, "", AddUserFunction), "add user") + .Add("add-user", SGCONF::MakeAPIAction(commands, "", params, AddUserFunction), "add user") .Add("del-user", SGCONF::MakeAPIAction(commands, "", DelUserFunction), "del user") - .Add("chg-user", SGCONF::MakeAPIAction(commands, "", ChgUserFunction), "change user") - .Add("check-user", SGCONF::MakeAPIAction(commands, "", CheckUserFunction), "check user existance and credentials") - .Add("send-message", SGCONF::MakeAPIAction(commands, "", SendMessageFunction), "send message"); + .Add("chg-user", SGCONF::MakeAPIAction(commands, "", params, ChgUserFunction), "change user") + .Add("check-user", SGCONF::MakeAPIAction(commands, "", GetCheckParams(), CheckUserFunction), "check user existance and credentials") + .Add("send-message", SGCONF::MakeAPIAction(commands, GetMessageParams(), SendMessageFunction), "send message"); } diff --git a/stglibs/srvconf.lib/include/stg/servconf_types.h b/stglibs/srvconf.lib/include/stg/servconf_types.h index 7cdf2475..229abb42 100644 --- a/stglibs/srvconf.lib/include/stg/servconf_types.h +++ b/stglibs/srvconf.lib/include/stg/servconf_types.h @@ -130,7 +130,6 @@ struct STAT ARRAY sd; ARRAY mu; ARRAY md; - double freeMb; }; struct INFO