1 #include "info_methods.h"
5 #include "stg/tariffs.h"
6 #include "stg/version.h"
7 #include "stg/common.h"
10 #include <ostream> // xmlrpc-c devs have missed something :)
12 #include <sys/utsname.h>
14 void METHOD_INFO::execute(xmlrpc_c::paramList const & paramList,
15 xmlrpc_c::value * const retvalPtr)
17 paramList.verifyEnd(0);
18 std::map<std::string, xmlrpc_c::value> structVal;
34 structVal["version"] = xmlrpc_c::value_string(SERVER_VERSION);
35 structVal["tariff_num"] = xmlrpc_c::value_int(static_cast<int>(tariffs->Count()));
36 structVal["tariff"] = xmlrpc_c::value_int(2);
37 structVal["users_num"] = xmlrpc_c::value_int(static_cast<int>(users->Count()));
38 structVal["uname"] = xmlrpc_c::value_string(un);
39 structVal["dir_num"] = xmlrpc_c::value_int(DIR_NUM);
40 structVal["day_fee"] = xmlrpc_c::value_int(static_cast<int>(dayFee));
42 std::vector<xmlrpc_c::value> dirnameVal;
44 for (int i = 0; i< DIR_NUM; i++)
46 dirnameVal.push_back(xmlrpc_c::value_string(IconvString(dirNames[i], "KOI8-RU", "UTF-8")));
49 structVal["dir_names"] = xmlrpc_c::value_array(dirnameVal);
51 *retvalPtr = xmlrpc_c::value_struct(structVal);
54 void METHOD_LOGIN::execute(xmlrpc_c::paramList const & paramList,
55 xmlrpc_c::value * const retvalPtr)
57 std::string login = paramList.getString(0);
58 std::string password = paramList.getString(1);
59 paramList.verifyEnd(2);
61 std::map<std::string, xmlrpc_c::value> structVal;
64 if (config->CheckAdmin(login, password, &cookie))
66 structVal["result"] = xmlrpc_c::value_boolean(false);
67 structVal["cookie"] = xmlrpc_c::value_string("");
71 structVal["result"] = xmlrpc_c::value_boolean(true);
72 structVal["cookie"] = xmlrpc_c::value_string(cookie);
75 *retvalPtr = xmlrpc_c::value_struct(structVal);
78 void METHOD_LOGOUT::execute(xmlrpc_c::paramList const & paramList,
79 xmlrpc_c::value * const retvalPtr)
81 std::string cookie = paramList.getString(0);
82 paramList.verifyEnd(1);
84 if (config->LogoutAdmin(cookie))
86 *retvalPtr = xmlrpc_c::value_boolean(false);
90 *retvalPtr = xmlrpc_c::value_boolean(true);