#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

@@ -208,6 +208,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-upgrade", 0)) {
args.m_notifyUpgrade = true;
return true;
}
else {
return false;
}

View File

@@ -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_notifyUpgrade) {
notifyUpgrade();
}
else if (m_args.m_notifyActivation) {
notifyActivation();
}
@@ -134,7 +137,29 @@ ToolApp::loginAuth()
}
}
void
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
ToolApp::notifyActivation()
{
String info;

View File

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

View File

@@ -23,6 +23,7 @@ ToolArgs::ToolArgs() :
m_getInstalledDir(false),
m_getProfileDir(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_getArch;
bool m_notifyActivation;
bool m_notifyUpgrade;
};