diff --git a/src/gui/main/gui.pro b/src/gui/main/gui.pro index da083775..23781f59 100644 --- a/src/gui/main/gui.pro +++ b/src/gui/main/gui.pro @@ -92,7 +92,6 @@ HEADERS += src/MainWindow.h \ src/CommandProcess.h \ src/LoginWindow.h \ src/LoginAuth.h \ - src/EditionType.h \ src/LoginResult.h RESOURCES += res/Synergy.qrc RC_FILE = res/win/Synergy.rc diff --git a/src/gui/main/src/AppConfig.cpp b/src/gui/main/src/AppConfig.cpp index d88ce20e..5e1746b0 100644 --- a/src/gui/main/src/AppConfig.cpp +++ b/src/gui/main/src/AppConfig.cpp @@ -129,7 +129,7 @@ void AppConfig::loadSettings() m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool(); m_UserEmail = settings().value("userEmail", "").toString(); m_UserToken = settings().value("userToken", "").toString(); - m_EditionType = settings().value("editionType", 0).toInt(); + m_UserType = settings().value("userType", 0).toInt(); } void AppConfig::saveSettings() @@ -150,7 +150,7 @@ void AppConfig::saveSettings() settings().setValue("autoConfigPrompted", m_AutoConfigPrompted); settings().setValue("userEmail", m_UserEmail); settings().setValue("userToken", m_UserToken); - settings().setValue("editionType", m_EditionType); + settings().setValue("userType", m_UserType); } void AppConfig::setCryptoPass(const QString &s) diff --git a/src/gui/main/src/AppConfig.h b/src/gui/main/src/AppConfig.h index d14ca8ac..6144844b 100644 --- a/src/gui/main/src/AppConfig.h +++ b/src/gui/main/src/AppConfig.h @@ -75,7 +75,7 @@ class AppConfig void setAutoConfigPrompted(bool prompted); const QString& userEmail() const { return m_UserEmail; } const QString& userToken() const { return m_UserToken; } - const int editionType() const { return m_EditionType; } + const int userType() const { return m_UserType; } QString synergysName() const { return m_SynergysName; } QString synergycName() const { return m_SynergycName; } @@ -101,7 +101,7 @@ class AppConfig void setElevateMode(bool b) { m_ElevateMode = b; } void setUserEmail(const QString& e) { m_UserEmail = e; } void setUserToken(const QString& t) { m_UserToken = t; } - void setEditionType(int t) { m_EditionType = t; } + void setUserType(int t) { m_UserType = t; } void loadSettings(); void saveSettings(); @@ -126,7 +126,7 @@ class AppConfig bool m_AutoConfigPrompted; QString m_UserEmail; QString m_UserToken; - int m_EditionType; + int m_UserType; static const char m_SynergysName[]; static const char m_SynergycName[]; diff --git a/src/gui/main/src/EditionType.h b/src/gui/main/src/EditionType.h deleted file mode 100644 index d4132ea8..00000000 --- a/src/gui/main/src/EditionType.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2015 Synergy Si 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 COPYING 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 - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef EDITIONTYPE_H -#define EDITIONTYPE_H - -enum qEditionType { - Basic, - Pro, - Unknown -}; - -#endif // EDITIONTYPE_H diff --git a/src/gui/main/src/LoginAuth.cpp b/src/gui/main/src/LoginAuth.cpp index a45ffc93..ea54ded0 100644 --- a/src/gui/main/src/LoginAuth.cpp +++ b/src/gui/main/src/LoginAuth.cpp @@ -21,7 +21,6 @@ #include "AppConfig.h" #include "QUtility.h" #include "LoginResult.h" -#include "EditionType.h" #include #include @@ -30,14 +29,12 @@ void LoginAuth::checkUserType() { - int edition = Unknown; - int result = doCheckUserType(edition); + int result = doCheckUserType(); m_pLoginWindow->setLoginResult(result); - m_pLoginWindow->setEditionType(edition); emit finished(); } -int LoginAuth::doCheckUserType(int& edition) +int LoginAuth::doCheckUserType() { QString responseJson; @@ -55,12 +52,7 @@ int LoginAuth::doCheckUserType(int& edition) if (resultRegex.exactMatch(responseJson)) { QString boolString = resultRegex.cap(1); if (boolString == "true") { - QRegExp editionRegex(".*\"edition\".*:.*\"(.+)\",.*"); - if (editionRegex.exactMatch(responseJson)) { - QString e = editionRegex.cap(1); - edition = e.toInt(); - } - return Ok; + return Home; } else if (boolString == "false") { return InvalidEmailPassword; diff --git a/src/gui/main/src/LoginAuth.h b/src/gui/main/src/LoginAuth.h index 560c284e..4df8d860 100644 --- a/src/gui/main/src/LoginAuth.h +++ b/src/gui/main/src/LoginAuth.h @@ -29,7 +29,7 @@ class LoginAuth : public QObject Q_OBJECT public: - int doCheckUserType(int& edition); + int doCheckUserType(); void setEmail(QString email) { m_Email = email; } void setPassword(QString password) { m_Password = password; } void setLoginWindow(LoginWindow* w) { m_pLoginWindow = w; } diff --git a/src/gui/main/src/LoginResult.h b/src/gui/main/src/LoginResult.h index 821f890d..1cda4978 100644 --- a/src/gui/main/src/LoginResult.h +++ b/src/gui/main/src/LoginResult.h @@ -1,29 +1,32 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2015 Synergy Si 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 COPYING 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 - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef LOGINRESULT_H -#define LOGINRESULT_H - -enum qLoginResult { - Ok, - Error, - ExceptionError, - InvalidEmailPassword, - ServerResponseError -}; - -#endif // LOGINRESULT_H +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2015 Synergy Si 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 COPYING 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 + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LOGINRESULT_H +#define LOGINRESULT_H + +enum qLoginResult { + Unknown, + Student, + Home, + Professional, + Error, + ExceptionError, + InvalidEmailPassword, + ServerResponseError +}; + +#endif // LOGINRESULT_H diff --git a/src/gui/main/src/LoginWindow.cpp b/src/gui/main/src/LoginWindow.cpp index ef2c28e2..34909959 100644 --- a/src/gui/main/src/LoginWindow.cpp +++ b/src/gui/main/src/LoginWindow.cpp @@ -22,7 +22,6 @@ #include "SetupWizard.h" #include "LoginAuth.h" #include "LoginResult.h" -#include "EditionType.h" #include "QUtility.h" #include @@ -39,8 +38,7 @@ LoginWindow::LoginWindow( m_pSetupWizard(setupWizard), m_WizardShouldRun(wizardShouldRun), m_pLoginAuth(NULL), - m_LoginResult(Ok), - m_EditionType(Unknown), + m_LoginResult(Unknown), m_AppConfig(m_pMainWindow->appConfig()) { setupUi(this); @@ -90,16 +88,16 @@ void LoginWindow::showNext() m_pSetupWizard->show(); } else { - m_pMainWindow->setEditionType(m_EditionType); + m_pMainWindow->setLoginResult(m_LoginResult); if (!m_pLineEditEmail->text().isEmpty()) { m_AppConfig.setUserEmail(m_pLineEditEmail->text()); - if (m_EditionType != Unknown) { + if (m_LoginResult != Unknown) { QString mac = getFirstMacAddress(); QString hashSrc = m_pLineEditEmail->text() + mac; QString hashResult = hash(hashSrc); m_AppConfig.setUserToken(hashResult); - m_AppConfig.setEditionType(m_EditionType); + m_AppConfig.setUserType(m_LoginResult); } } m_pMainWindow->show(); @@ -108,9 +106,8 @@ void LoginWindow::showNext() delete m_pLoginAuth; m_pLoginAuth = NULL; - m_LoginResult = Ok; - m_EditionType = Unknown; - m_pPushButtonLogin->setEnabled(true); + m_LoginResult = Unknown; + m_pPushButtonLogin->setText("Login"); m_pPushButtonLogin->setDefault(true); } @@ -153,7 +150,7 @@ void LoginWindow::on_m_pPushButtonLogin_clicked() m_pLoginAuth->setLoginWindow(this); } - m_pPushButtonLogin->setEnabled(false); + m_pPushButtonLogin->setText("Logging..."); QString email = m_pLineEditEmail->text(); QString password = m_pLineEditPassword->text(); diff --git a/src/gui/main/src/LoginWindow.h b/src/gui/main/src/LoginWindow.h index e0e6d464..da0906bc 100644 --- a/src/gui/main/src/LoginWindow.h +++ b/src/gui/main/src/LoginWindow.h @@ -38,7 +38,6 @@ public: ~LoginWindow(); void setLoginResult(int result) { m_LoginResult = result; } - void setEditionType(int type) { m_EditionType = type; } void setError(QString error) { m_Error = error; } protected: @@ -58,7 +57,6 @@ private: bool m_WizardShouldRun; LoginAuth* m_pLoginAuth; int m_LoginResult; - int m_EditionType; QString m_Error; AppConfig& m_AppConfig; diff --git a/src/gui/main/src/MainWindow.cpp b/src/gui/main/src/MainWindow.cpp index 94526b0a..e6519fc5 100644 --- a/src/gui/main/src/MainWindow.cpp +++ b/src/gui/main/src/MainWindow.cpp @@ -29,7 +29,7 @@ #include "DataDownloader.h" #include "CommandProcess.h" #include "LoginAuth.h" -#include "EditionType.h" +#include "LoginResult.h" #include #include @@ -92,7 +92,7 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) : m_SuppressAutoConfigWarning(false), m_BonjourInstall(NULL), m_SuppressEmptyServerWarning(false), - m_EditionType(Unknown) + m_LoginResult(Unknown) { setupUi(this); @@ -878,14 +878,17 @@ int MainWindow::checkWinArch() return unknown; } -void MainWindow::setEditionType(int type) +void MainWindow::setLoginResult(int result) { - m_EditionType = type; + m_LoginResult = result; QString title; - if (type == Basic) { - title = "Synergy Basic"; + if (result == Student) { + title = "Synergy Student"; } - else if (type == Pro) { + else if (result == Home) { + title = "Synergy Home"; + } + else if (result == Professional) { title = "Synergy Pro"; } else { diff --git a/src/gui/main/src/MainWindow.h b/src/gui/main/src/MainWindow.h index 91ff5609..9814c7e9 100644 --- a/src/gui/main/src/MainWindow.h +++ b/src/gui/main/src/MainWindow.h @@ -112,7 +112,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase void updateZeroconfService(); void serverDetected(const QString name); int checkWinArch(); - void setEditionType(int edition); + void setLoginResult(int result); AppConfig& appConfig() { return m_AppConfig; } public slots: @@ -193,7 +193,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase bool m_SuppressAutoConfigWarning; CommandProcess* m_BonjourInstall; bool m_SuppressEmptyServerWarning; - int m_EditionType; + int m_LoginResult; private slots: void on_m_pCheckBoxAutoConfig_toggled(bool checked); diff --git a/src/gui/main/src/main.cpp b/src/gui/main/src/main.cpp index 48141299..f07c859a 100644 --- a/src/gui/main/src/main.cpp +++ b/src/gui/main/src/main.cpp @@ -105,7 +105,7 @@ int main(int argc, char* argv[]) QString hashSrc = email + mac; QString hashResult = hash(hashSrc); if (hashResult == appConfig.userToken()) { - mainWindow.setEditionType(appConfig.editionType()); + mainWindow.setLoginResult(appConfig.userType()); mainWindow.show(); } else {