diff --git a/src/gui/src/CoreInterface.cpp b/src/gui/src/CoreInterface.cpp index 9bc8d132..1a917382 100644 --- a/src/gui/src/CoreInterface.cpp +++ b/src/gui/src/CoreInterface.cpp @@ -71,6 +71,12 @@ QString CoreInterface::checkSubscription() return run(args); } +QString CoreInterface::notifyActivation(const QString& input) +{ + QStringList args("--notify-activation"); + return run(args, input); +} + QString CoreInterface::run(const QStringList& args, const QString& input) { QString program( diff --git a/src/gui/src/CoreInterface.h b/src/gui/src/CoreInterface.h index dc2f9fb6..4949bddc 100644 --- a/src/gui/src/CoreInterface.h +++ b/src/gui/src/CoreInterface.h @@ -31,5 +31,6 @@ public: QString getSubscriptionFilename(); QString activateSerial(const QString& serial); QString checkSubscription(); + QString notifyActivation(const QString& input); QString run(const QStringList& args, const QString& input = ""); }; diff --git a/src/gui/src/SetupWizard.cpp b/src/gui/src/SetupWizard.cpp index cc8fd9ca..bbe14328 100644 --- a/src/gui/src/SetupWizard.cpp +++ b/src/gui/src/SetupWizard.cpp @@ -216,6 +216,17 @@ void SetupWizard::accept() if (m_pRadioButtonSubscription->isChecked()) { appConfig.setSerialKey(m_pLineEditSerialKey->text()); + + QString info("serial:" + hash(getFirstMacAddress()) + "\n"); + CoreInterface coreInterface; + coreInterface.notifyActivation(info); + } + + if (m_pRadioButtonSkip->isChecked()) + { + QString info("skip:" + hash(getFirstMacAddress()) + "\n"); + CoreInterface coreInterface; + coreInterface.notifyActivation(info); } m_MainWindow.setEdition(m_Edition); diff --git a/src/gui/src/WebClient.cpp b/src/gui/src/WebClient.cpp index 6de6d9ca..c231c970 100644 --- a/src/gui/src/WebClient.cpp +++ b/src/gui/src/WebClient.cpp @@ -94,6 +94,6 @@ QString WebClient::request( { QStringList args("--login-auth"); // hash password in case it contains interesting chars. - QString credentials(email + ":" + hash(password) + "\n"); + QString credentials(email + ":" + hash(password) + ":" + hash(getFirstMacAddress()) + "\n"); return m_CoreInterface.run(args, credentials); } diff --git a/src/lib/synergy/ArgParser.cpp b/src/lib/synergy/ArgParser.cpp index 92185b26..ba0a103c 100644 --- a/src/lib/synergy/ArgParser.cpp +++ b/src/lib/synergy/ArgParser.cpp @@ -211,6 +211,10 @@ ArgParser::parseToolArgs(ToolArgs& args, int argc, const char* const* argv) args.m_checkSubscription = true; return true; } + else if (isArg(i, argc, argv, NULL, "--notify-activation", 0)) { + args.m_notifyActivation = true; + return true; + } else { return false; } diff --git a/src/lib/synergy/ToolApp.cpp b/src/lib/synergy/ToolApp.cpp index f6cd2ef5..436db09d 100644 --- a/src/lib/synergy/ToolApp.cpp +++ b/src/lib/synergy/ToolApp.cpp @@ -117,6 +117,9 @@ ToolApp::run(int argc, char** argv) return kExitSubscription; } } + else if (m_args.m_notifyActivation) { + notifyActivation(); + } else { throw XSynergy("Nothing to do"); } @@ -149,14 +152,17 @@ ToolApp::loginAuth() String credentials; std::cin >> credentials; - size_t separator = credentials.find(':'); - String email = credentials.substr(0, separator); - String password = credentials.substr(separator + 1, credentials.length()); + size_t separator1 = credentials.find(':'); + size_t separator2 = credentials.find(':', separator1 + 1); + String email = credentials.substr(0, separator1); + String password = credentials.substr(separator1 + 1, separator2 - separator1 - 1); + String macHash = credentials.substr(separator2 + 1, credentials.length() - separator2 - 1); std::stringstream ss; ss << JSON_URL << "auth/"; ss << "?email=" << ARCH->internet().urlEncode(email); ss << "&password=" << password; + ss << "&mac=" << macHash; ss << "&os=" << ARCH->internet().urlEncode(ARCH->getOSName()); ss << "&arch=" << ARCH->internet().urlEncode(ARCH->getPlatformName()); @@ -179,4 +185,24 @@ ToolApp::getPluginList() ss << "&password=" << password; std::cout << ARCH->internet().get(ss.str()) << std::endl; -} \ No newline at end of file +} + +void +ToolApp::notifyActivation() +{ + String info; + std::cin >> info; + + size_t separator = info.find(':'); + String action = info.substr(0, separator); + String macHash = info.substr(separator + 1, info.length()); + + std::stringstream ss; + ss << JSON_URL << "notify/"; + ss << "?action=" << action; + ss << "&mac=" << macHash; + ss << "&os=" << ARCH->internet().urlEncode(ARCH->getOSName()); + ss << "&arch=" << ARCH->internet().urlEncode(ARCH->getPlatformName()); + + std::cout << ARCH->internet().get(ss.str()) << std::endl; +} diff --git a/src/lib/synergy/ToolApp.h b/src/lib/synergy/ToolApp.h index 08947c6e..7f0b6ea7 100644 --- a/src/lib/synergy/ToolApp.h +++ b/src/lib/synergy/ToolApp.h @@ -30,6 +30,7 @@ public: private: void loginAuth(); void getPluginList(); + void notifyActivation(); private: ToolArgs m_args; diff --git a/src/lib/synergy/ToolArgs.cpp b/src/lib/synergy/ToolArgs.cpp index 0fd68a92..23439317 100644 --- a/src/lib/synergy/ToolArgs.cpp +++ b/src/lib/synergy/ToolArgs.cpp @@ -27,6 +27,7 @@ ToolArgs::ToolArgs() : m_getArch(false), m_getSubscriptionFilename(false), m_checkSubscription(false), + m_notifyActivation(false), m_subscriptionSerial() { } diff --git a/src/lib/synergy/ToolArgs.h b/src/lib/synergy/ToolArgs.h index ffbf932e..fb0b3e78 100644 --- a/src/lib/synergy/ToolArgs.h +++ b/src/lib/synergy/ToolArgs.h @@ -33,5 +33,6 @@ public: bool m_getArch; bool m_getSubscriptionFilename; bool m_checkSubscription; + bool m_notifyActivation; String m_subscriptionSerial; };