]> git.stg.codes - stg.git/blobdiff - stglibs/srvconf.lib/parsers/get_user.cpp
Added handling of "AuthBy" info.
[stg.git] / stglibs / srvconf.lib / parsers / get_user.cpp
index 54cfc0f95f8a873df573043229bf3615b87557e5..a851e38077ec16b22e25036461e9b08afca6177b 100644 (file)
@@ -34,7 +34,7 @@ namespace STG
 {
 
 template <>
-bool GetValue<GET_USER::STAT>(const char ** attr, GET_USER::STAT & value)
+bool GetValue<GET_USER::STAT>(const char ** attr, GET_USER::STAT & value, const std::string & /*attrName*/)
 {
 if (!attr)
     return false;
@@ -71,12 +71,13 @@ GET_USER::PARSER::PARSER(CALLBACK f, void * d)
     AddParser(propertyParsers, "cash", info.cash);
     AddParser(propertyParsers, "credit", info.credit);
     AddParser(propertyParsers, "creditExpire", info.creditExpire);
-    AddParser(propertyParsers, "lastCash", info.lastCash);
-    AddParser(propertyParsers, "prepaidTraff", info.prepaidTraff);
-    AddParser(propertyParsers, "down", info.down);
+    AddParser(propertyParsers, "lastCash", info.lastCashAdd);
+    AddParser(propertyParsers, "lastTimeCash", info.lastCashAddTime);
+    AddParser(propertyParsers, "freeMb", info.prepaidTraff);
+    AddParser(propertyParsers, "down", info.disabled);
     AddParser(propertyParsers, "passive", info.passive);
     AddParser(propertyParsers, "disableDetailStat", info.disableDetailStat);
-    AddParser(propertyParsers, "connected", info.connected);
+    AddParser(propertyParsers, "status", info.connected);
     AddParser(propertyParsers, "aonline", info.alwaysOnline);
     AddParser(propertyParsers, "currIP", info.ip, GetIPValue);
     AddParser(propertyParsers, "ip", info.ips);
@@ -88,6 +89,8 @@ GET_USER::PARSER::PARSER(CALLBACK f, void * d)
     AddParser(propertyParsers, "address", info.address, GetEncodedValue);
     AddParser(propertyParsers, "phone", info.phone, GetEncodedValue);
     AddParser(propertyParsers, "traff", info.stat);
+    AddParser(propertyParsers, "pingTime", info.pingTime);
+    AddParser(propertyParsers, "lastActivityTime", info.lastActivityTime);
 
     for (size_t i = 0; i < USERDATA_NUM; ++i)
         AddParser(propertyParsers, "userData" + unsigned2str(i), info.userData[i], GetEncodedValue);
@@ -109,6 +112,9 @@ if (depth == 1)
 if (depth == 2 && parsingAnswer)
     ParseUserParams(el, attr);
 
+if (depth == 3 && parsingAnswer)
+    ParseAuthBy(el, attr);
+
 return 0;
 }
 //-----------------------------------------------------------------------------
@@ -137,16 +143,26 @@ if (strcasecmp(el, "user") == 0)
             else
                 error = "User not found.";
             }
-        else
-            parsingAnswer = true;
+        else if (strcasecmp(attr[0], "login") == 0 && attr[1])
+            info.login = attr[1];
         }
-    else
-        parsingAnswer = true;
+    parsingAnswer = true;
     }
 }
 //-----------------------------------------------------------------------------
 void GET_USER::PARSER::ParseUserParams(const char * el, const char ** attr)
 {
-if (!TryParse(propertyParsers, ToLower(el), attr))
+if (strcasecmp(el, "AuthorizedBy") != 0 &&
+    !TryParse(propertyParsers, ToLower(el), attr))
     error = "Invalid parameter.";
 }
+//-----------------------------------------------------------------------------
+void GET_USER::PARSER::ParseAuthBy(const char * el, const char ** attr)
+{
+if (strcasecmp(el, "Auth") == 0 &&
+    attr && attr[0] && attr[1] &&
+    strcasecmp(attr[0], "name") == 0)
+    info.authBy.push_back(attr[1]);
+else
+    error = "Invalid auth description.";
+}