]> git.stg.codes - stg.git/commitdiff
Fixed compilation with new TRAFF_TYPE.
authorMaxim Mamontov <faust.madf@gmail.com>
Wed, 17 Sep 2014 06:34:59 +0000 (09:34 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Wed, 17 Sep 2014 06:34:59 +0000 (09:34 +0300)
projects/stargazer/plugins/configuration/rpcconfig/tariff_helper.cpp
projects/stargazer/plugins/store/files/file_store.cpp
projects/stargazer/plugins/store/mysql/mysql_store.cpp
projects/stargazer/user_impl.cpp

index 85abf8205a5e59822db40850c3b37d4de905be45..26b4e993b719067fae180f47b9c1d1792b1da204 100644 (file)
@@ -63,7 +63,7 @@ if ((it = structVal.find("passivecost")) != structVal.end())
 
 if ((it = structVal.find("traffType")) != structVal.end())
     {
 
 if ((it = structVal.find("traffType")) != structVal.end())
     {
-    data.tariffConf.traffType = xmlrpc_c::value_int(it->second);
+    data.tariffConf.traffType = static_cast<TARIFF::TRAFF_TYPE>(xmlrpc_c::value_int(it->second).cvalue());
     }
 
 if ((it = structVal.find("period")) != structVal.end())
     }
 
 if ((it = structVal.find("period")) != structVal.end())
index 689f5fab9261937f63e58d29c9ce0912d7a458c6..a8b3990ffed700132ee3f5f0670894ba0cb04736 100644 (file)
@@ -1464,24 +1464,7 @@ if (conf.ReadString("TraffType", &str, "") < 0)
     return -1;
     }
 
     return -1;
     }
 
-if (!strcasecmp(str.c_str(), "up"))
-    td->tariffConf.traffType = TRAFF_UP;
-else
-    if (!strcasecmp(str.c_str(), "down"))
-        td->tariffConf.traffType = TRAFF_DOWN;
-    else
-        if (!strcasecmp(str.c_str(), "up+down"))
-            td->tariffConf.traffType = TRAFF_UP_DOWN;
-        else
-            if (!strcasecmp(str.c_str(), "max"))
-                td->tariffConf.traffType = TRAFF_MAX;
-            else
-                {
-                STG_LOCKER lock(&mutex);
-                errorStr = "Cannot read tariff " + tariffName + ". Parameter TraffType incorrect";
-                printfd(__FILE__, "FILES_STORE::RestoreTariff - invalid trafftype for tariff '%s'\n", tariffName.c_str());
-                return -1;
-                }
+td->tariffConf.traffType = TARIFF::StringToTraffType(str);
 
 if (conf.ReadString("Period", &str, "month") < 0)
     td->tariffConf.period = TARIFF::MONTH;
 
 if (conf.ReadString("Period", &str, "month") < 0)
     td->tariffConf.period = TARIFF::MONTH;
@@ -1546,23 +1529,7 @@ std::string fileName = storeSettings.GetTariffsDir() + "/" + tariffName + ".tf";
     cf.WriteDouble("PassiveCost", td.tariffConf.passiveCost);
     cf.WriteDouble("Fee", td.tariffConf.fee);
     cf.WriteDouble("Free", td.tariffConf.free);
     cf.WriteDouble("PassiveCost", td.tariffConf.passiveCost);
     cf.WriteDouble("Fee", td.tariffConf.fee);
     cf.WriteDouble("Free", td.tariffConf.free);
-
-    switch (td.tariffConf.traffType)
-        {
-        case TRAFF_UP:
-            cf.WriteString("TraffType", "up");
-            break;
-        case TRAFF_DOWN:
-            cf.WriteString("TraffType", "down");
-            break;
-        case TRAFF_UP_DOWN:
-            cf.WriteString("TraffType", "up+down");
-            break;
-        case TRAFF_MAX:
-            cf.WriteString("TraffType", "max");
-            break;
-        }
-
+    cf.WriteString("TraffType", TARIFF::TraffTypeToString(td.tariffConf.traffType));
     cf.WriteString("Period", TARIFF::PeriodToString(td.tariffConf.period));
     }
 
     cf.WriteString("Period", TARIFF::PeriodToString(td.tariffConf.period));
     }
 
