+
+void TIParseXMLStart(void * data, const char * name, const char ** attr)
+{
+ THREAD_INFO * ti = reinterpret_cast<THREAD_INFO *>(data);
+ if (strncmp(name, "request", 7) == 0) {
+ if (attr == NULL) {
+ printfd(__FILE__, "ParseXMLStart() 'reqest' tag require a 'login' parameter\n");
+ ti->request.isOk |= false;
+ return;
+ } else {
+ ti->request.login = *attr;
+ }
+ } else if (strncmp(name, "stat", 4)) {
+ ti->pvList = &(ti->request.stat);
+ } else if (strncmp(name, "conf", 4)) {
+ ti->pvList = &(ti->request.conf);
+ } else {
+ if (ti->pvList == NULL) {
+ printfd(__FILE__, "ParseXMLStart() Unexpected tag: '%s'\n", name);
+ ti->request.isOk |= false;
+ return;
+ }
+ (*ti->pvList)[name];
+ }
+}
+
+void TIParseXMLEnd(void * data, const char * name)
+{
+ THREAD_INFO * ti = reinterpret_cast<THREAD_INFO *>(data);
+ if (strncmp(name, "stat", 4) == 0) {
+ ti->pvList = NULL;
+ } else if (strncmp(name, "conf", 4) == 0) {
+ ti->pvList = NULL;
+ } else if (strncmp(name, "request", 7) == 0) {
+ }
+}
+
+THREAD_INFO::THREAD_INFO() : pvList(NULL),
+ users(NULL),
+ store(NULL),
+ outerSocket(-1),
+ done(true)
+{
+ printfd(__FILE__, "THREAD_INFO::THREAD_INFO()\n");
+ xmlParser = XML_ParserCreate(NULL);
+
+ if (!xmlParser)
+ {
+ printfd(__FILE__, "USERSTAT::Run() Couldn't allocate memory for parser\n");
+ }
+
+ XML_ParserReset(xmlParser, NULL);
+ XML_SetElementHandler(xmlParser, TIParseXMLStart, TIParseXMLEnd);
+ XML_SetUserData(xmlParser, this);
+}
+
+THREAD_INFO::~THREAD_INFO()
+{
+ printfd(__FILE__, "THREAD_INFO::~THREAD_INFO()\n");
+ XML_ParserFree(xmlParser);
+}
+
+int THREAD_INFO::Handle()
+{
+ if (!request.isOk)
+ return -1;
+
+ if (HandleStat())
+ return -1;
+
+ if (HandleConf())
+ return -1;
+
+ return 0;
+}
+
+int THREAD_INFO::HandleConf()
+{
+ PV_LIST::iterator it(request.conf.begin());
+
+ for (; it != request.conf.end(); ++it)
+ {
+ if (it->first == "password")
+ {
+ it->second = uit->property.password;
+ }
+ else if (it->first == "passive")
+ {
+ it->second = uit->property.passive;
+ }
+ else if (it->first == "disabled")
+ {
+ it->second = uit->property.disabled;
+ }
+ else if (it->first == "disabledDetailStat")
+ {
+ it->second = uit->property.disabledDetailStat;
+ }
+ else if (it->first == "alwaysOnline")
+ {
+ it->second = uit->property.alwaysOnline;
+ }
+ else if (it->first == "tariffName")
+ {
+ it->second = uit->property.tariffName;
+ }
+ else if (it->first == "address")
+ {
+ it->second = uit->property.address;
+ }
+ else if (it->first == "phone")
+ {
+ it->second = uit->property.phone;
+ }
+ else if (it->first == "email")
+ {
+ it->second = uit->property.email;
+ }
+ else if (it->first == "note")
+ {
+ it->second = uit->property.note;
+ }
+ else if (it->first == "realName")
+ {
+ it->second = uit->property.realName;
+ }
+ else if (it->first == "group")
+ {
+ it->second = uit->property.group;
+ }
+ else if (it->first == "credit")
+ {
+ it->second = uit->property.credit;
+ }
+ else if (it->first == "creditExpire")
+ {
+ it->second = uit->property.creditExpire;
+ }
+ else if (it->first == "nextTariff")
+ {
+ it->second = uit->property.nextTariff;
+ }
+ else
+ {
+ printfd(__FILE__, "THREAD_INFO::HandleConf() Invalid param: '%s'\n", it->first.c_str());
+ }
+ }
+
+ return 0;
+}
+
+int THREAD_INFO::HandleStat()
+{
+ PV_LIST::iterator it(request.conf.begin());
+
+ for (; it != request.conf.end(); ++it)
+ {
+ if (it->first == "cash")
+ {
+ it->second = uit->property.password;
+ }
+ else
+ {
+ printfd(__FILE__, "THREAD_INFO::HandleConf() Invalid param: '%s'\n", it->first.c_str());
+ }
+ }
+
+ return 0;
+}