"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/gui/src/LicenseManager.cpp" between
synergy-core-1.14.4.37-stable.tar.gz and synergy-core-1.14.5.13-stable.tar.gz

About: Synergy is software for sharing one mouse and one keyboard between multiple computers on your desk allowing to seamlessly move the mouse cursor from one screen to another (works on Linux, Windows and Mac OS X). Synergy 1.

LicenseManager.cpp  (synergy-core-1.14.4.37-stable):LicenseManager.cpp  (synergy-core-1.14.5.13-stable)
skipping to change at line 25 skipping to change at line 25
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "LicenseManager.h" #include "LicenseManager.h"
#include "AppConfig.h" #include "AppConfig.h"
#include <ctime> #include <ctime>
#include <stdexcept> #include <stdexcept>
#include <utility> #include <utility>
#include <QThread> #include <QThread>
#include <QTimer> #include <QTimer>
#include <QDateTime>
#include <QLocale>
LicenseManager::LicenseManager(AppConfig* appConfig) : namespace {
m_AppConfig(appConfig),
m_serialKey(appConfig->edition()) { std::string
getMaintenanceMessage(const SerialKey& serialKey)
{
auto expiration = QDateTime::fromTime_t(serialKey.getExpiration()).date();
QString message = "The license key you used will only work with versions of
Synergy released before %1."
"<p>To use this version, you’ll need to renew your Synergy
maintenance license. "
"<a href=\"https://symless.com/synergy/account?source=gui\
""
"style=\"text-decoration: none; color: #4285F4;\">Renew
today</a>.</p>";
auto formatedDate = QLocale("en_US").toString(expiration, "MMM dd yyyy");
return message.arg(formatedDate).toStdString();
} }
void void
LicenseManager::setSerialKey(SerialKey serialKey, bool acceptExpired) checkSerialKey(const SerialKey& serialKey, bool acceptExpired)
{ {
time_t currentTime = ::time(0); if (serialKey.isMaintenance()) {
auto buildDate = QDateTime::fromString(__TIMESTAMP__).toTime_t();
if (!acceptExpired && serialKey.isExpired(currentTime)) { if (buildDate > serialKey.getExpiration()) {
throw std::runtime_error(getMaintenanceMessage(serialKey));
}
}
if (!acceptExpired && serialKey.isExpired(::time(nullptr))) {
throw std::runtime_error("Serial key expired"); throw std::runtime_error("Serial key expired");
} }
#ifdef SYNERGY_BUSINESS #ifdef SYNERGY_BUSINESS
if (!serialKey.isValid()) { if (!serialKey.isValid()) {
throw std::runtime_error("The serial key is not compatible with the busi ness version of Synergy."); throw std::runtime_error("The serial key is not compatible with the busi ness version of Synergy.");
} }
#endif #endif
}
}
LicenseManager::LicenseManager(AppConfig* appConfig) :
m_AppConfig(appConfig),
m_serialKey(appConfig->edition()) {
}
void
LicenseManager::setSerialKey(SerialKey serialKey, bool acceptExpired)
{
checkSerialKey(serialKey, acceptExpired);
if (serialKey != m_serialKey) { if (serialKey != m_serialKey) {
using std::swap; using std::swap;
swap (serialKey, m_serialKey); swap (serialKey, m_serialKey);
m_AppConfig->setSerialKey(QString::fromStdString m_AppConfig->setSerialKey(QString::fromStdString
(m_serialKey.toString())); (m_serialKey.toString()));
emit showLicenseNotice(getLicenseNotice()); emit showLicenseNotice(getLicenseNotice());
validateSerialKey(); validateSerialKey();
skipping to change at line 111 skipping to change at line 141
} }
void void
LicenseManager::refresh() LicenseManager::refresh()
{ {
if (!m_AppConfig->serialKey().isEmpty()) { if (!m_AppConfig->serialKey().isEmpty()) {
try { try {
SerialKey serialKey (m_AppConfig->serialKey().toStdString()); SerialKey serialKey (m_AppConfig->serialKey().toStdString());
setSerialKey(serialKey, true); setSerialKey(serialKey, true);
} catch (...) { } catch (...) {
m_serialKey = SerialKey();
m_AppConfig->clearSerialKey(); m_AppConfig->clearSerialKey();
} }
} }
if (!m_serialKey.isValid()) { if (!m_serialKey.isValid()) {
emit InvalidLicense(); emit InvalidLicense();
} }
} }
void void
LicenseManager::skipActivation() const LicenseManager::skipActivation() const
 End of changes. 7 change blocks. 
6 lines changed or deleted 41 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)