#5707 Add support for upgrade notifications

This commit is contained in:
Andrew Nelless 2016-10-26 20:14:02 +01:00 committed by Andrew Nelless
parent 9f1e91cc76
commit 2de06b9727
9 changed files with 49 additions and 4 deletions

View File

@ -62,6 +62,12 @@ QString CoreInterface::getSerialKeyFilePath()
return filename; return filename;
} }
QString CoreInterface::notifyUpgrade (QString const& version,
QString const& serialKey) {
QStringList args("--notify-upgrade");
QString input(version + ":" + serialKey);
return run(args, input);
}
QString CoreInterface::notifyActivation(const QString& identity) QString CoreInterface::notifyActivation(const QString& identity)
{ {

View File

@ -29,5 +29,6 @@ public:
QString getArch(); QString getArch();
QString getSerialKeyFilePath(); QString getSerialKeyFilePath();
QString notifyActivation(const QString& identity); QString notifyActivation(const QString& identity);
QString notifyUpgrade (QString const& version, QString const& serialKey);
QString run(const QStringList& args, const QString& input = ""); QString run(const QStringList& args, const QString& input = "");
}; };

View File

@ -71,6 +71,11 @@ LicenseManager::setSerialKey(QString serialKeyString, bool acceptExpired)
return ret; return ret;
} }
void
LicenseManager::notifyUpdate(QString version) {
}
Edition Edition
LicenseManager::activeEdition() const LicenseManager::activeEdition() const
{ {

View File

@ -36,6 +36,7 @@ public:
QString activeEditionName() const; QString activeEditionName() const;
SerialKey serialKey() const; SerialKey serialKey() const;
void skipActivation(); void skipActivation();
void notifyUpdate(QString version);
static QString getEditionName(Edition edition, bool trial = false); static QString getEditionName(Edition edition, bool trial = false);
private: private:

View File

@ -208,6 +208,10 @@ ArgParser::parseToolArgs(ToolArgs& args, int argc, const char* const* argv)
args.m_notifyActivation = true; args.m_notifyActivation = true;
return true; return true;
} }
else if (isArg(i, argc, argv, NULL, "--notify-upgrade", 0)) {
args.m_notifyUpgrade = true;
return true;
}
else { else {
return false; return false;
} }

View File

@ -80,6 +80,9 @@ ToolApp::run(int argc, char** argv)
else if (m_args.m_getArch) { else if (m_args.m_getArch) {
std::cout << ARCH->getPlatformName() << std::endl; std::cout << ARCH->getPlatformName() << std::endl;
} }
else if (m_args.m_notifyUpgrade) {
notifyUpgrade();
}
else if (m_args.m_notifyActivation) { else if (m_args.m_notifyActivation) {
notifyActivation(); notifyActivation();
} }
@ -134,6 +137,28 @@ ToolApp::loginAuth()
} }
} }
void
ToolApp::notifyUpgrade()
{
String data;
std::cin >> data;
std::vector<String> parts = synergy::string::splitString(data, ':');
size_t count = parts.size();
if (count == 2) {
std::stringstream ss;
ss << JSON_URL << "notify/upgraded/";
ss << "?version=" << parts[0];
ss << "&serial=" << parts[1];
std::cout << ARCH->internet().get(ss.str()) << std::endl;
}
else {
throw XSynergy("Invalid upgrade data.");
}
}
void void
ToolApp::notifyActivation() ToolApp::notifyActivation()
{ {

View File

@ -30,6 +30,7 @@ public:
private: private:
void loginAuth(); void loginAuth();
void notifyActivation(); void notifyActivation();
void notifyUpgrade();
private: private:
ToolArgs m_args; ToolArgs m_args;

View File

@ -23,6 +23,7 @@ ToolArgs::ToolArgs() :
m_getInstalledDir(false), m_getInstalledDir(false),
m_getProfileDir(false), m_getProfileDir(false),
m_getArch(false), m_getArch(false),
m_notifyActivation(false) m_notifyActivation(false),
m_notifyUpgrade(false)
{ {
} }

View File

@ -30,4 +30,5 @@ public:
bool m_getProfileDir; bool m_getProfileDir;
bool m_getArch; bool m_getArch;
bool m_notifyActivation; bool m_notifyActivation;
bool m_notifyUpgrade;
}; };