diff --git a/CMakeLists.txt b/CMakeLists.txt index 05f0d900..67437548 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,7 +205,10 @@ if (UNIX) set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include") set(XKBlib "X11/Xlib.h;X11/XKBlib.h") - check_symbol_exists("XRRNotifyEvent" "${XKBlib};X11/extensions/Xrandr.h" HAVE_X11_EXTENSIONS_XRANDR_H) + set(CMAKE_EXTRA_INCLUDE_FILES "${XKBlib};X11/extensions/Xrandr.h") + check_type_size("XRRNotifyEvent" X11_EXTENSIONS_XRANDR_H) + set(HAVE_X11_EXTENSIONS_XRANDR_H "${X11_EXTENSIONS_XRANDR_H}") + set(CMAKE_EXTRA_INCLUDE_FILES) check_include_files("${XKBlib};X11/extensions/dpms.h" HAVE_X11_EXTENSIONS_DPMS_H) check_include_files("X11/extensions/Xinerama.h" HAVE_X11_EXTENSIONS_XINERAMA_H) diff --git a/ChangeLog b/ChangeLog index 270668f5..19d10d50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +v1.8.4-stable +============= + +Bug #4041 UHD/4K DPI scaling broken on Windows servers +Bug #4420 When XRandR adds a screen, it is inaccessible +Bug #5603 Activation notification depends on existence of /etc/os-release +Bug #5624 Update notification sometimes requests a downgrade +Bug #5329 Current date is shown for build date in the about dialog +Bug #5640 Synergy branding is inconsistent across platforms +Enhancement #5617 Remove redundant plugin infrastructure +Enhancement #5627 Move SSL certificate generation to main window +Enhancement #5628 Move SSL implementation into core binary +Enhancement #5629 Move activation from wizard into new dialog window + v1.8.3-stable ============= Bug #2765 - A letter appears on macOS clients when the spacebar is pressed diff --git a/ext/toolchain/commands1.py b/ext/toolchain/commands1.py index 3cdfb1da..62e7c249 100644 --- a/ext/toolchain/commands1.py +++ b/ext/toolchain/commands1.py @@ -747,16 +747,6 @@ class InternalCommands: shutil.copy(targetDir + "/synergys", bundleBinDir) shutil.copy(targetDir + "/syntool", bundleBinDir) - # Copy all generated plugins to the package - bundlePluginDir = bundleBinDir + "plugins" - pluginDir = targetDir + "/plugins" - print "Copying plugins dirtree: " + pluginDir - if os.path.isdir(pluginDir): - print "Copying to: " + bundlePluginDir - shutil.copytree(pluginDir, bundlePluginDir) - else: - print "pluginDir doesn't exist, skipping" - self.loadConfig() if not self.macIdentity: raise Exception("run config with --mac-identity") @@ -1152,14 +1142,12 @@ class InternalCommands: controlFile.close() targetBin = '%s/%s/usr/bin' % (debDir, package) - targetPlugin = '%s/%s/usr/lib/synergy/plugins' % (debDir, package) targetShare = '%s/%s/usr/share' % (debDir, package) targetApplications = "%s/applications" % targetShare targetIcons = "%s/icons" % targetShare targetDocs = "%s/doc/%s" % (targetShare, self.project) os.makedirs(targetBin) - os.makedirs(targetPlugin) os.makedirs(targetApplications) os.makedirs(targetIcons) os.makedirs(targetDocs) @@ -1177,17 +1165,6 @@ class InternalCommands: if err != 0: raise Exception('strip failed: ' + str(err)) - pluginDir = "%s/plugins" % binDir - - pluginFiles = [ 'libns.so'] - for f in pluginFiles: - shutil.copy("%s/%s" % (pluginDir, f), targetPlugin) - target = "%s/%s" % (targetPlugin, f) - os.chmod(target, 0o0644) - err = os.system("strip " + target) - if err != 0: - raise Exception('strip failed: ' + str(err)) - shutil.copy("%s/synergy.desktop" % resDir, targetApplications) shutil.copy("%s/synergy.ico" % resDir, targetIcons) @@ -1403,13 +1380,6 @@ class InternalCommands: packageTarget = filename ftp.upload(packageSource, packageTarget) - if type != 'src': - pluginsDir = binDir + '/plugins' - nsPluginSource = self.findLibraryFile(type, pluginsDir, 'ns') - if nsPluginSource: - nsPluginTarget = self.getLibraryDistFilename(type, pluginsDir, 'ns') - ftp.upload(nsPluginSource, nsPluginTarget, "plugins") - def getLibraryDistFilename(self, type, dir, name): (platform, packageExt, libraryExt) = self.getDistributePlatformInfo(type) firstPart = '%s-%s-%s' % (name, self.getVersionForFilename(), platform) diff --git a/res/banner.bmp b/res/banner.bmp index f5838d85..418746c8 100644 Binary files a/res/banner.bmp and b/res/banner.bmp differ diff --git a/res/dialog.bmp b/res/dialog.bmp index 4899e583..683f4fe5 100644 Binary files a/res/dialog.bmp and b/res/dialog.bmp differ diff --git a/res/dpiaware.manifest b/res/dpiaware.manifest new file mode 100644 index 00000000..743e3369 --- /dev/null +++ b/res/dpiaware.manifest @@ -0,0 +1,15 @@ + + + + + + + + + + + true + + + + diff --git a/res/synergy.ico b/res/synergy.ico index fc2e4146..9e3d5710 100644 Binary files a/res/synergy.ico and b/res/synergy.ico differ diff --git a/res/synergy.spec.in b/res/synergy.spec.in index 16b695e3..3f0c88f9 100644 --- a/res/synergy.spec.in +++ b/res/synergy.spec.in @@ -20,7 +20,6 @@ source=%{_topdir}/../.. mkdir -p %{buildroot}/%{_datarootdir}/applications mkdir -p %{buildroot}/%{_datarootdir}/icons mkdir -p %{buildroot}/%{_bindir} -mkdir -p %{buildroot}/%{_bindir}/../lib/synergy/plugins cp $source/bin/synergy %{buildroot}%{_bindir} cp $source/bin/synergyc %{buildroot}%{_bindir} @@ -29,7 +28,6 @@ cp $source/bin/synergyd %{buildroot}%{_bindir} cp $source/bin/syntool %{buildroot}%{_bindir} cp $source/res/synergy.desktop %{buildroot}%{_datarootdir}/applications cp $source/res/synergy.ico %{buildroot}%{_datarootdir}/icons -cp $source/bin/plugins/* %{buildroot}%{_bindir}/../lib/synergy/plugins %files %defattr(755,root,root,-) @@ -40,7 +38,6 @@ cp $source/bin/plugins/* %{buildroot}%{_bindir}/../lib/synergy/plugins %{_bindir}/syntool %attr(644,-,-) %{_datarootdir}/applications/synergy.desktop %attr(644,-,-) %{_datarootdir}/icons/synergy.ico -%attr(644,-,-) %{_bindir}/../lib/synergy/plugins/* %changelog * Thu Mar 20 2014 Nick Bolton diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 83707aad..7355cd1b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,6 +14,38 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +if (WIN32) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(OPENSSL_PLAT_DIR openssl-win64) + else() + set(OPENSSL_PLAT_DIR openssl-win32) + endif() + set(OPENSSL_INCLUDE ${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/inc32) +endif() + +if (APPLE) + set(OPENSSL_PLAT_DIR openssl-osx) + set(OPENSSL_INCLUDE ${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/include) +endif() + +if (WIN32) + set(OPENSSL_LIBS + ${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/out32dll/libeay32.lib + ${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/out32dll/ssleay32.lib + ) +endif() + +if (UNIX) + if (APPLE) + set(OPENSSL_LIBS + ${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/libssl.a + ${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/libcrypto.a + ) + else() + set(OPENSSL_LIBS ssl crypto) + endif() +endif() + add_subdirectory(lib) add_subdirectory(cmd) add_subdirectory(micro) diff --git a/src/cmd/synergyc/CMakeLists.txt b/src/cmd/synergyc/CMakeLists.txt index 11d428d4..653cf374 100644 --- a/src/cmd/synergyc/CMakeLists.txt +++ b/src/cmd/synergyc/CMakeLists.txt @@ -58,7 +58,16 @@ endif() add_executable(synergyc ${sources}) target_link_libraries(synergyc - arch base client common io mt net ipc platform server synergy ${libs}) + arch base client common io mt net ipc platform server synergy ${libs} ${OPENSSL_LIBS}) + +if (WIN32) + ADD_CUSTOM_COMMAND( + TARGET synergyc + POST_BUILD + COMMAND "mt.exe" -manifest \"${CMAKE_SOURCE_DIR}\\res\\dpiaware.manifest\" -inputresource:\"$\"\;\#1 -outputresource:\"$\"\;\#1 + COMMENT "Adding display aware manifest..." + ) +endif() if (CONF_CPACK) install(TARGETS diff --git a/src/cmd/synergyc/MSWindowsClientTaskBarReceiver.cpp b/src/cmd/synergyc/MSWindowsClientTaskBarReceiver.cpp index 039246cc..fc3ed94e 100644 --- a/src/cmd/synergyc/MSWindowsClientTaskBarReceiver.cpp +++ b/src/cmd/synergyc/MSWindowsClientTaskBarReceiver.cpp @@ -221,7 +221,7 @@ MSWindowsClientTaskBarReceiver::primaryAction() const IArchTaskBarReceiver::Icon MSWindowsClientTaskBarReceiver::getIcon() const { - return reinterpret_cast(m_icon[getStatus()]); + return static_cast(m_icon[getStatus()]); } void @@ -263,7 +263,7 @@ MSWindowsClientTaskBarReceiver::loadIcon(UINT id) IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); - return reinterpret_cast(icon); + return static_cast(icon); } void @@ -288,7 +288,7 @@ MSWindowsClientTaskBarReceiver::createWindow() NULL, (DLGPROC)&MSWindowsClientTaskBarReceiver::staticDlgProc, reinterpret_cast( - reinterpret_cast(this))); + static_cast(this))); // window should appear on top of everything, including (especially) // the task bar. @@ -337,7 +337,7 @@ MSWindowsClientTaskBarReceiver::staticDlgProc(HWND hwnd, // and put it in the extra window data then forward the call. MSWindowsClientTaskBarReceiver* self = NULL; if (msg == WM_INITDIALOG) { - self = reinterpret_cast( + self = static_cast( reinterpret_cast(lParam)); SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) lParam); } diff --git a/src/cmd/synergyd/CMakeLists.txt b/src/cmd/synergyd/CMakeLists.txt index 1caa35b5..4ee859fc 100644 --- a/src/cmd/synergyd/CMakeLists.txt +++ b/src/cmd/synergyd/CMakeLists.txt @@ -35,7 +35,16 @@ else() endif() target_link_libraries(synergyd - arch base common io ipc mt net platform synergy ${libs}) + arch base common io ipc mt net platform synergy ${libs} ${OPENSSL_LIBS}) + +if (WIN32) + ADD_CUSTOM_COMMAND( + TARGET synergyd + POST_BUILD + COMMAND "mt.exe" -manifest \"${CMAKE_SOURCE_DIR}\\res\\dpiaware.manifest\" -inputresource:\"$\"\;\#1 -outputresource:\"$\"\;\#1 + COMMENT "Adding display aware manifest..." + ) +endif() if (CONF_CPACK) install(TARGETS diff --git a/src/cmd/synergyp/CMakeLists.txt b/src/cmd/synergyp/CMakeLists.txt index 171ef999..c9989252 100644 --- a/src/cmd/synergyp/CMakeLists.txt +++ b/src/cmd/synergyp/CMakeLists.txt @@ -63,7 +63,7 @@ else() endif() target_link_libraries(synergyp - arch base client common io mt net ipc platform server synergy client ${libs}) + arch base client common io mt net ipc platform server synergy client ${libs} ${OPENSSL_LIBS}) if (CONF_CPACK) install(TARGETS diff --git a/src/cmd/synergyp/MSWindowsPortableTaskBarReceiver.cpp b/src/cmd/synergyp/MSWindowsPortableTaskBarReceiver.cpp index 3f6a55d6..ae7b0ee4 100644 --- a/src/cmd/synergyp/MSWindowsPortableTaskBarReceiver.cpp +++ b/src/cmd/synergyp/MSWindowsPortableTaskBarReceiver.cpp @@ -238,7 +238,7 @@ MSWindowsPortableTaskBarReceiver::primaryAction() const IArchTaskBarReceiver::Icon MSWindowsPortableTaskBarReceiver::getIcon() const { - return reinterpret_cast(m_icon[getStatus()]); + return static_cast(m_icon[getStatus()]); } void @@ -280,7 +280,7 @@ MSWindowsPortableTaskBarReceiver::loadIcon(UINT id) IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); - return reinterpret_cast(icon); + return static_cast(icon); } void @@ -305,7 +305,7 @@ MSWindowsPortableTaskBarReceiver::createWindow() NULL, (DLGPROC)&MSWindowsPortableTaskBarReceiver::staticDlgProc, reinterpret_cast( - reinterpret_cast(this))); + static_cast(this))); // window should appear on top of everything, including (especially) // the task bar. @@ -354,7 +354,7 @@ MSWindowsPortableTaskBarReceiver::staticDlgProc(HWND hwnd, // and put it in the extra window data then forward the call. MSWindowsPortableTaskBarReceiver* self = NULL; if (msg == WM_INITDIALOG) { - self = reinterpret_cast( + self = static_cast( reinterpret_cast(lParam)); SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); } @@ -362,7 +362,8 @@ MSWindowsPortableTaskBarReceiver::staticDlgProc(HWND hwnd, // get the extra window data and forward the call LONG_PTR data = GetWindowLongPtr(hwnd, GWLP_USERDATA); if (data != 0) { - self = reinterpret_cast(data); + self = static_cast( + reinterpret_cast(data)); } } diff --git a/src/cmd/synergys/CMakeLists.txt b/src/cmd/synergys/CMakeLists.txt index c749e09a..023574b1 100644 --- a/src/cmd/synergys/CMakeLists.txt +++ b/src/cmd/synergys/CMakeLists.txt @@ -58,7 +58,16 @@ endif() add_executable(synergys ${sources}) target_link_libraries(synergys - arch base client common io mt net ipc platform server synergy ${libs}) + arch base client common io mt net ipc platform server synergy ${libs} ${OPENSSL_LIBS}) + +if (WIN32) + ADD_CUSTOM_COMMAND( + TARGET synergys + POST_BUILD + COMMAND "mt.exe" -manifest \"${CMAKE_SOURCE_DIR}\\res\\dpiaware.manifest\" -inputresource:\"$\"\;\#1 -outputresource:\"$\"\;\#1 + COMMENT "Adding display aware manifest..." + ) +endif() if (CONF_CPACK) install(TARGETS diff --git a/src/cmd/synergys/MSWindowsServerTaskBarReceiver.cpp b/src/cmd/synergys/MSWindowsServerTaskBarReceiver.cpp index e2af3d3d..b2d304a1 100644 --- a/src/cmd/synergys/MSWindowsServerTaskBarReceiver.cpp +++ b/src/cmd/synergys/MSWindowsServerTaskBarReceiver.cpp @@ -252,7 +252,7 @@ MSWindowsServerTaskBarReceiver::primaryAction() const IArchTaskBarReceiver::Icon MSWindowsServerTaskBarReceiver::getIcon() const { - return reinterpret_cast(m_icon[getStatus()]); + return static_cast(m_icon[getStatus()]); } void @@ -294,7 +294,7 @@ MSWindowsServerTaskBarReceiver::loadIcon(UINT id) IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); - return reinterpret_cast(icon); + return static_cast(icon); } void @@ -319,7 +319,7 @@ MSWindowsServerTaskBarReceiver::createWindow() NULL, (DLGPROC)&MSWindowsServerTaskBarReceiver::staticDlgProc, reinterpret_cast( - reinterpret_cast(this))); + static_cast(this))); // window should appear on top of everything, including (especially) // the task bar. @@ -368,14 +368,16 @@ MSWindowsServerTaskBarReceiver::staticDlgProc(HWND hwnd, // and put it in the extra window data then forward the call. MSWindowsServerTaskBarReceiver* self = NULL; if (msg == WM_INITDIALOG) { - self = reinterpret_cast(lParam); + self = static_cast( + reinterpret_cast(lParam)); SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); } else { // get the extra window data and forward the call - LONG_PTR data = GetWindowLongPtr(hwnd, GWLP_USERDATA); + LONG_PTR data = GetWindowLongPtr(hwnd, GWLP_USERDATA); if (data != 0) { - self = reinterpret_cast(data); + self = static_cast( + reinterpret_cast(data)); } } diff --git a/src/cmd/syntool/CMakeLists.txt b/src/cmd/syntool/CMakeLists.txt index 7f10c010..ffbb61aa 100644 --- a/src/cmd/syntool/CMakeLists.txt +++ b/src/cmd/syntool/CMakeLists.txt @@ -29,7 +29,7 @@ endif() add_executable(syntool ${sources}) target_link_libraries(syntool - synergy arch base client common io ipc mt net platform server ${libs}) + synergy arch base client common io ipc mt net platform server ${libs} ${OPENSSL_LIBS}) if (CONF_CPACK) install(TARGETS diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 4fe96f66..43633137 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -17,7 +17,9 @@ FORMS += res/MainWindowBase.ui \ res/SettingsDialogBase.ui \ res/SetupWizardBase.ui \ res/AddClientDialogBase.ui \ - res/PluginWizardPageBase.ui + res/ActivationDialog.ui \ + res/CancelActivationDialog.ui \ + res/FailedLoginDialog.ui SOURCES += src/main.cpp \ src/MainWindow.cpp \ src/AboutDialog.cpp \ @@ -54,16 +56,15 @@ SOURCES += src/main.cpp \ src/DataDownloader.cpp \ src/AddClientDialog.cpp \ src/CommandProcess.cpp \ - src/PluginWizardPage.cpp \ - src/PluginManager.cpp \ src/CoreInterface.cpp \ src/Fingerprint.cpp \ src/SslCertificate.cpp \ - src/Plugin.cpp \ src/WebClient.cpp \ - ../lib/common/PluginVersion.cpp \ src/SubscriptionManager.cpp \ - src/ActivationNotifier.cpp + src/ActivationNotifier.cpp \ + src/ActivationDialog.cpp \ + src/CancelActivationDialog.cpp \ + src/FailedLoginDialog.cpp HEADERS += src/MainWindow.h \ src/AboutDialog.h \ src/ServerConfig.h \ @@ -101,18 +102,17 @@ HEADERS += src/MainWindow.h \ src/AddClientDialog.h \ src/CommandProcess.h \ src/EditionType.h \ - src/PluginWizardPage.h \ src/ProcessorArch.h \ - src/PluginManager.h \ src/CoreInterface.h \ src/Fingerprint.h \ src/SslCertificate.h \ - src/Plugin.h \ src/WebClient.h \ - ../lib/common/PluginVersion.h \ src/SubscriptionManager.h \ src/ActivationNotifier.h \ - src/ElevateMode.h + src/ElevateMode.h \ + src/ActivationDialog.h \ + src/CancelActivationDialog.h \ + src/FailedLoginDialog.h RESOURCES += res/Synergy.qrc RC_FILE = res/win/Synergy.rc macx { diff --git a/src/gui/res/AboutDialogBase.ui b/src/gui/res/AboutDialogBase.ui index ba18e309..01df3dd9 100644 --- a/src/gui/res/AboutDialogBase.ui +++ b/src/gui/res/AboutDialogBase.ui @@ -13,25 +13,19 @@ 0 0 450 - 300 + 378 - + 0 0 - - - 450 - 300 - - 450 - 300 + 378 @@ -41,48 +35,20 @@ true - - + + - + 0 0 - - <p> -Keyboard and mouse sharing application. Cross platform and open source.<br /><br /> -Copyright © 2012-2016 Symless Ltd.<br /> -Copyright © 2002-2012 Chris Schoeneman, Nick Bolton, Volker Lanz.<br /><br /> -Synergy is released under the GNU General Public License (GPLv2).<br /><br /> -Synergy is based on CosmoSynergy by Richard Lee and Adam Feder.<br /> -The Synergy GUI is based on QSynergy by Volker Lanz.<br /><br /> -Visit our website for help and info (symless.com). -</p> - - - 1 - - - - - - - Qt::Vertical - - - QSizePolicy::Preferred - - + - 20 - 100 + 450 + 16777215 - - - - @@ -197,6 +163,41 @@ Visit our website for help and info (symless.com). + + + + + 0 + 0 + + + + <html><head/><body><p>Keyboard and mouse sharing application. <br/><br/>Copyright © 2012-2016 Symless Ltd.<br/>Copyright © 2002-2012 Chris Schoeneman, Nick Bolton, Volker Lanz.</p><p>Synergy is based on CosmoSynergy by Richard Lee and Adam Feder.<br/>The Synergy GUI is based on QSynergy by Volker Lanz. </p><p>Synergy is released under the GNU General Public License (GPLv2).</p></body></html> + + + false + + + 1 + + + + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 20 + 100 + + + + diff --git a/src/gui/res/ActivationDialog.ui b/src/gui/res/ActivationDialog.ui new file mode 100644 index 00000000..fb700f91 --- /dev/null +++ b/src/gui/res/ActivationDialog.ui @@ -0,0 +1,173 @@ + + + ActivationDialog + + + + 0 + 0 + 440 + 314 + + + + Activate Synergy + + + + + + + 75 + true + + + + &Account login + + + true + + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + 20 + + + 10 + + + + + Email: + + + + + + + + 0 + 0 + + + + QLineEdit::Normal + + + + + + + Password: + + + + + + + + 0 + 0 + + + + QLineEdit::Password + + + + + + + + + + 75 + true + + + + &Serial key + + + + + + + Found on your <a href="https://symless.com/account/?source=gui">account</a> page. + + + true + + + + + + + false + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + + + false + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + ActivationDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ActivationDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/gui/res/CancelActivationDialog.ui b/src/gui/res/CancelActivationDialog.ui new file mode 100644 index 00000000..b98733f6 --- /dev/null +++ b/src/gui/res/CancelActivationDialog.ui @@ -0,0 +1,89 @@ + + + CancelActivationDialog + + + + 0 + 0 + 400 + 165 + + + + Cancel Activation + + + + + + Are you sure? + +If you don't activate Synergy you'll be missing out on some great features + + + true + + + true + + + + + + + <html><head/><body><p><a href="https://symless.com/pricing?source=gui"><span style=" text-decoration: underline; color:#0000ff;">Buy now</span></a></p></body></html> + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::No|QDialogButtonBox::Yes + + + + + + + + + buttonBox + accepted() + CancelActivationDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + CancelActivationDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/gui/res/FailedLoginDialog.ui b/src/gui/res/FailedLoginDialog.ui new file mode 100644 index 00000000..d3c6b507 --- /dev/null +++ b/src/gui/res/FailedLoginDialog.ui @@ -0,0 +1,108 @@ + + + FailedLoginDialog + + + + 0 + 0 + 400 + 165 + + + + Activation Error + + + + + 50 + 120 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + 10 + 90 + 382 + 30 + + + + <html><head/><body><p><a href="https://symless.com/account/reset/?source=gui"><span style=" text-decoration: underline; color:#0000ff;">Forgotten your password?</span></a></p></body></html> + + + true + + + + + + 10 + 10 + 382 + 72 + + + + An error occurred while trying to activate Synergy. The Symless server returned the following error: + +%1 + + + true + + + true + + + label_2 + messageLabel + buttonBox + + + + + buttonBox + accepted() + FailedLoginDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + FailedLoginDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/gui/res/MainWindowBase.ui b/src/gui/res/MainWindowBase.ui index 0a47e0d3..87144cd1 100644 --- a/src/gui/res/MainWindowBase.ui +++ b/src/gui/res/MainWindowBase.ui @@ -1,4 +1,4 @@ - + MainWindowBase @@ -128,7 +128,7 @@ - Fingerprint: + SSL Fingerprint: @@ -481,12 +481,12 @@ - + - Run Wizard + Activate - - + + Activate diff --git a/src/gui/res/PluginWizardPageBase.ui b/src/gui/res/PluginWizardPageBase.ui deleted file mode 100644 index dfb7a978..00000000 --- a/src/gui/res/PluginWizardPageBase.ui +++ /dev/null @@ -1,137 +0,0 @@ - - - PluginWizardPage - - - - 0 - 0 - 400 - 300 - - - - Setup Synergy - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Please wait... - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - diff --git a/src/gui/res/SettingsDialogBase.ui b/src/gui/res/SettingsDialogBase.ui index 1cd82801..dca1bdad 100644 --- a/src/gui/res/SettingsDialogBase.ui +++ b/src/gui/res/SettingsDialogBase.ui @@ -176,8 +176,11 @@ + + false + - Use &SSL encryption (unique certificate) + Use &SSL encryption diff --git a/src/gui/res/SetupWizardBase.ui b/src/gui/res/SetupWizardBase.ui index 6788a3d5..8c089886 100644 --- a/src/gui/res/SetupWizardBase.ui +++ b/src/gui/res/SetupWizardBase.ui @@ -120,214 +120,6 @@ - - - Activate - - - - - - Enable your <a href="http://symless.com/pricing?source=gui">Synergy Pro</a> and Synergy Basic features. - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - - - - 75 - true - - - - &Account login - - - true - - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - 20 - - - 10 - - - - - Email: - - - - - - - - 0 - 0 - - - - - 200 - 20 - - - - QLineEdit::Normal - - - - - - - Password: - - - - - - - - 0 - 0 - - - - - 200 - 20 - - - - QLineEdit::Password - - - - - - - <a href="https://symless.com/account/reset/?source=gui">Forgot password</a> - - - true - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - - - - 75 - true - - - - &Serial key - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - - - S&kip activation - - - - - - - color: rgb(100, 100, 100); - - - You will see UNREGISTERED in the window title (not recommended). - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 500 - - - - - - diff --git a/src/gui/res/icons/256x256/synergy.ico b/src/gui/res/icons/256x256/synergy.ico index fc2e4146..9e3d5710 100644 Binary files a/src/gui/res/icons/256x256/synergy.ico and b/src/gui/res/icons/256x256/synergy.ico differ diff --git a/src/gui/res/image/about.png b/src/gui/res/image/about.png index 4630bd32..66307bb0 100644 Binary files a/src/gui/res/image/about.png and b/src/gui/res/image/about.png differ diff --git a/src/gui/src/AboutDialog.cpp b/src/gui/src/AboutDialog.cpp index 6fc1d57e..1d2f5888 100644 --- a/src/gui/src/AboutDialog.cpp +++ b/src/gui/src/AboutDialog.cpp @@ -32,7 +32,9 @@ AboutDialog::AboutDialog(QWidget* parent, const QString& synergyApp) : version = version + '-' + VERSION_STAGE + '-' + VERSION_REVISION; m_pLabelSynergyVersion->setText(version); - m_pLabelBuildDate->setText(QDate::currentDate().toString()); + QString buildDateString = QString::fromLocal8Bit(__DATE__).simplified(); + QDate buildDate = QLocale("en_US").toDate(buildDateString, "MMM d yyyy"); + m_pLabelBuildDate->setText(buildDate.toString(Qt::SystemLocaleLongDate)); // change default size based on os #if defined(Q_OS_MAC) diff --git a/src/gui/src/ActivationDialog.cpp b/src/gui/src/ActivationDialog.cpp new file mode 100644 index 00000000..40251019 --- /dev/null +++ b/src/gui/src/ActivationDialog.cpp @@ -0,0 +1,165 @@ +#include "ActivationDialog.h" +#include "ui_ActivationDialog.h" +#include "CancelActivationDialog.h" +#include "AppConfig.h" +#include "WebClient.h" +#include "EditionType.h" +#include "ActivationNotifier.h" +#include "MainWindow.h" +#include "QUtility.h" +#include "SubscriptionManager.h" +#include "FailedLoginDialog.h" + +#include +#include +#include + +ActivationDialog::ActivationDialog(QWidget* parent, AppConfig& appConfig) : + QDialog(parent), + ui(new Ui::ActivationDialog), + m_appConfig (&appConfig) +{ + ui->setupUi(this); + + ui->m_pLineEditEmail->setText(appConfig.activateEmail()); + ui->m_pTextEditSerialKey->setText(appConfig.serialKey()); + + if (!appConfig.serialKey().isEmpty()) { + ui->m_pRadioButtonActivate->setAutoExclusive(false); + ui->m_pRadioButtonSubscription->setAutoExclusive(false); + ui->m_pRadioButtonActivate->setChecked(false); + ui->m_pRadioButtonSubscription->setChecked(true); + ui->m_pRadioButtonActivate->setAutoExclusive(true); + ui->m_pRadioButtonSubscription->setAutoExclusive(true); + ui->m_pTextEditSerialKey->setFocus(); + ui->m_pTextEditSerialKey->moveCursor(QTextCursor::End); + } else { + if (ui->m_pLineEditEmail->text().isEmpty()) { + ui->m_pLineEditEmail->setFocus(); + } else { + ui->m_pLineEditPassword->setFocus(); + } + } +} + +ActivationDialog::~ActivationDialog() +{ + delete ui; +} + +void ActivationDialog::notifyActivation(QString identity) +{ + ActivationNotifier* notifier = new ActivationNotifier(); + notifier->setIdentity(identity); + + QThread* thread = new QThread(); + connect(notifier, SIGNAL(finished()), thread, SLOT(quit())); + connect(notifier, SIGNAL(finished()), notifier, SLOT(deleteLater())); + connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); + + notifier->moveToThread(thread); + thread->start(); + + QMetaObject::invokeMethod(notifier, "notify", Qt::QueuedConnection); +} + +void ActivationDialog::reject() +{ + CancelActivationDialog cancelActivationDialog(this); + if (QDialog::Accepted == cancelActivationDialog.exec()) { + notifyActivation("skip:unknown"); + m_appConfig->activationHasRun(true); + m_appConfig->saveSettings(); + QDialog::reject(); + } +} + +void ActivationDialog::on_m_pRadioButtonSubscription_toggled(bool checked) +{ + if (checked) { + ui->m_pLineEditEmail->setEnabled(false); + ui->m_pLineEditPassword->setEnabled(false); + ui->m_pTextEditSerialKey->setEnabled(true); + ui->m_pTextEditSerialKey->setFocus(); + } +} + +void ActivationDialog::on_m_pRadioButtonActivate_toggled(bool checked) +{ + if (checked) { + ui->m_pLineEditEmail->setEnabled(true); + ui->m_pLineEditPassword->setEnabled(true); + ui->m_pTextEditSerialKey->setEnabled(false); + if (ui->m_pLineEditEmail->text().isEmpty()) { + ui->m_pLineEditEmail->setFocus(); + } else { + ui->m_pLineEditPassword->setFocus(); + } + } +} + +void ActivationDialog::accept() +{ + QMessageBox message; + QString error; + int edition = Unregistered; + + m_appConfig->activationHasRun(true); + m_appConfig->saveSettings(); + + try { + if (ui->m_pRadioButtonActivate->isChecked()) { + WebClient webClient; + QString email = ui->m_pLineEditEmail->text(); + QString password = ui->m_pLineEditPassword->text(); + + if (!webClient.setEmail (email, error)) { + message.critical (this, "Invalid Email Address", tr("%1").arg(error)); + return; + } + else if (!webClient.setPassword (password, error)) { + message.critical (this, "Invalid Password", tr("%1").arg(error)); + return; + } + else if (!webClient.getEdition (edition, error)) { + FailedLoginDialog failedLoginDialog (this, error); + failedLoginDialog.exec(); + return; + } + + m_appConfig->setActivateEmail (email); + m_appConfig->clearSerialKey(); + ui->m_pTextEditSerialKey->clear(); + notifyActivation ("login:" + m_appConfig->activateEmail()); + } + else { + QString serialKey = ui->m_pTextEditSerialKey->toPlainText(); + + if (!m_appConfig->setSerialKey (serialKey, error)) { + message.critical (this, "Invalid Serial Key", tr("%1").arg(error)); + return; + } + + SubscriptionManager subscriptionManager (this, *m_appConfig, edition); + if (!subscriptionManager.activateSerial (serialKey)) { + return; + } + m_appConfig->setActivateEmail(""); + notifyActivation ("serial:" + m_appConfig->serialKey()); + } + } + catch (std::exception& e) { + message.critical (this, "Unknown Error", + tr("An error occurred while trying to activate Synergy. " + "Please contact the helpdesk, and provide the " + "following details.\n\n%1").arg(e.what())); + return; + } + + m_appConfig->setEdition(edition); + m_appConfig->saveSettings(); + + message.information (this, "Activated!", + tr("Thanks for activating %1!").arg (getEditionName (edition))); + QDialog::accept(); +} diff --git a/src/gui/src/ActivationDialog.h b/src/gui/src/ActivationDialog.h new file mode 100644 index 00000000..6fb926cc --- /dev/null +++ b/src/gui/src/ActivationDialog.h @@ -0,0 +1,36 @@ +#ifndef ACTIVATIONDIALOG_H +#define ACTIVATIONDIALOG_H + +#include + +namespace Ui { +class ActivationDialog; +} + +class AppConfig; + +class ActivationDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ActivationDialog(QWidget *parent, AppConfig& appConfig); + ~ActivationDialog(); + +public slots: + void reject(); + void accept(); + +protected: + void notifyActivation (QString identity); + +private: + Ui::ActivationDialog *ui; + AppConfig* m_appConfig; + +private slots: + void on_m_pRadioButtonSubscription_toggled(bool checked); + void on_m_pRadioButtonActivate_toggled(bool checked); +}; + +#endif // ACTIVATIONDIALOG_H diff --git a/src/gui/src/AppConfig.cpp b/src/gui/src/AppConfig.cpp index 138a9969..956f5f65 100644 --- a/src/gui/src/AppConfig.cpp +++ b/src/gui/src/AppConfig.cpp @@ -73,6 +73,18 @@ AppConfig::~AppConfig() saveSettings(); } +const QString &AppConfig::screenName() const { return m_ScreenName; } + +int AppConfig::port() const { return m_Port; } + +const QString &AppConfig::networkInterface() const { return m_Interface; } + +int AppConfig::logLevel() const { return m_LogLevel; } + +bool AppConfig::logToFile() const { return m_LogToFile; } + +const QString &AppConfig::logFilename() const { return m_LogFilename; } + QString AppConfig::synergyLogDir() const { #if defined(Q_OS_WIN) @@ -116,6 +128,16 @@ QString AppConfig::logLevelText() const return logLevelNames[logLevel()]; } +ProcessMode AppConfig::processMode() const { return m_ProcessMode; } + +bool AppConfig::wizardShouldRun() const { return m_WizardLastRun < kWizardVersion; } + +const QString &AppConfig::language() const { return m_Language; } + +bool AppConfig::startedBefore() const { return m_StartedBefore; } + +bool AppConfig::autoConfig() const { return m_AutoConfig; } + void AppConfig::loadSettings() { m_ScreenName = settings().value("screenName", QHostInfo::localHostName()).toString(); @@ -135,12 +157,13 @@ void AppConfig::loadSettings() } m_ElevateMode = static_cast(elevateMode.toInt()); m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool(); - m_Edition = settings().value("edition", UnknownEdition).toInt(); + m_Edition = settings().value("edition", Unregistered).toInt(); m_ActivateEmail = settings().value("activateEmail", "").toString(); - m_CryptoEnabled = settings().value("cryptoEnabled", false).toBool(); + m_CryptoEnabled = settings().value("cryptoEnabled", true).toBool(); m_AutoHide = settings().value("autoHide", false).toBool(); m_Serialkey = settings().value("serialKey", "").toString(); m_LastExpiringWarningTime = settings().value("lastExpiringWarningTime", 0).toInt(); + m_ActivationHasRun = settings().value("activationHasRun", false).toBool(); } void AppConfig::saveSettings() @@ -166,19 +189,107 @@ void AppConfig::saveSettings() settings().setValue("autoHide", m_AutoHide); settings().setValue("serialKey", m_Serialkey); settings().setValue("lastExpiringWarningTime", m_LastExpiringWarningTime); + settings().setValue("activationHasRun", m_ActivationHasRun); + settings().sync(); } +bool AppConfig::activationHasRun() const +{ + return m_ActivationHasRun; +} + +AppConfig& AppConfig::activationHasRun(bool value) +{ + m_ActivationHasRun = value; + return *this; +} + +QSettings &AppConfig::settings() { return *m_pSettings; } + +void AppConfig::setScreenName(const QString &s) { m_ScreenName = s; } + +void AppConfig::setPort(int i) { m_Port = i; } + +void AppConfig::setNetworkInterface(const QString &s) { m_Interface = s; } + +void AppConfig::setLogLevel(int i) { m_LogLevel = i; } + +void AppConfig::setLogToFile(bool b) { m_LogToFile = b; } + +void AppConfig::setLogFilename(const QString &s) { m_LogFilename = s; } + +void AppConfig::setWizardHasRun() { m_WizardLastRun = kWizardVersion; } + +void AppConfig::setLanguage(const QString language) { m_Language = language; } + +void AppConfig::setStartedBefore(bool b) { m_StartedBefore = b; } + +void AppConfig::setElevateMode(ElevateMode em) { m_ElevateMode = em; } + void AppConfig::setAutoConfig(bool autoConfig) { m_AutoConfig = autoConfig; } +bool AppConfig::autoConfigPrompted() { return m_AutoConfigPrompted; } + void AppConfig::setAutoConfigPrompted(bool prompted) { m_AutoConfigPrompted = prompted; } +void AppConfig::setEdition(int e) { + m_Edition = e; + emit editionSet (e); +} + +int AppConfig::edition() const { return m_Edition; } + +bool AppConfig::setActivateEmail(QString e) { + m_ActivateEmail = e; + return true; +} + +QString AppConfig::activateEmail() { return m_ActivateEmail; } + +bool AppConfig::setSerialKey(QString serial, QString& errorOut) { + if (serial.isEmpty()) { + errorOut = "Your serial key cannot be blank."; + return false; + } + m_Serialkey = serial; + return true; +} + +void AppConfig::clearSerialKey() +{ + m_Serialkey.clear(); +} + +QString AppConfig::serialKey() { return m_Serialkey; } + +int AppConfig::lastExpiringWarningTime() const { return m_LastExpiringWarningTime; } + +void AppConfig::setLastExpiringWarningTime(int t) { m_LastExpiringWarningTime = t; } + +QString AppConfig::synergysName() const { return m_SynergysName; } + +QString AppConfig::synergycName() const { return m_SynergycName; } + ElevateMode AppConfig::elevateMode() { return m_ElevateMode; } + +void AppConfig::setCryptoEnabled(bool e) { + m_CryptoEnabled = e; + emit sslToggled(e); +} + +bool AppConfig::getCryptoEnabled() const { + return (edition() == Pro) && m_CryptoEnabled; +} + +void AppConfig::setAutoHide(bool b) { m_AutoHide = b; } + +bool AppConfig::getAutoHide() { return m_AutoHide; } diff --git a/src/gui/src/AppConfig.h b/src/gui/src/AppConfig.h index 747e306e..f67b2548 100644 --- a/src/gui/src/AppConfig.h +++ b/src/gui/src/AppConfig.h @@ -20,6 +20,7 @@ #define APPCONFIG_H +#include #include #include "ElevateMode.h" @@ -48,8 +49,10 @@ enum ProcessMode { Desktop }; -class AppConfig +class AppConfig: public QObject { + Q_OBJECT + friend class SettingsDialog; friend class MainWindow; friend class SetupWizard; @@ -59,33 +62,34 @@ class AppConfig ~AppConfig(); public: - const QString& screenName() const { return m_ScreenName; } - int port() const { return m_Port; } - const QString& networkInterface() const { return m_Interface; } - int logLevel() const { return m_LogLevel; } - bool logToFile() const { return m_LogToFile; } - const QString& logFilename() const { return m_LogFilename; } + const QString& screenName() const; + int port() const; + const QString& networkInterface() const; + int logLevel() const; + bool logToFile() const; + const QString& logFilename() const; const QString logFilenameCmd() const; QString logLevelText() const; - ProcessMode processMode() const { return m_ProcessMode; } - bool wizardShouldRun() const { return m_WizardLastRun < kWizardVersion; } - const QString& language() const { return m_Language; } - bool startedBefore() const { return m_StartedBefore; } - bool autoConfig() const { return m_AutoConfig; } + ProcessMode processMode() const; + bool wizardShouldRun() const; + const QString& language() const; + bool startedBefore() const; + bool autoConfig() const; void setAutoConfig(bool autoConfig); - bool autoConfigPrompted() { return m_AutoConfigPrompted; } + bool autoConfigPrompted(); void setAutoConfigPrompted(bool prompted); - void setEdition(int e) { m_Edition = e; } - int edition() { return m_Edition; } - void setActivateEmail(QString e) { m_ActivateEmail = e; } - QString activateEmail() { return m_ActivateEmail; } - void setSerialKey(QString serial) { m_Serialkey = serial; } - QString serialKey() { return m_Serialkey; } - int lastExpiringWarningTime() const { return m_LastExpiringWarningTime; } - void setLastExpiringWarningTime(int t) { m_LastExpiringWarningTime = t; } + void setEdition(int e); + int edition() const; + bool setActivateEmail(QString e); + QString activateEmail(); + bool setSerialKey(QString serial, QString& error); + void clearSerialKey(); + QString serialKey(); + int lastExpiringWarningTime() const; + void setLastExpiringWarningTime(int t); - QString synergysName() const { return m_SynergysName; } - QString synergycName() const { return m_SynergycName; } + QString synergysName() const; + QString synergycName() const; QString synergyProgramDir() const; QString synergyLogDir() const; @@ -93,26 +97,29 @@ class AppConfig void persistLogDir(); ElevateMode elevateMode(); - void setCryptoEnabled(bool e) { m_CryptoEnabled = e; } - bool getCryptoEnabled() { return m_CryptoEnabled; } - void setAutoHide(bool b) { m_AutoHide = b; } - bool getAutoHide() { return m_AutoHide; } + void setCryptoEnabled(bool e); + bool getCryptoEnabled() const; + + void setAutoHide(bool b); + bool getAutoHide(); + + bool activationHasRun() const; + AppConfig& activationHasRun(bool value); void saveSettings(); protected: - QSettings& settings() { return *m_pSettings; } - void setScreenName(const QString& s) { m_ScreenName = s; } - void setPort(int i) { m_Port = i; } - void setNetworkInterface(const QString& s) { m_Interface = s; } - void setLogLevel(int i) { m_LogLevel = i; } - void setLogToFile(bool b) { m_LogToFile = b; } - void setLogFilename(const QString& s) { m_LogFilename = s; } - void setWizardHasRun() { m_WizardLastRun = kWizardVersion; } - void setLanguage(const QString language) { m_Language = language; } - void setStartedBefore(bool b) { m_StartedBefore = b; } - void setElevateMode(ElevateMode em) { m_ElevateMode = em; } - + QSettings& settings(); + void setScreenName(const QString& s); + void setPort(int i); + void setNetworkInterface(const QString& s); + void setLogLevel(int i); + void setLogToFile(bool b); + void setLogFilename(const QString& s); + void setWizardHasRun(); + void setLanguage(const QString language); + void setStartedBefore(bool b); + void setElevateMode(ElevateMode em); void loadSettings(); private: @@ -136,10 +143,15 @@ class AppConfig bool m_AutoHide; QString m_Serialkey; int m_LastExpiringWarningTime; + bool m_ActivationHasRun; static const char m_SynergysName[]; static const char m_SynergycName[]; static const char m_SynergyLogDir[]; + + signals: + void editionSet(int); + void sslToggled(bool enabled); }; #endif diff --git a/src/gui/src/CancelActivationDialog.cpp b/src/gui/src/CancelActivationDialog.cpp new file mode 100644 index 00000000..074b76bb --- /dev/null +++ b/src/gui/src/CancelActivationDialog.cpp @@ -0,0 +1,14 @@ +#include "CancelActivationDialog.h" +#include "ui_CancelActivationDialog.h" + +CancelActivationDialog::CancelActivationDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::CancelActivationDialog) +{ + ui->setupUi(this); +} + +CancelActivationDialog::~CancelActivationDialog() +{ + delete ui; +} diff --git a/src/gui/src/CancelActivationDialog.h b/src/gui/src/CancelActivationDialog.h new file mode 100644 index 00000000..b90af083 --- /dev/null +++ b/src/gui/src/CancelActivationDialog.h @@ -0,0 +1,22 @@ +#ifndef CANCELACTIVATIONDIALOG_H +#define CANCELACTIVATIONDIALOG_H + +#include + +namespace Ui { +class CancelActivationDialog; +} + +class CancelActivationDialog : public QDialog +{ + Q_OBJECT + +public: + explicit CancelActivationDialog(QWidget *parent = 0); + ~CancelActivationDialog(); + +private: + Ui::CancelActivationDialog *ui; +}; + +#endif // CANCELACTIVATIONDIALOG_H diff --git a/src/gui/src/EditionType.h b/src/gui/src/EditionType.h index a1579c86..5869a32b 100644 --- a/src/gui/src/EditionType.h +++ b/src/gui/src/EditionType.h @@ -18,11 +18,13 @@ #ifndef EDITIONTYPE_H #define EDITIONTYPE_H -enum qEditionType { +/* Do not reorder these! */ + +enum EditionType { Basic, Pro, Trial, - UnknownEdition + Unregistered }; #endif // EDITIONTYPE_H diff --git a/src/gui/src/FailedLoginDialog.cpp b/src/gui/src/FailedLoginDialog.cpp new file mode 100644 index 00000000..07ec6bdc --- /dev/null +++ b/src/gui/src/FailedLoginDialog.cpp @@ -0,0 +1,15 @@ +#include "FailedLoginDialog.h" +#include "ui_FailedLoginDialog.h" + +FailedLoginDialog::FailedLoginDialog(QWidget *parent, QString message): + QDialog(parent), + ui(new Ui::FailedLoginDialog) +{ + ui->setupUi(this); + ui->messageLabel->setText(ui->messageLabel->text().arg(message)); +} + +FailedLoginDialog::~FailedLoginDialog() +{ + delete ui; +} diff --git a/src/gui/src/FailedLoginDialog.h b/src/gui/src/FailedLoginDialog.h new file mode 100644 index 00000000..2eb67634 --- /dev/null +++ b/src/gui/src/FailedLoginDialog.h @@ -0,0 +1,23 @@ +#ifndef FAILEDLOGINDIALOG_H +#define FAILEDLOGINDIALOG_H + +#include +#include + +namespace Ui { +class FailedLoginDialog; +} + +class FailedLoginDialog : public QDialog +{ + Q_OBJECT + +public: + explicit FailedLoginDialog(QWidget *parent = 0, QString message = ""); + ~FailedLoginDialog(); + +private: + Ui::FailedLoginDialog *ui; +}; + +#endif // FAILEDLOGINDIALOG_H diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 9811e95c..531efa09 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -23,11 +23,10 @@ #include "MainWindow.h" #include "Fingerprint.h" -#include "PluginManager.h" #include "AboutDialog.h" #include "ServerConfigDialog.h" #include "SettingsDialog.h" -#include "SetupWizard.h" +#include "ActivationDialog.h" #include "ZeroconfService.h" #include "DataDownloader.h" #include "CommandProcess.h" @@ -35,6 +34,7 @@ #include "EditionType.h" #include "QUtility.h" #include "ProcessorArch.h" +#include "SslCertificate.h" #include #include @@ -98,7 +98,8 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) : m_SuppressAutoConfigWarning(false), m_BonjourInstall(NULL), m_SuppressEmptyServerWarning(false), - m_ExpectedRunningState(kStopped) + m_ExpectedRunningState(kStopped), + m_pSslCertificate(NULL) { setupUi(this); @@ -137,8 +138,9 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) : setEdition(m_AppConfig.edition()); m_pLabelPadlock->hide(); - - updateLocalFingerprint(); + connect (this, SIGNAL(windowShown()), this, SLOT(on_windowShown()), Qt::QueuedConnection); + connect (&m_AppConfig, SIGNAL(editionSet(int)), this, SLOT(setEdition(int)), Qt::QueuedConnection); + connect (&m_AppConfig, SIGNAL(sslToggled(bool)), this, SLOT(sslToggled(bool)), Qt::QueuedConnection); } MainWindow::~MainWindow() @@ -159,6 +161,8 @@ MainWindow::~MainWindow() if (m_BonjourInstall != NULL) { delete m_BonjourInstall; } + + delete m_pSslCertificate; } void MainWindow::open() @@ -263,7 +267,8 @@ void MainWindow::createMenuBar() m_pMenuFile->addAction(m_pActionStartSynergy); m_pMenuFile->addAction(m_pActionStopSynergy); m_pMenuFile->addSeparator(); - m_pMenuFile->addAction(m_pActionWizard); + m_pMenuFile->addAction(m_pActivate); + m_pMenuFile->addSeparator(); m_pMenuFile->addAction(m_pActionSave); m_pMenuFile->addSeparator(); m_pMenuFile->addAction(m_pActionQuit); @@ -493,13 +498,19 @@ void MainWindow::restartSynergy() void MainWindow::proofreadInfo() { - setEdition(m_AppConfig.edition()); + setEdition(m_AppConfig.edition()); // Why is this here? int oldState = m_SynergyState; m_SynergyState = synergyDisconnected; setSynergyState((qSynergyState)oldState); } +void MainWindow::showEvent(QShowEvent* event) +{ + QMainWindow::showEvent(event); + emit windowShown(); +} + void MainWindow::clearLog() { m_pLogOutput->clear(); @@ -618,6 +629,16 @@ void MainWindow::startSynergy() } } +void +MainWindow::sslToggled (bool enabled) +{ + if (enabled) { + m_pSslCertificate = new SslCertificate(this); + m_pSslCertificate->generateCertificate(); + } + updateLocalFingerprint(); +} + bool MainWindow::clientArgs(QStringList& args, QString& app) { app = appPath(appConfig().synergycName()); @@ -1014,28 +1035,20 @@ void MainWindow::serverDetected(const QString name) } } -void MainWindow::setEdition(int type) +void MainWindow::setEdition(int edition) { - QString title; - if (type == Basic) { - title = "Synergy Basic"; + setWindowTitle(getEditionName(edition)); + if (m_AppConfig.getCryptoEnabled()) { + m_pSslCertificate = new SslCertificate(this); + m_pSslCertificate->generateCertificate(); } - else if (type == Pro) { - title = "Synergy Pro"; - } - else if (type == Trial) { - title = "Synergy Trial"; - } - else { - title = "Synergy (UNREGISTERED)"; - } - - setWindowTitle(title); + updateLocalFingerprint(); + saveSettings(); } void MainWindow::updateLocalFingerprint() { - if (Fingerprint::local().fileExists()) { + if (m_AppConfig.getCryptoEnabled() && Fingerprint::local().fileExists()) { m_pLabelFingerprint->setVisible(true); m_pLabelLocalFingerprint->setVisible(true); m_pLabelLocalFingerprint->setText(Fingerprint::local().readFirst()); @@ -1145,10 +1158,10 @@ void MainWindow::on_m_pButtonConfigureServer_clicked() showConfigureServer(); } -void MainWindow::on_m_pActionWizard_triggered() +void MainWindow::on_m_pActivate_triggered() { - SetupWizard wizard(*this, false); - wizard.exec(); + ActivationDialog activationDialog (this, this->appConfig()); + activationDialog.exec(); } void MainWindow::on_m_pButtonApply_clicked() @@ -1367,6 +1380,14 @@ void MainWindow::bonjourInstallFinished() m_pCheckBoxAutoConfig->setChecked(true); } +void MainWindow::on_windowShown() +{ + if (!m_AppConfig.activationHasRun() && (m_AppConfig.edition() == Unregistered)) { + ActivationDialog activationDialog (this, m_AppConfig); + activationDialog.exec(); + } +} + QString MainWindow::getProfileRootForArg() { CoreInterface coreInterface; diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index 87380f96..efd83dcc 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -33,6 +33,7 @@ #include "VersionChecker.h" #include "IpcClient.h" #include "Ipc.h" +#include "ActivationDialog.h" #include @@ -56,6 +57,7 @@ class SetupWizard; class ZeroconfService; class DataDownloader; class CommandProcess; +class SslCertificate; class MainWindow : public QMainWindow, public Ui::MainWindowBase { @@ -63,8 +65,9 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase friend class QSynergyApplication; friend class SetupWizard; - friend class PluginWizardPage; - + friend class ActivationDialog; + friend class SettingsDialog; + public: enum qSynergyState { @@ -112,10 +115,10 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase void autoAddScreen(const QString name); void updateZeroconfService(); void serverDetected(const QString name); - void setEdition(int type); void updateLocalFingerprint(); public slots: + void setEdition(int edition); void appendLogRaw(const QString& text); void appendLogInfo(const QString& text); void appendLogDebug(const QString& text); @@ -123,6 +126,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase void startSynergy(); protected slots: + void sslToggled(bool enabled); void on_m_pGroupClient_toggled(bool on); void on_m_pGroupServer_toggled(bool on); bool on_m_pButtonBrowseConfigFile_clicked(); @@ -130,7 +134,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase bool on_m_pActionSave_triggered(); void on_m_pActionAbout_triggered(); void on_m_pActionSettings_triggered(); - void on_m_pActionWizard_triggered(); + void on_m_pActivate_triggered(); void synergyFinished(int exitCode, QProcess::ExitStatus); void trayActivated(QSystemTrayIcon::ActivationReason reason); void stopSynergy(); @@ -180,6 +184,8 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase void restartSynergy(); void proofreadInfo(); + void showEvent (QShowEvent*); + private: QSettings& m_Settings; AppConfig& m_AppConfig; @@ -207,12 +213,17 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase bool m_SuppressEmptyServerWarning; qRuningState m_ExpectedRunningState; QMutex m_StopDesktopMutex; + SslCertificate* m_pSslCertificate; private slots: void on_m_pCheckBoxAutoConfig_toggled(bool checked); void on_m_pComboServerList_currentIndexChanged(QString ); void on_m_pButtonApply_clicked(); void installBonjour(); + void on_windowShown(); + +signals: + void windowShown(); }; #endif diff --git a/src/gui/src/Plugin.cpp b/src/gui/src/Plugin.cpp deleted file mode 100644 index 50079da2..00000000 --- a/src/gui/src/Plugin.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2015-2016 Symless 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 LICENSE 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 . - */ - -#include "Plugin.h" - -#include "CoreInterface.h" - -static const char kBaseUrl[] = "http://symless.com/files"; -static const char kDefaultVersion[] = "1.1"; -static const char kWinPackagePlatform32[] = "Windows-x86"; -static const char kWinPackagePlatform64[] = "Windows-x64"; -static const char kMacPackagePlatform[] = "MacOSX%1-i386"; -static const char kLinuxPackagePlatformDeb32[] = "Linux-i686-deb"; -static const char kLinuxPackagePlatformDeb64[] = "Linux-x86_64-deb"; -static const char kLinuxPackagePlatformRpm32[] = "Linux-i686-rpm"; -static const char kLinuxPackagePlatformRpm64[] = "Linux-x86_64-rpm"; - -#if defined(Q_OS_WIN) -static const char kWinPluginExt[] = ".dll"; -static const char kInstallerPluginLocation[] = "Plugins"; -#elif defined(Q_OS_MAC) -static const char kMacPluginPrefix[] = "lib"; -static const char kMacPluginExt[] = ".dylib"; -static const char kInstallerPluginLocation[] = "plugins"; // TODO: Fix for mac -#else -static const char kLinuxPluginPrefix[] = "lib"; -static const char kLinuxPluginExt[] = ".so"; -// /usr/bin becomes /usr/bin/../lib/syn... -static const char kInstallerPluginLocation[] = "../lib/synergy/plugins"; -#endif - -QString Plugin::getOsSpecificExt() -{ - -#if defined(Q_OS_WIN) - return kWinPluginExt; -#elif defined(Q_OS_MAC) - return kMacPluginExt; -#else - return kLinuxPluginExt; -#endif -} - -QString Plugin::getOsSpecificName(const QString& pluginName) -{ - QString result = pluginName; -#if defined(Q_OS_WIN) - result.append(getOsSpecificExt()); -#elif defined(Q_OS_MAC) - result = kMacPluginPrefix + pluginName + getOsSpecificExt(); -#else - result = kLinuxPluginPrefix + pluginName + getOsSpecificExt(); -#endif - return result; -} - -QString Plugin::getOsSpecificInstallerLocation() { - return kInstallerPluginLocation; -} diff --git a/src/gui/src/Plugin.h b/src/gui/src/Plugin.h deleted file mode 100644 index bec6a1c2..00000000 --- a/src/gui/src/Plugin.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2015-2016 Symless 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 LICENSE 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 . - */ -#ifndef PLUGIN_H -#define PLUGIN_H - -#include -#include -#include - -#include "SslCertificate.h" -#include "CoreInterface.h" -#include "DataDownloader.h" - -class Plugin : public QObject -{ - Q_OBJECT - -public: - //Plugin(); - //~PluginManager(); - - static QString getOsSpecificName(const QString& pluginName); - static QString getOsSpecificExt(); - static QString getOsSpecificLocation(); - static QString getOsSpecificInstallerLocation(); - static QString getOsSpecificUserLocation(); - -public slots: - -private: -// CoreInterface m_CoreInterface; - -signals: - -private: - -}; - -#endif // PLUGIN_H diff --git a/src/gui/src/PluginManager.cpp b/src/gui/src/PluginManager.cpp deleted file mode 100644 index b498751a..00000000 --- a/src/gui/src/PluginManager.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2015-2016 Symless 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 LICENSE 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 . - */ - -#include "PluginManager.h" - -#include "CoreInterface.h" -#include "DataDownloader.h" -#include "QUtility.h" -#include "ProcessorArch.h" -#include "Fingerprint.h" -#include "Plugin.h" -#include "../lib/common/PluginVersion.h" - -#include - -#include -#include -#include -#include - - -PluginManager::PluginManager() : - m_PluginList() -{ - init(); -} - -PluginManager::~PluginManager() -{ -} - -void PluginManager::init() -{ - m_PluginDir = m_CoreInterface.getPluginDir(); - if (m_PluginDir.isEmpty()) { - emit error(tr("Failed to get plugin directory.")); - } - - m_ProfileDir = m_CoreInterface.getProfileDir(); - if (m_ProfileDir.isEmpty()) { - emit error(tr("Failed to get profile directory.")); - } - - m_InstalledDir = m_CoreInterface.getInstalledDir(); - if (m_InstalledDir.isEmpty()) { - emit error(tr("Failed to get installed directory.")); - } -} - -bool PluginManager::exist(QString name) -{ - CoreInterface coreInterface; - QString PluginDir = coreInterface.getPluginDir(); - QString pluginName = Plugin::getOsSpecificName(name); - QString filename; - filename.append(PluginDir); - filename.append(QDir::separator()).append(pluginName); - QFile file(filename); - bool exist = false; - if (file.exists()) { - exist = true; - } - - return exist; -} - -void PluginManager::copyPlugins() -{ - try { - // Get the Directory where plugins are put on installation - // If it doesn't exist, there is nothing to do - QString srcDirName(m_InstalledDir.append(QDir::separator()) - .append(Plugin::getOsSpecificInstallerLocation())); - - QDir srcDir(srcDirName); - if (!srcDir.exists()) { - emit info( - tr("No plugins found to copy from %1") - .arg(srcDirName)); - emit copyFinished(); - } - - // Get the directory where Plugins are installed into Synergy - // If it doesn't exist make it - QString destDirName = m_PluginDir; - - QDir destDir(destDirName); - if (!destDir.exists()) { - destDir.mkpath("."); - } - // Run through the list of plugins and copy them - for ( int i = 0 ; i < m_PluginList.size() ; i++ ) { - // Get a file entry for the plugin using the full path - QFile file(srcDirName + QDir::separator() + m_PluginList.at(i)); - - // construct the destination file name - QString newName(destDirName + QDir::separator() + m_PluginList.at(i)); - - // Check to see if the plugin already exists - QFile newFile(newName); - if(newFile.exists()) { - // If it does, delete it. TODO: Check to see if same and leave - bool result = newFile.remove(); - if( !result ) { - emit error( - tr( "Unable to delete plugin:\n%1\n" - "Please stop synergy and run the wizard again.") - .arg(newName)); - return; - } - } - // make a copy of the plugin in the new location - #if defined(Q_OS_WIN) - bool result = file.copy(newName); - #else - bool result = file.link(newName); - #endif - if ( !result ) { - emit error( - tr("Failed to copy plugin '%1' to: %2\n%3\n" - "Please stop synergy and run the wizard again.") - .arg(m_PluginList.at(i)) - .arg(newName) - .arg(file.errorString())); - return; - } - else { - emit info( - tr("Copying '%1' plugin (%2/%3)...") - .arg(m_PluginList.at(i)) - .arg(i+1) - .arg(m_PluginList.size())); - } - } - } - catch (std::exception& e) - { - emit error(tr( "An error occurred while trying to copy the " - "plugin list. Please contact the help desk, and " - "provide the following details.\n\n%1").arg(e.what())); - } - - emit copyFinished(); - return; -} - -void PluginManager::queryPluginList() -{ - try { - setDone(false); - QString extension = "*" + Plugin::getOsSpecificExt(); - QStringList nameFilter(extension); - - QString installDir(m_CoreInterface.getInstalledDir() - .append(QDir::separator()) - .append(Plugin::getOsSpecificInstallerLocation())); - - QString searchDirectory(installDir); - QDir directory(searchDirectory); - m_PluginList = directory.entryList(nameFilter); - setDone(true); - } - catch (std::exception& e) - { - setDone(true); - emit error(tr( "An error occurred while trying to load the " - "plugin list. Please contact the help desk, and " - "provide the following details.\n\n%1").arg(e.what())); - } - emit queryPluginDone(); - return; -} diff --git a/src/gui/src/PluginManager.h b/src/gui/src/PluginManager.h deleted file mode 100644 index b1450fda..00000000 --- a/src/gui/src/PluginManager.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2015-2016 Symless 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 LICENSE 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 . - */ - -#ifndef PLUGINMANAGER_H -#define PLUGINMANAGER_H - -#include -#include -#include - -#include "SslCertificate.h" -#include "CoreInterface.h" -#include "DataDownloader.h" -#include "Plugin.h" - -class PluginManager : public QObject -{ - Q_OBJECT - -public: - PluginManager(); - ~PluginManager(); - - void init(); - - int pluginCount() { return m_PluginList.count(); } - QStringList& getPluginList() { return m_PluginList; } - - bool isDone() { return done; } - void setDone(bool b) { done = b; } - static bool exist(QString name); - -public slots: - void copyPlugins(); - void queryPluginList(); - -private: - QString getPluginUrl(const QString& pluginName); - bool runProgram( - const QString& program, - const QStringList& args, - const QStringList& env); - -signals: - void error(QString e); - void info(QString i); - void updateCopyStatus(int); - void copyFinished(); - void queryPluginDone(); - -private: - QStringList m_PluginList; - QString m_PluginDir; - QString m_ProfileDir; - QString m_InstalledDir; - CoreInterface m_CoreInterface; - SslCertificate m_SslCertificate; - bool done; -}; - -#endif // PLUGINMANAGER_H diff --git a/src/gui/src/PluginWizardPage.cpp b/src/gui/src/PluginWizardPage.cpp deleted file mode 100644 index 6109929a..00000000 --- a/src/gui/src/PluginWizardPage.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2015-2016 Symless 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 LICENSE 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 . - */ - -#include "PluginWizardPage.h" -#include "ui_PluginWizardPageBase.h" - -#include "SslCertificate.h" -#include "PluginManager.h" -#include "MainWindow.h" -#include "EditionType.h" - -#include -#include -#include - -PluginWizardPage::PluginWizardPage(MainWindow& mainWindow, QWidget *parent) : - QWizardPage(parent), - m_Finished(false), - m_Edition(UnknownEdition), - m_pSslCertificate(NULL), - m_mainWindow(mainWindow) -{ - setupUi(this); - - QMovie *movie = new QMovie(":/res/image/spinning-wheel.gif"); - m_pLabelSpinning->setMovie(movie); - movie->start(); - - m_pSslCertificate = new SslCertificate(this); -} - -PluginWizardPage::~PluginWizardPage() -{ - delete m_pSslCertificate; -} - -void PluginWizardPage::changeEvent(QEvent *e) -{ - QWizardPage::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - retranslateUi(this); - break; - default: - break; - } -} - -void PluginWizardPage::initializePage() -{ - QWizardPage::initializePage(); - - if (m_Edition != Pro) { - updateStatus(tr("Setup complete.")); - showFinished(); - return; - } - - m_pLabelSpinning->show(); - - QThread* thread = new QThread; - - connect(&m_PluginManager, - SIGNAL(error(QString)), - this, - SLOT(showError(QString))); - - connect(&m_PluginManager, - SIGNAL(info(QString)), - this, - SLOT(updateStatus(QString))); - - connect(&m_PluginManager, - SIGNAL(queryPluginDone()), - this, - SLOT(queryPluginDone())); - - connect(&m_PluginManager, - SIGNAL(queryPluginDone()), - thread, - SLOT(quit())); - - connect(&m_PluginManager, - SIGNAL(error(QString)), - thread, - SLOT(quit())); - - connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); - - m_PluginManager.moveToThread(thread); - thread->start(); - - QMetaObject::invokeMethod(&m_PluginManager, "queryPluginList", Qt::QueuedConnection); -} - -void PluginWizardPage::queryPluginDone() -{ - QStringList pluginList = m_PluginManager.getPluginList(); - if (pluginList.isEmpty()) { - updateStatus(tr("Setup complete.")); - showFinished(); - } - else { - m_mainWindow.stopSynergy(); - copyPlugins(); - m_mainWindow.startSynergy(); - } -} - -void PluginWizardPage::copyPlugins() -{ - m_pThread = new QThread; - - connect(&m_PluginManager, - SIGNAL(copyFinished()), - this, - SLOT(generateCertificate())); - - connect(&m_PluginManager, - SIGNAL(error(QString)), - m_pThread, - SLOT(quit())); - - connect(m_pThread, - SIGNAL(finished()), - m_pThread, - SLOT(deleteLater())); - - updateStatus( - tr("Copying plugins...")); - - m_PluginManager.moveToThread(m_pThread); - m_pThread->start(); - - QMetaObject::invokeMethod( - &m_PluginManager, - "copyPlugins", - Qt::QueuedConnection); -} - -void PluginWizardPage::generateCertificate() -{ - connect(m_pSslCertificate, - SIGNAL(generateFinished()), - this, - SLOT(finished())); - - connect(m_pSslCertificate, - SIGNAL(generateFinished()), - m_pThread, - SLOT(quit())); - - updateStatus(tr("Generating SSL certificate...")); - - QMetaObject::invokeMethod( - m_pSslCertificate, - "generateCertificate", - Qt::QueuedConnection); -} - -void PluginWizardPage::showError(QString error) -{ - updateStatus(tr("Error: %1").arg(error)); - showFinished(); -} - - -void PluginWizardPage::updateStatus(QString info) -{ - m_pLabelStatus->setText(info); -} - -void PluginWizardPage::finished() -{ - // TODO: we should check if ns plugin exists - m_mainWindow.appConfig().setCryptoEnabled(true); - - updateStatus(tr("Plugins installed successfully.")); - showFinished(); -} - -void PluginWizardPage::showFinished() -{ - m_pLabelSpinning->hide(); - m_Finished = true; - emit completeChanged(); -} - -bool PluginWizardPage::isComplete() const -{ - return m_Finished; -} diff --git a/src/gui/src/PluginWizardPage.h b/src/gui/src/PluginWizardPage.h deleted file mode 100644 index d4319786..00000000 --- a/src/gui/src/PluginWizardPage.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2015-2016 Symless 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 LICENSE 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 . - */ - -#ifndef PLUGINWIZARDPAGE_H -#define PLUGINWIZARDPAGE_H - -#include "AppConfig.h" - -#include "ui_PluginWizardPageBase.h" -#include "PluginManager.h" -#include - -class SslCertificate; -class MainWindow; - -class PluginWizardPage : public QWizardPage, public Ui::PluginWizardPage { - - Q_OBJECT - -public: - PluginWizardPage(MainWindow& mainWindow, QWidget *parent = 0); - ~PluginWizardPage(); - - void setFinished(bool b) { m_Finished = b; } - void setEdition(int edition) { m_Edition = edition; } - - bool isComplete() const; - void initializePage(); - -protected: - void changeEvent(QEvent *e); - -protected slots: - void showError(QString error); - void updateStatus(QString info); - void queryPluginDone(); - void generateCertificate(); - void finished(); - -private: - void copyPlugins(); - void showFinished(); - -private: - bool m_Finished; - int m_Edition; - PluginManager m_PluginManager; - SslCertificate* m_pSslCertificate; - QThread* m_pThread; - MainWindow& m_mainWindow; -}; -#endif // PLUGINWIZARDPAGE_H diff --git a/src/gui/src/QUtility.cpp b/src/gui/src/QUtility.cpp index 6a9c6e1d..a13849d4 100644 --- a/src/gui/src/QUtility.cpp +++ b/src/gui/src/QUtility.cpp @@ -19,6 +19,7 @@ #include "ProcessorArch.h" #include "CommandProcess.h" +#include "EditionType.h" #if defined(Q_OS_LINUX) #include @@ -41,6 +42,22 @@ void setIndexFromItemData(QComboBox* comboBox, const QVariant& itemData) } } +QString +getEditionName (int edition) { + if (edition == Basic) { + return "Synergy Basic"; + } + else if (edition == Pro) { + return "Synergy Pro"; + } + else if (edition == Trial) { + return "Synergy Trial"; + } + else { + return "Synergy (UNREGISTERED)"; + } +} + QString hash(const QString& string) { QByteArray data = string.toUtf8(); @@ -96,15 +113,18 @@ QString getOSInformation() QString result; #if defined(Q_OS_LINUX) - QStringList arguments; - arguments.append("/etc/os-release"); - CommandProcess cp("/bin/cat", arguments); - QString output = cp.run(); + result = "Linux"; + try { + QStringList arguments; + arguments.append("/etc/os-release"); + CommandProcess cp("/bin/cat", arguments); + QString output = cp.run(); - QRegExp resultRegex(".*PRETTY_NAME=\"([^\"]+)\".*"); - if (resultRegex.exactMatch(output)) { - QString OSInfo = resultRegex.cap(1); - result = OSInfo; + QRegExp resultRegex(".*PRETTY_NAME=\"([^\"]+)\".*"); + if (resultRegex.exactMatch(output)) { + result = resultRegex.cap(1); + } + } catch (...) { } #endif diff --git a/src/gui/src/QUtility.h b/src/gui/src/QUtility.h index 0738d96c..ca00d06f 100644 --- a/src/gui/src/QUtility.h +++ b/src/gui/src/QUtility.h @@ -29,3 +29,4 @@ QString hash(const QString& string); QString getFirstMacAddress(); qProcessorArch getProcessorArch(); QString getOSInformation(); +QString getEditionName (int edition); diff --git a/src/gui/src/SettingsDialog.cpp b/src/gui/src/SettingsDialog.cpp index a87172f5..0310a02f 100644 --- a/src/gui/src/SettingsDialog.cpp +++ b/src/gui/src/SettingsDialog.cpp @@ -18,12 +18,14 @@ #include "SettingsDialog.h" -#include "PluginManager.h" #include "CoreInterface.h" #include "SynergyLocale.h" #include "QSynergyApplication.h" #include "QUtility.h" #include "AppConfig.h" +#include "EditionType.h" +#include "SslCertificate.h" +#include "MainWindow.h" #include #include @@ -36,7 +38,7 @@ static const char networkSecurity[] = "ns"; SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), Ui::SettingsDialogBase(), - m_AppConfig(config) + m_appConfig(config) { setupUi(this); @@ -61,13 +63,8 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : m_pComboElevate->hide(); #endif - if (!PluginManager::exist(networkSecurity)) { - m_pGroupNetworkSecurity->setEnabled(false); - m_pCheckBoxEnableCrypto->setChecked(false); - } - else { - m_pCheckBoxEnableCrypto->setChecked(m_AppConfig.getCryptoEnabled()); - } + m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled()); + m_pCheckBoxEnableCrypto->setEnabled(m_appConfig.edition() == Pro); } void SettingsDialog::accept() @@ -147,5 +144,12 @@ void SettingsDialog::on_m_pComboLanguage_currentIndexChanged(int index) void SettingsDialog::on_m_pCheckBoxEnableCrypto_toggled(bool checked) { - m_AppConfig.setCryptoEnabled(checked); + m_appConfig.setCryptoEnabled(checked); + m_appConfig.saveSettings(); + if (checked) { + SslCertificate sslCertificate; + sslCertificate.generateCertificate(); + MainWindow& mainWindow = dynamic_cast (*this->parent()); + mainWindow.updateLocalFingerprint(); + } } diff --git a/src/gui/src/SettingsDialog.h b/src/gui/src/SettingsDialog.h index 656323a6..841ffff8 100644 --- a/src/gui/src/SettingsDialog.h +++ b/src/gui/src/SettingsDialog.h @@ -40,10 +40,10 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase void accept(); void reject(); void changeEvent(QEvent* event); - AppConfig& appConfig() { return m_AppConfig; } + AppConfig& appConfig() { return m_appConfig; } private: - AppConfig& m_AppConfig; + AppConfig& m_appConfig; SynergyLocale m_Locale; CoreInterface m_CoreInterface; diff --git a/src/gui/src/SetupWizard.cpp b/src/gui/src/SetupWizard.cpp index 67e3b1a5..b4e6ab3a 100644 --- a/src/gui/src/SetupWizard.cpp +++ b/src/gui/src/SetupWizard.cpp @@ -28,13 +28,9 @@ SetupWizard::SetupWizard(MainWindow& mainWindow, bool startMain) : m_MainWindow(mainWindow), - m_StartMain(startMain), - m_Edition(UnknownEdition), - m_LoginAttemps(0) + m_StartMain(startMain) { setupUi(this); - m_pPluginPage = new PluginWizardPage(mainWindow); - addPage(m_pPluginPage); #if defined(Q_OS_MAC) @@ -59,13 +55,6 @@ SetupWizard::SetupWizard(MainWindow& mainWindow, bool startMain) : m_Locale.fillLanguageComboBox(m_pComboLanguage); setIndexFromItemData(m_pComboLanguage, m_MainWindow.appConfig().language()); - AppConfig& appConfig = m_MainWindow.appConfig(); - - m_pLineEditEmail->setText(appConfig.activateEmail()); - m_pTextEditSerialKey->setText(appConfig.serialKey()); - - m_pTextEditSerialKey->setEnabled(false); - } SetupWizard::~SetupWizard() @@ -78,70 +67,7 @@ bool SetupWizard::validateCurrentPage() message.setWindowTitle(tr("Setup Synergy")); message.setIcon(QMessageBox::Information); - 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 == UnknownEdition) { - m_LoginAttemps++; - if (m_LoginAttemps == kMaximiumLoginAttemps) { - m_LoginAttemps = 0; - - QMessageBox::StandardButton reply = - QMessageBox::information( - this, tr("Setup Synergy"), - tr("Would you like to use your serial key instead?"), - QMessageBox::Yes | QMessageBox::No); - - if (reply == QMessageBox::Yes) { - m_pRadioButtonSubscription->setChecked(true); - } - } - - return false; - } - else { - m_pPluginPage->setEdition(m_Edition); - return true; - } - } - } - else if (m_pRadioButtonSubscription->isChecked()) { - if (m_pTextEditSerialKey->toPlainText().isEmpty()) { - message.setText(tr("Please enter your subscription serial key.")); - message.exec(); - return false; - } - else { - // create subscription file in profile directory - SubscriptionManager subscriptionManager(this, m_MainWindow.appConfig(), m_Edition); - if (!subscriptionManager.activateSerial(m_pTextEditSerialKey->toPlainText())) { - return false; - } - - m_pPluginPage->setEdition(m_Edition); - - return true; - } - } - else { - return true; - } - } - else if (currentPage() == m_pNodePage) + if (currentPage() == m_pNodePage) { bool result = m_pClientRadioButton->isChecked() || m_pServerRadioButton->isChecked(); @@ -198,31 +124,6 @@ void SetupWizard::accept() settings.setValue("groupServerChecked", false); } - if (m_pRadioButtonActivate->isChecked()) { - appConfig.setActivateEmail(m_pLineEditEmail->text()); - - notifyActivation("login:" + m_pLineEditEmail->text()); - } - - if (m_pRadioButtonSubscription->isChecked()) - { - appConfig.setSerialKey(m_pTextEditSerialKey->toPlainText()); - - notifyActivation("serial:" + m_pTextEditSerialKey->toPlainText()); - } - - if (m_pRadioButtonSkip->isChecked()) - { - notifyActivation("skip:unknown"); - } - - appConfig.setEdition(m_Edition); - m_MainWindow.setEdition(m_Edition); - m_MainWindow.updateLocalFingerprint(); - - appConfig.saveSettings(); - settings.sync(); - QWizard::accept(); if (m_StartMain) @@ -238,60 +139,14 @@ void SetupWizard::reject() if (m_StartMain) { - m_MainWindow.setEdition(m_Edition); m_MainWindow.open(); } - // treat cancel as skip - notifyActivation("skip:unknown"); - QWizard::reject(); } -void SetupWizard::notifyActivation(QString identity) -{ - ActivationNotifier* notifier = new ActivationNotifier(); - notifier->setIdentity(identity); - QThread* thread = new QThread; - connect(notifier, SIGNAL(finished()), thread, SLOT(quit())); - connect(notifier, SIGNAL(finished()), notifier, SLOT(deleteLater())); - connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); - - notifier->moveToThread(thread); - thread->start(); - - QMetaObject::invokeMethod(notifier, "notify", Qt::QueuedConnection); -} - void SetupWizard::on_m_pComboLanguage_currentIndexChanged(int index) { QString ietfCode = m_pComboLanguage->itemData(index).toString(); QSynergyApplication::getInstance()->switchTranslator(ietfCode); } - -void SetupWizard::on_m_pRadioButtonSkip_toggled(bool checked) -{ - if (checked) { - m_pLineEditEmail->setEnabled(false); - m_pLineEditPassword->setEnabled(false); - m_pTextEditSerialKey->setEnabled(false); - } -} - -void SetupWizard::on_m_pRadioButtonActivate_toggled(bool checked) -{ - if (checked) { - m_pLineEditEmail->setEnabled(true); - m_pLineEditPassword->setEnabled(true); - m_pTextEditSerialKey->setEnabled(false); - } -} - -void SetupWizard::on_m_pRadioButtonSubscription_toggled(bool checked) -{ - if (checked) { - m_pLineEditEmail->setEnabled(false); - m_pLineEditPassword->setEnabled(false); - m_pTextEditSerialKey->setEnabled(true); - } -} diff --git a/src/gui/src/SetupWizard.h b/src/gui/src/SetupWizard.h index 34b301a2..009939b2 100644 --- a/src/gui/src/SetupWizard.h +++ b/src/gui/src/SetupWizard.h @@ -19,7 +19,6 @@ #include "ui_SetupWizardBase.h" #include "SynergyLocale.h" -#include "PluginWizardPage.h" #include #include @@ -43,19 +42,12 @@ protected: void changeEvent(QEvent* event); void accept(); void reject(); - void notifyActivation(QString identity); private: MainWindow& m_MainWindow; bool m_StartMain; SynergyLocale m_Locale; - int m_Edition; - PluginWizardPage* m_pPluginPage; - int m_LoginAttemps; private slots: - void on_m_pRadioButtonSubscription_toggled(bool checked); - void on_m_pRadioButtonActivate_toggled(bool checked); - void on_m_pRadioButtonSkip_toggled(bool checked); void on_m_pComboLanguage_currentIndexChanged(int index); }; diff --git a/src/gui/src/SslCertificate.cpp b/src/gui/src/SslCertificate.cpp index 7a8403c0..a669c5f6 100644 --- a/src/gui/src/SslCertificate.cpp +++ b/src/gui/src/SslCertificate.cpp @@ -90,56 +90,59 @@ bool SslCertificate::runTool(const QStringList& args) void SslCertificate::generateCertificate() { - QStringList arguments; - - // self signed certificate - arguments.append("req"); - arguments.append("-x509"); - arguments.append("-nodes"); - - // valide duration - arguments.append("-days"); - arguments.append(kCertificateLifetime); - - // subject information - arguments.append("-subj"); - - QString subInfo(kCertificateSubjectInfo); - arguments.append(subInfo); - - // private key - arguments.append("-newkey"); - arguments.append("rsa:1024"); - QString sslDirPath = QString("%1%2%3") .arg(m_ProfileDir) .arg(QDir::separator()) .arg(kSslDir); - QDir sslDir(sslDirPath); - if (!sslDir.exists()) { - sslDir.mkpath("."); - } - QString filename = QString("%1%2%3") .arg(sslDirPath) .arg(QDir::separator()) .arg(kCertificateFilename); - // key output filename - arguments.append("-keyout"); - arguments.append(filename); + QFile file(filename); + if (!file.exists()) { + QStringList arguments; - // certificate output filename - arguments.append("-out"); - arguments.append(filename); + // self signed certificate + arguments.append("req"); + arguments.append("-x509"); + arguments.append("-nodes"); - if (!runTool(arguments)) { - return; + // valide duration + arguments.append("-days"); + arguments.append(kCertificateLifetime); + + // subject information + arguments.append("-subj"); + + QString subInfo(kCertificateSubjectInfo); + arguments.append(subInfo); + + // private key + arguments.append("-newkey"); + arguments.append("rsa:1024"); + + QDir sslDir(sslDirPath); + if (!sslDir.exists()) { + sslDir.mkpath("."); + } + + // key output filename + arguments.append("-keyout"); + arguments.append(filename); + + // certificate output filename + arguments.append("-out"); + arguments.append(filename); + + if (!runTool(arguments)) { + return; + } + + emit info(tr("SSL certificate generated.")); } - emit info(tr("SSL certificate generated.")); - generateFingerprint(filename); emit generateFinished(); diff --git a/src/gui/src/SubscriptionManager.cpp b/src/gui/src/SubscriptionManager.cpp index f3dd3425..77e0a91c 100644 --- a/src/gui/src/SubscriptionManager.cpp +++ b/src/gui/src/SubscriptionManager.cpp @@ -39,7 +39,7 @@ SubscriptionManager::SubscriptionManager(QWidget* parent, AppConfig& appConfig, bool SubscriptionManager::activateSerial(const QString& serial) { - m_Edition = UnknownEdition; + m_Edition = Unregistered; persistDirectory(); CoreInterface coreInterface; QString output; @@ -62,7 +62,7 @@ bool SubscriptionManager::activateSerial(const QString& serial) bool SubscriptionManager::checkSubscription() { - m_Edition = UnknownEdition; + m_Edition = Unregistered; persistDirectory(); CoreInterface coreInterface; QString output; @@ -98,7 +98,7 @@ void SubscriptionManager::checkError(QString& error) } else { QMessageBox::warning(m_pParent, tr("Subscription error"), - tr("An error occurred while trying to activate using a serial key. " + tr("An error occurred while trying to activate Synergy using your serial key. " "Please contact the helpdesk, and provide the " "following details.\n\n%1").arg(error)); } diff --git a/src/gui/src/VersionChecker.cpp b/src/gui/src/VersionChecker.cpp index 1f6980fc..4ce27433 100644 --- a/src/gui/src/VersionChecker.cpp +++ b/src/gui/src/VersionChecker.cpp @@ -51,8 +51,10 @@ void VersionChecker::replyFinished(QNetworkReply* reply) if (!newestVersion.isEmpty()) { QString currentVersion = getVersion(); - if (compareVersions(currentVersion, newestVersion) > 0) - emit updateFound(newestVersion); + if (currentVersion != "Unknown") { + if (compareVersions(currentVersion, newestVersion) > 0) + emit updateFound(newestVersion); + } } } diff --git a/src/gui/src/WebClient.cpp b/src/gui/src/WebClient.cpp index 66141c58..1d21dc82 100644 --- a/src/gui/src/WebClient.cpp +++ b/src/gui/src/WebClient.cpp @@ -25,76 +25,60 @@ #include #include -int WebClient::getEdition( - const QString& email, - const QString& password, - QMessageBox& message, - QWidget* w) -{ - QString responseJson; - int edition = UnknownEdition; - try { - responseJson = request(email, password); - } - catch (std::exception& e) - { - message.critical( - w, "Error", - tr("An error occurred while trying to sign in. " - "Please contact the helpdesk, and provide the " - "following details.\n\n%1").arg(e.what())); - return edition; - } +bool +WebClient::getEdition (int& edition, QString& errorOut) { + QString responseJson = request(); + + /* TODO: This is horrible and should be ripped out as soon as we move + * to Qt 5. See issue #5630 + */ QRegExp resultRegex(".*\"result\".*:.*(true|false).*"); - if (resultRegex.exactMatch(responseJson)) { + if (resultRegex.exactMatch (responseJson)) { QString boolString = resultRegex.cap(1); if (boolString == "true") { QRegExp editionRegex(".*\"edition\".*:.*\"([^\"]+)\".*"); if (editionRegex.exactMatch(responseJson)) { QString e = editionRegex.cap(1); edition = e.toInt(); + return true; + } else { + throw std::runtime_error ("Unrecognised server response."); } - - return edition; + } else { + errorOut = tr("Login failed. Invalid email address or password."); + return false; } - else if (boolString == "false") { - message.critical( - w, "Error", - tr("Login failed, invalid email or password.")); - - return edition; - } - } - else { + } else { QRegExp errorRegex(".*\"error\".*:.*\"([^\"]+)\".*"); - if (errorRegex.exactMatch(responseJson)) { - - // replace "\n" with real new lines. - QString error = errorRegex.cap(1).replace("\\n", "\n"); - message.critical( - w, "Error", - tr("Login failed, an error occurred.\n\n%1").arg(error)); - - return edition; + if (errorRegex.exactMatch (responseJson)) { + errorOut = errorRegex.cap(1).replace("\\n", "\n"); + return false; + } else { + throw std::runtime_error ("Unrecognised server response."); } } - - message.critical( - w, "Error", - tr("Login failed, an error occurred.\n\nServer response:\n\n%1") - .arg(responseJson)); - - return edition; } -QString WebClient::request( - const QString& email, - const QString& password) -{ +bool +WebClient::setEmail (QString email, QString& errorOut) { + if (email.isEmpty()) { + errorOut = tr("Your email address cannot be left blank."); + return false; + } + m_Email = email; + return true; +} + +bool +WebClient::setPassword (QString password, QString&) { + m_Password = password; + return true; +} + +QString +WebClient::request() { QStringList args("--login-auth"); - // hash password in case it contains interesting chars. - QString credentials(email + ":" + hash(password) + "\n"); - - return m_CoreInterface.run(args, credentials); + QString credentials (m_Email + ":" + hash(m_Password) + "\n"); + return m_CoreInterface.run (args, credentials); } diff --git a/src/gui/src/WebClient.h b/src/gui/src/WebClient.h index 100b63d1..7ff6e2be 100644 --- a/src/gui/src/WebClient.h +++ b/src/gui/src/WebClient.h @@ -32,21 +32,15 @@ class WebClient : public QObject Q_OBJECT public: - int getEdition(const QString& email, - const QString& password, - QMessageBox& message, - QWidget* w); - void setEmail(QString& e) { m_Email = e; } - void setPassword(QString& p) { m_Password = p; } - + bool getEdition (int& edition, QString& errorOut); + bool setEmail (QString email, QString& errorOut); + bool setPassword (QString password, QString& errorOut); signals: void error(QString e); private: - QString request(const QString& email, - const QString& password); - -private: + QString request(); + QString m_Email; QString m_Password; CoreInterface m_CoreInterface; diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 8eba5dff..48beb80a 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -23,7 +23,6 @@ add_subdirectory(ipc) add_subdirectory(mt) add_subdirectory(net) add_subdirectory(platform) -add_subdirectory(plugin) add_subdirectory(server) add_subdirectory(synergy) diff --git a/src/lib/arch/Arch.h b/src/lib/arch/Arch.h index 3c5a23ff..42be6eb8 100644 --- a/src/lib/arch/Arch.h +++ b/src/lib/arch/Arch.h @@ -50,7 +50,6 @@ # include "arch/win32/ArchSystemWindows.h" # include "arch/win32/ArchTaskBarWindows.h" # include "arch/win32/ArchTimeWindows.h" -# include "arch/win32/ArchPluginWindows.h" # include "arch/win32/ArchInternetWindows.h" #elif SYSAPI_UNIX # include "arch/unix/ArchConsoleUnix.h" @@ -66,7 +65,6 @@ # include "arch/unix/ArchSystemUnix.h" # include "arch/unix/ArchTaskBarXWindows.h" # include "arch/unix/ArchTimeUnix.h" -# include "arch/unix/ArchPluginUnix.h" # include "arch/unix/ArchInternetUnix.h" #endif @@ -122,12 +120,10 @@ public: static void setInstance(Arch* s) { s_instance = s; } - ARCH_PLUGIN& plugin() const { return (ARCH_PLUGIN&)m_plugin; } ARCH_INTERNET& internet() const { return (ARCH_INTERNET&)m_internet; } private: static Arch* s_instance; - ARCH_PLUGIN m_plugin; ARCH_INTERNET m_internet; }; diff --git a/src/lib/arch/IArchPlugin.h b/src/lib/arch/IArchPlugin.h deleted file mode 100644 index e91ed65f..00000000 --- a/src/lib/arch/IArchPlugin.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2012-2016 Symless Ltd. - * Copyright (C) 2012 Nick Bolton - * - * 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 LICENSE 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 . - */ - -#pragma once - -#include "common/IInterface.h" -#include "common/stdmap.h" -#include "base/String.h" - -class IEventQueue; - -//! Interface for plugin manager. -/*! -A plugin manager should load all 3rd party plugins from the plugins dir, -and then look for common function names in the plugins. -*/ -class IArchPlugin : public IInterface { -public: - //! @name manipulators - //@{ - - //!Load plugins - /*! - Scan the plugins dir and load plugins. - */ - virtual void load() = 0; - - //!Unload plugins - /*! - Look through the loaded plugins and unload them. - */ - virtual void unload() = 0; - - //! Init the common parts - /*! - Initializes common parts like log and arch. - */ - virtual void init(void* log, void* arch) = 0; - - //! Init the event part - /*! - Initializes event parts. - */ - virtual void initEvent(void* eventTarget, IEventQueue* events) = 0; - - //! Check if exists - /*! - Returns true if the plugin exists and is loaded. - */ - virtual bool exists(const char* name) = 0; - - //! Invoke function - /*! - Invokes a function from the plugin. - */ - virtual void* invoke(const char* plugin, - const char* command, - void** args, - void* library = NULL) = 0; - - //@} - -protected: - typedef std::map PluginTable; -}; diff --git a/src/lib/arch/unix/ArchMultithreadPosix.cpp b/src/lib/arch/unix/ArchMultithreadPosix.cpp index 807894e2..33da29b4 100644 --- a/src/lib/arch/unix/ArchMultithreadPosix.cpp +++ b/src/lib/arch/unix/ArchMultithreadPosix.cpp @@ -697,7 +697,7 @@ void* ArchMultithreadPosix::threadFunc(void* vrep) { // get the thread - ArchThreadImpl* thread = reinterpret_cast(vrep); + ArchThreadImpl* thread = static_cast(vrep); // setup pthreads pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); diff --git a/src/lib/arch/unix/ArchNetworkBSD.cpp b/src/lib/arch/unix/ArchNetworkBSD.cpp index c2d692fc..8913313e 100644 --- a/src/lib/arch/unix/ArchNetworkBSD.cpp +++ b/src/lib/arch/unix/ArchNetworkBSD.cpp @@ -646,7 +646,7 @@ ArchNetworkBSD::newAnyAddr(EAddressFamily family) switch (family) { case kINET: { struct sockaddr_in* ipAddr = - reinterpret_cast(&addr->m_addr); + reinterpret_cast(&addr->m_addr); ipAddr->sin_family = AF_INET; ipAddr->sin_port = 0; ipAddr->sin_addr.s_addr = INADDR_ANY; @@ -737,8 +737,7 @@ ArchNetworkBSD::addrToName(ArchNetAddress addr) // mutexed name lookup (ugh) ARCH->lockMutex(m_mutex); - struct hostent* info = gethostbyaddr( - reinterpret_cast(&addr->m_addr), + struct hostent* info = gethostbyaddr(&addr->m_addr, addr->m_len, addr->m_addr.sa_family); if (info == NULL) { ARCH->unlockMutex(m_mutex); @@ -834,7 +833,7 @@ ArchNetworkBSD::isAnyAddr(ArchNetAddress addr) switch (getAddrFamily(addr)) { case kINET: { struct sockaddr_in* ipAddr = - reinterpret_cast(&addr->m_addr); + reinterpret_cast(&addr->m_addr); return (ipAddr->sin_addr.s_addr == INADDR_ANY && addr->m_len == (socklen_t)sizeof(struct sockaddr_in)); } diff --git a/src/lib/arch/unix/ArchPluginUnix.cpp b/src/lib/arch/unix/ArchPluginUnix.cpp deleted file mode 100644 index edf53d17..00000000 --- a/src/lib/arch/unix/ArchPluginUnix.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2012-2016 Symless Ltd. - * Copyright (C) 2012 Nick Bolton - * - * 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 LICENSE 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 . - */ - -#include "arch/unix/ArchPluginUnix.h" - -#include "arch/unix/XArchUnix.h" -#include "common/PluginVersion.h" -#include "base/IEventQueue.h" -#include "base/Event.h" -#include "base/Log.h" - -#include -#include -#include -#include - -typedef void (*initFunc)(void*, void*); -typedef int (*initEventFunc)(void (*sendEvent)(const char*, void*)); -typedef void* (*invokeFunc)(const char*, void*); -typedef void (*cleanupFunc)(); - -void* g_eventTarget = NULL; -IEventQueue* g_events = NULL; - -ArchPluginUnix::ArchPluginUnix() -{ -} - -ArchPluginUnix::~ArchPluginUnix() -{ -} - -void -ArchPluginUnix::load() -{ - String pluginsDir = getPluginsDir(); - LOG((CLOG_DEBUG "plugins dir: %s", pluginsDir.c_str())); - - struct dirent* de = NULL; - DIR* dir = NULL; - - dir = opendir(pluginsDir.c_str()); - if (dir == NULL) { - LOG((CLOG_DEBUG "can't open plugins dir: %s", - pluginsDir.c_str())); - return; - } - - std::vector plugins; - while ((de = readdir(dir)) != NULL) { - // ignore hidden files and diretories like .. and . - if (de->d_name[0] != '.') { - plugins.push_back(de->d_name); - } - } - closedir(dir); - - std::vector::iterator it; - for (it = plugins.begin(); it != plugins.end(); ++it) { - String filename = *it; - String path = synergy::string::sprintf( - "%s/%s", pluginsDir.c_str(), filename.c_str()); - String name = synergy::string::removeFileExt(filename.substr(3)); - - LOG((CLOG_DEBUG "loading plugin: %s", filename.c_str())); - void* handle = dlopen(path.c_str(), RTLD_LAZY); - - if (handle == NULL) { - LOG((CLOG_ERR "failed to load plugin '%s', error: %s", - filename.c_str(), dlerror())); - continue; - } - - - String expectedVersion = getExpectedPluginVersion(name.c_str()); - String currentVersion = getCurrentVersion(name, handle); - - if (currentVersion.empty() || (expectedVersion != currentVersion)) { - LOG((CLOG_ERR - "failed to load plugin '%s', " - "expected version %s but was %s", - filename.c_str(), - expectedVersion.c_str(), - currentVersion.empty() ? "unknown" : currentVersion.c_str())); - - dlclose(handle); - continue; - } - - LOG((CLOG_DEBUG "plugin loaded: %s (version %s)", - filename.c_str(), - currentVersion.c_str())); - - m_pluginTable.insert(std::make_pair(name, handle)); - } -} - -void -ArchPluginUnix::unload() -{ - PluginTable::iterator it; - for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) { - cleanupFunc cleanup = (cleanupFunc)dlsym(it->second, "cleanup"); - if (cleanup != NULL) { - cleanup(); - } - else { - LOG((CLOG_DEBUG "no cleanup function in %s", it->first.c_str())); - } - - LOG((CLOG_DEBUG "unloading plugin: %s", it->first.c_str())); - dlclose(it->second); - } -} - -void -ArchPluginUnix::init(void* log, void* arch) -{ - PluginTable::iterator it; - for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) { - initFunc initPlugin = (initFunc)dlsym(it->second, "init"); - if (initPlugin != NULL) { - initPlugin(log, arch); - } - else { - LOG((CLOG_DEBUG "no init function in %s", it->first.c_str())); - } - } -} - -void -ArchPluginUnix::initEvent(void* eventTarget, IEventQueue* events) -{ - g_eventTarget = eventTarget; - g_events = events; - - PluginTable::iterator it; - for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) { - initEventFunc initEventPlugin = (initEventFunc)dlsym(it->second, "initEvent"); - if (initEventPlugin != NULL) { - initEventPlugin(&sendEvent); - } - else { - LOG((CLOG_DEBUG "no init event function in %s", it->first.c_str())); - } - } -} - -bool -ArchPluginUnix::exists(const char* name) -{ - PluginTable::iterator it; - it = m_pluginTable.find(name); - return it != m_pluginTable.end() ? true : false; -} - -void* -ArchPluginUnix::invoke( - const char* plugin, - const char* command, - void** args, - void* library) -{ - void* lib = NULL; - - if (library == NULL) { - PluginTable::iterator it; - it = m_pluginTable.find(plugin); - if (it != m_pluginTable.end()) { - lib = it->second; - } - else { - LOG((CLOG_DEBUG "invoke command failed, plugin: %s command: %s", - plugin, command)); - return NULL; - } - } - else { - lib = library; - } - - invokeFunc invokePlugin = (invokeFunc)dlsym(lib, "invoke"); - void* result = NULL; - if (invokePlugin != NULL) { - result = invokePlugin(command, args); - } - else { - LOG((CLOG_DEBUG "no invoke function in %s", plugin)); - } - - return result; -} - -String -ArchPluginUnix::getPluginsDir() -{ - return ARCH->getPluginDirectory(); -} - -String -ArchPluginUnix::getCurrentVersion(const String& name, void* handle) -{ - char* version = (char*)invoke(name.c_str(), "version", NULL, handle); - if (version == NULL) { - return ""; - } - - return version; -} - -void -sendEvent(const char* eventName, void* data) -{ - LOG((CLOG_DEBUG5 "plugin sending event")); - Event::Type type = g_events->getRegisteredType(eventName); - g_events->addEvent(Event(type, g_eventTarget, data)); -} - -void -log(const char* text) -{ - LOG((CLOG_DEBUG "plugin: %s", text)); -} - diff --git a/src/lib/arch/unix/ArchPluginUnix.h b/src/lib/arch/unix/ArchPluginUnix.h deleted file mode 100644 index 84ce185e..00000000 --- a/src/lib/arch/unix/ArchPluginUnix.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2012-2016 Symless Ltd. - * Copyright (C) 2012 Nick Bolton - * - * 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 LICENSE 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 . - */ - -#pragma once - -#include "arch/IArchPlugin.h" - -#define ARCH_PLUGIN ArchPluginUnix - -class IEventQueue; - -//! Unix implementation of IArchPlugin -class ArchPluginUnix : public IArchPlugin { -public: - ArchPluginUnix(); - virtual ~ArchPluginUnix(); - - // IArchPlugin overrides - void load(); - void unload(); - void init(void* log, void* arch); - void initEvent(void* eventTarget, IEventQueue* events); - bool exists(const char* name); - virtual void* invoke(const char* pluginName, - const char* functionName, - void** args, - void* library = NULL); - -private: - String getPluginsDir(); - String getCurrentVersion(const String& name, void* handle); - -private: - PluginTable m_pluginTable; -}; - -void sendEvent(const char* text, void* data); -void log(const char* text); diff --git a/src/lib/arch/win32/ArchMultithreadWindows.cpp b/src/lib/arch/win32/ArchMultithreadWindows.cpp index 0768492d..3c131780 100644 --- a/src/lib/arch/win32/ArchMultithreadWindows.cpp +++ b/src/lib/arch/win32/ArchMultithreadWindows.cpp @@ -661,7 +661,7 @@ unsigned int __stdcall ArchMultithreadWindows::threadFunc(void* vrep) { // get the thread - ArchThreadImpl* thread = reinterpret_cast(vrep); + ArchThreadImpl* thread = static_cast(vrep); // run thread s_instance->doThreadFunc(thread); diff --git a/src/lib/arch/win32/ArchNetworkWinsock.cpp b/src/lib/arch/win32/ArchNetworkWinsock.cpp index 712e1bdc..b1470aa2 100644 --- a/src/lib/arch/win32/ArchNetworkWinsock.cpp +++ b/src/lib/arch/win32/ArchNetworkWinsock.cpp @@ -805,7 +805,7 @@ ArchNetworkWinsock::setAddrPort(ArchNetAddress addr, int port) case kINET: { struct sockaddr_in* ipAddr = reinterpret_cast(&addr->m_addr); - ipAddr->sin_port = htons_winsock(static_cast(port)); + ipAddr->sin_port = htons_winsock(port); break; } diff --git a/src/lib/arch/win32/ArchPluginWindows.cpp b/src/lib/arch/win32/ArchPluginWindows.cpp deleted file mode 100644 index 7e498cb2..00000000 --- a/src/lib/arch/win32/ArchPluginWindows.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2012-2016 Symless Ltd. - * Copyright (C) 2012 Nick Bolton - * - * 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 LICENSE 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 . - */ - -#include "arch/win32/ArchPluginWindows.h" -#include "arch/win32/XArchWindows.h" -#include "common/PluginVersion.h" -#include "base/Log.h" -#include "base/IEventQueue.h" -#include "base/Event.h" -#include "synergy/Screen.h" - -#define WIN32_LEAN_AND_MEAN -#include -#include - -typedef void (*initFunc)(void*, void*); -typedef int (*initEventFunc)(void (*sendEvent)(const char*, void*)); -typedef void* (*invokeFunc)(const char*, void**); -typedef void (*cleanupFunc)(); - -void* g_eventTarget = NULL; -IEventQueue* g_events = NULL; -static const char * kPre174Plugin = "Pre-1.7.v"; - -ArchPluginWindows::ArchPluginWindows() -{ -} - -ArchPluginWindows::~ArchPluginWindows() -{ -} - -void -ArchPluginWindows::load() -{ - String dir = getPluginsDir(); - LOG((CLOG_DEBUG "plugins dir: %s", dir.c_str())); - - String pattern = String(dir).append("\\*.dll"); - std::vector plugins; - getFilenames(pattern, plugins); - - std::vector::iterator it; - for (it = plugins.begin(); it != plugins.end(); ++it) { - String filename = *it; - String name = synergy::string::removeFileExt(filename); - String path = synergy::string::sprintf( - "%s\\%s", dir.c_str(), filename.c_str()); - - LOG((CLOG_DEBUG "loading plugin: %s", filename.c_str())); - HINSTANCE handle = LoadLibrary(path.c_str()); - void* voidHandle = reinterpret_cast(handle); - - if (handle == NULL) { - String error = XArchEvalWindows().eval(); - LOG((CLOG_ERR "failed to load plugin '%s', error: %s", - filename.c_str(), error.c_str())); - continue; - } - - String expectedVersion = getExpectedPluginVersion(name.c_str()); - String currentVersion = getCurrentVersion(name.c_str(), voidHandle); - - if (currentVersion.empty() || (expectedVersion != currentVersion)) { - LOG((CLOG_ERR - "failed to load plugin '%s', " - "expected version %s but was %s", - filename.c_str(), - expectedVersion.c_str(), - currentVersion.empty() ? "unknown" : currentVersion.c_str())); - - FreeLibrary(handle); - continue; - } - - LOG((CLOG_DEBUG "plugin loaded: %s (version %s)", - filename.c_str(), - currentVersion.c_str())); - - m_pluginTable.insert(std::make_pair(name, voidHandle)); - } -} - -void -ArchPluginWindows::unload() -{ - PluginTable::iterator it; - HINSTANCE lib; - for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) { - lib = reinterpret_cast(it->second); - cleanupFunc cleanup = (cleanupFunc)GetProcAddress(lib, "cleanup"); - if (cleanup != NULL) { - cleanup(); - } - else { - LOG((CLOG_DEBUG "no cleanup function in %s", it->first.c_str())); - } - - LOG((CLOG_DEBUG "unloading plugin: %s", it->first.c_str())); - FreeLibrary(lib); - } -} - -void -ArchPluginWindows::init(void* log, void* arch) -{ - PluginTable::iterator it; - HINSTANCE lib; - for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) { - lib = reinterpret_cast(it->second); - initFunc initPlugin = (initFunc)GetProcAddress(lib, "init"); - if (initPlugin != NULL) { - initPlugin(log, arch); - } - else { - LOG((CLOG_DEBUG "no init function in %s", it->first.c_str())); - } - } -} - -void -ArchPluginWindows::initEvent(void* eventTarget, IEventQueue* events) -{ - g_eventTarget = eventTarget; - g_events = events; - - PluginTable::iterator it; - HINSTANCE lib; - for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) { - lib = reinterpret_cast(it->second); - initEventFunc initEventPlugin = (initEventFunc)GetProcAddress(lib, "initEvent"); - if (initEventPlugin != NULL) { - initEventPlugin(&sendEvent); - } - else { - LOG((CLOG_DEBUG "no init event function in %s", it->first.c_str())); - } - } -} - - -bool -ArchPluginWindows::exists(const char* name) -{ - PluginTable::iterator it; - it = m_pluginTable.find(name); - return it != m_pluginTable.end() ? true : false; -} - -void* -ArchPluginWindows::invoke( - const char* plugin, - const char* command, - void** args, - void* library) -{ - HINSTANCE lib = NULL; - - if (library == NULL) { - PluginTable::iterator it; - it = m_pluginTable.find(plugin); - if (it != m_pluginTable.end()) { - lib = reinterpret_cast(it->second); - } - else { - LOG((CLOG_DEBUG "invoke command failed, plugin: %s command: %s", - plugin, command)); - return NULL; - } - } - else { - lib = reinterpret_cast(library); - } - - invokeFunc invokePlugin = (invokeFunc)GetProcAddress(lib, "invoke"); - void* result = NULL; - if (invokePlugin != NULL) { - result = invokePlugin(command, args); - } - else { - LOG((CLOG_DEBUG "no invoke function in %s", plugin)); - } - - return result; -} - -void -ArchPluginWindows::getFilenames(const String& pattern, std::vector& filenames) -{ - WIN32_FIND_DATA data; - HANDLE find = FindFirstFile(pattern.c_str(), &data); - if (find == INVALID_HANDLE_VALUE) { - FindClose(find); - LOG((CLOG_DEBUG "plugins dir is empty: %s", pattern.c_str())); - return; - } - - do { - filenames.push_back(data.cFileName); - } while (FindNextFile(find, &data)); - - FindClose(find); -} - -String -ArchPluginWindows::getPluginsDir() -{ - return ARCH->getPluginDirectory(); -} - -String -ArchPluginWindows::getCurrentVersion(const String& name, void* handle) -{ - char* version = (char*)invoke(name.c_str(), "version", NULL, handle); - if (version == NULL) { - return ""; - } - - return version; -} - - -void -sendEvent(const char* eventName, void* data) -{ - LOG((CLOG_DEBUG5 "plugin sending event")); - Event::Type type = g_events->getRegisteredType(eventName); - g_events->addEvent(Event(type, g_eventTarget, data)); -} - -void -log(const char* text) -{ - LOG((CLOG_DEBUG "plugin: %s", text)); -} diff --git a/src/lib/arch/win32/ArchPluginWindows.h b/src/lib/arch/win32/ArchPluginWindows.h deleted file mode 100644 index dc61ead9..00000000 --- a/src/lib/arch/win32/ArchPluginWindows.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2012-2016 Symless Ltd. - * Copyright (C) 2012 Nick Bolton - * - * 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 LICENSE 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 . - */ - -#pragma once - -#include "arch/IArchPlugin.h" - -#include - -#define ARCH_PLUGIN ArchPluginWindows - -class Screen; -class IEventQueue; - -//! Windows implementation of IArchPlugin -class ArchPluginWindows : public IArchPlugin { -public: - ArchPluginWindows(); - virtual ~ArchPluginWindows(); - - // IArchPlugin overrides - void load(); - void unload(); - void init(void* log, void* arch); - void initEvent(void* eventTarget, IEventQueue* events); - bool exists(const char* name); - void* invoke(const char* pluginName, - const char* functionName, - void** args, - void* library = NULL); - -private: - void getFilenames(const String& pattern, std::vector& filenames); - String getPluginsDir(); - String getCurrentVersion(const String& name, void* handle); - -private: - PluginTable m_pluginTable; -}; - -void sendEvent(const char* text, void* data); -void log(const char* text); diff --git a/src/lib/arch/win32/ArchTaskBarWindows.cpp b/src/lib/arch/win32/ArchTaskBarWindows.cpp index 35b1fd7a..f87a595b 100644 --- a/src/lib/arch/win32/ArchTaskBarWindows.cpp +++ b/src/lib/arch/win32/ArchTaskBarWindows.cpp @@ -245,7 +245,7 @@ ArchTaskBarWindows::modifyIconNoLock( receiver->lock(); // get icon data - HICON icon = reinterpret_cast( + HICON icon = static_cast( const_cast(receiver->getIcon())); // get tool tip @@ -415,16 +415,15 @@ ArchTaskBarWindows::staticWndProc(HWND hwnd, UINT msg, if (msg == WM_NCCREATE) { CREATESTRUCT* createInfo; createInfo = reinterpret_cast(lParam); - self = reinterpret_cast( + self = static_cast( createInfo->lpCreateParams); - SetWindowLongPtr(hwnd, 0, reinterpret_cast(self)); + SetWindowLongPtr(hwnd, 0, reinterpret_cast(createInfo->lpCreateParams)); } else { // get the extra window data and forward the call LONG_PTR data = GetWindowLongPtr(hwnd, 0); if (data != 0) { - self = reinterpret_cast( - reinterpret_cast(data)); + self = static_cast(reinterpret_cast(data)); } } @@ -444,6 +443,7 @@ ArchTaskBarWindows::threadMainLoop() m_taskBarRestart = RegisterWindowMessage(TEXT("TaskbarCreated")); // register a window class + LPCTSTR className = TEXT("SynergyTaskBar"); WNDCLASSEX classInfo; classInfo.cbSize = sizeof(classInfo); classInfo.style = CS_NOCLOSE; @@ -455,20 +455,20 @@ ArchTaskBarWindows::threadMainLoop() classInfo.hCursor = NULL; classInfo.hbrBackground = NULL; classInfo.lpszMenuName = NULL; - classInfo.lpszClassName = TEXT("SynergyTaskBar"); + classInfo.lpszClassName = className; classInfo.hIconSm = NULL; ATOM windowClass = RegisterClassEx(&classInfo); // create window m_hwnd = CreateWindowEx(WS_EX_TOOLWINDOW, - reinterpret_cast(windowClass), + className, TEXT("Synergy Task Bar"), WS_POPUP, 0, 0, 1, 1, NULL, NULL, instanceWin32(), - reinterpret_cast(this)); + static_cast(this)); // signal ready ARCH->lockMutex(m_mutex); @@ -478,7 +478,7 @@ ArchTaskBarWindows::threadMainLoop() // handle failure if (m_hwnd == NULL) { - UnregisterClass(reinterpret_cast(windowClass), instanceWin32()); + UnregisterClass(className, instanceWin32()); return; } @@ -494,13 +494,13 @@ ArchTaskBarWindows::threadMainLoop() // clean up removeAllIcons(); DestroyWindow(m_hwnd); - UnregisterClass(reinterpret_cast(windowClass), instanceWin32()); + UnregisterClass(className, instanceWin32()); } void* ArchTaskBarWindows::threadEntry(void* self) { - reinterpret_cast(self)->threadMainLoop(); + static_cast(self)->threadMainLoop(); return NULL; } diff --git a/src/lib/arch/win32/ArchTimeWindows.cpp b/src/lib/arch/win32/ArchTimeWindows.cpp index ef3f9ef8..cf48c2a2 100644 --- a/src/lib/arch/win32/ArchTimeWindows.cpp +++ b/src/lib/arch/win32/ArchTimeWindows.cpp @@ -65,7 +65,7 @@ ArchTimeWindows::~ArchTimeWindows() { s_freq = 0.0; if (s_mmInstance == NULL) { - FreeLibrary(reinterpret_cast(s_mmInstance)); + FreeLibrary(static_cast(s_mmInstance)); s_tgt = NULL; s_mmInstance = NULL; } diff --git a/src/lib/base/EventQueue.cpp b/src/lib/base/EventQueue.cpp index 60a16317..5f15293f 100644 --- a/src/lib/base/EventQueue.cpp +++ b/src/lib/base/EventQueue.cpp @@ -54,7 +54,7 @@ static void interrupt(Arch::ESignal, void* data) { - EventQueue* events = reinterpret_cast(data); + EventQueue* events = static_cast(data); events->addEvent(Event(Event::kQuit)); } diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp index 748c8cb7..e0ef9e8b 100644 --- a/src/lib/client/Client.cpp +++ b/src/lib/client/Client.cpp @@ -18,7 +18,6 @@ #include "client/Client.h" -#include "../plugin/ns/SecureSocket.h" #include "client/ServerProxy.h" #include "synergy/Screen.h" #include "synergy/FileChunk.h" @@ -33,12 +32,12 @@ #include "net/TCPSocket.h" #include "net/IDataSocket.h" #include "net/ISocketFactory.h" +#include "net/SecureSocket.h" #include "arch/Arch.h" #include "base/Log.h" #include "base/IEventQueue.h" #include "base/TMethodEventJob.h" #include "base/TMethodJob.h" -#include "common/PluginVersion.h" #include "common/stdexcept.h" #include @@ -72,7 +71,7 @@ Client::Client( m_sendFileThread(NULL), m_writeToDropDirThread(NULL), m_socket(NULL), - m_useSecureNetwork(false), + m_useSecureNetwork(args.m_enableCrypto), m_args(args), m_enableClipboard(true) { @@ -99,13 +98,6 @@ Client::Client( new TMethodEventJob(this, &Client::handleFileRecieveCompleted)); } - - if (m_args.m_enableCrypto) { - m_useSecureNetwork = ARCH->plugin().exists(s_pluginNames[kSecureSocket]); - if (m_useSecureNetwork == false) { - LOG((CLOG_NOTE "crypto disabled because of ns plugin not available")); - } - } } Client::~Client() @@ -160,8 +152,7 @@ Client::connect() // filter socket messages, including a packetizing filter m_stream = socket; - bool adopt = !m_useSecureNetwork; - m_stream = new PacketStreamFilter(m_events, m_stream, adopt); + m_stream = new PacketStreamFilter(m_events, m_stream, true); // connect LOG((CLOG_DEBUG1 "connecting to server")); @@ -439,7 +430,7 @@ Client::sendConnectionFailedEvent(const char* msg) void Client::sendFileChunk(const void* data) { - FileChunk* chunk = reinterpret_cast(const_cast(data)); + FileChunk* chunk = static_cast(const_cast(data)); LOG((CLOG_DEBUG1 "send file chunk")); assert(m_server != NULL); @@ -593,13 +584,6 @@ Client::cleanupStream() { delete m_stream; m_stream = NULL; - - // PacketStreamFilter doen't adopt secure socket, because - // we need to tell the dynamic lib that allocated this object - // to do the deletion. - if (m_useSecureNetwork) { - ARCH->plugin().invoke(s_pluginNames[kSecureSocket], "deleteSocket", NULL); - } } void @@ -621,7 +605,7 @@ void Client::handleConnectionFailed(const Event& event, void*) { IDataSocket::ConnectionFailedInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); cleanupTimer(); cleanupConnecting(); @@ -677,7 +661,7 @@ Client::handleClipboardGrabbed(const Event& event, void*) } const IScreen::ClipboardInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); // grab ownership m_server->onGrabClipboard(info->m_id); @@ -826,14 +810,14 @@ Client::sendFileToServer(const char* filename) m_sendFileThread = new Thread( new TMethodJob( this, &Client::sendFileThread, - reinterpret_cast(const_cast(filename)))); + static_cast(const_cast(filename)))); } void Client::sendFileThread(void* filename) { try { - char* name = reinterpret_cast(filename); + char* name = static_cast(filename); StreamChunker::sendFile(name, m_events, this); } catch (std::runtime_error error) { diff --git a/src/lib/common/PluginVersion.cpp b/src/lib/common/PluginVersion.cpp deleted file mode 100644 index 4ccacead..00000000 --- a/src/lib/common/PluginVersion.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2015-2016 Symless 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 LICENSE 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 . - */ - -#include "PluginVersion.h" - -#include - -static const char kUnknownVersion[] = "unknown"; -const char* s_pluginNames[] = { "ns" }; -static const char* s_pluginVersions[] = { "1.3" }; - -const char* getExpectedPluginVersion(const char* name) -{ - for (int i = 0; i < kPluginCount; i++) { - if (strcmp(name, s_pluginNames[i]) == 0) { - return s_pluginVersions[i]; - break; - } - } - - return kUnknownVersion; -} diff --git a/src/lib/common/PluginVersion.h b/src/lib/common/PluginVersion.h deleted file mode 100644 index b2f6bae2..00000000 --- a/src/lib/common/PluginVersion.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2015-2016 Symless 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 LICENSE 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 . - */ - -#pragma once - -enum EPluginType { - kSecureSocket, - kPluginCount -}; - -extern const char* s_pluginNames[]; - -//! Get expected plugin version -/*! -Returns the plugin version expected by the plugin loader. -*/ -const char* getExpectedPluginVersion(const char* name); diff --git a/src/lib/io/StreamBuffer.cpp b/src/lib/io/StreamBuffer.cpp index 050adae1..80903ada 100644 --- a/src/lib/io/StreamBuffer.cpp +++ b/src/lib/io/StreamBuffer.cpp @@ -59,7 +59,7 @@ StreamBuffer::peek(UInt32 n) scan = m_chunks.erase(scan); } - return reinterpret_cast(&(head->begin()[m_headUsed])); + return static_cast(&(head->begin()[m_headUsed])); } void @@ -104,7 +104,7 @@ StreamBuffer::write(const void* vdata, UInt32 n) m_size += n; // cast data to bytes - const UInt8* data = reinterpret_cast(vdata); + const UInt8* data = static_cast(vdata); // point to last chunk if it has space, otherwise append an empty chunk ChunkList::iterator scan = m_chunks.end(); diff --git a/src/lib/io/StreamFilter.cpp b/src/lib/io/StreamFilter.cpp index eb66b973..468aff84 100644 --- a/src/lib/io/StreamFilter.cpp +++ b/src/lib/io/StreamFilter.cpp @@ -83,7 +83,7 @@ StreamFilter::shutdownOutput() void* StreamFilter::getEventTarget() const { - return const_cast(reinterpret_cast(this)); + return const_cast(static_cast(this)); } bool diff --git a/src/lib/mt/Thread.cpp b/src/lib/mt/Thread.cpp index 0c67e8a9..752aace8 100644 --- a/src/lib/mt/Thread.cpp +++ b/src/lib/mt/Thread.cpp @@ -147,7 +147,7 @@ Thread::threadFunc(void* vjob) } // get job - IJob* job = reinterpret_cast(vjob); + IJob* job = static_cast(vjob); // run job void* result = NULL; diff --git a/src/lib/net/CMakeLists.txt b/src/lib/net/CMakeLists.txt index ee50fe36..10e2cae1 100644 --- a/src/lib/net/CMakeLists.txt +++ b/src/lib/net/CMakeLists.txt @@ -23,6 +23,7 @@ endif() include_directories( ../ + ${OPENSSL_INCLUDE} ) if (UNIX) @@ -33,6 +34,23 @@ endif() add_library(net STATIC ${sources}) -if (UNIX) - target_link_libraries(net mt io) +if (WIN32) + add_custom_command( + TARGET net + POST_BUILD + COMMAND xcopy /Y /Q + ..\\..\\..\\..\\ext\\${OPENSSL_PLAT_DIR}\\out32dll\\libeay32.* + ..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR} + ) + add_custom_command( + TARGET net + POST_BUILD + COMMAND xcopy /Y /Q + ..\\..\\..\\..\\ext\\${OPENSSL_PLAT_DIR}\\out32dll\\ssleay32.* + ..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR} + ) +endif() + +if (UNIX) + target_link_libraries(net mt io ${OPENSSL_LIBS}) endif() diff --git a/src/lib/plugin/ns/SecureListenSocket.cpp b/src/lib/net/SecureListenSocket.cpp similarity index 100% rename from src/lib/plugin/ns/SecureListenSocket.cpp rename to src/lib/net/SecureListenSocket.cpp diff --git a/src/lib/plugin/ns/SecureListenSocket.h b/src/lib/net/SecureListenSocket.h similarity index 100% rename from src/lib/plugin/ns/SecureListenSocket.h rename to src/lib/net/SecureListenSocket.h diff --git a/src/lib/plugin/ns/SecureSocket.cpp b/src/lib/net/SecureSocket.cpp similarity index 100% rename from src/lib/plugin/ns/SecureSocket.cpp rename to src/lib/net/SecureSocket.cpp diff --git a/src/lib/plugin/ns/SecureSocket.h b/src/lib/net/SecureSocket.h similarity index 100% rename from src/lib/plugin/ns/SecureSocket.h rename to src/lib/net/SecureSocket.h diff --git a/src/lib/net/SocketMultiplexer.cpp b/src/lib/net/SocketMultiplexer.cpp index 9ba352a6..bab76b20 100644 --- a/src/lib/net/SocketMultiplexer.cpp +++ b/src/lib/net/SocketMultiplexer.cpp @@ -46,6 +46,7 @@ SocketMultiplexer::SocketMultiplexer() : // this pointer just has to be unique and not NULL. it will // never be dereferenced. it's used to identify cursor nodes // in the jobs list. + // TODO: Remove this evilness m_cursorMark = reinterpret_cast(this); // start thread diff --git a/src/lib/net/TCPListenSocket.cpp b/src/lib/net/TCPListenSocket.cpp index 94760d53..2b20c124 100644 --- a/src/lib/net/TCPListenSocket.cpp +++ b/src/lib/net/TCPListenSocket.cpp @@ -102,7 +102,7 @@ TCPListenSocket::close() void* TCPListenSocket::getEventTarget() const { - return const_cast(reinterpret_cast(this)); + return const_cast(static_cast(this)); } IDataSocket* diff --git a/src/lib/net/TCPSocket.cpp b/src/lib/net/TCPSocket.cpp index ce2cdd09..680e49e5 100644 --- a/src/lib/net/TCPSocket.cpp +++ b/src/lib/net/TCPSocket.cpp @@ -125,7 +125,7 @@ TCPSocket::close() void* TCPSocket::getEventTarget() const { - return const_cast(reinterpret_cast(this)); + return const_cast(static_cast(this)); } UInt32 diff --git a/src/lib/net/TCPSocketFactory.cpp b/src/lib/net/TCPSocketFactory.cpp index 9f8dc029..e205a9fa 100644 --- a/src/lib/net/TCPSocketFactory.cpp +++ b/src/lib/net/TCPSocketFactory.cpp @@ -17,11 +17,11 @@ */ #include "net/TCPSocketFactory.h" - #include "net/TCPSocket.h" #include "net/TCPListenSocket.h" +#include "net/SecureSocket.h" +#include "net/SecureListenSocket.h" #include "arch/Arch.h" -#include "common/PluginVersion.h" #include "base/Log.h" // @@ -43,20 +43,14 @@ TCPSocketFactory::~TCPSocketFactory() IDataSocket* TCPSocketFactory::create(bool secure) const { - IDataSocket* socket = NULL; if (secure) { - void* args[2] = { - m_events, - m_socketMultiplexer - }; - socket = static_cast( - ARCH->plugin().invoke(s_pluginNames[kSecureSocket], "getSocket", args)); + SecureSocket* secureSocket = new SecureSocket(m_events, m_socketMultiplexer); + secureSocket->initSsl (false); + return secureSocket; } else { - socket = new TCPSocket(m_events, m_socketMultiplexer); + return new TCPSocket(m_events, m_socketMultiplexer); } - - return socket; } IListenSocket* @@ -64,12 +58,7 @@ TCPSocketFactory::createListen(bool secure) const { IListenSocket* socket = NULL; if (secure) { - void* args[2] = { - m_events, - m_socketMultiplexer - }; - socket = static_cast( - ARCH->plugin().invoke(s_pluginNames[kSecureSocket], "getListenSocket", args)); + socket = new SecureListenSocket(m_events, m_socketMultiplexer); } else { socket = new TCPListenSocket(m_events, m_socketMultiplexer); diff --git a/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp b/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp index c78bd3c4..d1676bb0 100644 --- a/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp +++ b/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp @@ -71,21 +71,21 @@ String MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const { // get datator - const char* src = (const char*)GlobalLock(data); + LPVOID src = GlobalLock(data); if (src == NULL) { return String(); } UInt32 srcSize = (UInt32)GlobalSize(data); // check image type - const BITMAPINFO* bitmap = reinterpret_cast(src); + const BITMAPINFO* bitmap = static_cast(src); LOG((CLOG_INFO "bitmap: %dx%d %d", bitmap->bmiHeader.biWidth, bitmap->bmiHeader.biHeight, (int)bitmap->bmiHeader.biBitCount)); if (bitmap->bmiHeader.biPlanes == 1 && (bitmap->bmiHeader.biBitCount == 24 || bitmap->bmiHeader.biBitCount == 32) && bitmap->bmiHeader.biCompression == BI_RGB) { // already in canonical form - String image(src, srcSize); + String image(static_cast(src), srcSize); GlobalUnlock(data); return image; } diff --git a/src/lib/platform/MSWindowsDesks.cpp b/src/lib/platform/MSWindowsDesks.cpp index cb1ed9e9..a5cf4e62 100644 --- a/src/lib/platform/MSWindowsDesks.cpp +++ b/src/lib/platform/MSWindowsDesks.cpp @@ -656,7 +656,7 @@ MSWindowsDesks::deskThread(void* vdesk) MSG msg; // use given desktop for this thread - Desk* desk = reinterpret_cast(vdesk); + Desk* desk = static_cast(vdesk); desk->m_threadID = GetCurrentThreadId(); desk->m_window = NULL; desk->m_foregroundWindow = NULL; diff --git a/src/lib/platform/MSWindowsScreen.cpp b/src/lib/platform/MSWindowsScreen.cpp index de0c7c26..74abfcd7 100644 --- a/src/lib/platform/MSWindowsScreen.cpp +++ b/src/lib/platform/MSWindowsScreen.cpp @@ -105,6 +105,7 @@ MSWindowsScreen::MSWindowsScreen( m_xCenter(0), m_yCenter(0), m_multimon(false), m_xCursor(0), m_yCursor(0), + m_xFractionalMove(0.0f), m_yFractionalMove(0.0f), m_sequenceNumber(0), m_mark(0), m_markReceived(0), @@ -575,6 +576,21 @@ void MSWindowsScreen::saveMousePosition(SInt32 x, SInt32 y) { LOG((CLOG_DEBUG5 "saved mouse position for next delta: %+d,%+d", x,y)); } +void MSWindowsScreen::accumulateFractionalMove(float x, float y, SInt32& intX, SInt32& intY) +{ + // Accumulate together the move into the running total + m_xFractionalMove += x; + m_yFractionalMove += y; + + // Return the integer part + intX = (SInt32)m_xFractionalMove; + intY = (SInt32)m_yFractionalMove; + + // And keep only the fractional part + m_xFractionalMove -= intX; + m_yFractionalMove -= intY; +} + UInt32 MSWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask) { @@ -941,7 +957,7 @@ MSWindowsScreen::sendClipboardEvent(Event::Type type, ClipboardID id) void MSWindowsScreen::handleSystemEvent(const Event& event, void*) { - MSG* msg = reinterpret_cast(event.getData()); + MSG* msg = static_cast(event.getData()); assert(msg != NULL); if (ArchMiscWindows::processDialog(msg)) { @@ -1355,16 +1371,18 @@ MSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my) { SInt32 originalMX = mx; SInt32 originalMY = my; + float scaledMX = (float)mx; + float scaledMY = (float)my; if (DpiHelper::s_dpiScaled) { - mx = (SInt32)(mx / DpiHelper::getDpi()); - my = (SInt32)(my / DpiHelper::getDpi()); + scaledMX /= DpiHelper::getDpi(); + scaledMY /= DpiHelper::getDpi(); } // compute motion delta (relative to the last known // mouse position) - SInt32 x = mx - m_xCursor; - SInt32 y = my - m_yCursor; + float x = scaledMX - m_xCursor; + float y = scaledMY - m_yCursor; LOG((CLOG_DEBUG3 "mouse move - motion delta: %+d=(%+d - %+d),%+d=(%+d - %+d)", @@ -1377,7 +1395,7 @@ MSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my) } // save position to compute delta of next motion - saveMousePosition(mx, my); + saveMousePosition((SInt32)scaledMX, (SInt32)scaledMY); if (m_isOnScreen) { @@ -1415,7 +1433,9 @@ MSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my) } else { // send motion - sendEvent(m_events->forIPrimaryScreen().motionOnSecondary(), MotionInfo::alloc(x, y)); + SInt32 ix, iy; + accumulateFractionalMove(x, y, ix, iy); + sendEvent(m_events->forIPrimaryScreen().motionOnSecondary(), MotionInfo::alloc(ix, iy)); } } diff --git a/src/lib/platform/MSWindowsScreen.h b/src/lib/platform/MSWindowsScreen.h index 7e734f85..4d947be7 100644 --- a/src/lib/platform/MSWindowsScreen.h +++ b/src/lib/platform/MSWindowsScreen.h @@ -215,7 +215,11 @@ private: // HACK // save last position of mouse to compute next delta movement void saveMousePosition(SInt32 x, SInt32 y); - + + // accumulates together a series of fractional pixel moves, each time + // taking away and returning just the integer part of the running total. + void accumulateFractionalMove(float x, float y, SInt32& intX, SInt32& intY); + // check if it is a modifier key repeating message bool isModifierRepeat(KeyModifierMask oldState, KeyModifierMask state, WPARAM wParam) const; @@ -266,6 +270,9 @@ private: // last mouse position SInt32 m_xCursor, m_yCursor; + // accumulated fractional pixel moves + float m_xFractionalMove, m_yFractionalMove; + // last clipboard UInt32 m_sequenceNumber; diff --git a/src/lib/platform/OSXScreen.cpp b/src/lib/platform/OSXScreen.cpp index aae74123..b7f9a246 100644 --- a/src/lib/platform/OSXScreen.cpp +++ b/src/lib/platform/OSXScreen.cpp @@ -975,7 +975,7 @@ OSXScreen::sendClipboardEvent(Event::Type type, ClipboardID id) const void OSXScreen::handleSystemEvent(const Event& event, void*) { - EventRef* carbonEvent = reinterpret_cast(event.getData()); + EventRef* carbonEvent = static_cast(event.getData()); assert(carbonEvent != NULL); UInt32 eventClass = GetEventClass(*carbonEvent); diff --git a/src/lib/platform/OSXUchrKeyResource.cpp b/src/lib/platform/OSXUchrKeyResource.cpp index 7c362d70..603ba04a 100644 --- a/src/lib/platform/OSXUchrKeyResource.cpp +++ b/src/lib/platform/OSXUchrKeyResource.cpp @@ -31,7 +31,7 @@ OSXUchrKeyResource::OSXUchrKeyResource(const void* resource, m_sri(NULL), m_st(NULL) { - m_resource = reinterpret_cast(resource); + m_resource = static_cast(resource); if (m_resource == NULL) { return; } @@ -56,7 +56,7 @@ OSXUchrKeyResource::OSXUchrKeyResource(const void* resource, } // get tables for keyboard type - const UInt8* base = reinterpret_cast(m_resource); + const UInt8* const base = reinterpret_cast(m_resource); m_m = reinterpret_cast(base + th->keyModifiersToTableNumOffset); m_cti = reinterpret_cast(base + @@ -134,7 +134,7 @@ OSXUchrKeyResource::getKey(UInt32 table, UInt32 button) const assert(table < getNumTables()); assert(button < getNumButtons()); - const UInt8* base = reinterpret_cast(m_resource); + const UInt8* const base = reinterpret_cast(m_resource); const UCKeyOutput* cPtr = reinterpret_cast(base + m_cti->keyToCharTableOffsets[table]); @@ -211,7 +211,7 @@ bool OSXUchrKeyResource::getKeyRecord( KeySequence& keys, UInt16 index, UInt16& state) const { - const UInt8* base = reinterpret_cast(m_resource); + const UInt8* const base = reinterpret_cast(m_resource); const UCKeyStateRecord* sr = reinterpret_cast(base + m_sri->keyStateRecordOffsets[index]); diff --git a/src/lib/platform/XWindowsClipboard.cpp b/src/lib/platform/XWindowsClipboard.cpp index 6aa3a4cb..f30cc2c9 100644 --- a/src/lib/platform/XWindowsClipboard.cpp +++ b/src/lib/platform/XWindowsClipboard.cpp @@ -31,6 +31,7 @@ #include "common/stdvector.h" #include +#include #include // @@ -516,7 +517,7 @@ XWindowsClipboard::icccmFillCache() } XWindowsUtil::convertAtomProperty(data); - const Atom* targets = reinterpret_cast(data.data()); + const Atom* targets = reinterpret_cast(data.data()); // TODO: Safe? const UInt32 numTargets = data.size() / sizeof(Atom); LOG((CLOG_DEBUG " available targets: %s", XWindowsUtil::atomsToString(m_display, targets, numTargets).c_str())); @@ -671,11 +672,11 @@ XWindowsClipboard::motifOwnsClipboard() const } // check the owner window against the current clipboard owner - const MotifClipHeader* header = - reinterpret_cast(data.data()); - if (data.size() >= sizeof(MotifClipHeader) && - header->m_id == kMotifClipHeader) { - if (static_cast(header->m_selectionOwner) == owner) { + if (data.size() >= sizeof(MotifClipHeader)) { + MotifClipHeader header; + std::memcpy (&header, data.data(), sizeof(header)); + if ((header.m_id == kMotifClipHeader) && + (static_cast(header.m_selectionOwner) == owner)) { return true; } } @@ -699,18 +700,18 @@ XWindowsClipboard::motifFillCache() return; } - // check that the header is okay - const MotifClipHeader* header = - reinterpret_cast(data.data()); - if (data.size() < sizeof(MotifClipHeader) || - header->m_id != kMotifClipHeader || - header->m_numItems < 1) { + MotifClipHeader header; + if (data.size() < sizeof(header)) { // check that the header is okay + return; + } + std::memcpy (&header, data.data(), sizeof(header)); + if (header.m_id != kMotifClipHeader || header.m_numItems < 1) { return; } // get the Motif item property from the root window char name[18 + 20]; - sprintf(name, "_MOTIF_CLIP_ITEM_%d", header->m_item); + sprintf(name, "_MOTIF_CLIP_ITEM_%d", header.m_item); Atom atomItem = XInternAtom(m_display, name, False); data = ""; if (!XWindowsUtil::getWindowProperty(m_display, root, @@ -719,19 +720,20 @@ XWindowsClipboard::motifFillCache() return; } - // check that the item is okay - const MotifClipItem* item = - reinterpret_cast(data.data()); - if (data.size() < sizeof(MotifClipItem) || - item->m_id != kMotifClipItem || - item->m_numFormats - item->m_numDeletedFormats < 1) { + MotifClipItem item; + if (data.size() < sizeof(item)) { // check that the item is okay + return; + } + std::memcpy (&item, data.data(), sizeof(item)); + if (item.m_id != kMotifClipItem || + item.m_numFormats - item.m_numDeletedFormats < 1) { return; } // format list is after static item structure elements - const SInt32 numFormats = item->m_numFormats - item->m_numDeletedFormats; - const SInt32* formats = reinterpret_cast(item->m_size + - reinterpret_cast(data.data())); + const SInt32 numFormats = item.m_numFormats - item.m_numDeletedFormats; + const SInt32* formats = reinterpret_cast(item.m_size + + static_cast(data.data())); // get the available formats typedef std::map MotifFormatMap; @@ -748,18 +750,20 @@ XWindowsClipboard::motifFillCache() } // check that the format is okay - const MotifClipFormat* motifFormat = - reinterpret_cast(data.data()); - if (data.size() < sizeof(MotifClipFormat) || - motifFormat->m_id != kMotifClipFormat || - motifFormat->m_length < 0 || - motifFormat->m_type == None || - motifFormat->m_deleted != 0) { + MotifClipFormat motifFormat; + if (data.size() < sizeof(motifFormat)) { + continue; + } + std::memcpy (&motifFormat, data.data(), sizeof(motifFormat)); + if (motifFormat.m_id != kMotifClipFormat || + motifFormat.m_length < 0 || + motifFormat.m_type == None || + motifFormat.m_deleted != 0) { continue; } // save it - motifFormats.insert(std::make_pair(motifFormat->m_type, data)); + motifFormats.insert(std::make_pair(motifFormat.m_type, data)); } //const UInt32 numMotifFormats = motifFormats.size(); @@ -782,15 +786,14 @@ XWindowsClipboard::motifFillCache() } // get format - const MotifClipFormat* motifFormat = - reinterpret_cast( - index2->second.data()); - const Atom target = motifFormat->m_type; + MotifClipFormat motifFormat; + std::memcpy (&motifFormat, index2->second.data(), sizeof(motifFormat)); + const Atom target = motifFormat.m_type; // get the data (finally) Atom actualTarget; String targetData; - if (!motifGetSelection(motifFormat, &actualTarget, &targetData)) { + if (!motifGetSelection(&motifFormat, &actualTarget, &targetData)) { LOG((CLOG_DEBUG1 " no data for target %s", XWindowsUtil::atomToString(m_display, target).c_str())); continue; } diff --git a/src/lib/platform/XWindowsKeyState.cpp b/src/lib/platform/XWindowsKeyState.cpp index 6f82d4df..f97ef531 100644 --- a/src/lib/platform/XWindowsKeyState.cpp +++ b/src/lib/platform/XWindowsKeyState.cpp @@ -785,7 +785,7 @@ void XWindowsKeyState::remapKeyModifiers(KeyID id, SInt32 group, synergy::KeyMap::KeyItem& item, void* vself) { - XWindowsKeyState* self = reinterpret_cast(vself); + XWindowsKeyState* self = static_cast(vself); item.m_required = self->mapModifiersFromX(XkbBuildCoreState(item.m_required, group)); item.m_sensitive = diff --git a/src/lib/platform/XWindowsScreen.cpp b/src/lib/platform/XWindowsScreen.cpp index b16e2e51..c7032470 100644 --- a/src/lib/platform/XWindowsScreen.cpp +++ b/src/lib/platform/XWindowsScreen.cpp @@ -1179,7 +1179,7 @@ XWindowsScreen::findKeyEvent(Display*, XEvent* xevent, XPointer arg) void XWindowsScreen::handleSystemEvent(const Event& event, void*) { - XEvent* xevent = reinterpret_cast(event.getData()); + XEvent* xevent = static_cast(event.getData()); assert(xevent != NULL); // update key state @@ -1442,6 +1442,8 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*) XMoveWindow(m_display, m_window, m_x, m_y); XResizeWindow(m_display, m_window, m_w, m_h); } + + sendEvent(m_events->forIScreen().shapeChanged()); } } #endif diff --git a/src/lib/platform/XWindowsUtil.cpp b/src/lib/platform/XWindowsUtil.cpp index 6103cced..10b35096 100644 --- a/src/lib/platform/XWindowsUtil.cpp +++ b/src/lib/platform/XWindowsUtil.cpp @@ -1386,7 +1386,7 @@ XWindowsUtil::setWindowProperty(Display* display, Window window, Atom type, SInt32 format) { const UInt32 length = 4 * XMaxRequestSize(display); - const unsigned char* data = reinterpret_cast(vdata); + const unsigned char* data = static_cast(vdata); UInt32 datumSize = static_cast(format / 8); // format 32 on 64bit systems is 8 bytes not 4. if (format == 32) { @@ -1784,5 +1784,5 @@ void XWindowsUtil::ErrorLock::saveHandler(Display*, XErrorEvent* e, void* flag) { LOG((CLOG_DEBUG1 "flagging X error: %d", e->error_code)); - *reinterpret_cast(flag) = true; + *static_cast(flag) = true; } diff --git a/src/lib/plugin/CMakeLists.txt b/src/lib/plugin/CMakeLists.txt deleted file mode 100644 index 237da989..00000000 --- a/src/lib/plugin/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# synergy -- mouse and keyboard sharing utility -# Copyright (C) 2012-2016 Symless Ltd. -# Copyright (C) 2012 Nick Bolton -# -# 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 LICENSE 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 . - -if (WIN32) - add_subdirectory(winmmjoy) -endif() - -if (APPLE) - # 10.7 should be supported, but gives is a _NXArgv linker error - if (OSX_TARGET_MINOR GREATER 7) - add_subdirectory(ns) - endif() -else() - add_subdirectory(ns) -endif() diff --git a/src/lib/plugin/ns/CMakeLists.txt b/src/lib/plugin/ns/CMakeLists.txt deleted file mode 100644 index 80b56741..00000000 --- a/src/lib/plugin/ns/CMakeLists.txt +++ /dev/null @@ -1,128 +0,0 @@ -# synergy -- mouse and keyboard sharing utility -# Copyright (C) 2015-2016 Symless 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 LICENSE 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 . - -file(GLOB headers "*.h") -file(GLOB sources "*.cpp") - -if (SYNERGY_ADD_HEADERS) - list(APPEND sources ${headers}) -endif() - -if (WIN32) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(OPENSSL_PLAT_DIR openssl-win64) - else() - set(OPENSSL_PLAT_DIR openssl-win32) - endif() - set(OPENSSL_INCLUDE ../../../../ext/${OPENSSL_PLAT_DIR}/inc32) -endif() - -if (APPLE) - set(OPENSSL_PLAT_DIR openssl-osx) - set(OPENSSL_INCLUDE ../../../../ext/${OPENSSL_PLAT_DIR}/include) -endif() - -include_directories( - ../../../lib/ - ../../../.. - ${OPENSSL_INCLUDE} -) - -add_library(ns SHARED ${sources}) - -if (WIN32) - set(OPENSSL_LIBS - ${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/out32dll/libeay32.lib - ${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/out32dll/ssleay32.lib - ) -endif() - -if (UNIX) - if (APPLE) - set(OPENSSL_LIBS - ${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/libssl.a - ${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/libcrypto.a - ) - else() - set(OPENSSL_LIBS ssl crypto) - endif() -endif() - -target_link_libraries(ns - arch base client common io mt net ipc platform server synergy ${libs} ${OPENSSL_LIBS}) - -if (WIN32) - add_custom_command( - TARGET ns - POST_BUILD - COMMAND xcopy /Y /Q - ..\\..\\..\\..\\..\\lib\\${CMAKE_CFG_INTDIR}\\ns.* - ..\\..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR}\\plugins\\ - ) - add_custom_command( - TARGET ns - POST_BUILD - COMMAND xcopy /Y /Q - ..\\..\\..\\..\\..\\ext\\${OPENSSL_PLAT_DIR}\\out32dll\\libeay32.* - ..\\..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR} - ) - add_custom_command( - TARGET ns - POST_BUILD - COMMAND xcopy /Y /Q - ..\\..\\..\\..\\..\\ext\\${OPENSSL_PLAT_DIR}\\out32dll\\ssleay32.* - ..\\..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR} - ) -endif() - -if (UNIX) - if (APPLE) - add_custom_command( - TARGET ns - POST_BUILD - COMMAND - mkdir -p - ${CMAKE_SOURCE_DIR}/bin/${CMAKE_CFG_INTDIR}/plugins - && - cp - ${CMAKE_SOURCE_DIR}/lib/${CMAKE_CFG_INTDIR}/libns.* - ${CMAKE_SOURCE_DIR}/bin/${CMAKE_CFG_INTDIR}/plugins/ - ) - else() - if (CMAKE_BUILD_TYPE STREQUAL Debug) - add_custom_command( - TARGET ns - POST_BUILD - COMMAND mkdir -p - ${CMAKE_SOURCE_DIR}/bin/debug/plugins - && - cp - ${CMAKE_SOURCE_DIR}/lib/debug/libns.* - ${CMAKE_SOURCE_DIR}/bin/debug/plugins/ - ) - else() - add_custom_command( - TARGET ns - POST_BUILD - COMMAND mkdir -p - ${CMAKE_SOURCE_DIR}/bin/plugins - && - cp - ${CMAKE_SOURCE_DIR}/lib/libns.* - ${CMAKE_SOURCE_DIR}/bin/plugins/ - ) - endif() - endif() -endif() diff --git a/src/lib/plugin/ns/ns.cpp b/src/lib/plugin/ns/ns.cpp deleted file mode 100644 index 17ba322f..00000000 --- a/src/lib/plugin/ns/ns.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2015-2016 Symless 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 LICENSE 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 . - */ - -#include "ns.h" - -#include "SecureSocket.h" -#include "SecureListenSocket.h" -#include "arch/Arch.h" -#include "common/PluginVersion.h" -#include "base/Log.h" - -#include -#include -#include -#include - -SecureSocket* g_secureSocket = NULL; -SecureListenSocket* g_secureListenSocket = NULL; -Arch* g_arch = NULL; -Log* g_log = NULL; - -std::string -helperGetLibsUsed(void) -{ - std::stringstream libs(ARCH->getLibsUsed()); - std::string msg; - std::string pid; - std::getline(libs,pid); - - while( std::getline(libs,msg) ) { - LOG(( CLOG_DEBUG "libs:%s",msg.c_str())); - } - return pid; -} - -extern "C" { -void -init(void* log, void* arch) -{ - if (g_log == NULL) { - g_log = new Log(reinterpret_cast(log)); - } - - if (g_arch == NULL) { - Arch::setInstance(reinterpret_cast(arch)); - } - - LOG(( CLOG_DEBUG "library use: %s", helperGetLibsUsed().c_str())); -} - -int -initEvent(void (*sendEvent)(const char*, void*)) -{ - return 0; -} - -void* -invoke(const char* command, void** args) -{ - IEventQueue* arg1 = NULL; - SocketMultiplexer* arg2 = NULL; - if (args != NULL) { - arg1 = reinterpret_cast(args[0]); - arg2 = reinterpret_cast(args[1]); - } - - if (strcmp(command, "getSocket") == 0) { - if (g_secureSocket != NULL) { - delete g_secureSocket; - } - g_secureSocket = new SecureSocket(arg1, arg2); - g_secureSocket->initSsl(false); - return g_secureSocket; - } - else if (strcmp(command, "getListenSocket") == 0) { - if (g_secureListenSocket != NULL) { - delete g_secureListenSocket; - } - g_secureListenSocket = new SecureListenSocket(arg1, arg2); - return g_secureListenSocket; - } - else if (strcmp(command, "deleteSocket") == 0) { - if (g_secureSocket != NULL) { - delete g_secureSocket; - g_secureSocket = NULL; - } - } - else if (strcmp(command, "deleteListenSocket") == 0) { - if (g_secureListenSocket != NULL) { - delete g_secureListenSocket; - g_secureListenSocket = NULL; - } - } - else if (strcmp(command, "version") == 0) { - return (void*)getExpectedPluginVersion(s_pluginNames[kSecureSocket]); - } - - return NULL; -} - -void -cleanup() -{ - if (g_secureSocket != NULL) { - delete g_secureSocket; - } - - if (g_secureListenSocket != NULL) { - delete g_secureListenSocket; - } -} - -} diff --git a/src/lib/plugin/ns/ns.h b/src/lib/plugin/ns/ns.h deleted file mode 100644 index 39999110..00000000 --- a/src/lib/plugin/ns/ns.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2015-2016 Symless 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 LICENSE 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 . - */ - -#pragma once - -#if defined _WIN32 -#define WIN32_LEAN_AND_MEAN -#include - -#if defined(ns_EXPORTS) -#define NS_API __declspec(dllexport) -#else -#define NS_API __declspec(dllimport) -#endif - -#else -#define NS_API -#endif - -extern "C" { - -NS_API void init(void* log, void* arch); -NS_API int initEvent(void (*sendEvent)(const char*, void*)); -NS_API void* invoke(const char* command, void** args); -NS_API void cleanup(); - -} diff --git a/src/lib/plugin/winmmjoy/CMakeLists.txt b/src/lib/plugin/winmmjoy/CMakeLists.txt deleted file mode 100644 index b07915bf..00000000 --- a/src/lib/plugin/winmmjoy/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# synergy -- mouse and keyboard sharing utility -# Copyright (C) 2012-2016 Symless Ltd. -# Copyright (C) 2012 Nick Bolton -# -# 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 LICENSE 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 . - -file(GLOB headers "*.h") -file(GLOB sources "*.cpp") - -if (SYNERGY_ADD_HEADERS) - list(APPEND sources ${headers}) -endif() - -add_library(winmmjoy SHARED ${sources}) - -add_custom_command( - TARGET winmmjoy - POST_BUILD - COMMAND xcopy /Y /Q - ..\\..\\..\\..\\..\\lib\\${CMAKE_CFG_INTDIR}\\winmmjoy.* - ..\\..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR}\\plugins\\ -) diff --git a/src/lib/plugin/winmmjoy/winmmjoy.cpp b/src/lib/plugin/winmmjoy/winmmjoy.cpp deleted file mode 100644 index d6306e82..00000000 --- a/src/lib/plugin/winmmjoy/winmmjoy.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2012-2016 Symless Ltd. - * Copyright (C) 2012 Nick Bolton - * - * 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 LICENSE 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 . - */ - -#include "winmmjoy.h" - -#include -#include -#include - -#pragma comment(lib, "winmm.lib") - -std::stringstream _logStream; -#define LOG(s) \ - _logStream.str(""); \ - _logStream << "winmmjoy: " << s << std::endl; \ - s_log(_logStream.str().c_str()) - -static bool s_running = true; -static void (*s_sendEvent)(const char*, void*) = NULL; -static void (*s_log)(const char*) = NULL; - -extern "C" { - -void -init(void* log, void* arch) -{ -} - -int -initEvent(void (*sendEvent)(const char*, void*)) -{ - s_sendEvent = sendEvent; - CreateThread(NULL, 0, mainLoop, NULL, 0, NULL); - return 0; -} - -void -cleanup() -{ - s_running = false; -} - -} - -DWORD WINAPI -mainLoop(void* data) -{ - // TODO: use a different message - e.g. DPLG%s (data - plugin) - const char* buttonsEvent = "IPrimaryScreen::getGameDeviceButtonsEvent"; - const char* sticksEvent = "IPrimaryScreen::getGameDeviceSticksEvent"; - const char* triggersEvent = "IPrimaryScreen::getGameDeviceTriggersEvent"; - - JOYINFOEX joyInfo; - ZeroMemory(&joyInfo, sizeof(joyInfo)); - joyInfo.dwSize = sizeof(joyInfo); - joyInfo.dwFlags = JOY_RETURNALL; - - // note: synergy data is often 16-bit, where winmm is 32-bit. - UINT index = JOYSTICKID1; - DWORD buttons, buttonsLast = 0; - DWORD xPos, xPosLast = 0; - DWORD yPos, yPosLast = 0; - - while (s_running) { - - if (joyGetPosEx(index, &joyInfo) != JOYERR_NOERROR) { - Sleep(1000); - continue; - } - - buttons = joyInfo.dwButtons; - xPos = joyInfo.dwXpos; - yPos = joyInfo.dwYpos; - - if (buttons != buttonsLast) { - s_sendEvent(buttonsEvent, - new CGameDeviceButtonInfo(index, (GameDeviceButton)joyInfo.dwButtons)); - } - - if (xPos != xPosLast || yPos != yPosLast) { - s_sendEvent(sticksEvent, - new CGameDeviceStickInfo(index, (short)xPos, (short)yPos, 0, 0)); - } - - buttonsLast = buttons; - xPosLast = xPos; - yPosLast = yPos; - Sleep(1); - } - return 0; -} diff --git a/src/lib/plugin/winmmjoy/winmmjoy.h b/src/lib/plugin/winmmjoy/winmmjoy.h deleted file mode 100644 index 712bd6d9..00000000 --- a/src/lib/plugin/winmmjoy/winmmjoy.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2012-2016 Symless Ltd. - * Copyright (C) 2012 Nick Bolton - * - * 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 LICENSE 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 . - */ - -#pragma once - -#define WIN32_LEAN_AND_MEAN -#include - -#if defined(winmmjoy_EXPORTS) -#define WINMMJOY_API __declspec(dllexport) -#else -#define WINMMJOY_API __declspec(dllimport) -#endif - -extern "C" { - -WINMMJOY_API void init(void* log, void* arch); -WINMMJOY_API int initEvent(void (*sendEvent)(const char*, void*)); -WINMMJOY_API void cleanup(); - -} - -DWORD WINAPI mainLoop(void* data); - -typedef unsigned char GameDeviceID; -typedef unsigned short GameDeviceButton; - -class CGameDeviceButtonInfo { -public: - CGameDeviceButtonInfo(GameDeviceID id, GameDeviceButton buttons) : - m_id(id), m_buttons(buttons) { } -public: - GameDeviceID m_id; - GameDeviceButton m_buttons; -}; - -class CGameDeviceStickInfo { -public: - CGameDeviceStickInfo(GameDeviceID id, short x1, short y1, short x2, short y2) : - m_id(id), m_x1(x1), m_x2(x2), m_y1(y1), m_y2(y2) { } -public: - GameDeviceID m_id; - short m_x1; - short m_x2; - short m_y1; - short m_y2; -}; - -class CGameDeviceTriggerInfo { -public: - CGameDeviceTriggerInfo(GameDeviceID id, unsigned char t1, unsigned char t2) : - m_id(id), m_t1(t1), m_t2(t2) { } -public: - GameDeviceID m_id; - unsigned char m_t1; - unsigned char m_t2; -}; diff --git a/src/lib/server/ClientListener.cpp b/src/lib/server/ClientListener.cpp index cf64bc30..619ba2a0 100644 --- a/src/lib/server/ClientListener.cpp +++ b/src/lib/server/ClientListener.cpp @@ -25,7 +25,6 @@ #include "net/IListenSocket.h" #include "net/ISocketFactory.h" #include "net/XSocket.h" -#include "common/PluginVersion.h" #include "base/Log.h" #include "base/IEventQueue.h" #include "base/TMethodEventJob.h" @@ -41,19 +40,11 @@ ClientListener::ClientListener(const NetworkAddress& address, m_socketFactory(socketFactory), m_server(NULL), m_events(events), - m_useSecureNetwork(false) + m_useSecureNetwork(enableCrypto) { assert(m_socketFactory != NULL); try { - // create listen socket - if (enableCrypto) { - m_useSecureNetwork = ARCH->plugin().exists(s_pluginNames[kSecureSocket]); - if (m_useSecureNetwork == false) { - LOG((CLOG_NOTE "crypto disabled because of ns plugin not available")); - } - } - m_listen = m_socketFactory->createListen(m_useSecureNetwork); // setup event handler @@ -164,8 +155,7 @@ ClientListener::handleClientAccepted(const Event&, void* vsocket) IDataSocket* socket = static_cast(vsocket); // filter socket messages, including a packetizing filter - bool adopt = !m_useSecureNetwork; - synergy::IStream* stream = new PacketStreamFilter(m_events, socket, adopt); + synergy::IStream* stream = new PacketStreamFilter(m_events, socket, true); assert(m_server != NULL); // create proxy for unknown client @@ -188,7 +178,7 @@ void ClientListener::handleUnknownClient(const Event&, void* vclient) { ClientProxyUnknown* unknownClient = - reinterpret_cast(vclient); + static_cast(vclient); // we should have the client in our new client list assert(m_newClients.count(unknownClient) == 1); @@ -232,7 +222,7 @@ ClientListener::handleUnknownClient(const Event&, void* vclient) void ClientListener::handleClientDisconnected(const Event&, void* vclient) { - ClientProxy* client = reinterpret_cast(vclient); + ClientProxy* client = static_cast(vclient); // find client in waiting clients queue for (WaitingClients::iterator i = m_waitingClients.begin(), @@ -250,13 +240,5 @@ ClientListener::handleClientDisconnected(const Event&, void* vclient) void ClientListener::cleanupListenSocket() { - if (!m_useSecureNetwork) { - delete m_listen; - } - else { - ARCH->plugin().invoke( - s_pluginNames[kSecureSocket], - "deleteListenSocket", - NULL); - } + delete m_listen; } diff --git a/src/lib/server/InputFilter.cpp b/src/lib/server/InputFilter.cpp index f03786a7..0ab2fcaa 100644 --- a/src/lib/server/InputFilter.cpp +++ b/src/lib/server/InputFilter.cpp @@ -121,7 +121,7 @@ InputFilter::KeystrokeCondition::match(const Event& event) // check if it's our hotkey IPrimaryScreen::HotKeyInfo* kinfo = - reinterpret_cast(event.getData()); + static_cast(event.getData()); if (kinfo->m_id != m_id) { return kNoMatch; } @@ -217,7 +217,7 @@ InputFilter::MouseButtonCondition::match(const Event& event) // check if it's the right button and modifiers. ignore modifiers // that cannot be combined with a mouse button. IPlatformScreen::ButtonInfo* minfo = - reinterpret_cast(event.getData()); + static_cast(event.getData()); if (minfo->m_button != m_button || (minfo->m_mask & ~s_ignoreMask) != m_mask) { return kNoMatch; @@ -256,7 +256,7 @@ InputFilter::ScreenConnectedCondition::match(const Event& event) { if (event.getType() == m_events->forServer().connected()) { Server::ScreenConnectedInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); if (m_screen == info->m_screen || m_screen.empty()) { return kActivate; } @@ -357,7 +357,7 @@ InputFilter::SwitchToScreenAction::perform(const Event& event) String screen = m_screen; if (screen.empty() && event.getType() == m_events->forServer().connected()) { Server::ScreenConnectedInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); screen = info->m_screen; } diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index b0ff56fc..d9394ed5 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -1187,7 +1187,7 @@ void Server::handleShapeChanged(const Event&, void* vclient) { // ignore events from unknown clients - BaseClientProxy* client = reinterpret_cast(vclient); + BaseClientProxy* client = static_cast(vclient); if (m_clientSet.count(client) == 0) { return; } @@ -1224,12 +1224,12 @@ Server::handleClipboardGrabbed(const Event& event, void* vclient) } // ignore events from unknown clients - BaseClientProxy* grabber = reinterpret_cast(vclient); + BaseClientProxy* grabber = static_cast(vclient); if (m_clientSet.count(grabber) == 0) { return; } const IScreen::ClipboardInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); // ignore grab if sequence number is old. always allow primary // screen to grab. @@ -1270,12 +1270,12 @@ void Server::handleClipboardChanged(const Event& event, void* vclient) { // ignore events from unknown clients - BaseClientProxy* sender = reinterpret_cast(vclient); + BaseClientProxy* sender = static_cast(vclient); if (m_clientSet.count(sender) == 0) { return; } const IScreen::ClipboardInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); onClipboardChanged(sender, info->m_id, info->m_sequenceNumber); } @@ -1283,7 +1283,7 @@ void Server::handleKeyDownEvent(const Event& event, void*) { IPlatformScreen::KeyInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); onKeyDown(info->m_key, info->m_mask, info->m_button, info->m_screens); } @@ -1291,7 +1291,7 @@ void Server::handleKeyUpEvent(const Event& event, void*) { IPlatformScreen::KeyInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); onKeyUp(info->m_key, info->m_mask, info->m_button, info->m_screens); } @@ -1299,7 +1299,7 @@ void Server::handleKeyRepeatEvent(const Event& event, void*) { IPlatformScreen::KeyInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); onKeyRepeat(info->m_key, info->m_mask, info->m_count, info->m_button); } @@ -1307,7 +1307,7 @@ void Server::handleButtonDownEvent(const Event& event, void*) { IPlatformScreen::ButtonInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); onMouseDown(info->m_button); } @@ -1315,7 +1315,7 @@ void Server::handleButtonUpEvent(const Event& event, void*) { IPlatformScreen::ButtonInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); onMouseUp(info->m_button); } @@ -1323,7 +1323,7 @@ void Server::handleMotionPrimaryEvent(const Event& event, void*) { IPlatformScreen::MotionInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); onMouseMovePrimary(info->m_x, info->m_y); } @@ -1331,7 +1331,7 @@ void Server::handleMotionSecondaryEvent(const Event& event, void*) { IPlatformScreen::MotionInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); onMouseMoveSecondary(info->m_x, info->m_y); } @@ -1339,7 +1339,7 @@ void Server::handleWheelEvent(const Event& event, void*) { IPlatformScreen::WheelInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); onMouseWheel(info->m_xDelta, info->m_yDelta); } @@ -1374,7 +1374,7 @@ Server::handleClientDisconnected(const Event&, void* vclient) { // client has disconnected. it might be an old client or an // active client. we don't care so just handle it both ways. - BaseClientProxy* client = reinterpret_cast(vclient); + BaseClientProxy* client = static_cast(vclient); removeActiveClient(client); removeOldClient(client); @@ -1388,7 +1388,7 @@ void Server::handleClientCloseTimeout(const Event&, void* vclient) { // client took too long to disconnect. just dump it. - BaseClientProxy* client = reinterpret_cast(vclient); + BaseClientProxy* client = static_cast(vclient); LOG((CLOG_NOTE "forced disconnection of client \"%s\"", getName(client).c_str())); removeOldClient(client); PacketStreamFilter* streamFileter = dynamic_cast(client->getStream()); @@ -1401,7 +1401,7 @@ void Server::handleSwitchToScreenEvent(const Event& event, void*) { SwitchToScreenInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); ClientList::const_iterator index = m_clients.find(info->m_screen); if (index == m_clients.end()) { @@ -1416,7 +1416,7 @@ void Server::handleSwitchInDirectionEvent(const Event& event, void*) { SwitchInDirectionInfo* info = - reinterpret_cast(event.getData()); + static_cast(event.getData()); // jump to screen in chosen direction from center of this screen SInt32 x = m_x, y = m_y; @@ -1817,7 +1817,7 @@ Server::onMouseMovePrimary(SInt32 x, SInt32 y) void Server::sendDragInfoThread(void* arg) { - BaseClientProxy* newScreen = reinterpret_cast(arg); + BaseClientProxy* newScreen = static_cast(arg); m_dragFileList.clear(); String& dragFileList = m_screen->getDraggingFilename(); @@ -2053,7 +2053,7 @@ Server::onMouseWheel(SInt32 xDelta, SInt32 yDelta) void Server::onFileChunkSending(const void* data) { - FileChunk* chunk = reinterpret_cast(const_cast(data)); + FileChunk* chunk = static_cast(const_cast(data)); LOG((CLOG_DEBUG1 "sending file chunk")); assert(m_active != NULL); @@ -2372,14 +2372,14 @@ Server::sendFileToClient(const char* filename) m_sendFileThread = new Thread( new TMethodJob( this, &Server::sendFileThread, - reinterpret_cast(const_cast(filename)))); + static_cast(const_cast(filename)))); } void Server::sendFileThread(void* data) { try { - char* filename = reinterpret_cast(data); + char* filename = static_cast(data); LOG((CLOG_DEBUG "sending file to client, filename=%s", filename)); StreamChunker::sendFile(filename, m_events, this); } diff --git a/src/lib/synergy/ClientApp.cpp b/src/lib/synergy/ClientApp.cpp index 6adac9b9..10aba5f3 100644 --- a/src/lib/synergy/ClientApp.cpp +++ b/src/lib/synergy/ClientApp.cpp @@ -268,7 +268,7 @@ void ClientApp::handleClientRestart(const Event&, void* vtimer) { // discard old timer - EventQueueTimer* timer = reinterpret_cast(vtimer); + EventQueueTimer* timer = static_cast(vtimer); m_events->deleteTimer(timer); m_events->removeHandler(Event::kTimer, timer); @@ -301,7 +301,7 @@ void ClientApp::handleClientFailed(const Event& e, void*) { Client::FailInfo* info = - reinterpret_cast(e.getData()); + static_cast(e.getData()); updateStatus(String("Failed to connect to server: ") + info->m_what); if (!args().m_restartable || !info->m_retry) { @@ -455,11 +455,6 @@ ClientApp::mainLoop() SocketMultiplexer multiplexer; setSocketMultiplexer(&multiplexer); - // load all available plugins. - ARCH->plugin().load(); - // pass log and arch into plugins. - ARCH->plugin().init(Log::getInstance(), Arch::getInstance()); - // start client, etc appUtil().startNode(); @@ -469,9 +464,6 @@ ClientApp::mainLoop() initIpcClient(); } - // init event for all available plugins. - ARCH->plugin().initEvent(m_clientScreen->getEventTarget(), m_events); - // run event loop. if startClient() failed we're supposed to retry // later. the timer installed by startClient() will take care of // that. @@ -506,9 +498,6 @@ ClientApp::mainLoop() cleanupIpcClient(); } - // unload all plugins. - ARCH->plugin().unload(); - return kExitSuccess; } diff --git a/src/lib/synergy/ClipboardChunk.cpp b/src/lib/synergy/ClipboardChunk.cpp index f7a5673d..25c0e2d8 100644 --- a/src/lib/synergy/ClipboardChunk.cpp +++ b/src/lib/synergy/ClipboardChunk.cpp @@ -21,6 +21,7 @@ #include "synergy/protocol_types.h" #include "io/IStream.h" #include "base/Log.h" +#include size_t ClipboardChunk::s_expectedSize = 0; @@ -41,8 +42,7 @@ ClipboardChunk::start( char* chunk = start->m_chunk; chunk[0] = id; - UInt32* seq = reinterpret_cast(&chunk[1]); - *seq = sequence; + std::memcpy (&chunk[1], &sequence, 4); chunk[5] = kDataStart; memcpy(&chunk[6], size.c_str(), sizeLength); chunk[sizeLength + CLIPBOARD_CHUNK_META_SIZE - 1] = '\0'; @@ -61,8 +61,7 @@ ClipboardChunk::data( char* chunkData = chunk->m_chunk; chunkData[0] = id; - UInt32* seq = reinterpret_cast(&chunkData[1]); - *seq = sequence; + std::memcpy (&chunkData[1], &sequence, 4); chunkData[5] = kDataChunk; memcpy(&chunkData[6], data.c_str(), dataSize); chunkData[dataSize + CLIPBOARD_CHUNK_META_SIZE - 1] = '\0'; @@ -77,8 +76,7 @@ ClipboardChunk::end(ClipboardID id, UInt32 sequence) char* chunk = end->m_chunk; chunk[0] = id; - UInt32* seq = reinterpret_cast(&chunk[1]); - *seq = sequence; + std::memcpy (&chunk[1], &sequence, 4); chunk[5] = kDataEnd; chunk[CLIPBOARD_CHUNK_META_SIZE - 1] = '\0'; @@ -127,14 +125,14 @@ ClipboardChunk::assemble(synergy::IStream* stream, void ClipboardChunk::send(synergy::IStream* stream, void* data) { - ClipboardChunk* clipboardData = reinterpret_cast(data); + ClipboardChunk* clipboardData = static_cast(data); LOG((CLOG_DEBUG1 "sending clipboard chunk")); char* chunk = clipboardData->m_chunk; ClipboardID id = chunk[0]; - UInt32* seq = reinterpret_cast(&chunk[1]); - UInt32 sequence = *seq; + UInt32 sequence; + std::memcpy (&sequence, &chunk[1], 4); UInt8 mark = chunk[5]; String dataChunk(&chunk[6], clipboardData->m_dataSize); diff --git a/src/lib/synergy/KeyState.cpp b/src/lib/synergy/KeyState.cpp index 3808b944..bdb8706c 100644 --- a/src/lib/synergy/KeyState.cpp +++ b/src/lib/synergy/KeyState.cpp @@ -524,7 +524,7 @@ KeyState::addActiveModifierCB(KeyID, SInt32 group, synergy::KeyMap::KeyItem& keyItem, void* vcontext) { AddActiveModifierContext* context = - reinterpret_cast(vcontext); + static_cast(vcontext); if (group == context->m_activeGroup && (keyItem.m_generates & context->m_mask) != 0) { context->m_activeModifiers.insert(std::make_pair( diff --git a/src/lib/synergy/ProtocolUtil.cpp b/src/lib/synergy/ProtocolUtil.cpp index ab361880..ae796fa9 100644 --- a/src/lib/synergy/ProtocolUtil.cpp +++ b/src/lib/synergy/ProtocolUtil.cpp @@ -120,27 +120,27 @@ ProtocolUtil::vreadf(synergy::IStream* stream, const char* fmt, va_list args) switch (len) { case 1: // 1 byte integer - *reinterpret_cast(v) = buffer[0]; - LOG((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast(v), *reinterpret_cast(v))); + *static_cast(v) = buffer[0]; + LOG((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *static_cast(v), *static_cast(v))); break; case 2: // 2 byte integer - *reinterpret_cast(v) = + *static_cast(v) = static_cast( (static_cast(buffer[0]) << 8) | static_cast(buffer[1])); - LOG((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast(v), *reinterpret_cast(v))); + LOG((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *static_cast(v), *static_cast(v))); break; case 4: // 4 byte integer - *reinterpret_cast(v) = + *static_cast(v) = (static_cast(buffer[0]) << 24) | (static_cast(buffer[1]) << 16) | (static_cast(buffer[2]) << 8) | static_cast(buffer[3]); - LOG((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast(v), *reinterpret_cast(v))); + LOG((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *static_cast(v), *static_cast(v))); break; } break; @@ -165,9 +165,9 @@ ProtocolUtil::vreadf(synergy::IStream* stream, const char* fmt, va_list args) // 1 byte integer for (UInt32 i = 0; i < n; ++i) { read(stream, buffer, 1); - reinterpret_cast*>(v)->push_back( + static_cast*>(v)->push_back( buffer[0]); - LOG((CLOG_DEBUG2 "readf: read %d byte integer[%d]: %d (0x%x)", len, i, reinterpret_cast*>(v)->back(), reinterpret_cast*>(v)->back())); + LOG((CLOG_DEBUG2 "readf: read %d byte integer[%d]: %d (0x%x)", len, i, static_cast*>(v)->back(), static_cast*>(v)->back())); } break; @@ -175,11 +175,11 @@ ProtocolUtil::vreadf(synergy::IStream* stream, const char* fmt, va_list args) // 2 byte integer for (UInt32 i = 0; i < n; ++i) { read(stream, buffer, 2); - reinterpret_cast*>(v)->push_back( + static_cast*>(v)->push_back( static_cast( (static_cast(buffer[0]) << 8) | static_cast(buffer[1]))); - LOG((CLOG_DEBUG2 "readf: read %d byte integer[%d]: %d (0x%x)", len, i, reinterpret_cast*>(v)->back(), reinterpret_cast*>(v)->back())); + LOG((CLOG_DEBUG2 "readf: read %d byte integer[%d]: %d (0x%x)", len, i, static_cast*>(v)->back(), static_cast*>(v)->back())); } break; @@ -187,12 +187,12 @@ ProtocolUtil::vreadf(synergy::IStream* stream, const char* fmt, va_list args) // 4 byte integer for (UInt32 i = 0; i < n; ++i) { read(stream, buffer, 4); - reinterpret_cast*>(v)->push_back( + static_cast*>(v)->push_back( (static_cast(buffer[0]) << 24) | (static_cast(buffer[1]) << 16) | (static_cast(buffer[2]) << 8) | static_cast(buffer[3])); - LOG((CLOG_DEBUG2 "readf: read %d byte integer[%d]: %d (0x%x)", len, i, reinterpret_cast*>(v)->back(), reinterpret_cast*>(v)->back())); + LOG((CLOG_DEBUG2 "readf: read %d byte integer[%d]: %d (0x%x)", len, i, static_cast*>(v)->back(), static_cast*>(v)->back())); } break; } @@ -340,7 +340,7 @@ ProtocolUtil::getLength(const char* fmt, va_list args) void ProtocolUtil::writef(void* buffer, const char* fmt, va_list args) { - UInt8* dst = reinterpret_cast(buffer); + UInt8* dst = static_cast(buffer); while (*fmt) { if (*fmt == '%') { @@ -515,7 +515,7 @@ ProtocolUtil::read(synergy::IStream* stream, void* vbuffer, UInt32 count) assert(stream != NULL); assert(vbuffer != NULL); - UInt8* buffer = reinterpret_cast(vbuffer); + UInt8* buffer = static_cast(vbuffer); while (count > 0) { // read more UInt32 n = stream->read(buffer, count); diff --git a/src/lib/synergy/ServerApp.cpp b/src/lib/synergy/ServerApp.cpp index 0153f9a2..23884aec 100644 --- a/src/lib/synergy/ServerApp.cpp +++ b/src/lib/synergy/ServerApp.cpp @@ -259,7 +259,7 @@ ServerApp::forceReconnect(const Event&, void*) void ServerApp::handleClientConnected(const Event&, void* vlistener) { - ClientListener* listener = reinterpret_cast(vlistener); + ClientListener* listener = static_cast(vlistener); ClientProxy* client = listener->getNextClient(); if (client != NULL) { m_server->adoptClient(client); @@ -707,11 +707,6 @@ ServerApp::mainLoop() return kExitFailed; } - // load all available plugins. - ARCH->plugin().load(); - // pass log and arch into plugins. - ARCH->plugin().init(Log::getInstance(), Arch::getInstance()); - // start server, etc appUtil().startNode(); @@ -721,9 +716,6 @@ ServerApp::mainLoop() initIpcClient(); } - // init event for all available plugins. - ARCH->plugin().initEvent(m_serverScreen->getEventTarget(), m_events); - // handle hangup signal by reloading the server's configuration ARCH->setSignalHandler(Arch::kHANGUP, &reloadSignalHandler, NULL); m_events->adoptHandler(m_events->forServerApp().reloadConfig(), @@ -780,9 +772,6 @@ ServerApp::mainLoop() cleanupIpcClient(); } - // unload all plugins. - ARCH->plugin().unload(); - return kExitSuccess; } diff --git a/src/lib/synergy/StreamChunker.cpp b/src/lib/synergy/StreamChunker.cpp index f53c39bc..2ad64a03 100644 --- a/src/lib/synergy/StreamChunker.cpp +++ b/src/lib/synergy/StreamChunker.cpp @@ -49,7 +49,7 @@ StreamChunker::sendFile( { s_isChunkingFile = true; - std::fstream file(reinterpret_cast(filename), std::ios::in | std::ios::binary); + std::fstream file(static_cast(filename), std::ios::in | std::ios::binary); if (!file.is_open()) { throw runtime_error("failed to open file"); diff --git a/src/lib/synergy/ToolApp.cpp b/src/lib/synergy/ToolApp.cpp index b024bfe9..e6695f51 100644 --- a/src/lib/synergy/ToolApp.cpp +++ b/src/lib/synergy/ToolApp.cpp @@ -174,19 +174,6 @@ ToolApp::loginAuth() void ToolApp::getPluginList() { - String credentials; - std::cin >> credentials; - - size_t separator = credentials.find(':'); - String email = credentials.substr(0, separator); - String password = credentials.substr(separator + 1, credentials.length()); - - std::stringstream ss; - ss << JSON_URL << "plugins/"; - ss << "?email=" << ARCH->internet().urlEncode(email); - ss << "&password=" << password; - - std::cout << ARCH->internet().get(ss.str()) << std::endl; } void diff --git a/src/setup/win32/Product.wxs b/src/setup/win32/Product.wxs index 5769427b..34097863 100644 --- a/src/setup/win32/Product.wxs +++ b/src/setup/win32/Product.wxs @@ -27,7 +27,6 @@ - @@ -71,7 +70,6 @@ - @@ -146,11 +144,5 @@ - - - - - - diff --git a/src/test/integtests/CMakeLists.txt b/src/test/integtests/CMakeLists.txt index bde35c2f..2f1ca7f3 100644 --- a/src/test/integtests/CMakeLists.txt +++ b/src/test/integtests/CMakeLists.txt @@ -68,4 +68,4 @@ endif() add_executable(integtests ${sources}) target_link_libraries(integtests - arch base client common io ipc mt net platform server synergy gtest gmock ${libs}) + arch base client common io ipc mt net platform server synergy gtest gmock ${libs} ${OPENSSL_LIBS}) diff --git a/src/test/integtests/net/NetworkTests.cpp b/src/test/integtests/net/NetworkTests.cpp index dd7fb6b4..79ef7c99 100644 --- a/src/test/integtests/net/NetworkTests.cpp +++ b/src/test/integtests/net/NetworkTests.cpp @@ -27,6 +27,7 @@ #include "test/global/TestEventQueue.h" #include "server/Server.h" #include "server/ClientListener.h" +#include "server/ClientProxy.h" #include "client/Client.h" #include "synergy/FileChunk.h" #include "synergy/StreamChunker.h" @@ -328,7 +329,7 @@ TEST_F(NetworkTests, sendToServer_mockFile) void NetworkTests::sendToClient_mockData_handleClientConnected(const Event&, void* vlistener) { - ClientListener* listener = reinterpret_cast(vlistener); + ClientListener* listener = static_cast(vlistener); Server* server = listener->getServer(); ClientProxy* client = listener->getNextClient(); @@ -336,7 +337,7 @@ NetworkTests::sendToClient_mockData_handleClientConnected(const Event&, void* vl throw runtime_error("client is null"); } - BaseClientProxy* bcp = reinterpret_cast(client); + BaseClientProxy* bcp = client; server->adoptClient(bcp); server->setActive(bcp); @@ -346,7 +347,7 @@ NetworkTests::sendToClient_mockData_handleClientConnected(const Event&, void* vl void NetworkTests::sendToClient_mockData_fileRecieveCompleted(const Event& event, void*) { - Client* client = reinterpret_cast(event.getTarget()); + Client* client = static_cast(event.getTarget()); EXPECT_TRUE(client->isReceivedFileSizeValid()); m_events.raiseQuitEvent(); @@ -355,7 +356,7 @@ NetworkTests::sendToClient_mockData_fileRecieveCompleted(const Event& event, voi void NetworkTests::sendToClient_mockFile_handleClientConnected(const Event&, void* vlistener) { - ClientListener* listener = reinterpret_cast(vlistener); + ClientListener* listener = static_cast(vlistener); Server* server = listener->getServer(); ClientProxy* client = listener->getNextClient(); @@ -363,7 +364,7 @@ NetworkTests::sendToClient_mockFile_handleClientConnected(const Event&, void* vl throw runtime_error("client is null"); } - BaseClientProxy* bcp = reinterpret_cast(client); + BaseClientProxy* bcp = client; server->adoptClient(bcp); server->setActive(bcp); @@ -373,7 +374,7 @@ NetworkTests::sendToClient_mockFile_handleClientConnected(const Event&, void* vl void NetworkTests::sendToClient_mockFile_fileRecieveCompleted(const Event& event, void*) { - Client* client = reinterpret_cast(event.getTarget()); + Client* client = static_cast(event.getTarget()); EXPECT_TRUE(client->isReceivedFileSizeValid()); m_events.raiseQuitEvent(); @@ -382,14 +383,14 @@ NetworkTests::sendToClient_mockFile_fileRecieveCompleted(const Event& event, voi void NetworkTests::sendToServer_mockData_handleClientConnected(const Event&, void* vclient) { - Client* client = reinterpret_cast(vclient); + Client* client = static_cast(vclient); sendMockData(client); } void NetworkTests::sendToServer_mockData_fileRecieveCompleted(const Event& event, void*) { - Server* server = reinterpret_cast(event.getTarget()); + Server* server = static_cast(event.getTarget()); EXPECT_TRUE(server->isReceivedFileSizeValid()); m_events.raiseQuitEvent(); @@ -398,14 +399,14 @@ NetworkTests::sendToServer_mockData_fileRecieveCompleted(const Event& event, voi void NetworkTests::sendToServer_mockFile_handleClientConnected(const Event&, void* vclient) { - Client* client = reinterpret_cast(vclient); + Client* client = static_cast(vclient); client->sendFileToServer(kMockFilename); } void NetworkTests::sendToServer_mockFile_fileRecieveCompleted(const Event& event, void*) { - Server* server = reinterpret_cast(event.getTarget()); + Server* server = static_cast(event.getTarget()); EXPECT_TRUE(server->isReceivedFileSizeValid()); m_events.raiseQuitEvent(); diff --git a/src/test/unittests/CMakeLists.txt b/src/test/unittests/CMakeLists.txt index 4cacdf93..4cdab9bf 100644 --- a/src/test/unittests/CMakeLists.txt +++ b/src/test/unittests/CMakeLists.txt @@ -68,4 +68,4 @@ endif() add_executable(unittests ${sources}) target_link_libraries(unittests - arch base client server common io net platform server synergy mt ipc gtest gmock ${libs}) + arch base client server common io net platform server synergy mt ipc gtest gmock ${libs} ${OPENSSL_LIBS})