]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/store/files/file_store.cpp
Handle cash changes properly.
[stg.git] / projects / stargazer / plugins / store / files / file_store.cpp
index 9d66e352f12faed6e2f680d689a356c018855f8c..a8b3990ffed700132ee3f5f0670894ba0cb04736 100644 (file)
@@ -1138,14 +1138,14 @@ strprintf(&fileName, "%s/%s.adm", storeSettings.GetAdminsDir().c_str(), ac.login
     memset(adminPass, 0, sizeof(adminPass));
 
     BLOWFISH_CTX ctx;
-    EnDecodeInit(adm_enc_passwd, strlen(adm_enc_passwd), &ctx);
+    InitContext(adm_enc_passwd, strlen(adm_enc_passwd), &ctx);
 
     strncpy(adminPass, ac.password.c_str(), ADM_PASSWD_LEN);
     adminPass[ADM_PASSWD_LEN - 1] = 0;
 
     for (int i = 0; i < ADM_PASSWD_LEN/8; i++)
         {
-        EncodeString(pass + 8*i, adminPass + 8*i, &ctx);
+        EncryptBlock(pass + 8*i, adminPass + 8*i, &ctx);
         }
 
     pass[ADM_PASSWD_LEN - 1] = 0;
@@ -1203,11 +1203,11 @@ memset(pass, 0, sizeof(pass));
 if (passwordE[0] != 0)
     {
     Decode21(pass, passwordE);
-    EnDecodeInit(adm_enc_passwd, strlen(adm_enc_passwd), &ctx);
+    InitContext(adm_enc_passwd, strlen(adm_enc_passwd), &ctx);
 
     for (int i = 0; i < ADM_PASSWD_LEN/8; i++)
         {
-        DecodeString(password + 8*i, pass + 8*i, &ctx);
+        DecryptBlock(password + 8*i, pass + 8*i, &ctx);
         }
     }
 else
@@ -1464,24 +1464,7 @@ if (conf.ReadString("TraffType", &str, "") < 0)
     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;
@@ -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);
-
-    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));
     }