From 2935c6671ee29f170c9b81a5f45451ed5f169969 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Wed, 18 Sep 2013 08:34:32 +0000 Subject: [PATCH] added --enable-drag-drop arg and supporting gui changes. --- src/gui/res/SettingsDialogBase.ui | 2 +- src/gui/res/SetupWizardBase.ui | 196 ++++++++++++-------------- src/gui/src/AppConfig.cpp | 4 +- src/gui/src/MainWindow.cpp | 5 + src/gui/src/SettingsDialog.cpp | 15 +- src/gui/src/SetupWizard.cpp | 12 +- src/lib/platform/CMSWindowsScreen.cpp | 6 +- src/lib/platform/COSXScreen.cpp | 62 ++++---- src/lib/synergy/CApp.cpp | 8 ++ src/lib/synergy/CArgsBase.cpp | 3 +- src/lib/synergy/CArgsBase.h | 1 + src/lib/synergy/CClientApp.cpp | 4 + src/lib/synergy/CServerApp.cpp | 4 + 13 files changed, 156 insertions(+), 166 deletions(-) diff --git a/src/gui/res/SettingsDialogBase.ui b/src/gui/res/SettingsDialogBase.ui index a801283d..a8c5dcfd 100644 --- a/src/gui/res/SettingsDialogBase.ui +++ b/src/gui/res/SettingsDialogBase.ui @@ -208,7 +208,7 @@ - true + false QLineEdit::Password diff --git a/src/gui/res/SetupWizardBase.ui b/src/gui/res/SetupWizardBase.ui index 5cf69734..fb144f06 100644 --- a/src/gui/res/SetupWizardBase.ui +++ b/src/gui/res/SetupWizardBase.ui @@ -6,8 +6,8 @@ 0 0 - 500 - 390 + 556 + 489 @@ -134,7 +134,11 @@ - Synergy Premium users have access to extra features. The latest feature is encryption, which keeps sensitive information (e.g. passwords) safer when typed. These features are funded by Synergy Premium users. You can create an account for as little as $1. + <p><b>Latest feature:</b> Drag and drop files between computers.</p> + +<p>Thanks to donations from our Synergy Premium users, we've been able to add new features. The latest feature is drag and drop, where you can drag and drop files from one computer to another (supported on Windows and Mac OS X).</p> + +<p>To access the latest feature, donate $1 or more to our project, and in return we give you a Synergy Premium account. A help desk with <b>phone and email support</b> is also provided to our Synergy Premium users free of charge!</p> true @@ -160,74 +164,12 @@ - Yes, I have an account + Yes, I am a Synergy Premium user, and proud of it! :) - - - - true - - - - 0 - 0 - - - - - 200 - 0 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - QLineEdit::Password - - - - - - - - 100 - 0 - - - - - 75 - true - - - - &Password: - - - 10 - - - m_pLineEditPremiumPassword - - - @@ -293,6 +235,68 @@ + + + + + 100 + 0 + + + + + 75 + true + + + + &Password: + + + 10 + + + m_pLineEditPremiumPassword + + + + + + + true + + + + 0 + 0 + + + + + 200 + 0 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + QLineEdit::Password + + + @@ -324,7 +328,7 @@ - I want to sign up now + I want to donate $1 and get Synergy Premium @@ -347,7 +351,7 @@ - Maybe later + Maybe later :( @@ -356,6 +360,9 @@ Qt::Vertical + + QSizePolicy::Expanding + 20 @@ -483,36 +490,10 @@ Encryption - - - - Only available to Synergy Premium users. - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - Network traffic can be easily monitored. Using encryption can reduce the risk that sensitive information will be revealed to others (for example, passwords). + Network traffic can be easily monitored on public networks (e.g. schools and corporate networks) or WiFi networks. Using encryption can reduce the risk that sensitive information (e.g. passwords) will be revealed to others. true @@ -536,18 +517,17 @@ - - - QFormLayout::ExpandingFieldsGrow + + + + 75 + true + - - - - Enable encryption - - - - + + Enable encryption + + @@ -611,7 +591,7 @@ - true + false @@ -670,7 +650,7 @@ - true + false diff --git a/src/gui/src/AppConfig.cpp b/src/gui/src/AppConfig.cpp index 667bbf7c..5e6835cc 100644 --- a/src/gui/src/AppConfig.cpp +++ b/src/gui/src/AppConfig.cpp @@ -150,7 +150,7 @@ void AppConfig::loadSettings() m_ScreenName = settings().value("screenName", QHostInfo::localHostName()).toString(); m_Port = settings().value("port", 24800).toInt(); m_Interface = settings().value("interface").toString(); - m_LogLevel = settings().value("logLevel", 2).toInt(); + m_LogLevel = settings().value("logLevel", 3).toInt(); // level 3: INFO m_LogToFile = settings().value("logToFile", false).toBool(); m_LogFilename = settings().value("logFilename", synergyLogDir() + "synergy.log").toString(); m_AutoStart = settings().value("autoStart", false).toBool(); @@ -161,7 +161,7 @@ void AppConfig::loadSettings() m_CryptoPass = settings().value("cryptoPass", "").toString(); m_CryptoEnabled = settings().value("cryptoEnabled", false).toBool(); m_Language = settings().value("language", QLocale::system().name()).toString(); - m_PremiumEmail= settings().value("premiumEmail", "").toString(); + m_PremiumEmail = settings().value("premiumEmail", "").toString(); m_PremiumToken = settings().value("premiumToken", "").toString(); } diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index d8410500..6d7f4754 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -415,6 +415,11 @@ void MainWindow::startSynergy() #endif } + if (appConfig().isPremium()) + { + args << "--enable-drag-drop"; + } + if ((synergyType() == synergyClient && !clientArgs(args, app)) || (synergyType() == synergyServer && !serverArgs(args, app))) { diff --git a/src/gui/src/SettingsDialog.cpp b/src/gui/src/SettingsDialog.cpp index c51bfb09..796592ff 100644 --- a/src/gui/src/SettingsDialog.cpp +++ b/src/gui/src/SettingsDialog.cpp @@ -46,21 +46,10 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : m_pCheckBoxAutoHide->setChecked(appConfig().autoHide()); m_pCheckBoxEnableCrypto->setChecked(appConfig().cryptoEnabled()); setIndexFromItemData(m_pComboLanguage, appConfig().language()); - if (appConfig().isPremium()) + if (appConfig().cryptoEnabled()) { - if (appConfig().cryptoEnabled()) - { - m_pLineEditCryptoPass->setText(appConfig().cryptoPass()); - } + m_pLineEditCryptoPass->setText(appConfig().cryptoPass()); } - else - { - m_pCheckBoxEnableCrypto->setChecked(false); - m_pCheckBoxEnableCrypto->setEnabled(false); - m_pLineEditCryptoPass->clear(); - m_pLineEditCryptoPass->setEnabled(false); - } - } void SettingsDialog::accept() diff --git a/src/gui/src/SetupWizard.cpp b/src/gui/src/SetupWizard.cpp index 81935e78..249d06bc 100644 --- a/src/gui/src/SetupWizard.cpp +++ b/src/gui/src/SetupWizard.cpp @@ -105,11 +105,6 @@ bool SetupWizard::validateCurrentPage() { return false; } - else - { - m_pCheckBoxEnableCrypto->setEnabled(true); - m_pCheckBoxEnableCrypto->setChecked(true); - } } else if (m_pRadioButtonPremiumRegister->isChecked()) { @@ -120,9 +115,7 @@ bool SetupWizard::validateCurrentPage() } else if (m_pRadioButtonPremiumLater->isChecked()) { - m_pCheckBoxEnableCrypto->setEnabled(false); - m_pLineEditCryptoPassword1->setEnabled(false); - m_pLineEditCryptoPassword2->setEnabled(false); + return true; } else { message.setText(tr("Please select an option.")); @@ -257,6 +250,9 @@ void SetupWizard::on_m_pRadioButtonPremiumLogin_toggled(bool checked) bool SetupWizard::isPremiumLoginValid(QMessageBox& message) { + // hash the email and password and send it over plain-text, + // it would be nice to use SSL, but unfortunately the Qt + // implementation is unreliable. QString email = hash(m_pLineEditPremiumEmail->text()); QString password = hash(m_pLineEditPremiumPassword->text()); diff --git a/src/lib/platform/CMSWindowsScreen.cpp b/src/lib/platform/CMSWindowsScreen.cpp index 3f7b15ca..b76d8972 100644 --- a/src/lib/platform/CMSWindowsScreen.cpp +++ b/src/lib/platform/CMSWindowsScreen.cpp @@ -36,6 +36,8 @@ #include "TMethodJob.h" #include "CArch.h" #include "CArchMiscWindows.h" +#include "CApp.h" +#include "CArgsBase.h" #include #include #include @@ -1279,14 +1281,14 @@ CMSWindowsScreen::onMouseButton(WPARAM wParam, LPARAM lParam) if (button >= kButtonLeft && button <= kButtonExtra0 + 1) { if (pressed) { m_buttons[button] = true; - if (button == kButtonLeft) { + if (CApp::instance().argsBase().m_enableDragDrop && button == kButtonLeft) { m_draggingFileDir.clear(); LOG((CLOG_DEBUG2 "dragging file directory is cleared")); } } else { m_buttons[button] = false; - if (m_draggingStarted && button == kButtonLeft) { + if (CApp::instance().argsBase().m_enableDragDrop && m_draggingStarted && button == kButtonLeft) { m_draggingStarted = false; } } diff --git a/src/lib/platform/COSXScreen.cpp b/src/lib/platform/COSXScreen.cpp index fd0f675e..81934fd1 100644 --- a/src/lib/platform/COSXScreen.cpp +++ b/src/lib/platform/COSXScreen.cpp @@ -640,17 +640,19 @@ COSXScreen::getDropTargetThread(void*) void COSXScreen::fakeMouseMove(SInt32 x, SInt32 y) { - if (m_fakeDraggingStarted) { - // HACK: for some reason the drag icon - // does not follow the cursor unless a key - // is pressed (except esc key) - // TODO: fake this key down properly - fakeKeyDown(kKeyControl_L, 8194, 29); - } + if (CApp::instance().argsBase().m_enableDragDrop) { + if (m_fakeDraggingStarted) { + // HACK: for some reason the drag icon + // does not follow the cursor unless a key + // is pressed (except esc key) + // TODO: fake this key down properly + fakeKeyDown(kKeyControl_L, 8194, 29); + } - // index 0 means left mouse button - if (m_buttonState.test(0)) { - m_draggingStarted = true; + // index 0 means left mouse button + if (m_buttonState.test(0)) { + m_draggingStarted = true; + } } // synthesize event @@ -908,27 +910,25 @@ COSXScreen::leave() { hideCursor(); - if (m_draggingStarted) { - if (!m_isPrimary) { - // fake ctrl key up - fakeKeyUp(29); - // fake esc key down and up - fakeKeyDown(kKeyEscape, 8192, 1); - fakeKeyUp(1); - CFStringRef dragInfo = getDraggedFileURL(); - char* dragInfoCStr = CFStringRefToUTF8String(dragInfo); - LOG((CLOG_DEBUG "drag info: %s", dragInfoCStr)); - CFRelease(dragInfo); - CString fileList(dragInfoCStr); - size_t size = fileList.size(); - CClientApp& app = CClientApp::instance(); - CClient* client = app.getClientPtr(); - UInt32 fileCount = 1; - client->draggingInfoSending(fileCount, fileList, size); - LOG((CLOG_DEBUG "send dragging file to server")); - client->sendFileToServer(dragInfoCStr); - m_draggingStarted = false; - } + if (m_draggingStarted && !m_isPrimary) { + // fake ctrl key up + fakeKeyUp(29); + // fake esc key down and up + fakeKeyDown(kKeyEscape, 8192, 1); + fakeKeyUp(1); + CFStringRef dragInfo = getDraggedFileURL(); + char* dragInfoCStr = CFStringRefToUTF8String(dragInfo); + LOG((CLOG_DEBUG "drag info: %s", dragInfoCStr)); + CFRelease(dragInfo); + CString fileList(dragInfoCStr); + size_t size = fileList.size(); + CClientApp& app = CClientApp::instance(); + CClient* client = app.getClientPtr(); + UInt32 fileCount = 1; + client->draggingInfoSending(fileCount, fileList, size); + LOG((CLOG_DEBUG "send dragging file to server")); + client->sendFileToServer(dragInfoCStr); + m_draggingStarted = false; } if (m_isPrimary) { diff --git a/src/lib/synergy/CApp.cpp b/src/lib/synergy/CApp.cpp index cc1613f3..b569c173 100644 --- a/src/lib/synergy/CApp.cpp +++ b/src/lib/synergy/CApp.cpp @@ -168,6 +168,14 @@ CApp::parseArg(const int& argc, const char* const* argv, int& i) argsBase().m_crypto.setMode("cfb"); } + else if (isArg(i, argc, argv, NULL, "--enable-drag-drop")) { +#ifdef WINAPI_XWINDOWS + std::cerr << "Option not supported on Linux: " << argv[i] << std::endl; + m_bye(kExitArgs); +#endif + argsBase().m_enableDragDrop = true; + } + else { // option not supported here return false; diff --git a/src/lib/synergy/CArgsBase.cpp b/src/lib/synergy/CArgsBase.cpp index e8e52e48..9362f250 100644 --- a/src/lib/synergy/CArgsBase.cpp +++ b/src/lib/synergy/CArgsBase.cpp @@ -38,7 +38,8 @@ m_pname(NULL), m_logFilter(NULL), m_logFile(NULL), m_display(NULL), -m_enableIpc(false) +m_enableIpc(false), +m_enableDragDrop(false) { } diff --git a/src/lib/synergy/CArgsBase.h b/src/lib/synergy/CArgsBase.h index 96d288c4..99d4fb94 100644 --- a/src/lib/synergy/CArgsBase.h +++ b/src/lib/synergy/CArgsBase.h @@ -37,6 +37,7 @@ public: bool m_disableTray; bool m_enableIpc; CCryptoOptions m_crypto; + bool m_enableDragDrop; #if SYSAPI_WIN32 bool m_debugServiceWait; bool m_pauseOnExit; diff --git a/src/lib/synergy/CClientApp.cpp b/src/lib/synergy/CClientApp.cpp index 2348b4c0..c3063476 100644 --- a/src/lib/synergy/CClientApp.cpp +++ b/src/lib/synergy/CClientApp.cpp @@ -155,6 +155,10 @@ CClientApp::parseArgs(int argc, const char* const* argv) // identify system LOG((CLOG_INFO "%s Client on %s %s", kAppVersion, ARCH->getOSName().c_str(), ARCH->getPlatformName().c_str())); + + if (args().m_enableDragDrop) { + LOG((CLOG_INFO "drag and drop enabled")); + } loggingFilterWarning(); } diff --git a/src/lib/synergy/CServerApp.cpp b/src/lib/synergy/CServerApp.cpp index e07acfc9..5730f9d9 100644 --- a/src/lib/synergy/CServerApp.cpp +++ b/src/lib/synergy/CServerApp.cpp @@ -146,6 +146,10 @@ CServerApp::parseArgs(int argc, const char* const* argv) // identify system LOG((CLOG_INFO "%s Server on %s %s", kAppVersion, ARCH->getOSName().c_str(), ARCH->getPlatformName().c_str())); + + if (args().m_enableDragDrop) { + LOG((CLOG_INFO "drag and drop enabled")); + } loggingFilterWarning(); }