Jerry's crypto GUI patch.

This commit is contained in:
Nick Bolton 2013-04-11 16:51:17 +00:00
parent e84f111f35
commit fa4b2f4e85
12 changed files with 756 additions and 105 deletions

View File

@ -63,7 +63,8 @@ HEADERS += src/MainWindow.h \
src/SetupWizard.h \ src/SetupWizard.h \
src/IpcClient.h \ src/IpcClient.h \
src/IpcReader.h \ src/IpcReader.h \
src/Ipc.h src/Ipc.h \
src/CryptoMode.h
RESOURCES += res/Synergy.qrc RESOURCES += res/Synergy.qrc
RC_FILE = res/win/Synergy.rc RC_FILE = res/win/Synergy.rc
TRANSLATIONS = res/lang/nl_NL.ts TRANSLATIONS = res/lang/nl_NL.ts

View File

@ -6,22 +6,144 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>383</width> <width>369</width>
<height>387</height> <height>459</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Settings</string> <string>Settings</string>
</property> </property>
<layout class="QGridLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item row="1" column="0" colspan="2"> <item>
<widget class="QGroupBox" name="m_pGroupStart">
<property name="title">
<string>&amp;Startup</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="m_pCheckBoxAutoStart">
<property name="text">
<string>&amp;Start Synergy after logging in</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="m_pCheckBoxAutoConnect">
<property name="text">
<string>&amp;Automatically start server/client</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="m_pCheckBoxAutoHide">
<property name="text">
<string>&amp;Hide when server/client starts</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="m_pGroupCrypto">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>&amp;Encryption</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="m_pLabel_26">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>&amp;Mode:</string>
</property>
<property name="buddy">
<cstring>m_pComboCryptoMode</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_pComboCryptoMode">
<item>
<property name="text">
<string notr="true">OFB (Output Feedback)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">CFB (Cipher Feedback)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">CTR (Counter)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">GCM (Galois/Counter)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Disable encryption</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="m_pLabel_23">
<property name="text">
<string>Pass&amp;word:</string>
</property>
<property name="buddy">
<cstring>m_pLineEditCryptoPass</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="m_pLineEditCryptoPass">
<property name="enabled">
<bool>true</bool>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="m_pGroupAdvanced"> <widget class="QGroupBox" name="m_pGroupAdvanced">
<property name="title"> <property name="title">
<string>&amp;Advanced</string> <string>&amp;Advanced</string>
</property> </property>
<layout class="QGridLayout"> <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="m_pLabel_19"> <widget class="QLabel" name="m_pLabel_19">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Sc&amp;reen name:</string> <string>Sc&amp;reen name:</string>
</property> </property>
@ -30,7 +152,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="1">
<widget class="QLineEdit" name="m_pLineEditScreenName"> <widget class="QLineEdit" name="m_pLineEditScreenName">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@ -47,24 +169,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="1" column="1">
<widget class="QLabel" name="m_pLabel_21">
<property name="text">
<string>&amp;Interface:</string>
</property>
<property name="buddy">
<cstring>m_pLineEditInterface</cstring>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="m_pLineEditInterface">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="m_pSpinBoxPort"> <widget class="QSpinBox" name="m_pSpinBoxPort">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@ -83,17 +188,34 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="2" column="0">
<widget class="QLabel" name="m_pLabel_22"> <widget class="QLabel" name="m_pLabel_21">
<property name="text"> <property name="text">
<string>&amp;Process mode:</string> <string>&amp;Interface:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>m_pLineEditInterface</cstring> <cstring>m_pLineEditInterface</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="2"> <item row="2" column="1">
<widget class="QLineEdit" name="m_pLineEditInterface">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="m_pLabel_22">
<property name="text">
<string>&amp;Process mode:</string>
</property>
<property name="buddy">
<cstring>m_pComboProcessMode</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="m_pComboProcessMode"> <widget class="QComboBox" name="m_pComboProcessMode">
<item> <item>
<property name="text"> <property name="text">
@ -110,24 +232,32 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="2"> <item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="3" column="0" rowspan="2" colspan="2">
<widget class="QGroupBox" name="m_pGroupLog"> <widget class="QGroupBox" name="m_pGroupLog">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title"> <property name="title">
<string>Logging</string> <string>Logging</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="m_pLabel_3"> <widget class="QLabel" name="m_pLabel_3">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>&amp;Logging level:</string> <string>&amp;Logging level:</string>
</property> </property>
@ -136,31 +266,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="0" column="1" colspan="2">
<widget class="QCheckBox" name="m_pCheckBoxLogToFile">
<property name="text">
<string>Log to file:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="m_pLineEditLogFilename">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="m_pButtonBrowseLog">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_pComboLogLevel"> <widget class="QComboBox" name="m_pComboLogLevel">
<item> <item>
<property name="text"> <property name="text">
@ -199,40 +305,34 @@
</item> </item>
</widget> </widget>
</item> </item>
</layout> <item row="1" column="0">
</widget> <widget class="QCheckBox" name="m_pCheckBoxLogToFile">
</item>
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="m_pGroupStart">
<property name="title">
<string>&amp;Startup</string>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QCheckBox" name="m_pCheckBoxAutoStart">
<property name="text"> <property name="text">
<string>&amp;Start Synergy after logging in</string> <string>Log to file:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="1">
<widget class="QCheckBox" name="m_pCheckBoxAutoConnect"> <widget class="QLineEdit" name="m_pLineEditLogFilename">
<property name="text"> <property name="enabled">
<string>&amp;Automatically start server/client</string> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="2">
<widget class="QCheckBox" name="m_pCheckBoxAutoHide"> <widget class="QPushButton" name="m_pButtonBrowseLog">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>&amp;Hide when server/client starts</string> <string>Browse...</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="2"> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -245,6 +345,16 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
@ -254,7 +364,6 @@
<tabstop>m_pComboLogLevel</tabstop> <tabstop>m_pComboLogLevel</tabstop>
<tabstop>m_pCheckBoxLogToFile</tabstop> <tabstop>m_pCheckBoxLogToFile</tabstop>
<tabstop>m_pLineEditLogFilename</tabstop> <tabstop>m_pLineEditLogFilename</tabstop>
<tabstop>m_pButtonBrowseLog</tabstop>
<tabstop>buttonBox</tabstop> <tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>