index 3e61498f5785f8e40bb7cb293f3c47586883c96b..1e4c235d9dfb6d7b56b39d4b73fed3038fa79566 100644 (file)
@@ -1625,24 +1625,7 @@ if (GetDouble(row[1+8*DIR_NUM], &td->tariffConf.passiveCost, 0.0) < 0)
         return -1;
         }
 
         return -1;
         }
 
-if (!strcasecmp(str.c_str(), "up"))
-    td->tariffConf.traffType = TRAFF_UP;
-else
-    if (!strcasecmp(str.c_str(), "down"))
-        td->tariffConf.traffType = TRAFF_DOWN;
-    else
-        if (!strcasecmp(str.c_str(), "up+down"))
-            td->tariffConf.traffType = TRAFF_UP_DOWN;
-        else
-            if (!strcasecmp(str.c_str(), "max"))
-                td->tariffConf.traffType = TRAFF_MAX;
-            else
-                {
-                mysql_free_result(res);
-                errorStr = "Cannot read tariff " + tariffName + ". Parameter TraffType incorrect";
-                mysql_close(sock);
-                return -1;
-                }
+td->tariffConf.traffType = TARIFF::StringToTraffType(str);
 
 if (schemaVersion > 0)
 {
 
 if (schemaVersion > 0)
 {
@@ -1726,21 +1709,7 @@ res += param;
 strprintf(&param, " Free=%f,", td.tariffConf.free);
 res += param;
 
 strprintf(&param, " Free=%f,", td.tariffConf.free);
 res += param;
 
-switch (td.tariffConf.traffType)
-    {
-    case TRAFF_UP:
-        res += " TraffType='up'";
-        break;
-    case TRAFF_DOWN:
-        res += " TraffType='down'";
-        break;
-    case TRAFF_UP_DOWN:
-        res += " TraffType='up+down'";
-        break;
-    case TRAFF_MAX:
-        res += " TraffType='max'";
-        break;
-    }
+res += " TraffType='" + TARIFF::TraffTypeToString(td.tariffConf.traffType) + "'";
 
 if (schemaVersion > 0)
     res += ", Period='" + TARIFF::PeriodToString(td.tariffConf.period) + "'";
 
 if (schemaVersion > 0)
     res += ", Period='" + TARIFF::PeriodToString(td.tariffConf.period) + "'";
index ae7ccd339e340bd259318cd4190bbeb9cd8b11bb..7932198783197138cde33d1d7ef664e1af960f7f 100644 (file)
@@ -854,10 +854,10 @@ int64_t threshold = tariff->GetThreshold(dir) * 1024 * 1024;
 dt[dir] += len;
 
 int tt = tariff->GetTraffType();
 dt[dir] += len;
 
 int tt = tariff->GetTraffType();
-if (tt == TRAFF_UP ||
-    tt == TRAFF_UP_DOWN ||
+if (tt == TARIFF::TRAFF_UP ||
+    tt == TARIFF::TRAFF_UP_DOWN ||
     // Check NEW traff data
     // Check NEW traff data
-    (tt == TRAFF_MAX && dt[dir] > down.ConstData()[dir]))
+    (tt == TARIFF::TRAFF_MAX && dt[dir] > down.ConstData()[dir]))
     {
     double dc = 0;
     if (traff < threshold &&
     {
     double dc = 0;
     if (traff < threshold &&
@@ -947,10 +947,10 @@ int64_t threshold = tariff->GetThreshold(dir) * 1024 * 1024;
 dt[dir] += len;
 
 int tt = tariff->GetTraffType();
 dt[dir] += len;
 
 int tt = tariff->GetTraffType();
-if (tt == TRAFF_DOWN ||
-    tt == TRAFF_UP_DOWN ||
+if (tt == TARIFF::TRAFF_DOWN ||
+    tt == TARIFF::TRAFF_UP_DOWN ||
     // Check NEW traff data
     // Check NEW traff data
-    (tt == TRAFF_MAX && up.ConstData()[dir] <= dt[dir]))
+    (tt == TARIFF::TRAFF_MAX && up.ConstData()[dir] <= dt[dir]))
     {
     double dc = 0;
     if (traff < threshold &&
     {
     double dc = 0;
     if (traff < threshold &&