2013-07-24 16:41:12 +00:00
|
|
|
/*
|
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
2014-11-02 12:12:05 +00:00
|
|
|
* Copyright (C) 2012 Synergy Si Ltd.
|
2013-07-24 16:41:12 +00:00
|
|
|
*
|
|
|
|
|
* 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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "SetupWizard.h"
|
|
|
|
|
#include "MainWindow.h"
|
2015-02-05 14:17:34 +00:00
|
|
|
#include "WebClient.h"
|
|
|
|
|
#include "EditionType.h"
|
2013-07-24 16:41:12 +00:00
|
|
|
#include "QSynergyApplication.h"
|
|
|
|
|
#include "QUtility.h"
|
|
|
|
|
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
|
|
|
|
SetupWizard::SetupWizard(MainWindow& mainWindow, bool startMain) :
|
|
|
|
|
m_MainWindow(mainWindow),
|
2015-02-05 14:17:34 +00:00
|
|
|
m_StartMain(startMain),
|
|
|
|
|
m_Edition(Unknown)
|
2013-07-24 16:41:12 +00:00
|
|
|
{
|
|
|
|
|
setupUi(this);
|
2015-02-12 15:50:08 +00:00
|
|
|
m_pPluginPage = new PluginWizardPage(mainWindow.appConfig());
|
2015-02-05 15:52:50 +00:00
|
|
|
addPage(m_pPluginPage);
|
2013-07-24 16:41:12 +00:00
|
|
|
|
|
|
|
|
#if defined(Q_OS_MAC)
|
|
|
|
|
|
|
|
|
|
// the mac style needs a little more room because of the
|
|
|
|
|
// graphic on the left.
|
|
|
|
|
resize(600, 500);
|
|
|
|
|
setMinimumSize(size());
|
|
|
|
|
|
|
|
|
|
#elif defined(Q_OS_WIN)
|
|
|
|
|
|
|
|
|
|
// when areo is disabled on windows, the next/back buttons
|
|
|
|
|
// are hidden (must be a qt bug) -- resizing the window
|
|
|
|
|
// to +1 of the original height seems to fix this.
|
|
|
|
|
// NOTE: calling setMinimumSize after this will break
|
|
|
|
|
// it again, so don't do that.
|
|
|
|
|
resize(size().width(), size().height() + 1);
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
connect(m_pServerRadioButton, SIGNAL(toggled(bool)), m_MainWindow.m_pGroupServer, SLOT(setChecked(bool)));
|
|
|
|
|
connect(m_pClientRadioButton, SIGNAL(toggled(bool)), m_MainWindow.m_pGroupClient, SLOT(setChecked(bool)));
|
|
|
|
|
|
|
|
|
|
m_Locale.fillLanguageComboBox(m_pComboLanguage);
|
|
|
|
|
setIndexFromItemData(m_pComboLanguage, m_MainWindow.appConfig().language());
|
2015-02-05 14:17:34 +00:00
|
|
|
AppConfig& appConfig = m_MainWindow.appConfig();
|
|
|
|
|
|
|
|
|
|
m_pLineEditEmail->setText(appConfig.activateEmail());
|
2014-10-14 16:20:57 +00:00
|
|
|
|
2013-07-24 16:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetupWizard::~SetupWizard()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SetupWizard::validateCurrentPage()
|
|
|
|
|
{
|
|
|
|
|
QMessageBox message;
|
|
|
|
|
message.setWindowTitle(tr("Setup Synergy"));
|
|
|
|
|
message.setIcon(QMessageBox::Information);
|
|
|
|
|
|
2015-02-05 14:17:34 +00:00
|
|
|
if (currentPage() == m_pActivatePage)
|
|
|
|
|
{
|
|
|
|
|
if (m_pRadioButtonActivate->isChecked()) {
|
|
|
|
|
if (m_pLineEditEmail->text().isEmpty() ||
|
|
|
|
|
m_pLineEditPassword->text().isEmpty()) {
|
|
|
|
|
message.setText(tr("Please enter your email address and password."));
|
|
|
|
|
message.exec();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
WebClient webClient;
|
|
|
|
|
m_Edition = webClient .getEdition(
|
|
|
|
|
m_pLineEditEmail->text(),
|
|
|
|
|
m_pLineEditPassword->text(),
|
|
|
|
|
message,
|
|
|
|
|
this);
|
|
|
|
|
|
|
|
|
|
if (m_Edition == Unknown) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2015-02-06 10:39:58 +00:00
|
|
|
m_pPluginPage->setEmail(m_pLineEditEmail->text());
|
|
|
|
|
m_pPluginPage->setPassword(m_pLineEditPassword->text());
|
2015-02-05 14:17:34 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (currentPage() == m_pNodePage)
|
2013-07-24 16:41:12 +00:00
|
|
|
{
|
|
|
|
|
bool result = m_pClientRadioButton->isChecked() ||
|
|
|
|
|
m_pServerRadioButton->isChecked();
|
|
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
|
{
|
|
|
|
|
message.setText(tr("Please select an option."));
|
|
|
|
|
message.exec();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetupWizard::changeEvent(QEvent* event)
|
|
|
|
|
{
|
|
|
|
|
if (event != 0)
|
|
|
|
|
{
|
|
|
|
|
switch (event->type())
|
|
|
|
|
{
|
|
|
|
|
case QEvent::LanguageChange:
|
|
|
|
|
{
|
|
|
|
|
m_pComboLanguage->blockSignals(true);
|
|
|
|
|
retranslateUi(this);
|
|
|
|
|
m_pComboLanguage->blockSignals(false);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
QWizard::changeEvent(event);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetupWizard::accept()
|
|
|
|
|
{
|
|
|
|
|
AppConfig& appConfig = m_MainWindow.appConfig();
|
|
|
|
|
|
|
|
|
|
appConfig.setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
|
|
|
|
|
|
|
|
|
appConfig.setWizardHasRun();
|
|
|
|
|
appConfig.saveSettings();
|
|
|
|
|
|
|
|
|
|
QSettings& settings = m_MainWindow.settings();
|
|
|
|
|
if (m_pServerRadioButton->isChecked())
|
|
|
|
|
{
|
|
|
|
|
settings.setValue("groupServerChecked", true);
|
|
|
|
|
settings.setValue("groupClientChecked", false);
|
|
|
|
|
}
|
|
|
|
|
if (m_pClientRadioButton->isChecked())
|
|
|
|
|
{
|
|
|
|
|
settings.setValue("groupClientChecked", true);
|
|
|
|
|
settings.setValue("groupServerChecked", false);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-05 14:17:34 +00:00
|
|
|
if (m_pRadioButtonActivate->isChecked()) {
|
|
|
|
|
appConfig.setActivateEmail(m_pLineEditEmail->text());
|
|
|
|
|
QString mac = getFirstMacAddress();
|
|
|
|
|
QString hashSrc = m_pLineEditEmail->text() + mac;
|
|
|
|
|
QString hashResult = hash(hashSrc);
|
|
|
|
|
appConfig.setUserToken(hashResult);
|
|
|
|
|
appConfig.setEdition(m_Edition);
|
|
|
|
|
}
|
|
|
|
|
m_MainWindow.setEdition(m_Edition);
|
2015-04-21 16:56:01 +00:00
|
|
|
m_MainWindow.updateLocalFingerprint();
|
2015-02-05 14:17:34 +00:00
|
|
|
|
2013-07-24 16:41:12 +00:00
|
|
|
settings.sync();
|
|
|
|
|
|
2014-11-28 15:01:23 +00:00
|
|
|
QWizard::accept();
|
|
|
|
|
|
2013-07-24 16:41:12 +00:00
|
|
|
if (m_StartMain)
|
|
|
|
|
{
|
2014-08-21 17:32:40 +00:00
|
|
|
m_MainWindow.updateZeroconfService();
|
2014-03-21 09:22:18 +00:00
|
|
|
m_MainWindow.open();
|
2013-07-24 16:41:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetupWizard::reject()
|
|
|
|
|
{
|
|
|
|
|
QSynergyApplication::getInstance()->switchTranslator(m_MainWindow.appConfig().language());
|
|
|
|
|
|
|
|
|
|
if (m_StartMain)
|
|
|
|
|
{
|
2015-02-05 14:17:34 +00:00
|
|
|
m_MainWindow.setEdition(m_Edition);
|
2014-03-21 09:22:18 +00:00
|
|
|
m_MainWindow.open();
|
2013-07-24 16:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWizard::reject();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetupWizard::on_m_pComboLanguage_currentIndexChanged(int index)
|
|
|
|
|
{
|
|
|
|
|
QString ietfCode = m_pComboLanguage->itemData(index).toString();
|
|
|
|
|
QSynergyApplication::getInstance()->switchTranslator(ietfCode);
|
|
|
|
|
}
|
2015-02-05 14:17:34 +00:00
|
|
|
|
|
|
|
|
void SetupWizard::on_m_pRadioButtonSkip_toggled(bool checked)
|
|
|
|
|
{
|
|
|
|
|
if (checked) {
|
|
|
|
|
m_pLineEditEmail->setEnabled(false);
|
|
|
|
|
m_pLineEditPassword->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetupWizard::on_m_pRadioButtonActivate_toggled(bool checked)
|
|
|
|
|
{
|
|
|
|
|
if (checked) {
|
|
|
|
|
m_pLineEditEmail->setEnabled(true);
|
|
|
|
|
m_pLineEditPassword->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
}
|