1 #include <sys/utsname.h>
3 #include <ostream> // xmlrpc-c devs have missed something :)
5 #include "stg/version.h"
6 #include "stg/common.h"
7 #include "info_methods.h"
10 void METHOD_INFO::execute(xmlrpc_c::paramList const & paramList,
11 xmlrpc_c::value * const retvalPtr)
13 paramList.verifyEnd(0);
14 std::map<std::string, xmlrpc_c::value> structVal;
30 structVal["version"] = xmlrpc_c::value_string(SERVER_VERSION);
31 structVal["tariff_num"] = xmlrpc_c::value_int(static_cast<int>(tariffs->Count()));
32 structVal["tariff"] = xmlrpc_c::value_int(2);
33 structVal["users_num"] = xmlrpc_c::value_int(static_cast<int>(users->Count()));
34 structVal["uname"] = xmlrpc_c::value_string(un);
35 structVal["dir_num"] = xmlrpc_c::value_int(DIR_NUM);
36 structVal["day_fee"] = xmlrpc_c::value_int(static_cast<int>(dayFee));
38 std::vector<xmlrpc_c::value> dirnameVal;
40 for (int i = 0; i< DIR_NUM; i++)
42 dirnameVal.push_back(xmlrpc_c::value_string(IconvString(dirNames[i], "KOI8-RU", "UTF-8")));
45 structVal["dir_names"] = xmlrpc_c::value_array(dirnameVal);
47 *retvalPtr = xmlrpc_c::value_struct(structVal);
50 void METHOD_LOGIN::execute(xmlrpc_c::paramList const & paramList,
51 xmlrpc_c::value * const retvalPtr)
53 std::string login = paramList.getString(0);
54 std::string password = paramList.getString(1);
55 paramList.verifyEnd(2);
57 std::map<std::string, xmlrpc_c::value> structVal;
60 if (config->CheckAdmin(login, password, &cookie))
62 structVal["result"] = xmlrpc_c::value_boolean(false);
63 structVal["cookie"] = xmlrpc_c::value_string("");
67 structVal["result"] = xmlrpc_c::value_boolean(true);
68 structVal["cookie"] = xmlrpc_c::value_string(cookie);
71 *retvalPtr = xmlrpc_c::value_struct(structVal);
74 void METHOD_LOGOUT::execute(xmlrpc_c::paramList const & paramList,
75 xmlrpc_c::value * const retvalPtr)
77 std::string cookie = paramList.getString(0);
78 paramList.verifyEnd(1);
80 std::map<std::string, xmlrpc_c::value> structVal;
82 if (config->LogoutAdmin(cookie))
84 *retvalPtr = xmlrpc_c::value_boolean(false);
88 *retvalPtr = xmlrpc_c::value_boolean(true);