View File

@ -125,6 +125,310 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWizardPage" name="m_pCryptoPage">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Encryption</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Network traffic can be easily monitored. Using encryption can reduce the risk that sensitive information will be revealed to others (for example, passwords).</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Choose a random encryption mode. The mode must be the same on both the client and server.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="1" column="0">
<widget class="QLabel" name="m_pLabel_26">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&amp;Mode:</string>
</property>
<property name="indent">
<number>10</number>
</property>
<property name="buddy">
<cstring>m_pComboCryptoMode</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_pComboCryptoMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string notr="true"/>
</property>
</item>
<item>
<property name="text">
<string notr="true">OFB (Output Feedback)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">CFB (Cipher Feedback)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">CTR (Counter)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">GCM (Galois/Counter)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Disable encryption</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="m_pLabel_27">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;A longer password will provide stronger encryption. It is a good idea to use 20 characters or more.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="m_pLabel_23">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&amp;Password:</string>
</property>
<property name="indent">
<number>10</number>
</property>
<property name="buddy">
<cstring>m_pLineEditCryptoPass</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="m_pLineEditCryptoPass">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="m_pLabel_24">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&amp;Confirm:</string>
</property>
<property name="indent">
<number>10</number>
</property>
<property name="buddy">
<cstring>m_pLineEditCryptoPassConfirm</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="m_pLineEditCryptoPassConfirm">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>100</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

View File

@ -54,7 +54,9 @@ AppConfig::AppConfig(QSettings* settings) :
m_AutoStart(false), m_AutoStart(false),
m_AutoHide(false), m_AutoHide(false),
m_AutoStartPrompt(false), m_AutoStartPrompt(false),
m_WizardHasRun(false), m_WizardLastRun(0),
m_CryptoPass(),
m_CryptoMode(),
m_ProcessMode(DEFAULT_PROCESS_MODE) m_ProcessMode(DEFAULT_PROCESS_MODE)
{ {
Q_ASSERT(m_pSettings); Q_ASSERT(m_pSettings);
@ -154,8 +156,10 @@ void AppConfig::loadSettings()
m_AutoStart = settings().value("autoStart", false).toBool(); m_AutoStart = settings().value("autoStart", false).toBool();
m_AutoHide = settings().value("autoHide", true).toBool(); m_AutoHide = settings().value("autoHide", true).toBool();
m_AutoStartPrompt = settings().value("autoStartPrompt", true).toBool(); m_AutoStartPrompt = settings().value("autoStartPrompt", true).toBool();
m_WizardHasRun = settings().value("wizardHasRun", false).toBool(); m_WizardLastRun = settings().value("wizardLastRun", 0).toInt();
m_ProcessMode = (ProcessMode)settings().value("processMode2", DEFAULT_PROCESS_MODE).toInt(); m_ProcessMode = (ProcessMode)settings().value("processMode2", DEFAULT_PROCESS_MODE).toInt();
m_CryptoPass = settings().value("cryptoPass", "").toString();
m_CryptoMode = (CryptoMode)settings().value("cryptoMode", Disabled).toInt();
} }
void AppConfig::saveSettings() void AppConfig::saveSettings()
@ -170,6 +174,53 @@ void AppConfig::saveSettings()
settings().setValue("autoStart", m_AutoStart); settings().setValue("autoStart", m_AutoStart);
settings().setValue("autoHide", m_AutoHide); settings().setValue("autoHide", m_AutoHide);
settings().setValue("autoStartPrompt", m_AutoStartPrompt); settings().setValue("autoStartPrompt", m_AutoStartPrompt);
settings().setValue("wizardHasRun", m_WizardHasRun); settings().setValue("wizardLastRun", kWizardVersion);
settings().setValue("processMode2", m_ProcessMode); settings().setValue("processMode2", m_ProcessMode);
settings().setValue("cryptoPass", m_CryptoPass);
settings().setValue("cryptoMode", m_CryptoMode);
}
QString AppConfig::hash(const QString& string)
{
QByteArray data = string.toUtf8();
QByteArray hash = QCryptographicHash::hash(data, QCryptographicHash::Md5);
return hash.toHex();
}
void AppConfig::setCryptoPass(const QString &s)
{
// clear field to user doesn't get confused.
if (s.isEmpty())
{
m_CryptoPass.clear();
return;
}
// only hash if password changes -- don't re-hash the hash.
if (m_CryptoPass != s)
{
m_CryptoPass = hash(s);
}
}
QString AppConfig::cryptoModeString() const
{
switch (cryptoMode())
{
case OFB:
return "ofb";
case CFB:
return "cfb";
case CTR:
return "ctr";
case GCM:
return "gcm";
default:
qCritical() << "invalid crypto mode";
return "";
}
} }

View File

@ -21,6 +21,13 @@
#define APPCONFIG_H #define APPCONFIG_H
#include <QString> #include <QString>
#include "CryptoMode.h"
// this should be incremented each time a new page is added. this is
// saved to settings when the user finishes running the wizard. if
// the saved wizard version is lower than this number, the wizard
// will be displayed.
const int kWizardVersion = 1;
class QSettings; class QSettings;
class SettingsDialog; class SettingsDialog;
@ -52,8 +59,11 @@ class AppConfig
bool autoStart() const { return m_AutoStart; } bool autoStart() const { return m_AutoStart; }
bool autoHide() const { return m_AutoHide; } bool autoHide() const { return m_AutoHide; }
bool autoStartPrompt() const { return m_AutoStartPrompt; } bool autoStartPrompt() const { return m_AutoStartPrompt; }
bool wizardHasRun() const { return m_WizardHasRun; } const QString& cryptoPass() const { return m_CryptoPass; }
CryptoMode cryptoMode() const { return m_CryptoMode; }
QString cryptoModeString() const;
ProcessMode processMode() const { return m_ProcessMode; } ProcessMode processMode() const { return m_ProcessMode; }
bool wizardShouldRun() const { return m_WizardLastRun < kWizardVersion; }
QString synergysName() const { return m_SynergysName; } QString synergysName() const { return m_SynergysName; }
QString synergycName() const { return m_SynergycName; } QString synergycName() const { return m_SynergycName; }
@ -75,12 +85,16 @@ class AppConfig
void setAutoStart(bool b); void setAutoStart(bool b);
void setAutoHide(bool b) { m_AutoHide = b; } void setAutoHide(bool b) { m_AutoHide = b; }
void setAutoStartPrompt(bool b) { m_AutoStartPrompt = b; } void setAutoStartPrompt(bool b) { m_AutoStartPrompt = b; }
void setWizardHasRun(bool b) { m_WizardHasRun = b; } void setCryptoMode(CryptoMode c) { m_CryptoMode = c; }
void setProcessMode(ProcessMode p) { m_ProcessMode = p; } void setProcessMode(ProcessMode p) { m_ProcessMode = p; }
void setWizardHasRun() { m_WizardLastRun = kWizardVersion; }
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
void setCryptoPass(const QString& s);
static QString hash(const QString& string);
private: private:
QSettings* m_pSettings; QSettings* m_pSettings;
bool m_AutoConnect; bool m_AutoConnect;
@ -93,7 +107,9 @@ class AppConfig
bool m_AutoStart; bool m_AutoStart;
bool m_AutoHide; bool m_AutoHide;
bool m_AutoStartPrompt; bool m_AutoStartPrompt;
bool m_WizardHasRun; int m_WizardLastRun;
QString m_CryptoPass;
CryptoMode m_CryptoMode;
ProcessMode m_ProcessMode; ProcessMode m_ProcessMode;
static const char m_SynergysName[]; static const char m_SynergysName[];

26
src/gui/src/CryptoMode.h Normal file
View File

@ -0,0 +1,26 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2013 Bolton Software 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/>.
*/
#pragma once
enum CryptoMode {
Disabled,
OFB,
CFB,
CTR,
GCM
};

View File

@ -380,6 +380,12 @@ void MainWindow::startSynergy()
if (!appConfig().screenName().isEmpty()) if (!appConfig().screenName().isEmpty())
args << "--name" << appConfig().screenName(); args << "--name" << appConfig().screenName();
if (appConfig().cryptoMode() != Disabled)
{
args << "--crypto-mode" << appConfig().cryptoModeString();
args << "--crypto-pass" << appConfig().cryptoPass();
}
if (desktopMode) if (desktopMode)
{ {
setSynergyProcess(new QProcess(this)); setSynergyProcess(new QProcess(this));

View File

@ -20,6 +20,7 @@
#include <QtCore> #include <QtCore>
#include <QtGui> #include <QtGui>
#include <QCryptographicHash>
#include "AppConfig.h" #include "AppConfig.h"
@ -40,10 +41,24 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
m_pLineEditLogFilename->setText(appConfig().logFilename()); m_pLineEditLogFilename->setText(appConfig().logFilename());
m_pCheckBoxAutoStart->setChecked(appConfig().autoStart()); m_pCheckBoxAutoStart->setChecked(appConfig().autoStart());
m_pCheckBoxAutoHide->setChecked(appConfig().autoHide()); m_pCheckBoxAutoHide->setChecked(appConfig().autoHide());
m_pComboCryptoMode->setCurrentIndex(getCryptoModeIndex(appConfig().cryptoMode()));
m_pLineEditCryptoPass->setText(appConfig().cryptoPass());
} }
void SettingsDialog::accept() void SettingsDialog::accept()
{ {
const QString& cryptoPass = m_pLineEditCryptoPass->text();
CryptoMode cryptoMode = parseCryptoMode(m_pComboCryptoMode->currentText());
if ((cryptoMode != Disabled) && cryptoPass.isEmpty())
{
QMessageBox message;
message.setWindowTitle("Settings");
message.setIcon(QMessageBox::Information);
message.setText(tr("Encryption password must not be empty."));
message.exec();
return;
}
appConfig().setAutoConnect(m_pCheckBoxAutoConnect->isChecked()); appConfig().setAutoConnect(m_pCheckBoxAutoConnect->isChecked());
appConfig().setScreenName(m_pLineEditScreenName->text()); appConfig().setScreenName(m_pLineEditScreenName->text());
appConfig().setPort(m_pSpinBoxPort->value()); appConfig().setPort(m_pSpinBoxPort->value());
@ -54,7 +69,9 @@ void SettingsDialog::accept()
appConfig().setLogFilename(m_pLineEditLogFilename->text()); appConfig().setLogFilename(m_pLineEditLogFilename->text());
appConfig().setAutoStart(m_pCheckBoxAutoStart->isChecked()); appConfig().setAutoStart(m_pCheckBoxAutoStart->isChecked());
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked()); appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
appConfig().setCryptoMode(cryptoMode);
appConfig().setCryptoPass(cryptoPass);
appConfig().saveSettings();
QDialog::accept(); QDialog::accept();
} }
@ -78,3 +95,56 @@ void SettingsDialog::on_m_pButtonBrowseLog_clicked()
m_pLineEditLogFilename->setText(fileName); m_pLineEditLogFilename->setText(fileName);
} }
} }
void SettingsDialog::on_m_pComboCryptoMode_currentIndexChanged(int index)
{
bool enabled = parseCryptoMode(m_pComboCryptoMode->currentText()) != Disabled;
m_pLineEditCryptoPass->setEnabled(enabled);
if (!enabled)
{
m_pLineEditCryptoPass->clear();
}
}
int SettingsDialog::getCryptoModeIndex(const CryptoMode& mode) const
{
switch (mode)
{
case OFB:
return m_pComboCryptoMode->findText("OFB", Qt::MatchStartsWith);
case CFB:
return m_pComboCryptoMode->findText("CFB", Qt::MatchStartsWith);
case CTR:
return m_pComboCryptoMode->findText("CTR", Qt::MatchStartsWith);
case GCM:
return m_pComboCryptoMode->findText("GCM", Qt::MatchStartsWith);
default:
return m_pComboCryptoMode->findText("Disable", Qt::MatchStartsWith);
}
}
CryptoMode SettingsDialog::parseCryptoMode(const QString& s)
{
if (s.startsWith("OFB"))
{
return OFB;
}
else if (s.startsWith("CFB"))
{
return CFB;
}
else if (s.startsWith("CTR"))
{
return CTR;
}
else if (s.startsWith("GCM"))
{
return GCM;
}
return Disabled;
}

View File

@ -22,6 +22,7 @@
#include <QDialog> #include <QDialog>
#include "ui_SettingsDialogBase.h" #include "ui_SettingsDialogBase.h"
#include "CryptoMode.h"
class AppConfig; class AppConfig;
@ -39,9 +40,12 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase
AppConfig& appConfig() { return m_AppConfig; } AppConfig& appConfig() { return m_AppConfig; }
private: private:
int getCryptoModeIndex(const CryptoMode& mode) const;
CryptoMode parseCryptoMode(const QString& s);
AppConfig& m_AppConfig; AppConfig& m_AppConfig;
private slots: private slots:
void on_m_pComboCryptoMode_currentIndexChanged(int index);
void on_m_pCheckBoxLogToFile_stateChanged(int ); void on_m_pCheckBoxLogToFile_stateChanged(int );
void on_m_pButtonBrowseLog_clicked(); void on_m_pButtonBrowseLog_clicked();
}; };

View File

@ -45,7 +45,7 @@ SetupWizard::SetupWizard(MainWindow& mainWindow, bool startMain) :
#endif #endif
connect(this, SIGNAL(finished(int)), this, SLOT(handlefinished())); connect(this, SIGNAL(finished(int)), this, SLOT(handleFinished()));
connect(m_pServerRadioButton, SIGNAL(toggled(bool)), m_MainWindow.m_pGroupServer, SLOT(setChecked(bool))); 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))); connect(m_pClientRadioButton, SIGNAL(toggled(bool)), m_MainWindow.m_pGroupClient, SLOT(setChecked(bool)));
} }
@ -60,28 +60,59 @@ bool SetupWizard::validateCurrentPage()
message.setWindowTitle(tr("Setup Synergy")); message.setWindowTitle(tr("Setup Synergy"));
message.setIcon(QMessageBox::Information); message.setIcon(QMessageBox::Information);
bool result = false;
if (currentPage() == m_pNodePage) if (currentPage() == m_pNodePage)
{ {
result = m_pClientRadioButton->isChecked() || bool result = m_pClientRadioButton->isChecked() ||
m_pServerRadioButton->isChecked(); m_pServerRadioButton->isChecked();
if (!result) if (!result)
{ {
message.setText(tr("Please select an option.")); message.setText(tr("Please select an option."));
message.exec(); message.exec();
return false;
} }
} }
return result; else if (currentPage() == m_pCryptoPage)
{
QString modeText = m_pComboCryptoMode->currentText();
if (modeText.isEmpty())
{
message.setText(tr("Encryption mode required."));
message.exec();
return false;
}
if (parseCryptoMode(modeText) != Disabled)
{
if (m_pLineEditCryptoPass->text().isEmpty())
{
message.setText(tr("Encryption password required."));
message.exec();
return false;
}
if (m_pLineEditCryptoPass->text() != m_pLineEditCryptoPassConfirm->text())
{
message.setText(tr("Encryption password and confirmation do not match."));
message.exec();
return false;
}
}
}
return true;
} }
void SetupWizard::handlefinished() void SetupWizard::handleFinished()
{ {
close(); close();
AppConfig& appConfig = m_MainWindow.appConfig(); AppConfig& appConfig = m_MainWindow.appConfig();
appConfig.setWizardHasRun(true); appConfig.setCryptoMode(parseCryptoMode(m_pComboCryptoMode->currentText()));
appConfig.setCryptoPass(m_pLineEditCryptoPass->text());
appConfig.setWizardHasRun();
appConfig.saveSettings(); appConfig.saveSettings();
QSettings& settings = m_MainWindow.settings(); QSettings& settings = m_MainWindow.settings();
@ -95,6 +126,7 @@ void SetupWizard::handlefinished()
settings.setValue("groupClientChecked", true); settings.setValue("groupClientChecked", true);
settings.setValue("groupServerChecked", false); settings.setValue("groupServerChecked", false);
} }
settings.sync(); settings.sync();
if (m_StartMain) if (m_StartMain)
@ -102,3 +134,32 @@ void SetupWizard::handlefinished()
m_MainWindow.start(true); m_MainWindow.start(true);
} }
} }
void SetupWizard::on_m_pComboCryptoMode_currentIndexChanged(int index)
{
bool enabled = parseCryptoMode(m_pComboCryptoMode->currentText()) != Disabled;
m_pLineEditCryptoPass->setEnabled(enabled);
m_pLineEditCryptoPassConfirm->setEnabled(enabled);
}
CryptoMode SetupWizard::parseCryptoMode(const QString& s)
{
if (s.startsWith("OFB"))
{
return OFB;
}
else if (s.startsWith("CFB"))
{
return CFB;
}
else if (s.startsWith("CTR"))
{
return CTR;
}
else if (s.startsWith("GCM"))
{
return GCM;
}
return Disabled;
}

View File

@ -18,8 +18,8 @@
#pragma once #pragma once
#include <QWizard> #include <QWizard>
#include "ui_SetupWizardBase.h" #include "ui_SetupWizardBase.h"
#include "CryptoMode.h"
class MainWindow; class MainWindow;
@ -31,8 +31,11 @@ public:
virtual ~SetupWizard(); virtual ~SetupWizard();
bool validateCurrentPage(); bool validateCurrentPage();
protected slots: protected slots:
void handlefinished(); void handleFinished();
private: private:
MainWindow& m_MainWindow; MainWindow& m_MainWindow;
bool m_StartMain; bool m_StartMain;
CryptoMode parseCryptoMode(const QString& s);
private slots:
void on_m_pComboCryptoMode_currentIndexChanged(int index);
}; };

View File

@ -66,13 +66,13 @@ int main(int argc, char* argv[])
MainWindow mainWindow(settings, appConfig); MainWindow mainWindow(settings, appConfig);
SetupWizard setupWizard(mainWindow, true); SetupWizard setupWizard(mainWindow, true);
if (appConfig.wizardHasRun()) if (appConfig.wizardShouldRun())
{ {
mainWindow.start(false); setupWizard.show();
} }
else else
{ {
setupWizard.show(); mainWindow.start(false);
} }
return app.exec(); return app.exec();