#5657 Added version 2 trial serial key support
This commit is contained in:
parent
c7cd74ab5f
commit
d92fcd2453
|
@ -27,4 +27,5 @@ struct SubscriptionKey {
|
||||||
int m_userLimit;
|
int m_userLimit;
|
||||||
int m_warnTime;
|
int m_warnTime;
|
||||||
int m_expireTime;
|
int m_expireTime;
|
||||||
|
bool m_trial;
|
||||||
};
|
};
|
||||||
|
|
|
@ -140,9 +140,11 @@ SubscriptionManager::parsePlainSerial(const String& plainText, SubscriptionKey&
|
||||||
pos += 1;
|
pos += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// e.g.: {v1;trial;Bob;1;email;company name;1398297600;1398384000}
|
bool validSerial = false;
|
||||||
|
|
||||||
if ((parts.size() == 8)
|
if ((parts.size() == 8)
|
||||||
&& (parts.at(0).find("v1") != String::npos)) {
|
&& (parts.at(0).find("v1") != String::npos)) {
|
||||||
|
// e.g.: {v1;basic;Bob;1;email;company name;1398297600;1398384000}
|
||||||
key.m_type = parts.at(1);
|
key.m_type = parts.at(1);
|
||||||
key.m_name = parts.at(2);
|
key.m_name = parts.at(2);
|
||||||
sscanf(parts.at(3).c_str(), "%d", &key.m_userLimit);
|
sscanf(parts.at(3).c_str(), "%d", &key.m_userLimit);
|
||||||
|
@ -151,8 +153,22 @@ SubscriptionManager::parsePlainSerial(const String& plainText, SubscriptionKey&
|
||||||
sscanf(parts.at(6).c_str(), "%d", &key.m_warnTime);
|
sscanf(parts.at(6).c_str(), "%d", &key.m_warnTime);
|
||||||
sscanf(parts.at(7).c_str(), "%d", &key.m_expireTime);
|
sscanf(parts.at(7).c_str(), "%d", &key.m_expireTime);
|
||||||
|
|
||||||
|
validSerial = true;
|
||||||
|
}
|
||||||
|
else if ((parts.size() == 9)
|
||||||
|
&& (parts.at(0).find("v2") != String::npos)) {
|
||||||
|
// e.g.: {v2;trial;basic;Bob;1;email;company name;1398297600;1398384000}
|
||||||
|
key.m_trial = parts.at(1) == "trial" ? true : false;
|
||||||
|
key.m_type = parts.at(2);
|
||||||
|
key.m_name = parts.at(3);
|
||||||
|
sscanf(parts.at(4).c_str(), "%d", &key.m_userLimit);
|
||||||
|
key.m_email = parts.at(5);
|
||||||
|
key.m_company = parts.at(6);
|
||||||
|
sscanf(parts.at(7).c_str(), "%d", &key.m_warnTime);
|
||||||
|
sscanf(parts.at(8).c_str(), "%d", &key.m_expireTime);
|
||||||
|
|
||||||
// only limit to trial version
|
// only limit to trial version
|
||||||
if (key.m_type == "trial") {
|
if (key.m_trial) {
|
||||||
if (time(0) > key.m_expireTime) {
|
if (time(0) > key.m_expireTime) {
|
||||||
throw XSubscription("trial has expired");
|
throw XSubscription("trial has expired");
|
||||||
}
|
}
|
||||||
|
@ -164,8 +180,15 @@ SubscriptionManager::parsePlainSerial(const String& plainText, SubscriptionKey&
|
||||||
dayLeft,
|
dayLeft,
|
||||||
dayLeft == 1 ? "day" : "days"));
|
dayLeft == 1 ? "day" : "days"));
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validSerial = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validSerial) {
|
||||||
const char* userText = (key.m_userLimit == 1) ? "user" : "users";
|
const char* userText = (key.m_userLimit == 1) ? "user" : "users";
|
||||||
LOG((CLOG_INFO "%s subscription valid is for %d %s, registered to %s",
|
LOG((CLOG_INFO "%s subscription valid is for %d %s, registered to %s",
|
||||||
key.m_type.c_str(),
|
key.m_type.c_str(),
|
||||||
|
|
Loading…
Reference in New Issue