X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/1b2ab8e6d556a8ed30d4feadc72263b3f4c86665..fe67eb715426dbd5bb72d133b8d708f3042f1199:/stglibs/srvconf.lib/parsers/chg_user.cpp?ds=sidebyside diff --git a/stglibs/srvconf.lib/parsers/chg_user.cpp b/stglibs/srvconf.lib/parsers/chg_user.cpp index ed2002bc..f0027968 100644 --- a/stglibs/srvconf.lib/parsers/chg_user.cpp +++ b/stglibs/srvconf.lib/parsers/chg_user.cpp @@ -25,16 +25,19 @@ #include "stg/user_conf.h" #include "stg/user_stat.h" +#include "stg/common.h" #include +#include #include using namespace STG; -CHG_USER::PARSER::PARSER(SIMPLE::CALLBACK f, void * d) +CHG_USER::PARSER::PARSER(SIMPLE::CALLBACK f, void * d, const std::string & e) : callback(f), data(d), + encoding(e), depth(0) { } @@ -69,7 +72,7 @@ else callback(false, "Invalid response.", data); } -std::string CHG_USER::Serialize(const USER_CONF_RES & conf, const USER_STAT_RES & stat) +std::string CHG_USER::Serialize(const USER_CONF_RES & conf, const USER_STAT_RES & stat, const std::string & encoding) { std::ostringstream stream; @@ -87,24 +90,33 @@ appendResetable(stream, "ip", conf.ips); // TODO: ip -> ips if (!conf.nextTariff.empty()) stream << ""; else if (!conf.tariffName.empty()) - stream << ""; + stream << ""; -appendResetable(stream, "note", conf.note); -appendResetable(stream, "name", conf.realName); // TODO: name -> realName -appendResetable(stream, "address", conf.address); -appendResetable(stream, "email", conf.email); -appendResetable(stream, "phone", conf.phone); -appendResetable(stream, "group", conf.group); +appendResetable(stream, "note", MaybeEncode(MaybeIconv(conf.note, encoding, "koi8-ru"))); +appendResetable(stream, "name", MaybeEncode(MaybeIconv(conf.realName, encoding, "koi8-ru"))); // TODO: name -> realName +appendResetable(stream, "address", MaybeEncode(MaybeIconv(conf.address, encoding, "koi8-ru"))); +appendResetable(stream, "email", MaybeEncode(MaybeIconv(conf.email, encoding, "koi8-ru"))); +appendResetable(stream, "phone", MaybeEncode(MaybeIconv(conf.phone, encoding, "cp1251"))); +appendResetable(stream, "group", MaybeEncode(MaybeIconv(conf.group, encoding, "koi8-ru"))); +appendResetable(stream, "corp", conf.corp); for (size_t i = 0; i < conf.userdata.size(); ++i) - appendResetable(stream, "userdata", i, conf.userdata[i]); + appendResetable(stream, "userdata", i, MaybeEncode(MaybeIconv(conf.userdata[i], encoding, "koi8-ru"))); + +if (!conf.services.empty()) + { + stream << ""; + for (size_t i = 0; i < conf.services.data().size(); ++i) + stream << ""; + stream << ""; + } // Stat if (!stat.cashAdd.empty()) - stream << ""; + stream << ""; else if (!stat.cashSet.empty()) - stream << ""; + stream << ""; appendResetable(stream, "freeMb", stat.freeMb); @@ -126,5 +138,6 @@ std::string traffData = traff.str(); if (!traffData.empty()) stream << ""; +std::cerr << stream.str() << "\n"; return stream.str(); }