]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/configuration/sgconfig/parser_tariffs.cpp
Ticket 37. x2str() replaced by formatTime() for changePolicyTimeout
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / parser_tariffs.cpp
index b33b1305ca4e02789427882c2334f87cfb692c64..daf4ef629af69934e1633f8ea3afdbd9b8b00761 100644 (file)
@@ -115,6 +115,7 @@ void GET_TARIFFS::CreateAnswer()
                   "<TraffType value=\"" + TARIFF::TraffTypeToString(it->tariffConf.traffType) + "\"/>" +
                   "<Period value=\"" + TARIFF::PeriodToString(it->tariffConf.period) + "\"/>" +
                   "<ChangePolicy value=\"" + TARIFF::ChangePolicyToString(it->tariffConf.changePolicy) + "\"/>" +
                   "<TraffType value=\"" + TARIFF::TraffTypeToString(it->tariffConf.traffType) + "\"/>" +
                   "<Period value=\"" + TARIFF::PeriodToString(it->tariffConf.period) + "\"/>" +
                   "<ChangePolicy value=\"" + TARIFF::ChangePolicyToString(it->tariffConf.changePolicy) + "\"/>" +
+                  "<ChangePolicyTimeout value=\"" + formatTime(it->tariffConf.changePolicyTimeout) + "\"/>" +
                   "</tariff>";
         }
 
                   "</tariff>";
         }
 
@@ -171,7 +172,11 @@ int CHG_TARIFF::Start(void *, const char * el, const char ** attr)
     {
         if (strcasecmp(el, m_tag.c_str()) == 0)
         {
     {
         if (strcasecmp(el, m_tag.c_str()) == 0)
         {
-            td.tariffConf.name = attr[1];
+            const TARIFF * tariff = m_tariffs.FindByName(attr[1]);
+            if (tariff != NULL)
+                td = tariff->GetTariffData();
+            else
+                return -1;
             return 0;
         }
     }
             return 0;
         }
     }
@@ -295,6 +300,14 @@ int CHG_TARIFF::Start(void *, const char * el, const char ** attr)
             td.tariffConf.changePolicy = TARIFF::StringToChangePolicy(attr[1]);
             return 0;
         }
             td.tariffConf.changePolicy = TARIFF::StringToChangePolicy(attr[1]);
             return 0;
         }
+
+        if (strcasecmp(el, "ChangePolicyTimeout") == 0)
+        {
+            int64_t policyTime = 0;
+            if (str2x(attr[1], policyTime) == 0)
+                td.tariffConf.changePolicyTimeout = (time_t)policyTime;
+            return 0;
+        }
     }
     return -1;
 }
     }
     return -1;
 }