]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/configuration/sgconfig/parser_tariffs.cpp
Ticket 37. const TARIFF * tariff definition, tariff checking and tariff->GetTariffData()
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / parser_tariffs.cpp
index 0607db6fb12fbde08147a0af3418250ae3743bb3..b1564406f7bc7f9f51eec8ffdae7550f99d66f36 100644 (file)
@@ -114,6 +114,7 @@ void GET_TARIFFS::CreateAnswer()
                   "<Free value=\"" + x2str(it->tariffConf.free) + "\"/>" +
                   "<TraffType value=\"" + TARIFF::TraffTypeToString(it->tariffConf.traffType) + "\"/>" +
                   "<Period value=\"" + TARIFF::PeriodToString(it->tariffConf.period) + "\"/>" +
                   "<Free value=\"" + x2str(it->tariffConf.free) + "\"/>" +
                   "<TraffType value=\"" + TARIFF::TraffTypeToString(it->tariffConf.traffType) + "\"/>" +
                   "<Period value=\"" + TARIFF::PeriodToString(it->tariffConf.period) + "\"/>" +
+                  "<ChangePolicy value=\"" + TARIFF::ChangePolicyToString(it->tariffConf.changePolicy) + "\"/>" +
                   "</tariff>";
         }
 
                   "</tariff>";
         }
 
@@ -170,7 +171,9 @@ 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();
             return 0;
         }
     }
             return 0;
         }
     }
@@ -288,6 +291,12 @@ int CHG_TARIFF::Start(void *, const char * el, const char ** attr)
             td.tariffConf.period = TARIFF::StringToPeriod(attr[1]);
             return 0;
         }
             td.tariffConf.period = TARIFF::StringToPeriod(attr[1]);
             return 0;
         }
+
+        if (strcasecmp(el, "ChangePolicy") == 0)
+        {
+            td.tariffConf.changePolicy = TARIFF::StringToChangePolicy(attr[1]);
+            return 0;
+        }
     }
     return -1;
 }
     }
     return -1;
 }