seperated login result and edition type #4168
This commit is contained in:
parent
bfa9bab78d
commit
da68664bda
|
@ -92,6 +92,7 @@ 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
|
||||
|
|
|
@ -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_UserType = settings().value("userType", 0).toInt();
|
||||
m_EditionType = settings().value("editionType", 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("userType", m_UserType);
|
||||
settings().setValue("editionType", m_EditionType);
|
||||
}
|
||||
|
||||
void AppConfig::setCryptoPass(const QString &s)
|
||||
|
|
|
@ -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 userType() const { return m_UserType; }
|
||||
const int editionType() const { return m_EditionType; }
|
||||
|
||||
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 setUserType(int t) { m_UserType = t; }
|
||||
void setEditionType(int t) { m_EditionType = t; }
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
|
@ -126,7 +126,7 @@ class AppConfig
|
|||
bool m_AutoConfigPrompted;
|
||||
QString m_UserEmail;
|
||||
QString m_UserToken;
|
||||
int m_UserType;
|
||||
int m_EditionType;
|
||||
|
||||
static const char m_SynergysName[];
|
||||
static const char m_SynergycName[];
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EDITIONTYPE_H
|
||||
#define EDITIONTYPE_H
|
||||
|
||||
enum qEditionType {
|
||||
Basic,
|
||||
Pro,
|
||||
Unknown
|
||||
};
|
||||
|
||||
#endif // EDITIONTYPE_H
|
|
@ -21,6 +21,7 @@
|
|||
#include "AppConfig.h"
|
||||
#include "QUtility.h"
|
||||
#include "LoginResult.h"
|
||||
#include "EditionType.h"
|
||||
|
||||
#include <QProcess>
|
||||
#include <QCoreApplication>
|
||||
|
@ -29,12 +30,14 @@
|
|||
|
||||
void LoginAuth::checkUserType()
|
||||
{
|
||||
int result = doCheckUserType();
|
||||
int edition = Unknown;
|
||||
int result = doCheckUserType(edition);
|
||||
m_pLoginWindow->setLoginResult(result);
|
||||
m_pLoginWindow->setEditionType(edition);
|
||||
emit finished();
|
||||
}
|
||||
|
||||
int LoginAuth::doCheckUserType()
|
||||
int LoginAuth::doCheckUserType(int& edition)
|
||||
{
|
||||
QString responseJson;
|
||||
|
||||
|
@ -52,7 +55,12 @@ int LoginAuth::doCheckUserType()
|
|||
if (resultRegex.exactMatch(responseJson)) {
|
||||
QString boolString = resultRegex.cap(1);
|
||||
if (boolString == "true") {
|
||||
return Home;
|
||||
QRegExp editionRegex(".*\"edition\".*:.*\"(.+)\",.*");
|
||||
if (editionRegex.exactMatch(responseJson)) {
|
||||
QString e = editionRegex.cap(1);
|
||||
edition = e.toInt();
|
||||
}
|
||||
return Ok;
|
||||
}
|
||||
else if (boolString == "false") {
|
||||
return InvalidEmailPassword;
|
||||
|
|
|
@ -29,7 +29,7 @@ class LoginAuth : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
int doCheckUserType();
|
||||
int doCheckUserType(int& edition);
|
||||
void setEmail(QString email) { m_Email = email; }
|
||||
void setPassword(QString password) { m_Password = password; }
|
||||
void setLoginWindow(LoginWindow* w) { m_pLoginWindow = w; }
|
||||
|
|
|
@ -1,32 +1,29 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LOGINRESULT_H
|
||||
#define LOGINRESULT_H
|
||||
|
||||
enum qLoginResult {
|
||||
Unknown,
|
||||
Student,
|
||||
Home,
|
||||
Professional,
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LOGINRESULT_H
|
||||
#define LOGINRESULT_H
|
||||
|
||||
enum qLoginResult {
|
||||
Ok,
|
||||
Error,
|
||||
ExceptionError,
|
||||
InvalidEmailPassword,
|
||||
ServerResponseError
|
||||
};
|
||||
|
||||
#endif // LOGINRESULT_H
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "SetupWizard.h"
|
||||
#include "LoginAuth.h"
|
||||
#include "LoginResult.h"
|
||||
#include "EditionType.h"
|
||||
#include "QUtility.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
@ -38,7 +39,8 @@ LoginWindow::LoginWindow(
|
|||
m_pSetupWizard(setupWizard),
|
||||
m_WizardShouldRun(wizardShouldRun),
|
||||
m_pLoginAuth(NULL),
|
||||
m_LoginResult(Unknown),
|
||||
m_LoginResult(Ok),
|
||||
m_EditionType(Unknown),
|
||||
m_AppConfig(m_pMainWindow->appConfig())
|
||||
{
|
||||
setupUi(this);
|
||||
|
@ -88,16 +90,16 @@ void LoginWindow::showNext()
|
|||
m_pSetupWizard->show();
|
||||
}
|
||||
else {
|
||||
m_pMainWindow->setLoginResult(m_LoginResult);
|
||||
m_pMainWindow->setEditionType(m_EditionType);
|
||||
if (!m_pLineEditEmail->text().isEmpty()) {
|
||||
m_AppConfig.setUserEmail(m_pLineEditEmail->text());
|
||||
|
||||
if (m_LoginResult != Unknown) {
|
||||
if (m_EditionType != Unknown) {
|
||||
QString mac = getFirstMacAddress();
|
||||
QString hashSrc = m_pLineEditEmail->text() + mac;
|
||||
QString hashResult = hash(hashSrc);
|
||||
m_AppConfig.setUserToken(hashResult);
|
||||
m_AppConfig.setUserType(m_LoginResult);
|
||||
m_AppConfig.setEditionType(m_EditionType);
|
||||
}
|
||||
}
|
||||
m_pMainWindow->show();
|
||||
|
@ -106,8 +108,9 @@ void LoginWindow::showNext()
|
|||
|
||||
delete m_pLoginAuth;
|
||||
m_pLoginAuth = NULL;
|
||||
m_LoginResult = Unknown;
|
||||
m_pPushButtonLogin->setText("Login");
|
||||
m_LoginResult = Ok;
|
||||
m_EditionType = Unknown;
|
||||
m_pPushButtonLogin->setEnabled(true);
|
||||
m_pPushButtonLogin->setDefault(true);
|
||||
}
|
||||
|
||||
|
@ -150,7 +153,7 @@ void LoginWindow::on_m_pPushButtonLogin_clicked()
|
|||
m_pLoginAuth->setLoginWindow(this);
|
||||
}
|
||||
|
||||
m_pPushButtonLogin->setText("Logging...");
|
||||
m_pPushButtonLogin->setEnabled(false);
|
||||
|
||||
QString email = m_pLineEditEmail->text();
|
||||
QString password = m_pLineEditPassword->text();
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
~LoginWindow();
|
||||
|
||||
void setLoginResult(int result) { m_LoginResult = result; }
|
||||
void setEditionType(int type) { m_EditionType = type; }
|
||||
void setError(QString error) { m_Error = error; }
|
||||
|
||||
protected:
|
||||
|
@ -57,6 +58,7 @@ private:
|
|||
bool m_WizardShouldRun;
|
||||
LoginAuth* m_pLoginAuth;
|
||||
int m_LoginResult;
|
||||
int m_EditionType;
|
||||
QString m_Error;
|
||||
AppConfig& m_AppConfig;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "DataDownloader.h"
|
||||
#include "CommandProcess.h"
|
||||
#include "LoginAuth.h"
|
||||
#include "LoginResult.h"
|
||||
#include "EditionType.h"
|
||||
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
|
@ -92,7 +92,7 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
|
|||
m_SuppressAutoConfigWarning(false),
|
||||
m_BonjourInstall(NULL),
|
||||
m_SuppressEmptyServerWarning(false),
|
||||
m_LoginResult(Unknown)
|
||||
m_EditionType(Unknown)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
|
@ -878,17 +878,14 @@ int MainWindow::checkWinArch()
|
|||
return unknown;
|
||||
}
|
||||
|
||||
void MainWindow::setLoginResult(int result)
|
||||
void MainWindow::setEditionType(int type)
|
||||
{
|
||||
m_LoginResult = result;
|
||||
m_EditionType = type;
|
||||
QString title;
|
||||
if (result == Student) {
|
||||
title = "Synergy Student";
|
||||
if (type == Basic) {
|
||||
title = "Synergy Basic";
|
||||
}
|
||||
else if (result == Home) {
|
||||
title = "Synergy Home";
|
||||
}
|
||||
else if (result == Professional) {
|
||||
else if (type == Pro) {
|
||||
title = "Synergy Pro";
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -112,7 +112,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
|||
void updateZeroconfService();
|
||||
void serverDetected(const QString name);
|
||||
int checkWinArch();
|
||||
void setLoginResult(int result);
|
||||
void setEditionType(int edition);
|
||||
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_LoginResult;
|
||||
int m_EditionType;
|
||||
|
||||
private slots:
|
||||
void on_m_pCheckBoxAutoConfig_toggled(bool checked);
|
||||
|
|
|
@ -105,7 +105,7 @@ int main(int argc, char* argv[])
|
|||
QString hashSrc = email + mac;
|
||||
QString hashResult = hash(hashSrc);
|
||||
if (hashResult == appConfig.userToken()) {
|
||||
mainWindow.setLoginResult(appConfig.userType());
|
||||
mainWindow.setEditionType(appConfig.editionType());
|
||||
mainWindow.show();
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue