added enable crypto argument to synergys/c #4313

This commit is contained in:
XinyuHou
2015-02-12 15:50:08 +00:00
parent bbcca144f5
commit c4c0fc8a08
24 changed files with 106 additions and 66 deletions

View File

@@ -56,7 +56,8 @@ AppConfig::AppConfig(QSettings* settings) :
m_ProcessMode(DEFAULT_PROCESS_MODE),
m_AutoConfig(true),
m_ElevateMode(false),
m_AutoConfigPrompted(false)
m_AutoConfigPrompted(false),
m_CryptoEnabled(false)
{
Q_ASSERT(m_pSettings);
@@ -128,6 +129,7 @@ void AppConfig::loadSettings()
m_Edition = settings().value("edition", Unknown).toInt();
m_ActivateEmail = settings().value("activateEmail", "").toString();
m_UserToken = settings().value("userToken", "").toString();
m_CryptoEnabled = settings().value("cryptoEnabled", false).toBool();
}
void AppConfig::saveSettings()
@@ -147,6 +149,7 @@ void AppConfig::saveSettings()
settings().setValue("edition", m_Edition);
settings().setValue("activateEmail", m_ActivateEmail);
settings().setValue("userToken", m_UserToken);
settings().setValue("cryptoEnabled", m_CryptoEnabled);
}
void AppConfig::setAutoConfig(bool autoConfig)

View File

@@ -85,6 +85,9 @@ class AppConfig
void persistLogDir();
bool elevateMode();
void setCryptoEnabled(bool e) { m_CryptoEnabled = e; }
bool getCryptoEnabled() { return m_CryptoEnabled; }
protected:
QSettings& settings() { return *m_pSettings; }
void setScreenName(const QString& s) { m_ScreenName = s; }
@@ -119,6 +122,7 @@ class AppConfig
int m_Edition;
QString m_ActivateEmail;
QString m_UserToken;
bool m_CryptoEnabled;
static const char m_SynergysName[];
static const char m_SynergycName[];

View File

@@ -127,6 +127,8 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
m_SuppressAutoConfigWarning = false;
m_pComboServerList->hide();
updateEdition();
}
MainWindow::~MainWindow()
@@ -442,6 +444,10 @@ void MainWindow::startSynergy()
#endif
if (m_AppConfig.getCryptoEnabled()) {
args << "--enable-crypto";
}
if ((synergyType() == synergyClient && !clientArgs(args, app))
|| (synergyType() == synergyServer && !serverArgs(args, app)))
{
@@ -814,15 +820,8 @@ void MainWindow::changeEvent(QEvent* event)
retranslateUi(this);
retranslateMenuBar();
QString mac = getFirstMacAddress();
QString hashSrc = m_AppConfig.activateEmail() + mac;
QString hashResult = hash(hashSrc);
if (hashResult == m_AppConfig.userToken()) {
setEdition(m_AppConfig.edition());
}
else {
setEdition(Unknown);
}
updateEdition();
break;
}
default:
@@ -1149,6 +1148,19 @@ void MainWindow::promptAutoConfig()
m_AppConfig.setAutoConfigPrompted(true);
}
void MainWindow::updateEdition()
{
QString mac = getFirstMacAddress();
QString hashSrc = m_AppConfig.activateEmail() + mac;
QString hashResult = hash(hashSrc);
if (hashResult == m_AppConfig.userToken()) {
setEdition(m_AppConfig.edition());
}
else {
setEdition(Unknown);
}
}
void MainWindow::on_m_pComboServerList_currentIndexChanged(QString )
{
if (m_pComboServerList->count() != 0) {

View File

@@ -160,6 +160,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
bool isBonjourRunning();
void downloadBonjour();
void promptAutoConfig();
void updateEdition();
private:
QSettings& m_Settings;

View File

@@ -7,11 +7,12 @@
#include <QMovie>
#include <QThread>
PluginWizardPage::PluginWizardPage(QWidget *parent) :
PluginWizardPage::PluginWizardPage(AppConfig& appConfig, QWidget *parent) :
QWizardPage(parent),
m_Finished(false),
m_pWebClient(NULL),
m_pPluginManager(NULL)
m_pPluginManager(NULL),
m_AppConfig(appConfig)
{
setupUi(this);
@@ -79,6 +80,10 @@ void PluginWizardPage::finished()
{
updateStatus(tr("Plugins are ready."));
stopSpinning();
// ideally this should check if ns plugin is ready
m_AppConfig.setCryptoEnabled(true);
m_Finished = true;
emit completeChanged();
}

View File

@@ -1,6 +1,8 @@
#ifndef PLUGINWIZARDPAGE_H
#define PLUGINWIZARDPAGE_H
#include "AppConfig.h"
#include "ui_PluginWizardPageBase.h"
#include <QWizardPage>
@@ -12,7 +14,7 @@ class PluginWizardPage : public QWizardPage, public Ui::PluginWizardPage {
Q_OBJECT
public:
PluginWizardPage(QWidget *parent = 0);
PluginWizardPage(AppConfig& appConfig, QWidget *parent = 0);
~PluginWizardPage();
void setFinished(bool b) { m_Finished = b; }
@@ -44,5 +46,6 @@ private:
WebClient* m_pWebClient;
PluginManager* m_pPluginManager;
QThread* m_pPluginManagerThread;
AppConfig& m_AppConfig;
};
#endif // PLUGINWIZARDPAGE_H

View File

@@ -53,6 +53,8 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
// elevate checkbox is only useful on ms windows.
m_pCheckBoxElevateMode->hide();
#endif
m_pCheckBoxEnableCrypto->setChecked(m_AppConfig.getCryptoEnabled());
}
void SettingsDialog::accept()
@@ -120,10 +122,6 @@ void SettingsDialog::on_m_pButtonBrowseLog_clicked()
}
}
void SettingsDialog::on_m_pCheckBoxEnableCrypto_stateChanged(int )
{
}
void SettingsDialog::on_m_pComboLanguage_currentIndexChanged(int index)
{
QString ietfCode = m_pComboLanguage->itemData(index).toString();
@@ -147,3 +145,8 @@ void SettingsDialog::on_m_pCheckBoxElevateMode_toggled(bool checked)
}
}
}
void SettingsDialog::on_m_pCheckBoxEnableCrypto_toggled(bool checked)
{
m_AppConfig.setCryptoEnabled(checked);
}

View File

@@ -47,8 +47,8 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase
bool m_SuppressElevateWarning;
private slots:
void on_m_pCheckBoxEnableCrypto_toggled(bool checked);
void on_m_pCheckBoxElevateMode_toggled(bool checked);
void on_m_pCheckBoxEnableCrypto_stateChanged(int );
void on_m_pComboLanguage_currentIndexChanged(int index);
void on_m_pCheckBoxLogToFile_stateChanged(int );
void on_m_pButtonBrowseLog_clicked();

View File

@@ -30,7 +30,7 @@ SetupWizard::SetupWizard(MainWindow& mainWindow, bool startMain) :
m_Edition(Unknown)
{
setupUi(this);
m_pPluginPage = new PluginWizardPage();
m_pPluginPage = new PluginWizardPage(mainWindow.appConfig());
addPage(m_pPluginPage);
#if defined(Q_OS_MAC)