//-----------------------------------------------------------------------------
FILES_STORE_SETTINGS::FILES_STORE_SETTINGS()
: settings(NULL),
- errorStr(),
- workDir(),
- usersDir(),
- adminsDir(),
- tariffsDir(),
statMode(0),
statUID(0),
statGID(0),
pv.param = owner;
std::vector<PARAM_VALUE>::const_iterator pvi;
pvi = find(moduleParams.begin(), moduleParams.end(), pv);
-if (pvi == moduleParams.end())
+if (pvi == moduleParams.end() || pvi->value.empty())
{
errorStr = "Parameter \'" + owner + "\' not found.";
printfd(__FILE__, "%s\n", errorStr.c_str());
pv.param = group;
std::vector<PARAM_VALUE>::const_iterator pvi;
pvi = find(moduleParams.begin(), moduleParams.end(), pv);
-if (pvi == moduleParams.end())
+if (pvi == moduleParams.end() || pvi->value.empty())
{
errorStr = "Parameter \'" + group + "\' not found.";
printfd(__FILE__, "%s\n", errorStr.c_str());
pv.param = modeStr;
std::vector<PARAM_VALUE>::const_iterator pvi;
pvi = find(moduleParams.begin(), moduleParams.end(), pv);
-if (pvi == moduleParams.end())
+if (pvi == moduleParams.end() || pvi->value.empty())
{
errorStr = "Parameter \'" + modeStr + "\' not found.";
printfd(__FILE__, "%s\n", errorStr.c_str());
PARAM_VALUE pv;
pv.param = "RemoveBak";
pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
-if (pvi == s.moduleParams.end())
+if (pvi == s.moduleParams.end() || pvi->value.empty())
{
removeBak = true;
}
pv.param = "ReadBak";
pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
-if (pvi == s.moduleParams.end())
+if (pvi == s.moduleParams.end() || pvi->value.empty())
{
readBak = false;
}
pv.param = "WorkDir";
pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
-if (pvi == s.moduleParams.end())
+if (pvi == s.moduleParams.end() || pvi->value.empty())
{
errorStr = "Parameter \'WorkDir\' not found.";
printfd(__FILE__, "Parameter 'WorkDir' not found\n");
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;
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
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;
else
td->tariffConf.period = TARIFF::StringToPeriod(str);
+
+if (conf.ReadString("ChangePolicy", &str, "allow") < 0)
+ td->tariffConf.changePolicy = TARIFF::ALLOW;
+else
+ td->tariffConf.changePolicy = TARIFF::StringToChangePolicy(str);
+
+if (conf.ReadString("ChangePolicyTimeout", &str, "1970-01-01 00:00:00") < 0)
+ td->tariffConf.changePolicyTimeout = 0;
+else
+ td->tariffConf.changePolicyTimeout = readTime(str);
return 0;
}
//-----------------------------------------------------------------------------
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("ChangePolicy", TARIFF::ChangePolicyToString(td.tariffConf.changePolicy));
+ cf.WriteTime("ChangePolicyTimeout", td.tariffConf.changePolicyTimeout);
}
return 0;