mirror of
https://github.com/debauchee/barrier.git
synced 2026-02-11 22:25:53 +08:00
Merge branch 'v1.8.6' into issue5186-different-dpi
This commit is contained in:
@@ -90,6 +90,7 @@ void ActivationDialog::accept()
|
||||
return;
|
||||
}
|
||||
|
||||
m_LicenseManager->notifyActivation("serial:" + m_appConfig->serialKey());
|
||||
Edition edition = m_LicenseManager->activeEdition();
|
||||
time_t daysLeft = m_LicenseManager->serialKey().daysLeft(::time(0));
|
||||
if (edition != kUnregistered) {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "CoreInterface.h"
|
||||
|
||||
ActivationNotifier::ActivationNotifier(QObject *parent) :
|
||||
QObject(parent)
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -29,6 +29,15 @@ void ActivationNotifier::setIdentity(QString identity)
|
||||
m_Identity = identity;
|
||||
}
|
||||
|
||||
void ActivationNotifier::setUpdateInfo(QString const& fromVersion,
|
||||
QString const& toVersion,
|
||||
QString const& serialKey)
|
||||
{
|
||||
m_fromVersion = fromVersion;
|
||||
m_toVersion = toVersion;
|
||||
m_serialKey = serialKey;
|
||||
}
|
||||
|
||||
void ActivationNotifier::notify()
|
||||
{
|
||||
CoreInterface coreInterface;
|
||||
@@ -39,3 +48,13 @@ void ActivationNotifier::notify()
|
||||
// catch all exceptions and fails silently
|
||||
}
|
||||
}
|
||||
|
||||
void ActivationNotifier::notifyUpdate()
|
||||
{
|
||||
try {
|
||||
CoreInterface coreInterface;
|
||||
coreInterface.notifyUpdate(m_fromVersion, m_toVersion,
|
||||
m_serialKey);
|
||||
} catch (...) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,18 +24,24 @@ class ActivationNotifier : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ActivationNotifier(QObject *parent = 0);
|
||||
explicit ActivationNotifier(QObject *parent = 0);
|
||||
|
||||
void setIdentity(QString identity);
|
||||
void setUpdateInfo(QString const& fromVersion,
|
||||
QString const& toVersion, QString const& serialKey);
|
||||
|
||||
public slots:
|
||||
void notify();
|
||||
void notifyUpdate();
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
|
||||
private:
|
||||
QString m_Identity;
|
||||
QString m_fromVersion;
|
||||
QString m_toVersion;
|
||||
QString m_serialKey;
|
||||
};
|
||||
|
||||
#endif // ACTIVATIONNOTIFIER_H
|
||||
|
||||
@@ -162,6 +162,7 @@ void AppConfig::loadSettings()
|
||||
m_CryptoEnabled = settings().value("cryptoEnabled", true).toBool();
|
||||
m_AutoHide = settings().value("autoHide", false).toBool();
|
||||
m_Serialkey = settings().value("serialKey", "").toString();
|
||||
m_lastVersion = settings().value("lastVersion", "Unknown").toString();
|
||||
m_LastExpiringWarningTime = settings().value("lastExpiringWarningTime", 0).toInt();
|
||||
m_ActivationHasRun = settings().value("activationHasRun", false).toBool();
|
||||
}
|
||||
@@ -187,6 +188,7 @@ void AppConfig::saveSettings()
|
||||
settings().setValue("cryptoEnabled", m_CryptoEnabled);
|
||||
settings().setValue("autoHide", m_AutoHide);
|
||||
settings().setValue("serialKey", m_Serialkey);
|
||||
settings().setValue("lastVersion", m_lastVersion);
|
||||
settings().setValue("lastExpiringWarningTime", m_LastExpiringWarningTime);
|
||||
settings().setValue("activationHasRun", m_ActivationHasRun);
|
||||
settings().sync();
|
||||
@@ -203,6 +205,15 @@ AppConfig& AppConfig::activationHasRun(bool value)
|
||||
return *this;
|
||||
}
|
||||
|
||||
QString AppConfig::lastVersion() const
|
||||
{
|
||||
return m_lastVersion;
|
||||
}
|
||||
|
||||
void AppConfig::setLastVersion(QString version) {
|
||||
m_lastVersion = version;
|
||||
}
|
||||
|
||||
QSettings &AppConfig::settings() { return *m_pSettings; }
|
||||
|
||||
void AppConfig::setScreenName(const QString &s) { m_ScreenName = s; }
|
||||
|
||||
@@ -104,7 +104,11 @@ class AppConfig: public QObject
|
||||
bool activationHasRun() const;
|
||||
AppConfig& activationHasRun(bool value);
|
||||
|
||||
void saveSettings();;
|
||||
QString lastVersion() const;
|
||||
|
||||
void saveSettings();
|
||||
void setLastVersion(QString version);
|
||||
|
||||
protected:
|
||||
QSettings& settings();
|
||||
void setScreenName(const QString& s);
|
||||
@@ -139,6 +143,7 @@ protected:
|
||||
bool m_CryptoEnabled;
|
||||
bool m_AutoHide;
|
||||
QString m_Serialkey;
|
||||
QString m_lastVersion;
|
||||
int m_LastExpiringWarningTime;
|
||||
bool m_ActivationHasRun;
|
||||
|
||||
|
||||
@@ -62,6 +62,14 @@ QString CoreInterface::getSerialKeyFilePath()
|
||||
return filename;
|
||||
}
|
||||
|
||||
QString CoreInterface::notifyUpdate (QString const& fromVersion,
|
||||
QString const& toVersion,
|
||||
QString const& serialKey) {
|
||||
QStringList args("--notify-update");
|
||||
QString input(fromVersion + ":" + toVersion + ":" + serialKey);
|
||||
input.append("\n");
|
||||
return run(args, input);
|
||||
}
|
||||
|
||||
QString CoreInterface::notifyActivation(const QString& identity)
|
||||
{
|
||||
|
||||
@@ -29,5 +29,8 @@ public:
|
||||
QString getArch();
|
||||
QString getSerialKeyFilePath();
|
||||
QString notifyActivation(const QString& identity);
|
||||
QString notifyUpdate (QString const& fromVersion,
|
||||
QString const& toVersion,
|
||||
QString const& serialKey);
|
||||
QString run(const QStringList& args, const QString& input = "");
|
||||
};
|
||||
|
||||
@@ -45,7 +45,6 @@ LicenseManager::setSerialKey(QString serialKeyString, bool acceptExpired)
|
||||
using std::swap;
|
||||
swap (serialKey, m_serialKey);
|
||||
m_AppConfig->setSerialKey(serialKeyString);
|
||||
notifyActivation("serial:" + serialKeyString);
|
||||
emit serialKeyChanged(m_serialKey);
|
||||
|
||||
if (serialKey.isTrial()) {
|
||||
@@ -71,6 +70,29 @@ LicenseManager::setSerialKey(QString serialKeyString, bool acceptExpired)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
LicenseManager::notifyUpdate(QString fromVersion, QString toVersion) {
|
||||
if ((fromVersion == "Unknown")
|
||||
&& (m_serialKey == SerialKey(kUnregistered))) {
|
||||
return;
|
||||
}
|
||||
|
||||
ActivationNotifier* notifier = new ActivationNotifier();
|
||||
notifier->setUpdateInfo (fromVersion, toVersion,
|
||||
QString::fromStdString(m_serialKey.toString()));
|
||||
|
||||
QThread* thread = new QThread();
|
||||
connect(notifier, SIGNAL(finished()), thread, SLOT(quit()));
|
||||
connect(notifier, SIGNAL(finished()), notifier, SLOT(deleteLater()));
|
||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||
|
||||
notifier->moveToThread(thread);
|
||||
thread->start();
|
||||
|
||||
QMetaObject::invokeMethod(notifier, "notifyUpdate",
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
Edition
|
||||
LicenseManager::activeEdition() const
|
||||
{
|
||||
|
||||
@@ -36,9 +36,8 @@ public:
|
||||
QString activeEditionName() const;
|
||||
SerialKey serialKey() const;
|
||||
void skipActivation();
|
||||
void notifyUpdate(QString fromVersion, QString toVersion);
|
||||
static QString getEditionName(Edition edition, bool trial = false);
|
||||
|
||||
private:
|
||||
void notifyActivation(QString identity);
|
||||
|
||||
private:
|
||||
|
||||
@@ -157,6 +157,14 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig,
|
||||
|
||||
setWindowTitle (m_LicenseManager->activeEditionName());
|
||||
m_LicenseManager->refresh();
|
||||
|
||||
QString lastVersion = m_AppConfig->lastVersion();
|
||||
QString currentVersion = m_VersionChecker.getVersion();
|
||||
if (lastVersion != currentVersion) {
|
||||
m_AppConfig->setLastVersion (currentVersion);
|
||||
m_AppConfig->saveSettings();
|
||||
m_LicenseManager->notifyUpdate (lastVersion, currentVersion);
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
||||
@@ -116,7 +116,6 @@ CurlFacade::urlEncode(const String& url)
|
||||
char* resultCStr = curl_easy_escape(m_curl, url.c_str(), 0);
|
||||
|
||||
if (resultCStr == NULL) {
|
||||
curl_free(resultCStr);
|
||||
throw XArch("CURL escape failed.");
|
||||
}
|
||||
|
||||
|
||||
@@ -195,6 +195,10 @@ ArgParser::parseToolArgs(ToolArgs& args, int argc, const char* const* argv)
|
||||
args.m_notifyActivation = true;
|
||||
return true;
|
||||
}
|
||||
else if (isArg(i, argc, argv, NULL, "--notify-update", 0)) {
|
||||
args.m_notifyUpdate = true;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2014-2016 Symless Ltd.
|
||||
*
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file LICENSE that should have accompanied this file.
|
||||
*
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
@@ -80,6 +80,9 @@ ToolApp::run(int argc, char** argv)
|
||||
else if (m_args.m_getArch) {
|
||||
std::cout << ARCH->getPlatformName() << std::endl;
|
||||
}
|
||||
else if (m_args.m_notifyUpdate) {
|
||||
notifyUpdate();
|
||||
}
|
||||
else if (m_args.m_notifyActivation) {
|
||||
notifyActivation();
|
||||
}
|
||||
@@ -134,7 +137,30 @@ ToolApp::loginAuth()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ToolApp::notifyUpdate()
|
||||
{
|
||||
String data;
|
||||
std::cin >> data;
|
||||
|
||||
std::vector<String> parts = synergy::string::splitString(data, ':');
|
||||
size_t count = parts.size();
|
||||
|
||||
if (count == 3) {
|
||||
std::stringstream ss;
|
||||
ss << JSON_URL << "notify/update";
|
||||
ss << "?from=" << parts[0];
|
||||
ss << "&to=" << parts[1];
|
||||
ss << "&serial=" << parts[2];
|
||||
|
||||
std::cout << ARCH->internet().get(ss.str()) << std::endl;
|
||||
}
|
||||
else {
|
||||
throw XSynergy("Invalid update data.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ToolApp::notifyActivation()
|
||||
{
|
||||
String info;
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
private:
|
||||
void loginAuth();
|
||||
void notifyActivation();
|
||||
void notifyUpdate();
|
||||
|
||||
private:
|
||||
ToolArgs m_args;
|
||||
|
||||
@@ -23,6 +23,7 @@ ToolArgs::ToolArgs() :
|
||||
m_getInstalledDir(false),
|
||||
m_getProfileDir(false),
|
||||
m_getArch(false),
|
||||
m_notifyActivation(false)
|
||||
m_notifyActivation(false),
|
||||
m_notifyUpdate(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -30,4 +30,5 @@ public:
|
||||
bool m_getProfileDir;
|
||||
bool m_getArch;
|
||||
bool m_notifyActivation;
|
||||
bool m_notifyUpdate;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user