From beb08eb751fa8e1f72042f263316ab5e5ddb596d Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Wed, 10 Nov 2021 00:54:13 -0500 Subject: New upstream version 2.4.0+dfsg. --- src/CMakeLists.txt | 12 +- src/cmd/CMakeLists.txt | 7 +- src/cmd/barrierc/CMakeLists.txt | 16 +- .../barrierc/MSWindowsClientTaskBarReceiver.cpp | 4 +- src/cmd/barrierc/MSWindowsClientTaskBarReceiver.h | 4 +- src/cmd/barrierc/OSXClientTaskBarReceiver.cpp | 5 +- src/cmd/barrierc/OSXClientTaskBarReceiver.h | 4 +- src/cmd/barrierc/XWindowsClientTaskBarReceiver.cpp | 4 +- src/cmd/barrierc/XWindowsClientTaskBarReceiver.h | 4 +- src/cmd/barrierc/barrierc.cpp | 8 +- src/cmd/barrierc/barrierc.exe.manifest | 2 - src/cmd/barrierc/barrierc.rc | 97 +- src/cmd/barrierc/resource.h | 2 +- src/cmd/barrierd/CMakeLists.txt | 3 + src/cmd/barrierd/barrierd.cpp | 4 +- src/cmd/barrierd/barrierd.ico | Bin 0 -> 121502 bytes src/cmd/barrierd/barrierd.rc | 111 ++ src/cmd/barriers/CMakeLists.txt | 17 +- .../barriers/MSWindowsServerTaskBarReceiver.cpp | 4 +- src/cmd/barriers/MSWindowsServerTaskBarReceiver.h | 4 +- src/cmd/barriers/OSXServerTaskBarReceiver.cpp | 4 +- src/cmd/barriers/OSXServerTaskBarReceiver.h | 4 +- src/cmd/barriers/XWindowsServerTaskBarReceiver.cpp | 4 +- src/cmd/barriers/XWindowsServerTaskBarReceiver.h | 4 +- src/cmd/barriers/barriers.cpp | 8 +- src/cmd/barriers/barriers.exe.manifest | 2 - src/cmd/barriers/barriers.rc | 61 +- src/cmd/barriers/resource.h | 2 +- src/gui/CMakeLists.txt | 136 +- src/gui/gui.pro | 162 --- src/gui/gui.ts | 9 +- src/gui/lang.cmd | 2 +- src/gui/langbuild.cmd | 4 +- src/gui/res/lang/Languages.xml | 92 +- src/gui/res/lang/gui_af-ZA.ts | 9 +- src/gui/res/lang/gui_ar.ts | 9 +- src/gui/res/lang/gui_bg-BG.qm | Bin 21889 -> 21854 bytes src/gui/res/lang/gui_bg-BG.ts | 13 +- src/gui/res/lang/gui_ca-AD.qm | Bin 23086 -> 23050 bytes src/gui/res/lang/gui_ca-AD.ts | 19 +- src/gui/res/lang/gui_cs-CZ.qm | Bin 22897 -> 22864 bytes src/gui/res/lang/gui_cs-CZ.ts | 13 +- src/gui/res/lang/gui_cy.qm | Bin 15069 -> 15048 bytes src/gui/res/lang/gui_cy.ts | 13 +- src/gui/res/lang/gui_da.qm | Bin 22065 -> 22042 bytes src/gui/res/lang/gui_da.ts | 15 +- src/gui/res/lang/gui_de.qm | Bin 23631 -> 40389 bytes src/gui/res/lang/gui_de.ts | 589 +++++---- src/gui/res/lang/gui_es.qm | Bin 23609 -> 23570 bytes src/gui/res/lang/gui_es.ts | 13 +- src/gui/res/lang/gui_et-EE.qm | Bin 21531 -> 21506 bytes src/gui/res/lang/gui_et-EE.ts | 13 +- src/gui/res/lang/gui_fi.qm | Bin 21785 -> 21750 bytes src/gui/res/lang/gui_fi.ts | 13 +- src/gui/res/lang/gui_fr.qm | Bin 23635 -> 23610 bytes src/gui/res/lang/gui_fr.ts | 13 +- src/gui/res/lang/gui_gl.ts | 9 +- src/gui/res/lang/gui_grk.ts | 9 +- src/gui/res/lang/gui_he.qm | Bin 13576 -> 13555 bytes src/gui/res/lang/gui_he.ts | 13 +- src/gui/res/lang/gui_hi.ts | 9 +- src/gui/res/lang/gui_hr-HR.qm | Bin 20504 -> 20477 bytes src/gui/res/lang/gui_hr-HR.ts | 13 +- src/gui/res/lang/gui_hu-HU.qm | Bin 18574 -> 18549 bytes src/gui/res/lang/gui_hu-HU.ts | 13 +- src/gui/res/lang/gui_id.ts | 9 +- src/gui/res/lang/gui_is-IS.ts | 9 +- src/gui/res/lang/gui_it.qm | Bin 21856 -> 21827 bytes src/gui/res/lang/gui_it.ts | 13 +- src/gui/res/lang/gui_ja-JP.qm | Bin 17380 -> 33285 bytes src/gui/res/lang/gui_ja-JP.ts | 692 ++++++---- src/gui/res/lang/gui_ko.qm | Bin 18396 -> 18383 bytes src/gui/res/lang/gui_ko.ts | 23 +- src/gui/res/lang/gui_lt.ts | 9 +- src/gui/res/lang/gui_lv.ts | 9 +- src/gui/res/lang/gui_mr.ts | 9 +- src/gui/res/lang/gui_nl-NL.qm | Bin 22485 -> 22454 bytes src/gui/res/lang/gui_nl-NL.ts | 15 +- src/gui/res/lang/gui_no.qm | Bin 21717 -> 21694 bytes src/gui/res/lang/gui_no.ts | 13 +- src/gui/res/lang/gui_pes-IR.ts | 9 +- src/gui/res/lang/gui_pl-PL.qm | Bin 22481 -> 22448 bytes src/gui/res/lang/gui_pl-PL.ts | 17 +- src/gui/res/lang/gui_pt-BR.qm | Bin 22451 -> 22414 bytes src/gui/res/lang/gui_pt-BR.ts | 13 +- src/gui/res/lang/gui_pt-PT.qm | Bin 21266 -> 21229 bytes src/gui/res/lang/gui_pt-PT.ts | 13 +- src/gui/res/lang/gui_ro.qm | Bin 19807 -> 19774 bytes src/gui/res/lang/gui_ro.ts | 13 +- src/gui/res/lang/gui_ru.qm | Bin 22330 -> 22309 bytes src/gui/res/lang/gui_ru.ts | 17 +- src/gui/res/lang/gui_si.ts | 9 +- src/gui/res/lang/gui_sk-SK.qm | Bin 1198 -> 39331 bytes src/gui/res/lang/gui_sk-SK.ts | 586 +++++---- src/gui/res/lang/gui_sl-SI.ts | 9 +- src/gui/res/lang/gui_sq-AL.qm | Bin 20259 -> 20230 bytes src/gui/res/lang/gui_sq-AL.ts | 13 +- src/gui/res/lang/gui_sr.ts | 9 +- src/gui/res/lang/gui_sv.qm | Bin 22157 -> 37805 bytes src/gui/res/lang/gui_sv.ts | 13 +- src/gui/res/lang/gui_th-TH.ts | 9 +- src/gui/res/lang/gui_tr-TR.ts | 13 +- src/gui/res/lang/gui_uk.qm | Bin 22694 -> 22673 bytes src/gui/res/lang/gui_uk.ts | 13 +- src/gui/res/lang/gui_ur.ts | 9 +- src/gui/res/lang/gui_vi.ts | 9 +- src/gui/res/lang/gui_zh-CN.qm | Bin 16198 -> 25228 bytes src/gui/res/lang/gui_zh-CN.ts | 1352 +++++++++----------- src/gui/res/lang/gui_zh-TW.qm | Bin 16332 -> 16321 bytes src/gui/res/lang/gui_zh-TW.ts | 13 +- src/gui/res/win/Barrier.rc | 113 +- src/gui/src/AboutDialog.cpp | 4 +- src/gui/src/AboutDialog.h | 5 +- src/gui/src/Action.cpp | 19 +- src/gui/src/Action.h | 35 +- src/gui/src/ActionDialog.cpp | 14 +- src/gui/src/ActionDialog.h | 4 +- src/gui/src/AppConfig.cpp | 16 +- src/gui/src/AppConfig.h | 8 + src/gui/src/BaseConfig.cpp | 5 +- src/gui/src/BaseConfig.h | 4 +- src/gui/src/Fingerprint.cpp | 148 --- src/gui/src/Fingerprint.h | 42 - src/gui/src/FingerprintAcceptDialog.cpp | 65 + src/gui/src/FingerprintAcceptDialog.h | 45 + src/gui/src/FingerprintAcceptDialog.ui | 174 +++ src/gui/src/Hotkey.cpp | 36 +- src/gui/src/Hotkey.h | 27 +- src/gui/src/HotkeyDialog.cpp | 4 +- src/gui/src/HotkeyDialog.h | 4 +- src/gui/src/IpcClient.h | 2 +- src/gui/src/KeySequence.cpp | 33 +- src/gui/src/KeySequence.h | 8 +- src/gui/src/KeySequenceWidget.cpp | 4 +- src/gui/src/KeySequenceWidget.h | 5 +- src/gui/src/MainWindow.cpp | 192 ++- src/gui/src/MainWindow.h | 14 +- src/gui/src/MainWindowBase.ui | 148 ++- src/gui/src/NewScreenWidget.cpp | 7 +- src/gui/src/NewScreenWidget.h | 5 +- src/gui/src/QBarrierApplication.cpp | 7 +- src/gui/src/QBarrierApplication.h | 5 +- src/gui/src/QUtility.cpp | 3 +- src/gui/src/Screen.cpp | 7 +- src/gui/src/Screen.h | 7 +- src/gui/src/ScreenSettingsDialog.cpp | 5 +- src/gui/src/ScreenSettingsDialog.h | 5 +- src/gui/src/ScreenSetupModel.cpp | 14 +- src/gui/src/ScreenSetupModel.h | 9 +- src/gui/src/ScreenSetupView.cpp | 83 +- src/gui/src/ScreenSetupView.h | 9 +- src/gui/src/ServerConfig.cpp | 18 +- src/gui/src/ServerConfig.h | 21 +- src/gui/src/ServerConfigDialog.cpp | 26 +- src/gui/src/ServerConfigDialog.h | 5 +- src/gui/src/SettingsDialog.cpp | 8 +- src/gui/src/SettingsDialog.h | 4 +- src/gui/src/SettingsDialogBase.ui | 87 +- src/gui/src/SetupWizard.cpp | 10 +- src/gui/src/SetupWizard.h | 4 +- src/gui/src/ShutdownCh.h | 1 - src/gui/src/SslCertificate.cpp | 208 ++- src/gui/src/SslCertificate.h | 11 +- src/gui/src/TrashScreenWidget.cpp | 5 +- src/gui/src/TrashScreenWidget.h | 5 +- src/gui/src/ZeroconfService.cpp | 12 +- src/gui/src/main.cpp | 6 + src/gui/test/HotkeyTests.cpp | 320 +++++ src/gui/test/KeySequenceTests.cpp | 145 +++ src/gui/test/Utils.h | 38 + src/gui/test/main.cpp | 23 + src/lib/CMakeLists.txt | 4 +- src/lib/arch/Arch.cpp | 4 +- src/lib/arch/Arch.h | 4 +- src/lib/arch/ArchConsoleStd.cpp | 6 +- src/lib/arch/ArchConsoleStd.h | 4 +- src/lib/arch/ArchDaemonNone.cpp | 4 +- src/lib/arch/ArchDaemonNone.h | 4 +- src/lib/arch/CMakeLists.txt | 4 +- src/lib/arch/IArchConsole.h | 4 +- src/lib/arch/IArchDaemon.h | 8 +- src/lib/arch/IArchLog.h | 4 +- src/lib/arch/IArchMultithread.h | 30 +- src/lib/arch/IArchNetwork.h | 12 +- src/lib/arch/IArchSleep.h | 4 +- src/lib/arch/IArchString.cpp | 4 +- src/lib/arch/IArchString.h | 14 +- src/lib/arch/IArchSystem.h | 4 +- src/lib/arch/IArchTaskBar.h | 4 +- src/lib/arch/IArchTaskBarReceiver.h | 4 +- src/lib/arch/IArchTime.h | 4 +- src/lib/arch/XArch.h | 6 +- src/lib/arch/multibyte.h | 4 +- src/lib/arch/unix/ArchConsoleUnix.cpp | 4 +- src/lib/arch/unix/ArchConsoleUnix.h | 4 +- src/lib/arch/unix/ArchDaemonUnix.cpp | 20 +- src/lib/arch/unix/ArchDaemonUnix.h | 4 +- src/lib/arch/unix/ArchInternetUnix.cpp | 8 +- src/lib/arch/unix/ArchLogUnix.cpp | 4 +- src/lib/arch/unix/ArchLogUnix.h | 4 +- src/lib/arch/unix/ArchMultithreadPosix.cpp | 35 +- src/lib/arch/unix/ArchMultithreadPosix.h | 7 +- src/lib/arch/unix/ArchNetworkBSD.cpp | 4 +- src/lib/arch/unix/ArchNetworkBSD.h | 4 +- src/lib/arch/unix/ArchSleepUnix.cpp | 4 +- src/lib/arch/unix/ArchSleepUnix.h | 4 +- src/lib/arch/unix/ArchStringUnix.cpp | 5 +- src/lib/arch/unix/ArchStringUnix.h | 4 +- src/lib/arch/unix/ArchSystemUnix.cpp | 4 +- src/lib/arch/unix/ArchSystemUnix.h | 4 +- src/lib/arch/unix/ArchTaskBarXWindows.cpp | 4 +- src/lib/arch/unix/ArchTaskBarXWindows.h | 4 +- src/lib/arch/unix/ArchTimeUnix.cpp | 4 +- src/lib/arch/unix/ArchTimeUnix.h | 4 +- src/lib/arch/unix/XArchUnix.cpp | 4 +- src/lib/arch/unix/XArchUnix.h | 4 +- src/lib/arch/vsnprintf.h | 67 - src/lib/arch/win32/ArchConsoleWindows.cpp | 4 +- src/lib/arch/win32/ArchConsoleWindows.h | 4 +- src/lib/arch/win32/ArchDaemonWindows.cpp | 10 +- src/lib/arch/win32/ArchDaemonWindows.h | 4 +- src/lib/arch/win32/ArchInternetWindows.cpp | 8 +- src/lib/arch/win32/ArchLogWindows.cpp | 4 +- src/lib/arch/win32/ArchLogWindows.h | 4 +- src/lib/arch/win32/ArchMiscWindows.cpp | 22 +- src/lib/arch/win32/ArchMiscWindows.h | 6 +- src/lib/arch/win32/ArchMultithreadWindows.cpp | 33 +- src/lib/arch/win32/ArchMultithreadWindows.h | 7 +- src/lib/arch/win32/ArchNetworkWinsock.cpp | 4 +- src/lib/arch/win32/ArchNetworkWinsock.h | 4 +- src/lib/arch/win32/ArchSleepWindows.cpp | 6 +- src/lib/arch/win32/ArchSleepWindows.h | 4 +- src/lib/arch/win32/ArchStringWindows.cpp | 9 +- src/lib/arch/win32/ArchStringWindows.h | 4 +- src/lib/arch/win32/ArchSystemWindows.cpp | 4 +- src/lib/arch/win32/ArchSystemWindows.h | 4 +- src/lib/arch/win32/ArchTaskBarWindows.cpp | 15 +- src/lib/arch/win32/ArchTaskBarWindows.h | 7 +- src/lib/arch/win32/ArchTimeWindows.cpp | 4 +- src/lib/arch/win32/ArchTimeWindows.h | 4 +- src/lib/arch/win32/XArchWindows.cpp | 80 +- src/lib/arch/win32/XArchWindows.h | 4 +- src/lib/barrier/App.cpp | 47 +- src/lib/barrier/App.h | 24 +- src/lib/barrier/AppUtil.cpp | 8 +- src/lib/barrier/AppUtil.h | 8 +- src/lib/barrier/ArgParser.cpp | 67 +- src/lib/barrier/ArgParser.h | 20 +- src/lib/barrier/ArgsBase.cpp | 9 +- src/lib/barrier/ArgsBase.h | 10 +- src/lib/barrier/BarrierType.h | 26 + src/lib/barrier/CMakeLists.txt | 4 +- src/lib/barrier/Chunk.cpp | 4 +- src/lib/barrier/Chunk.h | 6 +- src/lib/barrier/ClientApp.cpp | 58 +- src/lib/barrier/ClientApp.h | 7 +- src/lib/barrier/ClientArgs.cpp | 4 +- src/lib/barrier/ClientArgs.h | 4 +- src/lib/barrier/ClientTaskBarReceiver.cpp | 4 +- src/lib/barrier/ClientTaskBarReceiver.h | 4 +- src/lib/barrier/Clipboard.cpp | 4 +- src/lib/barrier/Clipboard.h | 4 +- src/lib/barrier/ClipboardChunk.cpp | 8 +- src/lib/barrier/ClipboardChunk.h | 4 +- src/lib/barrier/DragInformation.cpp | 16 +- src/lib/barrier/DragInformation.h | 8 +- src/lib/barrier/DropHelper.cpp | 11 +- src/lib/barrier/DropHelper.h | 4 +- src/lib/barrier/FileChunk.cpp | 4 +- src/lib/barrier/FileChunk.h | 4 +- src/lib/barrier/IApp.h | 4 +- src/lib/barrier/IAppUtil.h | 6 +- src/lib/barrier/IClient.h | 4 +- src/lib/barrier/IClipboard.cpp | 8 +- src/lib/barrier/IClipboard.h | 4 +- src/lib/barrier/IKeyState.cpp | 4 +- src/lib/barrier/IKeyState.h | 8 +- src/lib/barrier/INode.h | 6 +- src/lib/barrier/IPlatformScreen.cpp | 4 +- src/lib/barrier/IPlatformScreen.h | 7 +- src/lib/barrier/IPrimaryScreen.cpp | 4 +- src/lib/barrier/IPrimaryScreen.h | 4 +- src/lib/barrier/IScreen.h | 6 +- src/lib/barrier/IScreenSaver.h | 6 +- src/lib/barrier/ISecondaryScreen.h | 4 +- src/lib/barrier/KeyMap.cpp | 14 +- src/lib/barrier/KeyMap.h | 12 +- src/lib/barrier/KeyState.cpp | 10 +- src/lib/barrier/KeyState.h | 8 +- src/lib/barrier/PacketStreamFilter.cpp | 26 +- src/lib/barrier/PacketStreamFilter.h | 10 +- src/lib/barrier/PlatformScreen.cpp | 4 +- src/lib/barrier/PlatformScreen.h | 1 + src/lib/barrier/PortableTaskBarReceiver.cpp | 6 +- src/lib/barrier/PortableTaskBarReceiver.h | 4 +- src/lib/barrier/ProtocolUtil.cpp | 18 +- src/lib/barrier/ProtocolUtil.h | 10 +- src/lib/barrier/Screen.cpp | 12 +- src/lib/barrier/Screen.h | 14 +- src/lib/barrier/ServerApp.cpp | 92 +- src/lib/barrier/ServerApp.h | 8 +- src/lib/barrier/ServerArgs.h | 1 + src/lib/barrier/ServerTaskBarReceiver.cpp | 6 +- src/lib/barrier/ServerTaskBarReceiver.h | 4 +- src/lib/barrier/StreamChunker.cpp | 27 +- src/lib/barrier/StreamChunker.h | 11 +- src/lib/barrier/XBarrier.cpp | 6 +- src/lib/barrier/XBarrier.h | 10 +- src/lib/barrier/XScreen.cpp | 4 +- src/lib/barrier/XScreen.h | 4 +- src/lib/barrier/clipboard_types.h | 4 +- src/lib/barrier/key_types.cpp | 14 +- src/lib/barrier/key_types.h | 17 +- src/lib/barrier/mouse_types.h | 4 +- src/lib/barrier/option_types.h | 4 +- src/lib/barrier/protocol_types.cpp | 4 +- src/lib/barrier/protocol_types.h | 16 +- src/lib/barrier/unix/AppUtilUnix.cpp | 4 +- src/lib/barrier/unix/AppUtilUnix.h | 6 +- src/lib/barrier/win32/AppUtilWindows.cpp | 28 +- src/lib/barrier/win32/AppUtilWindows.h | 6 +- src/lib/barrier/win32/DaemonApp.cpp | 25 +- src/lib/barrier/win32/DaemonApp.h | 6 +- src/lib/base/CMakeLists.txt | 4 +- src/lib/base/ELevel.h | 4 +- src/lib/base/Event.cpp | 4 +- src/lib/base/Event.h | 8 +- src/lib/base/EventQueue.cpp | 16 +- src/lib/base/EventQueue.h | 6 +- src/lib/base/EventTypes.cpp | 5 +- src/lib/base/EventTypes.h | 44 +- src/lib/base/FunctionEventJob.cpp | 4 +- src/lib/base/FunctionEventJob.h | 4 +- src/lib/base/FunctionJob.cpp | 43 - src/lib/base/FunctionJob.h | 39 - src/lib/base/IEventJob.h | 4 +- src/lib/base/IEventQueue.h | 8 +- src/lib/base/IEventQueueBuffer.h | 6 +- src/lib/base/IJob.h | 4 +- src/lib/base/ILogOutputter.h | 4 +- src/lib/base/Log.cpp | 10 +- src/lib/base/Log.h | 12 +- src/lib/base/PriorityQueue.h | 4 +- src/lib/base/SimpleEventQueueBuffer.cpp | 4 +- src/lib/base/SimpleEventQueueBuffer.h | 6 +- src/lib/base/Stopwatch.cpp | 4 +- src/lib/base/Stopwatch.h | 6 +- src/lib/base/String.cpp | 78 +- src/lib/base/String.h | 9 +- src/lib/base/TMethodEventJob.h | 4 +- src/lib/base/TMethodJob.h | 68 - src/lib/base/Unicode.cpp | 4 +- src/lib/base/Unicode.h | 4 +- src/lib/base/XBase.cpp | 4 +- src/lib/base/XBase.h | 4 +- src/lib/base/finally.h | 61 + src/lib/base/log_outputters.cpp | 11 +- src/lib/base/log_outputters.h | 4 +- src/lib/client/CMakeLists.txt | 4 +- src/lib/client/Client.cpp | 46 +- src/lib/client/Client.h | 16 +- src/lib/client/ServerProxy.cpp | 37 +- src/lib/client/ServerProxy.h | 8 +- src/lib/common/CMakeLists.txt | 4 +- src/lib/common/DataDirectories.h | 37 +- src/lib/common/DataDirectories_static.cpp | 41 +- src/lib/common/IInterface.h | 4 +- src/lib/common/MacOSXPrecomp.h | 23 - src/lib/common/PathUtilities.cpp | 75 -- src/lib/common/PathUtilities.h | 31 - src/lib/common/Version.cpp | 4 +- src/lib/common/Version.h | 4 +- src/lib/common/basic_types.h | 67 +- src/lib/common/common.h | 24 +- src/lib/common/stdbitset.h | 4 +- src/lib/common/stddeque.h | 4 +- src/lib/common/stdfstream.h | 4 +- src/lib/common/stdistream.h | 4 +- src/lib/common/stdlist.h | 4 +- src/lib/common/stdmap.h | 4 +- src/lib/common/stdostream.h | 4 +- src/lib/common/stdpost.h | 4 +- src/lib/common/stdpre.h | 4 +- src/lib/common/stdset.h | 4 +- src/lib/common/stdsstream.h | 4 +- src/lib/common/stdstring.h | 4 +- src/lib/common/stdvector.h | 4 +- src/lib/common/unix/DataDirectories.cpp | 38 +- src/lib/common/win32/DataDirectories.cpp | 36 +- src/lib/common/win32/encoding_utilities.cpp | 37 + src/lib/common/win32/encoding_utilities.h | 28 + src/lib/io/CMakeLists.txt | 4 +- src/lib/io/IStream.h | 4 +- src/lib/io/StreamBuffer.cpp | 6 +- src/lib/io/StreamBuffer.h | 4 +- src/lib/io/StreamFilter.cpp | 4 +- src/lib/io/StreamFilter.h | 4 +- src/lib/io/XIO.cpp | 4 +- src/lib/io/XIO.h | 4 +- src/lib/io/filesystem.cpp | 71 + src/lib/io/filesystem.h | 41 + src/lib/ipc/CMakeLists.txt | 4 +- src/lib/ipc/Ipc.h | 4 +- src/lib/ipc/IpcClient.cpp | 4 +- src/lib/ipc/IpcClient.h | 6 +- src/lib/ipc/IpcClientProxy.cpp | 8 +- src/lib/ipc/IpcClientProxy.h | 6 +- src/lib/ipc/IpcLogOutputter.cpp | 11 +- src/lib/ipc/IpcLogOutputter.h | 16 +- src/lib/ipc/IpcMessage.cpp | 4 +- src/lib/ipc/IpcMessage.h | 4 +- src/lib/ipc/IpcServer.cpp | 4 +- src/lib/ipc/IpcServer.h | 8 +- src/lib/ipc/IpcServerProxy.cpp | 12 +- src/lib/ipc/IpcServerProxy.h | 4 +- src/lib/mt/CMakeLists.txt | 4 +- src/lib/mt/CondVar.cpp | 6 +- src/lib/mt/CondVar.h | 6 +- src/lib/mt/Lock.cpp | 4 +- src/lib/mt/Lock.h | 4 +- src/lib/mt/Mutex.cpp | 4 +- src/lib/mt/Mutex.h | 4 +- src/lib/mt/Thread.cpp | 46 +- src/lib/mt/Thread.h | 35 +- src/lib/mt/XMT.cpp | 4 +- src/lib/mt/XMT.h | 4 +- src/lib/mt/XThread.h | 14 +- src/lib/net/CMakeLists.txt | 4 +- src/lib/net/ConnectionSecurityLevel.h | 27 + src/lib/net/FingerprintData.cpp | 52 + src/lib/net/FingerprintData.h | 46 + src/lib/net/FingerprintDatabase.cpp | 135 ++ src/lib/net/FingerprintDatabase.h | 53 + src/lib/net/IDataSocket.cpp | 4 +- src/lib/net/IDataSocket.h | 4 +- src/lib/net/IListenSocket.h | 6 +- src/lib/net/ISocket.h | 4 +- src/lib/net/ISocketFactory.h | 15 +- src/lib/net/ISocketMultiplexerJob.h | 4 +- src/lib/net/NetworkAddress.cpp | 4 +- src/lib/net/NetworkAddress.h | 6 +- src/lib/net/SecureListenSocket.cpp | 36 +- src/lib/net/SecureListenSocket.h | 15 +- src/lib/net/SecureSocket.cpp | 356 +++--- src/lib/net/SecureSocket.h | 62 +- src/lib/net/SecureUtils.cpp | 312 +++++ src/lib/net/SecureUtils.h | 43 + src/lib/net/SocketMultiplexer.cpp | 17 +- src/lib/net/SocketMultiplexer.h | 6 +- src/lib/net/TCPListenSocket.cpp | 16 +- src/lib/net/TCPListenSocket.h | 4 +- src/lib/net/TCPSocket.cpp | 42 +- src/lib/net/TCPSocket.h | 10 +- src/lib/net/TCPSocketFactory.cpp | 21 +- src/lib/net/TCPSocketFactory.h | 15 +- src/lib/net/TSocketMultiplexerMethodJob.h | 94 +- src/lib/net/XSocket.cpp | 6 +- src/lib/net/XSocket.h | 4 +- src/lib/platform/CMakeLists.txt | 4 +- src/lib/platform/IMSWindowsClipboardFacade.h | 6 +- src/lib/platform/IOSXKeyResource.cpp | 6 +- src/lib/platform/IOSXKeyResource.h | 8 +- src/lib/platform/IXWindowsImpl.h | 58 +- src/lib/platform/ImmuneKeysReader.cpp | 2 +- src/lib/platform/ImmuneKeysReader.h | 4 - src/lib/platform/MSWindowsClipboard.cpp | 6 +- src/lib/platform/MSWindowsClipboard.h | 4 +- .../MSWindowsClipboardAnyTextConverter.cpp | 4 +- .../platform/MSWindowsClipboardAnyTextConverter.h | 4 +- .../platform/MSWindowsClipboardBitmapConverter.cpp | 4 +- .../platform/MSWindowsClipboardBitmapConverter.h | 4 +- src/lib/platform/MSWindowsClipboardFacade.cpp | 4 +- src/lib/platform/MSWindowsClipboardFacade.h | 4 +- .../platform/MSWindowsClipboardHTMLConverter.cpp | 4 +- src/lib/platform/MSWindowsClipboardHTMLConverter.h | 4 +- .../platform/MSWindowsClipboardTextConverter.cpp | 4 +- src/lib/platform/MSWindowsClipboardTextConverter.h | 4 +- .../platform/MSWindowsClipboardUTF16Converter.cpp | 4 +- .../platform/MSWindowsClipboardUTF16Converter.h | 4 +- src/lib/platform/MSWindowsDebugOutputter.cpp | 4 +- src/lib/platform/MSWindowsDebugOutputter.h | 6 +- src/lib/platform/MSWindowsDesks.cpp | 25 +- src/lib/platform/MSWindowsDesks.h | 13 +- src/lib/platform/MSWindowsDropTarget.cpp | 10 +- src/lib/platform/MSWindowsDropTarget.h | 8 +- src/lib/platform/MSWindowsEventQueueBuffer.cpp | 4 +- src/lib/platform/MSWindowsEventQueueBuffer.h | 4 +- src/lib/platform/MSWindowsHook.cpp | 66 +- src/lib/platform/MSWindowsHook.h | 4 +- src/lib/platform/MSWindowsHookResource.cpp | 2 +- src/lib/platform/MSWindowsHookResource.h | 2 +- src/lib/platform/MSWindowsKeyState.cpp | 105 +- src/lib/platform/MSWindowsKeyState.h | 6 +- src/lib/platform/MSWindowsScreen.cpp | 92 +- src/lib/platform/MSWindowsScreen.h | 19 +- src/lib/platform/MSWindowsScreenSaver.cpp | 17 +- src/lib/platform/MSWindowsScreenSaver.h | 8 +- src/lib/platform/MSWindowsSession.cpp | 14 +- src/lib/platform/MSWindowsSession.h | 6 +- src/lib/platform/MSWindowsUtil.cpp | 4 +- src/lib/platform/MSWindowsUtil.h | 4 +- src/lib/platform/MSWindowsWatchdog.cpp | 60 +- src/lib/platform/MSWindowsWatchdog.h | 8 +- src/lib/platform/OSXClipboard.cpp | 14 +- src/lib/platform/OSXClipboard.h | 4 +- src/lib/platform/OSXClipboardAnyTextConverter.cpp | 4 +- src/lib/platform/OSXClipboardAnyTextConverter.h | 4 +- src/lib/platform/OSXClipboardHTMLConverter.cpp | 2 +- src/lib/platform/OSXClipboardTextConverter.cpp | 12 +- src/lib/platform/OSXClipboardTextConverter.h | 4 +- src/lib/platform/OSXClipboardUTF16Converter.cpp | 4 +- src/lib/platform/OSXClipboardUTF16Converter.h | 4 +- src/lib/platform/OSXDragSimulator.h | 2 +- src/lib/platform/OSXDragSimulator.m | 102 -- src/lib/platform/OSXDragSimulator.mm | 102 ++ src/lib/platform/OSXDragView.m | 177 --- src/lib/platform/OSXDragView.mm | 177 +++ src/lib/platform/OSXEventQueueBuffer.cpp | 18 +- src/lib/platform/OSXEventQueueBuffer.h | 4 +- src/lib/platform/OSXKeyState.cpp | 74 +- src/lib/platform/OSXKeyState.h | 8 +- src/lib/platform/OSXMediaKeySimulator.m | 92 -- src/lib/platform/OSXMediaKeySimulator.mm | 92 ++ src/lib/platform/OSXMediaKeySupport.m | 154 --- src/lib/platform/OSXMediaKeySupport.mm | 154 +++ src/lib/platform/OSXPasteboardPeeker.h | 2 +- src/lib/platform/OSXPasteboardPeeker.m | 37 - src/lib/platform/OSXPasteboardPeeker.mm | 37 + src/lib/platform/OSXScreen.h | 48 +- src/lib/platform/OSXScreen.mm | 218 ++-- src/lib/platform/OSXScreenSaver.cpp | 14 +- src/lib/platform/OSXScreenSaver.h | 8 +- src/lib/platform/OSXScreenSaverControl.h | 2 +- src/lib/platform/OSXScreenSaverUtil.h | 4 +- src/lib/platform/OSXScreenSaverUtil.m | 83 -- src/lib/platform/OSXScreenSaverUtil.mm | 83 ++ src/lib/platform/OSXUchrKeyResource.cpp | 4 +- src/lib/platform/OSXUchrKeyResource.h | 12 +- src/lib/platform/XWindowsClipboard.cpp | 8 +- src/lib/platform/XWindowsClipboard.h | 10 +- .../XWindowsClipboardAnyBitmapConverter.cpp | 4 +- .../platform/XWindowsClipboardAnyBitmapConverter.h | 4 +- src/lib/platform/XWindowsClipboardBMPConverter.cpp | 4 +- src/lib/platform/XWindowsClipboardBMPConverter.h | 4 +- .../platform/XWindowsClipboardHTMLConverter.cpp | 4 +- src/lib/platform/XWindowsClipboardHTMLConverter.h | 4 +- .../platform/XWindowsClipboardTextConverter.cpp | 4 +- src/lib/platform/XWindowsClipboardTextConverter.h | 4 +- .../platform/XWindowsClipboardUCS2Converter.cpp | 4 +- src/lib/platform/XWindowsClipboardUCS2Converter.h | 4 +- .../platform/XWindowsClipboardUTF8Converter.cpp | 4 +- src/lib/platform/XWindowsClipboardUTF8Converter.h | 4 +- src/lib/platform/XWindowsEventQueueBuffer.cpp | 8 +- src/lib/platform/XWindowsEventQueueBuffer.h | 10 +- src/lib/platform/XWindowsKeyState.cpp | 20 +- src/lib/platform/XWindowsKeyState.h | 24 +- src/lib/platform/XWindowsScreen.cpp | 12 +- src/lib/platform/XWindowsScreen.h | 10 +- src/lib/platform/XWindowsScreenSaver.cpp | 28 +- src/lib/platform/XWindowsScreenSaver.h | 12 +- src/lib/platform/XWindowsUtil.cpp | 49 +- src/lib/platform/XWindowsUtil.h | 12 +- src/lib/platform/synwinhk.h | 4 +- src/lib/server/BaseClientProxy.cpp | 4 +- src/lib/server/BaseClientProxy.h | 4 +- src/lib/server/CMakeLists.txt | 4 +- src/lib/server/ClientListener.cpp | 37 +- src/lib/server/ClientListener.h | 13 +- src/lib/server/ClientProxy.cpp | 4 +- src/lib/server/ClientProxy.h | 4 +- src/lib/server/ClientProxy1_0.cpp | 27 +- src/lib/server/ClientProxy1_0.h | 4 +- src/lib/server/ClientProxy1_1.cpp | 4 +- src/lib/server/ClientProxy1_1.h | 4 +- src/lib/server/ClientProxy1_2.cpp | 4 +- src/lib/server/ClientProxy1_2.h | 4 +- src/lib/server/ClientProxy1_3.cpp | 4 +- src/lib/server/ClientProxy1_3.h | 4 +- src/lib/server/ClientProxy1_4.cpp | 4 +- src/lib/server/ClientProxy1_4.h | 4 +- src/lib/server/ClientProxy1_5.cpp | 8 +- src/lib/server/ClientProxy1_5.h | 4 +- src/lib/server/ClientProxy1_6.cpp | 6 +- src/lib/server/ClientProxy1_6.h | 4 +- src/lib/server/ClientProxyUnknown.cpp | 10 +- src/lib/server/ClientProxyUnknown.h | 4 +- src/lib/server/Config.cpp | 38 +- src/lib/server/Config.h | 6 +- src/lib/server/InputFilter.cpp | 16 +- src/lib/server/InputFilter.h | 18 +- src/lib/server/PrimaryClient.cpp | 4 +- src/lib/server/PrimaryClient.h | 10 +- src/lib/server/Server.cpp | 32 +- src/lib/server/Server.h | 26 +- src/test/CMakeLists.txt | 33 - src/test/global/TestEventQueue.cpp | 6 +- src/test/global/TestEventQueue.h | 4 +- src/test/global/TestUtils.cpp | 37 + src/test/global/TestUtils.h | 30 + src/test/global/gmock.h | 4 +- src/test/global/gtest.h | 4 +- src/test/guitests/src/VersionCheckerTests.cpp | 4 +- src/test/guitests/src/VersionCheckerTests.h | 4 +- src/test/guitests/src/main.cpp | 4 +- src/test/integtests/CMakeLists.txt | 8 +- src/test/integtests/Main.cpp | 12 +- src/test/integtests/ipc/IpcTests.cpp | 21 +- src/test/integtests/net/NetworkTests.cpp | 79 +- .../platform/MSWindowsClipboardTests.cpp | 6 +- .../integtests/platform/MSWindowsKeyStateTests.cpp | 16 +- src/test/integtests/platform/OSXClipboardTests.cpp | 56 +- src/test/integtests/platform/OSXScreenTests.cpp | 4 +- .../integtests/platform/XWindowsClipboardTests.cpp | 44 +- .../integtests/platform/XWindowsKeyStateTests.cpp | 2 +- .../platform/XWindowsScreenSaverTests.cpp | 8 +- .../integtests/platform/XWindowsScreenTests.cpp | 8 +- src/test/mock/barrier/MockApp.h | 2 +- src/test/mock/barrier/MockArgParser.h | 2 +- src/test/mock/barrier/MockEventQueue.h | 4 +- src/test/mock/barrier/MockKeyState.h | 4 +- src/test/mock/barrier/MockScreen.h | 2 +- src/test/mock/ipc/MockIpcServer.h | 2 +- src/test/mock/server/MockConfig.h | 2 +- src/test/mock/server/MockInputFilter.h | 2 +- src/test/mock/server/MockPrimaryClient.h | 2 +- src/test/mock/server/MockServer.h | 2 +- src/test/unittests/CMakeLists.txt | 8 +- src/test/unittests/Main.cpp | 8 +- src/test/unittests/barrier/ArgParserTests.cpp | 4 +- .../unittests/barrier/ClientArgsParsingTests.cpp | 4 +- src/test/unittests/barrier/ClipboardChunkTests.cpp | 4 +- src/test/unittests/barrier/ClipboardTests.cpp | 16 +- .../unittests/barrier/GenericArgsParsingTests.cpp | 36 +- src/test/unittests/barrier/KeyMapTests.cpp | 42 +- src/test/unittests/barrier/KeyStateTests.cpp | 12 +- src/test/unittests/base/StringTests.cpp | 36 +- src/test/unittests/ipc/IpcLogOutputterTests.cpp | 20 +- .../unittests/net/FingerprintDatabaseTests.cpp | 95 ++ src/test/unittests/net/SecureUtilsTests.cpp | 73 ++ src/test/unittests/platform/OSXKeyStateTests.cpp | 12 +- 640 files changed, 8670 insertions(+), 6386 deletions(-) delete mode 100644 src/cmd/barrierc/barrierc.exe.manifest create mode 100644 src/cmd/barrierd/barrierd.ico create mode 100644 src/cmd/barrierd/barrierd.rc delete mode 100644 src/cmd/barriers/barriers.exe.manifest delete mode 100644 src/gui/gui.pro mode change 100644 => 100755 src/gui/langbuild.cmd delete mode 100644 src/gui/src/Fingerprint.cpp delete mode 100644 src/gui/src/Fingerprint.h create mode 100644 src/gui/src/FingerprintAcceptDialog.cpp create mode 100644 src/gui/src/FingerprintAcceptDialog.h create mode 100644 src/gui/src/FingerprintAcceptDialog.ui create mode 100644 src/gui/test/HotkeyTests.cpp create mode 100644 src/gui/test/KeySequenceTests.cpp create mode 100644 src/gui/test/Utils.h create mode 100644 src/gui/test/main.cpp delete mode 100644 src/lib/arch/vsnprintf.h create mode 100644 src/lib/barrier/BarrierType.h delete mode 100644 src/lib/base/FunctionJob.cpp delete mode 100644 src/lib/base/FunctionJob.h delete mode 100644 src/lib/base/TMethodJob.h create mode 100644 src/lib/base/finally.h delete mode 100644 src/lib/common/MacOSXPrecomp.h delete mode 100644 src/lib/common/PathUtilities.cpp delete mode 100644 src/lib/common/PathUtilities.h create mode 100644 src/lib/common/win32/encoding_utilities.cpp create mode 100644 src/lib/common/win32/encoding_utilities.h create mode 100644 src/lib/io/filesystem.cpp create mode 100644 src/lib/io/filesystem.h create mode 100644 src/lib/net/ConnectionSecurityLevel.h create mode 100644 src/lib/net/FingerprintData.cpp create mode 100644 src/lib/net/FingerprintData.h create mode 100644 src/lib/net/FingerprintDatabase.cpp create mode 100644 src/lib/net/FingerprintDatabase.h create mode 100644 src/lib/net/SecureUtils.cpp create mode 100644 src/lib/net/SecureUtils.h delete mode 100644 src/lib/platform/OSXDragSimulator.m create mode 100644 src/lib/platform/OSXDragSimulator.mm delete mode 100644 src/lib/platform/OSXDragView.m create mode 100644 src/lib/platform/OSXDragView.mm delete mode 100644 src/lib/platform/OSXMediaKeySimulator.m create mode 100644 src/lib/platform/OSXMediaKeySimulator.mm delete mode 100644 src/lib/platform/OSXMediaKeySupport.m create mode 100644 src/lib/platform/OSXMediaKeySupport.mm delete mode 100644 src/lib/platform/OSXPasteboardPeeker.m create mode 100644 src/lib/platform/OSXPasteboardPeeker.mm delete mode 100644 src/lib/platform/OSXScreenSaverUtil.m create mode 100644 src/lib/platform/OSXScreenSaverUtil.mm delete mode 100644 src/test/CMakeLists.txt create mode 100644 src/test/global/TestUtils.cpp create mode 100644 src/test/global/TestUtils.h create mode 100644 src/test/unittests/net/FingerprintDatabaseTests.cpp create mode 100644 src/test/unittests/net/SecureUtilsTests.cpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 55aad09..cc44fb2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2011 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 @@ -19,7 +19,13 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}/lib) add_subdirectory(lib) add_subdirectory(cmd) -add_subdirectory(test) + +include(../cmake/gtest.cmake) + +if (BARRIER_BUILD_TESTS) + add_subdirectory(test/integtests) + add_subdirectory(test/unittests) +endif() if (BARRIER_BUILD_GUI) add_subdirectory(gui) diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index ebf2a0d..946b19a 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2011 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 @@ -18,6 +18,5 @@ add_subdirectory(barrierc) add_subdirectory(barriers) if (WIN32) - add_subdirectory(barrierd) + add_subdirectory(barrierd) endif() - diff --git a/src/cmd/barrierc/CMakeLists.txt b/src/cmd/barrierc/CMakeLists.txt index 0c08550..45e9ab0 100644 --- a/src/cmd/barrierc/CMakeLists.txt +++ b/src/cmd/barrierc/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 @@ -21,16 +21,7 @@ set(sources if (WIN32) file(GLOB arch_headers "MSWindows*.h") file(GLOB arch_sources "MSWindows*.cpp") - list(APPEND sources - resource.h - barrierc.ico - barrierc.rc - tb_error.ico - tb_idle.ico - tb_run.ico - tb_wait.ico - barrierc.exe.manifest - ) + list(APPEND sources barrierc.rc) elseif (APPLE) file(GLOB arch_headers "OSX*.h") file(GLOB arch_sources "OSX*.cpp") @@ -55,4 +46,3 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") install (TARGETS barrierc DESTINATION bin) endif() - diff --git a/src/cmd/barrierc/MSWindowsClientTaskBarReceiver.cpp b/src/cmd/barrierc/MSWindowsClientTaskBarReceiver.cpp index 8d17900..dd2f59c 100644 --- a/src/cmd/barrierc/MSWindowsClientTaskBarReceiver.cpp +++ b/src/cmd/barrierc/MSWindowsClientTaskBarReceiver.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/cmd/barrierc/MSWindowsClientTaskBarReceiver.h b/src/cmd/barrierc/MSWindowsClientTaskBarReceiver.h index 91688e8..868b35b 100644 --- a/src/cmd/barrierc/MSWindowsClientTaskBarReceiver.h +++ b/src/cmd/barrierc/MSWindowsClientTaskBarReceiver.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/cmd/barrierc/OSXClientTaskBarReceiver.cpp b/src/cmd/barrierc/OSXClientTaskBarReceiver.cpp index 7e79991..e273f99 100644 --- a/src/cmd/barrierc/OSXClientTaskBarReceiver.cpp +++ b/src/cmd/barrierc/OSXClientTaskBarReceiver.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -66,4 +66,3 @@ createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events { return new OSXClientTaskBarReceiver(logBuffer, events); } - diff --git a/src/cmd/barrierc/OSXClientTaskBarReceiver.h b/src/cmd/barrierc/OSXClientTaskBarReceiver.h index fcc763a..59d5344 100644 --- a/src/cmd/barrierc/OSXClientTaskBarReceiver.h +++ b/src/cmd/barrierc/OSXClientTaskBarReceiver.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/cmd/barrierc/XWindowsClientTaskBarReceiver.cpp b/src/cmd/barrierc/XWindowsClientTaskBarReceiver.cpp index f56481c..f829ae0 100644 --- a/src/cmd/barrierc/XWindowsClientTaskBarReceiver.cpp +++ b/src/cmd/barrierc/XWindowsClientTaskBarReceiver.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/cmd/barrierc/XWindowsClientTaskBarReceiver.h b/src/cmd/barrierc/XWindowsClientTaskBarReceiver.h index 73250d0..c3db22e 100644 --- a/src/cmd/barrierc/XWindowsClientTaskBarReceiver.h +++ b/src/cmd/barrierc/XWindowsClientTaskBarReceiver.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/cmd/barrierc/barrierc.cpp b/src/cmd/barrierc/barrierc.cpp index 28d8efc..466a032 100644 --- a/src/cmd/barrierc/barrierc.cpp +++ b/src/cmd/barrierc/barrierc.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -32,13 +32,13 @@ #endif int -main(int argc, char** argv) +main(int argc, char** argv) { #if SYSAPI_WIN32 // record window instance for tray icon, etc ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL)); #endif - + Arch arch; arch.init(); diff --git a/src/cmd/barrierc/barrierc.exe.manifest b/src/cmd/barrierc/barrierc.exe.manifest deleted file mode 100644 index 2c6f365..0000000 --- a/src/cmd/barrierc/barrierc.exe.manifest +++ /dev/null @@ -1,2 +0,0 @@ - -PerMonitortrue \ No newline at end of file diff --git a/src/cmd/barrierc/barrierc.rc b/src/cmd/barrierc/barrierc.rc index b34127c..3000dcc 100644 --- a/src/cmd/barrierc/barrierc.rc +++ b/src/cmd/barrierc/barrierc.rc @@ -1,4 +1,4 @@ -//Microsoft Developer Studio generated resource script. +// Microsoft Visual C++ generated resource script. // #include "resource.h" @@ -8,9 +8,6 @@ // Generated from the TEXTINCLUDE 2 resource. // #include -#if !defined(IDC_STATIC) -#define IDC_STATIC (-1) -#endif ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -19,10 +16,8 @@ // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) -#endif //_WIN32 #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// @@ -30,18 +25,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // TEXTINCLUDE // -1 TEXTINCLUDE DISCARDABLE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE DISCARDABLE +2 TEXTINCLUDE BEGIN "#include \r\n" "\0" END -3 TEXTINCLUDE DISCARDABLE +3 TEXTINCLUDE BEGIN "\r\n" "\0" @@ -52,29 +47,56 @@ END ///////////////////////////////////////////////////////////////////////////// // -// Icon +// Version // -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_BARRIER ICON DISCARDABLE "barrierc.ico" -IDI_TASKBAR_NOT_RUNNING ICON DISCARDABLE "tb_idle.ico" -IDI_TASKBAR_NOT_WORKING ICON DISCARDABLE "tb_error.ico" -IDI_TASKBAR_NOT_CONNECTED ICON DISCARDABLE "tb_wait.ico" -IDI_TASKBAR_CONNECTED ICON DISCARDABLE "tb_run.ico" +VS_VERSION_INFO VERSIONINFO + FILEVERSION BARRIER_VERSION_MAJOR, BARRIER_VERSION_MINOR, BARRIER_VERSION_PATCH, BARRIER_BUILD_NUMBER + PRODUCTVERSION BARRIER_VERSION_MAJOR, BARRIER_VERSION_MINOR, BARRIER_VERSION_PATCH, BARRIER_BUILD_NUMBER + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Debauchee Open Source Group" + VALUE "CompanyWeb", "https://github.com/debauchee/barrier/" + VALUE "FileVersion", BARRIER_VERSION + VALUE "LegalCopyright", "Copyright (C) 2018 Debauchee Open Source Group\nCopyright (C) 2012-2016 Symless Ltd.\nCopyright (C) 2008-2014 Nick Bolton\nCopyright (C) 2002-2014 Chris Schoeneman" + VALUE "ProductName", "Barrier" + VALUE "ProductVersion", BARRIER_VERSION + VALUE "OriginalFilename", "barrierc.exe" + VALUE "FileDescription", "Open source KVM software client" + VALUE "InternalName", "barrierc" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + ///////////////////////////////////////////////////////////////////////////// // -// Dialog +// Icon // -IDD_TASKBAR_STATUS DIALOG DISCARDABLE 0, 0, 145, 18 -STYLE DS_MODALFRAME | WS_POPUP -FONT 8, "MS Sans Serif" -BEGIN - EDITTEXT IDC_TASKBAR_STATUS_STATUS,3,3,139,12,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER -END +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_BARRIER ICON "barrierc.ico" +IDI_TASKBAR_NOT_RUNNING ICON "tb_idle.ico" +IDI_TASKBAR_NOT_WORKING ICON "tb_error.ico" +IDI_TASKBAR_NOT_CONNECTED ICON "tb_wait.ico" +IDI_TASKBAR_CONNECTED ICON "tb_run.ico" ///////////////////////////////////////////////////////////////////////////// @@ -82,7 +104,7 @@ END // Menu // -IDR_TASKBAR MENU DISCARDABLE +IDR_TASKBAR MENU BEGIN POPUP "Barrier" BEGIN @@ -92,19 +114,12 @@ BEGIN POPUP "Set Log Level" BEGIN MENUITEM "Error", IDC_TASKBAR_LOG_LEVEL_ERROR - MENUITEM "Warning", IDC_TASKBAR_LOG_LEVEL_WARNING - MENUITEM "Note", IDC_TASKBAR_LOG_LEVEL_NOTE - MENUITEM "Info", IDC_TASKBAR_LOG_LEVEL_INFO - MENUITEM "Debug", IDC_TASKBAR_LOG_LEVEL_DEBUG - MENUITEM "Debug1", IDC_TASKBAR_LOG_LEVEL_DEBUG1 - MENUITEM "Debug2", IDC_TASKBAR_LOG_LEVEL_DEBUG2 - END MENUITEM SEPARATOR MENUITEM "Quit", IDC_TASKBAR_QUIT @@ -112,12 +127,26 @@ BEGIN END +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_TASKBAR_STATUS DIALOG 0, 0, 145, 18 +STYLE DS_MODALFRAME | WS_POPUP +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_TASKBAR_STATUS_STATUS,3,3,139,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER +END + + ///////////////////////////////////////////////////////////////////////////// // // String Table // -STRINGTABLE DISCARDABLE +STRINGTABLE BEGIN IDS_FAILED "Barrier is about to quit with errors or warnings. Please check the log then click OK." IDS_INIT_FAILED "Barrier failed to initialize: %{1}" diff --git a/src/cmd/barrierc/resource.h b/src/cmd/barrierc/resource.h index 57b271e..5603ba5 100644 --- a/src/cmd/barrierc/resource.h +++ b/src/cmd/barrierc/resource.h @@ -26,7 +26,7 @@ #define IDC_TASKBAR_LOG_LEVEL_DEBUG2 40015 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 109 diff --git a/src/cmd/barrierd/CMakeLists.txt b/src/cmd/barrierd/CMakeLists.txt index aeae94c..5c57882 100644 --- a/src/cmd/barrierd/CMakeLists.txt +++ b/src/cmd/barrierd/CMakeLists.txt @@ -16,6 +16,9 @@ file(GLOB headers "*.h") file(GLOB sources "*.cpp") +if (WIN32) + list(APPEND sources barrierd.rc) +endif() if (WIN32) add_executable (barrierd WIN32 ${sources}) diff --git a/src/cmd/barrierd/barrierd.cpp b/src/cmd/barrierd/barrierd.cpp index dd351f9..710e89d 100644 --- a/src/cmd/barrierd/barrierd.cpp +++ b/src/cmd/barrierd/barrierd.cpp @@ -2,11 +2,11 @@ * barrier -- 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 diff --git a/src/cmd/barrierd/barrierd.ico b/src/cmd/barrierd/barrierd.ico new file mode 100644 index 0000000..6e90545 Binary files /dev/null and b/src/cmd/barrierd/barrierd.ico differ diff --git a/src/cmd/barrierd/barrierd.rc b/src/cmd/barrierd/barrierd.rc new file mode 100644 index 0000000..c5ad502 --- /dev/null +++ b/src/cmd/barrierd/barrierd.rc @@ -0,0 +1,111 @@ +// Microsoft Visual C++ generated resource script. +// + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include \r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION BARRIER_VERSION_MAJOR, BARRIER_VERSION_MINOR, BARRIER_VERSION_PATCH, BARRIER_BUILD_NUMBER + PRODUCTVERSION BARRIER_VERSION_MAJOR, BARRIER_VERSION_MINOR, BARRIER_VERSION_PATCH, BARRIER_BUILD_NUMBER + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Debauchee Open Source Group" + VALUE "CompanyWeb", "https://github.com/debauchee/barrier/" + VALUE "FileVersion", BARRIER_VERSION + VALUE "LegalCopyright", "Copyright (C) 2018 Debauchee Open Source Group\nCopyright (C) 2012-2016 Symless Ltd.\nCopyright (C) 2008-2014 Nick Bolton\nCopyright (C) 2002-2014 Chris Schoeneman" + VALUE "ProductName", "Barrier" + VALUE "ProductVersion", BARRIER_VERSION + VALUE "OriginalFilename", "barrierd.exe" + VALUE "FileDescription", "Open source KVM software daemon" + VALUE "InternalName", "barrierd" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_BARRIER ICON "barrierd.ico" + + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/cmd/barriers/CMakeLists.txt b/src/cmd/barriers/CMakeLists.txt index 912421f..c9fa750 100644 --- a/src/cmd/barriers/CMakeLists.txt +++ b/src/cmd/barriers/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 @@ -21,16 +21,7 @@ set(sources if (WIN32) file(GLOB arch_headers "MSWindows*.h") file(GLOB arch_sources "MSWindows*.cpp") - list(APPEND sources - resource.h - barriers.ico - barriers.rc - tb_error.ico - tb_idle.ico - tb_run.ico - tb_wait.ico - barriers.exe.manifest - ) + list(APPEND sources barriers.rc) elseif (APPLE) file(GLOB arch_headers "OSX*.h") file(GLOB arch_sources "OSX*.cpp") @@ -55,5 +46,3 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") install (TARGETS barriers DESTINATION bin) endif() - - diff --git a/src/cmd/barriers/MSWindowsServerTaskBarReceiver.cpp b/src/cmd/barriers/MSWindowsServerTaskBarReceiver.cpp index a221dac..c86048a 100644 --- a/src/cmd/barriers/MSWindowsServerTaskBarReceiver.cpp +++ b/src/cmd/barriers/MSWindowsServerTaskBarReceiver.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/cmd/barriers/MSWindowsServerTaskBarReceiver.h b/src/cmd/barriers/MSWindowsServerTaskBarReceiver.h index a308ab4..c79a2b2 100644 --- a/src/cmd/barriers/MSWindowsServerTaskBarReceiver.h +++ b/src/cmd/barriers/MSWindowsServerTaskBarReceiver.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/cmd/barriers/OSXServerTaskBarReceiver.cpp b/src/cmd/barriers/OSXServerTaskBarReceiver.cpp index bbe8fd1..5fb525a 100644 --- a/src/cmd/barriers/OSXServerTaskBarReceiver.cpp +++ b/src/cmd/barriers/OSXServerTaskBarReceiver.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/cmd/barriers/OSXServerTaskBarReceiver.h b/src/cmd/barriers/OSXServerTaskBarReceiver.h index ab6928f..1ad4501 100644 --- a/src/cmd/barriers/OSXServerTaskBarReceiver.h +++ b/src/cmd/barriers/OSXServerTaskBarReceiver.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/cmd/barriers/XWindowsServerTaskBarReceiver.cpp b/src/cmd/barriers/XWindowsServerTaskBarReceiver.cpp index 7f525c5..6dfcdaa 100644 --- a/src/cmd/barriers/XWindowsServerTaskBarReceiver.cpp +++ b/src/cmd/barriers/XWindowsServerTaskBarReceiver.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/cmd/barriers/XWindowsServerTaskBarReceiver.h b/src/cmd/barriers/XWindowsServerTaskBarReceiver.h index 549a62f..ce56a3b 100644 --- a/src/cmd/barriers/XWindowsServerTaskBarReceiver.h +++ b/src/cmd/barriers/XWindowsServerTaskBarReceiver.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/cmd/barriers/barriers.cpp b/src/cmd/barriers/barriers.cpp index 21c4d80..169c5d3 100644 --- a/src/cmd/barriers/barriers.cpp +++ b/src/cmd/barriers/barriers.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -32,7 +32,7 @@ #endif int -main(int argc, char** argv) +main(int argc, char** argv) { #if SYSAPI_WIN32 // record window instance for tray icon, etc @@ -45,7 +45,7 @@ main(int argc, char** argv) */ setenv("OS_ACTIVITY_DT_MODE", "NO", true); #endif - + Arch arch; arch.init(); diff --git a/src/cmd/barriers/barriers.exe.manifest b/src/cmd/barriers/barriers.exe.manifest deleted file mode 100644 index 7309fde..0000000 --- a/src/cmd/barriers/barriers.exe.manifest +++ /dev/null @@ -1,2 +0,0 @@ - -true \ No newline at end of file diff --git a/src/cmd/barriers/barriers.rc b/src/cmd/barriers/barriers.rc index c4d263c..f9d8af1 100644 --- a/src/cmd/barriers/barriers.rc +++ b/src/cmd/barriers/barriers.rc @@ -16,10 +16,8 @@ // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) -#endif //_WIN32 #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// @@ -27,18 +25,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include \r\n" "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" @@ -47,6 +45,46 @@ END #endif // APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION BARRIER_VERSION_MAJOR, BARRIER_VERSION_MINOR, BARRIER_VERSION_PATCH, BARRIER_BUILD_NUMBER + PRODUCTVERSION BARRIER_VERSION_MAJOR, BARRIER_VERSION_MINOR, BARRIER_VERSION_PATCH, BARRIER_BUILD_NUMBER + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Debauchee Open Source Group" + VALUE "CompanyWeb", "https://github.com/debauchee/barrier/" + VALUE "FileVersion", BARRIER_VERSION + VALUE "LegalCopyright", "Copyright (C) 2018 Debauchee Open Source Group\nCopyright (C) 2012-2016 Symless Ltd.\nCopyright (C) 2008-2014 Nick Bolton\nCopyright (C) 2002-2014 Chris Schoeneman" + VALUE "ProductName", "Barrier" + VALUE "ProductVersion", BARRIER_VERSION + VALUE "OriginalFilename", "barriers.exe" + VALUE "FileDescription", "Open source KVM software server" + VALUE "InternalName", "barriers" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + ///////////////////////////////////////////////////////////////////////////// // // Icon @@ -54,18 +92,19 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -IDI_BARRIER ICON "barriers.ico" -IDI_TASKBAR_NOT_RUNNING ICON "tb_idle.ico" -IDI_TASKBAR_NOT_WORKING ICON "tb_error.ico" +IDI_BARRIER ICON "barriers.ico" +IDI_TASKBAR_NOT_RUNNING ICON "tb_idle.ico" +IDI_TASKBAR_NOT_WORKING ICON "tb_error.ico" IDI_TASKBAR_NOT_CONNECTED ICON "tb_wait.ico" -IDI_TASKBAR_CONNECTED ICON "tb_run.ico" +IDI_TASKBAR_CONNECTED ICON "tb_run.ico" + ///////////////////////////////////////////////////////////////////////////// // // Menu // -IDR_TASKBAR MENU +IDR_TASKBAR MENU BEGIN POPUP "Barrier" BEGIN @@ -110,7 +149,7 @@ END // String Table // -STRINGTABLE +STRINGTABLE BEGIN IDS_FAILED "Barrier is about to quit with errors or warnings. Please check the log then click OK." IDS_INIT_FAILED "Barrier failed to initialize: %{1}" diff --git a/src/cmd/barriers/resource.h b/src/cmd/barriers/resource.h index 9594db1..3ee57e7 100644 --- a/src/cmd/barriers/resource.h +++ b/src/cmd/barriers/resource.h @@ -31,7 +31,7 @@ #define ID_BARRIER_RESETSERVER 40017 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 109 diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index f29fd91..570e842 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -6,15 +6,124 @@ set (CMAKE_AUTORCC ON) set (CMAKE_AUTOUIC ON) set (CMAKE_INCLUDE_CURRENT_DIR ON) -file (GLOB GUI_SOURCE_FILES src/*.cpp src/*.h) -file (GLOB GUI_UI_FILES src/*.ui) +# files that are used both in tests and the app +set(GUI_COMMON_SOURCE_FILES + src/Action.cpp + src/Hotkey.cpp + src/KeySequence.cpp +) + +set(GUI_COMMON_HEADER_FILES + src/Action.h + src/Hotkey.h + src/KeySequence.h +) + +set(GUI_SOURCE_FILES + src/AboutDialog.cpp + src/ActionDialog.cpp + src/AddClientDialog.cpp + src/AppConfig.cpp + src/BarrierLocale.cpp + src/BaseConfig.cpp + src/CommandProcess.cpp + src/DataDownloader.cpp + src/DisplayIsValid.cpp + src/FingerprintAcceptDialog.cpp + src/HotkeyDialog.cpp + src/IpcClient.cpp + src/Ipc.cpp + src/IpcReader.cpp + src/KeySequenceWidget.cpp + src/LogWindow.cpp + src/main.cpp + src/MainWindow.cpp + src/NewScreenWidget.cpp + src/QBarrierApplication.cpp + src/QUtility.cpp + src/Screen.cpp + src/ScreenSettingsDialog.cpp + src/ScreenSetupModel.cpp + src/ScreenSetupView.cpp + src/ServerConfig.cpp + src/ServerConfigDialog.cpp + src/SettingsDialog.cpp + src/SetupWizard.cpp + src/SslCertificate.cpp + src/TrashScreenWidget.cpp + src/VersionChecker.cpp + src/ZeroconfBrowser.cpp + src/ZeroconfRegister.cpp + src/ZeroconfServer.cpp + src/ZeroconfService.cpp + src/ZeroconfThread.cpp +) + +set(GUI_HEADER_FILES + src/AboutDialog.h + src/ActionDialog.h + src/AddClientDialog.h + src/AppConfig.h + src/BarrierLocale.h + src/BaseConfig.h + src/CommandProcess.h + src/DataDownloader.h + src/DisplayIsValid.h + src/ElevateMode.h + src/HotkeyDialog.h + src/IpcClient.h + src/Ipc.h + src/IpcReader.h + src/KeySequenceWidget.h + src/LogWindow.h + src/MainWindow.h + src/NewScreenWidget.h + src/ProcessorArch.h + src/QBarrierApplication.h + src/QUtility.h + src/Screen.h + src/ScreenSettingsDialog.h + src/ScreenSetupModel.h + src/ScreenSetupView.h + src/ServerConfigDialog.h + src/ServerConfig.h + src/SettingsDialog.h + src/SetupWizard.h + src/ShutdownCh.h + src/SslCertificate.h + src/TrashScreenWidget.h + src/VersionChecker.h + src/ZeroconfBrowser.h + src/ZeroconfRecord.h + src/ZeroconfRegister.h + src/ZeroconfServer.h + src/ZeroconfService.h + src/ZeroconfThread.h +) + +set(GUI_UI_FILES + src/AboutDialogBase.ui + src/ActionDialogBase.ui + src/AddClientDialogBase.ui + src/FingerprintAcceptDialog.ui + src/HotkeyDialogBase.ui + src/LogWindowBase.ui + src/MainWindowBase.ui + src/ScreenSettingsDialogBase.ui + src/ServerConfigDialogBase.ui + src/SettingsDialogBase.ui + src/SetupWizardBase.ui +) if (WIN32) set (GUI_RC_FILES res/win/Barrier.rc) endif() add_executable (barrier WIN32 + ${GUI_COMMON_SOURCE_FILES} + ${GUI_COMMON_HEADER_FILES} ${GUI_SOURCE_FILES} + ${GUI_HEADER_FILES} ${GUI_UI_FILES} ${GUI_RC_FILES} res/Barrier.qrc @@ -22,13 +131,13 @@ add_executable (barrier WIN32 include_directories (./src) -target_link_libraries (barrier Qt5::Core Qt5::Widgets Qt5::Network) +target_link_libraries(barrier net base io Qt5::Core Qt5::Widgets Qt5::Network ${OPENSSL_LIBS}) target_compile_definitions (barrier PRIVATE -DBARRIER_VERSION_STAGE="${BARRIER_VERSION_STAGE}") target_compile_definitions (barrier PRIVATE -DBARRIER_REVISION="${BARRIER_REVISION}") if (WIN32) include_directories ($ENV{BONJOUR_SDK_HOME}/Include) - find_library (DNSSD_LIB dnssd.lib + find_library (DNSSD_LIB dnssd.lib HINTS ENV BONJOUR_SDK_HOME PATH_SUFFIXES "Lib/x64") set_target_properties (barrier PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT") @@ -51,3 +160,22 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "BSD") install (TARGETS barrier DESTINATION bin) endif() + +if (BARRIER_BUILD_TESTS) + set(GUI_TEST_SOURCE_FILES + test/KeySequenceTests.cpp + test/HotkeyTests.cpp + test/main.cpp + ) + + add_executable(guiunittests + ${GUI_TEST_SOURCE_FILES} + ${GUI_COMMON_SOURCE_FILES} + ${GUI_COMMON_HEADER_FILES} + ) + + add_test(guiunittests guiunittests) + + target_include_directories(guiunittests PUBLIC ../../ext) + target_link_libraries(guiunittests gtest gmock Qt5::Core Qt5::Widgets Qt5::Network ${libs}) +endif() diff --git a/src/gui/gui.pro b/src/gui/gui.pro deleted file mode 100644 index 14a2407..0000000 --- a/src/gui/gui.pro +++ /dev/null @@ -1,162 +0,0 @@ -QT += widgets \ - network -TEMPLATE = app -TARGET = barrier -DEFINES += VERSION_STAGE=\\\"$$QMAKE_VERSION_STAGE\\\" -DEFINES += VERSION_REVISION=\\\"$$QMAKE_VERSION_REVISION\\\" -DEFINES -= UNICODE -DEFINES += _MBCS -DEPENDPATH += . \ - res -INCLUDEPATH += . \ - src \ - ../lib/shared/ -FORMS += src/MainWindowBase.ui \ - src/AboutDialogBase.ui \ - src/ServerConfigDialogBase.ui \ - src/ScreenSettingsDialogBase.ui \ - src/ActionDialogBase.ui \ - src/HotkeyDialogBase.ui \ - src/SettingsDialogBase.ui \ - src/SetupWizardBase.ui \ - src/AddClientDialogBase.ui \ - src/ActivationDialog.ui \ - src/CancelActivationDialog.ui \ - src/FailedLoginDialog.ui -SOURCES += src/main.cpp \ - src/MainWindow.cpp \ - src/AboutDialog.cpp \ - src/ServerConfig.cpp \ - src/ServerConfigDialog.cpp \ - src/ScreenSetupView.cpp \ - src/Screen.cpp \ - src/ScreenSetupModel.cpp \ - src/NewScreenWidget.cpp \ - src/TrashScreenWidget.cpp \ - src/ScreenSettingsDialog.cpp \ - src/BaseConfig.cpp \ - src/HotkeyDialog.cpp \ - src/ActionDialog.cpp \ - src/Hotkey.cpp \ - src/Action.cpp \ - src/KeySequence.cpp \ - src/KeySequenceWidget.cpp \ - src/SettingsDialog.cpp \ - src/AppConfig.cpp \ - src/QBarrierApplication.cpp \ - src/VersionChecker.cpp \ - src/SetupWizard.cpp \ - src/IpcClient.cpp \ - src/IpcReader.cpp \ - src/Ipc.cpp \ - src/BarrierLocale.cpp \ - src/QUtility.cpp \ - src/ZeroconfServer.cpp \ - src/ZeroconfThread.cpp \ - src/ZeroconfRegister.cpp \ - src/ZeroconfBrowser.cpp \ - src/ZeroconfService.cpp \ - src/DataDownloader.cpp \ - src/AddClientDialog.cpp \ - src/CommandProcess.cpp \ - src/CoreInterface.cpp \ - src/Fingerprint.cpp \ - src/SslCertificate.cpp \ - src/WebClient.cpp \ - src/ActivationNotifier.cpp \ - src/ActivationDialog.cpp \ - src/CancelActivationDialog.cpp \ - src/FailedLoginDialog.cpp \ - ../lib/shared/SerialKey.cpp \ - src/LicenseManager.cpp -HEADERS += src/MainWindow.h \ - src/AboutDialog.h \ - src/ServerConfig.h \ - src/ServerConfigDialog.h \ - src/ScreenSetupView.h \ - src/Screen.h \ - src/ScreenSetupModel.h \ - src/NewScreenWidget.h \ - src/TrashScreenWidget.h \ - src/ScreenSettingsDialog.h \ - src/BaseConfig.h \ - src/HotkeyDialog.h \ - src/ActionDialog.h \ - src/Hotkey.h \ - src/Action.h \ - src/KeySequence.h \ - src/KeySequenceWidget.h \ - src/SettingsDialog.h \ - src/AppConfig.h \ - src/QBarrierApplication.h \ - src/VersionChecker.h \ - src/SetupWizard.h \ - src/IpcClient.h \ - src/IpcReader.h \ - src/Ipc.h \ - src/BarrierLocale.h \ - src/QUtility.h \ - src/ZeroconfServer.h \ - src/ZeroconfThread.h \ - src/ZeroconfRegister.h \ - src/ZeroconfRecord.h \ - src/ZeroconfBrowser.h \ - src/ZeroconfService.h \ - src/DataDownloader.h \ - src/AddClientDialog.h \ - src/CommandProcess.h \ - src/ProcessorArch.h \ - src/CoreInterface.h \ - src/Fingerprint.h \ - src/SslCertificate.h \ - src/WebClient.h \ - src/ActivationNotifier.h \ - src/ElevateMode.h \ - src/ActivationDialog.h \ - src/CancelActivationDialog.h \ - src/FailedLoginDialog.h \ - ../lib/shared/EditionType.h \ - ../lib/shared/SerialKey.h \ - src/LicenseManager.h -RESOURCES += res/Barrier.qrc -RC_FILE = res/win/Barrier.rc -macx { - QMAKE_INFO_PLIST = res/mac/Info.plist - TARGET = Barrier - QBARRIER_ICON.files = res/mac/Barrier.icns - QBARRIER_ICON.path = Contents/Resources - QMAKE_BUNDLE_DATA += QBARRIER_ICON - LIBS += $$MACX_LIBS -} -unix:!macx:LIBS += -ldns_sd -debug { - OBJECTS_DIR = tmp/debug - MOC_DIR = tmp/debug - RCC_DIR = tmp/debug -} -release { - OBJECTS_DIR = tmp/release - MOC_DIR = tmp/release - RCC_DIR = tmp/release -} -win32-msvc2015 { - LIBS += -lAdvapi32 - QMAKE_LFLAGS += /NODEFAULTLIB:LIBCMT -} -win32-msvc* { - contains(QMAKE_HOST.arch, x86):{ - QMAKE_LFLAGS *= /MACHINE:X86 - LIBS += -L"$$(BONJOUR_SDK_HOME)/Lib/Win32" -ldnssd - } - - contains(QMAKE_HOST.arch, x86_64):{ - QMAKE_LFLAGS *= /MACHINE:X64 - LIBS += -L"$$(BONJOUR_SDK_HOME)/Lib/x64" -ldnssd - } -} -win32 { - Debug:DESTDIR = ../../bin/Debug - Release:DESTDIR = ../../bin/Release - INCLUDEPATH += "$$(BONJOUR_SDK_HOME)/Include" -} -else:DESTDIR = ../../bin diff --git a/src/gui/gui.ts b/src/gui/gui.ts index 99bc7aa..308d41e 100644 --- a/src/gui/gui.ts +++ b/src/gui/gui.ts @@ -650,12 +650,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/lang.cmd b/src/gui/lang.cmd index 4418593..fbab95c 100644 --- a/src/gui/lang.cmd +++ b/src/gui/lang.cmd @@ -1 +1 @@ -lupdate -noobsolete gui.pro -ts gui.ts \ No newline at end of file +lupdate -noobsolete src/* -ts gui.ts diff --git a/src/gui/langbuild.cmd b/src/gui/langbuild.cmd old mode 100644 new mode 100755 index b86d202..aaeefbb --- a/src/gui/langbuild.cmd +++ b/src/gui/langbuild.cmd @@ -1,2 +1,2 @@ -cd res/lang -lrelease *.ts \ No newline at end of file +cd res/lang +lrelease *.ts diff --git a/src/gui/res/lang/Languages.xml b/src/gui/res/lang/Languages.xml index 5948f9c..723d667 100644 --- a/src/gui/res/lang/Languages.xml +++ b/src/gui/res/lang/Languages.xml @@ -1,46 +1,46 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/gui/res/lang/gui_af-ZA.ts b/src/gui/res/lang/gui_af-ZA.ts index 7ff6304..5e0121a 100644 --- a/src/gui/res/lang/gui_af-ZA.ts +++ b/src/gui/res/lang/gui_af-ZA.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_ar.ts b/src/gui/res/lang/gui_ar.ts index 84ae1e6..3882b6d 100644 --- a/src/gui/res/lang/gui_ar.ts +++ b/src/gui/res/lang/gui_ar.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_bg-BG.qm b/src/gui/res/lang/gui_bg-BG.qm index 013137d..7d02c13 100644 Binary files a/src/gui/res/lang/gui_bg-BG.qm and b/src/gui/res/lang/gui_bg-BG.qm differ diff --git a/src/gui/res/lang/gui_bg-BG.ts b/src/gui/res/lang/gui_bg-BG.ts index 6a373d8..ea45271 100644 --- a/src/gui/res/lang/gui_bg-BG.ts +++ b/src/gui/res/lang/gui_bg-BG.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Конфигурации на Синерджи (*.sgc);; Всички файлове (*.*) + All files (*.*) + Всички файлове (*.*) + + + + Barrier Configurations (*.sgc) + Конфигурации на Синерджи (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Конфигурации на Синерджи (*.conf);; Всички файлове (*.*) + Barrier Configurations (*.conf) + Конфигурации на Синерджи (*.conf) diff --git a/src/gui/res/lang/gui_ca-AD.qm b/src/gui/res/lang/gui_ca-AD.qm index 351c40d..755791b 100644 Binary files a/src/gui/res/lang/gui_ca-AD.qm and b/src/gui/res/lang/gui_ca-AD.qm differ diff --git a/src/gui/res/lang/gui_ca-AD.ts b/src/gui/res/lang/gui_ca-AD.ts index 34093d9..3cd7895 100644 --- a/src/gui/res/lang/gui_ca-AD.ts +++ b/src/gui/res/lang/gui_ca-AD.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Configuracions Barrier (*.sgc);;Tots els arxius (*.*) + All files (*.*) + Tots els arxius (*.*) + + + + Barrier Configurations (*.sgc) + Configuracions Barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Configuracions Barrier (*.conf);;Tots els arxius (*.*) + Barrier Configurations (*.conf) + Configuracions Barrier (*.conf) @@ -900,8 +905,8 @@ To automatically trust this fingerprint for future connections, click Yes. To re Drag new screens to the grid or move existing ones around. Drag a screen to the trashcan to delete it. Double click on a screen to edit its settings. - Arrossega noves pantalles a la graella o mou les actuals al voltant. -Arrossega una pantalla a la paperera per eliminar-la. + Arrossega noves pantalles a la graella o mou les actuals al voltant. +Arrossega una pantalla a la paperera per eliminar-la. Fes doble clic a una pantalla per editar la seva configuració. @@ -1330,7 +1335,7 @@ p, li { white-space: pre-wrap; } Server response: %1 - Error inici de sessió, hi ha hagut un error. + Error inici de sessió, hi ha hagut un error. Resposta del servidor: %1 diff --git a/src/gui/res/lang/gui_cs-CZ.qm b/src/gui/res/lang/gui_cs-CZ.qm index 1ac02c8..23ed7bd 100644 Binary files a/src/gui/res/lang/gui_cs-CZ.qm and b/src/gui/res/lang/gui_cs-CZ.qm differ diff --git a/src/gui/res/lang/gui_cs-CZ.ts b/src/gui/res/lang/gui_cs-CZ.ts index fd7b9c7..16142bf 100644 --- a/src/gui/res/lang/gui_cs-CZ.ts +++ b/src/gui/res/lang/gui_cs-CZ.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Nastavení Barrier (*.sgc);;Všechny soubory (*.*) + All files (*.*) + Všechny soubory (*.*) + + + + Barrier Configurations (*.sgc) + Nastavení Barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Nastavení Barrier (*.conf);;Všechny soubory (*.*) + Barrier Configurations (*.conf) + Nastavení Barrier (*.conf) diff --git a/src/gui/res/lang/gui_cy.qm b/src/gui/res/lang/gui_cy.qm index 87bc58c..0cdb24d 100644 Binary files a/src/gui/res/lang/gui_cy.qm and b/src/gui/res/lang/gui_cy.qm differ diff --git a/src/gui/res/lang/gui_cy.ts b/src/gui/res/lang/gui_cy.ts index be9cd1d..2478fee 100644 --- a/src/gui/res/lang/gui_cy.ts +++ b/src/gui/res/lang/gui_cy.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Cyfluniadau Barrier (*.sgc);;Pob ffeil (*.*) + All files (*.*) + Pob ffeil (*.*) + + + + Barrier Configurations (*.sgc) + Cyfluniadau Barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Cyfluniadau Barrier (*.conf);;Pob ffeil (*.*) + Barrier Configurations (*.conf) + Cyfluniadau Barrier (*.conf) diff --git a/src/gui/res/lang/gui_da.qm b/src/gui/res/lang/gui_da.qm index f78dbb7..dc7812b 100644 Binary files a/src/gui/res/lang/gui_da.qm and b/src/gui/res/lang/gui_da.qm differ diff --git a/src/gui/res/lang/gui_da.ts b/src/gui/res/lang/gui_da.ts index 2b17c0b..7bec518 100644 --- a/src/gui/res/lang/gui_da.ts +++ b/src/gui/res/lang/gui_da.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Barrier-konfigurationer (*.sgc);;Alle filer (*.*) + All files (*.*) + Alle filer (*.*) + + + + Barrier Configurations (*.sgc) + Barrier-konfigurationer (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Barrier-konfigurationer (*.conf);;Alle filer (*.*) + Barrier Configurations (*.conf) + Barrier-konfigurationer (*.conf) @@ -1329,7 +1334,7 @@ p, li { white-space: pre-wrap; } Server response: %1 - Fejl i login, en fejl opstod. + Fejl i login, en fejl opstod. Server svar: %1 diff --git a/src/gui/res/lang/gui_de.qm b/src/gui/res/lang/gui_de.qm index eb0bb40..2e4f300 100644 Binary files a/src/gui/res/lang/gui_de.qm and b/src/gui/res/lang/gui_de.qm differ diff --git a/src/gui/res/lang/gui_de.ts b/src/gui/res/lang/gui_de.ts index 67eb994..f43ee39 100644 --- a/src/gui/res/lang/gui_de.ts +++ b/src/gui/res/lang/gui_de.ts @@ -1,12 +1,14 @@ - + + + AboutDialogBase About Barrier - Über Barrier + Über Barrier - + <p> Keyboard and mouse sharing application. Cross platform and open source.<br /><br /> @@ -26,22 +28,30 @@ Barrier is based on CosmoSynergy by Richard Lee and Adam Feder.<br /> The Barrier GUI is based on QSynergy by Volker Lanz.<br /><br /> Visit our website for help and info (symless.com). </p> - + <p> +Anwendung zum Teilen von Tastatur und Maus. Betriebssystemübergreifend und Open Source.<br /><br /> +Copyright © 2012-2016 Symless Ltd.<br /> +Copyright © 2002-2012 Chris Schoeneman, Nick Bolton, Volker Lanz.<br /><br /> +Barrier wird herausgegeben unter der GNU General Public License (GPLv2).<br /><br /> +Barrier basiert auf CosmoSynergy von Richard Lee und Adam Feder.<br /> +Die Barrier-GUI basiert auf QSynergy von Volker Lanz.<br /><br /> +Besuchen Sie unsere Website für Hilfe und Info (symless.com). +</p> Unknown - Unbekannt + Unbekannt Version: - Version: + Version: &Ok - &Ok + &Ok @@ -49,97 +59,97 @@ Visit our website for help and info (symless.com). Configure Action - Aktion konfigurieren + Aktion konfigurieren Choose the action to perform - Wähle eine Aktion, die ausgeführt werden soll + Wähle eine Aktion, die ausgeführt werden soll Press a hotkey - Hotkey drücken + Hotkey drücken Release a hotkey - Hotkey loslassen + Hotkey loslassen Press and release a hotkey - Hotkey drücken und loslassen + Hotkey drücken und loslassen only on these screens - Nur auf diesen Bildschirmen + nur auf diesen Bildschirmen Switch to screen - Zu Anzeige Wechseln + Zum Bildschirm wechseln Switch in direction - In Richtung wechseln + In Richtung wechseln left - links + links right - rechts + rechts up - hoch + hoch down - runter + runter Lock cursor to screen - Cursor auf Anzeige beschränken + Cursor auf Bildschirm beschränken toggle - umschalten + umschalten on - ein + ein off - aus + aus This action is performed when - Diese Aktion wird ausgeführt, wenn + Diese Aktion wird ausgeführt, wenn the hotkey is pressed - wenn der Hotkey gedrückt wird + wenn der Hotkey gedrückt wird the hotkey is released - wenn der Hotkey losgelassen wird + wenn der Hotkey losgelassen wird @@ -147,17 +157,17 @@ Visit our website for help and info (symless.com). Dialog - + Dialog TextLabel - + TextLabel Ignore auto connect clients - + Autoconnect-Clients ignorieren @@ -165,12 +175,12 @@ Visit our website for help and info (symless.com). Hotkey - Hotkey + Hotkey Enter the specification for the hotkey: - Gib die Definition für den Hotkey ein: + Definition für den Hotkey eingeben: @@ -178,189 +188,193 @@ Visit our website for help and info (symless.com). &Start - &Start + &Start &File - &Datei + &Datei &Edit - &Bearbeiten + &Bearbeiten &Window - &Fenster + &Fenster &Help - &Hilfe + &Hilfe <p>Your version of Barrier is out of date. Version <b>%1</b> is now available to <a href="%2">download</a>.</p> <p>Version %1 is now available, <a href="%2">visit website</a>.</p> - <p>Ihre Barrier Version ist veraltet. Version <b>%1</b> ist jetzt zum <a href="%2">Download</a> verfügbar.</p> + <p>Ihre Barrier-Version ist veraltet. Version <b>%1</b> ist jetzt zum <a href="%2">Download</a> verfügbar.</p> Program can not be started - Das Programm konnte nicht gestartet werden + Programm konnte nicht gestartet werden The executable<br><br>%1<br><br>could not be successfully started, although it does exist. Please check if you have sufficient permissions to run this program. - Die Anwendung<br><br>%1<br><br> konnte nicht gestartet werden, obwohl sie vorhanden ist. Bitte überprüfen sie, ob sie die benötigten Berechtigungen zur Ausführung der Anwendung haben, + Die Anwendung<br><br>%1<br><br> konnte nicht gestartet werden, obwohl sie vorhanden ist. Bitte überprüfen Sie, ob Sie ausreichende Rechte zur Ausführung der Anwendung haben. Barrier client not found - Der Barrier Client wurde nicht gefunden + Barrier-Client wurde nicht gefunden The executable for the barrier client does not exist. - Die ausführbare Datei für den Barrier Client existiert nicht. + Die Anwendung für den Barrier-Client existiert nicht. Hostname is empty - Der Hostname is leer + Hostname ist leer Please fill in a hostname for the barrier client to connect to. - Bitte tragen Sie einen Hostnamen ein, zu dem sich der Barrier-Client verbinden soll. + Bitte tragen Sie einen Hostnamen ein, zu dem sich der Barrier-Client verbinden soll. Cannot write configuration file - Konfigurationsdatei konnte nicht geschrieben werden + Konfigurationsdatei konnte nicht geschrieben werden The temporary configuration file required to start barrier can not be written. - Die temporäre Konfigurationsdatei konnte nicht geschrieben werden. Sie wird jedoch für den Start von Barrier benötigt. + Die für den Start von Barrier nötige temporäre Konfigurationsdatei kann nicht geschrieben werden. Configuration filename invalid - Der Dateiname der Konfigurationsdatei ist ungültig. + Dateiname der Konfigurationsdatei ungültig You have not filled in a valid configuration file for the barrier server. Do you want to browse for the configuration file now? - Sie haben keine gültige Konfigurationsdatei angegeben. Wollen sie jetzt nach dieser Datei suchen? + Sie haben keine gültige Konfigurationsdatei für den Barrier-Server angegeben. Wollen sie jetzt nach dieser Datei suchen? Barrier server not found - Der Barrier Server wurde nicht gefunden. + Barrier-Server nicht gefunden The executable for the barrier server does not exist. - Die ausführbare Datei für den Barrier Server existiert nicht. + Die Anwendung für den Barrier-Server existiert nicht. Barrier terminated with an error - Barrier wurde mit einem Fehler beendet. + Barrier mit Fehler beendet Barrier terminated unexpectedly with an exit code of %1.<br><br>Please see the log output for details. - Barrier wurde unerwartet mit Abbruchcode %1 beendet. <br><br> Weitere Informationen können dem Log entnommen werden. + Barrier unerwartet mit Exit-Code %1 beendet. <br><br>Siehe Logausgabe für weitere Details. &Stop - &Stopp + &Stop Please add the server (%1) to the grid. - + Bitte Server (%1) zum Gitter hinzufügen. Please drag the new client screen (%1) to the desired position on the grid. - + Bitte den Bildschirm des neuen Clients zur gewünschten Position auf dem Gitter ziehen. Failed to detect system architecture. - + System-Architektur konnte nicht ermittelt werden. Cancel - + Abbrechen Failed to download Bonjour installer to location: %1 - + Bonjour-Installer konnte nicht heruntergeladen werden nach: %1 Do you want to enable auto config and install Bonjour? This feature helps you establish the connection. - + Möchten Sie Bonjour installieren, um Autoconfig zu aktivieren? + +Diese Funktion hilft Ihnen beim Verbindungsaufbau. Auto config feature requires Bonjour. Do you want to install Bonjour? - + Für die Autoconfig-Funktion ist Bonjour nötig. + +Möchten Sie Bonjour installieren? Barrier is starting. - Barrier wird gestartet. + Barrier startet. Barrier is running. - Barrier läuft. + Barrier läuft. Barrier is not running. - Barrier wird nicht ausgeführt. + Barrier läuft nicht. Unknown - Unbekannt + Unbekannt Barrier - Barrier + Barrier Browse for a barriers config file - Nach einer Konfigurationsdatei für Barrier suchen. + Nach einer Konfigurationsdatei für Barrier suchen Barrier is now connected, You can close the config window. Barrier will remain connected in the background. - + Barrier ist jetzt verbunden. Sie können das Konfigurationsfenster schließen. Barrier wird im Hintergrund verbunden bleiben. Security question - + Sicherheitsfrage @@ -368,25 +382,31 @@ Do you want to install Bonjour? %1 -This is a server fingerprint. You should compare this fingerprint to the one on your server's screen. If the two don't match exactly, then it's probably not the server you're expecting (it could be a malicious user). +This is a server fingerprint. You should compare this fingerprint to the one on your server's screen. If the two don't match exactly, then it's probably not the server you're expecting (it could be a malicious user). To automatically trust this fingerprint for future connections, click Yes. To reject this fingerprint and disconnect from the server, click No. - + Vertrauen Sie diesem Fingerabdruck? + +%1 + +Dies ist ein Server-Fingerabdruck. Sie sollten ihn mit dem Fingerabdruck auf dem Server-Bildschirm vergleichen. Wenn die zwei nicht identisch sind, handelt es sich wahrscheinlich nicht um den erwarteten Server (es könnte ein böswilliger User sein). + +Um diesem Fingerabdruck bei zukünftigen Verbindeungen automatisch zu vertrauen, klicken Sie auf Ja. Um diesen Fingerabdruck abzulehnen und die Verbindung vom Server zu trennen, klicken Sie auf Nein. Save configuration as... - Konfiguration speichern unter ... + Konfiguration speichern unter ... Save failed - Speichern fehlgeschlagen + Speichern fehlgeschlagen Could not save configuration to file. - Konfiguration konnte nicht in Datei gespeichert werden + Konfiguration konnte nicht in Datei gespeichert werden @@ -394,168 +414,168 @@ To automatically trust this fingerprint for future connections, click Yes. To re Barrier - Barrier + Barrier - Ser&ver (share this computer's mouse and keyboard): - + Ser&ver (share this computer's mouse and keyboard): + Ser&ver (Maus und Tastatur dieses Rechners teilen): Screen name: - Anzeigename: + Bildschirmname: &Server IP: - Server IP: + &Server IP: &Start - &Start + &Start Use existing configuration: - Verwende bestehende Konfiguration: + Verwende bestehende Konfiguration: &Configuration file: - &Konfigurationsdatei: + &Konfigurationsdatei: &Browse... - &Durchsuchen... + &Durchsuchen ... Configure interactively: - Interaktiv konfigurieren: + Interaktiv konfigurieren: &Configure Server... - Server &konfigurieren... + Server &konfigurieren ... Ready - Fertig + Bereit Log - Log + Log &Reload - &Anwenden + &Neu laden IP addresses: - IP Adressen: + IP-Adressen: Fingerprint: - + Fingerabdruck: - &Client (use another computer's mouse and keyboard): - + &Client (use another computer's mouse and keyboard): + &Client (Maus und Tastatur eines anderen Rechners benutzen): Auto config - + Autoconfig &About Barrier... - &Über Barrier... + &Über Barrier ... &Quit - &Beenden + &Beenden Quit - Beenden + Beenden Run - Start + Start S&top - S&topp + S&top Stop - Stop + Stop S&how Status - S&tatus anzeigen + S&tatus anzeigen &Hide - &Verstecken + &Verstecken Hide - Verstecken + Verstecken &Show - &Zeigen + An&zeigen Show - Anzeigen + Anzeigen Save configuration &as... - Configuration speichern &unter ... + Konfiguration speichern &unter ... Save the interactively generated server configuration to a file. - Speichere die interaktiv erstellte Konfiguration in eine Datei. + Speichere die interaktiv erstellte Konfiguration in eine Datei. Settings - Einstellungen + Einstellungen Edit settings - Einstellungen bearbeiten + Einstellungen bearbeiten Run Wizard - Assistent ausführen + Assistent ausführen @@ -563,7 +583,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Unnamed - Unbenannt + Unbenannt @@ -571,28 +591,29 @@ To automatically trust this fingerprint for future connections, click Yes. To re Failed to get plugin directory. - + Plugin-Verzeichnis konnte nicht ermittelt werden. Failed to get profile directory. - + Profil-Verzeichnis konnte nicht ermittelt werden. - Failed to download plugin '%1' to: %2 + Failed to download plugin '%1' to: %2 %3 - + Plugin '%1' konnte nicht runtergeladen werden nach: %2 +%3 Could not get Windows architecture type. - + Art der Windows-Architektur konnte nicht ermittelt werden. Could not get Linux architecture type. - + Art der Linux-Architektur konnte nicht ermittelt werden. @@ -600,66 +621,71 @@ To automatically trust this fingerprint for future connections, click Yes. To re Setup Barrier - Barrier einrichten + Barrier einrichten Please wait... - + Bitte warten ... Error: %1 - + Fehler: %1 Setup complete. - + Einrichtung abgeschlossen. - Downloading '%1' plugin (%2/%3)... - + Downloading '%1' plugin (%2/%3)... + Lade Plugin '%1' herunter (%2/%3) ... Plugins installed successfully. - + Plugins erfolgreich installiert. Generating SSL certificate... - + Erzeuge SSL-Zertifikat ... Downloading plugin: %1 (1/%2) - + Lade Plugin herunter: %1 (1/%2) Getting plugin list... - + Ermittle Plugin-Liste ... QObject - Barrier Configurations (*.sgc);;All files (*.*) - Barrier Konfigurationen (*.sgc);;Alle Dateien (*.*) + All files (*.*) + Alle Dateien (*.*) + + + + Barrier Configurations (*.sgc) + Barrier-Konfigurationen (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Barrier Konfigurationen (*.conf);;Alle Dateien (*.*) + Barrier Configurations (*.conf) + Barrier-Konfigurationen (*.conf) System tray is unavailable, quitting. - Infobereich ist nicht verfügbar. Beende Programm. + Systemabschnitt ist nicht verfügbar, beende. @@ -667,22 +693,22 @@ To automatically trust this fingerprint for future connections, click Yes. To re Screen name is empty - Der Anzeigename ist leer + Bildschirmname ist leer The screen name cannot be empty. Please either fill in a name or cancel the dialog. - Der Bildschirmname darf nicht leer sein. Bitte trage einen Namen ein oder schließe das Fenster. + Der Bildschirmname darf nicht leer sein. Bitte einen Namen eintragen oder das Dialogfenster abbrechen. Screen name matches alias - Der Anzeigename passt zum Alias + Bildschirmname passt zum Alias The screen name cannot be the same as an alias. Please either remove the alias or change the screen name. - Der Anzeigename kann nicht derselbe sein wie der Alias. Bitte entfernen sie den Alias oder ändern sie den Anzeigenamen. + Der Bildschirmname kann nicht derselbe sein wie ein Alias. Bitte entfernen sie den Alias oder ändern sie den Bildschirmnamen. @@ -690,37 +716,37 @@ To automatically trust this fingerprint for future connections, click Yes. To re Screen Settings - Anzeigeeinstellungen + Bildschirmeinstellungen Screen &name: - Anzeige&name: + Bildschirm&name: A&liases - A&liase + A&liase &Add - &Hinzufügen + &Hinzufügen &Remove - &Entfernen + &Entfernen &Modifier keys - &Zusatztasten + &Zusatztasten &Shift: - Um&schalt: + Um&schalt: @@ -729,7 +755,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Shift - Umschalt + Umschalt @@ -738,7 +764,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Ctrl - Strg + Strg @@ -747,7 +773,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Alt - Alt + Alt @@ -756,7 +782,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Meta - Meta + Meta @@ -765,7 +791,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Super - Windows + Windows @@ -774,82 +800,82 @@ To automatically trust this fingerprint for future connections, click Yes. To re None - Keine + Keine &Ctrl: - &Strg: + &Strg: Al&t: - Al&t: + Al&t: M&eta: - M&eta: + M&eta: S&uper: - S&uper: + S&uper: &Dead corners - "&Tote" Ecken + "&Tote" Ecken Top-left - Oben-links + Oben links Top-right - Oben-rechts + Oben rechts Bottom-left - Unten-links + Unten links Bottom-right - Unten-rechts + Unten rechts Corner Si&ze: - &Größe: + Ecken&größe: &Fixes - &Korrekturen + &Korrekturen Fix CAPS LOCK key - Korrektur für Feststelltaste + Korrektur für Feststelltaste Fix NUM LOCK key - Korrektur für Num Lock + Korrektur für Num-Lock-Taste Fix SCROLL LOCK key - Korrektur für Scroll Lock + Korrektur für Rollen-Taste Fix XTest for Xinerama - Korrektur für XTest mit Xinerama + Korrektur für XTest für Xinerama @@ -857,7 +883,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re <center>Screen: <b>%1</b></center><br>Double click to edit settings<br>Drag screen to the trashcan to remove it - <center>Anzeige: <b>%1</b></center><br>Klicken Sie doppelt um die Einstellungen zu ändern<br>Ziehen Sie die Anzeige in den Papierkorb um sie zu entfernen + <center>Bildschirm: <b>%1</b></center><br>Doppelklick, um die Einstellungen zu ändern<br>Bildschirm in den Papierkorb ziehen, um ihn zu entfernen @@ -865,7 +891,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Configure server - + Server konfigurieren @@ -873,168 +899,168 @@ To automatically trust this fingerprint for future connections, click Yes. To re Server Configuration - Server Konfiguration + Server-Konfiguration Screens and links - Anzeigen und Verbindungen + Bildschirme und Verbindungen Drag a screen from the grid to the trashcan to remove it. - Ziehen Sie eine Anzeige vom Raster in den Papierkorb um sie zu entfernen. + Ziehen Sie einen Bildschirm auf dem Gitter in den Papierkorb, um ihn zu entfernen. Configure the layout of your barrier server configuration. - Konfigurieren Sie die Anordnung Ihrer Barrier Server Konfiguration. + Konfigurieren Sie die Anordnung Ihrer Barrier-Server-Konfiguration. Drag this button to the grid to add a new screen. - Ziehen diese Symbol auf das Raster um eine neue Anzeige hinzuzufügen. + Ziehen Sie dieses Symbol auf das Gitter, um einen neuen Bildschirm hinzuzufügen. Drag new screens to the grid or move existing ones around. Drag a screen to the trashcan to delete it. Double click on a screen to edit its settings. - Ziehen Sie neue Anzeigen auf das Raster oder verschieben sie existierende. -Ziehen Sie eine Anzeige in den Papierkorb um sie zu entfernen. -Klicken sie doppelt auf eine Anzeige um die Einstellungen zu bearbeiten. + Ziehen Sie neue Bildschirme auf das Gitter oder verschieben sie existierende. +Ziehen Sie einen Bildschirm in den Papierkorb, um ihn zu entfernen. +Klicken Sie doppelt auf einen Bildschirm, um dessen Einstellungen zu bearbeiten. Hotkeys - Hotkeys + Hotkeys &Hotkeys - &Hotkeys + &Hotkeys &New - &Neu + &Neu &Edit - &Bearbeiten + &Bearbeiten &Remove - &Entfernen + &Entfernen A&ctions - &Befehle + &Befehle Ne&w - Ne&u + Ne&u E&dit - Än&dern + Än&dern Re&move - &Entfernen + &Entfernen Advanced server settings - Erwiterte Servereinstellungen + Erweiterte Server-Einstellungen &Switch - Wech&sel + Wech&seln Switch &after waiting - Wechsel n&ach Wartezeit + Wechseln n&ach Wartezeit ms - ms + ms Switch on double &tap within - Wechsel nach doppel&ter Randberührung innerhalb von + Wechsel nach doppel&ter Randberührung innerhalb von &Options - &Optionen + &Optionen &Check clients every - Prüfe auf Meldungen vom &Client aller + Prüfe &Clients alle Use &relative mouse moves - Ve&rwende relative Mausbewegungen + Ve&rwende relative Mausbewegungen S&ynchronize screen savers - Bildschirmschoner s&ynchronisieren + Bildschirmschoner s&ynchronisieren - Don't take &foreground window on Windows servers - Auf Windows Servern &Fenster im Vordergrund nicht aktivieren + Don't take &foreground window on Windows servers + Auf Windows-Servern &Fenster im Vordergrund nicht aktivieren Ignore auto config clients - + Ignoriere Autoconfig-Clients &Dead corners - "&Tote" Ecken + "&Tote" Ecken To&p-left - O&ben-links + O&ben links Top-rig&ht - Oben-rec&hts + Oben rec&hts &Bottom-left - &Unten-links + &Unten links Bottom-ri&ght - Unten-rec&hts + Unten rec&hts Cor&ner Size: - &Größe: + Ecken&größe: @@ -1042,20 +1068,20 @@ Klicken sie doppelt auf eine Anzeige um die Einstellungen zu bearbeiten. Save log file to... - Speicherort des Logfiles + Logfile speichern nach ... Elevate Barrier - Barrier Befördern + Barrier als Admin ausführen Are you sure you want to elevate Barrier? This allows Barrier to interact with elevated processes and the UAC dialog, but can cause problems with non-elevated processes. Elevate Barrier only if you really need to. - Sind Sie sicher das Sie Barrier Erweiterte Benutzerrechte einräumen wollen? -Das erlaubt Barrier mit Prozessen die höhere Rechte haben und dem UAC-Dialog zu interagieren, kann aber bei normalen Prozessen Probleme verursachen. Erweiterte Rechte an Barrier bitte nur vergeben wenn es unbedingt nötig ist. + Sind Sie sicher, dass Sie Barrier erweiterte Benutzerrechte einräumen wollen? +Das erlaubt Barrier, mit Prozessen, die höhere Rechte haben, und dem UAC-Dialog zu interagieren, kann aber bei normalen Prozessen Probleme verursachen. Erweiterte Rechte an Barrier bitte nur vergeben, wenn es unbedingt nötig ist. @@ -1063,107 +1089,107 @@ Das erlaubt Barrier mit Prozessen die höhere Rechte haben und dem UAC-Dialog zu Settings - Einstellungen + Einstellungen Sc&reen name: - &Anzeigename: + &Bildschirmname: P&ort: - P&ort: + P&ort: &Interface: - Schn&ittstelle + Schn&ittstelle Elevate mode - + Admin-Modus &Hide on startup - + Beim Starten &verstecken &Network Security - + &Netzwerksicherheit Use &SSL encryption (unique certificate) - + Verwende &SSL-Verschlüsselung (eindeutiges Zertifikat) Logging - Protokollierung + Protokollierung &Logging level: - &Umfang: + &Umfang: Log to file: - In Datei: + Protokolliere in Datei: Browse... - Durchsuchen... + Durchsuchen ... Error - Fehler + Fehler &Language: - Sprache: + Sprache: &Miscellaneous - &Sonstiges + &Sonstiges Warning - Warnung + Warnung Note - Hinweis + Hinweis Info - Info + Info Debug - Debug + Debug Debug1 - Debug1 + Debug1 Debug2 - Debug2 + Debug2 @@ -1171,17 +1197,17 @@ Das erlaubt Barrier mit Prozessen die höhere Rechte haben und dem UAC-Dialog zu Setup Barrier - Barrier einrichten + Barrier einrichten Please select an option. - Bitte wählen Sie eine option aus. + Bitte wählen Sie eine Option aus. Please enter your email address and password. - Bitte geben Sie Ihre E-Mail Adresse und Ihr Passwort ein. + Bitte geben Sie Ihre E-Mail-Adresse und Ihr Passwort ein. @@ -1189,85 +1215,93 @@ Das erlaubt Barrier mit Prozessen die höhere Rechte haben und dem UAC-Dialog zu Setup Barrier - Barrier einrichten + Barrier einrichten Welcome - Willkommen + Willkommen Thanks for installing Barrier! - Danke, dass du Barrier installiert hast! + Danke, dass Sie Barrier installiert haben! - Barrier lets you easily share your mouse and keyboard between multiple computers on your desk, and it's Free and Open Source. Just move your mouse off the edge of one computer's screen on to another. You can even share all of your clipboards. All you need is a network connection. Barrier is cross-platform (works on Windows, Mac OS X and Linux). - Mit Barrier können Sie einfach Ihre Tastatur und Maus an mehreren Computern auf Ihrem Schreibtisch nutzen, und es ist Frei und Open Source. Bewegen Sie einfach ihre Maus über den Rand des Bildschirms eines Computers auf den Bildschirm eines anderen. Sie können sogar den Inhalt ihrer Zwischenablage an alle Computer verteilen. Alles was Sie brauchen ist ein Netzwerk-Anschluss. Barrier funktioniert auf Windows, Mac OS X und Linux. + Barrier lets you easily share your mouse and keyboard between multiple computers on your desk, and it's Free and Open Source. Just move your mouse off the edge of one computer's screen on to another. You can even share all of your clipboards. All you need is a network connection. Barrier is cross-platform (works on Windows, Mac OS X and Linux). + Mit Barrier können Sie einfach Ihre Tastatur und Maus mit mehreren Computern auf Ihrem Schreibtisch teilen, und es ist frei und Open Source. Bewegen Sie einfach ihre Maus über den Rand des Bildschirms eines Computers auf den Bildschirm eines anderen. Sie können sogar den Inhalt ihrer Zwischenablage teilen. Alles, was Sie brauchen, ist ein Netzwerk-Verbindung. Barrier ist betriebssystemübergreifend (funktioniert auf Windows, Mac OS X und Linux). Activate - + Aktivieren &Activate now... - + Jetzt &aktivieren ... Email: - + E-Mail: Password: - + Passwort: <a href="https://symless.com/account/reset/">Forgot password</a> - + <a href="https://symless.com/account/reset/">Passwort vergessen</a> &Skip activation - + Aktivierung über&springen - &Server (share this computer's mouse and keyboard) - + &Server (share this computer's mouse and keyboard) + &Server (Maus und Tastatur dieses Rechners teilen) <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">My main mouse and keyboard are connected to this computer. This will allow you to move your mouse over to another computer's screen. There can only be one server in your setup.</span></p></body></html> - +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">My main mouse and keyboard are connected to this computer. This will allow you to move your mouse over to another computer's screen. There can only be one server in your setup.</span></p></body></html> + <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Meine Haupt-Maus und -Tastatur sind mit diesem Rechner verbunden. Das ermöglicht Ihnen, den Mauszeiger zum Bildschirm eines anderen Rechners zu bewegen. Es kann nur ein Server in Ihren Einstellungen vorhanden sein.</span></p></body></html> - &Client (use another computer's mouse and keyboard) - + &Client (use another computer's mouse and keyboard) + &Client (Maus und Tastatur eines anderen Rechners benutzen) <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">You have already set up a server. This computer will be controlled using the server's mouse and keyboard. There can be many clients in your setup.</span></p></body></html> - +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">You have already set up a server. This computer will be controlled using the server's mouse and keyboard. There can be many clients in your setup.</span></p></body></html> + <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Sie haben bereits einen Server eingerichtet. Dieser Rechner wird von der Maus und Tastatur des Servers kontrolliert. Es kann viele Clients in Ihren Einstellungen geben.</span></p></body></html> Server or Client? - Server oder Client? + Server oder Client? @@ -1275,22 +1309,22 @@ p, li { white-space: pre-wrap; } Failed to get profile directory. - + Profil-Verzeichnis kann nicht ermittelt werden. SSL certificate generated. - + SSZ-Zertifikat erzeugt. SSL fingerprint generated. - + SSL-Fingerabdruck erzeugt. Failed to find SSL fingerprint. - + SSL-Fingerabdruck kann nicht gefunden werden. @@ -1298,7 +1332,7 @@ p, li { white-space: pre-wrap; } Unknown - Unbekannt + Unbekannt @@ -1308,19 +1342,22 @@ p, li { white-space: pre-wrap; } An error occurred while trying to sign in. Please contact the helpdesk, and provide the following details. %1 - + Ein Fehler ist beim Einloggen aufgetreten. Bitte kontaktieren Sie das Helpdesk und halten Sie die folgenden Informationen bereit. + +%1 Login failed, invalid email or password. - Login fehlgeschlagen, falsche E-Mail Adresse oder Passwort. + Login fehlgeschlagen, E-Mail-Adresse oder Passwort ungültig. Login failed, an error occurred. %1 - Login fehlgeschlagen, ein Fehler ist aufgetreten. + Login fehlgeschlagen, ein Fehler ist aufgetreten. + %1 @@ -1330,8 +1367,10 @@ p, li { white-space: pre-wrap; } Server response: %1 - Login fehlgeschlagen, ein Fehler ist aufgetreten. -Serverantwort: + Login fehlgeschlagen, ein Fehler ist aufgetreten. + +Server-Antwort: + %1 @@ -1339,19 +1378,23 @@ Serverantwort: An error occurred while trying to query the plugin list. Please contact the help desk, and provide the following details. %1 - + Ein error ist bei der Abfrage der Plugin-Liste aufgetreten. Bitte kontaktieren Sie das Helpdesk und halten Sie die folgenden Informationen bereit. + +%1 Get plugin list failed, invalid user email or password. - + Konnte Plugin-Liste nicht ermitteln, E-Mail-Adresse oder Passwort ungültig. Get plugin list failed, an error occurred. %1 - + Konnte Plugin-Liste nicht ermitteln, ein Fehler ist aufgetreten. + +%1 @@ -1360,7 +1403,11 @@ Serverantwort: Server response: %1 - + Konnte Plugin-Liste nicht ermitteln, ein Fehler ist aufgetreten. + +Server-Antwort: + +%1 @@ -1368,44 +1415,44 @@ Server response: zeroconf server detected: %1 - + Zeroconf-Server erkannt: %1 zeroconf client detected: %1 - + Zeroconf-Client erkannt: %1 Zero configuration service - + Zero-Configuration-Dienst Error code: %1. - + Fehlercode: %1. Unable to start the zeroconf: %1. - + Zeroconf konnte nicht gestartet werden: %1. Barrier - Barrier + Barrier Failed to get local IP address. Please manually type in server address on your clients - + Lokale IP-Adresse nicht ermittelbar. Bitte die Server-Adresse an den Clients manuell eingeben %1 - + %1 - \ No newline at end of file + diff --git a/src/gui/res/lang/gui_es.qm b/src/gui/res/lang/gui_es.qm index d09974e..1a8735d 100644 Binary files a/src/gui/res/lang/gui_es.qm and b/src/gui/res/lang/gui_es.qm differ diff --git a/src/gui/res/lang/gui_es.ts b/src/gui/res/lang/gui_es.ts index 4b3523a..39fb569 100644 --- a/src/gui/res/lang/gui_es.ts +++ b/src/gui/res/lang/gui_es.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Configuraciones Barrier (*.sgc);;Todos los archivos (*.*) + All files (*.*) + Todos los archivos (*.*) + + + + Barrier Configurations (*.sgc) + Configuraciones Barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Configuraciones Barrier (*.conf);;Todos los archivos (*.*) + Barrier Configurations (*.conf) + Configuraciones Barrier (*.conf) diff --git a/src/gui/res/lang/gui_et-EE.qm b/src/gui/res/lang/gui_et-EE.qm index 7c2fc9b..2c8fe11 100644 Binary files a/src/gui/res/lang/gui_et-EE.qm and b/src/gui/res/lang/gui_et-EE.qm differ diff --git a/src/gui/res/lang/gui_et-EE.ts b/src/gui/res/lang/gui_et-EE.ts index 033b9d7..ddbf6f7 100644 --- a/src/gui/res/lang/gui_et-EE.ts +++ b/src/gui/res/lang/gui_et-EE.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Barrier seaded (*.sgc);;kõik failid (*.*) + All files (*.*) + Kõik failid (*.*) + + + + Barrier Configurations (*.sgc) + Barrier seaded (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Barrier seaded (*.conf);;Kõik failid (*.*) + Barrier Configurations (*.conf) + Barrier seaded (*.conf) diff --git a/src/gui/res/lang/gui_fi.qm b/src/gui/res/lang/gui_fi.qm index 1e7178c..7a8ae49 100644 Binary files a/src/gui/res/lang/gui_fi.qm and b/src/gui/res/lang/gui_fi.qm differ diff --git a/src/gui/res/lang/gui_fi.ts b/src/gui/res/lang/gui_fi.ts index e5aea17..6609da9 100644 --- a/src/gui/res/lang/gui_fi.ts +++ b/src/gui/res/lang/gui_fi.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Barrier Configuration (*.sgc);;Kaikki tiedostot (*.*) + All files (*.*) + Kaikki tiedostot (*.*) + + + + Barrier Configurations (*.sgc) + Barrier Configuration (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Barrier Configuration (*.conf);;Kaikki tiedostot (*.*) + Barrier Configurations (*.conf) + Barrier Configuration (*.conf) diff --git a/src/gui/res/lang/gui_fr.qm b/src/gui/res/lang/gui_fr.qm index 38116ce..a68df9d 100644 Binary files a/src/gui/res/lang/gui_fr.qm and b/src/gui/res/lang/gui_fr.qm differ diff --git a/src/gui/res/lang/gui_fr.ts b/src/gui/res/lang/gui_fr.ts index ed37997..66258ed 100644 --- a/src/gui/res/lang/gui_fr.ts +++ b/src/gui/res/lang/gui_fr.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Configuration Barrier (*.sgc);; Tous les fichiers (*.*) + All files (*.*) + Tous les fichiers (*.*) + + + + Barrier Configurations (*.sgc) + Configuration Barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) + Configuration Barrier (*.conf) diff --git a/src/gui/res/lang/gui_gl.ts b/src/gui/res/lang/gui_gl.ts index 2f89802..e0a95b7 100644 --- a/src/gui/res/lang/gui_gl.ts +++ b/src/gui/res/lang/gui_gl.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_grk.ts b/src/gui/res/lang/gui_grk.ts index ffbede5..751db12 100644 --- a/src/gui/res/lang/gui_grk.ts +++ b/src/gui/res/lang/gui_grk.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_he.qm b/src/gui/res/lang/gui_he.qm index 43fa7af..9bbf530 100644 Binary files a/src/gui/res/lang/gui_he.qm and b/src/gui/res/lang/gui_he.qm differ diff --git a/src/gui/res/lang/gui_he.ts b/src/gui/res/lang/gui_he.ts index 5a1ddcf..2850e83 100644 --- a/src/gui/res/lang/gui_he.ts +++ b/src/gui/res/lang/gui_he.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - קבצי הגדרות של Barrier (*.sgc);;All Files (*.*) + All files (*.*) + All Files (*.*) + + + + Barrier Configurations (*.sgc) + קבצי הגדרות של Barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - קבצי הגדרות של Barrier (*.conf);;All Files (*.*) + Barrier Configurations (*.conf) + קבצי הגדרות של Barrier (*.conf) diff --git a/src/gui/res/lang/gui_hi.ts b/src/gui/res/lang/gui_hi.ts index 57b409e..460a1bc 100644 --- a/src/gui/res/lang/gui_hi.ts +++ b/src/gui/res/lang/gui_hi.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_hr-HR.qm b/src/gui/res/lang/gui_hr-HR.qm index a7e5563..9dd5d45 100644 Binary files a/src/gui/res/lang/gui_hr-HR.qm and b/src/gui/res/lang/gui_hr-HR.qm differ diff --git a/src/gui/res/lang/gui_hr-HR.ts b/src/gui/res/lang/gui_hr-HR.ts index 4695e4e..c9883ed 100644 --- a/src/gui/res/lang/gui_hr-HR.ts +++ b/src/gui/res/lang/gui_hr-HR.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Barrier postavke (*.sgc);;Sve datoteke (*.*) + All files (*.*) + Sve datoteke (*.*) + + + + Barrier Configurations (*.sgc) + Barrier postavke (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Barrier postavke (*.conf);;Sve datoteke (*.*) + Barrier Configurations (*.conf) + Barrier postavke (*.conf) diff --git a/src/gui/res/lang/gui_hu-HU.qm b/src/gui/res/lang/gui_hu-HU.qm index 10361b7..678cc5c 100644 Binary files a/src/gui/res/lang/gui_hu-HU.qm and b/src/gui/res/lang/gui_hu-HU.qm differ diff --git a/src/gui/res/lang/gui_hu-HU.ts b/src/gui/res/lang/gui_hu-HU.ts index 7c26d46..536c904 100644 --- a/src/gui/res/lang/gui_hu-HU.ts +++ b/src/gui/res/lang/gui_hu-HU.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Barrier konfiguráció (*.sgc);;Minden fájl (*.*) + All files (*.*) + Minden fájl (*.*) + + + + Barrier Configurations (*.sgc) + Barrier konfiguráció (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Barrier konfiguráció (*.conf);;Minden fájl (*.*) + Barrier Configurations (*.conf) + Barrier konfiguráció (*.conf) diff --git a/src/gui/res/lang/gui_id.ts b/src/gui/res/lang/gui_id.ts index ed52252..1552cb8 100644 --- a/src/gui/res/lang/gui_id.ts +++ b/src/gui/res/lang/gui_id.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_is-IS.ts b/src/gui/res/lang/gui_is-IS.ts index 2764171..4a76edd 100644 --- a/src/gui/res/lang/gui_is-IS.ts +++ b/src/gui/res/lang/gui_is-IS.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_it.qm b/src/gui/res/lang/gui_it.qm index bc8dc7e..9ba0ea0 100644 Binary files a/src/gui/res/lang/gui_it.qm and b/src/gui/res/lang/gui_it.qm differ diff --git a/src/gui/res/lang/gui_it.ts b/src/gui/res/lang/gui_it.ts index c1096dd..c0a6c58 100644 --- a/src/gui/res/lang/gui_it.ts +++ b/src/gui/res/lang/gui_it.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Configurazioni di Barrier (*.sgc);;Tutti i files (*.*) + All files (*.*) + Tutti i files (*.*) + + + + Barrier Configurations (*.sgc) + Configurazioni di Barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Configurazioni di Barrier (*.conf);;Tutti i files (*.*) + Barrier Configurations (*.conf) + Configurazioni di Barrier (*.conf) diff --git a/src/gui/res/lang/gui_ja-JP.qm b/src/gui/res/lang/gui_ja-JP.qm index 90ff995..7209979 100644 Binary files a/src/gui/res/lang/gui_ja-JP.qm and b/src/gui/res/lang/gui_ja-JP.qm differ diff --git a/src/gui/res/lang/gui_ja-JP.ts b/src/gui/res/lang/gui_ja-JP.ts index e7ff5bd..1d80d2d 100644 --- a/src/gui/res/lang/gui_ja-JP.ts +++ b/src/gui/res/lang/gui_ja-JP.ts @@ -1,12 +1,14 @@ - + + + AboutDialogBase About Barrier - Barrierについて + Barrier について - + <p> Keyboard and mouse sharing application. Cross platform and open source.<br /><br /> @@ -26,22 +28,30 @@ Barrier is based on CosmoSynergy by Richard Lee and Adam Feder.<br /> The Barrier GUI is based on QSynergy by Volker Lanz.<br /><br /> Visit our website for help and info (symless.com). </p> - + <p> +キーボードとマウスの共有ソフトウェアです。クロスプラットフォームでオープンソースです。<br /><br /> +Copyright © 2012-2016 Symless Ltd.<br /> +Copyright © 2002-2012 Chris Schoeneman, Nick Bolton, Volker Lanz.<br /><br /> +Barrier は GNU General Public (GPLv2). のライセンスで公開されています。<br /><br /> +Barrier のベースは CosmoSynergy (Richard Lee, Adam Feder 開発) です。<br /> +Barrier の GUI は QSynergy (Volker Lanz 開発) がベースです。<br /><br /> +Visit our website for help and info (symless.com). +</p> Unknown - 不明 + 不明 Version: - バージョン: + バージョン: &Ok - OK + OK(&O) @@ -49,97 +59,97 @@ Visit our website for help and info (symless.com). Configure Action - 動作を構成 + アクションの設定 Choose the action to perform - 実行する動作を選択 + 実行するアクションを選択 Press a hotkey - ホットキーを押す + ホットキーを押す Release a hotkey - ホットキーを離す + ホットキーを離す Press and release a hotkey - ホットキーを押して離す + ホットキーを押して離す only on these screens - これらの画面だけ + これらのモニターのみにする Switch to screen - 画面に切り替え + モニターを切り替え Switch in direction - 切り替える方向 + 切り替える方向 left - + right - + up - + down - + Lock cursor to screen - カーソルを画面に限定 + カーソルを画面に限定 toggle - 切り替え + 切り替え on - オン + オン off - オフ + オフ This action is performed when - この動作を実行する時: + このアクション実行のタイミング the hotkey is pressed - ホットキーを押したとき + ホットキーを押したとき the hotkey is released - ホットキーを離したとき + ホットキーを離したとき @@ -147,7 +157,7 @@ Visit our website for help and info (symless.com). Dialog - + ダイアログ @@ -157,7 +167,7 @@ Visit our website for help and info (symless.com). Ignore auto connect clients - + クライアントの自動接続を無視 @@ -165,12 +175,30 @@ Visit our website for help and info (symless.com). Hotkey - ホットキー + ホットキー Enter the specification for the hotkey: - ホットキーの指定方法を入力してください: + ホットキーを入力してください: + + + + LogWindowBase + + + Log - Barrier + ログ - Barrier + + + + &Clear Log + ログ消去(&C) + + + + &Hide + 閉じる @@ -178,189 +206,193 @@ Visit our website for help and info (symless.com). &Start - 開始 + 開始(&S) &File - ファイル + ファイル(&F) &Edit - 編集 + 編集(&E) &Window - ウィンドウ + ウィンドウ(&W) &Help - ヘルプ + ヘルプ(&H) <p>Your version of Barrier is out of date. Version <b>%1</b> is now available to <a href="%2">download</a>.</p> <p>Version %1 is now available, <a href="%2">visit website</a>.</p> - + <p>お使いの Barrier のバージョンが古くなっています。 新しいバージョン <b>%1</b> が<a href="%2">ダウンロード</a>できます。</p> Program can not be started - プログラムを開始できません + プログラムを開始できません The executable<br><br>%1<br><br>could not be successfully started, although it does exist. Please check if you have sufficient permissions to run this program. - 実行ファイル<br><br>%1<br><br>は存在しますが、開始できませんでした。このプログラムを動作させる十分な権限があるかどうか確認してください。 + 実行ファイル<br><br>%1<br><br>は存在しますが、開始できませんでした。このプログラムを動作させる十分な権限があるかどうか確認してください。 Barrier client not found - Barrierクライアントが見つかりません + Barrier のクライアントが見つかりません The executable for the barrier client does not exist. - Barrierクライアントの実行ファイルが存在しません。 + Barrier のクライアントの実行ファイルが存在しません。 Hostname is empty - ホスト名が入力されていません + ホスト名がありません Please fill in a hostname for the barrier client to connect to. - Barrierクライアントで接続するホスト名を入力してください。 + Barrier のクライアントが接続するホスト名を入力してください。 Cannot write configuration file - 構成ファイルに書き込めません + 構成ファイルに書き込めません The temporary configuration file required to start barrier can not be written. - Barrierの開始に必要な一時的な構成ファイルを書き込めません。 + Barrier の開始に必要な一時的な構成ファイルに書き込めません。 Configuration filename invalid - 構成ファイル名が正しくありません。 + 構成ファイルのファイル名が正しくありません You have not filled in a valid configuration file for the barrier server. Do you want to browse for the configuration file now? - Barrierサーバーの正しい構成ファイルを書き込んでいません。今、構成ファイルを閲覧しますか? + Barrier のサーバー用の正しい構成ファイルではありません。構成ファイルを開きますか? Barrier server not found - Barrierサーバーが見つかりません + Barrier のサーバーが見つかりません The executable for the barrier server does not exist. - Barrierサーバーの実行ファイルが存在しません。 + Barrier のサーバーの実行ファイルが存在しません。 Barrier terminated with an error - Barrierはエラーで終了しました + Barrier はエラーで終了しました Barrier terminated unexpectedly with an exit code of %1.<br><br>Please see the log output for details. - Barrierは予期しない終了コード%1で終了しました。<br><br>詳細はログの出力を参照してください。 + Barrier は予期しない終了コード %1 で終了しました。<br><br>詳細はログの出力を参照してください。 &Stop - 停止 + 停止(&S) Please add the server (%1) to the grid. - + グリッドにサーバー (%1) を追加してください。 Please drag the new client screen (%1) to the desired position on the grid. - + グリッド上の希望する位置に新しいクライアントのモニタ (%1) をドラッグしてください。 Failed to detect system architecture. - + システムアーキテクチャの検出に失敗しました。 Cancel - + キャンセル Failed to download Bonjour installer to location: %1 - + Bonjour のインストーラーのダウンロードに失敗。場所: %1 Do you want to enable auto config and install Bonjour? This feature helps you establish the connection. - + 自動構成を有効にし、Bonjour をインストールしますか? + +この機能は接続を確立するためのお手伝いをします。 Auto config feature requires Bonjour. Do you want to install Bonjour? - + 自動構成の機能には Bonjour が必要です。 + +Bonjour をインストールしますか? Barrier is starting. - Barrierを開始中です。 + Barrier を開始中です。 Barrier is running. - Barrierは動作中です。 + Barrier は動作中です。 Barrier is not running. - Barrierは動作していません。 + Barrier は動作していません。 Unknown - 不明 + 不明 Barrier - Barrier + Barrier Browse for a barriers config file - Barrierの設定ファイルを参照 + Barrier の構成ファイルを参照 Barrier is now connected, You can close the config window. Barrier will remain connected in the background. - + ただいま Barrier は接続されました。設定ウインドウを閉じることができます。それでもバックグラウンドで接続を維持します。 Security question - + セキュリティの質問 @@ -368,25 +400,31 @@ Do you want to install Bonjour? %1 -This is a server fingerprint. You should compare this fingerprint to the one on your server's screen. If the two don't match exactly, then it's probably not the server you're expecting (it could be a malicious user). +This is a server fingerprint. You should compare this fingerprint to the one on your server's screen. If the two don't match exactly, then it's probably not the server you're expecting (it could be a malicious user). To automatically trust this fingerprint for future connections, click Yes. To reject this fingerprint and disconnect from the server, click No. - + このフィンガープリントを信頼しますか? + +%1 + +これはサーバーのフィンガープリントです。 このフィンガープリントを、サーバー側のモニタに表示されているフィンガープリントとで確認してください。その2つが一致しない場合、接続したいサーバーではありません (悪意のあるサーバの可能性があります)。 + +「はい」で、今後の接続でも、このフィンガープリントを自動的に信頼します。「いいえ」で、このフィンガープリントを拒否しサーバーから接続を切断します。 Save configuration as... - 設定に名前をつけて保存 + 構成設定に名前をつけて保存 Save failed - 保存できませんでした + 保存できませんでした Could not save configuration to file. - 設定をファイルに保存できませんでした + 構成設定をファイルに保存できませんでした。 @@ -394,168 +432,193 @@ To automatically trust this fingerprint for future connections, click Yes. To re Barrier - Barrier + Barrier - Ser&ver (share this computer's mouse and keyboard): - + Ser&ver (share this computer's mouse and keyboard): + サーバー (このコンピューターのキーボードとマウスを共有する)(&V): Screen name: - 画面の名前: + モニター名: &Server IP: - サーバー IP: + サーバー IP (&S): &Start - 開始 + 開始(&S) Use existing configuration: - 既存の設定を使用 + 既存の構成設定を使用: &Configuration file: - 設定ファイル: + 構成ファイル:(&C): &Browse... - 参照 + 参照(&B)... Configure interactively: - インタラクティブモードで設定: + 手動で構成を設定: &Configure Server... - サーバーを設定 + サーバーの構成設定(&S)... Ready - 準備完了 + 準備完了 Log - ログ + ログ &Reload - 適用 + 適用(&R) IP addresses: - IPアドレス: + IPアドレス: Fingerprint: - + フィンガープリント: - &Client (use another computer's mouse and keyboard): - + &Client (use another computer's mouse and keyboard): + クライアント (ほかのコンピューターのマウスとキーボードを使う)(&C): Auto config - + 自動構成 &About Barrier... - Barrierについて... + Barrier について(&A)... &Quit - 終了 + 終了(&Q) Quit - 終了 + 終了(&Q) Run - 実行 + 開始(&R) S&top - 停止 + 停止(&S) Stop - 停止 + 停止(&S) S&how Status - 状態を表示 + 状態を表示(&S) &Hide - 隠す + 隠す(&H) Hide - 隠す + 隠す(&H) &Show - 表示する + 表示(&S) Show - 表示する + 表示(&S) Save configuration &as... - 設定に名前をつけて保存 + 構成設定に名前をつけて保存 Save the interactively generated server configuration to a file. - インタラクティブモードで生成したサーバ設定をファイルに保存 + 手動で設定したサーバーの構成をファイルに保存する。 Settings - 設定 + 設定 Edit settings - 設定を編集 + 設定を編集 Run Wizard - ウィザードを実行する + ウィザードを実行 + + + + S&ave configuration + 構成設定の保存(&A) + + + + Change &Settings + 設定の変更(&S) + + + + Show &Log + ログを表示(&L) + + + + Show Log + ログを表示(&L) + + + + SSL Fingerprint: + SSLフィンガープリント: @@ -563,7 +626,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Unnamed - 名前なし + 名前なし @@ -571,28 +634,29 @@ To automatically trust this fingerprint for future connections, click Yes. To re Failed to get plugin directory. - + プラグインのフォルダ取得に失敗しました。 Failed to get profile directory. - + プロファイルのフォルダ取得に失敗しました。 - Failed to download plugin '%1' to: %2 + Failed to download plugin '%1' to: %2 %3 - + プラグイン「%1」の %2 へのダウンロードに失敗 +%3 Could not get Windows architecture type. - + Windows のアーキテクチャの種類を取得できません。 Could not get Linux architecture type. - + Linux のアーキテクチャの種類を取得できません。 @@ -600,66 +664,66 @@ To automatically trust this fingerprint for future connections, click Yes. To re Setup Barrier - Barrierのセットアップ + Barrier のセットアップ Please wait... - + お待ちください... Error: %1 - + エラー: %1 Setup complete. - + セットアップは完了しました。 - Downloading '%1' plugin (%2/%3)... - + Downloading '%1' plugin (%2/%3)... + プラグイン「%1」をダウンロード中 (%2/%3)... Plugins installed successfully. - + プラグインは正常にインストールされました。 Generating SSL certificate... - + SSL 証明書を生成中... Downloading plugin: %1 (1/%2) - + プラグインをダウンロード中: %1 (1/%2) Getting plugin list... - + プラグイン一覧を取得中... QObject - Barrier Configurations (*.sgc);;All files (*.*) - Barrierの構成(*.sgc);;すべてのファイル(*.*) + Barrier Configurations (*.sgc) + Barrier 構成設定 (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Barrierの構成(*.conf);;すべてのファイル(*.*) + Barrier Configurations (*.conf) + Barrier 構成設定 (*.conf) System tray is unavailable, quitting. - タスクトレイを利用できません。終了します。 + システムトレイを利用できません。終了します。 @@ -667,22 +731,22 @@ To automatically trust this fingerprint for future connections, click Yes. To re Screen name is empty - 画面の名前が空です。 + モニター名がありません The screen name cannot be empty. Please either fill in a name or cancel the dialog. - 画面の名前を空にすることはできません。名前を入力するかダイアログをキャンセルしてください。 + モニター名を空にはできません。名前を入力するか、ダイアログをキャンセルしてください。 Screen name matches alias - 画面の名前は別名と一致 + モニター名は別名に一致 The screen name cannot be the same as an alias. Please either remove the alias or change the screen name. - 画面の名前を別名と同じにすることは出来ません。別名を削除するか画面の名前を変更してください。 + モニター名を別名と同じにできません。別名を削除するか、モニター名を変更してください。 @@ -690,37 +754,37 @@ To automatically trust this fingerprint for future connections, click Yes. To re Screen Settings - 画面の設定 + モニターの設定 Screen &name: - 画面の名前 + モニター名(&N): A&liases - 別名 + 別名(&A) &Add - 追加 + 追加(&A) &Remove - 削除 + 除去(&R) &Modifier keys - 修飾キー + 修飾キー(&M) &Shift: - シフト + Shift(&S): @@ -729,7 +793,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Shift - シフト + @@ -738,7 +802,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Ctrl - コントロール + @@ -747,7 +811,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Alt - Alt + @@ -756,7 +820,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Meta - メタ + メタ @@ -765,7 +829,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Super - スーパー + スーパー @@ -774,82 +838,87 @@ To automatically trust this fingerprint for future connections, click Yes. To re None - なし + なし &Ctrl: - &undefinedCtrl: + Ctrl (&C): Al&t: - &undefinedl&t: + Alt (&T): M&eta: - &undefined&eta: + メタ (&E): S&uper: - &undefined&uper: + スーパー (&S): &Dead corners - 無効とする角 + 無効とする隅(&D) Top-left - 左上 + 左上 Top-right - 右上 + 右上 Bottom-left - 左下 + 左下 Bottom-right - 右下 + 右下 Corner Si&ze: - 角の大きさ + 隅の大きさ(&Z): &Fixes - 修正 + 修正(&F) Fix CAPS LOCK key - CAPSロックキーを固定 + CAPS ロックキーを固定 Fix NUM LOCK key - NUMロックキーを固定 + NUM ロックキーを固定 Fix SCROLL LOCK key - SCROLLロックキーを固定 + SCROLL ロックキーを固定 Fix XTest for Xinerama - Xinerama向けにXTestを修正 + Xinerama 向けに XTest を修正 + + + + Fix Preserve Focus + フォーカスの維持を修正 @@ -857,7 +926,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re <center>Screen: <b>%1</b></center><br>Double click to edit settings<br>Drag screen to the trashcan to remove it - <center>画面: <b>%1</b></center><br>ダブルクリックで設定を編集<br>削除するときは画面をゴミ箱にドラッグします + <center>モニター: <b>%1</b></center><br>ダブルクリックで設定を編集<br>削除するときは画面をゴミ箱にドラッグします @@ -865,7 +934,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Configure server - + サーバーの構成設定 @@ -873,168 +942,178 @@ To automatically trust this fingerprint for future connections, click Yes. To re Server Configuration - サーバーの構成 + サーバーの構成設定 Screens and links - 画面とリンク + モニタの結びつき Drag a screen from the grid to the trashcan to remove it. - 削除する時はグリッド内の画面をゴミ箱にドラッグしてください。 + 削除するには、グリッド内のモニターをゴミ箱にドラッグしてください。 Configure the layout of your barrier server configuration. - サーバ構成の配置を設定する + Barrier のサーバー構成の配置を設定します。 Drag this button to the grid to add a new screen. - 新規画面の追加はこのボタンをグリッド内にドラッグします。 + 新規モニターの追加するには、このボタンをグリッド内にドラッグします。 Drag new screens to the grid or move existing ones around. Drag a screen to the trashcan to delete it. Double click on a screen to edit its settings. - 新規画面をグリッド内にドラッグするか既存画面を移動してください。 -画面をゴミ箱にドラッグすると削除します。 -設定を編集する場合は画面上でダブルクリックしてください。 + 新規モニターをグリッド内にドラッグするか、既存のモニターを移動してください。 +削除するには、モニターをゴミ箱にドラッグします。 +モニターの設定を編集するには、モニターをダブルクリックします。 Hotkeys - ホットキー + ホットキー &Hotkeys - ホットキー + ホットキー(&H) &New - 新規 + 新規(&N) &Edit - 編集 + 編集(&E) &Remove - 削除 + 除去(&R) A&ctions - アクション + アクション(&A) Ne&w - 新規 + 新規(&W) E&dit - 編集 + 編集(&D) Re&move - 削除 + 除去(&M) Advanced server settings - サーバーの詳細な設定 + サーバーの詳細設定 &Switch - 切り替え + 切り替え(&S) Switch &after waiting - 次の時間の後切り替え + 次の時間の後切り替え(&A) ms - ミリ秒 + ミリ秒 Switch on double &tap within - 次の時間内のダブルタップで切り替え + 次の時間内のダブルタップで切り替え(&T) &Options - オプション + オプション(&O) &Check clients every - クライアント確認頻度 + クライアント確認頻度(&C) Use &relative mouse moves - マウスの相対的な動きを使用 + 相対的なマウスの移動を使用(&R) S&ynchronize screen savers - スクリーンセーバーの同期 + スクリーンセーバーの同期(&Y) - Don't take &foreground window on Windows servers - Windowsサーバでウィンドウを前面に表示しない + Don't take &foreground window on Windows servers + Windows サーバ上ではウィンドウを前面に表示しない(&F) Ignore auto config clients - + 自動構成のクライアントを無視 &Dead corners - 無効とする角 + 無効とする隅(&D) To&p-left - 左上 + 左上(&P) Top-rig&ht - 右上 + 右上(&H) &Bottom-left - 左下 + 左下(&B) Bottom-ri&ght - 右下 + 右下(&G) Cor&ner Size: - 隅の大きさ: + 隅の大きさ(&N): + + + + Enable drag and drop file transfers + ドラッグアンドドロップでファイル転送する + + + + Enable clipboard sharing + クリップボードを共有 @@ -1042,20 +1121,20 @@ Double click on a screen to edit its settings. Save log file to... - ログファイルの保存先 + ログファイルの保存先 Elevate Barrier - Barrierの権限昇格 + Barrier の権限昇格 Are you sure you want to elevate Barrier? This allows Barrier to interact with elevated processes and the UAC dialog, but can cause problems with non-elevated processes. Elevate Barrier only if you really need to. - 本当に Barrier を昇格させてよろしいですか? -これにより昇格されたプロセスや UAC dialog と、Barrier とが互いに作用しあうことができるようになる反面、昇格されていないプロセスとの間で問題を生じることもあり得ます。確かに必要であると判断できる場合にのみ Barrier の昇格を行ってください。 + Barrier を昇格させてもよろしいですか? +この許可により Barrier は権限を持つプロセスや UAC ダイアログやりとりできます。一方で、昇格されていないプロセスとのやり取りに問題が起こることもあります。確かに必要である場合にのみ Barrier を昇格させてください。 @@ -1063,107 +1142,162 @@ This allows Barrier to interact with elevated processes and the UAC dialog, but Settings - 設定 + 設定 Sc&reen name: - スクリーン名: + モニター名(&R): P&ort: - ポート: + ポート(&O): &Interface: - インターフェース: + インターフェース(&I): Elevate mode - + 特権の状態 &Hide on startup - + 起動時に隠す(&H) &Network Security - + ネットワークのセキュリティ(&N) Use &SSL encryption (unique certificate) - + SSL 暗号化を使用 (固有の証明書)(&S) Logging - ログ + ログ記録 &Logging level: - ログレベル: + ログ対象(&L): Log to file: - ログ記録先ファイル: + ログ記録ファイル: Browse... - 参照... + 参照... Error - エラー + エラー &Language: - 言語 + 言語(&L): &Miscellaneous - その他 + その他(&M) Warning - 警告 + 警告 Note - 通知 + 通知 Info - 情報 + 情報 Debug - デバッグ情報 + デバッグ情報 Debug1 - デバッグ情報1 + デバッグ情報1 Debug2 - デバッグ情報2 + デバッグ情報2 + + + + General + 一般 + + + + Elevate + 権限昇格 + + + + Specify when the Barrier service should run at an elevated privilege level + Barrier のサービスを昇格した権限で実行するタイミングの指定 + + + + As Needed + 必要に応じて + + + + Always + 常に + + + + Never + なし + + + + Minimize to System &Tray + システムトレイに最小化(&T) + + + + Networking + ネットワーク + + + + &Address: + アドレス(&A): + + + + Enable &SSL + SSLを使用(&S) + + + + Start &Barrier on startup + 起動時に Barrier を開始する (&B) @@ -1171,17 +1305,17 @@ This allows Barrier to interact with elevated processes and the UAC dialog, but Setup Barrier - Barrierのセットアップ + Barrier のセットアップ Please select an option. - オプションを選択してください。 + オプションを選択してください。 Please enter your email address and password. - メールアドレスとパスワードを入力してください。 + メールアドレスとパスワードを入力してください。 @@ -1189,85 +1323,93 @@ This allows Barrier to interact with elevated processes and the UAC dialog, but Setup Barrier - Barrierのセットアップ + Barrier のセットアップ Welcome - ようこそ + ようこそ Thanks for installing Barrier! - Barrierをインストールしていただき、ありがとうございます! + Barrier をインストールしていただき、ありがとうございます! - Barrier lets you easily share your mouse and keyboard between multiple computers on your desk, and it's Free and Open Source. Just move your mouse off the edge of one computer's screen on to another. You can even share all of your clipboards. All you need is a network connection. Barrier is cross-platform (works on Windows, Mac OS X and Linux). - Barrierは複数のコンピュータ間のマウスとキーボードを簡単に共有することができるフリーのオープンソースソフトウェアです。あるコンピュータの画面の端にマウスを移動すると別のコンピュータの画面に移ります。クリップボードを共有することもできます。必要なのは ネットワーク接続だけです。 BarrierはクロスプラットフォームでWindows, Mac OS X, Linux上で動作します。 + Barrier lets you easily share your mouse and keyboard between multiple computers on your desk, and it's Free and Open Source. Just move your mouse off the edge of one computer's screen on to another. You can even share all of your clipboards. All you need is a network connection. Barrier is cross-platform (works on Windows, Mac OS X and Linux). + Barrier によって、複数のデスクトップパソコン間でマウスとキーボードを簡単に共有することができます。そしてこれは無料でオープンソースのソフトウェアです。あるコンピュータの画面の端にマウスを移動するだけで、別のコンピュータの画面に移ることができます。クリップボードを共有することもできます。必要なのはネットワーク接続だけです。 Barrier はクロスプラットフォームで Windows, Mac OS X, Linux で動作します。 Activate - + アクティベート &Activate now... - + 今すぐアクティベート(&A)... Email: - + 電子メール: Password: - + パスワード: <a href="https://symless.com/account/reset/">Forgot password</a> - + <a href="https://symless.com/account/reset/">パスワードを忘れた場合</a> &Skip activation - + アクティベートを省略(&S) - &Server (share this computer's mouse and keyboard) - + &Server (share this computer's mouse and keyboard) + サーバー (このコンピューターのキーボードとマウスを共有する)(&V) <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">My main mouse and keyboard are connected to this computer. This will allow you to move your mouse over to another computer's screen. There can only be one server in your setup.</span></p></body></html> - +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">My main mouse and keyboard are connected to this computer. This will allow you to move your mouse over to another computer's screen. There can only be one server in your setup.</span></p></body></html> + <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">使いたいマウスとキーボードがこのパソコンに接続されている場合、こちらを選択することで、別のパソコンのモニタへとマウスを移動することができます。サーバーは1つしか設置できません。</span></p></body></html> - &Client (use another computer's mouse and keyboard) - + &Client (use another computer's mouse and keyboard) + クライアント (ほかのコンピューターのマウスとキーボードを使う)(&C) <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">You have already set up a server. This computer will be controlled using the server's mouse and keyboard. There can be many clients in your setup.</span></p></body></html> - +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">You have already set up a server. This computer will be controlled using the server's mouse and keyboard. There can be many clients in your setup.</span></p></body></html> + <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">既にサーバーを設置してある場合、このパソコンをサーバーに接続されたマウスとキーボードで制御できます。複数の数のクライアントを配置できます。</span></p></body></html> Server or Client? - サーバーまたはクライアント + サーバーにしますか?またはクライアントですか? @@ -1275,22 +1417,22 @@ p, li { white-space: pre-wrap; } Failed to get profile directory. - + プロファイルのフォルダ取得に失敗しました。 SSL certificate generated. - + SSL 証明書を生成しました。 SSL fingerprint generated. - + SSL フィンガープリントを生成しました。 Failed to find SSL fingerprint. - + SSL フィンガープリントが見つかりませんでした。 @@ -1298,7 +1440,7 @@ p, li { white-space: pre-wrap; } Unknown - 不明 + 不明 @@ -1308,19 +1450,21 @@ p, li { white-space: pre-wrap; } An error occurred while trying to sign in. Please contact the helpdesk, and provide the following details. %1 - + サインイン時にエラーが発生しました。ヘルプデスクにお問い合わせの上、以下の詳細を報告してください。 + +%1 Login failed, invalid email or password. - ログインは失敗しました。メールアドレスまたはパスワードが無効です。 + ログインに失敗しました。メールアドレスまたはパスワードが無効です。 Login failed, an error occurred. %1 - エラーが発生し、ログインが失敗しました。 + エラーが発生し、ログインに失敗しました。 %1 @@ -1330,8 +1474,8 @@ p, li { white-space: pre-wrap; } Server response: %1 - エラーが発生し、ログインが失敗しました。 -サーバの応答: + エラーが発生し、ログインに失敗しました。 +サーバの応答: %1 @@ -1339,19 +1483,23 @@ Server response: An error occurred while trying to query the plugin list. Please contact the help desk, and provide the following details. %1 - + プラグイン一覧の要求時にエラーが発生しました。ヘルプデスクにお問い合わせの上、以下の詳細を報告してください。 + +%1 Get plugin list failed, invalid user email or password. - + プラグイン一覧の取得に失敗しました。メールアドレスまたはパスワードが無効です。 Get plugin list failed, an error occurred. %1 - + エラーが発生し、プラグイン一覧の取得に失敗しました。 + +%1 @@ -1360,7 +1508,11 @@ Server response: Server response: %1 - + エラーが発生し、プラグイン一覧の取得に失敗しました。 + +サーバの応答: + +%1 @@ -1368,44 +1520,44 @@ Server response: zeroconf server detected: %1 - + ゼロ構成のサーバーを検出: %1 zeroconf client detected: %1 - + ゼロ構成のクライアントを検出: %1 Zero configuration service - + ゼロ構成のサービス Error code: %1. - + エラーコード: %1 Unable to start the zeroconf: %1. - + ゼロ構成は開始できません: %1 Barrier - Barrier + Barrier Failed to get local IP address. Please manually type in server address on your clients - + ローカル IP アドレスの取得に失敗しました。クライアント上でサーバーのアドレスを手動で入力してください %1 - + - \ No newline at end of file + diff --git a/src/gui/res/lang/gui_ko.qm b/src/gui/res/lang/gui_ko.qm index 06612cb..54b9461 100644 Binary files a/src/gui/res/lang/gui_ko.qm and b/src/gui/res/lang/gui_ko.qm differ diff --git a/src/gui/res/lang/gui_ko.ts b/src/gui/res/lang/gui_ko.ts index 8c477fc..46f7223 100644 --- a/src/gui/res/lang/gui_ko.ts +++ b/src/gui/res/lang/gui_ko.ts @@ -204,7 +204,7 @@ Visit our website for help and info (symless.com). <p>Your version of Barrier is out of date. Version <b>%1</b> is now available to <a href="%2">download</a>.</p> <p>Version %1 is now available, <a href="%2">visit website</a>.</p> - <p>사용 중인 시너지는 최신 버전이 아닙니다. 새 버전(<b>%1</b>)을 <a href="%2">다운로드</a> 받을 수 있습니다.</p> + <p>사용 중인 배리어는 최신 버전이 아닙니다. 새 버전(<b>%1</b>)을 <a href="%2">다운로드</a> 받을 수 있습니다.</p> @@ -600,7 +600,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Setup Barrier - 시너지 설정 + 배리어 설정 @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Barrier 설정파일 (*.sgc);;모든 파일 (*.*) + All files (*.*) + 모든 파일 (*.*) + + + + Barrier Configurations (*.sgc) + Barrier 설정파일 (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Barrier 설정파일 (*.conf);;모든 파일 (*.*) + Barrier Configurations (*.conf) + Barrier 설정파일 (*.conf) @@ -1171,7 +1176,7 @@ This allows Barrier to interact with elevated processes and the UAC dialog, but Setup Barrier - 시너지 설정 + 배리어 설정 @@ -1189,7 +1194,7 @@ This allows Barrier to interact with elevated processes and the UAC dialog, but Setup Barrier - 시너지 설정 + 배리어 설정 @@ -1199,7 +1204,7 @@ This allows Barrier to interact with elevated processes and the UAC dialog, but Thanks for installing Barrier! - 시너지를 설치하여 주셔서 감사합니다. + 배리어를 설치하여 주셔서 감사합니다. diff --git a/src/gui/res/lang/gui_lt.ts b/src/gui/res/lang/gui_lt.ts index 66976b1..58e9101 100644 --- a/src/gui/res/lang/gui_lt.ts +++ b/src/gui/res/lang/gui_lt.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_lv.ts b/src/gui/res/lang/gui_lv.ts index 27b74f0..4618c05 100644 --- a/src/gui/res/lang/gui_lv.ts +++ b/src/gui/res/lang/gui_lv.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_mr.ts b/src/gui/res/lang/gui_mr.ts index b91bd19..a646004 100644 --- a/src/gui/res/lang/gui_mr.ts +++ b/src/gui/res/lang/gui_mr.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_nl-NL.qm b/src/gui/res/lang/gui_nl-NL.qm index 102cec8..ac9a67c 100644 Binary files a/src/gui/res/lang/gui_nl-NL.qm and b/src/gui/res/lang/gui_nl-NL.qm differ diff --git a/src/gui/res/lang/gui_nl-NL.ts b/src/gui/res/lang/gui_nl-NL.ts index 5c5b490..4ea0ee8 100644 --- a/src/gui/res/lang/gui_nl-NL.ts +++ b/src/gui/res/lang/gui_nl-NL.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Barrier Configuratie (*.sgc);;Alle bestanden (*.*) + All files (*.*) + Alle bestanden (*.*) + + + + Barrier Configurations (*.sgc) + Barrier Configuratie (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Barrier configuratie (*.conf);;Alle bestanden (*.*) + Barrier Configurations (*.conf) + Barrier configuratie (*.conf) @@ -1329,7 +1334,7 @@ p, li { white-space: pre-wrap; } Server response: %1 - Inloggen mislukt, er is een fout opgetreden. + Inloggen mislukt, er is een fout opgetreden. Foutmelding: %1 diff --git a/src/gui/res/lang/gui_no.qm b/src/gui/res/lang/gui_no.qm index 903ae48..c4d1d81 100644 Binary files a/src/gui/res/lang/gui_no.qm and b/src/gui/res/lang/gui_no.qm differ diff --git a/src/gui/res/lang/gui_no.ts b/src/gui/res/lang/gui_no.ts index d27a620..0ccd61e 100644 --- a/src/gui/res/lang/gui_no.ts +++ b/src/gui/res/lang/gui_no.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Barrier-oppsett (*.sgc);;Alle filer (*.*) + All files (*.*) + Alle filer (*.*) + + + + Barrier Configurations (*.sgc) + Barrier-oppsett (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Barrier-oppsett (*.conf);;Alle filer (*.*) + Barrier Configurations (*.conf) + Barrier-oppsett (*.conf) diff --git a/src/gui/res/lang/gui_pes-IR.ts b/src/gui/res/lang/gui_pes-IR.ts index 31d7a67..3aaffed 100644 --- a/src/gui/res/lang/gui_pes-IR.ts +++ b/src/gui/res/lang/gui_pes-IR.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_pl-PL.qm b/src/gui/res/lang/gui_pl-PL.qm index 83e7352..65a2116 100644 Binary files a/src/gui/res/lang/gui_pl-PL.qm and b/src/gui/res/lang/gui_pl-PL.qm differ diff --git a/src/gui/res/lang/gui_pl-PL.ts b/src/gui/res/lang/gui_pl-PL.ts index 6fb96a0..7262a2a 100644 --- a/src/gui/res/lang/gui_pl-PL.ts +++ b/src/gui/res/lang/gui_pl-PL.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Konfiguracje Barrier (*.sgc);;Wszystkie pliki (*.*) + All files (*.*) + Wszystkie pliki (*.*) + + + + Barrier Configurations (*.sgc) + Konfiguracje Barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Konfiguracje Barrier (*.conf);;Wszystkie pliki (*.*) + Barrier Configurations (*.conf) + Konfiguracje Barrier (*.conf) @@ -1320,7 +1325,7 @@ p, li { white-space: pre-wrap; } Login failed, an error occurred. %1 - Logowanie nie powiodło się, wystąpił błąd. + Logowanie nie powiodło się, wystąpił błąd. %1 @@ -1330,7 +1335,7 @@ p, li { white-space: pre-wrap; } Server response: %1 - Logowanie nie powiodło się, wystąpił błąd. + Logowanie nie powiodło się, wystąpił błąd. Odpowiedź serwera: %1 diff --git a/src/gui/res/lang/gui_pt-BR.qm b/src/gui/res/lang/gui_pt-BR.qm index 1deecfd..0825fcf 100644 Binary files a/src/gui/res/lang/gui_pt-BR.qm and b/src/gui/res/lang/gui_pt-BR.qm differ diff --git a/src/gui/res/lang/gui_pt-BR.ts b/src/gui/res/lang/gui_pt-BR.ts index 6245bca..6e85dd8 100644 --- a/src/gui/res/lang/gui_pt-BR.ts +++ b/src/gui/res/lang/gui_pt-BR.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Configurações do Barrier (*.sgc);;Todos os arquivos (*.*) + All files (*.*) + Todos os arquivos (*.*) + + + + Barrier Configurations (*.sgc) + Configurações do Barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Configurações do Barrier (*.conf);;Todos os arquivos (*.*) + Barrier Configurations (*.conf) + Configurações do Barrier (*.conf) diff --git a/src/gui/res/lang/gui_pt-PT.qm b/src/gui/res/lang/gui_pt-PT.qm index 987d8ab..e824cce 100644 Binary files a/src/gui/res/lang/gui_pt-PT.qm and b/src/gui/res/lang/gui_pt-PT.qm differ diff --git a/src/gui/res/lang/gui_pt-PT.ts b/src/gui/res/lang/gui_pt-PT.ts index 03fc40d..9ae8899 100644 --- a/src/gui/res/lang/gui_pt-PT.ts +++ b/src/gui/res/lang/gui_pt-PT.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Configuração de barrier (*.sgc);;Todos os ficheiros (*.*) + All files (*.*) + Todos os ficheiros (*.*) + + + + Barrier Configurations (*.sgc) + Configuração de barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Configuração de barrier (*.conf);;Todos os ficheiros (*.*) + Barrier Configurations (*.conf) + Configuração de barrier (*.conf)) diff --git a/src/gui/res/lang/gui_ro.qm b/src/gui/res/lang/gui_ro.qm index 6d1fdd2..1a69dad 100644 Binary files a/src/gui/res/lang/gui_ro.qm and b/src/gui/res/lang/gui_ro.qm differ diff --git a/src/gui/res/lang/gui_ro.ts b/src/gui/res/lang/gui_ro.ts index f82d128..c3c9c43 100644 --- a/src/gui/res/lang/gui_ro.ts +++ b/src/gui/res/lang/gui_ro.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Configurații Barrier (*.sgc);;Toate Fișierele (*.*) + All files (*.*) + Toate Fișierele (*.*) + + + + Barrier Configurations (*.sgc) + Configurații Barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Configurații Barrier (*.conf);;Toate Fișierele (*.*) + Barrier Configurations (*.conf) + Configurații Barrier (*.conf) diff --git a/src/gui/res/lang/gui_ru.qm b/src/gui/res/lang/gui_ru.qm index 30ed0a7..ef3852c 100644 Binary files a/src/gui/res/lang/gui_ru.qm and b/src/gui/res/lang/gui_ru.qm differ diff --git a/src/gui/res/lang/gui_ru.ts b/src/gui/res/lang/gui_ru.ts index 411272f..f984240 100644 --- a/src/gui/res/lang/gui_ru.ts +++ b/src/gui/res/lang/gui_ru.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Конфигурация Barrier (*.sgc);;Все файлы (*.*) + All files (*.*) + Все файлы (*.*) + + + + Barrier Configurations (*.sgc) + Конфигурация Barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Конфигурация Barrier (*.conf);;Все файлы (*.*) + Barrier Configurations (*.conf) + Конфигурация Barrier (*.conf) @@ -1320,7 +1325,7 @@ p, li { white-space: pre-wrap; } Login failed, an error occurred. %1 - Войти не удалось, произошла ошибка. + Войти не удалось, произошла ошибка. %1 @@ -1331,7 +1336,7 @@ p, li { white-space: pre-wrap; } Server response: %1 - Войти не удалось, произошла ошибка. + Войти не удалось, произошла ошибка. Ответ сервера: diff --git a/src/gui/res/lang/gui_si.ts b/src/gui/res/lang/gui_si.ts index 33597e9..9abc5df 100644 --- a/src/gui/res/lang/gui_si.ts +++ b/src/gui/res/lang/gui_si.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_sk-SK.qm b/src/gui/res/lang/gui_sk-SK.qm index acdf4f6..0e5efca 100644 Binary files a/src/gui/res/lang/gui_sk-SK.qm and b/src/gui/res/lang/gui_sk-SK.qm differ diff --git a/src/gui/res/lang/gui_sk-SK.ts b/src/gui/res/lang/gui_sk-SK.ts index 3e63795..0bbeacf 100644 --- a/src/gui/res/lang/gui_sk-SK.ts +++ b/src/gui/res/lang/gui_sk-SK.ts @@ -1,12 +1,14 @@ - + + + AboutDialogBase About Barrier - + O Barrier - + <p> Keyboard and mouse sharing application. Cross platform and open source.<br /><br /> @@ -26,22 +28,30 @@ Barrier is based on CosmoSynergy by Richard Lee and Adam Feder.<br /> The Barrier GUI is based on QSynergy by Volker Lanz.<br /><br /> Visit our website for help and info (symless.com). </p> - + <p> +Aplikácia na zdieľanie klávesnice a myši. Podporuje viacero platforiem a má otvorený zdrojový kód.<br /><br /> +Autorské práva © 2012-2016 Symless Ltd.<br /> +Autorské práva © 2002-2012 Chris Schoeneman, Nick Bolton, Volker Lanz.<br /><br /> +Barrier je vydaný pod licenciou GNU General Public License (GPLv2).<br /><br /> +Základom pre Barrier je CosmoSynergy od Richarda Lee-a a Adama Federa.<br /> +Barrier GUI je postavené na QSynergy od Volkera Lanza.<br /><br /> +Pre pomoc a ďalšie informácie navštívte našu webovú stránku (symless.com). +</p> Unknown - + Neznáma Version: - + Verzia: &Ok - + &Ok @@ -49,97 +59,97 @@ Visit our website for help and info (symless.com). Configure Action - + Nastaviť akciu Choose the action to perform - + Vyberte akciu, ktorá sa má vykonať Press a hotkey - + Stlačte klávesovú skratku Release a hotkey - + Uvoľnite klávesovú skratku Press and release a hotkey - + Stlačte a uvoľnite klávesovú skratku only on these screens - + iba na týchto obrazovkách Switch to screen - + Prepnúť na obrazovku Switch in direction - + Prepnúť v smere left - + doľava right - + doprava up - + hore down - + dole Lock cursor to screen - + Zamknúť kurzor na obrazovke toggle - + prepnúť on - + zap off - + vyp This action is performed when - + Táto akcia sa vykoná pri the hotkey is pressed - + stlačení klávesovej skratky the hotkey is released - + uvoľnení klávesovej skratky @@ -147,17 +157,17 @@ Visit our website for help and info (symless.com). Dialog - + Dialógové okno TextLabel - + TextovýPopis Ignore auto connect clients - + Ignorovať automatické pripojenia klientov @@ -165,12 +175,12 @@ Visit our website for help and info (symless.com). Hotkey - + Klávesová skratka Enter the specification for the hotkey: - + Vložte popis klávesovej skratky: @@ -178,189 +188,193 @@ Visit our website for help and info (symless.com). &Start - + S&pustiť &File - + &Súbor &Edit - + &Upraviť &Window - + &Okno &Help - + &Pomocník <p>Your version of Barrier is out of date. Version <b>%1</b> is now available to <a href="%2">download</a>.</p> <p>Version %1 is now available, <a href="%2">visit website</a>.</p> - + <p>Vaša verzia Barrier nie je aktuálna. Na <a href="%2">stiahnutie</a> je k dispozícii verzia <b>%1</b>.</p> Program can not be started - + Program sa nepodarilo spustiť The executable<br><br>%1<br><br>could not be successfully started, although it does exist. Please check if you have sufficient permissions to run this program. - + Súbor <br><br>%1<br><br>sa nepodarilo spustiť aj napriek tomu, že existuje. Prosím, skontrolujte, či máte dostatočné práva na spustenie tohto programu. Barrier client not found - + Nepodarilo sa nájsť klienta Barrier The executable for the barrier client does not exist. - + Spustiteľný súbor klienta barrier neexistuje. Hostname is empty - + Názov hostiteľa je prázdny Please fill in a hostname for the barrier client to connect to. - + Prosím, vyplňte názov hostiteľa, ku ktorému sa klient barrier má pripojiť. Cannot write configuration file - + Nepodarilo sa zapísať súbor s konfiguráciou The temporary configuration file required to start barrier can not be written. - + Nepodarilo sa zapísať do dočasného súboru, ktorý je potrebný pre spustenie barrier. Configuration filename invalid - + Neplatný názov konfiguračného súboru You have not filled in a valid configuration file for the barrier server. Do you want to browse for the configuration file now? - + Nezadali ste platný konfiguračný súbor pre server barrier. Želáte si teraz vybrať súbor s konfiguráciou? Barrier server not found - + Server barrier nebol nájdený The executable for the barrier server does not exist. - + Spustiteľný súbor servera barrier neexistuje. Barrier terminated with an error - + Barrier skončil s chybou Barrier terminated unexpectedly with an exit code of %1.<br><br>Please see the log output for details. - + Barrier bolo neočakávane ukončený s chybovým kódom %1.<br><br>Podrobnosti nájdete v súbore s protokolom. &Stop - + &Zastaviť Please add the server (%1) to the grid. - + Pridajte, prosím, server (%1) do mriežky. Please drag the new client screen (%1) to the desired position on the grid. - + Ťahaním presuňte obrazovku nového klienta (%1) na požadovanú pozíciu v mriežke. Failed to detect system architecture. - + Nepodarilo sa zistiť systémovú architektúru. Cancel - + Zrušiť Failed to download Bonjour installer to location: %1 - + Nepodarilo sa stiahnuť inštalátor Bonjour do umiestnenia: %1 Do you want to enable auto config and install Bonjour? This feature helps you establish the connection. - + Želáte si povoliť autokonfiguráciu a nainštalovať Bonjour? + +Táto funkcia vám pomôže s nadväzovaním spojenia. Auto config feature requires Bonjour. Do you want to install Bonjour? - + Funkcia autokonfigurácie vyžaduje Bonjour. + +Želáte si nainštalovať Bonjour? Barrier is starting. - + Barrier sa spúšťa. Barrier is running. - + Barrier je spustený. Barrier is not running. - + Barrier nie je spustený. Unknown - + Neznáma Barrier - + Barrier Browse for a barriers config file - + Vybrať súbor s konfiguráciou barrier Barrier is now connected, You can close the config window. Barrier will remain connected in the background. - + Barrier je pripojený, môžete zavrieť okno s nastaveniami. Barrier zostane bežať na pozadí. Security question - + Bezpečnostná otázka @@ -368,25 +382,31 @@ Do you want to install Bonjour? %1 -This is a server fingerprint. You should compare this fingerprint to the one on your server's screen. If the two don't match exactly, then it's probably not the server you're expecting (it could be a malicious user). +This is a server fingerprint. You should compare this fingerprint to the one on your server's screen. If the two don't match exactly, then it's probably not the server you're expecting (it could be a malicious user). To automatically trust this fingerprint for future connections, click Yes. To reject this fingerprint and disconnect from the server, click No. - + Dôverujete tomuto otlačku? + +%1 + +Toto je digitálny otlačok servera. Mali by ste ho porovnať s otlačkom na jednej z obrazoviek vášho servera. Ak nie sú rovnaké, potom sa pravdepodobne nepripájate na server, na ktorý chcete (môže sa jednať o zlomyselného používateľa). + +Ak chcete automaticky dôverovať tomuto otlačku pri ďalších spojeniach, kliknite na Áno. Pre odmietnutie tohto otlačku a odpojenie od servera kliknite na Nie. Save configuration as... - + Uložiť konfiguráciu ako... Save failed - + Chyba pri ukladaní Could not save configuration to file. - + Nepodarilo sa uložiť súbor s konfiguráciou do súboru. @@ -394,168 +414,168 @@ To automatically trust this fingerprint for future connections, click Yes. To re Barrier - + Barrier - Ser&ver (share this computer's mouse and keyboard): - + Ser&ver (share this computer's mouse and keyboard): + Ser&ver (zdieľať klávesnicu a myš tohto počítača): Screen name: - + Názov obrazovky: &Server IP: - + &IP servera: &Start - + S&pustiť Use existing configuration: - + Použiť existujúcu konfiguráciu: &Configuration file: - + Sú&bor s konfiguráciou: &Browse... - + &Prechádzať... Configure interactively: - + Interaktívna konfigurácia: &Configure Server... - + &Konfigurovať server... Ready - + Pripravené Log - + Protokol &Reload - + &Znovu načítať IP addresses: - + IP adresy: Fingerprint: - + Otlačok: - &Client (use another computer's mouse and keyboard): - + &Client (use another computer's mouse and keyboard): + &Klient (používa klávesnicu a myš iného počítača): Auto config - + Automatická konfigurácia &About Barrier... - + &O Barrier... &Quit - + &Ukončiť Quit - + Ukončiť Run - + Spustiť S&top - + Za&staviť Stop - + Zastaviť S&how Status - + Zo&braziť stav &Hide - + &Skryť Hide - + Skryť &Show - + Z&obraziť Show - + Zobraziť Save configuration &as... - + Uložiť konfiguráciu &ako... Save the interactively generated server configuration to a file. - + Uložiť interaktívne vygenerovanú konfiguráciu serveru do súboru. Settings - + Nastavenia Edit settings - + Upraviť nastavenia Run Wizard - + Spustiť sprievodcu @@ -563,7 +583,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Unnamed - + Bezmena @@ -571,28 +591,29 @@ To automatically trust this fingerprint for future connections, click Yes. To re Failed to get plugin directory. - + Nepodarilo sa získať adresár s pluginmi. Failed to get profile directory. - + Nepodarilo sa získať adresár s profilom. - Failed to download plugin '%1' to: %2 + Failed to download plugin '%1' to: %2 %3 - + Nepodarilo sa stiahnuť plugin '%1' do: %2 +%3 Could not get Windows architecture type. - + Nepodarilo sa zistiť typ architektúry Windows. Could not get Linux architecture type. - + Nepodarilo sa zistiť typ architektúry Linuxu. @@ -600,66 +621,71 @@ To automatically trust this fingerprint for future connections, click Yes. To re Setup Barrier - + Nastaviť Barrier Please wait... - + Čakajte prosím... Error: %1 - + Chyba: %1 Setup complete. - + Nastavovanie dokončené. - Downloading '%1' plugin (%2/%3)... - + Downloading '%1' plugin (%2/%3)... + Sťahujem plugin '%1' (%2/%3)... Plugins installed successfully. - + Pluginy úspešne nainštalované. Generating SSL certificate... - + Generujem SSL certifikát... Downloading plugin: %1 (1/%2) - + Sťahujem plugin: %1 (1/%2) Getting plugin list... - + Získavam zoznam pluginov... QObject - Barrier Configurations (*.sgc);;All files (*.*) - + All files (*.*) + Všetky súbory (*.*) + + + + Barrier Configurations (*.sgc) + Konfiguračné súbory Barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - + Barrier Configurations (*.conf) + Konfiguračné súbory Barrier (*.conf) System tray is unavailable, quitting. - + Systémová oblasť nie je dostupná, končím. @@ -667,22 +693,22 @@ To automatically trust this fingerprint for future connections, click Yes. To re Screen name is empty - + Názov obrazovky je prázdny The screen name cannot be empty. Please either fill in a name or cancel the dialog. - + Názov obrazovky nemôže byť prázdny. Zadajte, prosím, názov alebo zrušte toto dialógové okno. Screen name matches alias - + Názov obrazovky koliduje s jej alternatívnym názvom The screen name cannot be the same as an alias. Please either remove the alias or change the screen name. - + Názov obrazovky nemôže byť rovnaký ako jej alternatívny názov. Prosím, odstráňte alternatívny názov alebo zmeňte názov obrazovky. @@ -690,37 +716,37 @@ To automatically trust this fingerprint for future connections, click Yes. To re Screen Settings - + Nastavenia obrazovky Screen &name: - + &Názov obrazovky: A&liases - + &Alternatívne názvy &Add - + &Pridať &Remove - + O&dstrániť &Modifier keys - + &Modifikátory klávesov &Shift: - + &Shift: @@ -729,7 +755,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Shift - + Shift @@ -738,7 +764,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Ctrl - + Ctrl @@ -747,7 +773,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Alt - + Alt @@ -756,7 +782,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Meta - + Meta @@ -765,7 +791,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Super - + Super @@ -774,82 +800,82 @@ To automatically trust this fingerprint for future connections, click Yes. To re None - + Žiadny &Ctrl: - + &Ctrl: Al&t: - + Al&t: M&eta: - + M&eta: S&uper: - + S&uper: &Dead corners - + &Mŕtve rohy Top-left - + Vľavo hore Top-right - + Vpravo hore Bottom-left - + Vľavo dole Bottom-right - + Vpravo dole Corner Si&ze: - + Veľ&kosť rohov: &Fixes - + &Opravy Fix CAPS LOCK key - + Opraviť správanie klávesu CAPS LOCK Fix NUM LOCK key - + Opraviť správanie klávesu NUM LOCK Fix SCROLL LOCK key - + Opraviť správanie klávesu SCROLL LOCK Fix XTest for Xinerama - + Opravit XTest pre Xinerama @@ -857,7 +883,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re <center>Screen: <b>%1</b></center><br>Double click to edit settings<br>Drag screen to the trashcan to remove it - + <center>Obrazovka: <b>%1</b></center><br>Dvojitým kliknutím upravíte nastavenia<br>Pre odstránenie obrazovky ju myšou presuňte do koša @@ -865,7 +891,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Configure server - + Konfigurovať server @@ -873,166 +899,168 @@ To automatically trust this fingerprint for future connections, click Yes. To re Server Configuration - + Konfigurácia servera Screens and links - + Obrazovky a prepojenia Drag a screen from the grid to the trashcan to remove it. - + Pre odstránenie obrazovky ju chyťte a presuňte z mriežky do koša. Configure the layout of your barrier server configuration. - + Nastaviť rozloženie konfigurácie vášho servera barrier. Drag this button to the grid to add a new screen. - + Pre vytvorenie novej obrazovky presuňte toto tlačidlo do mriežky. Drag new screens to the grid or move existing ones around. Drag a screen to the trashcan to delete it. Double click on a screen to edit its settings. - + Ťahaním pridajte nové obrazovky do mriežky alebo presuňte existujúce. +Presuňte obrazovku do koša, ak ju chcete odstrániť. +Dvojitým kliknutím na obrazovku upravíte jej nastavenia. Hotkeys - + Klávesové skratky &Hotkeys - + &Klávesové skratky &New - + &Nový &Edit - + &Upraviť &Remove - + O&dstrániť A&ctions - + &Akcie Ne&w - + No&vý E&dit - + U&praviť Re&move - + Ods&trániť Advanced server settings - + Pokročilé nastavenia serveru &Switch - + &Prepnúť Switch &after waiting - + Prepnúť &po prestávke ms - + ms Switch on double &tap within - + Prepnúť po &dvojitom ťuknutí počas &Options - + &Možnosti &Check clients every - + K&ontrolovať klientov každých Use &relative mouse moves - + Používať &relatívne pohyby myši S&ynchronize screen savers - + &Synchronizovať šetriče obrazovky - Don't take &foreground window on Windows servers - + Don't take &foreground window on Windows servers + Na serveroch s &Windows sa neprepínať do popredia Ignore auto config clients - + Ignorovať klientov s autokonfiguráciou &Dead corners - + &Mŕtve rohy To&p-left - + &Vľavo hore Top-rig&ht - + Vpravo &dole &Bottom-left - + &Vľavo dole Bottom-ri&ght - + V&pravo dole Cor&ner Size: - + &Veľkost rohov: @@ -1040,19 +1068,21 @@ Double click on a screen to edit its settings. Save log file to... - + Uložiť súbor s protokolom do... Elevate Barrier - + Zvýšiť stupeň oprávnení pre Barrier Are you sure you want to elevate Barrier? This allows Barrier to interact with elevated processes and the UAC dialog, but can cause problems with non-elevated processes. Elevate Barrier only if you really need to. - + Naozaj chcete zvýšiť stupeň oprávnení pre Barrier? + +Toto umožní Barrier pracovať s procesmi, ktoré majú takisto vyšší stupeň oprávnení a s oknom riadenia používateľských účtov (UAC), ale môže to tiež spôsobiť problémy aplikáciam s bežnými oprávneniami. Túto možnosť by ste mali použiť iba, ak ju skutočne potrebujete. @@ -1060,107 +1090,107 @@ This allows Barrier to interact with elevated processes and the UAC dialog, but Settings - + Nastavenia Sc&reen name: - + &Názov obrazovky: P&ort: - + P&ort: &Interface: - + &Používateľské rozhranie: Elevate mode - + Režim oprávnení &Hide on startup - + &Skryť pri spustení &Network Security - + Sieťová &bezpečnosť Use &SSL encryption (unique certificate) - + Používať šifrovanie &SSL (jedinečný certifikát) Logging - + Protokolovanie &Logging level: - + Ú&roveň protokolu: Log to file: - + Protokol ukladať do súboru: Browse... - + Prechádzať... Error - + Chyba &Language: - + &Jazyk: &Miscellaneous - + &Rôzne Warning - + Varovanie Note - + Poznámka Info - Informácie + Informácie Debug - + Ladenie Debug1 - + Ladenie1 Debug2 - + Ladenie2 @@ -1168,17 +1198,17 @@ This allows Barrier to interact with elevated processes and the UAC dialog, but Setup Barrier - + Nastaviť Barrier Please select an option. - + Prosím, vyberte si jednu z možností. Please enter your email address and password. - + Zadajte, prosím, vašu emailovú adresu a heslo. @@ -1186,85 +1216,93 @@ This allows Barrier to interact with elevated processes and the UAC dialog, but Setup Barrier - + Nastaviť Barrier Welcome - + Vitajte Thanks for installing Barrier! - + Ďakujeme, že ste sa rozhodli nainštalovať Barrier! - Barrier lets you easily share your mouse and keyboard between multiple computers on your desk, and it's Free and Open Source. Just move your mouse off the edge of one computer's screen on to another. You can even share all of your clipboards. All you need is a network connection. Barrier is cross-platform (works on Windows, Mac OS X and Linux). - Barrier vám umožní ľahko zdieľať myš a klávesnicu medzi viacerými počítačmi na stole, je to zadarmo a Open Source. Len presunúť kurzor myši mimo okraj jedného počítača na obrazovke na ďalšie. Môžete dokonca zdieľať všetky vaše schránok. Všetko, čo potrebujete, je pripojenie k sieti. Barrier je cross-platformové (práca na Windows, Mac OS X a Linux). + Barrier lets you easily share your mouse and keyboard between multiple computers on your desk, and it's Free and Open Source. Just move your mouse off the edge of one computer's screen on to another. You can even share all of your clipboards. All you need is a network connection. Barrier is cross-platform (works on Windows, Mac OS X and Linux). + Barrier vám umožní ľahko zdieľať myš a klávesnicu medzi viacerými počítačmi, je zadarmo a má otvorený zdrojový kód. Stačí len presunúť kurzor myši mimo okraj obrazovky jedného počítača a presuniete sa na druhý počítač. Môžete dokonca zdieľať všetky vaše schránky. Všetko, čo potrebujete, je pripojenie k sieti. Barrier podporuje viacero platforiem (funguje vo Windowse, Mac OS X a Linuxe). Activate - + Aktivovať &Activate now... - + &Aktivovať teraz... Email: - + Email: Password: - + Heslo: <a href="https://symless.com/account/reset/">Forgot password</a> - + <a href="https://symless.com/account/reset/">Zabudnuté heslo</a> &Skip activation - + &Preskočiť aktiváciu - &Server (share this computer's mouse and keyboard) - + &Server (share this computer's mouse and keyboard) + &Server (zdieľať klávesnicu a myš tohto počítača) <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">My main mouse and keyboard are connected to this computer. This will allow you to move your mouse over to another computer's screen. There can only be one server in your setup.</span></p></body></html> - +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">My main mouse and keyboard are connected to this computer. This will allow you to move your mouse over to another computer's screen. There can only be one server in your setup.</span></p></body></html> + <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">K tomuto počítaču je pripojená moja hlavná klávesnica a myš. Toto vám umožní presunúť kurzor myši na obrazovku iného počítača. V úlohe servera môže byť len jeden počítač.</span></p></body></html> - &Client (use another computer's mouse and keyboard) - + &Client (use another computer's mouse and keyboard) + &Klient (použiť klávesnicu a myš iného počítača) <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">You have already set up a server. This computer will be controlled using the server's mouse and keyboard. There can be many clients in your setup.</span></p></body></html> - +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">You have already set up a server. This computer will be controlled using the server's mouse and keyboard. There can be many clients in your setup.</span></p></body></html> + <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Server už ste nastavili. Tento počítač bude ovládaný klávesnicou a myšou pripojenou k serveru. V roli klienta môže byť viacero počítačov.</span></p></body></html> Server or Client? - + Server alebo klient? @@ -1272,22 +1310,22 @@ p, li { white-space: pre-wrap; } Failed to get profile directory. - + Nepodarilo sa získať adresár s profilom. SSL certificate generated. - + SSL certifikát bol vygenerovaný. SSL fingerprint generated. - + SSL otlačok bol vygenerovaný. Failed to find SSL fingerprint. - + Nepodarilo sa nájsť otlačok SSL. @@ -1295,7 +1333,7 @@ p, li { white-space: pre-wrap; } Unknown - + Neznáma @@ -1305,19 +1343,23 @@ p, li { white-space: pre-wrap; } An error occurred while trying to sign in. Please contact the helpdesk, and provide the following details. %1 - + Počas pokusu o prihlásenie došlo k chybe. Prosím, kontaktujte zákaznickú podporu a poskytnite im nasledujúce údaje. + +%1 Login failed, invalid email or password. - + Prihlásenie nebolo úspešné, neplatná emailová adresa alebo heslo. Login failed, an error occurred. %1 - + Prihlásenie nebolo úspešné, nastala chyba. + +%1 @@ -1326,26 +1368,33 @@ p, li { white-space: pre-wrap; } Server response: %1 - + Prihlásenie nebolo úspešné, nastala chyba. + +Odpoveď servera: +%1 An error occurred while trying to query the plugin list. Please contact the help desk, and provide the following details. %1 - + Počas získavania zoznamu pluginov došlo k chybe. Prosím, kontaktujte zákaznickú podporu a poskytnite im nasledujúce údaje. + +%1 Get plugin list failed, invalid user email or password. - + Zlyhalo získavanie zoznamu pluginov, neplatná emailová adresa alebo heslo. Get plugin list failed, an error occurred. %1 - + Zlyhalo získavanie zoznamu pluginov, nastala chyba. + +%1 @@ -1354,7 +1403,10 @@ Server response: Server response: %1 - + Zlyhalo získavanie zoznamu pluginov, nastala chyba. + +Odpoveď servera: +%1 @@ -1362,44 +1414,44 @@ Server response: zeroconf server detected: %1 - + detegovaný zeroconf server: %1 zeroconf client detected: %1 - + detegovaný zeroconf klient: %1 Zero configuration service - + Služba Zero configuration Error code: %1. - + Kód chyby: %1. Unable to start the zeroconf: %1. - + Nepodarilo sa spustiť zeroconf: %1. Barrier - + Barrier Failed to get local IP address. Please manually type in server address on your clients - + Nepodarilo sa získať miestnu IP adresu. Zadajte, prosím, adresu servera ručne v nastaveniach vašich klientov %1 - + %1 - \ No newline at end of file + diff --git a/src/gui/res/lang/gui_sl-SI.ts b/src/gui/res/lang/gui_sl-SI.ts index 5aa6cde..181d5e2 100644 --- a/src/gui/res/lang/gui_sl-SI.ts +++ b/src/gui/res/lang/gui_sl-SI.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_sq-AL.qm b/src/gui/res/lang/gui_sq-AL.qm index c80f8ab..b54bb6e 100644 Binary files a/src/gui/res/lang/gui_sq-AL.qm and b/src/gui/res/lang/gui_sq-AL.qm differ diff --git a/src/gui/res/lang/gui_sq-AL.ts b/src/gui/res/lang/gui_sq-AL.ts index 1fcd217..fa65c6c 100644 --- a/src/gui/res/lang/gui_sq-AL.ts +++ b/src/gui/res/lang/gui_sq-AL.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Konfiguracioni i Barrier (*.sgc);;Te gjithe (*.*) + All files (*.*) + Te gjithe (*.*) + + + + Barrier Configurations (*.sgc) + Konfiguracioni i Barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Konfiguracioni i Barrier (*.conf);;Te gjithe (*.*) + Barrier Configurations (*.conf) + Konfiguracioni i Barrier (*.conf) diff --git a/src/gui/res/lang/gui_sr.ts b/src/gui/res/lang/gui_sr.ts index 4ae87d8..d46168f 100644 --- a/src/gui/res/lang/gui_sr.ts +++ b/src/gui/res/lang/gui_sr.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_sv.qm b/src/gui/res/lang/gui_sv.qm index f014cfd..897abe3 100644 Binary files a/src/gui/res/lang/gui_sv.qm and b/src/gui/res/lang/gui_sv.qm differ diff --git a/src/gui/res/lang/gui_sv.ts b/src/gui/res/lang/gui_sv.ts index f0c239e..d28810c 100644 --- a/src/gui/res/lang/gui_sv.ts +++ b/src/gui/res/lang/gui_sv.ts @@ -669,13 +669,18 @@ Klicka "Ja" för att automatiskt lita på fingeravtrycket i framtida a QObject - Barrier Configurations (*.sgc);;All files (*.*) - Barrier-konfigurationer (*.sgc);;Alla filer (*.*) + All files (*.*) + Alla filer (*.*) + + + + Barrier Configurations (*.sgc) + Barrier-konfigurationer (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Barrier-konfigurationer (*.conf);;Alla filer (*.*) + Barrier Configurations (*.conf) + Barrier-konfigurationer (*.conf) diff --git a/src/gui/res/lang/gui_th-TH.ts b/src/gui/res/lang/gui_th-TH.ts index 07c74b8..88d7894 100644 --- a/src/gui/res/lang/gui_th-TH.ts +++ b/src/gui/res/lang/gui_th-TH.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_tr-TR.ts b/src/gui/res/lang/gui_tr-TR.ts index 01a681b..924662f 100644 --- a/src/gui/res/lang/gui_tr-TR.ts +++ b/src/gui/res/lang/gui_tr-TR.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) @@ -900,8 +905,8 @@ To automatically trust this fingerprint for future connections, click Yes. To re Drag new screens to the grid or move existing ones around. Drag a screen to the trashcan to delete it. Double click on a screen to edit its settings. - Izgaraya yeni ekranları sürükleyin veya çevresinde mevcut olanları taşıyın. -Silmek için çöp tenekesine ekranı sürükleyin. + Izgaraya yeni ekranları sürükleyin veya çevresinde mevcut olanları taşıyın. +Silmek için çöp tenekesine ekranı sürükleyin. Kendi ayarlarınızı düzenlemek için bir ekran üzerine çift tıklayın. diff --git a/src/gui/res/lang/gui_uk.qm b/src/gui/res/lang/gui_uk.qm index 3e9c9c5..86cb8ef 100644 Binary files a/src/gui/res/lang/gui_uk.qm and b/src/gui/res/lang/gui_uk.qm differ diff --git a/src/gui/res/lang/gui_uk.ts b/src/gui/res/lang/gui_uk.ts index 1f2dffe..b7297c1 100644 --- a/src/gui/res/lang/gui_uk.ts +++ b/src/gui/res/lang/gui_uk.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Конфігурація Barrier (*.sgc);;Всі файли (*.*) + All files (*.*) + Всі файли (*.*) + + + + Barrier Configurations (*.sgc) + Конфігурація Barrier (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Конфігурація Barrier (*.conf);;Всі файли (*.*) + Barrier Configurations (*.conf) + Конфігурація Barrier (*.conf) diff --git a/src/gui/res/lang/gui_ur.ts b/src/gui/res/lang/gui_ur.ts index 9b36dcf..c378089 100644 --- a/src/gui/res/lang/gui_ur.ts +++ b/src/gui/res/lang/gui_ur.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_vi.ts b/src/gui/res/lang/gui_vi.ts index a3c6025..16d013a 100644 --- a/src/gui/res/lang/gui_vi.ts +++ b/src/gui/res/lang/gui_vi.ts @@ -648,12 +648,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) + All files (*.*) + + + + + Barrier Configurations (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) + Barrier Configurations (*.conf) diff --git a/src/gui/res/lang/gui_zh-CN.qm b/src/gui/res/lang/gui_zh-CN.qm index f11d0b5..21c874e 100644 Binary files a/src/gui/res/lang/gui_zh-CN.qm and b/src/gui/res/lang/gui_zh-CN.qm differ diff --git a/src/gui/res/lang/gui_zh-CN.ts b/src/gui/res/lang/gui_zh-CN.ts index 0c8522a..d7a331c 100644 --- a/src/gui/res/lang/gui_zh-CN.ts +++ b/src/gui/res/lang/gui_zh-CN.ts @@ -1,1411 +1,1323 @@ - + + + AboutDialogBase - + About Barrier - 关于Barrier + 关于 Barrier - - + + + + Unknown + 未知 + + + + Version: + 版本: + + + + &Ok + 确定(&O) + + + <p> Keyboard and mouse sharing application. Cross platform and open source.<br /><br /> +Copyright © 2018 Debauchee Open Source Group<br /> Copyright © 2012-2016 Symless Ltd.<br /> Copyright © 2002-2012 Chris Schoeneman, Nick Bolton, Volker Lanz.<br /><br /> Barrier is released under the GNU General Public License (GPLv2).<br /><br /> Barrier is based on CosmoSynergy by Richard Lee and Adam Feder.<br /> -The Barrier GUI is based on QSynergy by Volker Lanz.<br /><br /> -Visit our website for help and info (symless.com). +The Barrier GUI is based on QSynergy by Volker Lanz. </p> - <p> -Keyboard and mouse sharing application. Cross platform and open source.<br /><br /> + <p> +共享键盘和鼠标,跨平台并开源。<br /><br /> +Copyright © 2018 Debauchee Open Source Group<br /> Copyright © 2012-2016 Symless Ltd.<br /> Copyright © 2002-2012 Chris Schoeneman, Nick Bolton, Volker Lanz.<br /><br /> -Barrier is released under the GNU General Public License (GPLv2).<br /><br /> -Barrier is based on CosmoSynergy by Richard Lee and Adam Feder.<br /> -The Barrier GUI is based on QSynergy by Volker Lanz.<br /><br /> -Visit our website for help and info (symless.com). -</p> - - - - - Unknown - 未知 - - - - Version: - 版本: +Barrier 适用 GNU 通用公共许可证(GPLv2)。<br /><br /> +Barrier 基于 Richard Lee 和 Adam Feder 制作的 CosmoSynergy .<br /> +Barrier GUI 基于 Volker Lanz 制作的 QSynergy. +</p> - - &Ok - 确定 + + Build Date: + 日期: ActionDialogBase - + Configure Action - 行为配置 + 配置动作 - + Choose the action to perform - 选择要执行的行为 + 选择要执行的动作 - + Press a hotkey - 按下热键 + 按下热键 - + Release a hotkey - 松开热键 + 松开热键 - + Press and release a hotkey - 按下一个键然后松开 + 单击热键 - + only on these screens - 仅仅在这些屏幕上 + 仅在这些屏幕上 - + Switch to screen - 切换到屏幕 + 切换到屏幕 - + Switch in direction - 方向切换 + 切换方向 - + left - + - + right - 右侧 + 右侧 - + up - 上方 + 上方 - + down - 下方 + 下方 - + Lock cursor to screen - 锁定指针于屏幕 + 锁定指针于屏幕 - + toggle - 切换 + 切换 - + on - 启用 + 启用 - + off - 禁用 + 禁用 - + This action is performed when - 当……时启用此行为 + 当……时启用此动作 - + the hotkey is pressed - 热键被按下 + 热键被按下 - + the hotkey is released - 热键被松开 + 热键被松开 + + + + Toggle screen + 切换屏幕 AddClientDialog - + Dialog - + TextLabel - + Ignore auto connect clients - + 忽略自动连接的客户端 HotkeyDialogBase - + Hotkey - 热键 + 热键 - + Enter the specification for the hotkey: - 输入热键的说明: + 指定热键: - MainWindow + LogWindowBase - - &Start - 开始 + + Log - Barrier + 日志 - Barrier - - &File - 文件 + + &Clear Log + 清空(&C) - - &Edit - 编辑 + + &Hide + 隐藏(&H) + + + MainWindow - - &Window - 窗口 + + &Start + 开始(&S) - + &Help - 帮助 - - - - <p>Your version of Barrier is out of date. Version <b>%1</b> is now available to <a href="%2">download</a>.</p> - <p>Version %1 is now available, <a href="%2">visit website</a>.</p> - <p>您正在使用的Barrier版本有些过时了,有新版 <b>%1</b> 可以 <a href="%2">下载</a>。</p> + 帮助(&S) - + Program can not be started - 程序无法启动 + 程序无法启动 - + The executable<br><br>%1<br><br>could not be successfully started, although it does exist. Please check if you have sufficient permissions to run this program. - 可执行程序<br><br>%1<br><br>没有成功运行,虽然程序本身存在。请检查你是否有运行此程序的权限。 + 可执行程序<br><br>%1<br><br>没有成功运行,虽然程序本身存在。请检查你是否有运行此程序的权限。 - + Barrier client not found - 未找到Barrier客户端 + 未找到Barrier客户端 - + The executable for the barrier client does not exist. - Barrier客户端的可执行程序不存在。 + Barrier客户端的可执行程序不存在。 - + Hostname is empty - 主机名为空 + 主机名为空 - + Please fill in a hostname for the barrier client to connect to. - 请为Barrier客户端设置一个用于连接的主机名 + 请为Barrier客户端设置一个用于连接的主机名。 - + Cannot write configuration file - 不能写入配置文件 + 不能写入配置文件 - + The temporary configuration file required to start barrier can not be written. - 启动Barrier所需的临时配置文件不可写。 + 启动Barrier所需的临时配置文件不可写。 - + Configuration filename invalid - 配置文件名非法 + 无效配置文件名 - + You have not filled in a valid configuration file for the barrier server. Do you want to browse for the configuration file now? - 你没有为Barrier服务端设置一个可用的配置文件。需要现在浏览配置文件吗? + Barrier服务端缺少有效的配置文件。需要现在浏览配置文件吗? - + Barrier server not found - 未找到Barrier服务端 + 未找到Barrier服务端 - + The executable for the barrier server does not exist. - Barrier服务端可执行程序不存在。 - - - - Barrier terminated with an error - Barrier因错终止运行 - - - - Barrier terminated unexpectedly with an exit code of %1.<br><br>Please see the log output for details. - Barrier意外终止运行,退出代码 %1。<br><br>请查看输出日志了解详情。 + Barrier服务端可执行程序不存在。 - + &Stop - 停止 + 停止(&S) - + Please add the server (%1) to the grid. - + 请添加服务端(%1)到网格。 - + Please drag the new client screen (%1) to the desired position on the grid. - + 请将新屏幕(%1)拖动到网格中的合适位置。 - + Failed to detect system architecture. - + 检测系统架构失败 - + Cancel - + 取消 - + Failed to download Bonjour installer to location: %1 - + 无法下载Bonjou安装包至 %1 - + Do you want to enable auto config and install Bonjour? This feature helps you establish the connection. - + 是否开启自动配置并下载Bonjour? + +此功能帮助你建立连接。 - + Auto config feature requires Bonjour. Do you want to install Bonjour? - + 自动配置需要Bonjour + +是否安装Bonjour? - + Barrier is starting. - Barrier正在启动 + Barrier正在启动 - + Barrier is running. - Barrier正在运行 + Barrier正在运行 - + Barrier is not running. - Barrier没有运行 + Barrier没有运行 - + Unknown - 未知 + 未知 - - - + + + Barrier - Barrier + Barrier - + Browse for a barriers config file - 浏览Barrier配置文件 + 浏览Barrier配置文件 - - Barrier is now connected, You can close the config window. Barrier will remain connected in the background. - - - - + Security question - + 安全确认 - + Do you trust this fingerprint? %1 -This is a server fingerprint. You should compare this fingerprint to the one on your server's screen. If the two don't match exactly, then it's probably not the server you're expecting (it could be a malicious user). +This is a server fingerprint. You should compare this fingerprint to the one on your server's screen. If the two don't match exactly, then it's probably not the server you're expecting (it could be a malicious user). To automatically trust this fingerprint for future connections, click Yes. To reject this fingerprint and disconnect from the server, click No. - + 是否信任此指纹? + +%1 + +这是服务端的指纹,请将其与你服务端屏幕的指纹进行对比。如果两者不一致,你可能没有连接到预期的服务端,或是遇到了恶意攻击。 + +点击确认以自动信任此指纹在未来的连接,点击停止来中断连接。 - + Save configuration as... - 保存配置到文件 + 保存配置到文件 - + Save failed - 保存失败 + 保存失败 - + Could not save configuration to file. - 不能保存配置到文件 + 无法保存配置到文件 + + + + &Barrier + &Barrier + + + + Barrier is now connected. You can close the config window and Barrier will remain connected in the background. + Barrier已连接。现在可以关闭窗口,Barrier会在后台保持连接。 MainWindowBase - + Barrier - Barrier + Barrier - - Ser&ver (share this computer's mouse and keyboard): - + + Ser&ver (share this computer's mouse and keyboard): + 服务端 - 共享此电脑的鼠标和键盘 - + Screen name: - 屏幕名: + 屏幕名: - + &Server IP: - 服务端IP + 服务端IP: - - + + &Start - 开始 + 开始(&S) - + Use existing configuration: - 使用已有的配置: + 使用已有的配置: - + &Configuration file: - 配置文件: + 配置文件: - + &Browse... - 浏览… + 浏览(&B)… - + Configure interactively: - 交互配置: + 交互配置: - + &Configure Server... - 设置服务端… + 设置服务端(&C)… - + Ready - 准备完毕 - - - - Log - 日志 + 准备完毕 - + &Reload - 应用 + 应用(&R) - + IP addresses: - IP地址 + IP地址: - - Fingerprint: - - - - - &Client (use another computer's mouse and keyboard): - + + &Client (use another computer's mouse and keyboard): + 客户端 - 使用另一电脑的鼠标和键盘 - + Auto config - + 自动配置 - + &About Barrier... - 关于Barrier… + 关于Barrier(&A)… - + &Quit - 退出 + 退出(&Q) - + Quit - 退出 + 退出 - + Run - 运行 + 运行 - + S&top - 停止 + 停止(&t) - + Stop - 停止 - - - - S&how Status - 显示状态 + 停止 - + &Hide - 隐藏 + 隐藏(&H) - + Hide - 隐藏 + 隐藏 - + &Show - 显示 + 显示(&S) - + Show - 显示 + 显示 - - Save configuration &as... - 保存配置到… - - - + Save the interactively generated server configuration to a file. - 保存通过交互配置生成的配置到文件。 - - - - Settings - 设置 + 保存交互生成的配置到文件。 - + Edit settings - 编辑设置 + 编辑设置 - - Run Wizard - 运行向导 + + SSL Fingerprint: + SSL指纹: - - - NewScreenWidget - - Unnamed - 未命名 + + S&ave configuration + 保存配置(&a) - - - PluginManager - - Failed to get plugin directory. - + + Change &Settings + 更改设置(&S) - - Failed to get profile directory. - + + Show &Log + 显示日志(&L) - - Failed to download plugin '%1' to: %2 -%3 - - - - - Could not get Windows architecture type. - - - - - Could not get Linux architecture type. - + + Show Log + 显示日志 - PluginWizardPage - - - Setup Barrier - 设置Barrier - - - - Please wait... - - - - - Error: %1 - - - - - - Setup complete. - - - - - Downloading '%1' plugin (%2/%3)... - - - - - Plugins installed successfully. - - - - - Generating SSL certificate... - - - - - Downloading plugin: %1 (1/%2) - - + NewScreenWidget - - Getting plugin list... - + + Unnamed + 未命名 QObject - - Barrier Configurations (*.sgc);;All files (*.*) - Barrier配置文件(*.sgc);;所有文件 (*.*) + + All files (*.*) + 所有文件 (*.*) - - Barrier Configurations (*.conf);;All files (*.*) - Barrier配置文件(*.conf);;所有文件 (*.*) + + Barrier Configurations (*.sgc) + Barrier配置文件 (*.sgc) - - System tray is unavailable, quitting. - 系统托盘不可用,程序退出。 + + Barrier Configurations (*.conf) + Barrier配置文件 (*.conf) ScreenSettingsDialog - + Screen name is empty - 屏幕名为空 + 屏幕名为空 - + The screen name cannot be empty. Please either fill in a name or cancel the dialog. - 屏幕名不能为空。请填入一个名字或者关闭对话框。 + 屏幕名不能为空。请填入一个名字或者关闭对话框。 - + Screen name matches alias - 屏幕名对应别名 + 屏幕名对应别名 - + The screen name cannot be the same as an alias. Please either remove the alias or change the screen name. - 屏幕名不能与别名相同,请取消或者更改别名。 + 屏幕名不能与别名相同,请取消或者更改别名。 ScreenSettingsDialogBase - + Screen Settings - 屏幕设置 + 屏幕设置 - + Screen &name: - 屏幕名: + 屏幕名: - + A&liases - 别名 + 别名 - + &Add - 添加 + 添加(&A) - + &Remove - 删除 + 删除(&R) - + &Modifier keys - 修改按键 + 修改按键 - + &Shift: - Shift: + Shift: - - - - - + + + + + Shift - Shift + Shift - - - - - + + + + + Ctrl - Ctrl + Ctrl - - - - - + + + + + Alt - Alt + Alt - - - - - + + + + + Meta - Meta + Meta - - - - - + + + + + Super - 超级 + 超级 - - - - - + + + + + None - + - + &Ctrl: - Ctrl: + &Ctrl: - + Al&t: - Alt: + Al&t: - + M&eta: - Meta: + M&eta: - + S&uper: - Super: + S&uper: - + &Dead corners - 死角 + 死角 - + Top-left - 左上角 + 左上角 - + Top-right - 右上角 + 右上角 - + Bottom-left - 左下角 + 左下角 - + Bottom-right - 右下角 + 右下角 - + Corner Si&ze: - 死角大小 + 死角大小 - + &Fixes - 修改 + 修改 - + Fix CAPS LOCK key - 修复caps lock键 + 修复caps lock键 - + Fix NUM LOCK key - 修复num lock键 + 修复num lock键 - + Fix SCROLL LOCK key - 修复scroll lock键 + 修复scroll lock键 - + Fix XTest for Xinerama - 修复Xinerama的XTest + 修复Xinerama的XTest + + + + Fix Preserve Focus + 修复焦点 ScreenSetupModel - + <center>Screen: <b>%1</b></center><br>Double click to edit settings<br>Drag screen to the trashcan to remove it - <center>屏幕设置: <b>%1</b></center><br>双击以修改设置<br>将屏幕拖到废纸篓来移除 + <center>屏幕设置: <b>%1</b></center><br>双击以修改设置<br>将屏幕拖到废纸篓来移除 + + + + ScreenSetupView + + + Unnamed + 未命名 ServerConfigDialog - + Configure server - + 设置服务端 ServerConfigDialogBase - + Server Configuration - 服务端配置 + 服务端配置 - + Screens and links - 屏幕和联接 + 屏幕和联接 - + Drag a screen from the grid to the trashcan to remove it. - 从格子中拖动屏幕到垃圾桶进行删除。 + 从网格中拖动屏幕到垃圾桶进行删除。 - + Configure the layout of your barrier server configuration. - 设置Barrier服务端配置的屏幕布局。 + 配置Barrier服务端的屏幕布局。 - + Drag this button to the grid to add a new screen. - 拖动此按钮到格子中进行添加屏幕。 + 拖动此按钮到网格以添加屏幕。 - + Drag new screens to the grid or move existing ones around. Drag a screen to the trashcan to delete it. Double click on a screen to edit its settings. - 拖动屏幕(图标)到网格中或者移动已经在网格中的屏幕的位置。 + 拖动屏幕图标到网格,或者移动已经在网格中的屏幕。 拖动屏幕到垃圾桶进行删除。 双击屏幕编辑其设置。 - + Hotkeys - 热键 + 热键 - + &Hotkeys - 热键 + 热键(&H) - + &New - 新建 + 新建(&N) - + &Edit - 编辑 + 编辑(&E) - + &Remove - 删除 + 删除(&R) - + A&ctions - 行为 + 动作 - + Ne&w - 新建 + 新建(&w) - + E&dit - 编辑 + 编辑(&d) - + Re&move - 删除 + 删除(&m) - + Advanced server settings - 服务端高级设置 + 服务端高级设置 - + &Switch - 切换 + 触边切换 - + Switch &after waiting - 等待后切换 + 延时 - - - + + + ms - 毫秒 + 毫秒 - + Switch on double &tap within - 双击tap切换 + 二次触边 - + &Options - 选项 + 选项 - + &Check clients every - 客户端检查周期 + 客户端检查周期 - + Use &relative mouse moves - 使用相关的鼠标动作 + 使用相对的鼠标动作 - + S&ynchronize screen savers - 同步屏幕保护 + 同步屏幕保护 - - Don't take &foreground window on Windows servers - 不要移动前台窗口在Windows服务器上 + + Don't take &foreground window on Windows servers + 不要在Windows服务端获取前台窗口 - + Ignore auto config clients - + 忽略自动配置的客户端 - + &Dead corners - 死角 + 死角 - + To&p-left - 左上角 + 左上角 - + Top-rig&ht - 右上角 + 右上角 - + &Bottom-left - 左下角 + 左下角 - + Bottom-ri&ght - 右下角 + 右下角 - + Cor&ner Size: - 死角大小 + 死角大小 - - - SettingsDialog - - Save log file to... - 保存日志文件… + + Bump against the screen edge with the mouse pointer twice in quick succession. + 要触发二次触边,快速并连续地滑动指针到屏幕边缘。 - - Elevate Barrier - 评价Barrier + + Enable drag and drop file transfers + 启用拖放文件传输 - - Are you sure you want to elevate Barrier? - -This allows Barrier to interact with elevated processes and the UAC dialog, but can cause problems with non-elevated processes. Elevate Barrier only if you really need to. - 您确定要elevate Barrier吗? -这会允许Barrier和elevated进程交互和UAC对话框,但是可能引起一切和非elevated进程交互的问题。只有在你需要的时候才Elevate Barrier。 + + Enable clipboard sharing + 启用剪切板共享 + + + + SettingsDialog + + + Save log file to... + 保存日志文件… SettingsDialogBase - + Settings - 设置 + 设置 - + Sc&reen name: - 屏幕名称: + 屏幕名称: - + P&ort: - 端口: - - - - &Interface: - 界面 + 端口: - - Elevate mode - - - - + &Hide on startup - + 最小化启动 - - &Network Security - - - - - Use &SSL encryption (unique certificate) - - - - + Logging - 日志记录 + 日志 - + &Logging level: - 日志等级 + 日志等级 - + Log to file: - 记录到文件 + 记录到文件 - + Browse... - 浏览… + 浏览… - + Error - 错误 + 错误 - + &Language: - 语言: - - - - &Miscellaneous - 其他 + 语言: - + Warning - 警告 + 警告 - + Note - 注意 + 注意 - + Info - 信息 + 信息 - + Debug - 调试 + 调试 - + Debug1 - 调试1 + 调试1 - + Debug2 - 调试2 + 调试2 - - - SetupWizard - - Setup Barrier - 设置Barrier + + General + 通用 - - Please select an option. - 请选择一个选项 + + Elevate + 提权 - - Please enter your email address and password. - 请输入您的邮箱地址和密码。 + + Specify when the Barrier service should run at an elevated privilege level + 设置Barrier服务何时应该提权运行 - - - SetupWizardBase - - Setup Barrier - 设置Barrier + + As Needed + 按需 - - Welcome - 欢迎 + + Always + 总是 - - Thanks for installing Barrier! - 感谢您安装Barrier! + + Never + 从不 - - Barrier lets you easily share your mouse and keyboard between multiple computers on your desk, and it's Free and Open Source. Just move your mouse off the edge of one computer's screen on to another. You can even share all of your clipboards. All you need is a network connection. Barrier is cross-platform (works on Windows, Mac OS X and Linux). - Barrier允许你轻松地在你办公桌上多台计算机之间共享你的鼠标和键盘,它免费并且开放源代码。你只要将鼠标(指针)从一台计算机的屏幕边缘移出到另一个屏幕就行了。甚至可以共享你的剪贴板。你所需要的仅仅是一个网络连接。Barrier是跨平台的(可以运行于Windows,Mac OS X和Linux)。 + + Minimize to System &Tray + 最小化到系统托盘 - - Activate - + + Start &Barrier on startup + 自动启动 - - &Activate now... - + + Networking + 网络 - - Email: - + + &Address: + 地址: - - Password: - + + Enable &SSL + 开启SSL + + + SetupWizard - - <a href="https://symless.com/account/reset/">Forgot password</a> - + + Setup Barrier + 设置Barrier - - &Skip activation - + + Please select an option. + 请选择一个选项 + + + + SetupWizardBase + + + Setup Barrier + 设置Barrier - - &Server (share this computer's mouse and keyboard) - + + Welcome + 欢迎 + + + + Thanks for installing Barrier! + 感谢您安装Barrier! - + + Barrier lets you easily share your mouse and keyboard between multiple computers on your desk, and it's Free and Open Source. Just move your mouse off the edge of one computer's screen on to another. You can even share all of your clipboards. All you need is a network connection. Barrier is cross-platform (works on Windows, Mac OS X and Linux). + Barrier可以在多台计算机间轻松共享你的鼠标和键盘,它还是自由开源软件。将鼠标指针从计算机的屏幕边缘移出到另一个屏幕,并同时共享剪贴板,只要你有一个网络连接。Barrier是跨平台的(可以运行于Windows,Mac OS X和Linux)。 + + + + &Server (share this computer's mouse and keyboard) + 服务端 - 共享此电脑的鼠标和键盘 + + + <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">My main mouse and keyboard are connected to this computer. This will allow you to move your mouse over to another computer's screen. There can only be one server in your setup.</span></p></body></html> - +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">My main mouse and keyboard are connected to this computer. This will allow you to move your mouse over to another computer's screen. There can only be one server in your setup.</span></p></body></html> + <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">这台电脑连接了鼠标和键盘,需要共享给其他电脑。一套配置只能有一个服务端。</span></p></body></html> - - &Client (use another computer's mouse and keyboard) - + + &Client (use another computer's mouse and keyboard) + 客户端 - 使用另一电脑的鼠标和键盘 - + <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">You have already set up a server. This computer will be controlled using the server's mouse and keyboard. There can be many clients in your setup.</span></p></body></html> - +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">You have already set up a server. This computer will be controlled using the server's mouse and keyboard. There can be many clients in your setup.</span></p></body></html> + <!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">已经配置了服务端,此电脑将由服务端的鼠标和键盘进行控制。可以配置多个客户端。</span></p></body></html> - + Server or Client? - (此计算机作为)服务端还是客户端? + 服务端还是客户端? SslCertificate - + Failed to get profile directory. - + 获取配置目录失败。 - + SSL certificate generated. - + SSL证书已生成。 - + SSL fingerprint generated. - + SSL指纹已生成。 - + Failed to find SSL fingerprint. - + 无法找到SSL指纹。 - - - VersionChecker - - Unknown - 未知 + + Could not read from default certificate file. + 无法读取默认证书文件。 - - - WebClient - - An error occurred while trying to sign in. Please contact the helpdesk, and provide the following details. - -%1 - - - - - Login failed, invalid email or password. - 登录失败,邮箱地址或密码错误。 + + Error loading default certificate file to memory. + 读取默认证书文件失败。 - - Login failed, an error occurred. - -%1 - 登录失败,出错了。 -%1 + + Default certificate key file does not contain valid public key + 默认证书文件没有有效的公钥 - - Login failed, an error occurred. - -Server response: - -%1 - 登录失败,出错了。 -服务器回应: -%1 + + Public key in default certificate key file is not RSA or DSA + 默认证书文件的公钥不是RSA或DSA - - An error occurred while trying to query the plugin list. Please contact the help desk, and provide the following details. - -%1 - - - - - Get plugin list failed, invalid user email or password. - - - - - Get plugin list failed, an error occurred. - -%1 - + + Public key in default certificate key file is too small. + 默认证书文件位数不足。 + + + VersionChecker - - Get plugin list failed, an error occurred. - -Server response: - -%1 - + + Unknown + 未知 ZeroconfService - + zeroconf server detected: %1 - + 检测到zeroconf服务端:%1 - + zeroconf client detected: %1 - + 检测到zeroconf客户端:%1 - - + + Zero configuration service - + zeroconf服务 - + Error code: %1. - + 错误代码:%1。 - + Unable to start the zeroconf: %1. - + 无法启动zeroconf:%1。 - + Barrier - Barrier + Barrier - + Failed to get local IP address. Please manually type in server address on your clients - + 无法获取本地IP地址。请在客户端上手动输入服务端地址。 - - + + %1 - + %1 - \ No newline at end of file + diff --git a/src/gui/res/lang/gui_zh-TW.qm b/src/gui/res/lang/gui_zh-TW.qm index 5cc8653..ac43686 100644 Binary files a/src/gui/res/lang/gui_zh-TW.qm and b/src/gui/res/lang/gui_zh-TW.qm differ diff --git a/src/gui/res/lang/gui_zh-TW.ts b/src/gui/res/lang/gui_zh-TW.ts index 902a444..d4d305a 100644 --- a/src/gui/res/lang/gui_zh-TW.ts +++ b/src/gui/res/lang/gui_zh-TW.ts @@ -648,13 +648,18 @@ To automatically trust this fingerprint for future connections, click Yes. To re QObject - Barrier Configurations (*.sgc);;All files (*.*) - Barrier 設定檔 (*.sgc);;所有檔案 (*.*) + All files (*.*) + 所有檔案 (*.*) + + + + Barrier Configurations (*.sgc) + Barrier 設定檔 (*.sgc) - Barrier Configurations (*.conf);;All files (*.*) - Barrier 設定檔 (*.conf);;所有檔案 (*.*) + Barrier Configurations (*.conf) + Barrier 設定檔 (*.conf) diff --git a/src/gui/res/win/Barrier.rc b/src/gui/res/win/Barrier.rc index 9db2b3e..2825690 100644 --- a/src/gui/res/win/Barrier.rc +++ b/src/gui/res/win/Barrier.rc @@ -1 +1,112 @@ -IDI_ICON1 ICON DISCARDABLE "../icons/256x256/barrier.ico" +// Microsoft Visual C++ generated resource script. +// +//#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include \r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION BARRIER_VERSION_MAJOR, BARRIER_VERSION_MINOR, BARRIER_VERSION_PATCH, BARRIER_BUILD_NUMBER + PRODUCTVERSION BARRIER_VERSION_MAJOR, BARRIER_VERSION_MINOR, BARRIER_VERSION_PATCH, BARRIER_BUILD_NUMBER + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Debauchee Open Source Group" + VALUE "CompanyWeb", "https://github.com/debauchee/barrier/" + VALUE "FileVersion", BARRIER_VERSION + VALUE "LegalCopyright", "Copyright (C) 2018 Debauchee Open Source Group\nCopyright (C) 2012-2016 Symless Ltd.\nCopyright (C) 2008-2014 Nick Bolton\nCopyright (C) 2002-2014 Chris Schoeneman" + VALUE "ProductName", "Barrier" + VALUE "ProductVersion", BARRIER_VERSION + VALUE "OriginalFilename", "barrier.exe" + VALUE "FileDescription", "Open source KVM software" + VALUE "InternalName", "barrier" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_BARRIER ICON "../icons/256x256/barrier.ico" + + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/gui/src/AboutDialog.cpp b/src/gui/src/AboutDialog.cpp index 76ba26b..b594bee 100644 --- a/src/gui/src/AboutDialog.cpp +++ b/src/gui/src/AboutDialog.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 diff --git a/src/gui/src/AboutDialog.h b/src/gui/src/AboutDialog.h index 3c498b4..6fdb0a2 100644 --- a/src/gui/src/AboutDialog.h +++ b/src/gui/src/AboutDialog.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -40,4 +40,3 @@ class AboutDialog : public QDialog, public Ui::AboutDialogBase }; #endif - diff --git a/src/gui/src/Action.cpp b/src/gui/src/Action.cpp index 909e983..f34d1e8 100644 --- a/src/gui/src/Action.cpp +++ b/src/gui/src/Action.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -51,7 +51,7 @@ QString Action::text() const * in the end but now argument inside. If you need a function with no * argument, it can not have () in the end. */ - QString text = QString(m_ActionTypeNames[keySequence().isMouseButton() ? + QString text = QString(m_ActionTypeNames[m_KeySequence.isMouseButton() ? type() + int(mouseDown) : type()]); switch (type()) @@ -61,9 +61,9 @@ QString Action::text() const case keystroke: { text += "("; - text += keySequence().toString(); + text += m_KeySequence.toString(); - if (!keySequence().isMouseButton()) + if (!m_KeySequence.isMouseButton()) { const QStringList& screens = typeScreenNames(); if (haveScreens() && !screens.isEmpty()) @@ -116,15 +116,15 @@ QString Action::text() const void Action::loadSettings(QSettings& settings) { - keySequence().loadSettings(settings); + m_KeySequence.loadSettings(settings); setType(settings.value("type", keyDown).toInt()); - typeScreenNames().clear(); + m_TypeScreenNames.clear(); int numTypeScreens = settings.beginReadArray("typeScreenNames"); for (int i = 0; i < numTypeScreens; i++) { settings.setArrayIndex(i); - typeScreenNames().append(settings.value("typeScreenName").toString()); + m_TypeScreenNames.append(settings.value("typeScreenName").toString()); } settings.endArray(); @@ -137,7 +137,7 @@ void Action::loadSettings(QSettings& settings) void Action::saveSettings(QSettings& settings) const { - keySequence().saveSettings(settings); + m_KeySequence.saveSettings(settings); settings.setValue("type", type()); settings.beginWriteArray("typeScreenNames"); @@ -164,4 +164,3 @@ QTextStream& operator<<(QTextStream& outStream, const Action& action) return outStream; } - diff --git a/src/gui/src/Action.h b/src/gui/src/Action.h index b738f3b..c260bad 100644 --- a/src/gui/src/Action.h +++ b/src/gui/src/Action.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -32,9 +32,6 @@ class QTextStream; class Action { - friend class ActionDialog; - friend QTextStream& operator<<(QTextStream& outStream, const Action& action); - public: enum ActionType { keyDown, keyUp, keystroke, switchToScreen, toggleScreen, switchInDirection, @@ -48,25 +45,31 @@ class Action public: QString text() const; const KeySequence& keySequence() const { return m_KeySequence; } + void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; } + void loadSettings(QSettings& settings); void saveSettings(QSettings& settings) const; + int type() const { return m_Type; } + void setType(int t) { m_Type = t; } + const QStringList& typeScreenNames() const { return m_TypeScreenNames; } - const QString& switchScreenName() const { return m_SwitchScreenName; } - int switchDirection() const { return m_SwitchDirection; } - int lockCursorMode() const { return m_LockCursorMode; } - bool activeOnRelease() const { return m_ActiveOnRelease; } - bool haveScreens() const { return m_HasScreens; } + void appendTypeScreenName(QString name) { m_TypeScreenNames.append(name); } + void clearTypeScreenNames() { m_TypeScreenNames.clear(); } - protected: - KeySequence& keySequence() { return m_KeySequence; } - void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; } - void setType(int t) { m_Type = t; } - QStringList& typeScreenNames() { return m_TypeScreenNames; } + const QString& switchScreenName() const { return m_SwitchScreenName; } void setSwitchScreenName(const QString& n) { m_SwitchScreenName = n; } + + int switchDirection() const { return m_SwitchDirection; } void setSwitchDirection(int d) { m_SwitchDirection = d; } + + int lockCursorMode() const { return m_LockCursorMode; } void setLockCursorMode(int m) { m_LockCursorMode = m; } + + bool activeOnRelease() const { return m_ActiveOnRelease; } void setActiveOnRelease(bool b) { m_ActiveOnRelease = b; } + + bool haveScreens() const { return m_HasScreens; } void setHaveScreens(bool b) { m_HasScreens = b; } private: @@ -84,8 +87,6 @@ class Action static const char* m_LockCursorModeNames[]; }; -typedef QList ActionList; - QTextStream& operator<<(QTextStream& outStream, const Action& action); #endif diff --git a/src/gui/src/ActionDialog.cpp b/src/gui/src/ActionDialog.cpp index 2796885..89a037e 100644 --- a/src/gui/src/ActionDialog.cpp +++ b/src/gui/src/ActionDialog.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -58,7 +58,7 @@ ActionDialog::ActionDialog(QWidget* parent, ServerConfig& config, Hotkey& hotkey m_pGroupBoxScreens->setChecked(m_Action.haveScreens()); int idx = 0; - foreach(const Screen& screen, serverConfig().screens()) + for (const Screen& screen : serverConfig().screens()) { if (!screen.isNull()) { QListWidgetItem *pListItem = new QListWidgetItem(screen.name()); @@ -72,6 +72,7 @@ ActionDialog::ActionDialog(QWidget* parent, ServerConfig& config, Hotkey& hotkey idx++; } + } } void ActionDialog::accept() @@ -83,9 +84,10 @@ void ActionDialog::accept() m_Action.setType(m_pButtonGroupType->checkedId()); m_Action.setHaveScreens(m_pGroupBoxScreens->isChecked()); - m_Action.typeScreenNames().clear(); - foreach(const QListWidgetItem* pItem, m_pListScreens->selectedItems()) - m_Action.typeScreenNames().append(pItem->text()); + m_Action.clearTypeScreenNames(); + for (const QListWidgetItem* pItem : m_pListScreens->selectedItems()) { + m_Action.appendTypeScreenName(pItem->text()); + } m_Action.setSwitchScreenName(m_pComboSwitchToScreen->currentText()); m_Action.setSwitchDirection(m_pComboSwitchInDirection->currentIndex()); diff --git a/src/gui/src/ActionDialog.h b/src/gui/src/ActionDialog.h index 388be1f..ea476c5 100644 --- a/src/gui/src/ActionDialog.h +++ b/src/gui/src/ActionDialog.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 diff --git a/src/gui/src/AppConfig.cpp b/src/gui/src/AppConfig.cpp index 2f8779d..894ce49 100644 --- a/src/gui/src/AppConfig.cpp +++ b/src/gui/src/AppConfig.cpp @@ -60,6 +60,7 @@ AppConfig::AppConfig(QSettings* settings) : m_AutoConfigPrompted(false), m_CryptoEnabled(false), m_AutoHide(false), + m_AutoStart(false), m_MinimizeToTray(false) { Q_ASSERT(m_pSettings); @@ -157,7 +158,10 @@ void AppConfig::loadSettings() m_ElevateMode = static_cast(elevateMode.toInt()); m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool(); m_CryptoEnabled = settings().value("cryptoEnabled", true).toBool(); + // TODO: set default value of requireClientCertificate to true on Barrier 2.5.0 + m_RequireClientCertificate = settings().value("requireClientCertificate", false).toBool(); m_AutoHide = settings().value("autoHide", false).toBool(); + m_AutoStart = settings().value("autoStart", false).toBool(); m_MinimizeToTray = settings().value("minimizeToTray", false).toBool(); } @@ -179,7 +183,9 @@ void AppConfig::saveSettings() settings().setValue("elevateModeEnum", static_cast(m_ElevateMode)); settings().setValue("autoConfigPrompted", m_AutoConfigPrompted); settings().setValue("cryptoEnabled", m_CryptoEnabled); + settings().setValue("requireClientCertificate", m_RequireClientCertificate); settings().setValue("autoHide", m_AutoHide); + settings().setValue("autoStart", m_AutoStart); settings().setValue("minimizeToTray", m_MinimizeToTray); settings().sync(); } @@ -208,7 +214,7 @@ void AppConfig::setElevateMode(ElevateMode em) { m_ElevateMode = em; } void AppConfig::setAutoConfig(bool autoConfig) { m_AutoConfig = autoConfig; } -bool AppConfig::autoConfigPrompted() { return m_AutoConfigPrompted; } +bool AppConfig::autoConfigPrompted() { return m_AutoConfigPrompted; } void AppConfig::setAutoConfigPrompted(bool prompted) { m_AutoConfigPrompted = prompted; } @@ -222,10 +228,18 @@ void AppConfig::setCryptoEnabled(bool e) { m_CryptoEnabled = e; } bool AppConfig::getCryptoEnabled() const { return m_CryptoEnabled; } +void AppConfig::setRequireClientCertificate(bool e) { m_RequireClientCertificate = e; } + +bool AppConfig::getRequireClientCertificate() const { return m_RequireClientCertificate; } + void AppConfig::setAutoHide(bool b) { m_AutoHide = b; } bool AppConfig::getAutoHide() { return m_AutoHide; } +void AppConfig::setAutoStart(bool b) { m_AutoStart = b; } + +bool AppConfig::getAutoStart() { return m_AutoStart; } + void AppConfig::setMinimizeToTray(bool b) { m_MinimizeToTray = b; } bool AppConfig::getMinimizeToTray() { return m_MinimizeToTray; } diff --git a/src/gui/src/AppConfig.h b/src/gui/src/AppConfig.h index c9ed38d..0dabb18 100644 --- a/src/gui/src/AppConfig.h +++ b/src/gui/src/AppConfig.h @@ -91,9 +91,15 @@ class AppConfig: public QObject void setCryptoEnabled(bool e); bool getCryptoEnabled() const; + void setRequireClientCertificate(bool e); + bool getRequireClientCertificate() const; + void setAutoHide(bool b); bool getAutoHide(); + void setAutoStart(bool b); + bool getAutoStart(); + void setMinimizeToTray(bool b); bool getMinimizeToTray(); @@ -129,7 +135,9 @@ protected: ElevateMode m_ElevateMode; bool m_AutoConfigPrompted; bool m_CryptoEnabled; + bool m_RequireClientCertificate = false; bool m_AutoHide; + bool m_AutoStart; bool m_MinimizeToTray; static const char m_BarriersName[]; diff --git a/src/gui/src/BaseConfig.cpp b/src/gui/src/BaseConfig.cpp index 241f590..0f31493 100644 --- a/src/gui/src/BaseConfig.cpp +++ b/src/gui/src/BaseConfig.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -44,4 +44,3 @@ const char* BaseConfig::m_SwitchCornerNames[] = "bottom-left", "bottom-right" }; - diff --git a/src/gui/src/BaseConfig.h b/src/gui/src/BaseConfig.h index cf41ac6..9dc6b65 100644 --- a/src/gui/src/BaseConfig.h +++ b/src/gui/src/BaseConfig.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 diff --git a/src/gui/src/Fingerprint.cpp b/src/gui/src/Fingerprint.cpp deleted file mode 100644 index 24c8a1a..0000000 --- a/src/gui/src/Fingerprint.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * barrier -- 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 "Fingerprint.h" - -#include "common/DataDirectories.h" - -#include -#include - -static const char kDirName[] = "SSL/Fingerprints"; -static const char kLocalFilename[] = "Local.txt"; -static const char kTrustedServersFilename[] = "TrustedServers.txt"; -static const char kTrustedClientsFilename[] = "TrustedClients.txt"; - -Fingerprint::Fingerprint(const QString& filename) -{ - m_Filename = filename; -} - -void Fingerprint::trust(const QString& fingerprintText, bool append) -{ - Fingerprint::persistDirectory(); - - QIODevice::OpenMode openMode; - if (append) { - openMode = QIODevice::Append; - } - else { - openMode = QIODevice::WriteOnly; - } - - QFile file(filePath()); - if (file.open(openMode)) - { - QTextStream out(&file); - out << fingerprintText << "\n"; - file.close(); - } -} - -bool Fingerprint::fileExists() const -{ - QString dirName = Fingerprint::directoryPath(); - if (!QDir(dirName).exists()) { - return false; - } - - QFile file(filePath()); - return file.exists(); -} - -bool Fingerprint::isTrusted(const QString& fingerprintText) -{ - QStringList list = readList(); - foreach (QString trusted, list) - { - if (trusted == fingerprintText) { - return true; - } - } - return false; -} - -QStringList Fingerprint::readList(const int readTo) -{ - QStringList list; - - QString dirName = Fingerprint::directoryPath(); - if (!QDir(dirName).exists()) { - return list; - } - - QFile file(filePath()); - - if (file.open(QIODevice::ReadOnly)) - { - QTextStream in(&file); - while (!in.atEnd()) - { - list.append(in.readLine()); - if (list.size() == readTo) { - break; - } - } - file.close(); - } - - return list; -} - -QString Fingerprint::readFirst() -{ - QStringList list = readList(1); - return list.at(0); -} - -QString Fingerprint::filePath() const -{ - QString dir = Fingerprint::directoryPath(); - return QString("%1/%2").arg(dir).arg(m_Filename); -} - -void Fingerprint::persistDirectory() -{ - QDir dir(Fingerprint::directoryPath()); - if (!dir.exists()) { - dir.mkpath("."); - } -} - -QString Fingerprint::directoryPath() -{ - auto profileDir = QString::fromStdString(DataDirectories::profile()); - - return QString("%1/%2") - .arg(profileDir) - .arg(kDirName); -} - -Fingerprint Fingerprint::local() -{ - return Fingerprint(kLocalFilename); -} - -Fingerprint Fingerprint::trustedServers() -{ - return Fingerprint(kTrustedServersFilename); -} - -Fingerprint Fingerprint::trustedClients() -{ - return Fingerprint(kTrustedClientsFilename); -} diff --git a/src/gui/src/Fingerprint.h b/src/gui/src/Fingerprint.h deleted file mode 100644 index 5a38d20..0000000 --- a/src/gui/src/Fingerprint.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * barrier -- 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 - -#include - -class Fingerprint -{ -public: - void trust(const QString& fingerprintText, bool append = true); - bool isTrusted(const QString& fingerprintText); - QStringList readList(const int readTo = -1); - QString readFirst(); - QString filePath() const; - bool fileExists() const; - - static Fingerprint local(); - static Fingerprint trustedServers(); - static Fingerprint trustedClients(); - static QString directoryPath(); - static void persistDirectory(); - -private: - Fingerprint(const QString& filename); - - QString m_Filename; -}; diff --git a/src/gui/src/FingerprintAcceptDialog.cpp b/src/gui/src/FingerprintAcceptDialog.cpp new file mode 100644 index 0000000..e0dc7e6 --- /dev/null +++ b/src/gui/src/FingerprintAcceptDialog.cpp @@ -0,0 +1,65 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 "FingerprintAcceptDialog.h" +#include "ui_FingerprintAcceptDialog.h" +#include "net/SecureUtils.h" + +FingerprintAcceptDialog::FingerprintAcceptDialog(QWidget *parent, + BarrierType type, + const barrier::FingerprintData& fingerprint_sha1, + const barrier::FingerprintData& fingerprint_sha256) : + QDialog(parent), + ui_{std::make_unique()} +{ + ui_->setupUi(this); + + if (type == BarrierType::Server) { + ui_->label_sha1->hide(); + ui_->label_sha1_fingerprint_full->hide(); + } else { + ui_->label_sha1_fingerprint_full->setText( + QString::fromStdString(barrier::format_ssl_fingerprint(fingerprint_sha1.data))); + } + + ui_->label_sha256_fingerprint_full->setText( + QString::fromStdString(barrier::format_ssl_fingerprint_columns(fingerprint_sha256.data))); + ui_->label_sha256_fingerprint_randomart->setText( + QString::fromStdString(barrier::create_fingerprint_randomart(fingerprint_sha256.data))); + + QString explanation; + if (type == BarrierType::Server) { + explanation = tr("This is a client fingerprint. You should compare this " + "fingerprint to the one on your client's screen. If the " + "two don't match exactly, then it's probably not the client " + "you're expecting (it could be a malicious user).\n\n" + "To automatically trust this fingerprint for future " + "connections, click Yes. To reject this fingerprint and " + "disconnect the client, click No."); + } else { + explanation = tr("This is a server fingerprint. You should compare this " + "fingerprint to the one on your server's screen. If the " + "two don't match exactly, then it's probably not the server " + "you're expecting (it could be a malicious user).\n\n" + "To automatically trust this fingerprint for future " + "connections, click Yes. To reject this fingerprint and " + "disconnect from the server, click No."); + } + ui_->label_explanation->setText(explanation); +} + +FingerprintAcceptDialog::~FingerprintAcceptDialog() = default; diff --git a/src/gui/src/FingerprintAcceptDialog.h b/src/gui/src/FingerprintAcceptDialog.h new file mode 100644 index 0000000..da8884c --- /dev/null +++ b/src/gui/src/FingerprintAcceptDialog.h @@ -0,0 +1,45 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 BARRIER_GUI_FINGERPRINT_ACCEPT_DIALOG_H +#define BARRIER_GUI_FINGERPRINT_ACCEPT_DIALOG_H + +#include "net/FingerprintData.h" +#include "barrier/BarrierType.h" +#include +#include + +namespace Ui { +class FingerprintAcceptDialog; +} + +class FingerprintAcceptDialog : public QDialog +{ + Q_OBJECT + +public: + explicit FingerprintAcceptDialog(QWidget* parent, + BarrierType type, + const barrier::FingerprintData& fingerprint_sha1, + const barrier::FingerprintData& fingerprint_sha256); + ~FingerprintAcceptDialog() override; + +private: + std::unique_ptr ui_; +}; + +#endif // BARRIER_GUI_FINGERPRINT_ACCEPT_DIALOG_H diff --git a/src/gui/src/FingerprintAcceptDialog.ui b/src/gui/src/FingerprintAcceptDialog.ui new file mode 100644 index 0000000..9c181ec --- /dev/null +++ b/src/gui/src/FingerprintAcceptDialog.ui @@ -0,0 +1,174 @@ + + + FingerprintAcceptDialog + + + + 0 + 0 + 600 + 400 + + + + + 0 + 0 + + + + Security question + + + + QLayout::SetFixedSize + + + + + Qt::Horizontal + + + QDialogButtonBox::No|QDialogButtonBox::Yes + + + + + + + + 0 + 0 + + + + SHA1 (deprecated, compare to old servers only) + + + + + + + + 0 + 0 + + + + + + + true + + + 10 + + + + + + + + 0 + 0 + + + + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Do you trust this fingerprint? + + + + + + + + 0 + 0 + + + + + Courier + 75 + true + + + + + + + Qt::AlignCenter + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + Qt::AlignCenter + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + SHA256: + + + + + + + + + buttonBox + accepted() + FingerprintAcceptDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + FingerprintAcceptDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/gui/src/Hotkey.cpp b/src/gui/src/Hotkey.cpp index c7138e7..4c008f8 100644 --- a/src/gui/src/Hotkey.cpp +++ b/src/gui/src/Hotkey.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -28,9 +28,9 @@ Hotkey::Hotkey() : QString Hotkey::text() const { - QString text = keySequence().toString(); + QString text = m_KeySequence.toString(); - if (keySequence().isMouseButton()) + if (m_KeySequence.isMouseButton()) return "mousebutton(" + text + ")"; return "keystroke(" + text + ")"; @@ -38,16 +38,16 @@ QString Hotkey::text() const void Hotkey::loadSettings(QSettings& settings) { - keySequence().loadSettings(settings); + m_KeySequence.loadSettings(settings); - actions().clear(); + m_Actions.clear(); int num = settings.beginReadArray("actions"); for (int i = 0; i < num; i++) { settings.setArrayIndex(i); Action a; a.loadSettings(settings); - actions().append(a); + m_Actions.push_back(a); } settings.endArray(); @@ -55,21 +55,33 @@ void Hotkey::loadSettings(QSettings& settings) void Hotkey::saveSettings(QSettings& settings) const { - keySequence().saveSettings(settings); + m_KeySequence.saveSettings(settings); settings.beginWriteArray("actions"); - for (int i = 0; i < actions().size(); i++) + for (int i = 0; i < m_Actions.size(); i++) { settings.setArrayIndex(i); - actions()[i].saveSettings(settings); + m_Actions[i].saveSettings(settings); } settings.endArray(); } QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey) { - for (int i = 0; i < hotkey.actions().size(); i++) - outStream << "\t" << hotkey.text() << " = " << hotkey.actions()[i] << endl; + // Don't write config if there are no actions + if (hotkey.actions().size() == 0) { + return outStream; + } + + outStream << "\t" << hotkey.text() << " = "; + for (int i = 0; i < hotkey.actions().size(); i++) { + outStream << hotkey.actions()[i]; + if (i != hotkey.actions().size() - 1) { + outStream << ", "; + } + } + + outStream << "\n"; return outStream; } diff --git a/src/gui/src/Hotkey.h b/src/gui/src/Hotkey.h index 475da02..5e6fc98 100644 --- a/src/gui/src/Hotkey.h +++ b/src/gui/src/Hotkey.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -27,40 +27,35 @@ #include "Action.h" #include "KeySequence.h" +#include + class HotkeyDialog; class ServerConfigDialog; class QSettings; class Hotkey { - friend class HotkeyDialog; - friend class ServerConfigDialog; - friend QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey); - public: Hotkey(); - public: QString text() const; const KeySequence& keySequence() const { return m_KeySequence; } - const ActionList& actions() const { return m_Actions; } + void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; } + + const std::vector& actions() const { return m_Actions; } + void appendAction(const Action& action) { m_Actions.push_back(action); } + void setAction(int index, const Action& action) { m_Actions[index] = action; } + void removeAction(int index) { m_Actions.erase(m_Actions.begin() + index); } void loadSettings(QSettings& settings); void saveSettings(QSettings& settings) const; - protected: - KeySequence& keySequence() { return m_KeySequence; } - void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; } - ActionList& actions() { return m_Actions; } - private: KeySequence m_KeySequence; - ActionList m_Actions; + std::vector m_Actions; }; -typedef QList HotkeyList; - QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey); #endif diff --git a/src/gui/src/HotkeyDialog.cpp b/src/gui/src/HotkeyDialog.cpp index ef25c3f..5b3e5a8 100644 --- a/src/gui/src/HotkeyDialog.cpp +++ b/src/gui/src/HotkeyDialog.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 diff --git a/src/gui/src/HotkeyDialog.h b/src/gui/src/HotkeyDialog.h index a13fc24..3a9967c 100644 --- a/src/gui/src/HotkeyDialog.h +++ b/src/gui/src/HotkeyDialog.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 diff --git a/src/gui/src/IpcClient.h b/src/gui/src/IpcClient.h index cd398b3..6040029 100644 --- a/src/gui/src/IpcClient.h +++ b/src/gui/src/IpcClient.h @@ -28,7 +28,7 @@ class IpcReader; class IpcClient : public QObject { - Q_OBJECT + Q_OBJECT public: IpcClient(); diff --git a/src/gui/src/KeySequence.cpp b/src/gui/src/KeySequence.cpp index cc74cb2..ddf7d33 100644 --- a/src/gui/src/KeySequence.cpp +++ b/src/gui/src/KeySequence.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -55,6 +55,8 @@ static const struct { Qt::Key_Help, "Help" }, { Qt::Key_Enter, "KP_Enter" }, { Qt::Key_Clear, "Clear" }, + { Qt::Key_Comma, "Comma" }, + { Qt::Key_Semicolon, "Semicolon" }, { Qt::Key_Back, "WWWBack" }, { Qt::Key_Forward, "WWWForward" }, @@ -152,12 +154,12 @@ bool KeySequence::appendKey(int key, int modifiers) void KeySequence::loadSettings(QSettings& settings) { - sequence().clear(); + m_Sequence.clear(); int num = settings.beginReadArray("keys"); for (int i = 0; i < num; i++) { settings.setArrayIndex(i); - sequence().append(settings.value("key", 0).toInt()); + m_Sequence.append(settings.value("key", 0).toInt()); } settings.endArray(); @@ -168,10 +170,10 @@ void KeySequence::loadSettings(QSettings& settings) void KeySequence::saveSettings(QSettings& settings) const { settings.beginWriteArray("keys"); - for (int i = 0; i < sequence().size(); i++) + for (int i = 0; i < m_Sequence.size(); i++) { settings.setArrayIndex(i); - settings.setValue("key", sequence()[i]); + settings.setValue("key", m_Sequence[i]); } settings.endArray(); } @@ -211,23 +213,22 @@ QString KeySequence::keyToString(int key) // treat key pad like normal keys (FIXME: we should have another lookup table for keypad keys instead) key &= ~Qt::KeypadModifier; + // a special key? + int i = 0; + while (keyname[i].name) { + if (key == keyname[i].key) + return QString::fromUtf8(keyname[i].name); + i++; + } + // a printable 7 bit character? - if (key < 0x80 && key != Qt::Key_Space) + if (key < 0x80) return QChar(key & 0x7f).toLower(); // a function key? if (key >= Qt::Key_F1 && key <= Qt::Key_F35) return QString::fromUtf8("F%1").arg(key - Qt::Key_F1 + 1); - // a special key? - int i=0; - while (keyname[i].name) - { - if (key == keyname[i].key) - return QString::fromUtf8(keyname[i].name); - i++; - } - // representable in ucs2? if (key < 0x10000) return QString("\\u%1").arg(QChar(key).toLower().unicode(), 4, 16, QChar('0')); diff --git a/src/gui/src/KeySequence.h b/src/gui/src/KeySequence.h index 8d9706d..0331091 100644 --- a/src/gui/src/KeySequence.h +++ b/src/gui/src/KeySequence.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -32,7 +32,7 @@ class KeySequence public: QString toString() const; - bool appendKey(int modifiers, int key); + bool appendKey(int key, int modifiers); bool appendMouseButton(int button); bool isMouseButton() const; bool valid() const { return m_IsValid; } @@ -44,7 +44,6 @@ class KeySequence private: void setValid(bool b) { m_IsValid = b; } void setModifiers(int i) { m_Modifiers = i; } - QList& sequence() { return m_Sequence; } private: QList m_Sequence; @@ -55,4 +54,3 @@ class KeySequence }; #endif - diff --git a/src/gui/src/KeySequenceWidget.cpp b/src/gui/src/KeySequenceWidget.cpp index e5823e1..067c5bf 100644 --- a/src/gui/src/KeySequenceWidget.cpp +++ b/src/gui/src/KeySequenceWidget.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 diff --git a/src/gui/src/KeySequenceWidget.h b/src/gui/src/KeySequenceWidget.h index eaef514..636375b 100644 --- a/src/gui/src/KeySequenceWidget.h +++ b/src/gui/src/KeySequenceWidget.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -78,4 +78,3 @@ class KeySequenceWidget : public QPushButton }; #endif - diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 01133bf..d17548a 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -20,18 +20,21 @@ #include "MainWindow.h" -#include "Fingerprint.h" #include "AboutDialog.h" #include "ServerConfigDialog.h" #include "SettingsDialog.h" #include "ZeroconfService.h" #include "DataDownloader.h" #include "CommandProcess.h" +#include "FingerprintAcceptDialog.h" #include "QUtility.h" #include "ProcessorArch.h" #include "SslCertificate.h" #include "ShutdownCh.h" +#include "base/String.h" #include "common/DataDirectories.h" +#include "net/FingerprintDatabase.h" +#include "net/SecureUtils.h" #include #include @@ -53,17 +56,20 @@ #include #endif +static const QString allFilesFilter(QObject::tr("All files (*.*)")); #if defined(Q_OS_WIN) static const char barrierConfigName[] = "barrier.sgc"; -static const QString barrierConfigFilter(QObject::tr("Barrier Configurations (*.sgc);;All files (*.*)")); +static const QString barrierConfigFilter(QObject::tr("Barrier Configurations (*.sgc)")); static QString bonjourBaseUrl = "http://binaries.symless.com/bonjour/"; static const char bonjourFilename32[] = "Bonjour.msi"; static const char bonjourFilename64[] = "Bonjour64.msi"; static const char bonjourTargetFilename[] = "Bonjour.msi"; #else static const char barrierConfigName[] = "barrier.conf"; -static const QString barrierConfigFilter(QObject::tr("Barrier Configurations (*.conf);;All files (*.*)")); +static const QString barrierConfigFilter(QObject::tr("Barrier Configurations (*.conf)")); #endif +static const QString barrierConfigOpenFilter(barrierConfigFilter + ";;" + allFilesFilter); +static const QString barrierConfigSaveFilter(barrierConfigFilter); static const char* barrierIconFiles[] = { @@ -80,6 +86,14 @@ static const char* barrierIconFiles[] = #endif }; +static const char* barrierIconNames[] = +{ + "barrier-disconnected", + "barrier-disconnected", + "barrier-connected", + "barrier-transfering" +}; + static const char* barrierLargeIcon = ":/res/icons/256x256/barrier.ico"; MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) : @@ -145,9 +159,22 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) : m_pComboServerList->hide(); m_pLabelPadlock->hide(); + frame_fingerprint_details->hide(); updateSSLFingerprint(); + connect(toolbutton_show_fingerprint, &QToolButton::clicked, [this](bool checked) + { + m_fingerprint_expanded = !m_fingerprint_expanded; + if (m_fingerprint_expanded) { + frame_fingerprint_details->show(); + toolbutton_show_fingerprint->setArrowType(Qt::ArrowType::UpArrow); + } else { + frame_fingerprint_details->hide(); + toolbutton_show_fingerprint->setArrowType(Qt::ArrowType::DownArrow); + } + }); + // resize window to smallest reasonable size resize(0, 0); } @@ -191,7 +218,7 @@ void MainWindow::open() // only start if user has previously started. this stops the gui from // auto hiding before the user has configured barrier (which of course // confuses first time users, who think barrier has crashed). - if (appConfig().startedBefore() && appConfig().processMode() == Desktop) { + if (appConfig().startedBefore() && appConfig().getAutoStart()) { m_SuppressEmptyServerWarning = true; startBarrier(); m_SuppressEmptyServerWarning = false; @@ -296,7 +323,7 @@ void MainWindow::saveSettings() void MainWindow::setIcon(qBarrierState state) { if (m_pTrayIcon) { - QIcon icon = QIcon(barrierIconFiles[state]); + QIcon icon = QIcon::fromTheme(barrierIconNames[state], QIcon(barrierIconFiles[state])); #if defined(Q_OS_MAC) icon.setIsMask(true); #endif @@ -325,8 +352,7 @@ void MainWindow::logOutput() if (m_pBarrier) { QString text(m_pBarrier->readAllStandardOutput()); - foreach(QString line, text.split(QRegExp("\r|\n|\r\n"))) - { + for (QString line : text.split(QRegExp("\r|\n|\r\n"))) { if (!line.isEmpty()) { appendLogRaw(line); @@ -363,7 +389,7 @@ void MainWindow::appendLogError(const QString& text) void MainWindow::appendLogRaw(const QString& text) { - foreach(QString line, text.split(QRegExp("\r|\n|\r\n"))) { + for (QString line : text.split(QRegExp("\r|\n|\r\n"))) { if (!line.isEmpty()) { m_pLogWindow->appendRaw(line); updateFromLogLine(line); @@ -402,41 +428,57 @@ void MainWindow::checkConnected(const QString& line) void MainWindow::checkFingerprint(const QString& line) { - QRegExp fingerprintRegex(".*server fingerprint: ([A-F0-9:]+)"); + QRegExp fingerprintRegex(".*peer fingerprint \\(SHA1\\): ([A-F0-9:]+) \\(SHA256\\): ([A-F0-9:]+)"); if (!fingerprintRegex.exactMatch(line)) { return; } - QString fingerprint = fingerprintRegex.cap(1); - if (Fingerprint::trustedServers().isTrusted(fingerprint)) { + barrier::FingerprintData fingerprint_sha1 = { + barrier::fingerprint_type_to_string(barrier::FingerprintType::SHA1), + barrier::string::from_hex(fingerprintRegex.cap(1).toStdString()) + }; + + barrier::FingerprintData fingerprint_sha256 = { + barrier::fingerprint_type_to_string(barrier::FingerprintType::SHA256), + barrier::string::from_hex(fingerprintRegex.cap(2).toStdString()) + }; + + bool is_client = barrier_type() == BarrierType::Client; + + auto db_path = is_client + ? barrier::DataDirectories::trusted_servers_ssl_fingerprints_path() + : barrier::DataDirectories::trusted_clients_ssl_fingerprints_path(); + + auto db_dir = db_path.parent_path(); + if (!barrier::fs::exists(db_dir)) { + barrier::fs::create_directories(db_dir); + } + + // We compare only SHA256 fingerprints, but show both SHA1 and SHA256 so that the users can + // still verify fingerprints on old Barrier servers. This way the only time when we are exposed + // to SHA1 vulnerabilities is when the user is reconnecting again. + barrier::FingerprintDatabase db; + db.read(db_path); + if (db.is_trusted(fingerprint_sha256)) { return; } static bool messageBoxAlreadyShown = false; if (!messageBoxAlreadyShown) { - stopBarrier(); + if (is_client) { + stopBarrier(); + } messageBoxAlreadyShown = true; - QMessageBox::StandardButton fingerprintReply = - QMessageBox::information( - this, tr("Security question"), - tr("Do you trust this fingerprint?\n\n" - "%1\n\n" - "This is a server fingerprint. You should compare this " - "fingerprint to the one on your server's screen. If the " - "two don't match exactly, then it's probably not the server " - "you're expecting (it could be a malicious user).\n\n" - "To automatically trust this fingerprint for future " - "connections, click Yes. To reject this fingerprint and " - "disconnect from the server, click No.") - .arg(fingerprint), - QMessageBox::Yes | QMessageBox::No); - - if (fingerprintReply == QMessageBox::Yes) { + FingerprintAcceptDialog dialog{this, barrier_type(), fingerprint_sha1, fingerprint_sha256}; + if (dialog.exec() == QDialog::Accepted) { // restart core process after trusting fingerprint. - Fingerprint::trustedServers().trust(fingerprint); - startBarrier(); + db.add_trusted(fingerprint_sha256); + db.write(db_path); + if (is_client) { + startBarrier(); + } } messageBoxAlreadyShown = false; @@ -506,8 +548,8 @@ void MainWindow::startBarrier() #endif - if (m_AppConfig->getCryptoEnabled()) { - args << "--enable-crypto"; + if (!m_AppConfig->getCryptoEnabled()) { + args << "--disable-crypto"; } #if defined(Q_OS_WIN) @@ -515,11 +557,11 @@ void MainWindow::startBarrier() // launched the process (e.g. when launched with elevation). setting the // profile dir on launch ensures it uses the same profile dir is used // no matter how its relaunched. - args << "--profile-dir" << QString::fromStdString("\"" + DataDirectories::profile() + "\""); + args << "--profile-dir" << QString::fromStdString("\"" + barrier::DataDirectories::profile().u8string() + "\""); #endif - if ((barrierType() == barrierClient && !clientArgs(args, app)) - || (barrierType() == barrierServer && !serverArgs(args, app))) + if ((barrier_type() == BarrierType::Client && !clientArgs(args, app)) + || (barrier_type() == BarrierType::Server && !serverArgs(args, app))) { stopBarrier(); return; @@ -534,7 +576,7 @@ void MainWindow::startBarrier() m_pLogWindow->startNewInstance(); - appendLogInfo("starting " + QString(barrierType() == barrierServer ? "server" : "client")); + appendLogInfo("starting " + QString(barrier_type() == BarrierType::Server ? "server" : "client")); qDebug() << args; @@ -615,7 +657,7 @@ QString MainWindow::configFilename() if (m_pRadioInternalConfig->isChecked()) { // TODO: no need to use a temporary file, since we need it to - // be permenant (since it'll be used for Windows services, etc). + // be permanent (since it'll be used for Windows services, etc). m_pTempConfigFile = new QTemporaryFile(); if (!m_pTempConfigFile->open()) { @@ -644,6 +686,11 @@ QString MainWindow::configFilename() return filename; } +BarrierType MainWindow::barrier_type() const +{ + return m_pGroupClient->isChecked() ? BarrierType::Client : BarrierType::Server; +} + QString MainWindow::address() { QString address = appConfig().networkInterface(); @@ -680,6 +727,10 @@ bool MainWindow::serverArgs(QStringList& args, QString& app) args << "--log" << appConfig().logFilenameCmd(); } + if (!appConfig().getRequireClientCertificate()) { + args << "--disable-client-cert-checking"; + } + QString configFilename = this->configFilename(); #if defined(Q_OS_WIN) // wrap in quotes in case username contains spaces. @@ -720,7 +771,7 @@ void MainWindow::stopBarrier() void MainWindow::stopService() { - // send empty command to stop service from laucning anything. + // send empty command to stop service from launching anything. m_IpcClient.sendCommand("", appConfig().elevateMode()); } @@ -915,6 +966,14 @@ void MainWindow::changeEvent(QEvent* event) QMainWindow::changeEvent(event); } +bool MainWindow::event(QEvent* event) +{ + if (event->type() == QEvent::LayoutRequest) { + setFixedSize(sizeHint()); + } + return QMainWindow::event(event); +} + void MainWindow::updateZeroconfService() { QMutexLocker locker(&m_UpdateZeroconfMutex); @@ -926,7 +985,7 @@ void MainWindow::updateZeroconfService() m_pZeroconfService = NULL; } - if (m_AppConfig->autoConfig() || barrierType() == barrierServer) { + if (m_AppConfig->autoConfig() || barrier_type() == BarrierType::Server) { m_pZeroconfService = new ZeroconfService(this); } } @@ -949,14 +1008,53 @@ void MainWindow::updateSSLFingerprint() { if (m_AppConfig->getCryptoEnabled() && m_pSslCertificate == nullptr) { m_pSslCertificate = new SslCertificate(this); + connect(m_pSslCertificate, &SslCertificate::info, [&](QString info) + { + appendLogInfo(info); + }); m_pSslCertificate->generateCertificate(); } - if (m_AppConfig->getCryptoEnabled() && Fingerprint::local().fileExists()) { - m_pLabelLocalFingerprint->setText(Fingerprint::local().readFirst()); - m_pLabelLocalFingerprint->setTextInteractionFlags(Qt::TextSelectableByMouse); - } else { - m_pLabelLocalFingerprint->setText("Disabled"); + + toolbutton_show_fingerprint->setEnabled(false); + m_pLabelLocalFingerprint->setText("Disabled"); + + if (!m_AppConfig->getCryptoEnabled()) { + return; + } + + auto local_path = barrier::DataDirectories::local_ssl_fingerprints_path(); + if (!barrier::fs::exists(local_path)) { + return; } + + barrier::FingerprintDatabase db; + db.read(local_path); + if (db.fingerprints().size() != 2) { + return; + } + + for (const auto& fingerprint : db.fingerprints()) { + if (fingerprint.algorithm == "sha1") { + auto fingerprint_str = barrier::format_ssl_fingerprint(fingerprint.data); + label_sha1_fingerprint_full->setText(QString::fromStdString(fingerprint_str)); + continue; + } + + if (fingerprint.algorithm == "sha256") { + auto fingerprint_str = barrier::format_ssl_fingerprint(fingerprint.data); + fingerprint_str.resize(40); + fingerprint_str += " ..."; + + auto fingerprint_str_cols = barrier::format_ssl_fingerprint_columns(fingerprint.data); + auto fingerprint_randomart = barrier::create_fingerprint_randomart(fingerprint.data); + + m_pLabelLocalFingerprint->setText(QString::fromStdString(fingerprint_str)); + label_sha256_fingerprint_full->setText(QString::fromStdString(fingerprint_str_cols)); + label_sha256_randomart->setText(QString::fromStdString(fingerprint_randomart)); + } + } + + toolbutton_show_fingerprint->setEnabled(true); } void MainWindow::on_m_pGroupClient_toggled(bool on) @@ -977,7 +1075,7 @@ void MainWindow::on_m_pGroupServer_toggled(bool on) bool MainWindow::on_m_pButtonBrowseConfigFile_clicked() { - QString fileName = QFileDialog::getOpenFileName(this, tr("Browse for a barriers config file"), QString(), barrierConfigFilter); + QString fileName = QFileDialog::getOpenFileName(this, tr("Browse for a barriers config file"), QString(), barrierConfigOpenFilter); if (!fileName.isEmpty()) { @@ -988,9 +1086,9 @@ bool MainWindow::on_m_pButtonBrowseConfigFile_clicked() return false; } -bool MainWindow::on_m_pActionSave_triggered() +bool MainWindow::on_m_pActionSave_triggered() { - QString fileName = QFileDialog::getSaveFileName(this, tr("Save configuration as..."), QString(), tr("Barrier Configuration (*.sgc)")); + QString fileName = QFileDialog::getSaveFileName(this, tr("Save configuration as..."), QString(), barrierConfigSaveFilter); if (!fileName.isEmpty() && !serverConfig().save(fileName)) { diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index c115b91..0c582c9 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -20,6 +20,8 @@ #define MAINWINDOW__H +#include "barrier/BarrierType.h" + #include #include #include @@ -76,12 +78,6 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase barrierTransfering }; - enum qBarrierType - { - barrierClient, - barrierServer - }; - enum qLevel { Error, Info @@ -98,7 +94,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase public: void setVisible(bool visible); - int barrierType() const { return m_pGroupClient->isChecked() ? barrierClient : barrierServer; } + BarrierType barrier_type() const; int barrierState() const { return m_BarrierState; } QString hostname() const { return m_pLineEditHostname->text(); } QString configFilename(); @@ -157,6 +153,7 @@ public slots: void stopService(); void stopDesktop(); void changeEvent(QEvent* event); + bool event(QEvent* event); void retranslateMenuBar(); #if defined(Q_OS_WIN) bool isServiceRunning(QString name); @@ -202,6 +199,8 @@ public slots: QStringList m_PendingClientNames; LogWindow *m_pLogWindow; + bool m_fingerprint_expanded = false; + private slots: void on_m_pCheckBoxAutoConfig_toggled(bool checked); void on_m_pComboServerList_currentIndexChanged(QString ); @@ -211,4 +210,3 @@ private slots: }; #endif - diff --git a/src/gui/src/MainWindowBase.ui b/src/gui/src/MainWindowBase.ui index 117405c..88994cf 100644 --- a/src/gui/src/MainWindowBase.ui +++ b/src/gui/src/MainWindowBase.ui @@ -2,31 +2,20 @@ MainWindowBase - - - 0 - 0 - 600 - 550 - - 0 0 - - - 600 - 0 - - Barrier + + QLayout::SetFixedSize + @@ -66,30 +55,6 @@ - - - - - - - 0 - 0 - - - - SSL Fingerprint: - - - - - - - - - - - - @@ -239,6 +204,107 @@ + + + + + + + 0 + 0 + + + + SSL Fingerprint: + + + + + + + + + + Qt::PlainText + + + + + + + ... + + + Qt::DownArrow + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + QLayout::SetMinimumSize + + + + + + Courier + + + + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + SHA1 (deprecated, compare to old clients and servers only): + + + + + + + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + SHA256: + + + + + + + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + @@ -253,7 +319,7 @@ - :/res/icons/16x16/padlock.png + :/res/icons/16x16/padlock.png @@ -388,7 +454,7 @@ - Show &Log + Show &Log Show Log @@ -399,7 +465,7 @@ - + diff --git a/src/gui/src/NewScreenWidget.cpp b/src/gui/src/NewScreenWidget.cpp index 0336249..28e99fa 100644 --- a/src/gui/src/NewScreenWidget.cpp +++ b/src/gui/src/NewScreenWidget.cpp @@ -1,12 +1,12 @@ -/* +/* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -45,4 +45,3 @@ void NewScreenWidget::mousePressEvent(QMouseEvent* event) pDrag->exec(Qt::CopyAction, Qt::CopyAction); } - diff --git a/src/gui/src/NewScreenWidget.h b/src/gui/src/NewScreenWidget.h index 34f3269..6e52795 100644 --- a/src/gui/src/NewScreenWidget.h +++ b/src/gui/src/NewScreenWidget.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -37,4 +37,3 @@ class NewScreenWidget : public QLabel }; #endif - diff --git a/src/gui/src/QBarrierApplication.cpp b/src/gui/src/QBarrierApplication.cpp index f2da382..f9362c7 100644 --- a/src/gui/src/QBarrierApplication.cpp +++ b/src/gui/src/QBarrierApplication.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -38,8 +38,7 @@ QBarrierApplication::~QBarrierApplication() void QBarrierApplication::commitData(QSessionManager&) { - foreach(QWidget* widget, topLevelWidgets()) - { + for (QWidget* widget : topLevelWidgets()) { MainWindow* mainWindow = qobject_cast(widget); if (mainWindow) mainWindow->saveSettings(); diff --git a/src/gui/src/QBarrierApplication.h b/src/gui/src/QBarrierApplication.h index 95729b2..bd348b3 100644 --- a/src/gui/src/QBarrierApplication.h +++ b/src/gui/src/QBarrierApplication.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -44,4 +44,3 @@ class QBarrierApplication : public QApplication }; #endif - diff --git a/src/gui/src/QUtility.cpp b/src/gui/src/QUtility.cpp index 7757adf..2d05fc3 100644 --- a/src/gui/src/QUtility.cpp +++ b/src/gui/src/QUtility.cpp @@ -51,8 +51,7 @@ QString hash(const QString& string) QString getFirstMacAddress() { QString mac; - foreach (const QNetworkInterface &interface, QNetworkInterface::allInterfaces()) - { + for (const QNetworkInterface &interface : QNetworkInterface::allInterfaces()) { mac = interface.hardwareAddress(); if (mac.size() != 0) { diff --git a/src/gui/src/Screen.cpp b/src/gui/src/Screen.cpp index 38d02e8..1e3b888 100644 --- a/src/gui/src/Screen.cpp +++ b/src/gui/src/Screen.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -125,8 +125,9 @@ QTextStream& Screen::writeAliasesSection(QTextStream& outStream) const { outStream << "\t" << name() << ":" << endl; - foreach (const QString& alias, aliases()) + for (const QString& alias : aliases()) { outStream << "\t\t" << alias << endl; + } } return outStream; diff --git a/src/gui/src/Screen.h b/src/gui/src/Screen.h index d728af1..6496221 100644 --- a/src/gui/src/Screen.h +++ b/src/gui/src/Screen.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -101,10 +101,7 @@ class Screen : public BaseConfig bool m_Swapped; }; -typedef QList ScreenList; - QDataStream& operator<<(QDataStream& outStream, const Screen& screen); QDataStream& operator>>(QDataStream& inStream, Screen& screen); #endif - diff --git a/src/gui/src/ScreenSettingsDialog.cpp b/src/gui/src/ScreenSettingsDialog.cpp index 123bb8a..9055e35 100644 --- a/src/gui/src/ScreenSettingsDialog.cpp +++ b/src/gui/src/ScreenSettingsDialog.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -152,4 +152,3 @@ void ScreenSettingsDialog::on_m_pListAliases_itemSelectionChanged() { m_pButtonRemoveAlias->setEnabled(!m_pListAliases->selectedItems().isEmpty()); } - diff --git a/src/gui/src/ScreenSettingsDialog.h b/src/gui/src/ScreenSettingsDialog.h index 1c525d2..953d1f8 100644 --- a/src/gui/src/ScreenSettingsDialog.h +++ b/src/gui/src/ScreenSettingsDialog.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -50,4 +50,3 @@ class ScreenSettingsDialog : public QDialog, public Ui::ScreenSettingsDialogBase }; #endif - diff --git a/src/gui/src/ScreenSetupModel.cpp b/src/gui/src/ScreenSetupModel.cpp index fce1a8c..5c933f8 100644 --- a/src/gui/src/ScreenSetupModel.cpp +++ b/src/gui/src/ScreenSetupModel.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -24,7 +24,7 @@ const QString ScreenSetupModel::m_MimeType = "application/x-qbarrier-screen"; -ScreenSetupModel::ScreenSetupModel(ScreenList& screens, int numColumns, int numRows) : +ScreenSetupModel::ScreenSetupModel(std::vector& screens, int numColumns, int numRows) : QAbstractTableModel(NULL), m_Screens(screens), m_NumColumns(numColumns), @@ -71,7 +71,7 @@ Qt::ItemFlags ScreenSetupModel::flags(const QModelIndex& index) const if (!screen(index).isNull()) return Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled; - return Qt::ItemIsDropEnabled; + return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled; } Qt::DropActions ScreenSetupModel::supportedDropActions() const @@ -91,9 +91,10 @@ QMimeData* ScreenSetupModel::mimeData(const QModelIndexList& indexes) const QDataStream stream(&encodedData, QIODevice::WriteOnly); - foreach (const QModelIndex& index, indexes) + for (const QModelIndex& index : indexes) { if (index.isValid()) stream << index.column() << index.row() << screen(index); + } pMimeData->setData(m_MimeType, encodedData); @@ -109,7 +110,7 @@ bool ScreenSetupModel::dropMimeData(const QMimeData* data, Qt::DropAction action return false; if (!parent.isValid() || row != -1 || column != -1) - return false; + return false; QByteArray encodedData = data->data(m_MimeType); QDataStream stream(&encodedData, QIODevice::ReadOnly); @@ -140,4 +141,3 @@ bool ScreenSetupModel::dropMimeData(const QMimeData* data, Qt::DropAction action return true; } - diff --git a/src/gui/src/ScreenSetupModel.h b/src/gui/src/ScreenSetupModel.h index ba46af3..0f558b4 100644 --- a/src/gui/src/ScreenSetupModel.h +++ b/src/gui/src/ScreenSetupModel.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -38,7 +38,7 @@ class ScreenSetupModel : public QAbstractTableModel friend class ServerConfigDialog; public: - ScreenSetupModel(ScreenList& screens, int numColumns, int numRows); + ScreenSetupModel(std::vector& screens, int numColumns, int numRows); public: static const QString& mimeType() { return m_MimeType; } @@ -60,7 +60,7 @@ class ScreenSetupModel : public QAbstractTableModel Screen& screen(int column, int row) { return m_Screens[row * m_NumColumns + column]; } private: - ScreenList& m_Screens; + std::vector& m_Screens; const int m_NumColumns; const int m_NumRows; @@ -68,4 +68,3 @@ class ScreenSetupModel : public QAbstractTableModel }; #endif - diff --git a/src/gui/src/ScreenSetupView.cpp b/src/gui/src/ScreenSetupView.cpp index 46e7099..5459f23 100644 --- a/src/gui/src/ScreenSetupView.cpp +++ b/src/gui/src/ScreenSetupView.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -30,6 +30,7 @@ ScreenSetupView::ScreenSetupView(QWidget* parent) : setDropIndicatorShown(true); setDragDropMode(DragDrop); setSelectionMode(SingleSelection); + setTabKeyNavigation(false); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -65,18 +66,83 @@ void ScreenSetupView::resizeEvent(QResizeEvent* event) event->ignore(); } +void ScreenSetupView::enter(const QModelIndex& index) +{ + if (!index.isValid()) + return; + Screen& screen = model()->screen(index); + if (screen.isNull()) + screen = Screen(tr("Unnamed")); + ScreenSettingsDialog dlg(this, &screen); + dlg.exec(); +} + +void ScreenSetupView::remove(const QModelIndex& index) +{ + if (!index.isValid()) + return; + Screen& screen = model()->screen(index); + if (!screen.isNull()) { + screen = Screen(); + emit dataChanged(index, index); + } +} + +void ScreenSetupView::keyPressEvent(QKeyEvent* event) +{ + if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Delete) + { + QModelIndexList indexes = selectedIndexes(); + if (indexes.count() == 1 && indexes[0].isValid()) + { + if (event->key() == Qt::Key_Return) + enter(indexes[0]); + else if (event->key() == Qt::Key_Delete) + remove(indexes[0]); + } + // Do not let base handle the event, at least not for return key because it + // results in next esc/return key in the opened Screen Settings dialog not + // only closing that but also the parent Server Configuration dialog. + } + else if ((event->modifiers() & Qt::ControlModifier) + && (event->key() == Qt::Key_Left || event->key() == Qt::Key_Right + || event->key() == Qt::Key_Up || event->key() == Qt::Key_Down)) + { + QModelIndexList indexes = selectedIndexes(); + if (indexes.count() == 1 && indexes[0].isValid()) + { + const QModelIndex& fromIndex = indexes[0]; + QModelIndex toIndex; + + if (event->key() == Qt::Key_Left) + toIndex = fromIndex.sibling(fromIndex.row(), fromIndex.column() - 1); + else if (event->key() == Qt::Key_Right) + toIndex = fromIndex.sibling(fromIndex.row(), fromIndex.column() + 1); + else if (event->key() == Qt::Key_Up) + toIndex = fromIndex.sibling(fromIndex.row() - 1, fromIndex.column()); + else if (event->key() == Qt::Key_Down) + toIndex = fromIndex.sibling(fromIndex.row() + 1, fromIndex.column()); + + if (toIndex.isValid() && fromIndex != toIndex) + std::swap(model()->screen(fromIndex), model()->screen(toIndex)); + } + // In this case let base also handle the event, because it will proceed moving + // the selection to target, update the view according to model changes etc. + QTableView::keyPressEvent(event); + } + else + { + QTableView::keyPressEvent(event); + } +} + void ScreenSetupView::mouseDoubleClickEvent(QMouseEvent* event) { if (event->buttons() & Qt::LeftButton) { int col = columnAt(event->pos().x()); int row = rowAt(event->pos().y()); - - if (!model()->screen(col, row).isNull()) - { - ScreenSettingsDialog dlg(this, &model()->screen(col, row)); - dlg.exec(); - } + enter(model()->createIndex(row, col)); } else event->ignore(); @@ -159,4 +225,3 @@ QStyleOptionViewItem ScreenSetupView::viewOptions() const option.textElideMode = Qt::ElideMiddle; return option; } - diff --git a/src/gui/src/ScreenSetupView.h b/src/gui/src/ScreenSetupView.h index a660511..64968a0 100644 --- a/src/gui/src/ScreenSetupView.h +++ b/src/gui/src/ScreenSetupView.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -44,6 +44,7 @@ class ScreenSetupView : public QTableView protected: void mouseDoubleClickEvent(QMouseEvent*) override; + void keyPressEvent(QKeyEvent*) override; void setTableSize(); void resizeEvent(QResizeEvent*) override; void dragEnterEvent(QDragEnterEvent* event) override; @@ -51,7 +52,9 @@ class ScreenSetupView : public QTableView void startDrag(Qt::DropActions supportedActions) override; QStyleOptionViewItem viewOptions() const override; void scrollTo(const QModelIndex&, ScrollHint) override {} + private: + void enter(const QModelIndex&); + void remove(const QModelIndex&); }; #endif - diff --git a/src/gui/src/ServerConfig.cpp b/src/gui/src/ServerConfig.cpp index 9fedd1e..3392572 100644 --- a/src/gui/src/ServerConfig.cpp +++ b/src/gui/src/ServerConfig.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -183,7 +183,7 @@ void ServerConfig::loadSettings() settings().setArrayIndex(i); Hotkey h; h.loadSettings(settings()); - hotkeys().append(h); + hotkeys().push_back(h); } settings().endArray(); @@ -212,17 +212,19 @@ QTextStream& operator<<(QTextStream& outStream, const ServerConfig& config) { outStream << "section: screens" << endl; - foreach (const Screen& s, config.screens()) + for (const Screen& s : config.screens()) { if (!s.isNull()) s.writeScreensSection(outStream); + } outStream << "end" << endl << endl; outStream << "section: aliases" << endl; - foreach (const Screen& s, config.screens()) + for (const Screen& s : config.screens()) { if (!s.isNull()) s.writeAliasesSection(outStream); + } outStream << "end" << endl << endl; @@ -270,8 +272,9 @@ QTextStream& operator<<(QTextStream& outStream, const ServerConfig& config) outStream << "\t" << "switchCornerSize = " << config.switchCornerSize() << endl; - foreach(const Hotkey& hotkey, config.hotkeys()) + for (const Hotkey& hotkey : config.hotkeys()) { outStream << hotkey; + } outStream << "end" << endl << endl; @@ -282,9 +285,10 @@ int ServerConfig::numScreens() const { int rval = 0; - foreach(const Screen& s, screens()) + for (const Screen& s : screens()) { if (!s.isNull()) rval++; + } return rval; } diff --git a/src/gui/src/ServerConfig.h b/src/gui/src/ServerConfig.h index c9648b0..9f3e2db 100644 --- a/src/gui/src/ServerConfig.h +++ b/src/gui/src/ServerConfig.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -44,7 +44,7 @@ class ServerConfig : public BaseConfig ~ServerConfig(); public: - const ScreenList& screens() const { return m_Screens; } + const std::vector& screens() const { return m_Screens; } int numColumns() const { return m_NumColumns; } int numRows() const { return m_NumRows; } bool hasHeartbeat() const { return m_HasHeartbeat; } @@ -59,7 +59,7 @@ class ServerConfig : public BaseConfig bool switchCorner(SwitchCorner c) const { return m_SwitchCorners[static_cast(c)]; } int switchCornerSize() const { return m_SwitchCornerSize; } const QList& switchCorners() const { return m_SwitchCorners; } - const HotkeyList& hotkeys() const { return m_Hotkeys; } + const std::vector& hotkeys() const { return m_Hotkeys; } bool ignoreAutoConfigClient() const { return m_IgnoreAutoConfigClient; } bool enableDragAndDrop() const { return m_EnableDragAndDrop; } bool clipboardSharing() const { return m_ClipboardSharing; } @@ -73,9 +73,9 @@ class ServerConfig : public BaseConfig protected: QSettings& settings() { return *m_pSettings; } - ScreenList& screens() { return m_Screens; } - void setScreens(const ScreenList& screens) { m_Screens = screens; } - void addScreen(const Screen& screen) { m_Screens.append(screen); } + std::vector& screens() { return m_Screens; } + void setScreens(const std::vector& screens) { m_Screens = screens; } + void addScreen(const Screen& screen) { m_Screens.push_back(screen); } void setNumColumns(int n) { m_NumColumns = n; } void setNumRows(int n) { m_NumRows = n; } void haveHeartbeat(bool on) { m_HasHeartbeat = on; } @@ -93,7 +93,7 @@ class ServerConfig : public BaseConfig void setEnableDragAndDrop(bool on) { m_EnableDragAndDrop = on; } void setClipboardSharing(bool on) { m_ClipboardSharing = on; } QList& switchCorners() { return m_SwitchCorners; } - HotkeyList& hotkeys() { return m_Hotkeys; } + std::vector& hotkeys() { return m_Hotkeys; } void init(); int adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) const; @@ -106,7 +106,7 @@ class ServerConfig : public BaseConfig private: QSettings* m_pSettings; - ScreenList m_Screens; + std::vector m_Screens; int m_NumColumns; int m_NumRows; bool m_HasHeartbeat; @@ -120,7 +120,7 @@ class ServerConfig : public BaseConfig int m_SwitchDoubleTap; int m_SwitchCornerSize; QList m_SwitchCorners; - HotkeyList m_Hotkeys; + std::vector m_Hotkeys; QString m_ServerName; bool m_IgnoreAutoConfigClient; bool m_EnableDragAndDrop; @@ -138,4 +138,3 @@ enum { }; #endif - diff --git a/src/gui/src/ServerConfigDialog.cpp b/src/gui/src/ServerConfigDialog.cpp index 2e7ffc9..84c2047 100644 --- a/src/gui/src/ServerConfigDialog.cpp +++ b/src/gui/src/ServerConfigDialog.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -60,8 +60,9 @@ ServerConfigDialog::ServerConfigDialog(QWidget* parent, ServerConfig& config, co m_pCheckBoxEnableClipboard->setChecked(serverConfig().clipboardSharing()); - foreach(const Hotkey& hotkey, serverConfig().hotkeys()) + for (const Hotkey& hotkey : serverConfig().hotkeys()) { m_pListHotkeys->addItem(hotkey.text()); + } m_pScreenSetupView->setModel(&m_ScreenSetupModel); @@ -75,7 +76,7 @@ void ServerConfigDialog::showEvent(QShowEvent* event) if (!m_Message.isEmpty()) { - // TODO: ideally this massage box should pop up after the dialog is shown + // TODO: ideally this message box should pop up after the dialog is shown QMessageBox::information(this, tr("Configure server"), m_Message); } } @@ -121,7 +122,7 @@ void ServerConfigDialog::on_m_pButtonNewHotkey_clicked() HotkeyDialog dlg(this, hotkey); if (dlg.exec() == QDialog::Accepted) { - serverConfig().hotkeys().append(hotkey); + serverConfig().hotkeys().push_back(hotkey); m_pListHotkeys->addItem(hotkey.text()); } } @@ -140,7 +141,7 @@ void ServerConfigDialog::on_m_pButtonRemoveHotkey_clicked() { int idx = m_pListHotkeys->currentRow(); Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size()); - serverConfig().hotkeys().removeAt(idx); + serverConfig().hotkeys().erase(serverConfig().hotkeys().begin() + idx); m_pListActions->clear(); delete m_pListHotkeys->item(idx); } @@ -168,8 +169,9 @@ void ServerConfigDialog::on_m_pListHotkeys_itemSelectionChanged() Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size()); const Hotkey& hotkey = serverConfig().hotkeys()[idx]; - foreach(const Action& action, hotkey.actions()) + for (const Action& action : hotkey.actions()) { m_pListActions->addItem(action.text()); + } } } @@ -183,7 +185,7 @@ void ServerConfigDialog::on_m_pButtonNewAction_clicked() ActionDialog dlg(this, serverConfig(), hotkey, action); if (dlg.exec() == QDialog::Accepted) { - hotkey.actions().append(action); + hotkey.appendAction(action); m_pListActions->addItem(action.text()); } } @@ -196,11 +198,13 @@ void ServerConfigDialog::on_m_pButtonEditAction_clicked() int idxAction = m_pListActions->currentRow(); Q_ASSERT(idxAction >= 0 && idxAction < hotkey.actions().size()); - Action& action = hotkey.actions()[idxAction]; + Action action = hotkey.actions()[idxAction]; ActionDialog dlg(this, serverConfig(), hotkey, action); - if (dlg.exec() == QDialog::Accepted) + if (dlg.exec() == QDialog::Accepted) { + hotkey.setAction(idxAction, action); m_pListActions->currentItem()->setText(action.text()); + } } void ServerConfigDialog::on_m_pButtonRemoveAction_clicked() @@ -212,7 +216,7 @@ void ServerConfigDialog::on_m_pButtonRemoveAction_clicked() int idxAction = m_pListActions->currentRow(); Q_ASSERT(idxAction >= 0 && idxAction < hotkey.actions().size()); - hotkey.actions().removeAt(idxAction); + hotkey.removeAction(idxAction); delete m_pListActions->currentItem(); } diff --git a/src/gui/src/ServerConfigDialog.h b/src/gui/src/ServerConfigDialog.h index 1ef17d1..91da51a 100644 --- a/src/gui/src/ServerConfigDialog.h +++ b/src/gui/src/ServerConfigDialog.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -63,4 +63,3 @@ class ServerConfigDialog : public QDialog, public Ui::ServerConfigDialogBase }; #endif - diff --git a/src/gui/src/SettingsDialog.cpp b/src/gui/src/SettingsDialog.cpp index 24bb86c..8d01c77 100644 --- a/src/gui/src/SettingsDialog.cpp +++ b/src/gui/src/SettingsDialog.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -48,8 +48,10 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : m_pLineEditLogFilename->setText(appConfig().logFilename()); setIndexFromItemData(m_pComboLanguage, appConfig().language()); m_pCheckBoxAutoHide->setChecked(appConfig().getAutoHide()); + m_pCheckBoxAutoStart->setChecked(appConfig().getAutoStart()); m_pCheckBoxMinimizeToTray->setChecked(appConfig().getMinimizeToTray()); m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled()); + checkbox_require_client_certificate->setChecked(m_appConfig.getRequireClientCertificate()); #if defined(Q_OS_WIN) m_pComboElevate->setCurrentIndex(static_cast(appConfig().elevateMode())); @@ -66,12 +68,14 @@ void SettingsDialog::accept() m_appConfig.setPort(m_pSpinBoxPort->value()); m_appConfig.setNetworkInterface(m_pLineEditInterface->text()); m_appConfig.setCryptoEnabled(m_pCheckBoxEnableCrypto->isChecked()); + m_appConfig.setRequireClientCertificate(checkbox_require_client_certificate->isChecked()); m_appConfig.setLogLevel(m_pComboLogLevel->currentIndex()); m_appConfig.setLogToFile(m_pCheckBoxLogToFile->isChecked()); m_appConfig.setLogFilename(m_pLineEditLogFilename->text()); m_appConfig.setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()); m_appConfig.setElevateMode(static_cast(m_pComboElevate->currentIndex())); m_appConfig.setAutoHide(m_pCheckBoxAutoHide->isChecked()); + m_appConfig.setAutoStart(m_pCheckBoxAutoStart->isChecked()); m_appConfig.setMinimizeToTray(m_pCheckBoxMinimizeToTray->isChecked()); m_appConfig.saveSettings(); QDialog::accept(); diff --git a/src/gui/src/SettingsDialog.h b/src/gui/src/SettingsDialog.h index b733bcc..210b6c0 100644 --- a/src/gui/src/SettingsDialog.h +++ b/src/gui/src/SettingsDialog.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 diff --git a/src/gui/src/SettingsDialogBase.ui b/src/gui/src/SettingsDialogBase.ui index d75c18c..44ed98c 100644 --- a/src/gui/src/SettingsDialogBase.ui +++ b/src/gui/src/SettingsDialogBase.ui @@ -7,7 +7,7 @@ 0 0 368 - 380 + 428 @@ -126,6 +126,13 @@ + + + + Start &Barrier on startup + + + @@ -135,6 +142,16 @@ Networking + + + + &Address: + + + m_pLineEditInterface + + + @@ -164,16 +181,6 @@ - - - - &Address: - - - m_pLineEditInterface - - - @@ -181,13 +188,20 @@ - + Enable &SSL + + + + Require client certificate + + + @@ -209,19 +223,20 @@ false - - - - - 75 - 0 - - + + - &Logging level: + Log to file: - - m_pComboLogLevel + + + + + + false + + + Browse... @@ -264,10 +279,19 @@ - - + + + + + 75 + 0 + + - Log to file: + &Logging level: + + + m_pComboLogLevel @@ -278,16 +302,6 @@ - - - - false - - - Browse... - - - @@ -322,6 +336,7 @@ m_pComboElevate m_pCheckBoxMinimizeToTray m_pCheckBoxAutoHide + m_pCheckBoxAutoStart m_pSpinBoxPort m_pLineEditInterface m_pCheckBoxEnableCrypto diff --git a/src/gui/src/SetupWizard.cpp b/src/gui/src/SetupWizard.cpp index 0cfdb81..262d63c 100644 --- a/src/gui/src/SetupWizard.cpp +++ b/src/gui/src/SetupWizard.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-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 @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + #include "SetupWizard.h" #include "MainWindow.h" #include "QBarrierApplication.h" @@ -37,7 +37,7 @@ SetupWizard::SetupWizard(MainWindow& mainWindow, bool startMain) : #elif defined(Q_OS_WIN) - // when areo is disabled on windows, the next/back buttons + // when aero is disabled on windows, the next/back buttons // are hidden (must be a qt bug) -- resizing the window // to +1 of the original height seems to fix this. // NOTE: calling setMinimumSize after this will break @@ -58,7 +58,7 @@ SetupWizard::~SetupWizard() } bool SetupWizard::validateCurrentPage() -{ +{ QMessageBox message; message.setWindowTitle(tr("Setup Barrier")); message.setIcon(QMessageBox::Information); diff --git a/src/gui/src/SetupWizard.h b/src/gui/src/SetupWizard.h index 80e19e9..73223b2 100644 --- a/src/gui/src/SetupWizard.h +++ b/src/gui/src/SetupWizard.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-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 diff --git a/src/gui/src/ShutdownCh.h b/src/gui/src/ShutdownCh.h index 2462cae..54ec84d 100644 --- a/src/gui/src/ShutdownCh.h +++ b/src/gui/src/ShutdownCh.h @@ -19,4 +19,3 @@ // included in both the GUI and the child apps (server & client) const char ShutdownCh = 'S'; - diff --git a/src/gui/src/SslCertificate.cpp b/src/gui/src/SslCertificate.cpp index 80fdfc2..65ac08a 100644 --- a/src/gui/src/SslCertificate.cpp +++ b/src/gui/src/SslCertificate.cpp @@ -16,163 +16,111 @@ */ #include "SslCertificate.h" -#include "Fingerprint.h" #include "common/DataDirectories.h" +#include "base/finally.h" +#include "io/filesystem.h" +#include "net/FingerprintDatabase.h" +#include "net/SecureUtils.h" -#include -#include -#include - -static const char kCertificateLifetime[] = "365"; -static const char kCertificateSubjectInfo[] = "/CN=Barrier"; -static const char kCertificateFilename[] = "Barrier.pem"; -static const char kSslDir[] = "SSL"; -static const char kUnixOpenSslCommand[] = "openssl"; - -#if defined(Q_OS_WIN) -static const char kWinOpenSslBinary[] = "openssl.exe"; -static const char kConfigFile[] = "barrier.conf"; -#endif +#include +#include +#include +#include +#include SslCertificate::SslCertificate(QObject *parent) : QObject(parent) { - m_ProfileDir = QString::fromStdString(DataDirectories::profile()); - if (m_ProfileDir.isEmpty()) { + if (barrier::DataDirectories::profile().empty()) { emit error(tr("Failed to get profile directory.")); } } -bool SslCertificate::runTool(const QStringList& args) +void SslCertificate::generateCertificate() { - QString program; -#if defined(Q_OS_WIN) - program = QCoreApplication::applicationDirPath(); - program.append("\\").append(kWinOpenSslBinary); -#else - program = kUnixOpenSslCommand; -#endif - - - QStringList environment; -#if defined(Q_OS_WIN) - environment << QString("OPENSSL_CONF=%1\\%2") - .arg(QCoreApplication::applicationDirPath()) - .arg(kConfigFile); -#endif - - QProcess process; - process.setEnvironment(environment); - process.start(program, args); - - bool success = process.waitForStarted(); - - QString standardError; - if (success && process.waitForFinished()) - { - m_ToolOutput = process.readAllStandardOutput().trimmed(); - standardError = process.readAllStandardError().trimmed(); - } + auto cert_path = barrier::DataDirectories::ssl_certificate_path(); + + if (!barrier::fs::exists(cert_path) || !is_certificate_valid(cert_path)) { + try { + auto cert_dir = cert_path.parent_path(); + if (!barrier::fs::exists(cert_dir)) { + barrier::fs::create_directories(cert_dir); + } + + barrier::generate_pem_self_signed_cert(cert_path.u8string()); + } catch (const std::exception& e) { + emit error(QString("SSL tool failed: %1").arg(e.what())); + return; + } - int code = process.exitCode(); - if (!success || code != 0) - { - emit error( - QString("SSL tool failed: %1\n\nCode: %2\nError: %3") - .arg(program) - .arg(process.exitCode()) - .arg(standardError.isEmpty() ? "Unknown" : standardError)); - return false; + emit info(tr("SSL certificate generated.")); } - return true; + generate_fingerprint(cert_path); + + emit generateFinished(); } -void SslCertificate::generateCertificate() +void SslCertificate::generate_fingerprint(const barrier::fs::path& cert_path) { - QString sslDirPath = QString("%1%2%3") - .arg(m_ProfileDir) - .arg(QDir::separator()) - .arg(kSslDir); - - QString filename = QString("%1%2%3") - .arg(sslDirPath) - .arg(QDir::separator()) - .arg(kCertificateFilename); - - QFile file(filename); - if (!file.exists()) { - 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:2048"); - - QDir sslDir(sslDirPath); - if (!sslDir.exists()) { - sslDir.mkpath("."); + try { + auto local_path = barrier::DataDirectories::local_ssl_fingerprints_path(); + auto local_dir = local_path.parent_path(); + if (!barrier::fs::exists(local_dir)) { + barrier::fs::create_directories(local_dir); } - // key output filename - arguments.append("-keyout"); - arguments.append(filename); - - // certificate output filename - arguments.append("-out"); - arguments.append(filename); + barrier::FingerprintDatabase db; + db.add_trusted(barrier::get_pem_file_cert_fingerprint(cert_path.u8string(), + barrier::FingerprintType::SHA1)); + db.add_trusted(barrier::get_pem_file_cert_fingerprint(cert_path.u8string(), + barrier::FingerprintType::SHA256)); + db.write(local_path); - if (!runTool(arguments)) { - return; - } - - emit info(tr("SSL certificate generated.")); + emit info(tr("SSL fingerprint generated.")); + } catch (const std::exception& e) { + emit error(tr("Failed to find SSL fingerprint.") + e.what()); } - - generateFingerprint(filename); - - emit generateFinished(); } -void SslCertificate::generateFingerprint(const QString& certificateFilename) +bool SslCertificate::is_certificate_valid(const barrier::fs::path& path) { - QStringList arguments; - arguments.append("x509"); - arguments.append("-fingerprint"); - arguments.append("-sha1"); - arguments.append("-noout"); - arguments.append("-in"); - arguments.append(certificateFilename); - - if (!runTool(arguments)) { - return; + OpenSSL_add_all_algorithms(); + ERR_load_crypto_strings(); + + auto fp = barrier::fopen_utf8_path(path, "r"); + if (!fp) { + emit info(tr("Could not read from default certificate file.")); + return false; } + auto file_close = barrier::finally([fp]() { std::fclose(fp); }); - // find the fingerprint from the tool output - int i = m_ToolOutput.indexOf("="); - if (i != -1) { - i++; - QString fingerprint = m_ToolOutput.mid( - i, m_ToolOutput.size() - i); + auto* cert = PEM_read_X509(fp, nullptr, nullptr, nullptr); + if (!cert) { + emit info(tr("Error loading default certificate file to memory.")); + return false; + } + auto cert_free = barrier::finally([cert]() { X509_free(cert); }); - Fingerprint::local().trust(fingerprint, false); - emit info(tr("SSL fingerprint generated.")); + auto* pubkey = X509_get_pubkey(cert); + if (!pubkey) { + emit info(tr("Default certificate key file does not contain valid public key")); + return false; + } + auto pubkey_free = barrier::finally([pubkey]() { EVP_PKEY_free(pubkey); }); + + auto type = EVP_PKEY_type(EVP_PKEY_id(pubkey)); + if (type != EVP_PKEY_RSA && type != EVP_PKEY_DSA) { + emit info(tr("Public key in default certificate key file is not RSA or DSA")); + return false; } - else { - emit error(tr("Failed to find SSL fingerprint.")); + + auto bits = EVP_PKEY_bits(pubkey); + if (bits < 2048) { + // We could have small keys in old barrier installations + emit info(tr("Public key in default certificate key file is too small.")); + return false; } + + return true; } diff --git a/src/gui/src/SslCertificate.h b/src/gui/src/SslCertificate.h index 8b20913..eae7fd6 100644 --- a/src/gui/src/SslCertificate.h +++ b/src/gui/src/SslCertificate.h @@ -18,10 +18,12 @@ #pragma once #include +#include +#include "io/filesystem.h" class SslCertificate : public QObject { -Q_OBJECT + Q_OBJECT public: explicit SslCertificate(QObject *parent = 0); @@ -35,10 +37,7 @@ signals: void generateFinished(); private: - bool runTool(const QStringList& args); - void generateFingerprint(const QString& certificateFilename); + void generate_fingerprint(const barrier::fs::path& cert_path); -private: - QString m_ProfileDir; - QString m_ToolOutput; + bool is_certificate_valid(const barrier::fs::path& path); }; diff --git a/src/gui/src/TrashScreenWidget.cpp b/src/gui/src/TrashScreenWidget.cpp index 42a9d56..6f2abad 100644 --- a/src/gui/src/TrashScreenWidget.cpp +++ b/src/gui/src/TrashScreenWidget.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -40,4 +40,3 @@ void TrashScreenWidget::dropEvent(QDropEvent* event) else event->ignore(); } - diff --git a/src/gui/src/TrashScreenWidget.h b/src/gui/src/TrashScreenWidget.h index 7ab887e..967f73d 100644 --- a/src/gui/src/TrashScreenWidget.h +++ b/src/gui/src/TrashScreenWidget.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) - * + * * 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 @@ -39,4 +39,3 @@ class TrashScreenWidget : public QLabel }; #endif - diff --git a/src/gui/src/ZeroconfService.cpp b/src/gui/src/ZeroconfService.cpp index 02902ee..fbb0ea1 100644 --- a/src/gui/src/ZeroconfService.cpp +++ b/src/gui/src/ZeroconfService.cpp @@ -66,7 +66,7 @@ ZeroconfService::ZeroconfService(MainWindow* mainWindow) : m_ServiceRegistered(false) { silence_avahi_warning(); - if (m_pMainWindow->barrierType() == MainWindow::barrierServer) { + if (m_pMainWindow->barrier_type() == BarrierType::Server) { if (registerService(true)) { m_pZeroconfBrowser = new ZeroconfBrowser(this); connect(m_pZeroconfBrowser, SIGNAL( @@ -101,7 +101,7 @@ ZeroconfService::~ZeroconfService() void ZeroconfService::serverDetected(const QList& list) { - foreach (ZeroconfRecord record, list) { + for (ZeroconfRecord record : list) { registerService(false); m_pMainWindow->appendLogInfo(tr("zeroconf server detected: %1").arg( record.serviceName)); @@ -111,7 +111,7 @@ void ZeroconfService::serverDetected(const QList& list) void ZeroconfService::clientDetected(const QList& list) { - foreach (ZeroconfRecord record, list) { + for (ZeroconfRecord record : list) { m_pMainWindow->appendLogInfo(tr("zeroconf client detected: %1").arg( record.serviceName)); m_pMainWindow->autoAddScreen(record.serviceName); @@ -127,15 +127,15 @@ void ZeroconfService::errorHandle(DNSServiceErrorType errorCode) QString ZeroconfService::getLocalIPAddresses() { QStringList addresses; - foreach (const QHostAddress& address, QNetworkInterface::allAddresses()) { + for (const QHostAddress& address : QNetworkInterface::allAddresses()) { if (address.protocol() == QAbstractSocket::IPv4Protocol && address != QHostAddress(QHostAddress::LocalHost)) { addresses.append(address.toString()); } } - foreach (const QString& preferedIP, preferedIPAddress) { - foreach (const QString& address, addresses) { + for (const QString& preferedIP : preferedIPAddress) { + for (const QString& address : addresses) { if (address.startsWith(preferedIP)) { return address; } diff --git a/src/gui/src/main.cpp b/src/gui/src/main.cpp index 73251d5..776b44d 100644 --- a/src/gui/src/main.cpp +++ b/src/gui/src/main.cpp @@ -97,6 +97,12 @@ int main(int argc, char* argv[]) QApplication::setQuitOnLastWindowClosed(false); + if (QGuiApplication::platformName() == "wayland") { + QMessageBox::warning( + NULL, "Barrier", + "You are using wayland session, which is currently not fully supported by Barrier."); + } + QSettings settings; AppConfig appConfig (&settings); diff --git a/src/gui/test/HotkeyTests.cpp b/src/gui/test/HotkeyTests.cpp new file mode 100644 index 0000000..7607dfb --- /dev/null +++ b/src/gui/test/HotkeyTests.cpp @@ -0,0 +1,320 @@ +/* barrier -- mouse and keyboard sharing utility + Copyright (C) 2021 Povilas Kanapickas + + 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 "../src/Hotkey.h" +#include +#include "Utils.h" + +#include +#include + +struct TestAction +{ + Action::ActionType type = Action::keyDown; + std::vector keys; + std::vector type_screen_names; + std::string screen_name; + Action::SwitchDirection switch_direction; + Action::LockCursorMode lock_cursor_mode; + + static TestAction createKeyAction(Action::ActionType type, const std::vector& keys, + const std::vector& type_screen_names = {}) + { + TestAction action; + action.type = Action::keyDown; + action.keys = keys; + action.type_screen_names = type_screen_names; + return action; + } + + static TestAction createKeyDown(const std::vector& keys, + const std::vector& type_screen_names = {}) + { + return createKeyAction(Action::keyDown, keys, type_screen_names); + } + + static TestAction createKeyUp(const std::vector& keys, + const std::vector& type_screen_names = {}) + { + return createKeyAction(Action::keyUp, keys, type_screen_names); + } + + static TestAction createKeyStroke(const std::vector& keys, + const std::vector& type_screen_names = {}) + { + return createKeyAction(Action::keystroke, keys, type_screen_names); + } + + static TestAction createSwitchToScreen(const std::string& screen_name) + { + TestAction action; + action.type = Action::switchToScreen; + action.screen_name = screen_name; + return action; + } + + static TestAction createToggleScreen() + { + TestAction action; + action.type = Action::toggleScreen; + return action; + } + + static TestAction createSwitchInDirection(Action::SwitchDirection switch_direction) + { + TestAction action; + action.type = Action::switchInDirection; + action.switch_direction = switch_direction; + return action; + } + + static TestAction createLockCursorToScreen(Action::LockCursorMode lock_cursor_mode) + { + TestAction action; + action.type = Action::lockCursorToScreen; + action.lock_cursor_mode = lock_cursor_mode; + return action; + } +}; + +struct TestHotKey +{ + std::vector keys; + std::vector actions; +}; + +namespace { + + Action createAction(const TestAction& test_action) + { + Action action; + action.setType(test_action.type); + + switch (test_action.type) { + case Action::keyDown: + case Action::keyUp: + case Action::keystroke: { + KeySequence sequence; + for (auto key : test_action.keys) { + sequence.appendKey(key.key, key.modifier); + } + action.setKeySequence(sequence); + for (const auto& type_screen_name : test_action.type_screen_names) { + action.appendTypeScreenName(QString::fromStdString(type_screen_name)); + } + break; + } + case Action::switchToScreen: + action.setSwitchScreenName(QString::fromStdString(test_action.screen_name)); + break; + case Action::toggleScreen: + break; + case Action::switchInDirection: + action.setSwitchDirection(test_action.switch_direction); + break; + case Action::lockCursorToScreen: + action.setLockCursorMode(test_action.lock_cursor_mode); + break; + } + return action; + } + + Hotkey createHotkey(const TestHotKey& test_hotkey) + { + Hotkey hotkey; + KeySequence sequence; + for (auto key : test_hotkey.keys) { + sequence.appendKey(key.key, key.modifier); + } + hotkey.setKeySequence(sequence); + + for (auto action : test_hotkey.actions) { + hotkey.appendAction(createAction(action)); + } + return hotkey; + } + + std::string hotkeyToStringViaTextStream(const Hotkey& hotkey) + { + QString result; + QTextStream stream{&result}; + stream << hotkey; + return result.toStdString(); + } +} // namespace + +void doHotkeyLoadSaveTest(const TestHotKey& test_hotkey) +{ + auto filename = getTemporaryFilename(); + + Hotkey hotkey_before, hotkey_after; + { + QSettings settings(filename, QSettings::NativeFormat); + + hotkey_before = createHotkey(test_hotkey); + + settings.beginGroup("test"); + hotkey_before.saveSettings(settings); + settings.endGroup(); + } + { + QSettings settings(filename, QSettings::NativeFormat); + + settings.beginGroup("test"); + hotkey_after.loadSettings(settings); + settings.endGroup(); + + ASSERT_EQ(hotkey_before.keySequence().sequence(), hotkey_after.keySequence().sequence()); + ASSERT_EQ(hotkey_before.keySequence().modifiers(), hotkey_after.keySequence().modifiers()); + + const auto& actions_before = hotkey_before.actions(); + const auto& actions_after = hotkey_after.actions(); + + ASSERT_EQ(actions_before.size(), actions_after.size()); + for (int i = 0; i < actions_before.size(); ++i) { + const auto& action_before = actions_before[i]; + const auto& action_after = actions_after[i]; + + ASSERT_EQ(action_before.keySequence().sequence(), action_after.keySequence().sequence()); + ASSERT_EQ(action_before.keySequence().modifiers(), action_after.keySequence().modifiers()); + ASSERT_EQ(action_before.type(), action_after.type()); + ASSERT_EQ(action_before.typeScreenNames(), action_after.typeScreenNames()); + ASSERT_EQ(action_before.switchScreenName(), action_after.switchScreenName()); + ASSERT_EQ(action_before.switchDirection(), action_after.switchDirection()); + ASSERT_EQ(action_before.lockCursorMode(), action_after.lockCursorMode()); + ASSERT_EQ(action_before.activeOnRelease(), action_after.activeOnRelease()); + ASSERT_EQ(action_before.haveScreens(), action_after.haveScreens()); + } + } + + QFile::remove(filename); +} + +TEST(HotkeyLoadSaveTests, Empty) +{ + TestHotKey hotkey; + doHotkeyLoadSaveTest(hotkey); +} + +TEST(HotkeyLoadSaveTests, KeysNoActions) +{ + TestHotKey hotkey = {{{Qt::Key_A, Qt::NoModifier}, {Qt::Key_B, Qt::NoModifier}}, {}}; + doHotkeyLoadSaveTest(hotkey); +} + +TEST(HotkeyLoadSaveTests, CommaKeyNoActions) +{ + TestHotKey hotkey = { + { + {Qt::Key_A, Qt::NoModifier}, + {Qt::Key_Comma, Qt::NoModifier}, + {Qt::Key_B, Qt::NoModifier} + }, {}}; + doHotkeyLoadSaveTest(hotkey); +} + +TEST(HotkeyLoadSaveTests, KeysSingleAction) +{ + TestHotKey hotkey = { + { + {Qt::Key_A, Qt::NoModifier}, + {Qt::Key_B, Qt::NoModifier} + }, + { + TestAction::createKeyDown({{Qt::Key_Z, Qt::NoModifier}}) + } + }; + doHotkeyLoadSaveTest(hotkey); +} + +TEST(HotkeyLoadSaveTests, KeysMultipleAction) +{ + TestHotKey hotkey = { + { + {Qt::Key_A, Qt::NoModifier}, + {Qt::Key_B, Qt::NoModifier} + }, + { + TestAction::createKeyDown({{Qt::Key_Z, Qt::NoModifier}}), + TestAction::createSwitchToScreen("test_screen") + } + }; + doHotkeyLoadSaveTest(hotkey); +} + +TEST(HotkeyToTexStreamTests, Empty) +{ + TestHotKey hotkey; + ASSERT_EQ(hotkeyToStringViaTextStream(createHotkey(hotkey)), ""); +} + +TEST(HotkeyToTexStreamTests, KeysNoActions) +{ + TestHotKey hotkey = { + { + {Qt::Key_A, Qt::NoModifier}, + {Qt::Key_B, Qt::NoModifier} + }, + {} + }; + ASSERT_EQ(hotkeyToStringViaTextStream(createHotkey(hotkey)), ""); +} + +TEST(HotkeyToTexStreamTests, KeysSingleAction) +{ + TestHotKey hotkey = { + { + {Qt::Key_A, Qt::NoModifier}, + {Qt::Key_B, Qt::NoModifier} + }, + {} + }; + ASSERT_EQ(hotkeyToStringViaTextStream(createHotkey(hotkey)), ""); +} + + +TEST(HotkeyToTexStreamTests, KeysCommaSingleAction) +{ + TestHotKey hotkey = { + { + {Qt::Key_A, Qt::NoModifier}, + {Qt::Key_Comma, Qt::NoModifier}, + {Qt::Key_B, Qt::NoModifier} + }, + { + TestAction::createKeyDown({{Qt::Key_Z, Qt::NoModifier}}) + } + }; + ASSERT_EQ(hotkeyToStringViaTextStream(createHotkey(hotkey)), + "\tkeystroke(a+Comma+b) = keyDown(z,*)\n"); +} + +TEST(HotkeyToTexStreamTests, KeysMultipleAction) +{ + TestHotKey hotkey = { + { + {Qt::Key_A, Qt::NoModifier}, + {Qt::Key_B, Qt::NoModifier} + }, + { + TestAction::createKeyDown({{Qt::Key_Z, Qt::NoModifier}}), + TestAction::createSwitchToScreen("test_screen") + } + }; + ASSERT_EQ(hotkeyToStringViaTextStream(createHotkey(hotkey)), + "\tkeystroke(a+b) = keyDown(z,*), switchToScreen(test_screen)\n"); +} diff --git a/src/gui/test/KeySequenceTests.cpp b/src/gui/test/KeySequenceTests.cpp new file mode 100644 index 0000000..9fa9273 --- /dev/null +++ b/src/gui/test/KeySequenceTests.cpp @@ -0,0 +1,145 @@ +/* barrier -- mouse and keyboard sharing utility + Copyright (C) 2021 Povilas Kanapickas + + 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 "../src/KeySequence.h" +#include "Utils.h" +#include +#include + +#include +#include +#include + +namespace { + + auto s_key_sequence_test_keys = { + Qt::Key_Space, + Qt::Key_Escape, + Qt::Key_Tab, + Qt::Key_Backtab, + Qt::Key_Backspace, + Qt::Key_Return, + Qt::Key_Insert, + Qt::Key_Delete, + Qt::Key_Pause, + Qt::Key_Print, + Qt::Key_SysReq, + Qt::Key_Home, + Qt::Key_End, + Qt::Key_Left, + Qt::Key_Up, + Qt::Key_Right, + Qt::Key_Down, + Qt::Key_Comma, + Qt::Key_Semicolon, + Qt::Key_PageUp, + Qt::Key_PageDown, + Qt::Key_CapsLock, + Qt::Key_NumLock, + Qt::Key_ScrollLock, + Qt::Key_Help, + Qt::Key_Enter, + Qt::Key_Clear, + Qt::Key_Back, + Qt::Key_Forward, + Qt::Key_Stop, + Qt::Key_Refresh, + Qt::Key_VolumeDown, + Qt::Key_VolumeMute, + Qt::Key_VolumeUp, + Qt::Key_MediaPlay, + Qt::Key_MediaStop, + Qt::Key_MediaPrevious, + Qt::Key_MediaNext, + Qt::Key_HomePage, + Qt::Key_Favorites, + Qt::Key_Search, + Qt::Key_Standby, + Qt::Key_LaunchMail, + Qt::Key_LaunchMedia, + Qt::Key_Launch0, + Qt::Key_Launch1, + Qt::Key_Select, + }; + + std::string keySequenceToString(const std::vector& key_pairs) + { + KeySequence sequence; + for (auto key_pair : key_pairs) { + sequence.appendKey(key_pair.key, key_pair.modifier); + } + return sequence.toString().toStdString(); + } +} // namespace + +class KeySequenceLoadSaveTestFixture : + public ::testing::TestWithParam {}; + +TEST_P(KeySequenceLoadSaveTestFixture, SupportsSpecialSymbols) +{ + int key = GetParam(); + + auto filename = getTemporaryFilename(); + + { + QSettings settings(filename, QSettings::NativeFormat); + KeySequence sequence; + + sequence.appendKey(key, 0); + sequence.appendKey(key, 0); + settings.beginGroup("test"); + sequence.saveSettings(settings); + settings.endGroup(); + } + { + QSettings settings(filename, QSettings::NativeFormat); + KeySequence sequence; + + settings.beginGroup("test"); + sequence.loadSettings(settings); + settings.endGroup(); + + const auto& data = sequence.sequence(); + ASSERT_EQ(data.size(), 2); + ASSERT_EQ(data[0], key); + ASSERT_EQ(data[1], key); + } + + QFile::remove(filename); +} + +INSTANTIATE_TEST_CASE_P( + KeySequenceLoadSaveTests, + KeySequenceLoadSaveTestFixture, + ::testing::ValuesIn(s_key_sequence_test_keys)); + +TEST(KeySequenceTests, ToString) +{ + ASSERT_EQ(keySequenceToString({{Qt::Key_Menu, Qt::MetaModifier}}), + "Meta"); + ASSERT_EQ(keySequenceToString({{Qt::Key_A, 0}, {Qt::Key_B, 0}}), + "a+b"); + ASSERT_EQ(keySequenceToString({{Qt::Key_A, 0}, {Qt::Key_Comma, 0}, {Qt::Key_B, 0}}), + "a+Comma+b"); + ASSERT_EQ(keySequenceToString({{Qt::Key_A, 0}, {Qt::Key_Semicolon, 0}, {Qt::Key_B, 0}}), + "a+Semicolon+b"); + ASSERT_EQ(keySequenceToString({{Qt::Key_A, 0}, {Qt::Key_Shift, Qt::ShiftModifier}, + {Qt::Key_0, Qt::ShiftModifier}}), + "a+Shift+0"); + ASSERT_EQ(keySequenceToString({{Qt::Key_A, 0}, {Qt::Key_Control, Qt::ControlModifier}, + {Qt::Key_0, Qt::ControlModifier}}), + "a+Control+0"); +} diff --git a/src/gui/test/Utils.h b/src/gui/test/Utils.h new file mode 100644 index 0000000..da66ce7 --- /dev/null +++ b/src/gui/test/Utils.h @@ -0,0 +1,38 @@ +/* barrier -- mouse and keyboard sharing utility + Copyright (C) 2021 Povilas Kanapickas + + 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 BARRIER_GUI_TEST_UTILS_H +#define BARRIER_GUI_TEST_UTILS_H + +#include +#include + +struct TestKey +{ + int key = 0; + int modifier = Qt::NoModifier; + + TestKey(int key, int modifier) : key{key}, modifier{modifier} {} +}; + +inline QString getTemporaryFilename() +{ + QTemporaryFile temp_file; + temp_file.open(); + return temp_file.fileName(); +} + +#endif // BARRIER_GUI_TEST_UTILS_H diff --git a/src/gui/test/main.cpp b/src/gui/test/main.cpp new file mode 100644 index 0000000..b57dd76 --- /dev/null +++ b/src/gui/test/main.cpp @@ -0,0 +1,23 @@ +/* barrier -- mouse and keyboard sharing utility + Copyright (C) 2021 Povilas Kanapickas + + 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 + +int main(int argc, char **argv) +{ + testing::InitGoogleTest(&argc, argv); + return (RUN_ALL_TESTS() == 1) ? 1 : 0; +} diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 70a0629..fdec71c 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 diff --git a/src/lib/arch/Arch.cpp b/src/lib/arch/Arch.cpp index 0a3b3e5..810b74f 100644 --- a/src/lib/arch/Arch.cpp +++ b/src/lib/arch/Arch.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/Arch.h b/src/lib/arch/Arch.h index 940a2e3..3b37617 100644 --- a/src/lib/arch/Arch.h +++ b/src/lib/arch/Arch.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/ArchConsoleStd.cpp b/src/lib/arch/ArchConsoleStd.cpp index f7f7691..2e188bb 100644 --- a/src/lib/arch/ArchConsoleStd.cpp +++ b/src/lib/arch/ArchConsoleStd.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -30,4 +30,4 @@ ArchConsoleStd::writeConsole(ELevel level, const char* str) std::cout << str << std::endl; std::cout.flush(); -} \ No newline at end of file +} diff --git a/src/lib/arch/ArchConsoleStd.h b/src/lib/arch/ArchConsoleStd.h index 8560fad..1d306e7 100644 --- a/src/lib/arch/ArchConsoleStd.h +++ b/src/lib/arch/ArchConsoleStd.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/ArchDaemonNone.cpp b/src/lib/arch/ArchDaemonNone.cpp index 1222549..5cb4681 100644 --- a/src/lib/arch/ArchDaemonNone.cpp +++ b/src/lib/arch/ArchDaemonNone.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/ArchDaemonNone.h b/src/lib/arch/ArchDaemonNone.h index e02405f..425ae56 100644 --- a/src/lib/arch/ArchDaemonNone.h +++ b/src/lib/arch/ArchDaemonNone.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/CMakeLists.txt b/src/lib/arch/CMakeLists.txt index db92634..5ff7b51 100644 --- a/src/lib/arch/CMakeLists.txt +++ b/src/lib/arch/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 diff --git a/src/lib/arch/IArchConsole.h b/src/lib/arch/IArchConsole.h index d115c50..41e3527 100644 --- a/src/lib/arch/IArchConsole.h +++ b/src/lib/arch/IArchConsole.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/IArchDaemon.h b/src/lib/arch/IArchDaemon.h index 23a34f2..6a4fb67 100644 --- a/src/lib/arch/IArchDaemon.h +++ b/src/lib/arch/IArchDaemon.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -64,7 +64,7 @@ public: Installs the default daemon. */ virtual void installDaemon() = 0; - + //! Uninstall daemon /*! Uninstalls the default daemon. @@ -76,7 +76,7 @@ public: Daemonize. Throw XArchDaemonFailed on error. \c name is the name of the daemon. Once daemonized, \c func is invoked and daemonize returns when and what it does. - + Exactly what happens when daemonizing depends on the platform.
  • unix: diff --git a/src/lib/arch/IArchLog.h b/src/lib/arch/IArchLog.h index 165b1df..704ad47 100644 --- a/src/lib/arch/IArchLog.h +++ b/src/lib/arch/IArchLog.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/IArchMultithread.h b/src/lib/arch/IArchMultithread.h index e8d358b..6a57694 100644 --- a/src/lib/arch/IArchMultithread.h +++ b/src/lib/arch/IArchMultithread.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -19,8 +19,9 @@ #pragma once #include "common/IInterface.h" +#include -/*! +/*! \class ArchCondImpl \brief Internal condition variable data. An architecture dependent type holding the necessary data for a @@ -28,35 +29,35 @@ condition variable. */ class ArchCondImpl; -/*! +/*! \var ArchCond \brief Opaque condition variable type. An opaque type representing a condition variable. */ typedef ArchCondImpl* ArchCond; -/*! +/*! \class ArchMutexImpl \brief Internal mutex data. An architecture dependent type holding the necessary data for a mutex. */ class ArchMutexImpl; -/*! +/*! \var ArchMutex \brief Opaque mutex type. An opaque type representing a mutex. */ typedef ArchMutexImpl* ArchMutex; -/*! +/*! \class ArchThreadImpl \brief Internal thread data. An architecture dependent type holding the necessary data for a thread. */ class ArchThreadImpl; -/*! +/*! \var ArchThread \brief Opaque thread type. An opaque type representing a thread. @@ -71,7 +72,7 @@ barrier. Each architecture must implement this interface. class IArchMultithread : public IInterface { public: //! Type of thread entry point - typedef void* (*ThreadFunc)(void*); + typedef void (*ThreadFunc)(void*); //! Type of thread identifier typedef unsigned int ThreadID; //! Types of signals @@ -160,7 +161,7 @@ public: Creates and starts a new thread, using \c func as the entry point and passing it \c userData. The thread is an opaque data type. */ - virtual ArchThread newThread(ThreadFunc func, void* userData) = 0; + virtual ArchThread newThread(const std::function& func) = 0; //! Get a reference to the calling thread /*! @@ -235,15 +236,6 @@ public: */ virtual bool isExitedThread(ArchThread thread) = 0; - //! Returns the exit code of a thread - /*! - Waits indefinitely for \c thread to exit (if it hasn't yet) then - returns the thread's exit code. - - (Cancellation point) - */ - virtual void* getResultOfThread(ArchThread thread) = 0; - //! Returns an ID for a thread /*! Returns some ID number for \c thread. This is for logging purposes. diff --git a/src/lib/arch/IArchNetwork.h b/src/lib/arch/IArchNetwork.h index b859506..7eae63e 100644 --- a/src/lib/arch/IArchNetwork.h +++ b/src/lib/arch/IArchNetwork.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -24,21 +24,21 @@ class ArchThreadImpl; typedef ArchThreadImpl* ArchThread; -/*! +/*! \class ArchSocketImpl \brief Internal socket data. An architecture dependent type holding the necessary data for a socket. */ class ArchSocketImpl; -/*! +/*! \var ArchSocket \brief Opaque socket type. An opaque type representing a socket. */ typedef ArchSocketImpl* ArchSocket; -/*! +/*! \class ArchNetAddressImpl \brief Internal network address data. An architecture dependent type holding the necessary data for a network @@ -46,7 +46,7 @@ address. */ class ArchNetAddressImpl; -/*! +/*! \var ArchNetAddress \brief Opaque network address type. An opaque type representing a network address. diff --git a/src/lib/arch/IArchSleep.h b/src/lib/arch/IArchSleep.h index 9999d0e..86c571f 100644 --- a/src/lib/arch/IArchSleep.h +++ b/src/lib/arch/IArchSleep.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/IArchString.cpp b/src/lib/arch/IArchString.cpp index 0f7f300..b1118ec 100644 --- a/src/lib/arch/IArchString.cpp +++ b/src/lib/arch/IArchString.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/IArchString.h b/src/lib/arch/IArchString.h index ea10b65..f1803d8 100644 --- a/src/lib/arch/IArchString.h +++ b/src/lib/arch/IArchString.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -46,16 +46,6 @@ public: //! @name manipulators //@{ - //! printf() to limited size buffer with va_list - /*! - This method is equivalent to vsprintf() except it will not write - more than \c n bytes to the buffer, returning -1 if the output - was truncated and the number of bytes written not including the - trailing NUL otherwise. - */ - virtual int vsnprintf(char* str, - int size, const char* fmt, va_list ap); - //! Convert multibyte string to wide character string virtual int convStringMBToWC(wchar_t*, const char*, UInt32 n, bool* errors); diff --git a/src/lib/arch/IArchSystem.h b/src/lib/arch/IArchSystem.h index 9446505..3e7aa98 100644 --- a/src/lib/arch/IArchSystem.h +++ b/src/lib/arch/IArchSystem.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/IArchTaskBar.h b/src/lib/arch/IArchTaskBar.h index 85a32d8..fc5f0d0 100644 --- a/src/lib/arch/IArchTaskBar.h +++ b/src/lib/arch/IArchTaskBar.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/IArchTaskBarReceiver.h b/src/lib/arch/IArchTaskBarReceiver.h index 997c8ae..b4f0d30 100644 --- a/src/lib/arch/IArchTaskBarReceiver.h +++ b/src/lib/arch/IArchTaskBarReceiver.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/IArchTime.h b/src/lib/arch/IArchTime.h index abb3cdd..297aab7 100644 --- a/src/lib/arch/IArchTime.h +++ b/src/lib/arch/IArchTime.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/XArch.h b/src/lib/arch/XArch.h index 8484d06..2fcf686 100644 --- a/src/lib/arch/XArch.h +++ b/src/lib/arch/XArch.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -57,7 +57,7 @@ class XArchEval { public: XArchEval() { } virtual ~XArchEval() noexcept { } - + virtual std::string eval() const = 0; }; diff --git a/src/lib/arch/multibyte.h b/src/lib/arch/multibyte.h index 4a4e0ec..7812e0b 100644 --- a/src/lib/arch/multibyte.h +++ b/src/lib/arch/multibyte.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchConsoleUnix.cpp b/src/lib/arch/unix/ArchConsoleUnix.cpp index 79a4634..d5e8e1d 100644 --- a/src/lib/arch/unix/ArchConsoleUnix.cpp +++ b/src/lib/arch/unix/ArchConsoleUnix.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchConsoleUnix.h b/src/lib/arch/unix/ArchConsoleUnix.h index 8326ab5..136c606 100644 --- a/src/lib/arch/unix/ArchConsoleUnix.h +++ b/src/lib/arch/unix/ArchConsoleUnix.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchDaemonUnix.cpp b/src/lib/arch/unix/ArchDaemonUnix.cpp index a03bf7a..f1ac1d5 100644 --- a/src/lib/arch/unix/ArchDaemonUnix.cpp +++ b/src/lib/arch/unix/ArchDaemonUnix.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -53,15 +53,15 @@ execSelfNonDaemonized() { extern char** NXArgv; char** selfArgv = NXArgv; - + setenv("_BARRIER_DAEMONIZED", "", 1); - + execvp(selfArgv[0], selfArgv); return 0; } bool alreadyDaemonized() { - return getenv("_BARRIER_DAEMONIZED") != NULL; + return std::getenv("_BARRIER_DAEMONIZED") != NULL; } #endif @@ -73,7 +73,7 @@ ArchDaemonUnix::daemonize(const char* name, DaemonFunc func) if (alreadyDaemonized()) return func(1, &name); #endif - + // fork so shell thinks we're done and so we're not a process // group leader switch (fork()) { @@ -92,7 +92,7 @@ ArchDaemonUnix::daemonize(const char* name, DaemonFunc func) // become leader of a new session setsid(); - + #ifndef __APPLE__ // NB: don't run chdir on apple; causes strange behaviour. // chdir to root so we don't keep mounted filesystems points busy @@ -115,18 +115,18 @@ ArchDaemonUnix::daemonize(const char* name, DaemonFunc func) // of standard I/O safely goes in the bit bucket. open("/dev/null", O_RDONLY); open("/dev/null", O_RDWR); - + int dupErr = dup(1); if (dupErr < 0) { // NB: file logging actually isn't working at this point! LOG((CLOG_ERR "dup error: %i", dupErr)); } - + #ifdef __APPLE__ return execSelfNonDaemonized(); #endif - + // invoke function return func(1, &name); } diff --git a/src/lib/arch/unix/ArchDaemonUnix.h b/src/lib/arch/unix/ArchDaemonUnix.h index 530159a..52a531e 100644 --- a/src/lib/arch/unix/ArchDaemonUnix.h +++ b/src/lib/arch/unix/ArchDaemonUnix.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchInternetUnix.cpp b/src/lib/arch/unix/ArchInternetUnix.cpp index 76966dc..dcea2ae 100644 --- a/src/lib/arch/unix/ArchInternetUnix.cpp +++ b/src/lib/arch/unix/ArchInternetUnix.cpp @@ -94,16 +94,16 @@ std::string CurlFacade::get(const std::string& url) userAgent << "Barrier "; userAgent << kVersion; curl_easy_setopt(m_curl, CURLOPT_USERAGENT, userAgent.str().c_str()); - + std::string result; curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, &result); - + CURLcode code = curl_easy_perform(m_curl); if (code != CURLE_OK) { LOG((CLOG_ERR "curl perform error: %s", curl_easy_strerror(code))); throw XArch("CURL perform failed."); } - + return result; } @@ -114,7 +114,7 @@ std::string CurlFacade::urlEncode(const std::string& url) if (resultCStr == NULL) { throw XArch("CURL escape failed."); } - + std::string result(resultCStr); curl_free(resultCStr); diff --git a/src/lib/arch/unix/ArchLogUnix.cpp b/src/lib/arch/unix/ArchLogUnix.cpp index b1f9089..2389f48 100644 --- a/src/lib/arch/unix/ArchLogUnix.cpp +++ b/src/lib/arch/unix/ArchLogUnix.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchLogUnix.h b/src/lib/arch/unix/ArchLogUnix.h index cdd733f..f37bab8 100644 --- a/src/lib/arch/unix/ArchLogUnix.h +++ b/src/lib/arch/unix/ArchLogUnix.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchMultithreadPosix.cpp b/src/lib/arch/unix/ArchMultithreadPosix.cpp index 4866edc..8400f9d 100644 --- a/src/lib/arch/unix/ArchMultithreadPosix.cpp +++ b/src/lib/arch/unix/ArchMultithreadPosix.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -59,24 +59,19 @@ public: int m_refCount; IArchMultithread::ThreadID m_id; pthread_t m_thread; - IArchMultithread::ThreadFunc m_func; - void* m_userData; + std::function func_;; bool m_cancel; bool m_cancelling; bool m_exited; - void* m_result; void* m_networkData; }; ArchThreadImpl::ArchThreadImpl() : m_refCount(1), m_id(0), - m_func(NULL), - m_userData(NULL), m_cancel(false), m_cancelling(false), m_exited(false), - m_result(NULL), m_networkData(NULL) { // do nothing @@ -319,11 +314,8 @@ ArchMultithreadPosix::unlockMutex(ArchMutex mutex) } } -ArchThread -ArchMultithreadPosix::newThread(ThreadFunc func, void* data) +ArchThread ArchMultithreadPosix::newThread(const std::function& func) { - assert(func != NULL); - // initialize signal handler. we do this here instead of the // constructor so we can avoid daemonizing (using fork()) // when there are multiple threads. clients can safely @@ -341,8 +333,7 @@ ArchMultithreadPosix::newThread(ThreadFunc func, void* data) // create thread impl for new thread ArchThreadImpl* thread = new ArchThreadImpl; - thread->m_func = func; - thread->m_userData = data; + thread->func_ = func; // create the thread. pthread_create() on RedHat 7.2 smp fails // if passed a NULL attr so use a default attr. @@ -389,7 +380,7 @@ ArchMultithreadPosix::closeThread(ArchThread thread) // decrement ref count and clean up thread if no more references if (--thread->m_refCount == 0) { // detach from thread (unless it's the main thread) - if (thread->m_func != NULL) { + if (thread->func_) { pthread_detach(thread->m_thread); } @@ -526,13 +517,6 @@ ArchMultithreadPosix::isExitedThread(ArchThread thread) return thread->m_exited; } -void* -ArchMultithreadPosix::getResultOfThread(ArchThread thread) -{ - std::lock_guard lock(m_threadMutex); - return thread->m_result; -} - IArchMultithread::ThreadID ArchMultithreadPosix::getIDOfThread(ArchThread thread) { @@ -549,7 +533,7 @@ ArchMultithreadPosix::setSignalHandler( } void -ArchMultithreadPosix::raiseSignal(ESignal signal) +ArchMultithreadPosix::raiseSignal(ESignal signal) { std::lock_guard lock(m_threadMutex); if (m_signalFunc[signal] != NULL) { @@ -699,10 +683,8 @@ ArchMultithreadPosix::doThreadFunc(ArchThread thread) std::lock_guard lock(m_threadMutex); } - void* result = NULL; try { - // go - result = (*thread->m_func)(thread->m_userData); + thread->func_(); } catch (XThreadCancel&) { @@ -721,7 +703,6 @@ ArchMultithreadPosix::doThreadFunc(ArchThread thread) // thread has exited { std::lock_guard lock(m_threadMutex); - thread->m_result = result; thread->m_exited = true; } diff --git a/src/lib/arch/unix/ArchMultithreadPosix.h b/src/lib/arch/unix/ArchMultithreadPosix.h index 4bd879f..798147a 100644 --- a/src/lib/arch/unix/ArchMultithreadPosix.h +++ b/src/lib/arch/unix/ArchMultithreadPosix.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -67,7 +67,7 @@ public: virtual void closeMutex(ArchMutex); virtual void lockMutex(ArchMutex); virtual void unlockMutex(ArchMutex); - virtual ArchThread newThread(ThreadFunc, void*); + virtual ArchThread newThread(const std::function& func); virtual ArchThread newCurrentThread(); virtual ArchThread copyThread(ArchThread); virtual void closeThread(ArchThread); @@ -77,7 +77,6 @@ public: virtual bool wait(ArchThread, double timeout); virtual bool isSameThread(ArchThread, ArchThread); virtual bool isExitedThread(ArchThread); - virtual void* getResultOfThread(ArchThread); virtual ThreadID getIDOfThread(ArchThread); virtual void setSignalHandler(ESignal, SignalFunc, void*); virtual void raiseSignal(ESignal); diff --git a/src/lib/arch/unix/ArchNetworkBSD.cpp b/src/lib/arch/unix/ArchNetworkBSD.cpp index 496c988..5507bfe 100644 --- a/src/lib/arch/unix/ArchNetworkBSD.cpp +++ b/src/lib/arch/unix/ArchNetworkBSD.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchNetworkBSD.h b/src/lib/arch/unix/ArchNetworkBSD.h index 3f5679a..e3f11d5 100644 --- a/src/lib/arch/unix/ArchNetworkBSD.h +++ b/src/lib/arch/unix/ArchNetworkBSD.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchSleepUnix.cpp b/src/lib/arch/unix/ArchSleepUnix.cpp index 48e2600..1f91c34 100644 --- a/src/lib/arch/unix/ArchSleepUnix.cpp +++ b/src/lib/arch/unix/ArchSleepUnix.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchSleepUnix.h b/src/lib/arch/unix/ArchSleepUnix.h index 3e307a5..d2cdbca 100644 --- a/src/lib/arch/unix/ArchSleepUnix.h +++ b/src/lib/arch/unix/ArchSleepUnix.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchStringUnix.cpp b/src/lib/arch/unix/ArchStringUnix.cpp index 591c826..dbb91c1 100644 --- a/src/lib/arch/unix/ArchStringUnix.cpp +++ b/src/lib/arch/unix/ArchStringUnix.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -25,7 +25,6 @@ // #include "arch/multibyte.h" -#include "arch/vsnprintf.h" ArchStringUnix::ArchStringUnix() { diff --git a/src/lib/arch/unix/ArchStringUnix.h b/src/lib/arch/unix/ArchStringUnix.h index f7d0035..551f497 100644 --- a/src/lib/arch/unix/ArchStringUnix.h +++ b/src/lib/arch/unix/ArchStringUnix.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchSystemUnix.cpp b/src/lib/arch/unix/ArchSystemUnix.cpp index f51e47f..f956998 100644 --- a/src/lib/arch/unix/ArchSystemUnix.cpp +++ b/src/lib/arch/unix/ArchSystemUnix.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchSystemUnix.h b/src/lib/arch/unix/ArchSystemUnix.h index aa9c564..f3c2ad6 100644 --- a/src/lib/arch/unix/ArchSystemUnix.h +++ b/src/lib/arch/unix/ArchSystemUnix.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchTaskBarXWindows.cpp b/src/lib/arch/unix/ArchTaskBarXWindows.cpp index c3577ad..522c7fd 100644 --- a/src/lib/arch/unix/ArchTaskBarXWindows.cpp +++ b/src/lib/arch/unix/ArchTaskBarXWindows.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchTaskBarXWindows.h b/src/lib/arch/unix/ArchTaskBarXWindows.h index f2c8977..5b60a08 100644 --- a/src/lib/arch/unix/ArchTaskBarXWindows.h +++ b/src/lib/arch/unix/ArchTaskBarXWindows.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchTimeUnix.cpp b/src/lib/arch/unix/ArchTimeUnix.cpp index 24685aa..665a7eb 100644 --- a/src/lib/arch/unix/ArchTimeUnix.cpp +++ b/src/lib/arch/unix/ArchTimeUnix.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/ArchTimeUnix.h b/src/lib/arch/unix/ArchTimeUnix.h index 3c5c0f8..c6a7dc6 100644 --- a/src/lib/arch/unix/ArchTimeUnix.h +++ b/src/lib/arch/unix/ArchTimeUnix.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/XArchUnix.cpp b/src/lib/arch/unix/XArchUnix.cpp index fc7ff65..db2006d 100644 --- a/src/lib/arch/unix/XArchUnix.cpp +++ b/src/lib/arch/unix/XArchUnix.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/unix/XArchUnix.h b/src/lib/arch/unix/XArchUnix.h index 93d6d62..be2e689 100644 --- a/src/lib/arch/unix/XArchUnix.h +++ b/src/lib/arch/unix/XArchUnix.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/vsnprintf.h b/src/lib/arch/vsnprintf.h deleted file mode 100644 index 5a4e3dc..0000000 --- a/src/lib/arch/vsnprintf.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2012-2016 Symless Ltd. - * Copyright (C) 2002 Chris Schoeneman - * - * 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/IArchString.h" - -#if HAVE_VSNPRINTF - -#if !defined(ARCH_VSNPRINTF) -# define ARCH_VSNPRINTF vsnprintf -#endif - -int -IArchString::vsnprintf(char* str, int size, const char* fmt, va_list ap) -{ - int n = ::ARCH_VSNPRINTF(str, size, fmt, ap); - if (n > size) { - n = -1; - } - return n; -} - -#elif SYSAPI_UNIX // !HAVE_VSNPRINTF - -#include - -int -IArchString::vsnprintf(char* str, int size, const char* fmt, va_list ap) -{ - static FILE* bitbucket = fopen("/dev/null", "w"); - if (bitbucket == NULL) { - // uh oh - if (size > 0) { - str[0] = '\0'; - } - return 0; - } - else { - // count the characters using the bitbucket - int n = vfprintf(bitbucket, fmt, ap); - if (n + 1 <= size) { - // it'll fit so print it into str - vsprintf(str, fmt, ap); - } - return n; - } -} - -#else // !HAVE_VSNPRINTF && !SYSAPI_UNIX - -#error vsnprintf not implemented - -#endif // !HAVE_VSNPRINTF diff --git a/src/lib/arch/win32/ArchConsoleWindows.cpp b/src/lib/arch/win32/ArchConsoleWindows.cpp index 4514555..2c61eb7 100644 --- a/src/lib/arch/win32/ArchConsoleWindows.cpp +++ b/src/lib/arch/win32/ArchConsoleWindows.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/win32/ArchConsoleWindows.h b/src/lib/arch/win32/ArchConsoleWindows.h index f1f0cc9..a6c6d68 100644 --- a/src/lib/arch/win32/ArchConsoleWindows.h +++ b/src/lib/arch/win32/ArchConsoleWindows.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/win32/ArchDaemonWindows.cpp b/src/lib/arch/win32/ArchDaemonWindows.cpp index efcf235..df0a4ce 100644 --- a/src/lib/arch/win32/ArchDaemonWindows.cpp +++ b/src/lib/arch/win32/ArchDaemonWindows.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -441,7 +441,7 @@ ArchDaemonWindows::serviceMain(DWORD argc, LPTSTR* argvIn) // create synchronization objects m_serviceMutex = ARCH->newMutex(); m_serviceCondVar = ARCH->newCondVar(); - + // register our service handler function m_statusHandle = RegisterServiceCtrlHandler(argv[0], &ArchDaemonWindows::serviceHandlerEntry); @@ -667,7 +667,7 @@ ArchDaemonWindows::stop(const char* name) // ask the service to stop, asynchronously SERVICE_STATUS ss; if (!ControlService(service, SERVICE_CONTROL_STOP, &ss)) { - DWORD dwErrCode = GetLastError(); + DWORD dwErrCode = GetLastError(); if (dwErrCode != ERROR_SERVICE_NOT_ACTIVE) { throw XArchDaemonFailed(new XArchEvalWindows()); } @@ -681,7 +681,7 @@ ArchDaemonWindows::installDaemon() if (!isDaemonInstalled(DEFAULT_DAEMON_NAME)) { char path[MAX_PATH]; GetModuleFileName(ArchMiscWindows::instanceWin32(), path, MAX_PATH); - + // wrap in quotes so a malicious user can't start \Program.exe as admin. std::stringstream ss; ss << '"'; diff --git a/src/lib/arch/win32/ArchDaemonWindows.h b/src/lib/arch/win32/ArchDaemonWindows.h index 2db9792..7813f09 100644 --- a/src/lib/arch/win32/ArchDaemonWindows.h +++ b/src/lib/arch/win32/ArchDaemonWindows.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/win32/ArchInternetWindows.cpp b/src/lib/arch/win32/ArchInternetWindows.cpp index 8a28fde..fb75e7d 100644 --- a/src/lib/arch/win32/ArchInternetWindows.cpp +++ b/src/lib/arch/win32/ArchInternetWindows.cpp @@ -72,7 +72,7 @@ std::string ArchInternetWindows::urlEncode(const std::string& url) std::string result(buffer); - // the win32 url encoding funcitons are pretty useless (to us) and only + // the win32 url encoding functions are pretty useless (to us) and only // escape "unsafe" chars, but not + or =, so we need to replace these // manually (and probably many other chars). barrier::string::findReplaceAll(result, "+", "%2B"); @@ -121,12 +121,12 @@ std::string WinINetRequest::send() openSession(); connect(); openRequest(); - + std::string headers("Content-Type: text/html"); if (!HttpSendRequest(m_request, headers.c_str(), (DWORD)headers.length(), NULL, NULL)) { throw XArch(new XArchEvalWindows()); } - + std::stringstream result; CHAR buffer[1025]; DWORD read = 0; @@ -170,7 +170,7 @@ WinINetRequest::connect() INTERNET_SERVICE_HTTP, NULL, NULL); - + if (m_connect == NULL) { throw XArch(new XArchEvalWindows()); } diff --git a/src/lib/arch/win32/ArchLogWindows.cpp b/src/lib/arch/win32/ArchLogWindows.cpp index bc17abf..1b8855a 100644 --- a/src/lib/arch/win32/ArchLogWindows.cpp +++ b/src/lib/arch/win32/ArchLogWindows.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/win32/ArchLogWindows.h b/src/lib/arch/win32/ArchLogWindows.h index 3a997f1..efc466f 100644 --- a/src/lib/arch/win32/ArchLogWindows.h +++ b/src/lib/arch/win32/ArchLogWindows.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/win32/ArchMiscWindows.cpp b/src/lib/arch/win32/ArchMiscWindows.cpp index 2c022b1..ab16daa 100644 --- a/src/lib/arch/win32/ArchMiscWindows.cpp +++ b/src/lib/arch/win32/ArchMiscWindows.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -429,7 +429,7 @@ ArchMiscWindows::wakeupDisplay() } bool -ArchMiscWindows::wasLaunchedAsService() +ArchMiscWindows::wasLaunchedAsService() { std::string name; if (!getParentProcessName(name)) { @@ -441,9 +441,9 @@ ArchMiscWindows::wasLaunchedAsService() } bool ArchMiscWindows::getParentProcessName(std::string &name) -{ +{ PROCESSENTRY32 parentEntry; - if (!getParentProcessEntry(parentEntry)){ + if (!getParentProcessEntry(parentEntry)) { LOG((CLOG_ERR "could not get entry for parent process")); return false; } @@ -452,14 +452,14 @@ bool ArchMiscWindows::getParentProcessName(std::string &name) return true; } -BOOL WINAPI +BOOL WINAPI ArchMiscWindows::getSelfProcessEntry(PROCESSENTRY32& entry) { // get entry from current PID return getProcessEntry(entry, GetCurrentProcessId()); } -BOOL WINAPI +BOOL WINAPI ArchMiscWindows::getParentProcessEntry(PROCESSENTRY32& entry) { // get the current process, so we can get parent PID @@ -472,24 +472,24 @@ ArchMiscWindows::getParentProcessEntry(PROCESSENTRY32& entry) return getProcessEntry(entry, selfEntry.th32ParentProcessID); } -BOOL WINAPI +BOOL WINAPI ArchMiscWindows::getProcessEntry(PROCESSENTRY32& entry, DWORD processID) { // first we need to take a snapshot of the running processes HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (snapshot == INVALID_HANDLE_VALUE) { - LOG((CLOG_ERR "could not get process snapshot (error: %i)", + LOG((CLOG_ERR "could not get process snapshot (error: %i)", GetLastError())); return FALSE; } entry.dwSize = sizeof(PROCESSENTRY32); - // get the first process, and if we can't do that then it's + // get the first process, and if we can't do that then it's // unlikely we can go any further BOOL gotEntry = Process32First(snapshot, &entry); if (!gotEntry) { - LOG((CLOG_ERR "could not get first process entry (error: %i)", + LOG((CLOG_ERR "could not get first process entry (error: %i)", GetLastError())); return FALSE; } diff --git a/src/lib/arch/win32/ArchMiscWindows.h b/src/lib/arch/win32/ArchMiscWindows.h index 91cd8f5..d5373a0 100644 --- a/src/lib/arch/win32/ArchMiscWindows.h +++ b/src/lib/arch/win32/ArchMiscWindows.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -167,7 +167,7 @@ public: static HINSTANCE instanceWin32(); static void setInstanceWin32(HINSTANCE instance); - + static BOOL WINAPI getProcessEntry(PROCESSENTRY32& entry, DWORD processID); static BOOL WINAPI getSelfProcessEntry(PROCESSENTRY32& entry); static BOOL WINAPI getParentProcessEntry(PROCESSENTRY32& entry); diff --git a/src/lib/arch/win32/ArchMultithreadWindows.cpp b/src/lib/arch/win32/ArchMultithreadWindows.cpp index d3fd059..43a7374 100644 --- a/src/lib/arch/win32/ArchMultithreadWindows.cpp +++ b/src/lib/arch/win32/ArchMultithreadWindows.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -49,12 +49,10 @@ public: int m_refCount; HANDLE m_thread; DWORD m_id; - IArchMultithread::ThreadFunc m_func; - void* m_userData; + std::function func_; HANDLE m_cancel; bool m_cancelling; HANDLE m_exit; - void* m_result; void* m_networkData; }; @@ -62,10 +60,7 @@ ArchThreadImpl::ArchThreadImpl() : m_refCount(1), m_thread(NULL), m_id(0), - m_func(NULL), - m_userData(NULL), m_cancelling(false), - m_result(NULL), m_networkData(NULL) { m_exit = CreateEvent(NULL, TRUE, FALSE, NULL); @@ -292,15 +287,13 @@ ArchMultithreadWindows::unlockMutex(ArchMutex mutex) LeaveCriticalSection(&mutex->m_mutex); } -ArchThread -ArchMultithreadWindows::newThread(ThreadFunc func, void* data) +ArchThread ArchMultithreadWindows::newThread(const std::function& func) { lockMutex(m_threadMutex); // create thread impl for new thread ArchThreadImpl* thread = new ArchThreadImpl; - thread->m_func = func; - thread->m_userData = data; + thread->func_ = func; // create thread unsigned int id = 0; @@ -523,15 +516,6 @@ ArchMultithreadWindows::isExitedThread(ArchThread thread) return (WaitForSingleObject(thread->m_exit, 0) == WAIT_OBJECT_0); } -void* -ArchMultithreadWindows::getResultOfThread(ArchThread thread) -{ - lockMutex(m_threadMutex); - void* result = thread->m_result; - unlockMutex(m_threadMutex); - return result; -} - IArchMultithread::ThreadID ArchMultithreadWindows::getIDOfThread(ArchThread thread) { @@ -678,10 +662,8 @@ ArchMultithreadWindows::doThreadFunc(ArchThread thread) lockMutex(m_threadMutex); unlockMutex(m_threadMutex); - void* result = NULL; try { - // go - result = (*thread->m_func)(thread->m_userData); + thread->func_(); } catch (XThreadCancel&) { @@ -695,9 +677,6 @@ ArchMultithreadWindows::doThreadFunc(ArchThread thread) } // thread has exited - lockMutex(m_threadMutex); - thread->m_result = result; - unlockMutex(m_threadMutex); SetEvent(thread->m_exit); // done with thread diff --git a/src/lib/arch/win32/ArchMultithreadWindows.h b/src/lib/arch/win32/ArchMultithreadWindows.h index 99aa640..31a2b30 100644 --- a/src/lib/arch/win32/ArchMultithreadWindows.h +++ b/src/lib/arch/win32/ArchMultithreadWindows.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -73,7 +73,7 @@ public: virtual void closeMutex(ArchMutex); virtual void lockMutex(ArchMutex); virtual void unlockMutex(ArchMutex); - virtual ArchThread newThread(ThreadFunc, void*); + virtual ArchThread newThread(const std::function& func); virtual ArchThread newCurrentThread(); virtual ArchThread copyThread(ArchThread); virtual void closeThread(ArchThread); @@ -83,7 +83,6 @@ public: virtual bool wait(ArchThread, double timeout); virtual bool isSameThread(ArchThread, ArchThread); virtual bool isExitedThread(ArchThread); - virtual void* getResultOfThread(ArchThread); virtual ThreadID getIDOfThread(ArchThread); virtual void setSignalHandler(ESignal, SignalFunc, void*); virtual void raiseSignal(ESignal); diff --git a/src/lib/arch/win32/ArchNetworkWinsock.cpp b/src/lib/arch/win32/ArchNetworkWinsock.cpp index 4bc61d8..2d444fd 100644 --- a/src/lib/arch/win32/ArchNetworkWinsock.cpp +++ b/src/lib/arch/win32/ArchNetworkWinsock.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/win32/ArchNetworkWinsock.h b/src/lib/arch/win32/ArchNetworkWinsock.h index 0b01671..7f65795 100644 --- a/src/lib/arch/win32/ArchNetworkWinsock.h +++ b/src/lib/arch/win32/ArchNetworkWinsock.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/win32/ArchSleepWindows.cpp b/src/lib/arch/win32/ArchSleepWindows.cpp index 69648a7..0395031 100644 --- a/src/lib/arch/win32/ArchSleepWindows.cpp +++ b/src/lib/arch/win32/ArchSleepWindows.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -57,5 +57,5 @@ ArchSleepWindows::sleep(double timeout) else { Sleep((DWORD)(1000.0 * timeout)); } - ARCH->testCancelThread(); + ARCH->testCancelThread(); } diff --git a/src/lib/arch/win32/ArchSleepWindows.h b/src/lib/arch/win32/ArchSleepWindows.h index d673caf..da89cea 100644 --- a/src/lib/arch/win32/ArchSleepWindows.h +++ b/src/lib/arch/win32/ArchSleepWindows.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/win32/ArchStringWindows.cpp b/src/lib/arch/win32/ArchStringWindows.cpp index deaf536..0033659 100644 --- a/src/lib/arch/win32/ArchStringWindows.cpp +++ b/src/lib/arch/win32/ArchStringWindows.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -26,11 +26,6 @@ // ArchStringWindows // -#include "arch/multibyte.h" -#define HAVE_VSNPRINTF 1 -#define ARCH_VSNPRINTF _vsnprintf -#include "arch/vsnprintf.h" - ArchStringWindows::ArchStringWindows() { } diff --git a/src/lib/arch/win32/ArchStringWindows.h b/src/lib/arch/win32/ArchStringWindows.h index 23812dc..b2869b4 100644 --- a/src/lib/arch/win32/ArchStringWindows.h +++ b/src/lib/arch/win32/ArchStringWindows.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/win32/ArchSystemWindows.cpp b/src/lib/arch/win32/ArchSystemWindows.cpp index cf3b066..badcf28 100644 --- a/src/lib/arch/win32/ArchSystemWindows.cpp +++ b/src/lib/arch/win32/ArchSystemWindows.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/win32/ArchSystemWindows.h b/src/lib/arch/win32/ArchSystemWindows.h index 3d45ee6..835560d 100644 --- a/src/lib/arch/win32/ArchSystemWindows.h +++ b/src/lib/arch/win32/ArchSystemWindows.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/win32/ArchTaskBarWindows.cpp b/src/lib/arch/win32/ArchTaskBarWindows.cpp index 731dc59..bf71b74 100644 --- a/src/lib/arch/win32/ArchTaskBarWindows.cpp +++ b/src/lib/arch/win32/ArchTaskBarWindows.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 @@ -88,7 +88,7 @@ ArchTaskBarWindows::init() // create a window on the current desktop with the current // thread then the current thread won't be able to switch // desktops if it needs to. - m_thread = ARCH->newThread(&ArchTaskBarWindows::threadEntry, this); + m_thread = ARCH->newThread([this]() { threadMainLoop(); }); // wait for child thread while (!m_ready) { @@ -501,14 +501,7 @@ ArchTaskBarWindows::threadMainLoop() UnregisterClass(className, instanceWin32()); } -void* -ArchTaskBarWindows::threadEntry(void* self) -{ - static_cast(self)->threadMainLoop(); - return NULL; -} - HINSTANCE ArchTaskBarWindows::instanceWin32() { return ArchMiscWindows::instanceWin32(); -} \ No newline at end of file +} diff --git a/src/lib/arch/win32/ArchTaskBarWindows.h b/src/lib/arch/win32/ArchTaskBarWindows.h index 0edddf8..2b8b7ad 100644 --- a/src/lib/arch/win32/ArchTaskBarWindows.h +++ b/src/lib/arch/win32/ArchTaskBarWindows.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 @@ -36,7 +36,7 @@ public: virtual void init(); - //! Add a dialog window + //! Add a dialog window /*! Tell the task bar event loop about a dialog. Win32 annoyingly requires messages destined for modeless dialog boxes to be @@ -84,7 +84,6 @@ private: static LRESULT CALLBACK staticWndProc(HWND, UINT, WPARAM, LPARAM); void threadMainLoop(); - static void* threadEntry(void*); HINSTANCE instanceWin32(); diff --git a/src/lib/arch/win32/ArchTimeWindows.cpp b/src/lib/arch/win32/ArchTimeWindows.cpp index 568a483..eae0c15 100644 --- a/src/lib/arch/win32/ArchTimeWindows.cpp +++ b/src/lib/arch/win32/ArchTimeWindows.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/win32/ArchTimeWindows.h b/src/lib/arch/win32/ArchTimeWindows.h index 42351a1..c695e79 100644 --- a/src/lib/arch/win32/ArchTimeWindows.h +++ b/src/lib/arch/win32/ArchTimeWindows.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/arch/win32/XArchWindows.cpp b/src/lib/arch/win32/XArchWindows.cpp index e116eda..eb3c151 100644 --- a/src/lib/arch/win32/XArchWindows.cpp +++ b/src/lib/arch/win32/XArchWindows.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -57,58 +57,58 @@ XArchEvalWinsock::eval() const noexcept // may not look up network error messages correctly. we'll have // to do it ourself. static const struct { int m_code; const char* m_msg; } s_netErrorCodes[] = { - /* 10004 */{WSAEINTR, "The (blocking) call was canceled via WSACancelBlockingCall"}, - /* 10009 */{WSAEBADF, "Bad file handle"}, - /* 10013 */{WSAEACCES, "The requested address is a broadcast address, but the appropriate flag was not set"}, - /* 10014 */{WSAEFAULT, "WSAEFAULT"}, - /* 10022 */{WSAEINVAL, "WSAEINVAL"}, - /* 10024 */{WSAEMFILE, "No more file descriptors available"}, - /* 10035 */{WSAEWOULDBLOCK, "Socket is marked as non-blocking and no connections are present or the receive operation would block"}, - /* 10036 */{WSAEINPROGRESS, "A blocking Windows Sockets operation is in progress"}, + /* 10004 */{WSAEINTR, "The (blocking) call was canceled via WSACancelBlockingCall"}, + /* 10009 */{WSAEBADF, "Bad file handle"}, + /* 10013 */{WSAEACCES, "The requested address is a broadcast address, but the appropriate flag was not set"}, + /* 10014 */{WSAEFAULT, "WSAEFAULT"}, + /* 10022 */{WSAEINVAL, "WSAEINVAL"}, + /* 10024 */{WSAEMFILE, "No more file descriptors available"}, + /* 10035 */{WSAEWOULDBLOCK, "Socket is marked as non-blocking and no connections are present or the receive operation would block"}, + /* 10036 */{WSAEINPROGRESS, "A blocking Windows Sockets operation is in progress"}, /* 10037 */{WSAEALREADY, "The asynchronous routine being canceled has already completed"}, /* 10038 */{WSAENOTSOCK, "At least on descriptor is not a socket"}, /* 10039 */{WSAEDESTADDRREQ, "A destination address is required"}, /* 10040 */{WSAEMSGSIZE, "The datagram was too large to fit into the specified buffer and was truncated"}, - /* 10041 */{WSAEPROTOTYPE, "The specified protocol is the wrong type for this socket"}, - /* 10042 */{WSAENOPROTOOPT, "The option is unknown or unsupported"}, - /* 10043 */{WSAEPROTONOSUPPORT,"The specified protocol is not supported"}, - /* 10044 */{WSAESOCKTNOSUPPORT,"The specified socket type is not supported by this address family"}, - /* 10045 */{WSAEOPNOTSUPP, "The referenced socket is not a type that supports that operation"}, + /* 10041 */{WSAEPROTOTYPE, "The specified protocol is the wrong type for this socket"}, + /* 10042 */{WSAENOPROTOOPT, "The option is unknown or unsupported"}, + /* 10043 */{WSAEPROTONOSUPPORT, "The specified protocol is not supported"}, + /* 10044 */{WSAESOCKTNOSUPPORT, "The specified socket type is not supported by this address family"}, + /* 10045 */{WSAEOPNOTSUPP, "The referenced socket is not a type that supports that operation"}, /* 10046 */{WSAEPFNOSUPPORT, "BSD: Protocol family not supported"}, /* 10047 */{WSAEAFNOSUPPORT, "The specified address family is not supported"}, - /* 10048 */{WSAEADDRINUSE, "The specified address is already in use"}, - /* 10049 */{WSAEADDRNOTAVAIL, "The specified address is not available from the local machine"}, + /* 10048 */{WSAEADDRINUSE, "The specified address is already in use"}, + /* 10049 */{WSAEADDRNOTAVAIL, "The specified address is not available from the local machine"}, /* 10050 */{WSAENETDOWN, "The Windows Sockets implementation has detected that the network subsystem has failed"}, - /* 10051 */{WSAENETUNREACH, "The network can't be reached from this host at this time"}, - /* 10052 */{WSAENETRESET, "The connection must be reset because the Windows Sockets implementation dropped it"}, + /* 10051 */{WSAENETUNREACH, "The network can't be reached from this host at this time"}, + /* 10052 */{WSAENETRESET, "The connection must be reset because the Windows Sockets implementation dropped it"}, /* 10053 */{WSAECONNABORTED, "The virtual circuit was aborted due to timeout or other failure"}, - /* 10054 */{WSAECONNRESET, "The virtual circuit was reset by the remote side"}, - /* 10055 */{WSAENOBUFS, "No buffer space is available or a buffer deadlock has occured. The socket cannot be created"}, - /* 10056 */{WSAEISCONN, "The socket is already connected"}, + /* 10054 */{WSAECONNRESET, "The virtual circuit was reset by the remote side"}, + /* 10055 */{WSAENOBUFS, "No buffer space is available or a buffer deadlock has occurred. The socket cannot be created"}, + /* 10056 */{WSAEISCONN, "The socket is already connected"}, /* 10057 */{WSAENOTCONN, "The socket is not connected"}, - /* 10058 */{WSAESHUTDOWN, "The socket has been shutdown"}, + /* 10058 */{WSAESHUTDOWN, "The socket has been shutdown"}, /* 10059 */{WSAETOOMANYREFS, "BSD: Too many references"}, - /* 10060 */{WSAETIMEDOUT, "Attempt to connect timed out without establishing a connection"}, + /* 10060 */{WSAETIMEDOUT, "Attempt to connect timed out without establishing a connection"}, /* 10061 */{WSAECONNREFUSED, "Connection was refused"}, - /* 10062 */{WSAELOOP, "Undocumented WinSock error code used in BSD"}, + /* 10062 */{WSAELOOP, "Undocumented WinSock error code used in BSD"}, /* 10063 */{WSAENAMETOOLONG, "Undocumented WinSock error code used in BSD"}, - /* 10064 */{WSAEHOSTDOWN, "Undocumented WinSock error code used in BSD"}, + /* 10064 */{WSAEHOSTDOWN, "Undocumented WinSock error code used in BSD"}, /* 10065 */{WSAEHOSTUNREACH, "No route to host"}, - /* 10066 */{WSAENOTEMPTY, "Undocumented WinSock error code"}, + /* 10066 */{WSAENOTEMPTY, "Undocumented WinSock error code"}, /* 10067 */{WSAEPROCLIM, "Undocumented WinSock error code"}, - /* 10068 */{WSAEUSERS, "Undocumented WinSock error code"}, - /* 10069 */{WSAEDQUOT, "Undocumented WinSock error code"}, - /* 10070 */{WSAESTALE, "Undocumented WinSock error code"}, - /* 10071 */{WSAEREMOTE, "Undocumented WinSock error code"}, - /* 10091 */{WSASYSNOTREADY, "Underlying network subsytem is not ready for network communication"}, - /* 10092 */{WSAVERNOTSUPPORTED, "The version of WinSock API support requested is not provided in this implementation"}, - /* 10093 */{WSANOTINITIALISED, "WinSock subsystem not properly initialized"}, - /* 10101 */{WSAEDISCON, "Virtual circuit has gracefully terminated connection"}, - /* 11001 */{WSAHOST_NOT_FOUND, "The specified host is unknown"}, - /* 11002 */{WSATRY_AGAIN, "A temporary error occurred on an authoritative name server"}, - /* 11003 */{WSANO_RECOVERY, "A non-recoverable name server error occurred"}, - /* 11004 */{WSANO_DATA, "The requested name is valid but does not have an IP address"}, - /* end */{0, NULL} + /* 10068 */{WSAEUSERS, "Undocumented WinSock error code"}, + /* 10069 */{WSAEDQUOT, "Undocumented WinSock error code"}, + /* 10070 */{WSAESTALE, "Undocumented WinSock error code"}, + /* 10071 */{WSAEREMOTE, "Undocumented WinSock error code"}, + /* 10091 */{WSASYSNOTREADY, "Underlying network subsystem is not ready for network communication"}, + /* 10092 */{WSAVERNOTSUPPORTED, "The version of WinSock API support requested is not provided in this implementation"}, + /* 10093 */{WSANOTINITIALISED, "WinSock subsystem not properly initialized"}, + /* 10101 */{WSAEDISCON, "Virtual circuit has gracefully terminated connection"}, + /* 11001 */{WSAHOST_NOT_FOUND, "The specified host is unknown"}, + /* 11002 */{WSATRY_AGAIN, "A temporary error occurred on an authoritative name server"}, + /* 11003 */{WSANO_RECOVERY, "A non-recoverable name server error occurred"}, + /* 11004 */{WSANO_DATA, "The requested name is valid but does not have an IP address"}, + /* end */{0, NULL} }; for (unsigned int i = 0; s_netErrorCodes[i].m_code != 0; ++i) { diff --git a/src/lib/arch/win32/XArchWindows.h b/src/lib/arch/win32/XArchWindows.h index 4fb2a23..5ac71f2 100644 --- a/src/lib/arch/win32/XArchWindows.h +++ b/src/lib/arch/win32/XArchWindows.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/App.cpp b/src/lib/barrier/App.cpp index 8a79aa2..2b3eccc 100644 --- a/src/lib/barrier/App.cpp +++ b/src/lib/barrier/App.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -34,7 +34,6 @@ #if SYSAPI_WIN32 #include "base/IEventQueue.h" -#include "base/TMethodJob.h" #endif #include @@ -79,18 +78,18 @@ App::~App() void App::version() { - std::cout << argsBase().m_exename << " " << kVersion << std::endl; - std::cout <<"Protocol version " << kProtocolMajorVersion << "." << kProtocolMinorVersion << std::endl; - std::cout << kCopyright << std::endl; + std::cout << argsBase().m_exename << " " << kVersion << "\n"; + std::cout <<"Protocol version " << kProtocolMajorVersion << "." << kProtocolMinorVersion << "\n"; + std::cout << kCopyright << "\n"; } int App::run(int argc, char** argv) -{ +{ #if MAC_OS_X_VERSION_10_7 // dock hide only supported on lion :( ProcessSerialNumber psn = { 0, kCurrentProcess }; - + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" GetCurrentProcess(&psn); @@ -101,7 +100,7 @@ App::run(int argc, char** argv) // install application in to arch appUtil().adoptApp(this); - + // HACK: fail by default (saves us setting result in each catch) int result = kExitFailed; @@ -110,7 +109,7 @@ App::run(int argc, char** argv) } catch (XExitApp& e) { // instead of showing a nasty error, just exit with the error code. - // not sure if i like this behaviour, but it's probably better than + // not sure if i like this behaviour, but it's probably better than // using the exit(int) function! result = e.getCode(); } @@ -122,7 +121,7 @@ App::run(int argc, char** argv) } appUtil().beforeAppExit(); - + return result; } @@ -137,7 +136,7 @@ App::daemonMainLoop(int, const char**) return mainLoop(); } -void +void App::setupFileLogging() { if (argsBase().m_logFile != NULL) { @@ -147,24 +146,24 @@ App::setupFileLogging() } } -void +void App::loggingFilterWarning() { if (CLOG->getFilter() > CLOG->getConsoleMaxLevel()) { if (argsBase().m_logFile == NULL) { - LOG((CLOG_WARN "log messages above %s are NOT sent to console (use file logging)", + LOG((CLOG_WARN "log messages above %s are NOT sent to console (use file logging)", CLOG->getFilterName(CLOG->getConsoleMaxLevel()))); } } } -void +void App::initApp(int argc, const char** argv) { // parse command line parseArgs(argc, argv); - - DataDirectories::profile(argsBase().m_profileDirectory); + + barrier::DataDirectories::profile(argsBase().m_profileDirectory); // set log filter if (!CLOG->setFilter(argsBase().m_logFilter)) { @@ -173,9 +172,12 @@ App::initApp(int argc, const char** argv) m_bye(kExitArgs); } loggingFilterWarning(); - + if (argsBase().m_enableDragDrop) { LOG((CLOG_INFO "drag and drop enabled")); + if (!argsBase().m_dropTarget.empty()) { + LOG((CLOG_INFO "drop target: %s", argsBase().m_dropTarget.c_str())); + } } // setup file logging after parsing args @@ -226,15 +228,14 @@ App::handleIpcMessage(const Event& e, void*) } } -void -App::runEventsLoop(void*) +void App::run_events_loop() { m_events->loop(); - + #if defined(MAC_OS_X_VERSION_10_7) - + stopCocoaLoop(); - + #endif } diff --git a/src/lib/barrier/App.h b/src/lib/barrier/App.h index 8040da8..8e17a71 100644 --- a/src/lib/barrier/App.h +++ b/src/lib/barrier/App.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -59,7 +59,7 @@ public: // Parse command line arguments. virtual void parseArgs(int argc, const char* const* argv) = 0; - + int run(int argc, char** argv); int daemonMainLoop(int, const char**); @@ -90,11 +90,11 @@ public: ARCH_APP_UTIL& appUtil() { return m_appUtil; } - virtual IArchTaskBarReceiver* taskBarReceiver() const { return m_taskBarReceiver; } + virtual IArchTaskBarReceiver* taskBarReceiver() const { return m_taskBarReceiver; } virtual void setByeFunc(void(*bye)(int)) { m_bye = bye; } virtual void bye(int error) { m_bye(error); } - + virtual IEventQueue* getEvents() const { return m_events; } void setSocketMultiplexer(std::unique_ptr&& sm) { m_socketMultiplexer = std::move(sm); } @@ -108,7 +108,7 @@ private: protected: void initIpcClient(); void cleanupIpcClient(); - void runEventsLoop(void*); + void run_events_loop(); IArchTaskBarReceiver* m_taskBarReceiver; bool m_suspended; @@ -135,7 +135,7 @@ public: virtual void startNode(); virtual int mainLoop(); virtual int foregroundStartup(int argc, char** argv); - virtual barrier::Screen* + virtual barrier::Screen* createScreen(); virtual void loadConfig(); virtual bool loadConfig(const String& pathname); @@ -166,7 +166,10 @@ private: " -l --log write log messages to file.\n" \ " --no-tray disable the system tray icon.\n" \ " --enable-drag-drop enable file drag & drop.\n" \ - " --enable-crypto enable the crypto (ssl) plugin.\n" + " --enable-crypto enable the crypto (ssl) plugin (default, deprecated).\n" \ + " --disable-crypto disable the crypto (ssl) plugin.\n" \ + " --profile-dir use named profile directory instead.\n" \ + " --drop-dir use named drop target directory instead.\n" #define HELP_COMMON_INFO_2 \ " -h, --help display this help and exit.\n" \ @@ -191,12 +194,11 @@ private: // windows args # define HELP_SYS_ARGS \ - " [--service ] [--relaunch] [--exit-pause]" + " [--exit-pause]" # define HELP_SYS_INFO \ " --service manage the windows service, valid options are:\n" \ " install/uninstall/start/stop\n" \ - " --relaunch persistently relaunches process in current user \n" \ - " session (useful for vista and upward).\n" \ + " (obsolete, use barrierd instead)\n" \ " --exit-pause wait for key press on exit, can be useful for\n" \ " reading error messages that occur on exit.\n" #endif diff --git a/src/lib/barrier/AppUtil.cpp b/src/lib/barrier/AppUtil.cpp index 3298d7b..d615648 100644 --- a/src/lib/barrier/AppUtil.cpp +++ b/src/lib/barrier/AppUtil.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -15,11 +15,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + #include "barrier/AppUtil.h" AppUtil* AppUtil::s_instance = nullptr; - + AppUtil::AppUtil() : m_app(nullptr) { diff --git a/src/lib/barrier/AppUtil.h b/src/lib/barrier/AppUtil.h index 6f5f073..097c7f2 100644 --- a/src/lib/barrier/AppUtil.h +++ b/src/lib/barrier/AppUtil.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + #pragma once #include "barrier/IAppUtil.h" @@ -33,7 +33,7 @@ public: static AppUtil& instance(); static void exitAppStatic(int code) { instance().exitApp(code); } virtual void beforeAppExit() {} - + private: IApp* m_app; static AppUtil* s_instance; diff --git a/src/lib/barrier/ArgParser.cpp b/src/lib/barrier/ArgParser.cpp index ec3991c..99cd803 100644 --- a/src/lib/barrier/ArgParser.cpp +++ b/src/lib/barrier/ArgParser.cpp @@ -24,7 +24,7 @@ #include "barrier/ArgsBase.h" #include "base/Log.h" #include "base/String.h" -#include "common/PathUtilities.h" +#include "io/filesystem.h" #ifdef WINAPI_MSWINDOWS #include @@ -65,7 +65,9 @@ ArgParser::parseServerArgs(ServerArgs& args, int argc, const char* const* argv) // save screen change script path args.m_screenChangeScript = argv[++i]; } - else { + else if (isArg(i, argc, argv, nullptr, "--disable-client-cert-checking")) { + args.check_client_certificates = false; + } else { LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_exename.c_str(), argv[i], args.m_exename.c_str())); return false; } @@ -133,10 +135,10 @@ ArgParser::parseClientArgs(ClientArgs& args, int argc, const char* const* argv) return true; } +#if WINAPI_MSWINDOWS bool -ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i) +ArgParser::parseMSWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i) { -#if WINAPI_MSWINDOWS if (isArg(i, argc, argv, NULL, "--service")) { LOG((CLOG_WARN "obsolete argument --service, use barrierd instead.")); argsBase.m_shouldExit = true; @@ -153,25 +155,46 @@ ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* con } return true; -#elif WINAPI_XWINDOWS +} +#endif + +#if WINAPI_CARBON +bool +ArgParser::parseCarbonArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i) +{ + // no options for carbon + return false; +} +#endif + +#if WINAPI_XWINDOWS +bool +ArgParser::parseXWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i) +{ if (isArg(i, argc, argv, "-display", "--display", 1)) { // use alternative display argsBase.m_display = argv[++i]; } - else if (isArg(i, argc, argv, NULL, "--no-xinitthreads")) { argsBase.m_disableXInitThreads = true; - } - - else { + } else { // option not supported here return false; } return true; +} +#endif + +bool +ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i) +{ +#if WINAPI_MSWINDOWS + return parseMSWindowsArg(argsBase, argc, argv, i); #elif WINAPI_CARBON - // no options for carbon - return false; + return parseCarbonArg(argsBase, argc, argv, i); +#elif WINAPI_XWINDOWS + return parseXWindowsArg(argsBase, argc, argv, i); #endif } @@ -257,14 +280,20 @@ ArgParser::parseGenericArgs(int argc, const char* const* argv, int& i) argsBase().m_enableDragDrop = true; } } + else if (isArg(i, argc, argv, NULL, "--drop-dir")) { + argsBase().m_dropTarget = argv[++i]; + } else if (isArg(i, argc, argv, NULL, "--enable-crypto")) { - argsBase().m_enableCrypto = true; + LOG((CLOG_INFO "--enable-crypto is used by default. The option is deprecated.")); + } + else if (isArg(i, argc, argv, NULL, "--disable-crypto")) { + argsBase().m_enableCrypto = false; } else if (isArg(i, argc, argv, NULL, "--profile-dir", 1)) { - argsBase().m_profileDirectory = argv[++i]; + argsBase().m_profileDirectory = barrier::fs::u8path(argv[++i]); } else if (isArg(i, argc, argv, NULL, "--plugin-dir", 1)) { - argsBase().m_pluginDirectory = argv[++i]; + argsBase().m_pluginDirectory = barrier::fs::u8path(argv[++i]); } else { // option not supported here @@ -349,7 +378,7 @@ ArgParser::splitCommandString(String& command, std::vector& argv) if (space > leftDoubleQuote && space < rightDoubleQuote) { ignoreThisSpace = true; } - else if (space > rightDoubleQuote){ + else if (space > rightDoubleQuote) { searchDoubleQuotes(command, leftDoubleQuote, rightDoubleQuote, rightDoubleQuote + 1); } @@ -460,7 +489,13 @@ void ArgParser::updateCommonArgs(const char* const* argv) { argsBase().m_name = ARCH->getHostName(); - argsBase().m_exename = PathUtilities::basename(argv[0]); + argsBase().m_exename = parse_exename(argv[0]); +} + +std::string ArgParser::parse_exename(const char* arg) +{ + // FIXME: we assume UTF-8 encoding, but on Windows this is not correct + return barrier::fs::u8path(arg).filename().u8string(); } bool diff --git a/src/lib/barrier/ArgParser.h b/src/lib/barrier/ArgParser.h index 32300c6..472d93a 100644 --- a/src/lib/barrier/ArgParser.h +++ b/src/lib/barrier/ArgParser.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-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 @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + #pragma once #include "base/String.h" @@ -41,21 +41,27 @@ public: const char* name1, const char* name2, int minRequiredParameters = 0); static void splitCommandString(String& command, std::vector& argv); - static bool searchDoubleQuotes(String& command, size_t& left, + static bool searchDoubleQuotes(String& command, size_t& left, size_t& right, size_t startPos = 0); static void removeDoubleQuotes(String& arg); static const char** getArgv(std::vector& argsArray); - static String assembleCommand(std::vector& argsArray, + static String assembleCommand(std::vector& argsArray, String ignoreArg = "", int parametersRequired = 0); + static std::string parse_exename(const char* arg); + private: void updateCommonArgs(const char* const* argv); bool checkUnexpectedArgs(); - + static ArgsBase& argsBase() { return *m_argsBase; } + bool parseMSWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i); + bool parseCarbonArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i); + bool parseXWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i); + private: App* m_app; - + static ArgsBase* m_argsBase; }; diff --git a/src/lib/barrier/ArgsBase.cpp b/src/lib/barrier/ArgsBase.cpp index eb63150..e3e3803 100644 --- a/src/lib/barrier/ArgsBase.cpp +++ b/src/lib/barrier/ArgsBase.cpp @@ -2,11 +2,11 @@ * barrier -- 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 @@ -39,10 +39,11 @@ m_display(NULL), m_disableTray(false), m_enableIpc(false), m_enableDragDrop(false), +m_dropTarget(""), m_shouldExit(false), m_barrierAddress(), -m_enableCrypto(false), -m_profileDirectory(""), + m_enableCrypto(true), +m_profileDirectory(), m_pluginDirectory("") { } diff --git a/src/lib/barrier/ArgsBase.h b/src/lib/barrier/ArgsBase.h index 99929b3..cdb5092 100644 --- a/src/lib/barrier/ArgsBase.h +++ b/src/lib/barrier/ArgsBase.h @@ -2,11 +2,11 @@ * barrier -- 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 @@ -19,6 +19,7 @@ #pragma once #include "base/String.h" +#include "io/filesystem.h" class ArgsBase { public: @@ -38,6 +39,7 @@ public: bool m_disableTray; bool m_enableIpc; bool m_enableDragDrop; + String m_dropTarget; #if SYSAPI_WIN32 bool m_debugServiceWait; bool m_pauseOnExit; @@ -49,6 +51,6 @@ public: bool m_shouldExit; String m_barrierAddress; bool m_enableCrypto; - String m_profileDirectory; - String m_pluginDirectory; + barrier::fs::path m_profileDirectory; + barrier::fs::path m_pluginDirectory; }; diff --git a/src/lib/barrier/BarrierType.h b/src/lib/barrier/BarrierType.h new file mode 100644 index 0000000..0a18477 --- /dev/null +++ b/src/lib/barrier/BarrierType.h @@ -0,0 +1,26 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 BARRIER_LIB_BARRIER_BARRIER_TYPE_H +#define BARRIER_LIB_BARRIER_BARRIER_TYPE_H + +enum class BarrierType { + Server, + Client +}; + +#endif // BARRIER_LIB_BARRIER_BARRIER_TYPE_H diff --git a/src/lib/barrier/CMakeLists.txt b/src/lib/barrier/CMakeLists.txt index 6978aef..b60936d 100644 --- a/src/lib/barrier/CMakeLists.txt +++ b/src/lib/barrier/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 diff --git a/src/lib/barrier/Chunk.cpp b/src/lib/barrier/Chunk.cpp index f11bff5..fd69cdb 100644 --- a/src/lib/barrier/Chunk.cpp +++ b/src/lib/barrier/Chunk.cpp @@ -1,11 +1,11 @@ /* * barrier -- 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 diff --git a/src/lib/barrier/Chunk.h b/src/lib/barrier/Chunk.h index 42b85bf..26a343d 100644 --- a/src/lib/barrier/Chunk.h +++ b/src/lib/barrier/Chunk.h @@ -1,11 +1,11 @@ /* * barrier -- 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 @@ -17,7 +17,7 @@ #pragma once -#include "common/basic_types.h" +#include class Chunk { public: diff --git a/src/lib/barrier/ClientApp.cpp b/src/lib/barrier/ClientApp.cpp index b1a7661..4b0ef61 100644 --- a/src/lib/barrier/ClientApp.cpp +++ b/src/lib/barrier/ClientApp.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -37,10 +37,8 @@ #include "base/TMethodEventJob.h" #include "base/log_outputters.h" #include "base/EventQueue.h" -#include "base/TMethodJob.h" #include "base/Log.h" #include "common/Version.h" -#include "common/PathUtilities.h" #if WINAPI_MSWINDOWS #include "platform/MSWindowsScreen.h" @@ -118,23 +116,23 @@ ClientApp::help() #endif std::ostringstream buffer; - buffer << "Start the barrier client and connect to a remote server component." << std::endl - << std::endl + buffer << "Start the barrier client and connect to a remote server component.\n" + << "\n" << "Usage: " << args().m_exename << " [--yscroll ]" << WINAPI_ARG << HELP_SYS_ARGS - << HELP_COMMON_ARGS << " " << std::endl - << std::endl - << "Options:" << std::endl + << HELP_COMMON_ARGS << " \n" + << "\n" + << "Options:\n" << HELP_COMMON_INFO_1 << WINAPI_INFO << HELP_SYS_INFO - << " --yscroll defines the vertical scrolling delta, which is" << std::endl - << " 120 by default." << std::endl + << " --yscroll defines the vertical scrolling delta, which is\n" + << " 120 by default.\n" << HELP_COMMON_INFO_2 - << std::endl - << "Default options are marked with a *" << std::endl - << std::endl - << "The server address is of the form: [][:]. The hostname" << std::endl - << "must be the address or hostname of the server. Placing brackets around" << std::endl - << "an IPv6 address is required when also specifying a port number and " << std::endl - << "optional otherwise. The default port number is " << kDefaultPort << "." << std::endl; + << "\n" + << "Default options are marked with a *\n" + << "\n" + << "The server address is of the form: [][:]. The hostname\n" + << "must be the address or hostname of the server. Placing brackets around\n" + << "an IPv6 address is required when also specifying a port number and \n" + << "optional otherwise. The default port number is " << kDefaultPort << ".\n"; LOG((CLOG_PRINT "%s", buffer.str().c_str())); } @@ -235,6 +233,9 @@ barrier::Screen* ClientApp::openClientScreen() { barrier::Screen* screen = createScreen(); + if (!argsBase().m_dropTarget.empty()) { + screen->setDropTarget(argsBase().m_dropTarget); + } screen->setEnableDragDrop(argsBase().m_enableDragDrop); m_events->adoptHandler(m_events->forIScreen().error(), screen->getEventTarget(), @@ -449,7 +450,7 @@ ClientApp::mainLoop() // start client, etc appUtil().startNode(); - + // init ipc client after node start, since create a new screen wipes out // the event queue (the screen ctors call adoptBuffer). if (argsBase().m_enableIpc) { @@ -460,24 +461,21 @@ ClientApp::mainLoop() // later. the timer installed by startClient() will take care of // that. DAEMON_RUNNING(true); - + #if defined(MAC_OS_X_VERSION_10_7) - - Thread thread( - new TMethodJob( - this, &ClientApp::runEventsLoop, - NULL)); - + + Thread thread([this](){ run_events_loop(); }); + // wait until carbon loop is ready OSXScreen* screen = dynamic_cast( m_clientScreen->getPlatformScreen()); screen->waitForCarbonLoop(); - + runCocoaApp(); #else m_events->loop(); #endif - + DAEMON_RUNNING(false); // close down @@ -519,7 +517,7 @@ ClientApp::runInner(int argc, char** argv, ILogOutputter* outputter, StartupFunc { // general initialization m_serverAddress = new NetworkAddress; - args().m_exename = PathUtilities::basename(argv[0]); + argsBase().m_exename = ArgParser::parse_exename(argv[0]); // install caller's output filter if (outputter != NULL) { @@ -548,7 +546,7 @@ ClientApp::runInner(int argc, char** argv, ILogOutputter* outputter, StartupFunc return result; } -void +void ClientApp::startNode() { // start the client. if this return false then we've failed and diff --git a/src/lib/barrier/ClientApp.h b/src/lib/barrier/ClientApp.h index 777f3d3..d1db8d0 100644 --- a/src/lib/barrier/ClientApp.h +++ b/src/lib/barrier/ClientApp.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -24,7 +24,6 @@ namespace barrier { class Screen; } class Event; class Client; class NetworkAddress; -class Thread; class ClientArgs; class ClientApp : public App { @@ -64,7 +63,7 @@ public: void handleClientConnected(const Event&, void*); void handleClientFailed(const Event& e, void*); void handleClientDisconnected(const Event&, void*); - Client* openClient(const String& name, const NetworkAddress& address, + Client* openClient(const String& name, const NetworkAddress& address, barrier::Screen* screen); void closeClient(Client* client); bool startClient(); diff --git a/src/lib/barrier/ClientArgs.cpp b/src/lib/barrier/ClientArgs.cpp index 5c9ed88..9d1d37a 100644 --- a/src/lib/barrier/ClientArgs.cpp +++ b/src/lib/barrier/ClientArgs.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-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 diff --git a/src/lib/barrier/ClientArgs.h b/src/lib/barrier/ClientArgs.h index 70285fa..c11fa28 100644 --- a/src/lib/barrier/ClientArgs.h +++ b/src/lib/barrier/ClientArgs.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-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 diff --git a/src/lib/barrier/ClientTaskBarReceiver.cpp b/src/lib/barrier/ClientTaskBarReceiver.cpp index 2ea6566..ea29f3d 100644 --- a/src/lib/barrier/ClientTaskBarReceiver.cpp +++ b/src/lib/barrier/ClientTaskBarReceiver.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/ClientTaskBarReceiver.h b/src/lib/barrier/ClientTaskBarReceiver.h index da15154..b79b958 100644 --- a/src/lib/barrier/ClientTaskBarReceiver.h +++ b/src/lib/barrier/ClientTaskBarReceiver.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/Clipboard.cpp b/src/lib/barrier/Clipboard.cpp index a6a166d..d7ad0b8 100644 --- a/src/lib/barrier/Clipboard.cpp +++ b/src/lib/barrier/Clipboard.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/Clipboard.h b/src/lib/barrier/Clipboard.h index 23bea75..5365a8c 100644 --- a/src/lib/barrier/Clipboard.h +++ b/src/lib/barrier/Clipboard.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/ClipboardChunk.cpp b/src/lib/barrier/ClipboardChunk.cpp index bc71471..c2ffab0 100644 --- a/src/lib/barrier/ClipboardChunk.cpp +++ b/src/lib/barrier/ClipboardChunk.cpp @@ -1,11 +1,11 @@ /* * barrier -- 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 @@ -74,7 +74,7 @@ ClipboardChunk::end(ClipboardID id, UInt32 sequence) { ClipboardChunk* end = new ClipboardChunk(CLIPBOARD_CHUNK_META_SIZE); char* chunk = end->m_chunk; - + chunk[0] = id; std::memcpy (&chunk[1], &sequence, 4); chunk[5] = kDataEnd; @@ -95,7 +95,7 @@ ClipboardChunk::assemble(barrier::IStream* stream, if (!ProtocolUtil::readf(stream, kMsgDClipboard + 4, &id, &sequence, &mark, &data)) { return kError; } - + if (mark == kDataStart) { s_expectedSize = barrier::string::stringToSizeType(data); LOG((CLOG_DEBUG "start receiving clipboard data")); diff --git a/src/lib/barrier/ClipboardChunk.h b/src/lib/barrier/ClipboardChunk.h index 6402aca..a96877f 100644 --- a/src/lib/barrier/ClipboardChunk.h +++ b/src/lib/barrier/ClipboardChunk.h @@ -1,11 +1,11 @@ /* * barrier -- 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 diff --git a/src/lib/barrier/DragInformation.cpp b/src/lib/barrier/DragInformation.cpp index db28f3d..5a46678 100644 --- a/src/lib/barrier/DragInformation.cpp +++ b/src/lib/barrier/DragInformation.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2013-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 @@ -41,7 +41,7 @@ DragInformation::parseDragInfo(DragFileList& dragFileList, UInt32 fileNum, Strin if (data.find("/", startPos) != string::npos) { slash = "/"; } - + UInt32 index = 0; while (index < fileNum) { findResult1 = data.find(',', startPos); @@ -51,7 +51,7 @@ DragInformation::parseDragInfo(DragFileList& dragFileList, UInt32 fileNum, Strin //TODO: file number does not match, something goes wrong break; } - + // set filename if (findResult1 - findResult2 > 1) { String filename = data.substr(findResult2 + 1, @@ -61,7 +61,7 @@ DragInformation::parseDragInfo(DragFileList& dragFileList, UInt32 fileNum, Strin dragFileList.push_back(di); } startPos = findResult1 + 1; - + //set filesize findResult2 = data.find(',', startPos); if (findResult2 - findResult1 > 1) { @@ -71,7 +71,7 @@ DragInformation::parseDragInfo(DragFileList& dragFileList, UInt32 fileNum, Strin dragFileList.at(index).setFilesize(size); } startPos = findResult1 + 1; - + ++index; } @@ -151,8 +151,8 @@ DragInformation::getFileSize(String& filename) stringstream ss; ss << size; - + file. close(); - + return ss.str(); } diff --git a/src/lib/barrier/DragInformation.h b/src/lib/barrier/DragInformation.h index b985bd1..a5d76b0 100644 --- a/src/lib/barrier/DragInformation.h +++ b/src/lib/barrier/DragInformation.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2013-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 @@ -28,12 +28,12 @@ class DragInformation { public: DragInformation(); ~DragInformation() { } - + String& getFilename() { return m_filename; } void setFilename(String& name) { m_filename = name; } size_t getFilesize() { return m_filesize; } void setFilesize(size_t size) { m_filesize = size; } - + static void parseDragInfo(DragFileList& dragFileList, UInt32 fileNum, String data); static String getDragFileExtension(String filename); // helper function to setup drag info diff --git a/src/lib/barrier/DropHelper.cpp b/src/lib/barrier/DropHelper.cpp index ee5e5ee..af22b52 100644 --- a/src/lib/barrier/DropHelper.cpp +++ b/src/lib/barrier/DropHelper.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-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 @@ -18,6 +18,7 @@ #include "barrier/DropHelper.h" #include "base/Log.h" +#include "io/filesystem.h" #include @@ -35,15 +36,15 @@ DropHelper::writeToDir(const String& destination, DragFileList& fileList, String dropTarget.append("/"); #endif dropTarget.append(fileList.at(0).getFilename()); - file.open(dropTarget.c_str(), std::ios::out | std::ios::binary); + barrier::open_utf8_path(file, dropTarget, std::ios::out | std::ios::binary); if (!file.is_open()) { LOG((CLOG_ERR "drop file failed: can not open %s", dropTarget.c_str())); } - + file.write(data.c_str(), data.size()); file.close(); - LOG((CLOG_DEBUG "%s is saved to %s", fileList.at(0).getFilename().c_str(), destination.c_str())); + LOG((CLOG_INFO "dropped file \"%s\" in \"%s\"", fileList.at(0).getFilename().c_str(), destination.c_str())); fileList.clear(); } diff --git a/src/lib/barrier/DropHelper.h b/src/lib/barrier/DropHelper.h index 67facbb..801779c 100644 --- a/src/lib/barrier/DropHelper.h +++ b/src/lib/barrier/DropHelper.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-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 diff --git a/src/lib/barrier/FileChunk.cpp b/src/lib/barrier/FileChunk.cpp index 3a98568..08c489b 100644 --- a/src/lib/barrier/FileChunk.cpp +++ b/src/lib/barrier/FileChunk.cpp @@ -1,11 +1,11 @@ /* * barrier -- 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 diff --git a/src/lib/barrier/FileChunk.h b/src/lib/barrier/FileChunk.h index bdc2f64..bdb5006 100644 --- a/src/lib/barrier/FileChunk.h +++ b/src/lib/barrier/FileChunk.h @@ -1,11 +1,11 @@ /* * barrier -- 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 diff --git a/src/lib/barrier/IApp.h b/src/lib/barrier/IApp.h index 3a8cd56..0c516b9 100644 --- a/src/lib/barrier/IApp.h +++ b/src/lib/barrier/IApp.h @@ -2,11 +2,11 @@ * barrier -- 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 diff --git a/src/lib/barrier/IAppUtil.h b/src/lib/barrier/IAppUtil.h index 39df65d..521bfce 100644 --- a/src/lib/barrier/IAppUtil.h +++ b/src/lib/barrier/IAppUtil.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -15,7 +15,7 @@ * 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" diff --git a/src/lib/barrier/IClient.h b/src/lib/barrier/IClient.h index d9b2194..e1382b7 100644 --- a/src/lib/barrier/IClient.h +++ b/src/lib/barrier/IClient.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/IClipboard.cpp b/src/lib/barrier/IClipboard.cpp index 19b4b56..d484121 100644 --- a/src/lib/barrier/IClipboard.cpp +++ b/src/lib/barrier/IClipboard.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -66,13 +66,13 @@ IClipboard::unmarshall(IClipboard* clipboard, const String& data, Time time) String IClipboard::marshall(const IClipboard* clipboard) { - // return data format: + // return data format: // 4 bytes => number of formats included // 4 bytes => format enum // 4 bytes => clipboard data size n // n bytes => clipboard data // back to the second 4 bytes if there is another format - + assert(clipboard != NULL); String data; diff --git a/src/lib/barrier/IClipboard.h b/src/lib/barrier/IClipboard.h index e11b264..436b21b 100644 --- a/src/lib/barrier/IClipboard.h +++ b/src/lib/barrier/IClipboard.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/IKeyState.cpp b/src/lib/barrier/IKeyState.cpp index 5d1114c..e89c0e9 100644 --- a/src/lib/barrier/IKeyState.cpp +++ b/src/lib/barrier/IKeyState.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/IKeyState.h b/src/lib/barrier/IKeyState.h index b9d4706..e7f88fa 100644 --- a/src/lib/barrier/IKeyState.h +++ b/src/lib/barrier/IKeyState.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 @@ -122,14 +122,14 @@ public: complete and false if normal key processing should continue. */ virtual bool fakeCtrlAltDel() = 0; - + //! Fake a media key /*! Synthesizes a media key down and up. Only Mac would implement this by use cocoa appkit framework. */ virtual bool fakeMediaKey(KeyID id) = 0; - + //@} //! @name accessors //@{ diff --git a/src/lib/barrier/INode.h b/src/lib/barrier/INode.h index 2e78f7c..02fd9de 100644 --- a/src/lib/barrier/INode.h +++ b/src/lib/barrier/INode.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -21,5 +21,5 @@ #include "common/IInterface.h" class INode : IInterface { - + }; diff --git a/src/lib/barrier/IPlatformScreen.cpp b/src/lib/barrier/IPlatformScreen.cpp index d1d9f78..a037f75 100644 --- a/src/lib/barrier/IPlatformScreen.cpp +++ b/src/lib/barrier/IPlatformScreen.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2016 Symless. - * + * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file COPYING that should have accompanied this file. - * + * * This package is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the diff --git a/src/lib/barrier/IPlatformScreen.h b/src/lib/barrier/IPlatformScreen.h index 440e218..995ff73 100644 --- a/src/lib/barrier/IPlatformScreen.h +++ b/src/lib/barrier/IPlatformScreen.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -197,7 +197,8 @@ public: virtual void fakeDraggingFiles(DragFileList fileList) = 0; virtual const String& getDropTarget() const = 0; - + virtual void setDropTarget(const String&) = 0; + protected: //! Handle system event /*! diff --git a/src/lib/barrier/IPrimaryScreen.cpp b/src/lib/barrier/IPrimaryScreen.cpp index 4954e4f..2220212 100644 --- a/src/lib/barrier/IPrimaryScreen.cpp +++ b/src/lib/barrier/IPrimaryScreen.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/IPrimaryScreen.h b/src/lib/barrier/IPrimaryScreen.h index 7f3fa9c..0cf3688 100644 --- a/src/lib/barrier/IPrimaryScreen.h +++ b/src/lib/barrier/IPrimaryScreen.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/IScreen.h b/src/lib/barrier/IScreen.h index 47d6578..a1e7c47 100644 --- a/src/lib/barrier/IScreen.h +++ b/src/lib/barrier/IScreen.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 @@ -66,6 +66,6 @@ public: Return the current position of the cursor in \c x and \c y. */ virtual void getCursorPos(SInt32& x, SInt32& y) const = 0; - + //@} }; diff --git a/src/lib/barrier/IScreenSaver.h b/src/lib/barrier/IScreenSaver.h index fc21ac5..2099f6d 100644 --- a/src/lib/barrier/IScreenSaver.h +++ b/src/lib/barrier/IScreenSaver.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -56,7 +56,7 @@ public: //! Deactivate screen saver /*! - Deactivate (i.e. hide) the screen saver, reseting the screen saver + Deactivate (i.e. hide) the screen saver, resetting the screen saver timer. */ virtual void deactivate() = 0; diff --git a/src/lib/barrier/ISecondaryScreen.h b/src/lib/barrier/ISecondaryScreen.h index 527ca2e..85da511 100644 --- a/src/lib/barrier/ISecondaryScreen.h +++ b/src/lib/barrier/ISecondaryScreen.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/KeyMap.cpp b/src/lib/barrier/KeyMap.cpp index 621e747..7d53deb 100644 --- a/src/lib/barrier/KeyMap.cpp +++ b/src/lib/barrier/KeyMap.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2005 Chris Schoeneman - * + * * 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 @@ -733,7 +733,7 @@ KeyMap::keyForModifier(KeyButton button, SInt32 group, assert(modifierBit >= 0 && modifierBit < kKeyModifierNumBits); assert(group >= 0 && group < getNumGroups()); - // find a key that generates the given modifier in the given group + // find a key that generates the given modifier in the given group // but doesn't use the given button, presumably because we're trying // to generate a KeyID that's only bound the the given button. // this is important when a shift button is modified by shift; we @@ -989,7 +989,7 @@ KeyMap::addKeystrokes(EKeystroke type, const KeyItem& keyItem, } } break; - + case kKeystrokeRelease: keystrokes.push_back(Keystroke(button, false, false, data)); if (keyItem.m_generates != 0 && !keyItem.m_lock) { @@ -1011,19 +1011,19 @@ KeyMap::addKeystrokes(EKeystroke type, const KeyItem& keyItem, } } break; - + case kKeystrokeRepeat: keystrokes.push_back(Keystroke(button, false, true, data)); keystrokes.push_back(Keystroke(button, true, true, data)); // no modifier changes on key repeat break; - + case kKeystrokeClick: keystrokes.push_back(Keystroke(button, true, false, data)); keystrokes.push_back(Keystroke(button, false, false, data)); // no modifier changes on key click break; - + case kKeystrokeModify: case kKeystrokeUnmodify: if (keyItem.m_lock) { diff --git a/src/lib/barrier/KeyMap.h b/src/lib/barrier/KeyMap.h index b6eb865..bc72020 100644 --- a/src/lib/barrier/KeyMap.h +++ b/src/lib/barrier/KeyMap.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2005 Chris Schoeneman - * + * * 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 @@ -24,7 +24,9 @@ #include "common/stdset.h" #include "common/stdvector.h" +#ifdef BARRIER_TEST_ENV #include +#endif namespace barrier { @@ -320,13 +322,14 @@ public: Converts a string into a modifier mask. Returns \c true on success and \c false if the string cannot be parsed. The modifiers plus any remaining leading and trailing whitespace is stripped from the input - string. + string. */ static bool parseModifiers(String&, KeyModifierMask&); //@} private: +#ifdef BARRIER_TEST_ENV FRIEND_TEST(KeyMapTests, findBestKey_requiredDown_matchExactFirstItem); FRIEND_TEST(KeyMapTests, @@ -340,6 +343,7 @@ private: FRIEND_TEST(KeyMapTests, findBestKey_onlyOneRequiredDown_matchTwoRequiredChangesItem); FRIEND_TEST(KeyMapTests, findBestKey_noRequiredDown_cannotMatch); +#endif private: //! Ways to synthesize a key @@ -351,7 +355,7 @@ private: kKeystrokeModify, //!< Synthesize pressing a modifier kKeystrokeUnmodify //!< Synthesize releasing a modifier }; - + // A list of ways to synthesize a KeyID typedef std::vector KeyEntryList; diff --git a/src/lib/barrier/KeyState.cpp b/src/lib/barrier/KeyState.cpp index fc5579d..4c04277 100644 --- a/src/lib/barrier/KeyState.cpp +++ b/src/lib/barrier/KeyState.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -529,7 +529,7 @@ KeyState::addActiveModifierCB(KeyID, SInt32 group, (keyItem.m_generates & context->m_mask) != 0) { context->m_activeModifiers.insert(std::make_pair( keyItem.m_generates, keyItem)); - } + } } void @@ -581,10 +581,10 @@ KeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID) LOG((CLOG_DEBUG1 "emulating media key")); fakeMediaKey(id); } - + return; } - + KeyButton localID = (KeyButton)(keyItem->m_button & kButtonMask); updateModifierKeyState(localID, oldActiveModifiers, m_activeModifiers); if (localID != 0) { diff --git a/src/lib/barrier/KeyState.h b/src/lib/barrier/KeyState.h index 737d515..6f32b5d 100644 --- a/src/lib/barrier/KeyState.h +++ b/src/lib/barrier/KeyState.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -74,7 +74,7 @@ public: virtual void fakeAllKeysUp(); virtual bool fakeCtrlAltDel() = 0; virtual bool fakeMediaKey(KeyID id); - + virtual bool isKeyDown(KeyButton) const; virtual KeyModifierMask getActiveModifiers() const; @@ -157,7 +157,7 @@ public: AddActiveModifierContext& operator=(const AddActiveModifierContext&); }; private: - + class ButtonToKeyLess { public: bool operator()(const barrier::KeyMap::ButtonToKeyMap::value_type& a, diff --git a/src/lib/barrier/PacketStreamFilter.cpp b/src/lib/barrier/PacketStreamFilter.cpp index 16f0fe7..5955b6c 100644 --- a/src/lib/barrier/PacketStreamFilter.cpp +++ b/src/lib/barrier/PacketStreamFilter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -17,6 +17,7 @@ */ #include "barrier/PacketStreamFilter.h" +#include "barrier/protocol_types.h" #include "base/IEventQueue.h" #include "mt/Lock.h" #include "base/TMethodEventJob.h" @@ -133,8 +134,7 @@ PacketStreamFilter::isReadyNoLock() const return (m_size != 0 && m_buffer.getSize() >= m_size); } -void -PacketStreamFilter::readPacketSize() +bool PacketStreamFilter::readPacketSize() { // note -- m_mutex must be locked on entry @@ -146,7 +146,13 @@ PacketStreamFilter::readPacketSize() ((UInt32)buffer[1] << 16) | ((UInt32)buffer[2] << 8) | (UInt32)buffer[3]; + + if (m_size > PROTOCOL_MAX_MESSAGE_LENGTH) { + m_events->addEvent(Event(m_events->forIStream().inputFormatError(), getEventTarget())); + return false; + } } + return true; } bool @@ -160,13 +166,17 @@ PacketStreamFilter::readMore() UInt32 n = getStream()->read(buffer, sizeof(buffer)); while (n > 0) { m_buffer.write(buffer, n); + + // if we don't yet have the next packet size then get it, if possible. + // Note that we can't wait for whole pending data to arrive because it may be huge in + // case of malicious or erroneous peer. + if (!readPacketSize()) { + break; + } + n = getStream()->read(buffer, sizeof(buffer)); } - // if we don't yet have the next packet size then get it, - // if possible. - readPacketSize(); - // note if we now have a whole packet bool isReady = isReadyNoLock(); diff --git a/src/lib/barrier/PacketStreamFilter.h b/src/lib/barrier/PacketStreamFilter.h index bcbd604..0c4bb04 100644 --- a/src/lib/barrier/PacketStreamFilter.h +++ b/src/lib/barrier/PacketStreamFilter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -24,7 +24,7 @@ class IEventQueue; -//! Packetizing stream filter +//! Packetizing stream filter /*! Filters a stream to read and write packets. */ @@ -47,7 +47,9 @@ protected: private: bool isReadyNoLock() const; - void readPacketSize(); + + // returns false on erroneous packet size + bool readPacketSize(); bool readMore(); private: diff --git a/src/lib/barrier/PlatformScreen.cpp b/src/lib/barrier/PlatformScreen.cpp index b0fdc75..d72e69a 100644 --- a/src/lib/barrier/PlatformScreen.cpp +++ b/src/lib/barrier/PlatformScreen.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/PlatformScreen.h b/src/lib/barrier/PlatformScreen.h index 38bf8de..19a3da1 100644 --- a/src/lib/barrier/PlatformScreen.h +++ b/src/lib/barrier/PlatformScreen.h @@ -101,6 +101,7 @@ public: virtual void fakeDraggingFiles(DragFileList fileList) { throw std::runtime_error("fakeDraggingFiles not implemented"); } virtual const String& getDropTarget() const { throw std::runtime_error("getDropTarget not implemented"); } + virtual void setDropTarget(const String&) { throw std::runtime_error("setDropTarget not implemented"); } protected: //! Update mouse buttons diff --git a/src/lib/barrier/PortableTaskBarReceiver.cpp b/src/lib/barrier/PortableTaskBarReceiver.cpp index 384cacd..e9a5f40 100644 --- a/src/lib/barrier/PortableTaskBarReceiver.cpp +++ b/src/lib/barrier/PortableTaskBarReceiver.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 @@ -111,7 +111,7 @@ PortableTaskBarReceiver::getToolTip() const case kNotWorking: return barrier::string::sprintf("%s: %s", kAppVersion, m_errorMessage.c_str()); - + case kNotConnected: return barrier::string::sprintf("%s: Unknown", kAppVersion); diff --git a/src/lib/barrier/PortableTaskBarReceiver.h b/src/lib/barrier/PortableTaskBarReceiver.h index d335e44..3db27ba 100644 --- a/src/lib/barrier/PortableTaskBarReceiver.h +++ b/src/lib/barrier/PortableTaskBarReceiver.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/ProtocolUtil.cpp b/src/lib/barrier/ProtocolUtil.cpp index e742687..5a71010 100644 --- a/src/lib/barrier/ProtocolUtil.cpp +++ b/src/lib/barrier/ProtocolUtil.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -19,6 +19,8 @@ #include "barrier/ProtocolUtil.h" #include "io/IStream.h" #include "base/Log.h" +#include "barrier/protocol_types.h" +#include "barrier/XBarrier.h" #include "common/stdvector.h" #include "base/String.h" @@ -80,7 +82,7 @@ ProtocolUtil::vwritef(barrier::IStream* stream, // fill buffer UInt8* buffer = new UInt8[size]; - writef(buffer, fmt, args); + writef_void(buffer, fmt, args); try { // write buffer @@ -159,6 +161,10 @@ ProtocolUtil::vreadf(barrier::IStream* stream, const char* fmt, va_list args) (static_cast(buffer[2]) << 8) | static_cast(buffer[3]); + if (n > PROTOCOL_MAX_LIST_LENGTH) { + throw XBadClient("Too long message received"); + } + // convert it void* v = va_arg(args, void*); switch (len) { @@ -211,6 +217,10 @@ ProtocolUtil::vreadf(barrier::IStream* stream, const char* fmt, va_list args) (static_cast(buffer[2]) << 8) | static_cast(buffer[3]); + if (len > PROTOCOL_MAX_STRING_LENGTH) { + throw XBadClient("Too long message received"); + } + // use a fixed size buffer if its big enough const bool useFixed = (len <= sizeof(buffer)); @@ -339,7 +349,7 @@ ProtocolUtil::getLength(const char* fmt, va_list args) } void -ProtocolUtil::writef(void* buffer, const char* fmt, va_list args) +ProtocolUtil::writef_void(void* buffer, const char* fmt, va_list args) { UInt8* dst = static_cast(buffer); diff --git a/src/lib/barrier/ProtocolUtil.h b/src/lib/barrier/ProtocolUtil.h index 9930cfc..af4fea8 100644 --- a/src/lib/barrier/ProtocolUtil.h +++ b/src/lib/barrier/ProtocolUtil.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -38,7 +38,7 @@ public: regular characters and format specifiers. Format specifiers begin with \%. All characters not part of a format specifier are regular and are transmitted unchanged. - + Format specifiers are: - \%\% -- literal `\%' - \%1i -- converts integer argument to 1 byte integer @@ -58,7 +58,7 @@ public: Read formatted binary data from a buffer. This performs the reverse operation of writef(). Returns true if the entire format was successfully parsed, false otherwise. - + Format specifiers are: - \%\% -- read (and discard) a literal `\%' - \%1i -- reads a 1 byte integer; argument is a SInt32* or UInt32* @@ -79,7 +79,7 @@ private: const char* fmt, va_list); static UInt32 getLength(const char* fmt, va_list); - static void writef(void*, const char* fmt, va_list); + static void writef_void(void*, const char* fmt, va_list); static UInt32 eatLength(const char** fmt); static void read(barrier::IStream*, void*, UInt32); }; diff --git a/src/lib/barrier/Screen.cpp b/src/lib/barrier/Screen.cpp index 32442f6..2a2c877 100644 --- a/src/lib/barrier/Screen.cpp +++ b/src/lib/barrier/Screen.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 @@ -376,7 +376,7 @@ Screen::isLockedToScreen() const if (buttonID != kButtonLeft) { LOG((CLOG_DEBUG "locked by mouse buttonID: %d", buttonID)); } - + if (m_enableDragDrop) { return (buttonID == kButtonLeft) ? false : true; } @@ -466,6 +466,12 @@ Screen::getDropTarget() const return m_screen->getDropTarget(); } +void +Screen::setDropTarget(const String& target) +{ + return m_screen->setDropTarget(target); +} + void* Screen::getEventTarget() const { diff --git a/src/lib/barrier/Screen.h b/src/lib/barrier/Screen.h index b16feff..1c8e7de 100644 --- a/src/lib/barrier/Screen.h +++ b/src/lib/barrier/Screen.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -42,7 +42,7 @@ public: Screen(IPlatformScreen* platformScreen, IEventQueue* events); virtual ~Screen(); -#ifdef TEST_ENV +#ifdef BARRIER_TEST_ENV Screen() : m_mock(true) { } #endif @@ -223,7 +223,7 @@ public: //! Change dragging status void setDraggingStarted(bool started); - + //! Fake a files dragging operation void startDraggingFiles(DragFileList& fileList); @@ -278,7 +278,7 @@ public: //! Test if file is dragged on primary screen bool isDraggingStarted() const; - + //! Test if file is dragged on secondary screen bool isFakeDraggingStarted() const; @@ -290,6 +290,8 @@ public: //! Get the drop target directory const String& getDropTarget() const; + //! Set the drop target directory + void setDropTarget(const String&); //@} @@ -299,7 +301,7 @@ public: virtual void getShape(SInt32& x, SInt32& y, SInt32& width, SInt32& height) const; virtual void getCursorPos(SInt32& x, SInt32& y) const; - + IPlatformScreen* getPlatformScreen() { return m_screen; } protected: diff --git a/src/lib/barrier/ServerApp.cpp b/src/lib/barrier/ServerApp.cpp index 18cf935..71158ce 100644 --- a/src/lib/barrier/ServerApp.cpp +++ b/src/lib/barrier/ServerApp.cpp @@ -34,13 +34,11 @@ #include "base/EventQueue.h" #include "base/log_outputters.h" #include "base/FunctionEventJob.h" -#include "base/TMethodJob.h" #include "base/IEventQueue.h" #include "base/Log.h" #include "base/TMethodEventJob.h" #include "common/Version.h" #include "common/DataDirectories.h" -#include "common/PathUtilities.h" #if SYSAPI_WIN32 #include "arch/win32/ArchMiscWindows.h" @@ -128,30 +126,43 @@ ServerApp::help() # define WINAPI_INFO "" #endif + // refer to custom profile directory even if not saved yet + barrier::fs::path profile_path = argsBase().m_profileDirectory; + if (profile_path.empty()) { + profile_path = barrier::DataDirectories::profile(); + } + + auto usr_config_path = (profile_path / barrier::fs::u8path(USR_CONFIG_NAME)).u8string(); + auto sys_config_path = (barrier::DataDirectories::systemconfig() / + barrier::fs::u8path(SYS_CONFIG_NAME)).u8string(); + std::ostringstream buffer; - buffer << "Start the barrier server component." << std::endl - << std::endl + buffer << "Start the barrier server component.\n" + << "\n" << "Usage: " << args().m_exename << " [--address
    ]" << " [--config ]" - << WINAPI_ARGS << HELP_SYS_ARGS << HELP_COMMON_ARGS << std::endl - << std::endl - << "Options:" << std::endl - << " -a, --address
    listen for clients on the given address." << std::endl - << " -c, --config use the named configuration file instead." << std::endl - << HELP_COMMON_INFO_1 << WINAPI_INFO << HELP_SYS_INFO << HELP_COMMON_INFO_2 << std::endl - << "Default options are marked with a *" << std::endl - << std::endl - << "The argument for --address is of the form: [][:]. The" << std::endl - << "hostname must be the address or hostname of an interface on the system." << std::endl - << "Placing brackets around an IPv6 address is required when also specifying " << std::endl - << "a port number and optional otherwise. The default is to listen on all" << std::endl - << "interfaces using port number " << kDefaultPort << "." << std::endl - << std::endl - << "If no configuration file pathname is provided then the first of the" << std::endl - << "following to load successfully sets the configuration:" << std::endl - << " " << PathUtilities::concat(DataDirectories::profile(), USR_CONFIG_NAME) << std::endl - << " " << PathUtilities::concat(DataDirectories::systemconfig(), SYS_CONFIG_NAME) << std::endl; + << WINAPI_ARGS << HELP_SYS_ARGS << HELP_COMMON_ARGS << "\n" + << "\n" + << "Options:\n" + << " -a, --address
    listen for clients on the given address.\n" + << " -c, --config use the named configuration file instead.\n" + << HELP_COMMON_INFO_1 + << " --disable-client-cert-checking disable client SSL certificate \n" + " checking (deprecated)\n" + << WINAPI_INFO << HELP_SYS_INFO << HELP_COMMON_INFO_2 << "\n" + << "Default options are marked with a *\n" + << "\n" + << "The argument for --address is of the form: [][:]. The\n" + << "hostname must be the address or hostname of an interface on the system.\n" + << "Placing brackets around an IPv6 address is required when also specifying \n" + << "a port number and optional otherwise. The default is to listen on all\n" + << "interfaces using port number " << kDefaultPort << ".\n" + << "\n" + << "If no configuration file pathname is provided then the first of the\n" + << "following to load successfully sets the configuration:\n" + << " " << usr_config_path << "\n" + << " " << sys_config_path << "\n"; LOG((CLOG_PRINT "%s", buffer.str().c_str())); } @@ -188,25 +199,25 @@ ServerApp::loadConfig() // load the default configuration if no explicit file given else { - String path = DataDirectories::profile(); + auto path = barrier::DataDirectories::profile(); if (!path.empty()) { // complete path - path = PathUtilities::concat(path, USR_CONFIG_NAME); + path /= barrier::fs::u8path(USR_CONFIG_NAME); // now try loading the user's configuration - if (loadConfig(path)) { + if (loadConfig(path.u8string())) { loaded = true; - args().m_configFile = path; + args().m_configFile = path.u8string(); } } if (!loaded) { // try the system-wide config file - path = DataDirectories::systemconfig(); + path = barrier::DataDirectories::systemconfig(); if (!path.empty()) { - path = PathUtilities::concat(path, SYS_CONFIG_NAME); - if (loadConfig(path)) { + path /= barrier::fs::u8path(SYS_CONFIG_NAME); + if (loadConfig(path.u8string())) { loaded = true; - args().m_configFile = path; + args().m_configFile = path.u8string(); } } } @@ -496,6 +507,9 @@ barrier::Screen* ServerApp::openServerScreen() { barrier::Screen* screen = createScreen(); + if (!argsBase().m_dropTarget.empty()) { + screen->setDropTarget(argsBase().m_dropTarget); + } screen->setEnableDragDrop(argsBase().m_enableDragDrop); m_events->adoptHandler(m_events->forIScreen().error(), screen->getEventTarget(), @@ -643,11 +657,18 @@ ServerApp::handleResume(const Event&, void*) ClientListener* ServerApp::openClientListener(const NetworkAddress& address) { + auto security_level = ConnectionSecurityLevel::PLAINTEXT; + if (args().m_enableCrypto) { + security_level = ConnectionSecurityLevel::ENCRYPTED; + if (args().check_client_certificates) { + security_level = ConnectionSecurityLevel::ENCRYPTED_AUTHENTICATED; + } + } + ClientListener* listen = new ClientListener( address, new TCPSocketFactory(m_events, getSocketMultiplexer()), - m_events, - args().m_enableCrypto); + m_events, security_level); m_events->adoptHandler( m_events->forClientListener().connected(), listen, @@ -775,10 +796,7 @@ ServerApp::mainLoop() #if defined(MAC_OS_X_VERSION_10_7) - Thread thread( - new TMethodJob( - this, &ServerApp::runEventsLoop, - NULL)); + Thread thread([this](){ run_events_loop(); }); // wait until carbon loop is ready OSXScreen* screen = dynamic_cast( @@ -823,7 +841,7 @@ ServerApp::runInner(int argc, char** argv, ILogOutputter* outputter, StartupFunc // general initialization m_barrierAddress = new NetworkAddress; args().m_config = new Config(m_events); - args().m_exename = PathUtilities::basename(argv[0]); + args().m_exename = ArgParser::parse_exename(argv[0]); // install caller's output filter if (outputter != NULL) { diff --git a/src/lib/barrier/ServerApp.h b/src/lib/barrier/ServerApp.h index 528aa24..ca38568 100644 --- a/src/lib/barrier/ServerApp.h +++ b/src/lib/barrier/ServerApp.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -51,7 +51,7 @@ class ServerApp : public App { public: ServerApp(IEventQueue* events, CreateTaskBarReceiverFunc createTaskBarReceiver); virtual ~ServerApp(); - + // Parse server specific command line arguments. void parseArgs(int argc, const char* const* argv); @@ -104,7 +104,7 @@ public: static ServerApp& instance() { return (ServerApp&)App::instance(); } Server* getServerPtr() { return m_server; } - + Server* m_server; EServerState m_serverState; barrier::Screen* m_serverScreen; diff --git a/src/lib/barrier/ServerArgs.h b/src/lib/barrier/ServerArgs.h index 6d91233..6323705 100644 --- a/src/lib/barrier/ServerArgs.h +++ b/src/lib/barrier/ServerArgs.h @@ -30,4 +30,5 @@ public: String m_configFile; Config* m_config; String m_screenChangeScript; + bool check_client_certificates = true; }; diff --git a/src/lib/barrier/ServerTaskBarReceiver.cpp b/src/lib/barrier/ServerTaskBarReceiver.cpp index b427cd1..c3ba7cf 100644 --- a/src/lib/barrier/ServerTaskBarReceiver.cpp +++ b/src/lib/barrier/ServerTaskBarReceiver.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 @@ -125,7 +125,7 @@ ServerTaskBarReceiver::getToolTip() const case kNotWorking: return barrier::string::sprintf("%s: %s", kAppVersion, m_errorMessage.c_str()); - + case kNotConnected: return barrier::string::sprintf("%s: Waiting for clients", kAppVersion); diff --git a/src/lib/barrier/ServerTaskBarReceiver.h b/src/lib/barrier/ServerTaskBarReceiver.h index 3cef9c0..086de8c 100644 --- a/src/lib/barrier/ServerTaskBarReceiver.h +++ b/src/lib/barrier/ServerTaskBarReceiver.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/StreamChunker.cpp b/src/lib/barrier/StreamChunker.cpp index 579d02f..0f6c0a9 100644 --- a/src/lib/barrier/StreamChunker.cpp +++ b/src/lib/barrier/StreamChunker.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2013-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 @@ -42,14 +42,13 @@ bool StreamChunker::s_interruptFile = false; Mutex* StreamChunker::s_interruptMutex = NULL; void -StreamChunker::sendFile( - char* filename, +StreamChunker::sendFile(const char* filename, IEventQueue* events, void* eventTarget) { s_isChunkingFile = true; - - std::fstream file(static_cast(filename), std::ios::in | std::ios::binary); + + std::fstream file(filename, std::ios::in | std::ios::binary); if (!file.is_open()) { throw runtime_error("failed to open file"); @@ -76,9 +75,9 @@ StreamChunker::sendFile( LOG((CLOG_DEBUG "file transmission interrupted")); break; } - + events->addEvent(Event(events->forFile().keepAlive(), eventTarget)); - + // make sure we don't read too much from the mock data. if (sentLength + chunkSize > size) { chunkSize = size - sentLength; @@ -106,7 +105,7 @@ StreamChunker::sendFile( events->addEvent(Event(events->forFile().fileChunkSending(), eventTarget, end)); file.close(); - + s_isChunkingFile = false; } @@ -122,16 +121,16 @@ StreamChunker::sendClipboard( // send first message (data size) String dataSize = barrier::string::sizeTypeToString(size); ClipboardChunk* sizeMessage = ClipboardChunk::start(id, sequence, dataSize); - + events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, sizeMessage)); // send clipboard chunk with a fixed size size_t sentLength = 0; size_t chunkSize = g_chunkSize; - + while (true) { events->addEvent(Event(events->forFile().keepAlive(), eventTarget)); - + // make sure we don't read too much from the mock data. if (sentLength + chunkSize > size) { chunkSize = size - sentLength; @@ -139,7 +138,7 @@ StreamChunker::sendClipboard( String chunk(data.substr(sentLength, chunkSize).c_str(), chunkSize); ClipboardChunk* dataChunk = ClipboardChunk::data(id, sequence, chunk); - + events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, dataChunk)); sentLength += chunkSize; @@ -152,7 +151,7 @@ StreamChunker::sendClipboard( ClipboardChunk* end = ClipboardChunk::end(id, sequence); events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, end)); - + LOG((CLOG_DEBUG "sent clipboard size=%d", sentLength)); } diff --git a/src/lib/barrier/StreamChunker.h b/src/lib/barrier/StreamChunker.h index ab57c7e..ed5d83c 100644 --- a/src/lib/barrier/StreamChunker.h +++ b/src/lib/barrier/StreamChunker.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2013-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 @@ -25,10 +25,7 @@ class Mutex; class StreamChunker { public: - static void sendFile( - char* filename, - IEventQueue* events, - void* eventTarget); + static void sendFile(const char* filename, IEventQueue* events, void* eventTarget); static void sendClipboard( String& data, size_t size, @@ -37,7 +34,7 @@ public: IEventQueue* events, void* eventTarget); static void interruptFile(); - + private: static bool s_isChunkingFile; static bool s_interruptFile; diff --git a/src/lib/barrier/XBarrier.cpp b/src/lib/barrier/XBarrier.cpp index 7fe3577..44593d1 100644 --- a/src/lib/barrier/XBarrier.cpp +++ b/src/lib/barrier/XBarrier.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -118,6 +118,6 @@ int XExitApp::getCode() const noexcept String XExitApp::getWhat() const noexcept { return format( - "XExitApp", "exiting with code %{1}", + "XExitApp", "exiting with code %{1}", barrier::string::sprintf("%d", m_code).c_str()); } diff --git a/src/lib/barrier/XBarrier.h b/src/lib/barrier/XBarrier.h index fef931e..b7a3891 100644 --- a/src/lib/barrier/XBarrier.h +++ b/src/lib/barrier/XBarrier.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -113,8 +113,8 @@ private: //! Generic exit eception /*! -Thrown when we want to abort, with the opportunity to clean up. This is a -little bit of a hack, but it's a better way of exiting, than just calling +Thrown when we want to abort, with the opportunity to clean up. This is a +little bit of a hack, but it's a better way of exiting, than just calling exit(int). */ class XExitApp : public XBarrier { @@ -127,7 +127,7 @@ public: protected: virtual std::string getWhat() const noexcept; - + private: int m_code; }; diff --git a/src/lib/barrier/XScreen.cpp b/src/lib/barrier/XScreen.cpp index 3398423..bb5c860 100644 --- a/src/lib/barrier/XScreen.cpp +++ b/src/lib/barrier/XScreen.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/XScreen.h b/src/lib/barrier/XScreen.h index f8fe7a7..7033556 100644 --- a/src/lib/barrier/XScreen.h +++ b/src/lib/barrier/XScreen.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/clipboard_types.h b/src/lib/barrier/clipboard_types.h index 54f2732..7de608c 100644 --- a/src/lib/barrier/clipboard_types.h +++ b/src/lib/barrier/clipboard_types.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/key_types.cpp b/src/lib/barrier/key_types.cpp index 902670d..33ee3eb 100644 --- a/src/lib/barrier/key_types.cpp +++ b/src/lib/barrier/key_types.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -17,6 +17,7 @@ */ #include "barrier/key_types.h" +#include const KeyNameMapEntry kKeyNameMap[] = { { "AltGr", kKeyAltGr }, @@ -43,6 +44,7 @@ const KeyNameMapEntry kKeyNameMap[] = { { "Control_R", kKeyControl_R }, { "Delete", kKeyDelete }, { "Down", kKeyDown }, + { "EisuToggle", kKeyEisuToggle }, { "Eject", kKeyEject }, { "End", kKeyEnd }, { "Escape", kKeyEscape }, @@ -89,6 +91,7 @@ const KeyNameMapEntry kKeyNameMap[] = { { "Hyper_L", kKeyHyper_L }, { "Hyper_R", kKeyHyper_R }, { "Insert", kKeyInsert }, + { "Kana", kKeyKana }, { "KP_0", kKeyKP_0 }, { "KP_1", kKeyKP_1 }, { "KP_2", kKeyKP_2 }, @@ -130,6 +133,7 @@ const KeyNameMapEntry kKeyNameMap[] = { { "Menu", kKeyMenu }, { "Meta_L", kKeyMeta_L }, { "Meta_R", kKeyMeta_R }, + { "Muhenkan", kKeyMuhenkan }, { "NumLock", kKeyNumLock }, { "PageDown", kKeyPageDown }, { "PageUp", kKeyPageUp }, @@ -191,6 +195,12 @@ const KeyNameMapEntry kKeyNameMap[] = { { "Bar", 0x007c }, { "BraceR", 0x007d }, { "Tilde", 0x007e }, + { "Copy", kKeyCopy }, + { "Cut", kKeyCut }, + { "Open", kKeyOpen }, + { "Paste", kKeyPaste }, + { "Props", kKeyProps }, + { "Front", kKeyFront }, { NULL, 0 }, }; diff --git a/src/lib/barrier/key_types.h b/src/lib/barrier/key_types.h index 7a8ea53..863dc17 100644 --- a/src/lib/barrier/key_types.h +++ b/src/lib/barrier/key_types.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -109,11 +109,13 @@ static const KeyID kKeyPause = 0xEF13; /* Pause, hold */ static const KeyID kKeyScrollLock = 0xEF14; static const KeyID kKeySysReq = 0xEF15; static const KeyID kKeyEscape = 0xEF1B; +static const KeyID kKeyMuhenkan = 0xEF22; /* Cancel Conversion */ static const KeyID kKeyHenkan = 0xEF23; /* Start/Stop Conversion */ static const KeyID kKeyKana = 0xEF26; /* Kana */ static const KeyID kKeyHiraganaKatakana = 0xEF27; /* Hiragana/Katakana toggle */ static const KeyID kKeyZenkaku = 0xEF2A; /* Zenkaku/Hankaku */ static const KeyID kKeyKanzi = 0xEF2A; /* Kanzi */ +static const KeyID kKeyEisuToggle = 0xEF30; /* Alphanumeric toggle */ static const KeyID kKeyHangul = 0xEF31; /* Hangul */ static const KeyID kKeyHanja = 0xEF34; /* Hanja */ static const KeyID kKeyDelete = 0xEFFF; /* Delete, rubout */ @@ -170,7 +172,7 @@ static const KeyID kKeyKP_Separator= 0xEFAC; /* separator, often comma */ static const KeyID kKeyKP_Subtract = 0xEFAD; static const KeyID kKeyKP_Decimal = 0xEFAE; static const KeyID kKeyKP_Divide = 0xEFAF; -static const KeyID kKeyKP_0 = 0xEFB0; +static const KeyID kKeyKP_0 = 0xEFB0; static const KeyID kKeyKP_1 = 0xEFB1; static const KeyID kKeyKP_2 = 0xEFB2; static const KeyID kKeyKP_3 = 0xEFB3; @@ -234,6 +236,13 @@ static const KeyID kKeySuper_R = 0xEFEC; /* Right super */ static const KeyID kKeyHyper_L = 0xEFED; /* Left hyper */ static const KeyID kKeyHyper_R = 0xEFEE; /* Right hyper */ +static const KeyID kKeyCopy = 0x1008EF57; +static const KeyID kKeyCut = 0x1008EF58; +static const KeyID kKeyOpen = 0x1008EF6b; +static const KeyID kKeyPaste = 0x1008EF6d; +static const KeyID kKeyProps = 0x1005EF70; +static const KeyID kKeyFront = 0x1005EF71; + // multi-key character composition static const KeyID kKeyCompose = 0xEF20; static const KeyID kKeyDeadGrave = 0x0300; @@ -284,6 +293,8 @@ static const KeyID kKeyAppUser1 = 0xE0B6; static const KeyID kKeyAppUser2 = 0xE0B7; static const KeyID kKeyBrightnessDown = 0xE0B8; static const KeyID kKeyBrightnessUp = 0xE0B9; +static const KeyID kKeyKbdBrightnessDown = 0xE0BA; +static const KeyID kKeyKbdBrightnessUp = 0xE0BB; static const KeyID kKeyMissionControl = 0xE0C0; static const KeyID kKeyLaunchpad = 0xE0C1; diff --git a/src/lib/barrier/mouse_types.h b/src/lib/barrier/mouse_types.h index 62a2396..ccb18ac 100644 --- a/src/lib/barrier/mouse_types.h +++ b/src/lib/barrier/mouse_types.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/option_types.h b/src/lib/barrier/option_types.h index 6323e37..42103d4 100644 --- a/src/lib/barrier/option_types.h +++ b/src/lib/barrier/option_types.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/protocol_types.cpp b/src/lib/barrier/protocol_types.cpp index 07acf61..9710841 100644 --- a/src/lib/barrier/protocol_types.cpp +++ b/src/lib/barrier/protocol_types.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/protocol_types.h b/src/lib/barrier/protocol_types.h index bc5e037..f730606 100644 --- a/src/lib/barrier/protocol_types.h +++ b/src/lib/barrier/protocol_types.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -20,6 +20,8 @@ #include "base/EventTypes.h" +#include + // protocol version number // 1.0: initial protocol // 1.1: adds KeyCode to key press, release, and repeat @@ -51,6 +53,12 @@ static const double kKeepAlivesUntilDeath = 3.0; static const double kHeartRate = -1.0; static const double kHeartBeatsUntilDeath = 3.0; +// Messages of very large size indicate a likely protocol error. We don't parse such messages and +// drop connection instead. Note that e.g. the clipboard messages are already limited to 32kB. +static constexpr std::uint32_t PROTOCOL_MAX_MESSAGE_LENGTH = 4 * 1024 * 1024; +static constexpr std::uint32_t PROTOCOL_MAX_LIST_LENGTH = 1024 * 1024; +static constexpr std::uint32_t PROTOCOL_MAX_STRING_LENGTH = 1024 * 1024; + // direction constants enum EDirection { kNoDirection, @@ -267,8 +275,8 @@ extern const char* kMsgDSetOptions; // 2 means the file transfer is finished. extern const char* kMsgDFileTransfer; -// drag infomation: primary <-> secondary -// transfer drag infomation. The first 2 bytes are used for storing +// drag information: primary <-> secondary +// transfer drag information. The first 2 bytes are used for storing // the number of dragging objects. Then the following string consists // of each object's directory. extern const char* kMsgDDragInfo; diff --git a/src/lib/barrier/unix/AppUtilUnix.cpp b/src/lib/barrier/unix/AppUtilUnix.cpp index a1548d8..272dcf4 100644 --- a/src/lib/barrier/unix/AppUtilUnix.cpp +++ b/src/lib/barrier/unix/AppUtilUnix.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/barrier/unix/AppUtilUnix.h b/src/lib/barrier/unix/AppUtilUnix.h index fefcfea..9555ccd 100644 --- a/src/lib/barrier/unix/AppUtilUnix.h +++ b/src/lib/barrier/unix/AppUtilUnix.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -28,7 +28,7 @@ class AppUtilUnix : public AppUtil { public: AppUtilUnix(IEventQueue* events); virtual ~AppUtilUnix(); - + int run(int argc, char** argv); void startNode(); }; diff --git a/src/lib/barrier/win32/AppUtilWindows.cpp b/src/lib/barrier/win32/AppUtilWindows.cpp index 560b029..b19cf15 100644 --- a/src/lib/barrier/win32/AppUtilWindows.cpp +++ b/src/lib/barrier/win32/AppUtilWindows.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -60,13 +60,13 @@ BOOL WINAPI AppUtilWindows::consoleHandler(DWORD) } static -int -mainLoopStatic() +int +mainLoopStatic() { return AppUtil::instance().app().mainLoop(); } -int +int AppUtilWindows::daemonNTMainLoop(int argc, const char** argv) { app().initApp(argc, argv); @@ -74,11 +74,11 @@ AppUtilWindows::daemonNTMainLoop(int argc, const char** argv) // NB: what the hell does this do?! app().argsBase().m_backend = false; - + return ArchMiscWindows::runDaemon(mainLoopStatic); } -void +void AppUtilWindows::exitApp(int code) { switch (m_exitMode) { @@ -97,7 +97,7 @@ int daemonNTMainLoopStatic(int argc, const char** argv) return AppUtilWindows::instance().daemonNTMainLoop(argc, argv); } -int +int AppUtilWindows::daemonNTStartup(int, char**) { SystemLogger sysLogger(app().daemonName(), false); @@ -126,7 +126,7 @@ AppUtilWindows::beforeAppExit() // a new console window, and will normally close on exit (making it so // that we can't see error messages). if (app().argsBase().m_pauseOnExit) { - std::cout << std::endl << "press any key to exit..." << std::endl; + std::cout << "\n" << "press any key to exit...\n"; int c = _getch(); } } @@ -155,13 +155,13 @@ AppUtilWindows::run(int argc, char** argv) return app().runInner(argc, argv, NULL, startup); } -AppUtilWindows& +AppUtilWindows& AppUtilWindows::instance() { return (AppUtilWindows&)AppUtil::instance(); } -void +void AppUtilWindows::debugServiceWait() { if (app().argsBase().m_debugServiceWait) @@ -169,8 +169,8 @@ AppUtilWindows::debugServiceWait() while(true) { // this code is only executed when the process is launched via the - // windows service controller (and --debug-service-wait arg is - // used). to debug, set a breakpoint on this line so that + // windows service controller (and --debug-service-wait arg is + // used). to debug, set a breakpoint on this line so that // execution is delayed until the debugger is attached. ARCH->sleep(1); LOG((CLOG_INFO "waiting for debugger to attach")); @@ -178,7 +178,7 @@ AppUtilWindows::debugServiceWait() } } -void +void AppUtilWindows::startNode() { app().startNode(); diff --git a/src/lib/barrier/win32/AppUtilWindows.h b/src/lib/barrier/win32/AppUtilWindows.h index c5da228..23e7919 100644 --- a/src/lib/barrier/win32/AppUtilWindows.h +++ b/src/lib/barrier/win32/AppUtilWindows.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -39,7 +39,7 @@ public: virtual ~AppUtilWindows(); int daemonNTStartup(int, char**); - + int daemonNTMainLoop(int argc, const char** argv); void debugServiceWait(); diff --git a/src/lib/barrier/win32/DaemonApp.cpp b/src/lib/barrier/win32/DaemonApp.cpp index 482c465..81ec5ff 100644 --- a/src/lib/barrier/win32/DaemonApp.cpp +++ b/src/lib/barrier/win32/DaemonApp.cpp @@ -2,11 +2,11 @@ * barrier -- 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 @@ -28,7 +28,6 @@ #include "net/SocketMultiplexer.h" #include "arch/XArch.h" #include "base/Log.h" -#include "base/TMethodJob.h" #include "base/TMethodEventJob.h" #include "base/EventQueue.h" #include "base/log_outputters.h" @@ -87,7 +86,7 @@ DaemonApp::run(int argc, char** argv) { // win32 instance needed for threading, etc. ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL)); - + Arch arch; arch.init(); @@ -174,7 +173,7 @@ DaemonApp::mainLoop(bool daemonized) try { DAEMON_RUNNING(true); - + if (daemonized) { m_fileLogOutputter = new FileLogOutputter(logFilename().c_str()); CLOG->insert(m_fileLogOutputter); @@ -190,19 +189,19 @@ DaemonApp::mainLoop(bool daemonized) // send logging to gui via ipc, log system adopts outputter. m_ipcLogOutputter = new IpcLogOutputter(*m_ipcServer, kIpcClientGui, true); CLOG->insert(m_ipcLogOutputter); - + m_watchdog = new MSWindowsWatchdog(daemonized, false, *m_ipcServer, *m_ipcLogOutputter); m_watchdog->setFileLogOutputter(m_fileLogOutputter); - + m_events->adoptHandler( m_events->forIpcServer().messageReceived(), m_ipcServer, new TMethodEventJob(this, &DaemonApp::handleIpcMessage)); m_ipcServer->listen(); - + // install the platform event queue to handle service stop events. m_events->adoptBuffer(new MSWindowsEventQueueBuffer(m_events)); - + String command = ARCH->setting("Command"); bool elevate = ARCH->setting("Elevate") == "1"; if (command != "") { @@ -219,11 +218,11 @@ DaemonApp::mainLoop(bool daemonized) m_events->removeHandler( m_events->forIpcServer().messageReceived(), m_ipcServer); - + CLOG->remove(m_ipcLogOutputter); delete m_ipcLogOutputter; delete m_ipcServer; - + DAEMON_RUNNING(false); } catch (std::exception& e) { @@ -245,7 +244,7 @@ DaemonApp::logFilename() { string logFilename = ARCH->setting("LogFilename"); if (logFilename.empty()) - logFilename = DataDirectories::global() + "\\" + LOG_FILENAME; + logFilename = (barrier::DataDirectories::global() / LOG_FILENAME).u8string(); MSWindowsUtil::createDirectory(logFilename, true); return logFilename; } @@ -287,7 +286,7 @@ DaemonApp::handleIpcMessage(const Event& e, void*) } delete[] argv; - + String logLevel(argBase->m_logFilter); if (!logLevel.empty()) { try { diff --git a/src/lib/barrier/win32/DaemonApp.h b/src/lib/barrier/win32/DaemonApp.h index 2a8484b..e0eb385 100644 --- a/src/lib/barrier/win32/DaemonApp.h +++ b/src/lib/barrier/win32/DaemonApp.h @@ -2,11 +2,11 @@ * barrier -- 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 @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + #pragma once #include "arch/Arch.h" diff --git a/src/lib/base/CMakeLists.txt b/src/lib/base/CMakeLists.txt index 66ba5a6..9bd4472 100644 --- a/src/lib/base/CMakeLists.txt +++ b/src/lib/base/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 diff --git a/src/lib/base/ELevel.h b/src/lib/base/ELevel.h index ec0f94f..45b51d7 100644 --- a/src/lib/base/ELevel.h +++ b/src/lib/base/ELevel.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/Event.cpp b/src/lib/base/Event.cpp index f2c1a12..cc548fc 100644 --- a/src/lib/base/Event.cpp +++ b/src/lib/base/Event.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/Event.h b/src/lib/base/Event.h index 2741813..38a2cf1 100644 --- a/src/lib/base/Event.h +++ b/src/lib/base/Event.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -71,7 +71,7 @@ public: Deletes event data for the given event (using free()). */ static void deleteData(const Event&); - + //! Set data (non-POD) /*! Set non-POD (non plain old data), where delete is called when the event @@ -114,7 +114,7 @@ public: Returns the event flags. */ Flags getFlags() const; - + //@} private: diff --git a/src/lib/base/EventQueue.cpp b/src/lib/base/EventQueue.cpp index 2429522..7764ed8 100644 --- a/src/lib/base/EventQueue.cpp +++ b/src/lib/base/EventQueue.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -100,7 +100,7 @@ EventQueue::~EventQueue() delete m_buffer; delete m_readyCondVar; delete m_readyMutex; - + ARCH->setSignalHandler(Arch::kINTERRUPT, NULL, NULL); ARCH->setSignalHandler(Arch::kTERMINATE, NULL, NULL); } @@ -121,7 +121,7 @@ EventQueue::loop() addEventToBuffer(event); m_pending.pop(); } - + Event event; getEvent(event); while (event.getType() != Event::kQuit) { @@ -298,7 +298,7 @@ EventQueue::addEvent(const Event& event) default: break; } - + if ((event.getFlags() & Event::kDeliverImmediately) != 0) { dispatchEvent(event); Event::deleteData(event); @@ -315,10 +315,10 @@ void EventQueue::addEventToBuffer(const Event& event) { std::lock_guard lock(m_mutex); - + // store the event's data locally UInt32 eventID = saveEvent(event); - + // add it if (!m_buffer->addEvent(eventID)) { // failed to send event @@ -568,7 +568,7 @@ EventQueue::waitForReady() const { double timeout = ARCH->time() + 10; Lock lock(m_readyMutex); - + while (!m_readyCondVar->wait()) { if (ARCH->time() > timeout) { throw std::runtime_error("event queue is not ready within 5 sec"); diff --git a/src/lib/base/EventQueue.h b/src/lib/base/EventQueue.h index 842c5ca..55b6fce 100644 --- a/src/lib/base/EventQueue.h +++ b/src/lib/base/EventQueue.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -71,7 +71,7 @@ private: double getNextTimerTimeout() const; void addEventToBuffer(const Event& event); bool parent_requests_shutdown() const; - + private: class Timer { public: diff --git a/src/lib/base/EventTypes.cpp b/src/lib/base/EventTypes.cpp index 2ba2077..173a0a9 100644 --- a/src/lib/base/EventTypes.cpp +++ b/src/lib/base/EventTypes.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2013-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 @@ -56,6 +56,7 @@ REGISTER_EVENT(IStream, outputFlushed) REGISTER_EVENT(IStream, outputError) REGISTER_EVENT(IStream, inputShutdown) REGISTER_EVENT(IStream, outputShutdown) +REGISTER_EVENT(IStream, inputFormatError) // // IpcClient diff --git a/src/lib/base/EventTypes.h b/src/lib/base/EventTypes.h index f81617e..995490e 100644 --- a/src/lib/base/EventTypes.h +++ b/src/lib/base/EventTypes.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2013-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 @@ -133,14 +133,20 @@ public: */ Event::Type outputShutdown(); + /** Get input format error event type + + This is sent when a stream receives an irrecoverable input format error. + */ + Event::Type inputFormatError(); //@} - + private: Event::Type m_inputReady; Event::Type m_outputFlushed; Event::Type m_outputError; Event::Type m_inputShutdown; Event::Type m_outputShutdown; + Event::Type m_inputFormatError; }; class IpcClientEvents : public EventTypes { @@ -159,7 +165,7 @@ public: Event::Type messageReceived(); //@} - + private: Event::Type m_connected; Event::Type m_messageReceived; @@ -179,7 +185,7 @@ public: //! Raised when the client disconnects from the server. Event::Type disconnected(); - + //@} private: @@ -198,7 +204,7 @@ public: //! Raised when we have created the client proxy. Event::Type clientConnected(); - + //! Raised when a message is received through a client proxy. Event::Type messageReceived(); @@ -242,7 +248,7 @@ public: event when a remote connection has been established. */ Event::Type connected(); - + //! Get secure connected event type /*! Returns the secure socket connected event type. A secure socket sends @@ -342,14 +348,14 @@ public: //! @name accessors //@{ - + //! Get accepted event type /*! Returns the accepted event type. This is sent whenever a server accepts a client. */ Event::Type accepted(); - + //! Get connected event type /*! Returns the connected event type. This is sent whenever a @@ -419,7 +425,7 @@ public: Event::Type failure(); //@} - + private: Event::Type m_success; Event::Type m_failure; @@ -510,7 +516,7 @@ public: Event::Type screenSwitched(); //@} - + private: Event::Type m_error; Event::Type m_connected; @@ -529,16 +535,16 @@ public: m_reloadConfig(Event::kUnknown), m_forceReconnect(Event::kUnknown), m_resetServer(Event::kUnknown) { } - + //! @name accessors //@{ - + Event::Type reloadConfig(); Event::Type forceReconnect(); Event::Type resetServer(); //@} - + private: Event::Type m_reloadConfig; Event::Type m_forceReconnect; @@ -565,7 +571,7 @@ public: Event::Type keyRepeat(); //@} - + private: Event::Type m_keyDown; Event::Type m_keyUp; @@ -589,7 +595,7 @@ public: //! @name accessors //@{ - + //! button down event type. Event data is ButtonInfo*. Event::Type buttonDown(); @@ -677,7 +683,7 @@ public: to sleep or a user session is deactivated (fast user switching). */ Event::Type suspend(); - + //! Get resume event type /*! Returns the resume event type. This is sent whenever the system wakes @@ -686,7 +692,7 @@ public: Event::Type resume(); //@} - + private: Event::Type m_error; Event::Type m_shapeChanged; @@ -722,7 +728,7 @@ public: //! Clipboard sending event type /*! - Returns the clipboard sending event type. This is used to send + Returns the clipboard sending event type. This is used to send clipboard chunks. */ Event::Type clipboardSending(); diff --git a/src/lib/base/FunctionEventJob.cpp b/src/lib/base/FunctionEventJob.cpp index 705e058..751b50d 100644 --- a/src/lib/base/FunctionEventJob.cpp +++ b/src/lib/base/FunctionEventJob.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/FunctionEventJob.h b/src/lib/base/FunctionEventJob.h index 4b2c2fc..3d9acaa 100644 --- a/src/lib/base/FunctionEventJob.h +++ b/src/lib/base/FunctionEventJob.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/FunctionJob.cpp b/src/lib/base/FunctionJob.cpp deleted file mode 100644 index 859010e..0000000 --- a/src/lib/base/FunctionJob.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2012-2016 Symless Ltd. - * Copyright (C) 2002 Chris Schoeneman - * - * 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 "base/FunctionJob.h" - -// -// FunctionJob -// - -FunctionJob::FunctionJob(void (*func)(void*), void* arg) : - m_func(func), - m_arg(arg) -{ - // do nothing -} - -FunctionJob::~FunctionJob() -{ - // do nothing -} - -void -FunctionJob::run() -{ - if (m_func != NULL) { - m_func(m_arg); - } -} diff --git a/src/lib/base/FunctionJob.h b/src/lib/base/FunctionJob.h deleted file mode 100644 index 9cdfa9d..0000000 --- a/src/lib/base/FunctionJob.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2012-2016 Symless Ltd. - * Copyright (C) 2002 Chris Schoeneman - * - * 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 "base/IJob.h" - -//! Use a function as a job -/*! -A job class that invokes a function. -*/ -class FunctionJob : public IJob { -public: - //! run() invokes \c func(arg) - FunctionJob(void (*func)(void*), void* arg = NULL); - virtual ~FunctionJob(); - - // IJob overrides - virtual void run(); - -private: - void (*m_func)(void*); - void* m_arg; -}; diff --git a/src/lib/base/IEventJob.h b/src/lib/base/IEventJob.h index 3e4a420..844cc4a 100644 --- a/src/lib/base/IEventJob.h +++ b/src/lib/base/IEventJob.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/IEventQueue.h b/src/lib/base/IEventQueue.h index 150595c..833081c 100644 --- a/src/lib/base/IEventQueue.h +++ b/src/lib/base/IEventQueue.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -184,7 +184,7 @@ public: be added. */ virtual void waitForReady() const = 0; - + //@} //! @name accessors //@{ @@ -216,7 +216,7 @@ public: virtual void* getSystemTarget() = 0; //@} - + // // Event type providers. // diff --git a/src/lib/base/IEventQueueBuffer.h b/src/lib/base/IEventQueueBuffer.h index b594436..f25cc66 100644 --- a/src/lib/base/IEventQueueBuffer.h +++ b/src/lib/base/IEventQueueBuffer.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -38,7 +38,7 @@ public: //! @name manipulators //@{ - + //! Initialize /*! Useful for platform-specific initialisation from a specific thread. diff --git a/src/lib/base/IJob.h b/src/lib/base/IJob.h index f966ec0..29aa941 100644 --- a/src/lib/base/IJob.h +++ b/src/lib/base/IJob.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/ILogOutputter.h b/src/lib/base/ILogOutputter.h index ab218fc..e11f9e2 100644 --- a/src/lib/base/ILogOutputter.h +++ b/src/lib/base/ILogOutputter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/Log.cpp b/src/lib/base/Log.cpp index a3b328d..8f52a80 100644 --- a/src/lib/base/Log.cpp +++ b/src/lib/base/Log.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -25,7 +25,7 @@ #include #include #include -#include +#include // names of priorities static const char* g_priority[] = { @@ -62,7 +62,7 @@ Log::Log() { assert(s_log == NULL); - // other initalization + // other initialization m_maxPriority = g_defaultMaxPriority; m_maxNewlineLength = 0; insert(new ConsoleLogOutputter); @@ -145,7 +145,7 @@ Log::print(const char* file, int line, const char* fmt, ...) // try printing into the buffer va_list args; va_start(args, fmt); - int n = ARCH->vsnprintf(buffer, len - sPad, fmt, args); + int n = std::vsnprintf(buffer, len - sPad, fmt, args); va_end(args); // if the buffer wasn't big enough then make it bigger and try again diff --git a/src/lib/base/Log.h b/src/lib/base/Log.h index 0ed458f..22224b9 100644 --- a/src/lib/base/Log.h +++ b/src/lib/base/Log.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -91,7 +91,7 @@ public: then it simply returns true. */ bool setFilter(const char* name); - + //! Set the minimum priority filter (by ordinal). void setFilter(int); @@ -193,9 +193,9 @@ otherwise it expands to a call that doesn't. #define CLOG_TRACE __FILE__, __LINE__, #endif -// the CLOG_* defines are line and file plus %z and an octal number (060=0, -// 071=9), but the limitation is that once we run out of numbers at either -// end, then we resort to using non-numerical chars. this still works (since +// the CLOG_* defines are line and file plus %z and an octal number (060=0, +// 071=9), but the limitation is that once we run out of numbers at either +// end, then we resort to using non-numerical chars. this still works (since // to deduce the number we subtract octal \060, so '/' is -1, and ':' is 10 #define CLOG_PRINT CLOG_TRACE "%z\057" // char is '/' diff --git a/src/lib/base/PriorityQueue.h b/src/lib/base/PriorityQueue.h index d2ca70e..8aac88c 100644 --- a/src/lib/base/PriorityQueue.h +++ b/src/lib/base/PriorityQueue.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/SimpleEventQueueBuffer.cpp b/src/lib/base/SimpleEventQueueBuffer.cpp index b55fe55..a26f255 100644 --- a/src/lib/base/SimpleEventQueueBuffer.cpp +++ b/src/lib/base/SimpleEventQueueBuffer.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/SimpleEventQueueBuffer.h b/src/lib/base/SimpleEventQueueBuffer.h index 4aa76d3..db6a502 100644 --- a/src/lib/base/SimpleEventQueueBuffer.h +++ b/src/lib/base/SimpleEventQueueBuffer.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -28,7 +28,7 @@ An event queue buffer provides a queue of events for an IEventQueue. */ class SimpleEventQueueBuffer : public IEventQueueBuffer { public: - SimpleEventQueueBuffer(); + SimpleEventQueueBuffer(); ~SimpleEventQueueBuffer(); // IEventQueueBuffer overrides diff --git a/src/lib/base/Stopwatch.cpp b/src/lib/base/Stopwatch.cpp index b9ceb85..a174ea6 100644 --- a/src/lib/base/Stopwatch.cpp +++ b/src/lib/base/Stopwatch.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/Stopwatch.h b/src/lib/base/Stopwatch.h index dda74ea..81098fd 100644 --- a/src/lib/base/Stopwatch.h +++ b/src/lib/base/Stopwatch.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -88,7 +88,7 @@ public: */ bool isStopped() const; - // return the time since the last reset(). + // return the time since the last reset(). //! Get elapsed time /*! Returns the time since the last reset(). This cannot trigger the diff --git a/src/lib/base/String.cpp b/src/lib/base/String.cpp index 1ab3623..adbb11d 100644 --- a/src/lib/base/String.cpp +++ b/src/lib/base/String.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-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 @@ -35,6 +35,42 @@ namespace barrier { namespace string { +namespace { + +// returns negative in case of non-matching character +int hex_to_number(char ch) +{ + switch (ch) { + case '0': return 0; + case '1': return 1; + case '2': return 2; + case '3': return 3; + case '4': return 4; + case '5': return 5; + case '6': return 6; + case '7': return 7; + case '8': return 8; + case '9': return 9; + + case 'a': return 10; + case 'b': return 11; + case 'c': return 12; + case 'd': return 13; + case 'e': return 14; + case 'f': return 15; + + case 'A': return 10; + case 'B': return 11; + case 'C': return 12; + case 'D': return 13; + case 'E': return 14; + case 'F': return 15; + } + return -1; +} + +} // namespace + std::string format(const char* fmt, ...) { @@ -135,7 +171,7 @@ sprintf(const char* fmt, ...) // try printing into the buffer va_list args; va_start(args, fmt); - int n = ARCH->vsnprintf(buffer, len, fmt, args); + int n = std::vsnprintf(buffer, len, fmt, args); va_end(args); // if the buffer wasn't big enough then make it bigger and try again @@ -185,16 +221,42 @@ removeFileExt(std::string filename) return filename.substr(0, dot); } -void -toHex(std::string& subject, int width, const char fill) +std::string to_hex(const std::vector& subject, int width, const char fill) { std::stringstream ss; ss << std::hex; - for (unsigned int i = 0; i < subject.length(); i++) { - ss << std::setw(width) << std::setfill(fill) << (int)(unsigned char)subject[i]; + for (unsigned int i = 0; i < subject.size(); i++) { + ss << std::setw(width) << std::setfill(fill) << static_cast(subject[i]); } - subject = ss.str(); + return ss.str(); +} + +std::vector from_hex(const std::string& data) +{ + std::vector result; + result.reserve(data.size() / 2); + + std::size_t i = 0; + while (i < data.size()) { + if (data[i] == ':') { + i++; + continue; + } + + if (i + 2 > data.size()) { + return {}; // uneven character count follows, it's unclear how to interpret it + } + + auto high = hex_to_number(data[i]); + auto low = hex_to_number(data[i + 1]); + if (high < 0 || low < 0) { + return {}; + } + result.push_back(high * 16 + low); + i += 2; + } + return result; } void diff --git a/src/lib/base/String.h b/src/lib/base/String.h index 73526b4..9c5a53b 100644 --- a/src/lib/base/String.h +++ b/src/lib/base/String.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -75,7 +75,10 @@ std::string removeFileExt(std::string filename); /*! Convert each character in \c subject into hexdecimal form with \c width */ -void toHex(std::string& subject, int width, const char fill = '0'); +std::string to_hex(const std::vector& subject, int width, const char fill = '0'); + +/// Convert binary data from hexadecimal +std::vector from_hex(const std::string& data); //! Convert to all uppercase /*! diff --git a/src/lib/base/TMethodEventJob.h b/src/lib/base/TMethodEventJob.h index a65f8c9..04a36fd 100644 --- a/src/lib/base/TMethodEventJob.h +++ b/src/lib/base/TMethodEventJob.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/TMethodJob.h b/src/lib/base/TMethodJob.h deleted file mode 100644 index ec88f05..0000000 --- a/src/lib/base/TMethodJob.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2012-2016 Symless Ltd. - * Copyright (C) 2002 Chris Schoeneman - * - * 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 "IJob.h" - -//! Use a function as a job -/*! -A job class that invokes a member function. -*/ -template -class TMethodJob : public IJob { -public: - //! run() invokes \c object->method(arg) - TMethodJob(T* object, void (T::*method)(void*), void* arg = NULL); - virtual ~TMethodJob(); - - // IJob overrides - virtual void run(); - -private: - T* m_object; - void (T::*m_method)(void*); - void* m_arg; -}; - -template -inline -TMethodJob::TMethodJob(T* object, void (T::*method)(void*), void* arg) : - m_object(object), - m_method(method), - m_arg(arg) -{ - // do nothing -} - -template -inline -TMethodJob::~TMethodJob() -{ - // do nothing -} - -template -inline -void -TMethodJob::run() -{ - if (m_object != NULL) { - (m_object->*m_method)(m_arg); - } -} diff --git a/src/lib/base/Unicode.cpp b/src/lib/base/Unicode.cpp index 05b0212..2bd0360 100644 --- a/src/lib/base/Unicode.cpp +++ b/src/lib/base/Unicode.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/Unicode.h b/src/lib/base/Unicode.h index 9bf83ae..430bb1b 100644 --- a/src/lib/base/Unicode.h +++ b/src/lib/base/Unicode.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/XBase.cpp b/src/lib/base/XBase.cpp index cb0db2e..b7a7baf 100644 --- a/src/lib/base/XBase.cpp +++ b/src/lib/base/XBase.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/XBase.h b/src/lib/base/XBase.h index 59b700e..0b46750 100644 --- a/src/lib/base/XBase.h +++ b/src/lib/base/XBase.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/base/finally.h b/src/lib/base/finally.h new file mode 100644 index 0000000..f3be617 --- /dev/null +++ b/src/lib/base/finally.h @@ -0,0 +1,61 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 BARRIER_LIB_BASE_FINALLY_H +#define BARRIER_LIB_BASE_FINALLY_H + +#include + +namespace barrier { + +// this implements a common pattern of executing an action at the end of function + +template +class final_action { +public: + final_action() noexcept {} + final_action(Callable callable) noexcept : callable_{callable} {} + + ~final_action() noexcept + { + if (!invoked_) { + callable_(); + } + } + + final_action(final_action&& other) noexcept : + callable_{std::move(other.callable_)} + { + std::swap(invoked_, other.invoked_); + } + + final_action(const final_action&) = delete; + final_action& operator=(const final_action&) = delete; +private: + bool invoked_ = false; + Callable callable_; +}; + +template +inline final_action finally(Callable&& callable) noexcept +{ + return final_action(std::forward(callable)); +} + +} // namespace barrier + +#endif // BARRIER_LIB_BASE_FINALLY_H diff --git a/src/lib/base/log_outputters.cpp b/src/lib/base/log_outputters.cpp index af53192..176af2d 100644 --- a/src/lib/base/log_outputters.cpp +++ b/src/lib/base/log_outputters.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -17,10 +17,9 @@ */ #include "base/log_outputters.h" -#include "base/TMethodJob.h" #include "arch/Arch.h" #include "base/String.h" - +#include "io/filesystem.h" #include enum EFileLogOutputter { @@ -260,7 +259,7 @@ FileLogOutputter::write(ELevel level, const char *message) bool moveFile = false; std::ofstream m_handle; - m_handle.open(m_fileName.c_str(), std::fstream::app); + barrier::open_utf8_path(m_handle, m_fileName, std::fstream::app); if (m_handle.is_open() && m_handle.fail() != true) { m_handle << message << std::endl; @@ -305,7 +304,7 @@ MesssageBoxLogOutputter::~MesssageBoxLogOutputter() } void -MesssageBoxLogOutputter::open(const char* title) +MesssageBoxLogOutputter::open(const char* title) { // do nothing } diff --git a/src/lib/base/log_outputters.h b/src/lib/base/log_outputters.h index 15f1e7a..2a84170 100644 --- a/src/lib/base/log_outputters.h +++ b/src/lib/base/log_outputters.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/client/CMakeLists.txt b/src/lib/client/CMakeLists.txt index 97dc9db..033876f 100644 --- a/src/lib/client/CMakeLists.txt +++ b/src/lib/client/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp index 96d2c67..a7b15cf 100644 --- a/src/lib/client/Client.cpp +++ b/src/lib/client/Client.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -37,7 +37,6 @@ #include "base/Log.h" #include "base/IEventQueue.h" #include "base/TMethodEventJob.h" -#include "base/TMethodJob.h" #include #include @@ -127,6 +126,12 @@ Client::connect() return; } + auto security_level = ConnectionSecurityLevel::PLAINTEXT; + if (m_useSecureNetwork) { + // client always authenticates server + security_level = ConnectionSecurityLevel::ENCRYPTED_AUTHENTICATED; + } + try { // resolve the server hostname. do this every time we connect // in case we couldn't resolve the address earlier or the address @@ -134,20 +139,19 @@ Client::connect() // being shuttled between various networks). patch by Brent // Priddy. m_serverAddress.resolve(); - + // m_serverAddress will be null if the hostname address is not reolved if (m_serverAddress.getAddress() != NULL) { // to help users troubleshoot, show server host name (issue: 60) - LOG((CLOG_NOTE "connecting to '%s': %s:%i", + LOG((CLOG_NOTE "connecting to '%s': %s:%i", m_serverAddress.getHostname().c_str(), ARCH->addrToString(m_serverAddress.getAddress()).c_str(), m_serverAddress.getPort())); } // create the socket - IDataSocket* socket = m_socketFactory->create( - ARCH->getAddrFamily(m_serverAddress.getAddress()), - m_useSecureNetwork); + IDataSocket* socket = m_socketFactory->create(ARCH->getAddrFamily(m_serverAddress.getAddress()), + security_level); m_socket = dynamic_cast(socket); // filter socket messages, including a packetizing filter @@ -255,7 +259,7 @@ Client::leave() m_active = false; m_screen->leave(); - + if (m_enableClipboard) { // send clipboards that we own and that have changed for (ClipboardID id = 0; id < kClipboardEnd; ++id) { @@ -755,9 +759,7 @@ void Client::onFileRecieveCompleted() { if (isReceivedFileSizeValid()) { - m_writeToDropDirThread = new Thread( - new TMethodJob( - this, &Client::writeToDropDirThread)); + m_writeToDropDirThread = new Thread([this](){ write_to_drop_dir_thread(); }); } } @@ -767,15 +769,14 @@ Client::handleStopRetry(const Event&, void*) m_args.m_restartable = false; } -void -Client::writeToDropDirThread(void*) +void Client::write_to_drop_dir_thread() { LOG((CLOG_DEBUG "starting write to drop dir thread")); while (m_screen->isFakeDraggingStarted()) { ARCH->sleep(.1f); } - + DropHelper::writeToDir(m_screen->getDropTarget(), m_dragFileList, m_receivedFileData); } @@ -790,7 +791,7 @@ Client::dragInfoReceived(UInt32 fileNum, std::string data) } DragInformation::parseDragInfo(m_dragFileList, fileNum, data); - + m_screen->startDraggingFiles(m_dragFileList); } @@ -806,19 +807,14 @@ Client::sendFileToServer(const char* filename) if (m_sendFileThread != NULL) { StreamChunker::interruptFile(); } - - m_sendFileThread = new Thread( - new TMethodJob( - this, &Client::sendFileThread, - static_cast(const_cast(filename)))); + + m_sendFileThread = new Thread([this, filename]() { send_file_thread(filename); }); } -void -Client::sendFileThread(void* filename) +void Client::send_file_thread(const char* filename) { try { - char* name = static_cast(filename); - StreamChunker::sendFile(name, m_events, this); + StreamChunker::sendFile(filename, m_events, this); } catch (std::runtime_error& error) { LOG((CLOG_ERR "failed sending file chunks: %s", error.what())); diff --git a/src/lib/client/Client.h b/src/lib/client/Client.h index 7e566be..c172af2 100644 --- a/src/lib/client/Client.h +++ b/src/lib/client/Client.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -90,11 +90,11 @@ public: //! Create a new thread and use it to send file to Server void sendFileToServer(const char* filename); - + //! Send dragging file information back to server void sendDragInfo(UInt32 fileCount, std::string& info, size_t size); - + //@} //! @name accessors //@{ @@ -118,8 +118,8 @@ public: to connect) to. */ NetworkAddress getServerAddress() const; - - //! Return true if recieved file size is valid + + //! Return true if received file size is valid bool isReceivedFileSizeValid(); //! Return expected file size @@ -167,8 +167,8 @@ private: void sendEvent(Event::Type, void*); void sendConnectionFailedEvent(const char* msg); void sendFileChunk(const void* data); - void sendFileThread(void*); - void writeToDropDirThread(void*); + void send_file_thread(const char* filename); + void write_to_drop_dir_thread(); void setupConnecting(); void setupConnection(); void setupScreen(); diff --git a/src/lib/client/ServerProxy.cpp b/src/lib/client/ServerProxy.cpp index c067f13..c6e3576 100644 --- a/src/lib/client/ServerProxy.cpp +++ b/src/lib/client/ServerProxy.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -26,6 +26,7 @@ #include "barrier/ProtocolUtil.h" #include "barrier/option_types.h" #include "barrier/protocol_types.h" +#include "barrier/XBarrier.h" #include "io/IStream.h" #include "base/Log.h" #include "base/IEventQueue.h" @@ -124,17 +125,27 @@ ServerProxy::handleData(const Event&, void*) // parse message LOG((CLOG_DEBUG2 "msg from server: %c%c%c%c", code[0], code[1], code[2], code[3])); - switch ((this->*m_parser)(code)) { - case kOkay: - break; - - case kUnknown: - LOG((CLOG_ERR "invalid message from server: %c%c%c%c", code[0], code[1], code[2], code[3])); + try { + switch ((this->*m_parser)(code)) { + case kOkay: + break; + + case kUnknown: + LOG((CLOG_ERR "invalid message from server: %c%c%c%c", code[0], code[1], code[2], code[3])); + m_client->disconnect("invalid message from server"); + return; + + case kDisconnect: + return; + } + } catch (const XBadClient& e) { + // TODO: disconnect handling is currently dispersed across both parseMessage() and + // handleData() functions, we should collect that to a single place + + LOG((CLOG_ERR "protocol error from server: %s", e.what())); + ProtocolUtil::writef(m_stream, kMsgEBad); m_client->disconnect("invalid message from server"); return; - - case kDisconnect: - return; } // next message @@ -553,7 +564,7 @@ ServerProxy::setClipboard() static std::string dataCached; ClipboardID id; UInt32 seq; - + int r = ClipboardChunk::assemble(m_stream, dataCached, id, seq); if (r == kStart) { @@ -562,7 +573,7 @@ ServerProxy::setClipboard() } else if (r == kFinish) { LOG((CLOG_DEBUG "received clipboard %d size=%d", id, dataCached.size())); - + // forward Clipboard clipboard; clipboard.unmarshall(dataCached, 0); diff --git a/src/lib/client/ServerProxy.h b/src/lib/client/ServerProxy.h index abca4c3..12a3226 100644 --- a/src/lib/client/ServerProxy.h +++ b/src/lib/client/ServerProxy.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -58,8 +58,8 @@ public: // sending dragging information to server void sendDragInfo(UInt32 fileCount, const char* info, size_t size); - -#ifdef TEST_ENV + +#ifdef BARRIER_TEST_ENV void handleDataForTest() { handleData(Event(), NULL); } #endif diff --git a/src/lib/common/CMakeLists.txt b/src/lib/common/CMakeLists.txt index b3791c1..82ca614 100644 --- a/src/lib/common/CMakeLists.txt +++ b/src/lib/common/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 diff --git a/src/lib/common/DataDirectories.h b/src/lib/common/DataDirectories.h index 6b990c2..4550211 100644 --- a/src/lib/common/DataDirectories.h +++ b/src/lib/common/DataDirectories.h @@ -15,27 +15,36 @@ * along with this program. If not, see . */ -#pragma once +#ifndef BARRIER_LIB_COMMON_DATA_DIRECTORIES_H +#define BARRIER_LIB_COMMON_DATA_DIRECTORIES_H -#include +#include "io/filesystem.h" + +namespace barrier { class DataDirectories { public: - static const std::string& profile(); - static const std::string& profile(const std::string& path); + static const fs::path& profile(); + static const fs::path& profile(const fs::path& path); - static const std::string& global(); - static const std::string& global(const std::string& path); + static const fs::path& global(); + static const fs::path& global(const fs::path& path); - static const std::string& systemconfig(); - static const std::string& systemconfig(const std::string& path); + static const fs::path& systemconfig(); + static const fs::path& systemconfig(const fs::path& path); + static fs::path ssl_fingerprints_path(); + static fs::path local_ssl_fingerprints_path(); + static fs::path trusted_servers_ssl_fingerprints_path(); + static fs::path trusted_clients_ssl_fingerprints_path(); + static fs::path ssl_certificate_path(); private: - // static class - DataDirectories() {} - - static std::string _profile; - static std::string _global; - static std::string _systemconfig; + static fs::path _profile; + static fs::path _global; + static fs::path _systemconfig; }; + +} // namespace barrier + +#endif diff --git a/src/lib/common/DataDirectories_static.cpp b/src/lib/common/DataDirectories_static.cpp index 48dccb6..47f88e7 100644 --- a/src/lib/common/DataDirectories_static.cpp +++ b/src/lib/common/DataDirectories_static.cpp @@ -17,7 +17,40 @@ #include "DataDirectories.h" -// static member -std::string DataDirectories::_profile; -std::string DataDirectories::_global; -std::string DataDirectories::_systemconfig; +namespace barrier { + +fs::path DataDirectories::_profile; +fs::path DataDirectories::_global; +fs::path DataDirectories::_systemconfig; + +static const char kFingerprintsDirName[] = "SSL/Fingerprints"; +static const char kFingerprintsLocalFilename[] = "Local.txt"; +static const char kFingerprintsTrustedServersFilename[] = "TrustedServers.txt"; +static const char kFingerprintsTrustedClientsFilename[] = "TrustedClients.txt"; + +fs::path DataDirectories::ssl_fingerprints_path() +{ + return profile() / kFingerprintsDirName; +} + +fs::path DataDirectories::local_ssl_fingerprints_path() +{ + return ssl_fingerprints_path() / kFingerprintsLocalFilename; +} + +fs::path DataDirectories::trusted_servers_ssl_fingerprints_path() +{ + return ssl_fingerprints_path() / kFingerprintsTrustedServersFilename; +} + +fs::path DataDirectories::trusted_clients_ssl_fingerprints_path() +{ + return ssl_fingerprints_path() / kFingerprintsTrustedClientsFilename; +} + +fs::path DataDirectories::ssl_certificate_path() +{ + return profile() / "SSL" / "Barrier.pem"; +} + +} // namespace barrier diff --git a/src/lib/common/IInterface.h b/src/lib/common/IInterface.h index 84a76a9..65ede4d 100644 --- a/src/lib/common/IInterface.h +++ b/src/lib/common/IInterface.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/MacOSXPrecomp.h b/src/lib/common/MacOSXPrecomp.h deleted file mode 100644 index 7dbc8d0..0000000 --- a/src/lib/common/MacOSXPrecomp.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2012-2016 Symless Ltd. - * Copyright (C) 2002 Chris Schoeneman - * - * 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 . - */ - - // -// Prefix header for all source files of the 'deleteme' target in the 'deleteme' project. -// - -#include diff --git a/src/lib/common/PathUtilities.cpp b/src/lib/common/PathUtilities.cpp deleted file mode 100644 index a2ab38a..0000000 --- a/src/lib/common/PathUtilities.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -* barrier -- mouse and keyboard sharing utility -* Copyright (C) 2018 Debauchee Open Source Group -* -* 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 . -*/ - -/* - -These functions cover the vast majority of cases for different paths across -windows and unixes. They are not, however, fullproof and probably don't cover -fringe cases very well. The library below might be used as an alternative if -these implementations prove to be insufficient. As the library's readme states -it is simply a temporary band-aid until std::filesystem is integrated (C++17 -has it in std::experimental) and this class should also be treated as such. - -https://github.com/wjakob/filesystem/ - -*/ - -#include "PathUtilities.h" - -// keep the default platform delimiter as the first in the list -#ifdef _WIN32 -static const char *Delimiters = "\\/"; -#else -static const char *Delimiters = "/"; -#endif - -static const char DefaultDelimiter = Delimiters[0]; - -std::string PathUtilities::basename(const std::string& path) -{ - return path.substr(path.find_last_of(Delimiters) + 1); -} - -std::string PathUtilities::concat(const std::string& left, const std::string& right) -{ - // although npos is usually (-1) we can't count on that so handle it explicitly - auto leftEnd = left.find_last_not_of(Delimiters); - if (leftEnd == std::string::npos) - leftEnd = 0; - else - ++leftEnd; - auto rightStart = right.find_first_not_of(Delimiters, 0); - if (rightStart == std::string::npos) { - // both left/right are empty - if (left.size() == 0 && right.size() == 0) - return ""; - // right is full of delims, left is okay - if (leftEnd > 0) - return left.substr(0, leftEnd); - // both left/right useless but at least one has delims - return std::string(1, DefaultDelimiter); - } - if (leftEnd == 0) { - // right is okay and not prefixed with delims, left is empty - if (left.size() == 0 && rightStart == 0) - return right.substr(rightStart); - // (right is okay and prefixed with delims) OR left is full of delims - return DefaultDelimiter + right.substr(rightStart); - } - // concatenation using both left and right - return left.substr(0, leftEnd) + DefaultDelimiter + right.substr(rightStart); -} diff --git a/src/lib/common/PathUtilities.h b/src/lib/common/PathUtilities.h deleted file mode 100644 index 70b85b4..0000000 --- a/src/lib/common/PathUtilities.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -* barrier -- mouse and keyboard sharing utility -* Copyright (C) 2018 Debauchee Open Source Group -* -* 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 - -class PathUtilities -{ -public: - static std::string basename(const std::string& path); - static std::string concat(const std::string& left, const std::string& right); - -private: - // static class - PathUtilities() {} -}; diff --git a/src/lib/common/Version.cpp b/src/lib/common/Version.cpp index 94d6c5d..41d2804 100644 --- a/src/lib/common/Version.cpp +++ b/src/lib/common/Version.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/Version.h b/src/lib/common/Version.h index 66bb2e2..ad4a3e7 100644 --- a/src/lib/common/Version.h +++ b/src/lib/common/Version.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/basic_types.h b/src/lib/common/basic_types.h index f84550c..1882e57 100644 --- a/src/lib/common/basic_types.h +++ b/src/lib/common/basic_types.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -18,49 +18,7 @@ #pragma once -#include "common/common.h" - -// -// pick types of particular sizes -// - -#if !defined(TYPE_OF_SIZE_1) -# if SIZEOF_CHAR == 1 -# define TYPE_OF_SIZE_1 char -# endif -#endif - -#if !defined(TYPE_OF_SIZE_2) -# if SIZEOF_INT == 2 -# define TYPE_OF_SIZE_2 int -# else -# define TYPE_OF_SIZE_2 short -# endif -#endif - -#if !defined(TYPE_OF_SIZE_4) - // Carbon defines SInt32 and UInt32 in terms of long -# if SIZEOF_INT == 4 && !defined(__APPLE__) -# define TYPE_OF_SIZE_4 int -# else -# define TYPE_OF_SIZE_4 long -# endif -#endif - - // -// verify existence of required types -// - -#if !defined(TYPE_OF_SIZE_1) -# error No 1 byte integer type -#endif -#if !defined(TYPE_OF_SIZE_2) -# error No 2 byte integer type -#endif -#if !defined(TYPE_OF_SIZE_4) -# error No 4 byte integer type -#endif - +#include // // make typedefs @@ -75,18 +33,11 @@ #if defined(__APPLE__) #include #else -typedef signed TYPE_OF_SIZE_1 SInt8; -typedef signed TYPE_OF_SIZE_2 SInt16; -typedef signed TYPE_OF_SIZE_4 SInt32; -typedef unsigned TYPE_OF_SIZE_1 UInt8; -typedef unsigned TYPE_OF_SIZE_2 UInt16; -typedef unsigned TYPE_OF_SIZE_4 UInt32; +using SInt8 = std::int8_t; +using SInt16 = std::int16_t; +using SInt32 = std::int32_t; +using UInt8 = std::uint8_t; +using UInt16 = std::uint16_t; +using UInt32 = std::uint32_t; #endif #endif -// -// clean up -// - -#undef TYPE_OF_SIZE_1 -#undef TYPE_OF_SIZE_2 -#undef TYPE_OF_SIZE_4 diff --git a/src/lib/common/common.h b/src/lib/common/common.h index 5ea215f..3946256 100644 --- a/src/lib/common/common.h +++ b/src/lib/common/common.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -18,26 +18,8 @@ #pragma once -#if defined(_WIN32) -# define SYSAPI_WIN32 1 -# define WINAPI_MSWINDOWS 1 -#elif HAVE_CONFIG_H +#if HAVE_CONFIG_H # include "config.h" -#else -# error "config.h missing" -#endif - -// VC++ has built-in sized types -#if defined(_MSC_VER) -# include -# define TYPE_OF_SIZE_1 __int8 -# define TYPE_OF_SIZE_2 __int16 -# define TYPE_OF_SIZE_4 __int32 -#else -# define SIZE_OF_CHAR 1 -# define SIZE_OF_SHORT 2 -# define SIZE_OF_INT 4 -# define SIZE_OF_LONG 4 #endif // define NULL diff --git a/src/lib/common/stdbitset.h b/src/lib/common/stdbitset.h index 1096249..65433ac 100644 --- a/src/lib/common/stdbitset.h +++ b/src/lib/common/stdbitset.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/stddeque.h b/src/lib/common/stddeque.h index ffaed24..5033826 100644 --- a/src/lib/common/stddeque.h +++ b/src/lib/common/stddeque.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/stdfstream.h b/src/lib/common/stdfstream.h index e9aa263..0328a4b 100644 --- a/src/lib/common/stdfstream.h +++ b/src/lib/common/stdfstream.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/stdistream.h b/src/lib/common/stdistream.h index b19e2ab..2e9c3cc 100644 --- a/src/lib/common/stdistream.h +++ b/src/lib/common/stdistream.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/stdlist.h b/src/lib/common/stdlist.h index d530e57..f1c03e2 100644 --- a/src/lib/common/stdlist.h +++ b/src/lib/common/stdlist.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/stdmap.h b/src/lib/common/stdmap.h index 2351074..7a1040e 100644 --- a/src/lib/common/stdmap.h +++ b/src/lib/common/stdmap.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/stdostream.h b/src/lib/common/stdostream.h index bb82285..10b65d0 100644 --- a/src/lib/common/stdostream.h +++ b/src/lib/common/stdostream.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/stdpost.h b/src/lib/common/stdpost.h index 8046da0..d7f0f9c 100644 --- a/src/lib/common/stdpost.h +++ b/src/lib/common/stdpost.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/stdpre.h b/src/lib/common/stdpre.h index 8ccd308..bf8b9bf 100644 --- a/src/lib/common/stdpre.h +++ b/src/lib/common/stdpre.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/stdset.h b/src/lib/common/stdset.h index 1c98971..e247745 100644 --- a/src/lib/common/stdset.h +++ b/src/lib/common/stdset.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/stdsstream.h b/src/lib/common/stdsstream.h index 43671ff..1bfdd7e 100644 --- a/src/lib/common/stdsstream.h +++ b/src/lib/common/stdsstream.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/stdstring.h b/src/lib/common/stdstring.h index f320ca8..3b3ba0e 100644 --- a/src/lib/common/stdstring.h +++ b/src/lib/common/stdstring.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/stdvector.h b/src/lib/common/stdvector.h index ab4b853..4dd263d 100644 --- a/src/lib/common/stdvector.h +++ b/src/lib/common/stdvector.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/common/unix/DataDirectories.cpp b/src/lib/common/unix/DataDirectories.cpp index 72e510a..cf3ca24 100644 --- a/src/lib/common/unix/DataDirectories.cpp +++ b/src/lib/common/unix/DataDirectories.cpp @@ -18,11 +18,11 @@ #include "../DataDirectories.h" #include // sysconf -#include // getenv +#include // getenv #include // getpwuid(_r) #include // getpwuid(_r) -const std::string ProfileSubdir = "/barrier"; +namespace barrier { static std::string pw_dir(struct passwd* pwentp) { @@ -33,7 +33,7 @@ static std::string pw_dir(struct passwd* pwentp) #ifdef HAVE_GETPWUID_R -static std::string unix_home() +static fs::path unix_home() { long size = -1; #if defined(_SC_GETPW_R_SIZE_MAX) @@ -46,47 +46,47 @@ static std::string unix_home() struct passwd* pwentp; std::string buffer(size, 0); getpwuid_r(getuid(), &pwent, &buffer[0], size, &pwentp); - return pw_dir(pwentp); + return fs::u8path(pw_dir(pwentp)); } #else // not HAVE_GETPWUID_R -static std::string unix_home() +static fs::path unix_home() { - return pw_dir(getpwuid(getuid())); + return fs::u8path(pw_dir(getpwuid(getuid()))); } #endif // HAVE_GETPWUID_R -static std::string profile_basedir() +static fs::path profile_basedir() { #ifdef WINAPI_XWINDOWS // linux/bsd adheres to freedesktop standards // https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html - const char* dir = getenv("XDG_DATA_HOME"); + const char* dir = std::getenv("XDG_DATA_HOME"); if (dir != NULL) - return dir; - return unix_home() + "/.local/share"; + return fs::u8path(dir); + return unix_home() / ".local/share"; #else // macos has its own standards // https://developer.apple.com/library/content/documentation/General/Conceptual/MOSXAppProgrammingGuide/AppRuntime/AppRuntime.html - return unix_home() + "/Library/Application Support"; + return unix_home() / "Library/Application Support"; #endif } -const std::string& DataDirectories::profile() +const fs::path& DataDirectories::profile() { if (_profile.empty()) - _profile = profile_basedir() + ProfileSubdir; + _profile = profile_basedir() / "barrier"; return _profile; } -const std::string& DataDirectories::profile(const std::string& path) +const fs::path& DataDirectories::profile(const fs::path& path) { _profile = path; return _profile; } -const std::string& DataDirectories::global() +const fs::path& DataDirectories::global() { if (_global.empty()) // TODO: where on a unix system should public/global shared data go? @@ -94,21 +94,23 @@ const std::string& DataDirectories::global() _global = "/tmp"; return _global; } -const std::string& DataDirectories::global(const std::string& path) +const fs::path& DataDirectories::global(const fs::path& path) { _global = path; return _global; } -const std::string& DataDirectories::systemconfig() +const fs::path& DataDirectories::systemconfig() { if (_systemconfig.empty()) _systemconfig = "/etc"; return _systemconfig; } -const std::string& DataDirectories::systemconfig(const std::string& path) +const fs::path& DataDirectories::systemconfig(const fs::path& path) { _systemconfig = path; return _systemconfig; } + +} // namespace barrier diff --git a/src/lib/common/win32/DataDirectories.cpp b/src/lib/common/win32/DataDirectories.cpp index 15cb64e..31a428f 100644 --- a/src/lib/common/win32/DataDirectories.cpp +++ b/src/lib/common/win32/DataDirectories.cpp @@ -16,66 +16,62 @@ */ #include "../DataDirectories.h" +#include "encoding_utilities.h" #include -std::string unicode_to_mb(const WCHAR* utfStr) -{ - int utfLength = lstrlenW(utfStr); - int mbLength = WideCharToMultiByte(CP_UTF8, 0, utfStr, utfLength, NULL, 0, NULL, NULL); - std::string mbStr(mbLength, 0); - WideCharToMultiByte(CP_UTF8, 0, utfStr, utfLength, &mbStr[0], mbLength, NULL, NULL); - return mbStr; -} +namespace barrier { -std::string known_folder_path(const KNOWNFOLDERID& id) +fs::path known_folder_path(const KNOWNFOLDERID& id) { - std::string path; + fs::path path; WCHAR* buffer; HRESULT result = SHGetKnownFolderPath(id, 0, NULL, &buffer); if (result == S_OK) { - path = unicode_to_mb(buffer); + path = fs::path(std::wstring(buffer)); CoTaskMemFree(buffer); } return path; } -const std::string& DataDirectories::profile() +const fs::path& DataDirectories::profile() { if (_profile.empty()) - _profile = known_folder_path(FOLDERID_LocalAppData) + "\\Barrier"; + _profile = known_folder_path(FOLDERID_LocalAppData) / "Barrier"; return _profile; } -const std::string& DataDirectories::profile(const std::string& path) +const fs::path& DataDirectories::profile(const fs::path& path) { _profile = path; return _profile; } -const std::string& DataDirectories::global() +const fs::path& DataDirectories::global() { if (_global.empty()) - _global = known_folder_path(FOLDERID_ProgramData) + "\\Barrier"; + _global = known_folder_path(FOLDERID_ProgramData) / "Barrier"; return _global; } -const std::string& DataDirectories::global(const std::string& path) +const fs::path& DataDirectories::global(const fs::path& path) { _global = path; return _global; } -const std::string& DataDirectories::systemconfig() +const fs::path& DataDirectories::systemconfig() { // systemconfig() is a special case in that it will track the current value - // of global() unless and until it is explictly set otherwise + // of global() unless and until it is explicitly set otherwise // previously it would default to the windows folder which was horrible! if (_systemconfig.empty()) return global(); return _systemconfig; } -const std::string& DataDirectories::systemconfig(const std::string& path) +const fs::path& DataDirectories::systemconfig(const fs::path& path) { _systemconfig = path; return _systemconfig; } + +} // namespace barrier diff --git a/src/lib/common/win32/encoding_utilities.cpp b/src/lib/common/win32/encoding_utilities.cpp new file mode 100644 index 0000000..11781d3 --- /dev/null +++ b/src/lib/common/win32/encoding_utilities.cpp @@ -0,0 +1,37 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 "encoding_utilities.h" +#include + +std::string win_wchar_to_utf8(const WCHAR* utfStr) +{ + int utfLength = lstrlenW(utfStr); + int mbLength = WideCharToMultiByte(CP_UTF8, 0, utfStr, utfLength, NULL, 0, NULL, NULL); + std::string mbStr(mbLength, 0); + WideCharToMultiByte(CP_UTF8, 0, utfStr, utfLength, &mbStr[0], mbLength, NULL, NULL); + return mbStr; +} + +std::vector utf8_to_win_char(const std::string& str) +{ + int result_len = MultiByteToWideChar(CP_UTF8, 0, str.data(), str.size(), NULL, 0); + std::vector result; + result.resize(result_len + 1, 0); + MultiByteToWideChar(CP_UTF8, 0, str.data(), str.size(), result.data(), result_len); + return result; +} diff --git a/src/lib/common/win32/encoding_utilities.h b/src/lib/common/win32/encoding_utilities.h new file mode 100644 index 0000000..747371e --- /dev/null +++ b/src/lib/common/win32/encoding_utilities.h @@ -0,0 +1,28 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 BARRIER_LIB_COMMON_WIN32_ENCODING_UTILITIES_H +#define BARRIER_LIB_COMMON_WIN32_ENCODING_UTILITIES_H + +#include +#include +#include + +std::string win_wchar_to_utf8(const WCHAR* utfStr); +std::vector utf8_to_win_char(const std::string& str); + +#endif diff --git a/src/lib/io/CMakeLists.txt b/src/lib/io/CMakeLists.txt index 32ae7ec..10b79df 100644 --- a/src/lib/io/CMakeLists.txt +++ b/src/lib/io/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 diff --git a/src/lib/io/IStream.h b/src/lib/io/IStream.h index cf93ac4..7601fc4 100644 --- a/src/lib/io/IStream.h +++ b/src/lib/io/IStream.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/io/StreamBuffer.cpp b/src/lib/io/StreamBuffer.cpp index 61f05ba..8abbbb8 100644 --- a/src/lib/io/StreamBuffer.cpp +++ b/src/lib/io/StreamBuffer.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -22,6 +22,8 @@ // StreamBuffer // +#include + const UInt32 StreamBuffer::kChunkSize = 4096; StreamBuffer::StreamBuffer() : diff --git a/src/lib/io/StreamBuffer.h b/src/lib/io/StreamBuffer.h index 49b666b..364175f 100644 --- a/src/lib/io/StreamBuffer.h +++ b/src/lib/io/StreamBuffer.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/io/StreamFilter.cpp b/src/lib/io/StreamFilter.cpp index 170e237..dca0a69 100644 --- a/src/lib/io/StreamFilter.cpp +++ b/src/lib/io/StreamFilter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/io/StreamFilter.h b/src/lib/io/StreamFilter.h index e578e0c..55d481e 100644 --- a/src/lib/io/StreamFilter.h +++ b/src/lib/io/StreamFilter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/io/XIO.cpp b/src/lib/io/XIO.cpp index 911fa87..f78e031 100644 --- a/src/lib/io/XIO.cpp +++ b/src/lib/io/XIO.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/io/XIO.h b/src/lib/io/XIO.h index 4964441..5803388 100644 --- a/src/lib/io/XIO.h +++ b/src/lib/io/XIO.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/io/filesystem.cpp b/src/lib/io/filesystem.cpp new file mode 100644 index 0000000..46ae06d --- /dev/null +++ b/src/lib/io/filesystem.cpp @@ -0,0 +1,71 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 . +*/ + +// this header must come first so that it picks up the filesystem implementation +#include + +#include "filesystem.h" +#if SYSAPI_WIN32 +#include "common/win32/encoding_utilities.h" +#endif +#include + +namespace barrier { + +namespace { + +template +void open_utf8_path_impl(Stream& stream, const fs::path& path, std::ios_base::openmode mode) +{ +#if SYSAPI_WIN32 + // on Windows we need to use a non-standard constructor from wchar_t* string + // which fs::path::native() returns + stream.open(path.native().c_str(), mode); +#else + stream.open(path.native().c_str(), mode); +#endif +} + +} // namespace + +void open_utf8_path(std::ifstream& stream, const fs::path& path, std::ios_base::openmode mode) +{ + open_utf8_path_impl(stream, path, mode); +} + +void open_utf8_path(std::ofstream& stream, const fs::path& path, std::ios_base::openmode mode) +{ + open_utf8_path_impl(stream, path, mode); +} + +void open_utf8_path(std::fstream& stream, const fs::path& path, std::ios_base::openmode mode) +{ + open_utf8_path_impl(stream, path, mode); +} + +std::FILE* fopen_utf8_path(const fs::path& path, const std::string& mode) +{ +#if SYSAPI_WIN32 + auto wchar_mode = utf8_to_win_char(mode); + return _wfopen(path.native().c_str(), + reinterpret_cast(wchar_mode.data())); +#else + return std::fopen(path.native().c_str(), mode.c_str()); +#endif +} + +} // namespace barrier diff --git a/src/lib/io/filesystem.h b/src/lib/io/filesystem.h new file mode 100644 index 0000000..78e3423 --- /dev/null +++ b/src/lib/io/filesystem.h @@ -0,0 +1,41 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 BARRIER_LIB_IO_FILESYSTEM_H +#define BARRIER_LIB_IO_FILESYSTEM_H + +#include +#include +#include +#include + +namespace barrier { + +namespace fs = ghc::filesystem; + +void open_utf8_path(std::ifstream& stream, const fs::path& path, + std::ios_base::openmode mode = std::ios_base::in); +void open_utf8_path(std::ofstream& stream, const fs::path& path, + std::ios_base::openmode mode = std::ios_base::out); +void open_utf8_path(std::fstream& stream, const fs::path& path, + std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out); + +std::FILE* fopen_utf8_path(const fs::path& path, const std::string& mode); + +} // namespace barrier + +#endif // BARRIER_LIB_IO_FILESYSTEM_H diff --git a/src/lib/ipc/CMakeLists.txt b/src/lib/ipc/CMakeLists.txt index 3c7302a..e7ada8f 100644 --- a/src/lib/ipc/CMakeLists.txt +++ b/src/lib/ipc/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 diff --git a/src/lib/ipc/Ipc.h b/src/lib/ipc/Ipc.h index bc69c08..65e7aaf 100644 --- a/src/lib/ipc/Ipc.h +++ b/src/lib/ipc/Ipc.h @@ -2,11 +2,11 @@ * barrier -- 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 diff --git a/src/lib/ipc/IpcClient.cpp b/src/lib/ipc/IpcClient.cpp index 4eeae5b..ea5eee1 100644 --- a/src/lib/ipc/IpcClient.cpp +++ b/src/lib/ipc/IpcClient.cpp @@ -2,11 +2,11 @@ * barrier -- 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 diff --git a/src/lib/ipc/IpcClient.h b/src/lib/ipc/IpcClient.h index 1e9bca6..900b46c 100644 --- a/src/lib/ipc/IpcClient.h +++ b/src/lib/ipc/IpcClient.h @@ -2,11 +2,11 @@ * barrier -- 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 @@ -42,7 +42,7 @@ public: //! Connects to the IPC server at localhost. void connect(); - + //! Disconnects from the IPC server. void disconnect(); diff --git a/src/lib/ipc/IpcClientProxy.cpp b/src/lib/ipc/IpcClientProxy.cpp index 432cc8c..cedfa5b 100644 --- a/src/lib/ipc/IpcClientProxy.cpp +++ b/src/lib/ipc/IpcClientProxy.cpp @@ -2,11 +2,11 @@ * barrier -- 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 @@ -67,7 +67,7 @@ IpcClientProxy::~IpcClientProxy() m_events->forIStream().inputShutdown(), m_stream.getEventTarget()); m_events->removeHandler( m_events->forIStream().outputShutdown(), m_stream.getEventTarget()); - + // don't delete the stream while it's being used. { std::lock_guard lock_read(m_readMutex); @@ -145,7 +145,7 @@ IpcClientProxy::send(const IpcMessage& message) ProtocolUtil::writef(&m_stream, kIpcMsgLogLine, &logLine); break; } - + case kIpcShutdown: ProtocolUtil::writef(&m_stream, kIpcMsgShutdown); break; diff --git a/src/lib/ipc/IpcClientProxy.h b/src/lib/ipc/IpcClientProxy.h index eb9f1e9..dbd0846 100644 --- a/src/lib/ipc/IpcClientProxy.h +++ b/src/lib/ipc/IpcClientProxy.h @@ -2,11 +2,11 @@ * barrier -- 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 @@ -46,7 +46,7 @@ private: IpcHelloMessage* parseHello(); IpcCommandMessage* parseCommand(); void disconnect(); - + private: barrier::IStream& m_stream; EIpcClientType m_clientType; diff --git a/src/lib/ipc/IpcLogOutputter.cpp b/src/lib/ipc/IpcLogOutputter.cpp index 44ecdba..5118a0a 100644 --- a/src/lib/ipc/IpcLogOutputter.cpp +++ b/src/lib/ipc/IpcLogOutputter.cpp @@ -2,11 +2,11 @@ * barrier -- 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 @@ -28,7 +28,6 @@ #include "base/Event.h" #include "base/EventQueue.h" #include "base/TMethodEventJob.h" -#include "base/TMethodJob.h" enum EIpcLogOutputter { kBufferMaxSize = 1000, @@ -54,8 +53,7 @@ IpcLogOutputter::IpcLogOutputter(IpcServer& ipcServer, EIpcClientType clientType m_clientType(clientType) { if (useThread) { - m_bufferThread = new Thread(new TMethodJob( - this, &IpcLogOutputter::bufferThread)); + m_bufferThread = new Thread([this](){ buffer_thread(); }); } } @@ -142,8 +140,7 @@ IpcLogOutputter::isRunning() return m_running; } -void -IpcLogOutputter::bufferThread(void*) +void IpcLogOutputter::buffer_thread() { m_bufferThreadId = m_bufferThread->getID(); m_running = true; diff --git a/src/lib/ipc/IpcLogOutputter.h b/src/lib/ipc/IpcLogOutputter.h index cc7b2fe..3f3ab0a 100644 --- a/src/lib/ipc/IpcLogOutputter.h +++ b/src/lib/ipc/IpcLogOutputter.h @@ -2,11 +2,11 @@ * barrier -- 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 @@ -50,7 +50,7 @@ public: virtual void close(); virtual void show(bool showIfEmpty); virtual bool write(ELevel level, const char* message); - + //! @name manipulators //@{ @@ -76,23 +76,23 @@ public: when threaded mode is on. */ void sendBuffer(); - + //@} - + //! @name accessors //@{ - + //! Get the buffer size /*! Returns the maximum size of the buffer. */ UInt16 bufferMaxSize() const; - + //@} private: void init(); - void bufferThread(void*); + void buffer_thread(); std::string getChunk(size_t count); void appendBuffer(const std::string& text); bool isRunning(); diff --git a/src/lib/ipc/IpcMessage.cpp b/src/lib/ipc/IpcMessage.cpp index 9c321cb..f1b13b1 100644 --- a/src/lib/ipc/IpcMessage.cpp +++ b/src/lib/ipc/IpcMessage.cpp @@ -2,11 +2,11 @@ * barrier -- 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 diff --git a/src/lib/ipc/IpcMessage.h b/src/lib/ipc/IpcMessage.h index d37ebc3..06ca08a 100644 --- a/src/lib/ipc/IpcMessage.h +++ b/src/lib/ipc/IpcMessage.h @@ -2,11 +2,11 @@ * barrier -- 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 diff --git a/src/lib/ipc/IpcServer.cpp b/src/lib/ipc/IpcServer.cpp index 8df98d1..da201c1 100644 --- a/src/lib/ipc/IpcServer.cpp +++ b/src/lib/ipc/IpcServer.cpp @@ -2,11 +2,11 @@ * barrier -- 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 diff --git a/src/lib/ipc/IpcServer.h b/src/lib/ipc/IpcServer.h index 179bad8..f6227f2 100644 --- a/src/lib/ipc/IpcServer.h +++ b/src/lib/ipc/IpcServer.h @@ -2,11 +2,11 @@ * barrier -- 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 @@ -73,7 +73,7 @@ private: private: typedef std::list ClientList; - + bool m_mock; IEventQueue* m_events; SocketMultiplexer* m_socketMultiplexer; @@ -82,7 +82,7 @@ private: ClientList m_clients; mutable std::mutex m_clientsMutex; -#ifdef TEST_ENV +#ifdef BARRIER_TEST_ENV public: IpcServer() : m_mock(true), diff --git a/src/lib/ipc/IpcServerProxy.cpp b/src/lib/ipc/IpcServerProxy.cpp index 49b3e00..073f7e7 100644 --- a/src/lib/ipc/IpcServerProxy.cpp +++ b/src/lib/ipc/IpcServerProxy.cpp @@ -2,11 +2,11 @@ * barrier -- 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 @@ -56,7 +56,7 @@ IpcServerProxy::handleData(const Event&, void*) LOG((CLOG_DEBUG "ipc read: %c%c%c%c", code[0], code[1], code[2], code[3])); - + IpcMessage* m = nullptr; if (memcmp(code, kIpcMsgLogLine, 4) == 0) { m = parseLogLine(); @@ -68,7 +68,7 @@ IpcServerProxy::handleData(const Event&, void*) LOG((CLOG_ERR "invalid ipc message")); disconnect(); } - + // don't delete with this event; the data is passed to a new event. Event e(m_events->forIpcServerProxy().messageReceived(), this, NULL, Event::kDontFreeData); e.setDataObject(m); @@ -76,7 +76,7 @@ IpcServerProxy::handleData(const Event&, void*) n = m_stream.read(code, 4); } - + LOG((CLOG_DEBUG "finished ipc handle data")); } @@ -110,7 +110,7 @@ IpcServerProxy::parseLogLine() { std::string logLine; ProtocolUtil::readf(&m_stream, kIpcMsgLogLine + 4, &logLine); - + // must be deleted by event handler. return new IpcLogLineMessage(logLine); } diff --git a/src/lib/ipc/IpcServerProxy.h b/src/lib/ipc/IpcServerProxy.h index f2218a4..f724f97 100644 --- a/src/lib/ipc/IpcServerProxy.h +++ b/src/lib/ipc/IpcServerProxy.h @@ -2,11 +2,11 @@ * barrier -- 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 diff --git a/src/lib/mt/CMakeLists.txt b/src/lib/mt/CMakeLists.txt index 9ee5ea4..19d1829 100644 --- a/src/lib/mt/CMakeLists.txt +++ b/src/lib/mt/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 diff --git a/src/lib/mt/CondVar.cpp b/src/lib/mt/CondVar.cpp index 11318f9..b9cf565 100644 --- a/src/lib/mt/CondVar.cpp +++ b/src/lib/mt/CondVar.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -24,7 +24,7 @@ // CondVarBase // -CondVarBase::CondVarBase(Mutex* mutex) : +CondVarBase::CondVarBase(Mutex* mutex) : m_mutex(mutex) { assert(m_mutex != NULL); diff --git a/src/lib/mt/CondVar.h b/src/lib/mt/CondVar.h index 0ab956b..fc18748 100644 --- a/src/lib/mt/CondVar.h +++ b/src/lib/mt/CondVar.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -78,7 +78,7 @@ public: signalled, otherwise up to \c timeout seconds or until signalled, whichever comes first. Returns true if the object was signalled during the wait, false otherwise. - + The proper way to wait for a condition is: \code cv.lock(); diff --git a/src/lib/mt/Lock.cpp b/src/lib/mt/Lock.cpp index 80721b9..6614858 100644 --- a/src/lib/mt/Lock.cpp +++ b/src/lib/mt/Lock.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/mt/Lock.h b/src/lib/mt/Lock.h index 4a3f311..e4bbacf 100644 --- a/src/lib/mt/Lock.h +++ b/src/lib/mt/Lock.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/mt/Mutex.cpp b/src/lib/mt/Mutex.cpp index e9a62e8..02d34c9 100644 --- a/src/lib/mt/Mutex.cpp +++ b/src/lib/mt/Mutex.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/mt/Mutex.h b/src/lib/mt/Mutex.h index 51a9649..53b8f45 100644 --- a/src/lib/mt/Mutex.h +++ b/src/lib/mt/Mutex.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/mt/Thread.cpp b/src/lib/mt/Thread.cpp index 7474c16..755c0e6 100644 --- a/src/lib/mt/Thread.cpp +++ b/src/lib/mt/Thread.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -28,12 +28,10 @@ // Thread // -Thread::Thread(IJob* job) +Thread::Thread(const std::function& fun) { - m_thread = ARCH->newThread(&Thread::threadFunc, job); + m_thread = ARCH->newThread([=](){ threadFunc(fun); }); if (m_thread == NULL) { - // couldn't create thread - delete job; throw XMTThreadUnavailable(); } } @@ -69,7 +67,7 @@ Thread::operator=(const Thread& thread) void Thread::exit(void* result) { - throw XThreadExit(result); + throw XThreadExit(); } void @@ -108,15 +106,6 @@ Thread::wait(double timeout) const return ARCH->wait(m_thread, timeout); } -void* -Thread::getResult() const -{ - if (wait()) - return ARCH->getResultOfThread(m_thread); - else - return NULL; -} - IArchMultithread::ThreadID Thread::getID() const { @@ -135,8 +124,7 @@ Thread::operator!=(const Thread& thread) const return !ARCH->isSameThread(m_thread, thread.m_thread); } -void* -Thread::threadFunc(void* vjob) +void Thread::threadFunc(const std::function& func) { // get this thread's id for logging IArchMultithread::ThreadID id; @@ -146,42 +134,26 @@ Thread::threadFunc(void* vjob) ARCH->closeThread(thread); } - // get job - IJob* job = static_cast(vjob); - - // run job - void* result = NULL; try { // go LOG((CLOG_DEBUG1 "thread 0x%08x entry", id)); - job->run(); + func(); LOG((CLOG_DEBUG1 "thread 0x%08x exit", id)); } catch (XThreadCancel&) { // client called cancel() LOG((CLOG_DEBUG1 "caught cancel on thread 0x%08x", id)); - delete job; throw; } - catch (XThreadExit& e) { - // client called exit() - result = e.m_result; - LOG((CLOG_DEBUG1 "caught exit on thread 0x%08x, result %p", id, result)); + catch (XThreadExit&) { + LOG((CLOG_DEBUG1 "caught exit on thread 0x%08x", id)); } catch (XBase& e) { LOG((CLOG_ERR "exception on thread 0x%08x: %s", id, e.what())); - delete job; throw; } catch (...) { LOG((CLOG_ERR "exception on thread 0x%08x: ", id)); - delete job; throw; } - - // done with job - delete job; - - // return exit result - return result; } diff --git a/src/lib/mt/Thread.h b/src/lib/mt/Thread.h index a7434fd..141d59f 100644 --- a/src/lib/mt/Thread.h +++ b/src/lib/mt/Thread.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -19,13 +19,12 @@ #pragma once #include "arch/IArchMultithread.h" - -class IJob; +#include //! Thread handle /*! Creating a Thread creates a new context of execution (i.e. thread) that -runs simulatenously with the calling thread. A Thread is only a handle +runs simultaneously with the calling thread. A Thread is only a handle to a thread; deleting a Thread does not cancel or destroy the thread it refers to and multiple Thread objects can refer to the same thread. @@ -44,10 +43,9 @@ class Thread { public: //! Run \c adoptedJob in a new thread /*! - Create and start a new thread executing the \c adoptedJob. The - new thread takes ownership of \c adoptedJob and will delete it. + Create and start a new thread executing the \c fun. */ - Thread(IJob* adoptedJob); + Thread(const std::function& fun); //! Duplicate a thread handle /*! @@ -79,8 +77,7 @@ public: /*! Terminate the calling thread. This function does not return but the stack is unwound and automatic objects are destroyed, as if - exit() threw an exception (which is, in fact, what it does). The - argument is saved as the result returned by getResult(). If you + exit() threw an exception (which is, in fact, what it does). If you have \c catch(...) blocks then you should add the following before each to avoid catching the exit: \code @@ -98,7 +95,7 @@ public: enabled. If cancellation is disabled then the cancel is remembered but not acted on until the first call to a cancellation point after cancellation is enabled. - + A cancellation point is a function that can act on cancellation. A cancellation point does not return if there's a cancel pending. Instead, it unwinds the stack and destroys automatic objects, as @@ -110,7 +107,7 @@ public: objects (like Lock). Clients are strongly encouraged to do the latter. During cancellation, further cancel() calls are ignored (i.e. a thread cannot be interrupted by a cancel during cancellation). - + Clients that \c catch(XThreadCancel) must always rethrow the exception. Clients that \c catch(...) must either rethrow the exception or include a \c catch(XThreadCancel) handler that @@ -122,7 +119,7 @@ public: /*! Change the priority of the thread. Normal priority is 0, 1 is the next lower, etc. -1 is the next higher, etc. but boosting - the priority may not be permitted and will be silenty ignored. + the priority may not be permitted and will be silently ignored. */ void setPriority(int n); @@ -167,16 +164,6 @@ public: */ bool wait(double timeout = -1.0) const; - //! Get the exit result - /*! - Returns the exit result. This does an implicit wait(). It returns - NULL immediately if called by a thread on itself or on a thread that - was cancelled. - - (cancellation point) - */ - void* getResult() const; - //! Get the thread id /*! Returns an integer id for this thread. This id must not be used to @@ -203,7 +190,7 @@ public: private: Thread(ArchThread); - static void* threadFunc(void*); + static void threadFunc(const std::function& func); private: ArchThread m_thread; diff --git a/src/lib/mt/XMT.cpp b/src/lib/mt/XMT.cpp index 2274a6b..2282d63 100644 --- a/src/lib/mt/XMT.cpp +++ b/src/lib/mt/XMT.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/mt/XMT.h b/src/lib/mt/XMT.h index 9e48fd9..ec4a683 100644 --- a/src/lib/mt/XMT.h +++ b/src/lib/mt/XMT.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/mt/XThread.h b/src/lib/mt/XThread.h index acc32e3..41172b3 100644 --- a/src/lib/mt/XThread.h +++ b/src/lib/mt/XThread.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -26,12 +26,4 @@ Thrown by Thread::exit() to exit a thread. Clients of Thread must not throw this type but must rethrow it if caught (by XThreadExit, XThread, or ...). */ -class XThreadExit : public XThread { -public: - //! \c result is the result of the thread - XThreadExit(void* result) : m_result(result) { } - ~XThreadExit() { } - -public: - void* m_result; -}; +class XThreadExit : public XThread {}; diff --git a/src/lib/net/CMakeLists.txt b/src/lib/net/CMakeLists.txt index 5439450..8c12ed9 100644 --- a/src/lib/net/CMakeLists.txt +++ b/src/lib/net/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 diff --git a/src/lib/net/ConnectionSecurityLevel.h b/src/lib/net/ConnectionSecurityLevel.h new file mode 100644 index 0000000..913c2fd --- /dev/null +++ b/src/lib/net/ConnectionSecurityLevel.h @@ -0,0 +1,27 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 BARRIER_LIB_NET_CONNECTION_SECURITY_LEVEL_H +#define BARRIER_LIB_NET_CONNECTION_SECURITY_LEVEL_H + +enum class ConnectionSecurityLevel { + PLAINTEXT, + ENCRYPTED, + ENCRYPTED_AUTHENTICATED +}; + +#endif // BARRIER_LIB_NET_CONNECTION_SECURITY_LEVEL_H diff --git a/src/lib/net/FingerprintData.cpp b/src/lib/net/FingerprintData.cpp new file mode 100644 index 0000000..460b39b --- /dev/null +++ b/src/lib/net/FingerprintData.cpp @@ -0,0 +1,52 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 "base/String.h" +#include "FingerprintDatabase.h" +#include "io/filesystem.h" +#include +#include + +namespace barrier { + +bool FingerprintData::operator==(const FingerprintData& other) const +{ + return algorithm == other.algorithm && data == other.data; +} + +const char* fingerprint_type_to_string(FingerprintType type) +{ + switch (type) { + case FingerprintType::INVALID: return "invalid"; + case FingerprintType::SHA1: return "sha1"; + case FingerprintType::SHA256: return "sha256"; + } + return "invalid"; +} + +FingerprintType fingerprint_type_from_string(const std::string& type) +{ + if (type == "sha1") { + return FingerprintType::SHA1; + } + if (type == "sha256") { + return FingerprintType::SHA256; + } + return FingerprintType::INVALID; +} + +} // namespace barrier diff --git a/src/lib/net/FingerprintData.h b/src/lib/net/FingerprintData.h new file mode 100644 index 0000000..938a695 --- /dev/null +++ b/src/lib/net/FingerprintData.h @@ -0,0 +1,46 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 BARRIER_LIB_NET_FINGERPRINT_DATA_H +#define BARRIER_LIB_NET_FINGERPRINT_DATA_H + +#include +#include + +namespace barrier { + +enum FingerprintType { + INVALID, + SHA1, // deprecated + SHA256, +}; + +struct FingerprintData { + std::string algorithm; + std::vector data; + + bool valid() const { return !algorithm.empty(); } + + bool operator==(const FingerprintData& other) const; +}; + +const char* fingerprint_type_to_string(FingerprintType type); +FingerprintType fingerprint_type_from_string(const std::string& type); + +} // namespace barrier + +#endif // BARRIER_LIB_NET_FINGERPRINT_TYPE_H diff --git a/src/lib/net/FingerprintDatabase.cpp b/src/lib/net/FingerprintDatabase.cpp new file mode 100644 index 0000000..def0de9 --- /dev/null +++ b/src/lib/net/FingerprintDatabase.cpp @@ -0,0 +1,135 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 "base/String.h" +#include "FingerprintDatabase.h" +#include "io/filesystem.h" +#include +#include + +namespace barrier { + +void FingerprintDatabase::read(const fs::path& path) +{ + std::ifstream file; + open_utf8_path(file, path, std::ios_base::in); + read_stream(file); +} + +void FingerprintDatabase::write(const fs::path& path) +{ + std::ofstream file; + open_utf8_path(file, path, std::ios_base::out); + write_stream(file); +} + +void FingerprintDatabase::read_stream(std::istream& stream) +{ + if (!stream.good()) { + return; + } + + std::string line; + while (std::getline(stream, line)) { + if (line.empty()) { + continue; + } + + auto fingerprint = parse_db_line(line); + if (!fingerprint.valid()) { + continue; + } + + fingerprints_.push_back(fingerprint); + } +} + +void FingerprintDatabase::write_stream(std::ostream& stream) +{ + if (!stream.good()) { + return; + } + + for (const auto& fingerprint : fingerprints_) { + stream << to_db_line(fingerprint) << "\n"; + } +} + +void FingerprintDatabase::clear() +{ + fingerprints_.clear(); +} + +void FingerprintDatabase::add_trusted(const FingerprintData& fingerprint) +{ + if (is_trusted(fingerprint)) { + return; + } + fingerprints_.push_back(fingerprint); +} + +bool FingerprintDatabase::is_trusted(const FingerprintData& fingerprint) +{ + auto found_it = std::find(fingerprints_.begin(), fingerprints_.end(), fingerprint); + return found_it != fingerprints_.end(); +} + +FingerprintData FingerprintDatabase::parse_db_line(const std::string& line) +{ + FingerprintData result; + + // legacy v1 certificate handling + if (std::count(line.begin(), line.end(), ':') == 19 && line.size() == 40 + 19) { + auto data = string::from_hex(line); + if (data.empty()) { + return result; + } + result.algorithm = fingerprint_type_to_string(FingerprintType::SHA1); + result.data = data; + return result; + } + + auto version_end_pos = line.find(':'); + if (version_end_pos == std::string::npos) { + return result; + } + if (line.substr(0, version_end_pos) != "v2") { + return result; + } + auto algo_start_pos = version_end_pos + 1; + auto algo_end_pos = line.find(':', algo_start_pos); + if (algo_end_pos == std::string::npos) { + return result; + } + auto algorithm = line.substr(algo_start_pos, algo_end_pos - algo_start_pos); + auto data = string::from_hex(line.substr(algo_end_pos + 1)); + + if (data.empty()) { + return result; + } + + result.algorithm = algorithm; + result.data = data; + return result; +} + +std::string FingerprintDatabase::to_db_line(const FingerprintData& fingerprint) +{ + return "v2:" + fingerprint.algorithm + ":" + string::to_hex(fingerprint.data, 2); +} + +} // namespace barrier diff --git a/src/lib/net/FingerprintDatabase.h b/src/lib/net/FingerprintDatabase.h new file mode 100644 index 0000000..4927265 --- /dev/null +++ b/src/lib/net/FingerprintDatabase.h @@ -0,0 +1,53 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 BARRIER_LIB_NET_FINGERPRINT_DATABASE_H +#define BARRIER_LIB_NET_FINGERPRINT_DATABASE_H + +#include "FingerprintData.h" +#include "io/filesystem.h" +#include +#include +#include + +namespace barrier { + +class FingerprintDatabase { +public: + void read(const fs::path& path); + void write(const fs::path& path); + + void read_stream(std::istream& stream); + void write_stream(std::ostream& stream); + + void clear(); + void add_trusted(const FingerprintData& fingerprint); + bool is_trusted(const FingerprintData& fingerprint); + + const std::vector& fingerprints() const { return fingerprints_; } + + static FingerprintData parse_db_line(const std::string& line); + static std::string to_db_line(const FingerprintData& fingerprint); + +private: + + std::vector fingerprints_; +}; + +} // namespace barrier + +#endif // BARRIER_LIB_NET_FINGERPRINT_DATABASE_H diff --git a/src/lib/net/IDataSocket.cpp b/src/lib/net/IDataSocket.cpp index cc679c3..30e00f4 100644 --- a/src/lib/net/IDataSocket.cpp +++ b/src/lib/net/IDataSocket.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/net/IDataSocket.h b/src/lib/net/IDataSocket.h index c77a99c..0fc41bb 100644 --- a/src/lib/net/IDataSocket.h +++ b/src/lib/net/IDataSocket.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/net/IListenSocket.h b/src/lib/net/IListenSocket.h index 73dcc6e..5452a37 100644 --- a/src/lib/net/IListenSocket.h +++ b/src/lib/net/IListenSocket.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -41,7 +41,7 @@ public: */ virtual IDataSocket* accept() = 0; - + //@} // ISocket overrides diff --git a/src/lib/net/ISocket.h b/src/lib/net/ISocket.h index 0e9688b..f41fd55 100644 --- a/src/lib/net/ISocket.h +++ b/src/lib/net/ISocket.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/net/ISocketFactory.h b/src/lib/net/ISocketFactory.h index e440953..edfc8c9 100644 --- a/src/lib/net/ISocketFactory.h +++ b/src/lib/net/ISocketFactory.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -20,6 +20,7 @@ #include "common/IInterface.h" #include "arch/IArchNetwork.h" +#include "net/ConnectionSecurityLevel.h" class IDataSocket; class IListenSocket; @@ -35,14 +36,12 @@ public: //@{ //! Create data socket - virtual IDataSocket* create( - IArchNetwork::EAddressFamily family, - bool secure) const = 0; + virtual IDataSocket* create(IArchNetwork::EAddressFamily family, + ConnectionSecurityLevel security_level) const = 0; //! Create listen socket - virtual IListenSocket* createListen( - IArchNetwork::EAddressFamily family, - bool secure) const = 0; + virtual IListenSocket* createListen(IArchNetwork::EAddressFamily family, + ConnectionSecurityLevel security_level) const = 0; //@} }; diff --git a/src/lib/net/ISocketMultiplexerJob.h b/src/lib/net/ISocketMultiplexerJob.h index c27fce2..2dab87e 100644 --- a/src/lib/net/ISocketMultiplexerJob.h +++ b/src/lib/net/ISocketMultiplexerJob.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/net/NetworkAddress.cpp b/src/lib/net/NetworkAddress.cpp index c8ea9c6..3526fc0 100644 --- a/src/lib/net/NetworkAddress.cpp +++ b/src/lib/net/NetworkAddress.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/net/NetworkAddress.h b/src/lib/net/NetworkAddress.h index 87dc1e4..3a006af 100644 --- a/src/lib/net/NetworkAddress.h +++ b/src/lib/net/NetworkAddress.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -43,7 +43,7 @@ public: If \c hostname can be parsed as a numerical address then that's how it's used, otherwise it's used as a host name. If \c hostname ends in ":[0-9]+" then that suffix is extracted and used as the port, - overridding the port parameter. The resulting port must be a valid + overriding the port parameter. The resulting port must be a valid port number (zero is not a valid port number) otherwise \c XSocketAddress is thrown with an error of \c XSocketAddress::kBadPort. The hostname is not resolved by the c'tor; use \c resolve to do that. diff --git a/src/lib/net/SecureListenSocket.cpp b/src/lib/net/SecureListenSocket.cpp index a137f39..11efc5c 100644 --- a/src/lib/net/SecureListenSocket.cpp +++ b/src/lib/net/SecureListenSocket.cpp @@ -1,11 +1,11 @@ /* * barrier -- 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 @@ -20,23 +20,16 @@ #include "SecureSocket.h" #include "net/NetworkAddress.h" #include "net/SocketMultiplexer.h" -#include "net/TSocketMultiplexerMethodJob.h" +#include "arch/Arch.h" #include "arch/XArch.h" #include "common/DataDirectories.h" #include "base/String.h" -static const char s_certificateDir[] = { "SSL" }; -static const char s_certificateFilename[] = { "Barrier.pem" }; - -// -// SecureListenSocket -// - -SecureListenSocket::SecureListenSocket( - IEventQueue* events, - SocketMultiplexer* socketMultiplexer, - IArchNetwork::EAddressFamily family) : - TCPListenSocket(events, socketMultiplexer, family) +SecureListenSocket::SecureListenSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, + IArchNetwork::EAddressFamily family, + ConnectionSecurityLevel security_level) : + TCPListenSocket(events, socketMultiplexer, family), + security_level_{security_level} { } @@ -45,22 +38,15 @@ SecureListenSocket::accept() { SecureSocket* socket = NULL; try { - socket = new SecureSocket( - m_events, - m_socketMultiplexer, - ARCH->acceptSocket(m_socket, NULL)); + socket = new SecureSocket(m_events, m_socketMultiplexer, + ARCH->acceptSocket(m_socket, NULL), security_level_); socket->initSsl(true); if (socket != NULL) { setListeningJob(); } - std::string certificateFilename = barrier::string::sprintf("%s/%s/%s", - DataDirectories::profile().c_str(), - s_certificateDir, - s_certificateFilename); - - bool loaded = socket->loadCertificates(certificateFilename); + bool loaded = socket->load_certificates(barrier::DataDirectories::ssl_certificate_path()); if (!loaded) { delete socket; return NULL; diff --git a/src/lib/net/SecureListenSocket.h b/src/lib/net/SecureListenSocket.h index d0c6e23..a0e792a 100644 --- a/src/lib/net/SecureListenSocket.h +++ b/src/lib/net/SecureListenSocket.h @@ -1,11 +1,11 @@ /* * barrier -- 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 @@ -19,18 +19,21 @@ #include "net/TCPListenSocket.h" #include "common/stdset.h" +#include "ConnectionSecurityLevel.h" class IEventQueue; class SocketMultiplexer; class IDataSocket; -class SecureListenSocket : public TCPListenSocket{ +class SecureListenSocket : public TCPListenSocket { public: - SecureListenSocket(IEventQueue* events, - SocketMultiplexer* socketMultiplexer, - IArchNetwork::EAddressFamily family); + SecureListenSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, + IArchNetwork::EAddressFamily family, + ConnectionSecurityLevel security_level); // IListenSocket overrides virtual IDataSocket* accept(); +private: + ConnectionSecurityLevel security_level_; }; diff --git a/src/lib/net/SecureSocket.cpp b/src/lib/net/SecureSocket.cpp index 855e16b..85e1d38 100644 --- a/src/lib/net/SecureSocket.cpp +++ b/src/lib/net/SecureSocket.cpp @@ -1,11 +1,11 @@ /* * barrier -- 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 @@ -16,6 +16,7 @@ */ #include "SecureSocket.h" +#include "SecureUtils.h" #include "net/TSocketMultiplexerMethodJob.h" #include "base/TMethodEventJob.h" @@ -25,6 +26,8 @@ #include "base/Log.h" #include "base/String.h" #include "common/DataDirectories.h" +#include "io/filesystem.h" +#include "net/FingerprintDatabase.h" #include #include @@ -40,41 +43,36 @@ #define MAX_ERROR_SIZE 65535 +static const std::size_t MAX_INPUT_BUFFER_SIZE = 1024 * 1024; static const float s_retryDelay = 0.01f; enum { kMsgSize = 128 }; -static const char kFingerprintDirName[] = "SSL/Fingerprints"; -//static const char kFingerprintLocalFilename[] = "Local.txt"; -static const char kFingerprintTrustedServersFilename[] = "TrustedServers.txt"; -//static const char kFingerprintTrustedClientsFilename[] = "TrustedClients.txt"; - struct Ssl { SSL_CTX* m_context; SSL* m_ssl; }; -SecureSocket::SecureSocket( - IEventQueue* events, - SocketMultiplexer* socketMultiplexer, - IArchNetwork::EAddressFamily family) : +SecureSocket::SecureSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, + IArchNetwork::EAddressFamily family, + ConnectionSecurityLevel security_level) : TCPSocket(events, socketMultiplexer, family), m_ssl(nullptr), m_secureReady(false), - m_fatal(false) + m_fatal(false), + security_level_{security_level} { } -SecureSocket::SecureSocket( - IEventQueue* events, - SocketMultiplexer* socketMultiplexer, - ArchSocket socket) : +SecureSocket::SecureSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, + ArchSocket socket, ConnectionSecurityLevel security_level) : TCPSocket(events, socketMultiplexer, socket), m_ssl(nullptr), m_secureReady(false), - m_fatal(false) + m_fatal(false), + security_level_{security_level} { } @@ -103,6 +101,8 @@ SecureSocket::close() void SecureSocket::freeSSLResources() { + std::lock_guard ssl_lock{ssl_mutex_}; + if (m_ssl->m_ssl != NULL) { SSL_shutdown(m_ssl->m_ssl); SSL_free(m_ssl->m_ssl); @@ -133,30 +133,30 @@ std::unique_ptr SecureSocket::newJob() if (m_connected && !m_secureReady) { return {}; } - + return TCPSocket::newJob(); } void SecureSocket::secureConnect() { - setJob(std::make_unique>( - this, &SecureSocket::serviceConnect, - getSocket(), isReadable(), isWritable())); + setJob(std::make_unique([this](auto j, auto r, auto w, auto e) + { return serviceConnect(j, r, w, e); }, + getSocket(), isReadable(), isWritable())); } void SecureSocket::secureAccept() { - setJob(std::make_unique>( - this, &SecureSocket::serviceAccept, - getSocket(), isReadable(), isWritable())); + setJob(std::make_unique([this](auto j, auto r, auto w, auto e) + { return serviceAccept(j, r, w, e); }, + getSocket(), isReadable(), isWritable())); } TCPSocket::EJobResult SecureSocket::doRead() { - static UInt8 buffer[4096]; + UInt8 buffer[4096]; memset(buffer, 0, sizeof(buffer)); int bytesRead = 0; int status = 0; @@ -173,20 +173,24 @@ SecureSocket::doRead() else { return kRetry; } - + if (bytesRead > 0) { bool wasEmpty = (m_inputBuffer.getSize() == 0); - + // slurp up as much as possible do { m_inputBuffer.write(buffer, bytesRead); - + + if (m_inputBuffer.getSize() > MAX_INPUT_BUFFER_SIZE) { + break; + } + status = secureRead(buffer, sizeof(buffer), bytesRead); if (status < 0) { return kBreak; } } while (bytesRead > 0 || status > 0); - + // send input ready if input buffer was empty if (wasEmpty) { sendEvent(m_events->forIStream().inputReady()); @@ -204,18 +208,13 @@ SecureSocket::doRead() m_readable = false; return kNew; } - + return kRetry; } TCPSocket::EJobResult SecureSocket::doWrite() { - static bool s_retry = false; - static int s_retrySize = 0; - static std::unique_ptr s_staticBuffer; - static std::size_t s_staticBufferSize = 0; - // write data int bufferSize = 0; int bytesWrote = 0; @@ -224,34 +223,34 @@ SecureSocket::doWrite() if (!isSecureReady()) return kRetry; - if (s_retry) { - bufferSize = s_retrySize; + if (do_write_retry_) { + bufferSize = do_write_retry_size_; } else { bufferSize = m_outputBuffer.getSize(); - if (bufferSize > s_staticBufferSize) { - s_staticBuffer.reset(new char[bufferSize]); - s_staticBufferSize = bufferSize; + if (bufferSize > do_write_retry_buffer_size_) { + do_write_retry_buffer_.reset(new char[bufferSize]); + do_write_retry_buffer_size_ = bufferSize; } if (bufferSize > 0) { - memcpy(s_staticBuffer.get(), m_outputBuffer.peek(bufferSize), bufferSize); + std::memcpy(do_write_retry_buffer_.get(), m_outputBuffer.peek(bufferSize), bufferSize); } } - + if (bufferSize == 0) { return kRetry; } - status = secureWrite(s_staticBuffer.get(), bufferSize, bytesWrote); + status = secureWrite(do_write_retry_buffer_.get(), bufferSize, bytesWrote); if (status > 0) { - s_retry = false; + do_write_retry_ = false; } else if (status < 0) { return kBreak; } else if (status == 0) { - s_retry = true; - s_retrySize = bufferSize; + do_write_retry_ = true; + do_write_retry_size_ = bufferSize; return kNew; } - + if (bytesWrote > 0) { discardWrittenData(bytesWrote); return kNew; @@ -263,16 +262,16 @@ SecureSocket::doWrite() int SecureSocket::secureRead(void* buffer, int size, int& read) { + std::lock_guard ssl_lock{ssl_mutex_}; + if (m_ssl->m_ssl != NULL) { LOG((CLOG_DEBUG2 "reading secure socket")); read = SSL_read(m_ssl->m_ssl, buffer, size); - - static int retry; // Check result will cleanup the connection in the case of a fatal - checkResult(read, retry); - - if (retry) { + checkResult(read, secure_read_retry_); + + if (secure_read_retry_) { return 0; } @@ -289,17 +288,17 @@ SecureSocket::secureRead(void* buffer, int size, int& read) int SecureSocket::secureWrite(const void* buffer, int size, int& wrote) { + std::lock_guard ssl_lock{ssl_mutex_}; + if (m_ssl->m_ssl != NULL) { LOG((CLOG_DEBUG2 "writing secure socket:%p", this)); wrote = SSL_write(m_ssl->m_ssl, buffer, size); - - static int retry; // Check result will cleanup the connection in the case of a fatal - checkResult(wrote, retry); + checkResult(wrote, secure_write_retry_); - if (retry) { + if (secure_write_retry_) { return 0; } @@ -322,6 +321,8 @@ SecureSocket::isSecureReady() void SecureSocket::initSsl(bool server) { + std::lock_guard ssl_lock{ssl_mutex_}; + m_ssl = new Ssl(); m_ssl->m_context = NULL; m_ssl->m_ssl = NULL; @@ -329,54 +330,57 @@ SecureSocket::initSsl(bool server) initContext(server); } -bool SecureSocket::loadCertificates(std::string& filename) +bool SecureSocket::load_certificates(const barrier::fs::path& path) { - if (filename.empty()) { + std::lock_guard ssl_lock{ssl_mutex_}; + + if (path.empty()) { showError("ssl certificate is not specified"); return false; } else { - std::ifstream file(filename.c_str()); - bool exist = file.good(); - file.close(); - - if (!exist) { - std::string errorMsg("ssl certificate doesn't exist: "); - errorMsg.append(filename); - showError(errorMsg.c_str()); + if (!barrier::fs::is_regular_file(path)) { + showError("ssl certificate doesn't exist: " + path.u8string()); return false; } } int r = 0; - r = SSL_CTX_use_certificate_file(m_ssl->m_context, filename.c_str(), SSL_FILETYPE_PEM); + r = SSL_CTX_use_certificate_file(m_ssl->m_context, path.u8string().c_str(), SSL_FILETYPE_PEM); if (r <= 0) { - showError("could not use ssl certificate"); + showError("could not use ssl certificate: " + path.u8string()); return false; } - r = SSL_CTX_use_PrivateKey_file(m_ssl->m_context, filename.c_str(), SSL_FILETYPE_PEM); + r = SSL_CTX_use_PrivateKey_file(m_ssl->m_context, path.u8string().c_str(), SSL_FILETYPE_PEM); if (r <= 0) { - showError("could not use ssl private key"); + showError("could not use ssl private key: " + path.u8string()); return false; } r = SSL_CTX_check_private_key(m_ssl->m_context); if (!r) { - showError("could not verify ssl private key"); + showError("could not verify ssl private key: " + path.u8string()); return false; } return true; } +static int cert_verify_ignore_callback(X509_STORE_CTX*, void*) +{ + return 1; +} + void SecureSocket::initContext(bool server) { + // ssl_mutex_ is assumed to be acquired + SSL_library_init(); const SSL_METHOD* method; - + // load & register all cryptos, etc. OpenSSL_add_all_algorithms(); @@ -394,7 +398,7 @@ SecureSocket::initContext(bool server) else { method = SSLv23_client_method(); } - + // create new context from method SSL_METHOD* m = const_cast(method); m_ssl->m_context = SSL_CTX_new(m); @@ -403,13 +407,23 @@ SecureSocket::initContext(bool server) SSL_CTX_set_options(m_ssl->m_context, SSL_OP_NO_SSLv3); if (m_ssl->m_context == NULL) { - showError(); + showError(""); + } + + if (security_level_ == ConnectionSecurityLevel::ENCRYPTED_AUTHENTICATED) { + // We want to ask for peer certificate, but not verify it. If we don't ask for peer + // certificate, e.g. client won't send it. + SSL_CTX_set_verify(m_ssl->m_context, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, + nullptr); + SSL_CTX_set_cert_verify_callback(m_ssl->m_context, cert_verify_ignore_callback, nullptr); } } void SecureSocket::createSSL() { + // ssl_mutex_ is assumed to be acquired + // I assume just one instance is needed // get new SSL state with context if (m_ssl->m_ssl == NULL) { @@ -421,17 +435,17 @@ SecureSocket::createSSL() int SecureSocket::secureAccept(int socket) { + std::lock_guard ssl_lock{ssl_mutex_}; + createSSL(); // set connection socket to SSL state SSL_set_fd(m_ssl->m_ssl, socket); - + LOG((CLOG_DEBUG2 "accepting secure socket")); int r = SSL_accept(m_ssl->m_ssl); - - static int retry; - checkResult(r, retry); + checkResult(r, secure_accept_retry_); if (isFatal()) { // tell user and sleep so the socket isn't hammered. @@ -439,12 +453,30 @@ SecureSocket::secureAccept(int socket) LOG((CLOG_INFO "client connection may not be secure")); m_secureReady = false; ARCH->sleep(1); - retry = 0; + secure_accept_retry_ = 0; return -1; // Failed, error out } // If not fatal and no retry, state is good - if (retry == 0) { + if (secure_accept_retry_ == 0) { + if (security_level_ == ConnectionSecurityLevel::ENCRYPTED_AUTHENTICATED) { + if (verify_cert_fingerprint( + barrier::DataDirectories::trusted_clients_ssl_fingerprints_path())) { + LOG((CLOG_INFO "accepted secure socket")); + if (!ensure_peer_certificate()) { + secure_accept_retry_ = 0; + disconnect(); + return -1;// Cert fail, error + } + } + else { + LOG((CLOG_ERR "failed to verify server certificate fingerprint")); + secure_accept_retry_ = 0; + disconnect(); + return -1; // Fingerprint failed, error + } + } + m_secureReady = true; LOG((CLOG_INFO "accepted secure socket")); if (CLOG->getFilter() >= kDEBUG1) { @@ -455,7 +487,7 @@ SecureSocket::secureAccept(int socket) } // If not fatal and retry is set, not ready, and return retry - if (retry > 0) { + if (secure_accept_retry_ > 0) { LOG((CLOG_DEBUG2 "retry accepting secure socket")); m_secureReady = false; ARCH->sleep(s_retryDelay); @@ -470,38 +502,45 @@ SecureSocket::secureAccept(int socket) int SecureSocket::secureConnect(int socket) { + // note that load_certificates acquires ssl_mutex_ + if (!load_certificates(barrier::DataDirectories::ssl_certificate_path())) { + LOG((CLOG_ERR "could not load client certificates")); + // FIXME: this is fatal error, but we current don't disconnect because whole logic in this + // function needs to be cleaned up + } + + std::lock_guard ssl_lock{ssl_mutex_}; + createSSL(); // attach the socket descriptor SSL_set_fd(m_ssl->m_ssl, socket); - + LOG((CLOG_DEBUG2 "connecting secure socket")); int r = SSL_connect(m_ssl->m_ssl); - - static int retry; - checkResult(r, retry); + checkResult(r, secure_connect_retry_); if (isFatal()) { LOG((CLOG_ERR "failed to connect secure socket")); - retry = 0; + secure_connect_retry_ = 0; return -1; } // If we should retry, not ready and return 0 - if (retry > 0) { + if (secure_connect_retry_ > 0) { LOG((CLOG_DEBUG2 "retry connect secure socket")); m_secureReady = false; ARCH->sleep(s_retryDelay); return 0; } - retry = 0; + secure_connect_retry_ = 0; // No error, set ready, process and return ok m_secureReady = true; - if (verifyCertFingerprint()) { + if (verify_cert_fingerprint(barrier::DataDirectories::trusted_servers_ssl_fingerprints_path())) { LOG((CLOG_INFO "connected to secure socket")); - if (!showCertificate()) { + if (!ensure_peer_certificate()) { disconnect(); return -1;// Cert fail, error } @@ -520,21 +559,22 @@ SecureSocket::secureConnect(int socket) } bool -SecureSocket::showCertificate() +SecureSocket::ensure_peer_certificate() { + // ssl_mutex_ is assumed to be acquired X509* cert; char* line; - + // get the server's certificate cert = SSL_get_peer_certificate(m_ssl->m_ssl); if (cert != NULL) { line = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0); - LOG((CLOG_INFO "server ssl certificate info: %s", line)); + LOG((CLOG_INFO "peer ssl certificate info: %s", line)); OPENSSL_free(line); X509_free(cert); } else { - showError("server has no ssl certificate"); + showError("peer has no ssl certificate"); return false; } @@ -544,6 +584,8 @@ SecureSocket::showCertificate() void SecureSocket::checkResult(int status, int& retry) { + // ssl_mutex_ is assumed to be acquired + // ssl errors are a little quirky. the "want" errors are normal and // should result in a retry. @@ -568,7 +610,7 @@ SecureSocket::checkResult(int status, int& retry) case SSL_ERROR_WANT_WRITE: // Need to make sure the socket is known to be writable so the impending - // select action actually triggers on a write. This isn't necessary for + // select action actually triggers on a write. This isn't necessary for // m_readable because the socket logic is always readable m_writable = true; retry++; @@ -618,16 +660,15 @@ SecureSocket::checkResult(int status, int& retry) if (isFatal()) { retry = 0; - showError(); + showError(""); disconnect(); } } -void -SecureSocket::showError(const char* reason) +void SecureSocket::showError(const std::string& reason) { - if (reason != NULL) { - LOG((CLOG_ERR "%s", reason)); + if (!reason.empty()) { + LOG((CLOG_ERR "%s", reason.c_str())); } std::string error = getError(); @@ -658,83 +699,49 @@ SecureSocket::disconnect() sendEvent(getEvents()->forIStream().inputShutdown()); } -void SecureSocket::formatFingerprint(std::string& fingerprint, bool hex, bool separator) +bool SecureSocket::verify_cert_fingerprint(const barrier::fs::path& fingerprint_db_path) { - if (hex) { - // to hexidecimal - barrier::string::toHex(fingerprint, 2); - } - - // all uppercase - barrier::string::uppercase(fingerprint); + // ssl_mutex_ is assumed to be acquired - if (separator) { - // add colon to separate each 2 charactors - size_t separators = fingerprint.size() / 2; - for (size_t i = 1; i < separators; i++) { - fingerprint.insert(i * 3 - 1, ":"); - } - } -} - -bool -SecureSocket::verifyCertFingerprint() -{ // calculate received certificate fingerprint - X509 *cert = cert = SSL_get_peer_certificate(m_ssl->m_ssl); - EVP_MD* tempDigest; - unsigned char tempFingerprint[EVP_MAX_MD_SIZE]; - unsigned int tempFingerprintLen; - tempDigest = (EVP_MD*)EVP_sha1(); - int digestResult = X509_digest(cert, tempDigest, tempFingerprint, &tempFingerprintLen); - - if (digestResult <= 0) { - LOG((CLOG_ERR "failed to calculate fingerprint, digest result: %d", digestResult)); + barrier::FingerprintData fingerprint_sha1, fingerprint_sha256; + try { + auto* cert = SSL_get_peer_certificate(m_ssl->m_ssl); + fingerprint_sha1 = barrier::get_ssl_cert_fingerprint(cert, + barrier::FingerprintType::SHA1); + fingerprint_sha256 = barrier::get_ssl_cert_fingerprint(cert, + barrier::FingerprintType::SHA256); + } catch (const std::exception& e) { + LOG((CLOG_ERR "%s", e.what())); return false; } - // format fingerprint into hexdecimal format with colon separator - std::string fingerprint(reinterpret_cast(tempFingerprint), tempFingerprintLen); - formatFingerprint(fingerprint); - LOG((CLOG_NOTE "server fingerprint: %s", fingerprint.c_str())); - - std::string trustedServersFilename; - trustedServersFilename = barrier::string::sprintf( - "%s/%s/%s", - DataDirectories::profile().c_str(), - kFingerprintDirName, - kFingerprintTrustedServersFilename); + // note: the GUI parses the following two lines of logs, don't change unnecessarily + LOG((CLOG_NOTE "peer fingerprint (SHA1): %s (SHA256): %s", + barrier::format_ssl_fingerprint(fingerprint_sha1.data).c_str(), + barrier::format_ssl_fingerprint(fingerprint_sha256.data).c_str())); // Provide debug hint as to what file is being used to verify fingerprint trust - LOG((CLOG_NOTE "trustedServersFilename: %s", trustedServersFilename.c_str() )); + LOG((CLOG_NOTE "fingerprint_db_path: %s", fingerprint_db_path.u8string().c_str())); - // check if this fingerprint exist - std::string fileLine; - std::ifstream file; - file.open(trustedServersFilename.c_str()); + barrier::FingerprintDatabase db; + db.read(fingerprint_db_path); - if (!file.is_open()) { - LOG((CLOG_NOTE "Unable to open trustedServersFile: %s", trustedServersFilename.c_str() )); + if (!db.fingerprints().empty()) { + LOG((CLOG_NOTE "Read %d fingerprints from: %s", db.fingerprints().size(), + fingerprint_db_path.u8string().c_str())); } else { - LOG((CLOG_NOTE "Opened trustedServersFilename: %s", trustedServersFilename.c_str() )); + LOG((CLOG_NOTE "Could not read fingerprints from: %s", + fingerprint_db_path.u8string().c_str())); } - bool isValid = false; - while (!file.eof() && file.is_open()) { - getline(file,fileLine); - if (!fileLine.empty()) { - if (fileLine.compare(fingerprint) == 0) { - LOG((CLOG_NOTE "Fingerprint matches trusted fingerprint")); - isValid = true; - break; - } else { - LOG((CLOG_NOTE "Fingerprint does not match trusted fingerprint")); - } - } + if (db.is_trusted(fingerprint_sha256)) { + LOG((CLOG_NOTE "Fingerprint matches trusted fingerprint")); + return true; + } else { + LOG((CLOG_NOTE "Fingerprint does not match trusted fingerprint")); + return false; } - - file.close(); - return isValid; } MultiplexerJobStatus SecureSocket::serviceConnect(ISocketMultiplexerJob* job, @@ -765,9 +772,9 @@ MultiplexerJobStatus SecureSocket::serviceConnect(ISocketMultiplexerJob* job, // Retry case return { true, - std::make_unique>( - this, &SecureSocket::serviceConnect, - getSocket(), isReadable(), isWritable()) + std::make_unique([this](auto j, auto r, auto w, auto e) + { return serviceConnect(j, r, w, e); }, + getSocket(), isReadable(), isWritable()) }; } @@ -795,9 +802,12 @@ MultiplexerJobStatus SecureSocket::serviceAccept(ISocketMultiplexerJob* job, } // Retry case - return {true, std::make_unique>( - this, &SecureSocket::serviceAccept, - getSocket(), isReadable(), isWritable())}; + return { + true, + std::make_unique([this](auto j, auto r, auto w, auto e) + { return serviceAccept(j, r, w, e); }, + getSocket(), isReadable(), isWritable()) + }; } void @@ -822,6 +832,8 @@ showCipherStackDesc(STACK_OF(SSL_CIPHER) * stack) { void SecureSocket::showSecureCipherInfo() { + // ssl_mutex_ is assumed to be acquired + STACK_OF(SSL_CIPHER) * sStack = SSL_get_ciphers(m_ssl->m_ssl); if (sStack == NULL) { @@ -832,8 +844,8 @@ SecureSocket::showSecureCipherInfo() showCipherStackDesc(sStack); } -#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) - // m_ssl->m_ssl->session->ciphers is not forward compatable, +#if OPENSSL_VERSION_NUMBER < 0x10100000L + // m_ssl->m_ssl->session->ciphers is not forward compatible, // In future release of OpenSSL, it's not visible, STACK_OF(SSL_CIPHER) * cStack = m_ssl->m_ssl->session->ciphers; #else @@ -864,6 +876,8 @@ SecureSocket::showSecureLibInfo() void SecureSocket::showSecureConnectInfo() { + // ssl_mutex_ is assumed to be acquired + const SSL_CIPHER* cipher = SSL_get_current_cipher(m_ssl->m_ssl); if (cipher != NULL) { diff --git a/src/lib/net/SecureSocket.h b/src/lib/net/SecureSocket.h index c602e2d..be7dc0d 100644 --- a/src/lib/net/SecureSocket.h +++ b/src/lib/net/SecureSocket.h @@ -1,11 +1,11 @@ /* * barrier -- 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 @@ -17,8 +17,11 @@ #pragma once +#include "ConnectionSecurityLevel.h" #include "net/TCPSocket.h" #include "net/XSocket.h" +#include "io/filesystem.h" +#include class IEventQueue; class SocketMultiplexer; @@ -32,10 +35,10 @@ A secure socket using SSL. */ class SecureSocket : public TCPSocket { public: - SecureSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, IArchNetwork::EAddressFamily family); - SecureSocket(IEventQueue* events, - SocketMultiplexer* socketMultiplexer, - ArchSocket socket); + SecureSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, + IArchNetwork::EAddressFamily family, ConnectionSecurityLevel security_level); + SecureSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, + ArchSocket socket, ConnectionSecurityLevel security_level); ~SecureSocket(); // ISocket overrides @@ -43,7 +46,7 @@ public: // IDataSocket overrides virtual void connect(const NetworkAddress&) override; - + std::unique_ptr newJob() override; bool isFatal() const override { return m_fatal; } void isFatal(bool b) { m_fatal = b; } @@ -55,35 +58,56 @@ public: EJobResult doRead() override; EJobResult doWrite() override; void initSsl(bool server); - bool loadCertificates(std::string& CertFile); + bool load_certificates(const barrier::fs::path& path); private: // SSL - void initContext(bool server); - void createSSL(); + void initContext(bool server); // may only be called with ssl_mutex_ acquired + void createSSL(); // may only be called with ssl_mutex_ acquired. int secureAccept(int s); int secureConnect(int s); - bool showCertificate(); - void checkResult(int n, int& retry); - void showError(const char* reason = NULL); + bool ensure_peer_certificate(); // may only be called with ssl_mutex_ acquired + + void checkResult(int n, int& retry); // may only be called with m_ssl_mutex_ acquired. + + void showError(const std::string& reason); std::string getError(); void disconnect(); - void formatFingerprint(std::string& fingerprint, bool hex = true, bool separator = true); - bool verifyCertFingerprint(); + + // may only be called with ssl_mutex_ acquired + bool verify_cert_fingerprint(const barrier::fs::path& fingerprint_db_path); MultiplexerJobStatus serviceConnect(ISocketMultiplexerJob*, bool, bool, bool); MultiplexerJobStatus serviceAccept(ISocketMultiplexerJob*, bool, bool, bool); - void showSecureConnectInfo(); - void showSecureLibInfo(); - void showSecureCipherInfo(); - + void showSecureConnectInfo(); // may only be called with ssl_mutex_ acquired + void showSecureLibInfo(); + void showSecureCipherInfo(); // may only be called with ssl_mutex_ acquired + void handleTCPConnected(const Event& event, void*); void freeSSLResources(); private: + // all accesses to m_ssl must be protected by this mutex. The only function that is called + // from outside SocketMultiplexer thread is close(), so we mostly care about things accessed + // by it. + std::mutex ssl_mutex_; + Ssl* m_ssl; bool m_secureReady; bool m_fatal; + ConnectionSecurityLevel security_level_ = ConnectionSecurityLevel::ENCRYPTED; + + int secure_accept_retry_ = 0; // used only in secureAccept() + int secure_connect_retry_ = 0; // used only in secureConnect() + int secure_read_retry_ = 0; // used only in secureRead() + int secure_write_retry_ = 0; // used only in secureWrite() + + // The following are used only from doWrite() + // FIXME: using std::vector would simplify logic significantly. + bool do_write_retry_ = false; + int do_write_retry_size_ = 0; + std::unique_ptr do_write_retry_buffer_; + std::size_t do_write_retry_buffer_size_ = 0; }; diff --git a/src/lib/net/SecureUtils.cpp b/src/lib/net/SecureUtils.cpp new file mode 100644 index 0000000..c581dd4 --- /dev/null +++ b/src/lib/net/SecureUtils.cpp @@ -0,0 +1,312 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 . + + ----------------------------------------------------------------------- + create_fingerprint_randomart() has been taken from the OpenSSH project. + Copyright information follows. + + Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. + Copyright (c) 2008 Alexander von Gernler. All rights reserved. + Copyright (c) 2010,2011 Damien Miller. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "SecureUtils.h" +#include "base/String.h" +#include "base/finally.h" +#include "io/filesystem.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#if SYSAPI_WIN32 +// Windows builds require a shim that makes it possible to link to different +// versions of the Win32 C runtime. See OpenSSL FAQ. +#include +#endif + +namespace barrier { + +namespace { + +const EVP_MD* get_digest_for_type(FingerprintType type) +{ + switch (type) { + case FingerprintType::SHA1: return EVP_sha1(); + case FingerprintType::SHA256: return EVP_sha256(); + } + throw std::runtime_error("Unknown fingerprint type " + std::to_string(static_cast(type))); +} + +} // namespace + +std::string format_ssl_fingerprint(const std::vector& fingerprint, bool separator) +{ + std::string result = barrier::string::to_hex(fingerprint, 2); + + // all uppercase + barrier::string::uppercase(result); + + if (separator) { + // add colon to separate each 2 characters + size_t separators = result.size() / 2; + for (size_t i = 1; i < separators; i++) { + result.insert(i * 3 - 1, ":"); + } + } + return result; +} + +std::string format_ssl_fingerprint_columns(const std::vector& fingerprint) +{ + auto max_columns = 8; + + std::string hex = barrier::string::to_hex(fingerprint, 2); + barrier::string::uppercase(hex); + if (hex.empty() || hex.size() % 2 != 0) { + return hex; + } + + std::string separated; + for (std::size_t i = 0; i < hex.size(); i += max_columns * 2) { + for (std::size_t j = i; j < i + 16 && j < hex.size() - 1; j += 2) { + separated.push_back(hex[j]); + separated.push_back(hex[j + 1]); + separated.push_back(':'); + } + separated.push_back('\n'); + } + separated.pop_back(); // we don't need last newline character + return separated; +} + +FingerprintData get_ssl_cert_fingerprint(X509* cert, FingerprintType type) +{ + if (!cert) { + throw std::runtime_error("certificate is null"); + } + + unsigned char digest[EVP_MAX_MD_SIZE]; + unsigned int digest_length = 0; + int result = X509_digest(cert, get_digest_for_type(type), digest, &digest_length); + + if (result <= 0) { + throw std::runtime_error("failed to calculate fingerprint, digest result: " + + std::to_string(result)); + } + + std::vector digest_vec; + digest_vec.assign(reinterpret_cast(digest), + reinterpret_cast(digest) + digest_length); + return {fingerprint_type_to_string(type), digest_vec}; +} + +FingerprintData get_pem_file_cert_fingerprint(const std::string& path, FingerprintType type) +{ + auto fp = fopen_utf8_path(path, "r"); + if (!fp) { + throw std::runtime_error("Could not open certificate path"); + } + auto file_close = finally([fp]() { std::fclose(fp); }); + + X509* cert = PEM_read_X509(fp, nullptr, nullptr, nullptr); + if (!cert) { + throw std::runtime_error("Certificate could not be parsed"); + } + auto cert_free = finally([cert]() { X509_free(cert); }); + + return get_ssl_cert_fingerprint(cert, type); +} + +void generate_pem_self_signed_cert(const std::string& path) +{ + auto expiration_days = 365; + + auto* private_key = EVP_PKEY_new(); + if (!private_key) { + throw std::runtime_error("Could not allocate private key for certificate"); + } + auto private_key_free = finally([private_key](){ EVP_PKEY_free(private_key); }); + + auto* rsa = RSA_generate_key(2048, RSA_F4, nullptr, nullptr); + if (!rsa) { + throw std::runtime_error("Failed to generate RSA key"); + } + EVP_PKEY_assign_RSA(private_key, rsa); + + auto* cert = X509_new(); + if (!cert) { + throw std::runtime_error("Could not allocate certificate"); + } + auto cert_free = finally([cert]() { X509_free(cert); }); + + ASN1_INTEGER_set(X509_get_serialNumber(cert), 1); + X509_gmtime_adj(X509_get_notBefore(cert), 0); + X509_gmtime_adj(X509_get_notAfter(cert), expiration_days * 24 * 3600); + X509_set_pubkey(cert, private_key); + + auto* name = X509_get_subject_name(cert); + X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, + reinterpret_cast("Barrier"), -1, -1, 0); + X509_set_issuer_name(cert, name); + + X509_sign(cert, private_key, EVP_sha256()); + + auto fp = fopen_utf8_path(path.c_str(), "r"); + if (!fp) { + throw std::runtime_error("Could not open certificate output path"); + } + auto file_close = finally([fp]() { std::fclose(fp); }); + + PEM_write_PrivateKey(fp, private_key, nullptr, nullptr, 0, nullptr, nullptr); + PEM_write_X509(fp, cert); +} + +/* + Draw an ASCII-Art representing the fingerprint so human brain can + profit from its built-in pattern recognition ability. + This technique is called "random art" and can be found in some + scientific publications like this original paper: + + "Hash Visualization: a New Technique to improve Real-World Security", + Perrig A. and Song D., 1999, International Workshop on Cryptographic + Techniques and E-Commerce (CrypTEC '99) + sparrow.ece.cmu.edu/~adrian/projects/validation/validation.pdf + + The subject came up in a talk by Dan Kaminsky, too. + + If you see the picture is different, the key is different. + If the picture looks the same, you still know nothing. + + The algorithm used here is a worm crawling over a discrete plane, + leaving a trace (augmenting the field) everywhere it goes. + Movement is taken from dgst_raw 2bit-wise. Bumping into walls + makes the respective movement vector be ignored for this turn. + Graphs are not unambiguous, because circles in graphs can be +walked in either direction. + */ + +/* + Field sizes for the random art. Have to be odd, so the starting point + can be in the exact middle of the picture, and FLDBASE should be >=8 . + Else pictures would be too dense, and drawing the frame would + fail, too, because the key type would not fit in anymore. +*/ +#define FLDBASE 8 +#define FLDSIZE_Y (FLDBASE + 1) +#define FLDSIZE_X (FLDBASE * 2 + 1) + +std::string create_fingerprint_randomart(const std::vector& dgst_raw) +{ + /* + * Chars to be used after each other every time the worm + * intersects with itself. Matter of taste. + */ + const char* augmentation_string = " .o+=*BOX@%&#/^SE"; + char *p; + std::uint8_t field[FLDSIZE_X][FLDSIZE_Y]; + std::size_t i; + std::uint32_t b; + int x, y; + std::size_t len = strlen(augmentation_string) - 1; + + std::vector retval; + retval.reserve((FLDSIZE_X + 3) * (FLDSIZE_Y + 2)); + + auto add_char = [&retval](char ch) { retval.push_back(ch); }; + + /* initialize field */ + std::memset(field, 0, FLDSIZE_X * FLDSIZE_Y * sizeof(char)); + x = FLDSIZE_X / 2; + y = FLDSIZE_Y / 2; + + /* process raw key */ + for (i = 0; i < dgst_raw.size(); i++) { + /* each byte conveys four 2-bit move commands */ + int input = dgst_raw[i]; + for (b = 0; b < 4; b++) { + /* evaluate 2 bit, rest is shifted later */ + x += (input & 0x1) ? 1 : -1; + y += (input & 0x2) ? 1 : -1; + + /* assure we are still in bounds */ + x = std::max(x, 0); + y = std::max(y, 0); + x = std::min(x, FLDSIZE_X - 1); + y = std::min(y, FLDSIZE_Y - 1); + + /* augment the field */ + if (field[x][y] < len - 2) + field[x][y]++; + input = input >> 2; + } + } + + /* mark starting point and end point*/ + field[FLDSIZE_X / 2][FLDSIZE_Y / 2] = len - 1; + field[x][y] = len; + + /* output upper border */ + add_char('+'); + for (i = 0; i < FLDSIZE_X; i++) + add_char('-'); + add_char('+'); + add_char('\n'); + + /* output content */ + for (y = 0; y < FLDSIZE_Y; y++) { + add_char('|'); + for (x = 0; x < FLDSIZE_X; x++) + add_char(augmentation_string[std::min(field[x][y], len)]); + add_char('|'); + add_char('\n'); + } + + /* output lower border */ + add_char('+'); + for (i = 0; i < FLDSIZE_X; i++) + add_char('-'); + add_char('+'); + + return std::string{retval.data(), retval.size()}; +} + +} // namespace barrier diff --git a/src/lib/net/SecureUtils.h b/src/lib/net/SecureUtils.h new file mode 100644 index 0000000..c4d51f3 --- /dev/null +++ b/src/lib/net/SecureUtils.h @@ -0,0 +1,43 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 BARRIER_LIB_NET_SECUREUTILS_H +#define BARRIER_LIB_NET_SECUREUTILS_H + +#include "FingerprintData.h" +#include +#include +#include +#include + +namespace barrier { + +std::string format_ssl_fingerprint(const std::vector& fingerprint, + bool separator = true); +std::string format_ssl_fingerprint_columns(const std::vector& fingerprint); + +FingerprintData get_ssl_cert_fingerprint(X509* cert, FingerprintType type); + +FingerprintData get_pem_file_cert_fingerprint(const std::string& path, FingerprintType type); + +void generate_pem_self_signed_cert(const std::string& path); + +std::string create_fingerprint_randomart(const std::vector& dgst_raw); + +} // namespace barrier + +#endif // BARRIER_LIB_NET_SECUREUTILS_H diff --git a/src/lib/net/SocketMultiplexer.cpp b/src/lib/net/SocketMultiplexer.cpp index cdb9039..5a2328e 100644 --- a/src/lib/net/SocketMultiplexer.cpp +++ b/src/lib/net/SocketMultiplexer.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -26,7 +26,6 @@ #include "arch/Arch.h" #include "arch/XArch.h" #include "base/Log.h" -#include "base/TMethodJob.h" #include "common/stdvector.h" // @@ -58,8 +57,7 @@ SocketMultiplexer::SocketMultiplexer() : m_jobListLockLocker(NULL) { // start thread - m_thread = new Thread(new TMethodJob( - this, &SocketMultiplexer::serviceThread)); + m_thread = new Thread([this](){ service_thread(); }); } SocketMultiplexer::~SocketMultiplexer() @@ -95,7 +93,7 @@ void SocketMultiplexer::addSocket(ISocket* socket, std::unique_ptrsecond)) { @@ -138,8 +136,7 @@ SocketMultiplexer::removeSocket(ISocket* socket) unlockJobList(); } -void -SocketMultiplexer::serviceThread(void*) +void SocketMultiplexer::service_thread() { std::vector pfds; IArchNetwork::PollEntry pfd; @@ -179,7 +176,7 @@ SocketMultiplexer::serviceThread(void*) pfd.m_events |= IArchNetwork::kPOLLOUT; } pfds.push_back(pfd); - } + } jobCursor = nextCursor(cursor); } deleteCursor(cursor); diff --git a/src/lib/net/SocketMultiplexer.h b/src/lib/net/SocketMultiplexer.h index 9891558..b13c725 100644 --- a/src/lib/net/SocketMultiplexer.h +++ b/src/lib/net/SocketMultiplexer.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -67,7 +67,7 @@ private: // and m_update while m_pollable and m_polling are true. all other // threads must only modify these when m_pollable and m_polling are // false. only the service thread sets m_polling. - void serviceThread(void*); + void service_thread(); // create, iterate, and destroy a cursor. a cursor is used to // safely iterate through the job list while other threads modify diff --git a/src/lib/net/TCPListenSocket.cpp b/src/lib/net/TCPListenSocket.cpp index 26f03b0..2c305fc 100644 --- a/src/lib/net/TCPListenSocket.cpp +++ b/src/lib/net/TCPListenSocket.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -70,8 +70,10 @@ TCPListenSocket::bind(const NetworkAddress& addr) ARCH->bindSocket(m_socket, addr.getAddress()); ARCH->listenOnSocket(m_socket); - auto new_job = std::make_unique>( - this, &TCPListenSocket::serviceListening, m_socket, true, false); + auto new_job = std::make_unique( + [this](auto j, auto r, auto w, auto e) + { return serviceListening(j, r, w, e); }, + m_socket, true, false); m_socketMultiplexer->addSocket(this, std::move(new_job)); } @@ -136,8 +138,10 @@ TCPListenSocket::accept() void TCPListenSocket::setListeningJob() { - auto new_job = std::make_unique>( - this, &TCPListenSocket::serviceListening, m_socket, true, false); + auto new_job = std::make_unique( + [this](auto j, auto r, auto w, auto e) + { return serviceListening(j, r, w, e); }, + m_socket, true, false); m_socketMultiplexer->addSocket(this, std::move(new_job)); } diff --git a/src/lib/net/TCPListenSocket.h b/src/lib/net/TCPListenSocket.h index f3ababc..109c1c3 100644 --- a/src/lib/net/TCPListenSocket.h +++ b/src/lib/net/TCPListenSocket.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/net/TCPSocket.cpp b/src/lib/net/TCPSocket.cpp index 09a8f17..fa7edcc 100644 --- a/src/lib/net/TCPSocket.cpp +++ b/src/lib/net/TCPSocket.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -33,9 +33,7 @@ #include #include -// -// TCPSocket -// +static const std::size_t MAX_INPUT_BUFFER_SIZE = 1024 * 1024; TCPSocket::TCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, IArchNetwork::EAddressFamily family) : IDataSocket(events), @@ -335,19 +333,23 @@ TCPSocket::doRead() UInt8 buffer[4096]; memset(buffer, 0, sizeof(buffer)); size_t bytesRead = 0; - + bytesRead = ARCH->readSocket(m_socket, buffer, sizeof(buffer)); - + if (bytesRead > 0) { bool wasEmpty = (m_inputBuffer.getSize() == 0); - + // slurp up as much as possible do { m_inputBuffer.write(buffer, (UInt32)bytesRead); + if (m_inputBuffer.getSize() > MAX_INPUT_BUFFER_SIZE) { + break; + } + bytesRead = ARCH->readSocket(m_socket, buffer, sizeof(buffer)); } while (bytesRead > 0); - + // send input ready if input buffer was empty if (wasEmpty) { sendEvent(m_events->forIStream().inputReady()); @@ -365,7 +367,7 @@ TCPSocket::doRead() m_readable = false; return kNew; } - + return kRetry; } @@ -384,7 +386,7 @@ TCPSocket::doWrite() discardWrittenData(bytesWrote); return kNew; } - + return kRetry; } @@ -424,18 +426,20 @@ std::unique_ptr TCPSocket::newJob() if (!(m_readable || m_writable)) { return {}; } - return std::make_unique>( - this, &TCPSocket::serviceConnecting, - m_socket, m_readable, m_writable); + return std::make_unique( + [this](auto j, auto r, auto w, auto e) + { return serviceConnecting(j, r, w, e); }, + m_socket, m_readable, m_writable); } else { - if (!(m_readable || (m_writable && (m_outputBuffer.getSize() > 0)))) { + auto writable = m_writable && (m_outputBuffer.getSize() > 0); + if (!(m_readable || writable)) { return {}; } - return std::make_unique>( - this, &TCPSocket::serviceConnected, - m_socket, m_readable, - m_writable && (m_outputBuffer.getSize() > 0)); + return std::make_unique( + [this](auto j, auto r, auto w, auto e) + { return serviceConnected(j, r, w, e); }, + m_socket, m_readable, writable); } } diff --git a/src/lib/net/TCPSocket.h b/src/lib/net/TCPSocket.h index 0b98888..45aed07 100644 --- a/src/lib/net/TCPSocket.h +++ b/src/lib/net/TCPSocket.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -59,7 +59,7 @@ public: // IDataSocket overrides virtual void connect(const NetworkAddress&); - + virtual std::unique_ptr newJob(); protected: @@ -68,7 +68,7 @@ protected: kRetry, //!< Retry the same job kNew //!< Require a new job }; - + ArchSocket getSocket() { return m_socket; } IEventQueue* getEvents() { return m_events; } virtual EJobResult doRead(); @@ -105,7 +105,7 @@ protected: IEventQueue* m_events; StreamBuffer m_inputBuffer; StreamBuffer m_outputBuffer; - + private: Mutex m_mutex; ArchSocket m_socket; diff --git a/src/lib/net/TCPSocketFactory.cpp b/src/lib/net/TCPSocketFactory.cpp index 6ff4ef8..30e930e 100644 --- a/src/lib/net/TCPSocketFactory.cpp +++ b/src/lib/net/TCPSocketFactory.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -40,11 +40,12 @@ TCPSocketFactory::~TCPSocketFactory() // do nothing } -IDataSocket* -TCPSocketFactory::create(IArchNetwork::EAddressFamily family, bool secure) const +IDataSocket* TCPSocketFactory::create(IArchNetwork::EAddressFamily family, + ConnectionSecurityLevel security_level) const { - if (secure) { - SecureSocket* secureSocket = new SecureSocket(m_events, m_socketMultiplexer, family); + if (security_level != ConnectionSecurityLevel::PLAINTEXT) { + SecureSocket* secureSocket = new SecureSocket(m_events, m_socketMultiplexer, family, + security_level); secureSocket->initSsl (false); return secureSocket; } @@ -53,12 +54,12 @@ TCPSocketFactory::create(IArchNetwork::EAddressFamily family, bool secure) const } } -IListenSocket* -TCPSocketFactory::createListen(IArchNetwork::EAddressFamily family, bool secure) const +IListenSocket* TCPSocketFactory::createListen(IArchNetwork::EAddressFamily family, + ConnectionSecurityLevel security_level) const { IListenSocket* socket = NULL; - if (secure) { - socket = new SecureListenSocket(m_events, m_socketMultiplexer, family); + if (security_level != ConnectionSecurityLevel::PLAINTEXT) { + socket = new SecureListenSocket(m_events, m_socketMultiplexer, family, security_level); } else { socket = new TCPListenSocket(m_events, m_socketMultiplexer, family); diff --git a/src/lib/net/TCPSocketFactory.h b/src/lib/net/TCPSocketFactory.h index 0195ec4..ac21cab 100644 --- a/src/lib/net/TCPSocketFactory.h +++ b/src/lib/net/TCPSocketFactory.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -31,12 +31,11 @@ public: virtual ~TCPSocketFactory(); // ISocketFactory overrides - virtual IDataSocket* create( - IArchNetwork::EAddressFamily family, - bool secure) const; - virtual IListenSocket* createListen( - IArchNetwork::EAddressFamily family, - bool secure) const; + virtual IDataSocket* create(IArchNetwork::EAddressFamily family, + ConnectionSecurityLevel security_level) const; + + virtual IListenSocket* createListen(IArchNetwork::EAddressFamily family, + ConnectionSecurityLevel security_level) const; private: IEventQueue* m_events; diff --git a/src/lib/net/TSocketMultiplexerMethodJob.h b/src/lib/net/TSocketMultiplexerMethodJob.h index 9e74cdd..4b571ab 100644 --- a/src/lib/net/TSocketMultiplexerMethodJob.h +++ b/src/lib/net/TSocketMultiplexerMethodJob.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -25,81 +25,43 @@ /*! A socket multiplexer job class that invokes a member function. */ -template class TSocketMultiplexerMethodJob : public ISocketMultiplexerJob { public: - using Method = MultiplexerJobStatus (T::*)(ISocketMultiplexerJob*, bool, bool, bool); + using RunFunction = std::function; //! run() invokes \c object->method(arg) - TSocketMultiplexerMethodJob(T* object, Method method, - ArchSocket socket, bool readable, bool writeable); - virtual ~TSocketMultiplexerMethodJob(); + TSocketMultiplexerMethodJob(const RunFunction& func, + ArchSocket socket, bool readable, bool writable) : + func_{func}, + m_socket(ARCH->copySocket(socket)), + m_readable(readable), + m_writable(writable) + { + } + + ~TSocketMultiplexerMethodJob() override + { + ARCH->closeSocket(m_socket); + } // IJob overrides - virtual MultiplexerJobStatus run(bool readable, bool writable, bool error) override; - virtual ArchSocket getSocket() const override; - virtual bool isReadable() const override; - virtual bool isWritable() const override; + virtual MultiplexerJobStatus run(bool readable, bool writable, bool error) override + { + if (func_) { + return func_(this, readable, writable, error); + } + return {false, {}}; + } + + virtual ArchSocket getSocket() const override { return m_socket; } + virtual bool isReadable() const override { return m_readable; } + virtual bool isWritable() const override { return m_writable; } private: - T* m_object; - Method m_method; + RunFunction func_; ArchSocket m_socket; bool m_readable; bool m_writable; - void* m_arg; }; -template -inline -TSocketMultiplexerMethodJob::TSocketMultiplexerMethodJob(T* object, - Method method, ArchSocket socket, - bool readable, bool writable) : - m_object(object), - m_method(method), - m_socket(ARCH->copySocket(socket)), - m_readable(readable), - m_writable(writable) -{ - // do nothing -} - -template -inline -TSocketMultiplexerMethodJob::~TSocketMultiplexerMethodJob() -{ - ARCH->closeSocket(m_socket); -} - -template -inline MultiplexerJobStatus TSocketMultiplexerMethodJob::run(bool read, bool write, bool error) -{ - if (m_object != NULL) { - return (m_object->*m_method)(this, read, write, error); - } - return {false, {}}; -} - -template -inline -ArchSocket -TSocketMultiplexerMethodJob::getSocket() const -{ - return m_socket; -} - -template -inline -bool -TSocketMultiplexerMethodJob::isReadable() const -{ - return m_readable; -} -template -inline -bool -TSocketMultiplexerMethodJob::isWritable() const -{ - return m_writable; -} diff --git a/src/lib/net/XSocket.cpp b/src/lib/net/XSocket.cpp index eed7a26..6a50537 100644 --- a/src/lib/net/XSocket.cpp +++ b/src/lib/net/XSocket.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -63,7 +63,7 @@ std::string XSocketAddress::getWhat() const noexcept "invalid port" // m_port may not be set to the bad port }; return format(s_errorID[m_error], s_errorMsg[m_error], - m_hostname.c_str(), + m_hostname.c_str(), barrier::string::sprintf("%d", m_port).c_str()); } diff --git a/src/lib/net/XSocket.h b/src/lib/net/XSocket.h index d12278e..cafe59c 100644 --- a/src/lib/net/XSocket.h +++ b/src/lib/net/XSocket.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/CMakeLists.txt b/src/lib/platform/CMakeLists.txt index a1718a1..75551b7 100644 --- a/src/lib/platform/CMakeLists.txt +++ b/src/lib/platform/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 diff --git a/src/lib/platform/IMSWindowsClipboardFacade.h b/src/lib/platform/IMSWindowsClipboardFacade.h index 03c6248..d848184 100644 --- a/src/lib/platform/IMSWindowsClipboardFacade.h +++ b/src/lib/platform/IMSWindowsClipboardFacade.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -33,4 +33,4 @@ public: virtual ~IMSWindowsClipboardFacade() { } }; -#endif \ No newline at end of file +#endif diff --git a/src/lib/platform/IOSXKeyResource.cpp b/src/lib/platform/IOSXKeyResource.cpp index 0c5abe7..1866968 100644 --- a/src/lib/platform/IOSXKeyResource.cpp +++ b/src/lib/platform/IOSXKeyResource.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 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 @@ -128,7 +128,7 @@ IOSXKeyResource::getKeyID(UInt8 c) // encoding with char value 214). if it did then make no key, // otherwise CFStringCreateMutableCopy() will crash. if (cfString == NULL) { - return kKeyNone; + return kKeyNone; } // convert to precomposed diff --git a/src/lib/platform/IOSXKeyResource.h b/src/lib/platform/IOSXKeyResource.h index fc190ef..b032bd9 100644 --- a/src/lib/platform/IOSXKeyResource.h +++ b/src/lib/platform/IOSXKeyResource.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 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 @@ -27,10 +27,10 @@ public: virtual UInt32 getNumButtons() const = 0; virtual UInt32 getTableForModifier(UInt32 mask) const = 0; virtual KeyID getKey(UInt32 table, UInt32 button) const = 0; - + // Convert a character in the current script to the equivalent KeyID static KeyID getKeyID(UInt8); - + // Convert a unicode character to the equivalent KeyID. static KeyID unicharToKeyID(UniChar); }; diff --git a/src/lib/platform/IXWindowsImpl.h b/src/lib/platform/IXWindowsImpl.h index ddcaf2f..37c59b2 100644 --- a/src/lib/platform/IXWindowsImpl.h +++ b/src/lib/platform/IXWindowsImpl.h @@ -3,39 +3,31 @@ #include "config.h" -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include -# include -# define XK_MISCELLANY -# define XK_XKB_KEYS -# include -# if HAVE_X11_EXTENSIONS_DPMS_H - extern "C" { -# include - } -# endif -# if HAVE_X11_EXTENSIONS_XTEST_H -# include -# else -# error The XTest extension is required to build barrier -# endif -# if HAVE_X11_EXTENSIONS_XINERAMA_H - // Xinerama.h may lack extern "C" for inclusion by C++ - extern "C" { -# include - } -# endif -# if HAVE_X11_EXTENSIONS_XRANDR_H -# include -# endif -# if HAVE_XKB_EXTENSION -# include -# endif -# ifdef HAVE_XI2 -# include -# endif +#include +#include +#define XK_MISCELLANY +#define XK_XKB_KEYS +#include +#if HAVE_X11_EXTENSIONS_DPMS_H + extern "C" { +# include + } +#endif +#include +#if HAVE_X11_EXTENSIONS_XINERAMA_H + // Xinerama.h may lack extern "C" for inclusion by C++ + extern "C" { +# include + } +#endif +#if HAVE_X11_EXTENSIONS_XRANDR_H +# include +#endif +#if HAVE_XKB_EXTENSION +# include +#endif +#ifdef HAVE_XI2 +# include #endif class IXWindowsImpl { diff --git a/src/lib/platform/ImmuneKeysReader.cpp b/src/lib/platform/ImmuneKeysReader.cpp index 72baed3..eaeedc1 100644 --- a/src/lib/platform/ImmuneKeysReader.cpp +++ b/src/lib/platform/ImmuneKeysReader.cpp @@ -50,4 +50,4 @@ static void add_key(const char * const buffer, std::vector &keys) } } return true; -} \ No newline at end of file +} diff --git a/src/lib/platform/ImmuneKeysReader.h b/src/lib/platform/ImmuneKeysReader.h index b46cbbe..536dd45 100644 --- a/src/lib/platform/ImmuneKeysReader.h +++ b/src/lib/platform/ImmuneKeysReader.h @@ -27,8 +27,4 @@ class ImmuneKeysReader { public: static bool get_list(const char * const path, std::vector &keys, std::string &badLine); - -private: - // static class - explicit ImmuneKeysReader() {} }; diff --git a/src/lib/platform/MSWindowsClipboard.cpp b/src/lib/platform/MSWindowsClipboard.cpp index 20445d4..fa59c3e 100644 --- a/src/lib/platform/MSWindowsClipboard.cpp +++ b/src/lib/platform/MSWindowsClipboard.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -70,7 +70,7 @@ MSWindowsClipboard::emptyUnowned() // empty the clipboard (and take ownership) if (!EmptyClipboard()) { - // unable to cause this in integ tests, but this error has never + // unable to cause this in integ tests, but this error has never // actually been reported by users. LOG((CLOG_DEBUG "failed to grab clipboard")); return false; diff --git a/src/lib/platform/MSWindowsClipboard.h b/src/lib/platform/MSWindowsClipboard.h index 35ccb56..415f31c 100644 --- a/src/lib/platform/MSWindowsClipboard.h +++ b/src/lib/platform/MSWindowsClipboard.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsClipboardAnyTextConverter.cpp b/src/lib/platform/MSWindowsClipboardAnyTextConverter.cpp index 85a7dbe..e46b1de 100644 --- a/src/lib/platform/MSWindowsClipboardAnyTextConverter.cpp +++ b/src/lib/platform/MSWindowsClipboardAnyTextConverter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsClipboardAnyTextConverter.h b/src/lib/platform/MSWindowsClipboardAnyTextConverter.h index 622d281..463a24a 100644 --- a/src/lib/platform/MSWindowsClipboardAnyTextConverter.h +++ b/src/lib/platform/MSWindowsClipboardAnyTextConverter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp b/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp index 7d38fda..bac8cb6 100644 --- a/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp +++ b/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsClipboardBitmapConverter.h b/src/lib/platform/MSWindowsClipboardBitmapConverter.h index 2733884..9ca27ee 100644 --- a/src/lib/platform/MSWindowsClipboardBitmapConverter.h +++ b/src/lib/platform/MSWindowsClipboardBitmapConverter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsClipboardFacade.cpp b/src/lib/platform/MSWindowsClipboardFacade.cpp index 3b6478f..a6e1207 100644 --- a/src/lib/platform/MSWindowsClipboardFacade.cpp +++ b/src/lib/platform/MSWindowsClipboardFacade.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsClipboardFacade.h b/src/lib/platform/MSWindowsClipboardFacade.h index a95e835..cdbd796 100644 --- a/src/lib/platform/MSWindowsClipboardFacade.h +++ b/src/lib/platform/MSWindowsClipboardFacade.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp b/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp index a1f1212..d2ac3dd 100644 --- a/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp +++ b/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsClipboardHTMLConverter.h b/src/lib/platform/MSWindowsClipboardHTMLConverter.h index 51607a7..87d7fda 100644 --- a/src/lib/platform/MSWindowsClipboardHTMLConverter.h +++ b/src/lib/platform/MSWindowsClipboardHTMLConverter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsClipboardTextConverter.cpp b/src/lib/platform/MSWindowsClipboardTextConverter.cpp index 1500e7e..15f2cc2 100644 --- a/src/lib/platform/MSWindowsClipboardTextConverter.cpp +++ b/src/lib/platform/MSWindowsClipboardTextConverter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsClipboardTextConverter.h b/src/lib/platform/MSWindowsClipboardTextConverter.h index 6e265a2..4ebfa36 100644 --- a/src/lib/platform/MSWindowsClipboardTextConverter.h +++ b/src/lib/platform/MSWindowsClipboardTextConverter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsClipboardUTF16Converter.cpp b/src/lib/platform/MSWindowsClipboardUTF16Converter.cpp index 4b72717..52c6d4c 100644 --- a/src/lib/platform/MSWindowsClipboardUTF16Converter.cpp +++ b/src/lib/platform/MSWindowsClipboardUTF16Converter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsClipboardUTF16Converter.h b/src/lib/platform/MSWindowsClipboardUTF16Converter.h index 1a9d435..7314678 100644 --- a/src/lib/platform/MSWindowsClipboardUTF16Converter.h +++ b/src/lib/platform/MSWindowsClipboardUTF16Converter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsDebugOutputter.cpp b/src/lib/platform/MSWindowsDebugOutputter.cpp index 43c38ad..22442ad 100644 --- a/src/lib/platform/MSWindowsDebugOutputter.cpp +++ b/src/lib/platform/MSWindowsDebugOutputter.cpp @@ -2,11 +2,11 @@ * barrier -- 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 diff --git a/src/lib/platform/MSWindowsDebugOutputter.h b/src/lib/platform/MSWindowsDebugOutputter.h index 01fd97e..e8ba5e6 100644 --- a/src/lib/platform/MSWindowsDebugOutputter.h +++ b/src/lib/platform/MSWindowsDebugOutputter.h @@ -2,11 +2,11 @@ * barrier -- 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 @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + #pragma once #include "base/ILogOutputter.h" diff --git a/src/lib/platform/MSWindowsDesks.cpp b/src/lib/platform/MSWindowsDesks.cpp index 768ccb4..d126e13 100644 --- a/src/lib/platform/MSWindowsDesks.cpp +++ b/src/lib/platform/MSWindowsDesks.cpp @@ -3,11 +3,11 @@ * Copyright (C) 2018 Debauchee Open Source Group * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -27,9 +27,7 @@ #include "arch/win32/ArchMiscWindows.h" #include "base/Log.h" #include "base/IEventQueue.h" -#include "base/IJob.h" #include "base/TMethodEventJob.h" -#include "base/TMethodJob.h" #include "base/IEventQueue.h" #include @@ -97,10 +95,9 @@ // MSWindowsDesks // -MSWindowsDesks::MSWindowsDesks( - bool isPrimary, bool noHooks, +MSWindowsDesks::MSWindowsDesks(bool isPrimary, bool noHooks, const IScreenSaver* screensaver, IEventQueue* events, - IJob* updateKeys, bool stopOnDeskSwitch) : + const std::function& updateKeys, bool stopOnDeskSwitch) : m_isPrimary(isPrimary), m_noHooks(noHooks), m_isOnScreen(m_isPrimary), @@ -130,7 +127,6 @@ MSWindowsDesks::~MSWindowsDesks() disable(); destroyClass(m_deskClass); destroyCursor(m_cursor); - delete m_updateKeys; } void @@ -602,13 +598,11 @@ MSWindowsDesks::deskLeave(Desk* desk, HKL keyLayout) } } -void -MSWindowsDesks::deskThread(void* vdesk) +void MSWindowsDesks::desk_thread(Desk* desk) { MSG msg; // use given desktop for this thread - Desk* desk = static_cast(vdesk); desk->m_threadID = GetCurrentThreadId(); desk->m_window = NULL; desk->m_foregroundWindow = NULL; @@ -709,7 +703,7 @@ MSWindowsDesks::deskThread(void* vdesk) } case BARRIER_MSG_SYNC_KEYS: - m_updateKeys->run(); + m_updateKeys(); break; case BARRIER_MSG_SCREENSAVER: @@ -752,8 +746,7 @@ MSWindowsDesks::Desk* MSWindowsDesks::addDesk(const std::string& name, HDESK hde desk->m_name = name; desk->m_desk = hdesk; desk->m_targetID = GetCurrentThreadId(); - desk->m_thread = new Thread(new TMethodJob( - this, &MSWindowsDesks::deskThread, desk)); + desk->m_thread = new Thread([this, desk]() { desk_thread(desk); }); waitForDesk(); m_desks.insert(std::make_pair(name, desk)); return desk; @@ -793,7 +786,7 @@ MSWindowsDesks::checkDesk() desk = index->second; } - // if we are told to shut down on desk switch, and this is not the + // if we are told to shut down on desk switch, and this is not the // first switch, then shut down. if (m_stopOnDeskSwitch && m_activeDesk != NULL && name != m_activeDeskName) { LOG((CLOG_DEBUG "shutting down because of desk switch to \"%s\"", name.c_str())); @@ -803,7 +796,7 @@ MSWindowsDesks::checkDesk() // if active desktop changed then tell the old and new desk threads // about the change. don't switch desktops when the screensaver is - // active becaue we'd most likely switch to the screensaver desktop + // active because we'd most likely switch to the screensaver desktop // which would have the side effect of forcing the screensaver to // stop. if (name != m_activeDeskName && !m_screensaver->isActive()) { diff --git a/src/lib/platform/MSWindowsDesks.h b/src/lib/platform/MSWindowsDesks.h index 6e5e709..6292f98 100644 --- a/src/lib/platform/MSWindowsDesks.h +++ b/src/lib/platform/MSWindowsDesks.h @@ -3,11 +3,11 @@ * Copyright (C) 2018 Debauchee Open Source Group * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -26,15 +26,16 @@ #include "mt/CondVar.h" #include "mt/Mutex.h" #include "common/stdmap.h" +#include #include #define WIN32_LEAN_AND_MEAN #include + class Event; class EventQueueTimer; class Thread; -class IJob; class IScreenSaver; class IEventQueue; @@ -68,7 +69,7 @@ public: MSWindowsDesks( bool isPrimary, bool noHooks, const IScreenSaver* screensaver, IEventQueue* events, - IJob* updateKeys, bool stopOnDeskSwitch); + const std::function& updateKeys, bool stopOnDeskSwitch); ~MSWindowsDesks(); //! @name manipulators @@ -219,7 +220,7 @@ private: void deskMouseRelativeMove(SInt32 dx, SInt32 dy) const; void deskEnter(Desk* desk); void deskLeave(Desk* desk, HKL keyLayout); - void deskThread(void* vdesk); + void desk_thread(Desk* desk); // desk switch checking and handling Desk* addDesk(const std::string& name, HDESK hdesk); @@ -284,7 +285,7 @@ private: Desks m_desks; // keyboard stuff - IJob* m_updateKeys; + std::function m_updateKeys; HKL m_keyLayout; // options diff --git a/src/lib/platform/MSWindowsDropTarget.cpp b/src/lib/platform/MSWindowsDropTarget.cpp index d647808..095ab53 100644 --- a/src/lib/platform/MSWindowsDropTarget.cpp +++ b/src/lib/platform/MSWindowsDropTarget.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-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 @@ -53,7 +53,7 @@ MSWindowsDropTarget::DragEnter(IDataObject* dataObject, DWORD keyState, POINTL p if (m_allowDrop) { getDropData(dataObject); } - + *effect = DROPEFFECT_NONE; return S_OK; @@ -132,7 +132,7 @@ getDropData(IDataObject* dataObject) wcstombs(filename, wcData, wcslen(wcData)); MSWindowsDropTarget::instance().setDraggingFilename(filename); - + GlobalUnlock(stgMed.hGlobal); // release the data using the COM API @@ -167,7 +167,7 @@ ULONG __stdcall MSWindowsDropTarget::Release(void) { LONG count = InterlockedDecrement(&m_refCount); - + if (count == 0) { delete this; return 0; diff --git a/src/lib/platform/MSWindowsDropTarget.h b/src/lib/platform/MSWindowsDropTarget.h index 6d60845..6c3bf69 100644 --- a/src/lib/platform/MSWindowsDropTarget.h +++ b/src/lib/platform/MSWindowsDropTarget.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-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 @@ -44,7 +44,7 @@ public: std::string getDraggingFilename(); void clearDraggingFilename(); - static MSWindowsDropTarget& + static MSWindowsDropTarget& instance(); private: @@ -53,7 +53,7 @@ private: long m_refCount; bool m_allowDrop; std::string m_dragFilename; - + static MSWindowsDropTarget* s_instance; }; diff --git a/src/lib/platform/MSWindowsEventQueueBuffer.cpp b/src/lib/platform/MSWindowsEventQueueBuffer.cpp index 3111367..709d814 100644 --- a/src/lib/platform/MSWindowsEventQueueBuffer.cpp +++ b/src/lib/platform/MSWindowsEventQueueBuffer.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsEventQueueBuffer.h b/src/lib/platform/MSWindowsEventQueueBuffer.h index bc9bde1..6f918d4 100644 --- a/src/lib/platform/MSWindowsEventQueueBuffer.h +++ b/src/lib/platform/MSWindowsEventQueueBuffer.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsHook.cpp b/src/lib/platform/MSWindowsHook.cpp index b9b9740..3230d24 100644 --- a/src/lib/platform/MSWindowsHook.cpp +++ b/src/lib/platform/MSWindowsHook.cpp @@ -3,11 +3,11 @@ * Copyright (C) 2018 Debauchee Open Source Group * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 Chris Schoeneman - * + * * 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 @@ -56,14 +56,13 @@ static BYTE g_deadKeyState[256] = { 0 }; static BYTE g_keyState[256] = { 0 }; static bool g_fakeServerInput = false; static std::vector g_immuneKeys; - -static const std::string ImmuneKeysPath = DataDirectories::profile() + "\\ImmuneKeys.txt"; +static std::string g_immuneKeysPath; static std::vector immune_keys_list() { std::vector keys; std::string badLine; - if (!ImmuneKeysReader::get_list(ImmuneKeysPath.c_str(), keys, badLine)) + if (!ImmuneKeysReader::get_list(g_immuneKeysPath.c_str(), keys, badLine)) LOG((CLOG_ERR "Reading immune keys stopped at: %s", badLine.c_str())); return keys; } @@ -144,9 +143,9 @@ keyboardGetState(BYTE keys[256], DWORD vkCode, bool kf_up) static WPARAM -makeKeyMsg(UINT virtKey, char c, bool noAltGr) +makeKeyMsg(UINT virtKey, WCHAR wc, bool noAltGr) { - return MAKEWPARAM(MAKEWORD(virtKey & 0xff, (BYTE)c), noAltGr ? 1 : 0); + return MAKEWPARAM((WORD)wc, MAKEWORD(virtKey & 0xff, noAltGr ? 1 : 0)); } static @@ -193,7 +192,7 @@ keyboardHookHandler(WPARAM wParam, LPARAM lParam) (lParam & 0x80000000u) != 0) { g_deadRelease = 0; PostThreadMessage(g_threadID, BARRIER_MSG_DEBUG, - wParam | 0x04000000, lParam); + wParam | 0x40000000, lParam); return false; } @@ -245,19 +244,19 @@ keyboardHookHandler(WPARAM wParam, LPARAM lParam) } } - WORD c = 0; + WCHAR wc[2] = { 0, 0 }; // map the key event to a character. we have to put the dead // key back first and this has the side effect of removing it. if (g_deadVirtKey != 0) { - if (ToAscii((UINT)g_deadVirtKey, (g_deadLParam & 0x10ff0000u) >> 16, - g_deadKeyState, &c, flags) == 2) { - // If ToAscii returned 2, it means that we accidentally removed + if (ToUnicode((UINT)g_deadVirtKey, (g_deadLParam & 0x10ff0000u) >> 16, + g_deadKeyState, wc, 2, flags) == 2) { + // If ToUnicode returned 2, it means that we accidentally removed // a double dead key instead of restoring it. Thus, we call - // ToAscii again with the same parameters to restore the + // ToUnicode again with the same parameters to restore the // internal dead key state. - ToAscii((UINT)g_deadVirtKey, (g_deadLParam & 0x10ff0000u) >> 16, - g_deadKeyState, &c, flags); + ToUnicode((UINT)g_deadVirtKey, (g_deadLParam & 0x10ff0000u) >> 16, + g_deadKeyState, wc, 2, flags); // We need to keep track of this because g_deadVirtKey will be // cleared later on; this would cause the dead key release to @@ -267,7 +266,7 @@ keyboardHookHandler(WPARAM wParam, LPARAM lParam) } UINT scanCode = ((lParam & 0x10ff0000u) >> 16); - int n = ToAscii((UINT)wParam, scanCode, keys, &c, flags); + int n = ToUnicode((UINT)wParam, scanCode, keys, wc, 2, flags); // if mapping failed and ctrl and alt are pressed then try again // with both not pressed. this handles the case where ctrl and @@ -279,12 +278,12 @@ keyboardHookHandler(WPARAM wParam, LPARAM lParam) if (n == 0 && (control & 0x80) != 0 && (menu & 0x80) != 0) { noAltGr = true; PostThreadMessage(g_threadID, BARRIER_MSG_DEBUG, - wParam | 0x05000000, lParam); + wParam | 0x50000000, lParam); if (g_deadVirtKey != 0) { - if (ToAscii((UINT)g_deadVirtKey, (g_deadLParam & 0x10ff0000u) >> 16, - g_deadKeyState, &c, flags) == 2) { - ToAscii((UINT)g_deadVirtKey, (g_deadLParam & 0x10ff0000u) >> 16, - g_deadKeyState, &c, flags); + if (ToUnicode((UINT)g_deadVirtKey, (g_deadLParam & 0x10ff0000u) >> 16, + g_deadKeyState, wc, 2, flags) == 2) { + ToUnicode((UINT)g_deadVirtKey, (g_deadLParam & 0x10ff0000u) >> 16, + g_deadKeyState, wc, 2, flags); g_deadRelease = g_deadVirtKey; } } @@ -298,12 +297,12 @@ keyboardHookHandler(WPARAM wParam, LPARAM lParam) keys2[VK_LMENU] = 0; keys2[VK_RMENU] = 0; keys2[VK_MENU] = 0; - n = ToAscii((UINT)wParam, scanCode, keys2, &c, flags); + n = ToUnicode((UINT)wParam, scanCode, keys2, wc, 2, flags); } PostThreadMessage(g_threadID, BARRIER_MSG_DEBUG, - wParam | ((c & 0xff) << 8) | - ((n & 0xff) << 16) | 0x06000000, + (wc[0] & 0xffff) | ((wParam & 0xff) << 16) | + ((n & 0xf) << 24) | 0x60000000, lParam); WPARAM charAndVirtKey = 0; bool clearDeadKey = false; @@ -329,12 +328,12 @@ keyboardHookHandler(WPARAM wParam, LPARAM lParam) case 0: // key doesn't map to a character. this can happen if // non-character keys are pressed after a dead key. - charAndVirtKey = makeKeyMsg((UINT)wParam, (char)0, noAltGr); + charAndVirtKey = makeKeyMsg((UINT)wParam, (WCHAR)0, noAltGr); break; case 1: // key maps to a character composed with dead key - charAndVirtKey = makeKeyMsg((UINT)wParam, (char)LOBYTE(c), noAltGr); + charAndVirtKey = makeKeyMsg((UINT)wParam, wc[0], noAltGr); clearDeadKey = true; break; @@ -342,14 +341,14 @@ keyboardHookHandler(WPARAM wParam, LPARAM lParam) // previous dead key not composed. send a fake key press // and release for the dead key to our window. WPARAM deadCharAndVirtKey = - makeKeyMsg((UINT)g_deadVirtKey, (char)LOBYTE(c), noAltGr); + makeKeyMsg((UINT)g_deadVirtKey, wc[0], noAltGr); PostThreadMessage(g_threadID, BARRIER_MSG_KEY, deadCharAndVirtKey, g_deadLParam & 0x7fffffffu); PostThreadMessage(g_threadID, BARRIER_MSG_KEY, deadCharAndVirtKey, g_deadLParam | 0x80000000u); // use uncomposed character - charAndVirtKey = makeKeyMsg((UINT)wParam, (char)HIBYTE(c), noAltGr); + charAndVirtKey = makeKeyMsg((UINT)wParam, wc[1], noAltGr); clearDeadKey = true; break; } @@ -357,8 +356,8 @@ keyboardHookHandler(WPARAM wParam, LPARAM lParam) // put back the dead key, if any, for the application to use if (g_deadVirtKey != 0) { - ToAscii((UINT)g_deadVirtKey, (g_deadLParam & 0x10ff0000u) >> 16, - g_deadKeyState, &c, flags); + ToUnicode((UINT)g_deadVirtKey, (g_deadLParam & 0x10ff0000u) >> 16, + g_deadKeyState, wc, 2, flags); } // clear out old dead key state @@ -375,7 +374,7 @@ keyboardHookHandler(WPARAM wParam, LPARAM lParam) // forwarding. if (charAndVirtKey != 0) { PostThreadMessage(g_threadID, BARRIER_MSG_DEBUG, - charAndVirtKey | 0x07000000, lParam); + charAndVirtKey | 0x70000000, lParam); PostThreadMessage(g_threadID, BARRIER_MSG_KEY, charAndVirtKey, lParam); } @@ -575,8 +574,9 @@ MSWindowsHook::install() g_fakeServerInput = false; // setup immune keys + g_immuneKeysPath = (barrier::DataDirectories::profile() / "ImmuneKeys.txt").u8string(); g_immuneKeys = immune_keys_list(); - LOG((CLOG_DEBUG "Found %u immune keys in %s", g_immuneKeys.size(), ImmuneKeysPath.c_str())); + LOG((CLOG_DEBUG "Found %u immune keys in %s", g_immuneKeys.size(), g_immuneKeysPath.c_str())); #if NO_GRAB_KEYBOARD // we only need the mouse hook @@ -638,4 +638,4 @@ void MSWindowsHook::uninstallScreenSaver() { g_hkMessage.unset(); -} \ No newline at end of file +} diff --git a/src/lib/platform/MSWindowsHook.h b/src/lib/platform/MSWindowsHook.h index 7b2121c..c6d91a2 100644 --- a/src/lib/platform/MSWindowsHook.h +++ b/src/lib/platform/MSWindowsHook.h @@ -3,11 +3,11 @@ * Copyright (C) 2018 Debauchee Open Source Group * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsHookResource.cpp b/src/lib/platform/MSWindowsHookResource.cpp index ced5ff1..c6349ab 100644 --- a/src/lib/platform/MSWindowsHookResource.cpp +++ b/src/lib/platform/MSWindowsHookResource.cpp @@ -30,4 +30,4 @@ bool WindowsHookResource::unset() } bool WindowsHookResource::is_set() const { return _hook != NULL; } -WindowsHookResource::operator HHOOK() const { return _hook; } \ No newline at end of file +WindowsHookResource::operator HHOOK() const { return _hook; } diff --git a/src/lib/platform/MSWindowsHookResource.h b/src/lib/platform/MSWindowsHookResource.h index b66c4b8..a3c9d83 100644 --- a/src/lib/platform/MSWindowsHookResource.h +++ b/src/lib/platform/MSWindowsHookResource.h @@ -17,4 +17,4 @@ public: private: HHOOK _hook; -}; \ No newline at end of file +}; diff --git a/src/lib/platform/MSWindowsKeyState.cpp b/src/lib/platform/MSWindowsKeyState.cpp index 2f29f72..c723d19 100644 --- a/src/lib/platform/MSWindowsKeyState.cpp +++ b/src/lib/platform/MSWindowsKeyState.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 @@ -21,7 +21,6 @@ #include "platform/MSWindowsDesks.h" #include "mt/Thread.h" #include "arch/win32/ArchMiscWindows.h" -#include "base/FunctionJob.h" #include "base/Log.h" #include "base/String.h" #include "base/IEventQueue.h" @@ -61,17 +60,17 @@ const KeyID MSWindowsKeyState::s_virtualKey[] = /* 0x012 */ { kKeyAlt_L }, // VK_MENU /* 0x013 */ { kKeyPause }, // VK_PAUSE /* 0x014 */ { kKeyCapsLock }, // VK_CAPITAL - /* 0x015 */ { kKeyKana }, // VK_HANGUL, VK_KANA - /* 0x016 */ { kKeyNone }, // undefined + /* 0x015 */ { kKeyNone }, // undefined + /* 0x016 */ { kKeyKana }, // VK_HANGUL, VK_KANA, VK_IME_ON /* 0x017 */ { kKeyNone }, // VK_JUNJA /* 0x018 */ { kKeyNone }, // VK_FINAL /* 0x019 */ { kKeyKanzi }, // VK_HANJA, VK_KANJI - /* 0x01a */ { kKeyNone }, // undefined + /* 0x01a */ { kKeyEisuToggle }, // VK_IME_OFF /* 0x01b */ { kKeyEscape }, // VK_ESCAPE - /* 0x01c */ { kKeyHenkan }, // VK_CONVERT - /* 0x01d */ { kKeyNone }, // VK_NONCONVERT - /* 0x01e */ { kKeyNone }, // VK_ACCEPT - /* 0x01f */ { kKeyNone }, // VK_MODECHANGE + /* 0x01c */ { kKeyHenkan }, // VK_CONVERT + /* 0x01d */ { kKeyMuhenkan }, // VK_NONCONVERT + /* 0x01e */ { kKeyNone }, // VK_ACCEPT + /* 0x01f */ { kKeyNone }, // VK_MODECHANGE /* 0x020 */ { kKeyNone }, // VK_SPACE /* 0x021 */ { kKeyKP_PageUp }, // VK_PRIOR /* 0x022 */ { kKeyKP_PageDown },// VK_NEXT @@ -286,15 +285,15 @@ const KeyID MSWindowsKeyState::s_virtualKey[] = /* 0x0f3 */ { kKeyZenkaku }, // VK_OEM_AUTO /* 0x0f4 */ { kKeyZenkaku }, // VK_OEM_ENLW /* 0x0f5 */ { kKeyNone }, // OEM specific - /* 0x0f6 */ { kKeyNone }, // VK_ATTN - /* 0x0f7 */ { kKeyNone }, // VK_CRSEL - /* 0x0f8 */ { kKeyNone }, // VK_EXSEL - /* 0x0f9 */ { kKeyNone }, // VK_EREOF - /* 0x0fa */ { kKeyNone }, // VK_PLAY - /* 0x0fb */ { kKeyNone }, // VK_ZOOM + /* 0x0f6 */ { kKeyNone }, // VK_ATTN + /* 0x0f7 */ { kKeyNone }, // VK_CRSEL + /* 0x0f8 */ { kKeyNone }, // VK_EXSEL + /* 0x0f9 */ { kKeyNone }, // VK_EREOF + /* 0x0fa */ { kKeyNone }, // VK_PLAY + /* 0x0fb */ { kKeyNone }, // VK_ZOOM /* 0x0fc */ { kKeyNone }, // reserved - /* 0x0fd */ { kKeyNone }, // VK_PA1 - /* 0x0fe */ { kKeyNone }, // VK_OEM_CLEAR + /* 0x0fd */ { kKeyNone }, // VK_PA1 + /* 0x0fe */ { kKeyNone }, // VK_OEM_CLEAR /* 0x0ff */ { kKeyNone }, // reserved /* 0x100 */ { kKeyNone }, // reserved @@ -320,15 +319,15 @@ const KeyID MSWindowsKeyState::s_virtualKey[] = /* 0x114 */ { kKeyNone }, // VK_CAPITAL /* 0x115 */ { kKeyHangul }, // VK_HANGUL /* 0x116 */ { kKeyNone }, // undefined - /* 0x117 */ { kKeyNone }, // VK_JUNJA - /* 0x118 */ { kKeyNone }, // VK_FINAL + /* 0x117 */ { kKeyNone }, // VK_JUNJA + /* 0x118 */ { kKeyNone }, // VK_FINAL /* 0x119 */ { kKeyHanja }, // VK_HANJA /* 0x11a */ { kKeyNone }, // undefined /* 0x11b */ { kKeyNone }, // VK_ESCAPE - /* 0x11c */ { kKeyNone }, // VK_CONVERT - /* 0x11d */ { kKeyNone }, // VK_NONCONVERT - /* 0x11e */ { kKeyNone }, // VK_ACCEPT - /* 0x11f */ { kKeyNone }, // VK_MODECHANGE + /* 0x11c */ { kKeyNone }, // VK_CONVERT + /* 0x11d */ { kKeyNone }, // VK_NONCONVERT + /* 0x11e */ { kKeyNone }, // VK_ACCEPT + /* 0x11f */ { kKeyNone }, // VK_MODECHANGE /* 0x120 */ { kKeyNone }, // VK_SPACE /* 0x121 */ { kKeyPageUp }, // VK_PRIOR /* 0x122 */ { kKeyPageDown }, // VK_NEXT @@ -543,15 +542,15 @@ const KeyID MSWindowsKeyState::s_virtualKey[] = /* 0x1f3 */ { kKeyNone }, // VK_OEM_AUTO /* 0x1f4 */ { kKeyNone }, // VK_OEM_ENLW /* 0x1f5 */ { kKeyNone }, // OEM specific - /* 0x1f6 */ { kKeyNone }, // VK_ATTN - /* 0x1f7 */ { kKeyNone }, // VK_CRSEL - /* 0x1f8 */ { kKeyNone }, // VK_EXSEL - /* 0x1f9 */ { kKeyNone }, // VK_EREOF - /* 0x1fa */ { kKeyNone }, // VK_PLAY - /* 0x1fb */ { kKeyNone }, // VK_ZOOM + /* 0x1f6 */ { kKeyNone }, // VK_ATTN + /* 0x1f7 */ { kKeyNone }, // VK_CRSEL + /* 0x1f8 */ { kKeyNone }, // VK_EXSEL + /* 0x1f9 */ { kKeyNone }, // VK_EREOF + /* 0x1fa */ { kKeyNone }, // VK_PLAY + /* 0x1fb */ { kKeyNone }, // VK_ZOOM /* 0x1fc */ { kKeyNone }, // reserved - /* 0x1fd */ { kKeyNone }, // VK_PA1 - /* 0x1fe */ { kKeyNone }, // VK_OEM_CLEAR + /* 0x1fd */ { kKeyNone }, // VK_PA1 + /* 0x1fe */ { kKeyNone }, // VK_OEM_CLEAR /* 0x1ff */ { kKeyNone } // reserved }; @@ -688,34 +687,17 @@ MSWindowsKeyState::mapKeyFromEvent(WPARAM charAndVirtKey, KeyModifierControl | KeyModifierAlt; // extract character, virtual key, and if we didn't use AltGr - char c = (char)((charAndVirtKey & 0xff00u) >> 8); - UINT vkCode = (charAndVirtKey & 0xffu); - bool noAltGr = ((charAndVirtKey & 0xff0000u) != 0); + WCHAR wc = (WCHAR)(charAndVirtKey & 0xffffu); + UINT vkCode = ((charAndVirtKey >> 16) & 0xffu); + bool noAltGr = ((charAndVirtKey & 0xff000000u) != 0); // handle some keys via table lookup KeyID id = getKeyID(vkCode, (KeyButton)((info >> 16) & 0x1ffu)); // check if not in table; map character to key id - if (id == kKeyNone && c != 0) { - if ((c & 0x80u) == 0) { - // ASCII - id = static_cast(c) & 0xffu; - } - else { - // character is not really ASCII. instead it's some - // character in the current ANSI code page. try to - // convert that to a Unicode character. if we fail - // then use the single byte character as is. - char src = c; - wchar_t unicode; - if (MultiByteToWideChar(CP_THREAD_ACP, MB_PRECOMPOSED, - &src, 1, &unicode, 1) > 0) { - id = static_cast(unicode); - } - else { - id = static_cast(c) & 0xffu; - } - } + if (id == kKeyNone && wc != 0) { + // UTF16 + id = static_cast(wc) & 0xffffu; } // set modifier mask @@ -821,15 +803,14 @@ MSWindowsKeyState::fakeCtrlAltDel() CloseHandle(hEvtSendSas); } else { - Thread cad(new FunctionJob(&MSWindowsKeyState::ctrlAltDelThread)); + Thread cad([this](){ ctrl_alt_del_thread(); }); cad.wait(); } return true; } -void -MSWindowsKeyState::ctrlAltDelThread(void*) +void MSWindowsKeyState::ctrl_alt_del_thread() { // get the Winlogon desktop at whatever privilege we can HDESK desk = OpenDesktop("Winlogon", 0, FALSE, MAXIMUM_ALLOWED); @@ -959,7 +940,7 @@ MSWindowsKeyState::getKeyMap(barrier::KeyMap& keyMap) // deal with certain virtual keys specially switch (vk) { case VK_SHIFT: - // this is important for sending the correct modifier to the + // this is important for sending the correct modifier to the // client, a patch from bug #242 (right shift broken for ms // remote desktop) removed this to just use left shift, which // caused bug #2799 (right shift broken for osx). @@ -1176,7 +1157,7 @@ MSWindowsKeyState::getKeyMap(barrier::KeyMap& keyMap) } } } - + // save each key. the map will automatically discard // duplicates, like an unshift and shifted version of // a key that's insensitive to shift. @@ -1347,7 +1328,7 @@ MSWindowsKeyState::getKeyID(UINT virtualKey, KeyButton button) const if ((LOWORD(m_keyLayout) & 0xffffu) == 0x0412u) { // 0x0412 : Korean Locale ID if (virtualKey == VK_HANGUL || virtualKey == VK_HANJA) { // If shift-space is used to change the input mode, - // the extented bit is not set. So add it to get right key id. + // the extended bit is not set. So add it to get right key id. button |= 0x100u; } } @@ -1374,7 +1355,7 @@ MSWindowsKeyState::getIDForKey(barrier::KeyMap::KeyItem& item, virtualKey, button, keyState, unicode, sizeof(unicode) / sizeof(unicode[0]), 0, hkl); KeyID id = static_cast(unicode[0]); - + switch (n) { case -1: return barrier::KeyMap::getDeadKey(id); diff --git a/src/lib/platform/MSWindowsKeyState.h b/src/lib/platform/MSWindowsKeyState.h index 3c5fa40..eedcd85 100644 --- a/src/lib/platform/MSWindowsKeyState.h +++ b/src/lib/platform/MSWindowsKeyState.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 @@ -169,7 +169,7 @@ private: typedef std::vector GroupList; // send ctrl+alt+del hotkey event on NT family - static void ctrlAltDelThread(void*); + static void ctrl_alt_del_thread(); bool getGroups(GroupList&) const; void setWindowGroup(SInt32 group); diff --git a/src/lib/platform/MSWindowsScreen.cpp b/src/lib/platform/MSWindowsScreen.cpp index df10270..c995a40 100644 --- a/src/lib/platform/MSWindowsScreen.cpp +++ b/src/lib/platform/MSWindowsScreen.cpp @@ -3,11 +3,11 @@ * Copyright (C) 2018 Debauchee Open Source Group * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -36,11 +36,9 @@ #include "mt/Thread.h" #include "arch/win32/ArchMiscWindows.h" #include "arch/Arch.h" -#include "base/FunctionJob.h" #include "base/Log.h" #include "base/IEventQueue.h" #include "base/TMethodEventJob.h" -#include "base/TMethodJob.h" #include #include @@ -134,8 +132,7 @@ MSWindowsScreen::MSWindowsScreen( m_noHooks, m_screensaver, m_events, - new TMethodJob( - this, &MSWindowsScreen::updateKeysCB), + [this]() { updateKeysCB(); }, stopOnDeskSwitch); m_keyState = new MSWindowsKeyState(m_desks, getEventTarget(), m_events); @@ -145,16 +142,6 @@ MSWindowsScreen::MSWindowsScreen( forceShowCursor(); LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_multimon ? "(multi-monitor)" : "")); LOG((CLOG_DEBUG "window is 0x%08x", m_window)); - - // SHGetFolderPath is deprecated in vista, but use it for xp support. - char desktopPath[MAX_PATH]; - if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, desktopPath))) { - m_desktopPath = std::string(desktopPath); - LOG((CLOG_DEBUG "using desktop for drop target: %s", m_desktopPath.c_str())); - } - else { - LOG((CLOG_ERR "failed to get desktop path, no drop target available, error=%d", GetLastError())); - } OleInitialize(0); m_dropWindow = createDropWindow(m_class, "DropWindow"); @@ -365,17 +352,13 @@ MSWindowsScreen::leave() forceShowCursor(); if (isDraggingStarted() && !m_isPrimary) { - m_sendDragThread = new Thread( - new TMethodJob( - this, - &MSWindowsScreen::sendDragThread)); + m_sendDragThread = new Thread([this](){ send_drag_thread(); }); } return true; } -void -MSWindowsScreen::sendDragThread(void*) +void MSWindowsScreen::send_drag_thread() { std::string& draggingFilename = getDraggingFilename(); size_t size = draggingFilename.size(); @@ -389,7 +372,7 @@ MSWindowsScreen::sendDragThread(void*) LOG((CLOG_DEBUG "send dragging file to server")); client->sendFileToServer(draggingFilename.c_str()); } - + m_draggingStarted = false; } @@ -636,7 +619,7 @@ MSWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask) LOG((CLOG_WARN "failed to register hotkey %s (id=%04x mask=%04x)", barrier::KeyMap::formatKey(key, mask).c_str(), key, mask)); return 0; } - + LOG((CLOG_DEBUG "registered hotkey %s (id=%04x mask=%04x) as id=%d", barrier::KeyMap::formatKey(key, mask).c_str(), key, mask, id)); return id; } @@ -1114,7 +1097,7 @@ MSWindowsScreen::onKey(WPARAM wParam, LPARAM lParam) static const KeyModifierMask s_ctrlAlt = KeyModifierControl | KeyModifierAlt; - LOG((CLOG_DEBUG1 "event: Key char=%d, vk=0x%02x, nagr=%d, lParam=0x%08x", (wParam & 0xff00u) >> 8, wParam & 0xffu, (wParam & 0x10000u) ? 1 : 0, lParam)); + LOG((CLOG_DEBUG1 "event: Key char=%d, vk=0x%02x, nagr=%d, lParam=0x%08x", wParam & 0xffffu, (wParam >> 16) & 0xffu, (wParam & 0x1000000u) ? 1 : 0, lParam)); // get event info KeyButton button = (KeyButton)((lParam & 0x01ff0000) >> 16); @@ -1132,7 +1115,7 @@ MSWindowsScreen::onKey(WPARAM wParam, LPARAM lParam) // that maps mouse buttons to keys is known to do this. // alternatively, we could just throw these events out. if (button == 0) { - button = m_keyState->virtualKeyToButton(wParam & 0xffu); + button = m_keyState->virtualKeyToButton((wParam >> 16) & 0xffu); if (button == 0) { return true; } @@ -1198,7 +1181,7 @@ MSWindowsScreen::onKey(WPARAM wParam, LPARAM lParam) if (!ignore()) { // check for ctrl+alt+del. we do not want to pass that to the // client. the user can use ctrl+alt+pause to emulate it. - UINT virtKey = (wParam & 0xffu); + UINT virtKey = (wParam >> 16) & 0xffu; if (virtKey == VK_DELETE && (state & s_ctrlAlt) == s_ctrlAlt) { LOG((CLOG_DEBUG "discard ctrl+alt+del")); return true; @@ -1212,9 +1195,9 @@ MSWindowsScreen::onKey(WPARAM wParam, LPARAM lParam) // pressed or released. when mapping the key we require that // we not use AltGr (the 0x10000 flag in wParam) and we not // use the keypad delete key (the 0x01000000 flag in lParam). - wParam = VK_DELETE | 0x00010000u; + wParam = (VK_DELETE << 16) | 0x01000000u; lParam &= 0xfe000000; - lParam |= m_keyState->virtualKeyToButton(wParam & 0xffu) << 16; + lParam |= m_keyState->virtualKeyToButton(VK_DELETE) << 16; lParam |= 0x01000001; } @@ -1242,7 +1225,7 @@ MSWindowsScreen::onHotKey(WPARAM wParam, LPARAM lParam) { // get the key info KeyModifierMask state = getActiveModifiers(); - UINT virtKey = (wParam & 0xffu); + UINT virtKey = (wParam >> 16) & 0xffu; UINT modifiers = 0; if ((state & KeyModifierShift) != 0) { modifiers |= MOD_SHIFT; @@ -1360,7 +1343,7 @@ MSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my) saveMousePosition(mx, my); if (m_isOnScreen) { - + // motion on primary screen sendEvent( m_events->forIPrimaryScreen().motionOnPrimary(), @@ -1370,15 +1353,15 @@ MSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my) m_draggingStarted = true; } } - else + else { // the motion is on the secondary screen, so we warp mouse back to - // center on the server screen. if we don't do this, then the mouse - // will always try to return to the original entry point on the + // center on the server screen. if we don't do this, then the mouse + // will always try to return to the original entry point on the // secondary screen. LOG((CLOG_DEBUG5 "warping server cursor to center: %+d,%+d", m_xCenter, m_yCenter)); warpCursorNoFlush(m_xCenter, m_yCenter); - + // examine the motion. if it's about the distance // from the center of the screen to an edge then // it's probably a bogus motion that we want to @@ -1389,7 +1372,7 @@ MSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my) x + bogusZoneSize > m_x + m_w - m_xCenter || -y + bogusZoneSize > m_yCenter - m_y || y + bogusZoneSize > m_y + m_h - m_yCenter) { - + LOG((CLOG_DEBUG "dropped bogus delta motion: %+d,%+d", x, y)); } else { @@ -1521,8 +1504,8 @@ MSWindowsScreen::warpCursorNoFlush(SInt32 x, SInt32 y) POINT cursorPos; GetCursorPos(&cursorPos); - // there is a bug or round error in SetCursorPos and GetCursorPos on - // a high DPI setting. The check here is for Vista/7 login screen. + // there is a bug or round error in SetCursorPos and GetCursorPos on + // a high DPI setting. The check here is for Vista/7 login screen. // since this feature is mainly for client, so only check on client. if (!isPrimary()) { if ((cursorPos.x != x) && (cursorPos.y != y)) { @@ -1531,7 +1514,7 @@ MSWindowsScreen::warpCursorNoFlush(SInt32 x, SInt32 y) // when at Vista/7 login screen, SetCursorPos does not work (which could be // an MS security feature). instead we can use fakeMouseMove, which calls // mouse_event. - // IMPORTANT: as of implementing this function, it has an annoying side + // IMPORTANT: as of implementing this function, it has an annoying side // effect; instead of the mouse returning to the correct exit point, it // returns to the center of the screen. this could have something to do with // the center screen warping technique used (see comments for onMouseMove @@ -1723,7 +1706,7 @@ MSWindowsScreen::mapPressFromEvent(WPARAM msg, LPARAM) const } void -MSWindowsScreen::updateKeysCB(void*) +MSWindowsScreen::updateKeysCB() { // record which keys we think are down bool down[IKeyState::kNumButtons]; @@ -1888,6 +1871,7 @@ std::string& MSWindowsScreen::getDraggingFilename() SWP_SHOWWINDOW); // TODO: fake these keys properly + ARCH->sleep(.05f); // A tiny sleep here makes the DragEnter event on m_dropWindow trigger much more consistently fakeKeyDown(kKeyEscape, 8192, 1); fakeKeyUp(1); fakeMouseButton(kButtonLeft, false); @@ -1909,21 +1893,39 @@ std::string& MSWindowsScreen::getDraggingFilename() m_draggingFilename = filename; } else { - LOG((CLOG_DEBUG "drag file name is invalid: %s", filename.c_str())); + LOG((CLOG_ERR "drag file name is invalid: %s", filename.c_str())); } } if (m_draggingFilename.empty()) { - LOG((CLOG_DEBUG "failed to get drag file name from OLE")); + LOG((CLOG_ERR "failed to get drag file name from OLE")); } } return m_draggingFilename; } -const std::string& MSWindowsScreen::getDropTarget() const +const std::string& +MSWindowsScreen::getDropTarget() const +{ + if (m_dropTargetPath.empty()) { + // SHGetFolderPath is deprecated in vista, but use it for xp support. + char desktopPath[MAX_PATH]; + if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, desktopPath))) { + m_dropTargetPath = std::string(desktopPath); + LOG((CLOG_INFO "using desktop for drop target: %s", m_dropTargetPath.c_str())); + } + else { + LOG((CLOG_ERR "failed to get desktop path, no drop target available, error=%d", GetLastError())); + } + } + return m_dropTargetPath; +} + +void +MSWindowsScreen::setDropTarget(const std::string& target) { - return m_desktopPath; + m_dropTargetPath = target; } bool @@ -1932,7 +1934,7 @@ MSWindowsScreen::isModifierRepeat(KeyModifierMask oldState, KeyModifierMask stat bool result = false; if (oldState == state && state != 0) { - UINT virtKey = (wParam & 0xffu); + UINT virtKey = (wParam >> 16) & 0xffu; if ((state & KeyModifierShift) != 0 && (virtKey == VK_LSHIFT || virtKey == VK_RSHIFT)) { result = true; diff --git a/src/lib/platform/MSWindowsScreen.h b/src/lib/platform/MSWindowsScreen.h index 49e09df..eaa7b88 100644 --- a/src/lib/platform/MSWindowsScreen.h +++ b/src/lib/platform/MSWindowsScreen.h @@ -3,11 +3,11 @@ * Copyright (C) 2018 Debauchee Open Source Group * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -120,6 +120,7 @@ public: virtual void fakeDraggingFiles(DragFileList fileList); virtual std::string& getDraggingFilename(); virtual const std::string& getDropTarget() const; + virtual void setDropTarget(const std::string&); protected: // IPlatformScreen overrides @@ -198,7 +199,7 @@ private: // HACK bool mapPressFromEvent(WPARAM msg, LPARAM button) const; // job to update the key state - void updateKeysCB(void*); + void updateKeysCB(); // determine whether the mouse is hidden by the system and force // it to be displayed if user has entered this secondary screen. @@ -212,16 +213,16 @@ private: // HACK // our window proc static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM); - + // save last position of mouse to compute next delta movement void saveMousePosition(SInt32 x, SInt32 y); // check if it is a modifier key repeating message - bool isModifierRepeat(KeyModifierMask oldState, + bool isModifierRepeat(KeyModifierMask oldState, KeyModifierMask state, WPARAM wParam) const; // send drag info and data back to server - void sendDragThread(void*); + void send_drag_thread(); private: struct HotKeyItem { @@ -324,15 +325,15 @@ private: bool m_gotOldMouseKeys; MOUSEKEYS m_mouseKeys; MOUSEKEYS m_oldMouseKeys; - + MSWindowsHook m_hook; static MSWindowsScreen* s_screen; - + IEventQueue* m_events; - std::string m_desktopPath; + mutable std::string m_dropTargetPath; MSWindowsDropTarget* m_dropTarget; diff --git a/src/lib/platform/MSWindowsScreenSaver.cpp b/src/lib/platform/MSWindowsScreenSaver.cpp index f9c15fb..9f93792 100644 --- a/src/lib/platform/MSWindowsScreenSaver.cpp +++ b/src/lib/platform/MSWindowsScreenSaver.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -23,7 +23,6 @@ #include "arch/Arch.h" #include "arch/win32/ArchMiscWindows.h" #include "base/Log.h" -#include "base/TMethodJob.h" #include #include @@ -223,8 +222,7 @@ MSWindowsScreenSaver::watchDesktop() // watch desktop in another thread LOG((CLOG_DEBUG "watching screen saver desktop")); m_active = true; - m_watch = new Thread(new TMethodJob(this, - &MSWindowsScreenSaver::watchDesktopThread)); + m_watch = new Thread([this](){ watch_desktop_thread(); }); } void @@ -238,8 +236,7 @@ MSWindowsScreenSaver::watchProcess(HANDLE process) LOG((CLOG_DEBUG "watching screen saver process")); m_process = process; m_active = true; - m_watch = new Thread(new TMethodJob(this, - &MSWindowsScreenSaver::watchProcessThread)); + m_watch = new Thread([this](){ watch_process_thread(); }); } } @@ -260,8 +257,7 @@ MSWindowsScreenSaver::unwatchProcess() } } -void -MSWindowsScreenSaver::watchDesktopThread(void*) +void MSWindowsScreenSaver::watch_desktop_thread() { DWORD reserved = 0; TCHAR* name = NULL; @@ -283,8 +279,7 @@ MSWindowsScreenSaver::watchDesktopThread(void*) } } -void -MSWindowsScreenSaver::watchProcessThread(void*) +void MSWindowsScreenSaver::watch_process_thread() { for (;;) { Thread::testCancel(); diff --git a/src/lib/platform/MSWindowsScreenSaver.h b/src/lib/platform/MSWindowsScreenSaver.h index a117370..4f1dd5f 100644 --- a/src/lib/platform/MSWindowsScreenSaver.h +++ b/src/lib/platform/MSWindowsScreenSaver.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -64,8 +64,8 @@ private: void watchDesktop(); void watchProcess(HANDLE process); void unwatchProcess(); - void watchDesktopThread(void*); - void watchProcessThread(void*); + void watch_desktop_thread(); + void watch_process_thread(); void setSecure(bool secure, bool saveSecureAsInt); bool isSecure(bool* wasSecureAnInt) const; diff --git a/src/lib/platform/MSWindowsSession.cpp b/src/lib/platform/MSWindowsSession.cpp index 8d4f8ce..daa9276 100644 --- a/src/lib/platform/MSWindowsSession.cpp +++ b/src/lib/platform/MSWindowsSession.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2013-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 @@ -45,7 +45,7 @@ MSWindowsSession::isProcessInSession(const char* name, PHANDLE process = NULL) PROCESSENTRY32 entry; entry.dwSize = sizeof(PROCESSENTRY32); - // get the first process, and if we can't do that then it's + // get the first process, and if we can't do that then it's // unlikely we can go any further BOOL gotEntry = Process32First(snapshot, &entry); if (!gotEntry) { @@ -94,7 +94,7 @@ MSWindowsSession::isProcessInSession(const char* name, PHANDLE process = NULL) } std::string nameListJoin; - for(std::list::iterator it = nameList.begin(); + for (std::list::iterator it = nameList.begin(); it != nameList.end(); it++) { nameListJoin.append(*it); nameListJoin.append(", "); @@ -119,7 +119,7 @@ MSWindowsSession::isProcessInSession(const char* name, PHANDLE process = NULL) } } -HANDLE +HANDLE MSWindowsSession::getUserToken(LPSECURITY_ATTRIBUTES security) { HANDLE sourceToken; @@ -127,7 +127,7 @@ MSWindowsSession::getUserToken(LPSECURITY_ATTRIBUTES security) LOG((CLOG_ERR "could not get token from session %d", m_activeSessionId)); throw XArch(new XArchEvalWindows); } - + HANDLE newToken; if (!DuplicateTokenEx( sourceToken, TOKEN_ASSIGN_PRIMARY | TOKEN_ALL_ACCESS, security, @@ -136,7 +136,7 @@ MSWindowsSession::getUserToken(LPSECURITY_ATTRIBUTES security) LOG((CLOG_ERR "could not duplicate token")); throw XArch(new XArchEvalWindows); } - + LOG((CLOG_DEBUG "duplicated, new token: %i", newToken)); return newToken; } diff --git a/src/lib/platform/MSWindowsSession.h b/src/lib/platform/MSWindowsSession.h index e14d7e2..c3fff9d 100644 --- a/src/lib/platform/MSWindowsSession.h +++ b/src/lib/platform/MSWindowsSession.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2013-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 @@ -33,7 +33,7 @@ public: Returns true if the session ID has changed since updateActiveSession was called. */ BOOL hasChanged(); - + bool isProcessInSession(const char* name, PHANDLE process); HANDLE getUserToken(LPSECURITY_ATTRIBUTES security); diff --git a/src/lib/platform/MSWindowsUtil.cpp b/src/lib/platform/MSWindowsUtil.cpp index b6b809f..5a0778e 100644 --- a/src/lib/platform/MSWindowsUtil.cpp +++ b/src/lib/platform/MSWindowsUtil.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsUtil.h b/src/lib/platform/MSWindowsUtil.h index 59f2eac..df80f3f 100644 --- a/src/lib/platform/MSWindowsUtil.h +++ b/src/lib/platform/MSWindowsUtil.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/MSWindowsWatchdog.cpp b/src/lib/platform/MSWindowsWatchdog.cpp index 0aa5505..2d9a61c 100644 --- a/src/lib/platform/MSWindowsWatchdog.cpp +++ b/src/lib/platform/MSWindowsWatchdog.cpp @@ -6,7 +6,7 @@ * 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 @@ -29,7 +29,6 @@ #include "arch/win32/XArchWindows.h" #include "arch/Arch.h" #include "base/log_outputters.h" -#include "base/TMethodJob.h" #include "base/Log.h" #include "common/Version.h" @@ -81,21 +80,18 @@ MSWindowsWatchdog::MSWindowsWatchdog( { } -void +void MSWindowsWatchdog::startAsync() { - m_thread = new Thread(new TMethodJob( - this, &MSWindowsWatchdog::mainLoop, nullptr)); - - m_outputThread = new Thread(new TMethodJob( - this, &MSWindowsWatchdog::outputLoop, nullptr)); + m_thread = new Thread([this](){ main_loop(); }); + m_outputThread = new Thread([this](){ output_loop(); }); } void MSWindowsWatchdog::stop() { m_monitoring = false; - + m_thread->wait(5); delete m_thread; @@ -117,7 +113,7 @@ MSWindowsWatchdog::duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES s LOG((CLOG_ERR "could not open token, process handle: %d", process)); throw XArch(new XArchEvalWindows()); } - + LOG((CLOG_DEBUG "got token %i, duplicating", sourceToken)); HANDLE newToken; @@ -129,22 +125,22 @@ MSWindowsWatchdog::duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES s LOG((CLOG_ERR "could not duplicate token %i", sourceToken)); throw XArch(new XArchEvalWindows()); } - + LOG((CLOG_DEBUG "duplicated, new token: %i", newToken)); return newToken; } -HANDLE +HANDLE MSWindowsWatchdog::getUserToken(LPSECURITY_ATTRIBUTES security) { - // always elevate if we are at the vista/7 login screen. we could also + // always elevate if we are at the vista/7 login screen. we could also // elevate for the uac dialog (consent.exe) but this would be pointless, // since barrier would re-launch as non-elevated after the desk switch, // and so would be unusable with the new elevated process taking focus. if (m_elevateProcess || m_autoElevated) { LOG((CLOG_DEBUG "getting elevated token, %s", (m_elevateProcess ? "elevation required" : "at login screen"))); - + HANDLE process; if (!m_session.isProcessInSession("winlogon.exe", &process)) { throw XMSWindowsWatchdogError("cannot get user token without winlogon.exe"); @@ -157,8 +153,7 @@ MSWindowsWatchdog::getUserToken(LPSECURITY_ATTRIBUTES security) } } -void -MSWindowsWatchdog::mainLoop(void*) +void MSWindowsWatchdog::main_loop() { shutdownExistingProcesses(); @@ -169,10 +164,10 @@ MSWindowsWatchdog::mainLoop(void*) sendSasFunc = (SendSas)GetProcAddress(sasLib, "SendSAS"); } - SECURITY_ATTRIBUTES saAttr; - saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); - saAttr.bInheritHandle = TRUE; - saAttr.lpSecurityDescriptor = NULL; + SECURITY_ATTRIBUTES saAttr; + saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); + saAttr.bInheritHandle = TRUE; + saAttr.lpSecurityDescriptor = NULL; if (!CreatePipe(&m_stdOutRead, &m_stdOutWrite, &saAttr, 0)) { throw XArch(new XArchEvalWindows()); @@ -196,7 +191,7 @@ MSWindowsWatchdog::mainLoop(void*) LOG((CLOG_INFO "backing off, wait=%ds, failures=%d", timeout, m_processFailures)); ARCH->sleep(timeout); } - + if (!getCommand().empty() && ((m_processFailures != 0) || m_session.hasChanged() || m_commandChanged)) { startProcess(); } @@ -205,7 +200,7 @@ MSWindowsWatchdog::mainLoop(void*) m_processFailures++; m_processRunning = false; - + LOG((CLOG_WARN "detected application not running, pid=%d", m_processInfo.dwProcessId)); } @@ -228,7 +223,7 @@ MSWindowsWatchdog::mainLoop(void*) // if the sas event failed, wait by sleeping. ARCH->sleep(1); - + } catch (std::exception& e) { LOG((CLOG_ERR "failed to launch, error: %s", e.what())); @@ -248,7 +243,7 @@ MSWindowsWatchdog::mainLoop(void*) LOG((CLOG_DEBUG "terminated running process on exit")); shutdownProcess(m_processInfo.hProcess, m_processInfo.dwProcessId, 20); } - + LOG((CLOG_DEBUG "watchdog main thread finished")); } @@ -260,7 +255,7 @@ MSWindowsWatchdog::isProcessActive() return exitCode == STILL_ACTIVE; } -void +void MSWindowsWatchdog::setFileLogOutputter(FileLogOutputter* outputter) { m_fileLogOutputter = outputter; @@ -367,7 +362,7 @@ BOOL MSWindowsWatchdog::doStartProcessAsUser(std::string& command, HANDLE userTo throw XArch(new XArchEvalWindows); } - DWORD creationFlags = + DWORD creationFlags = NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT; @@ -421,14 +416,13 @@ MSWindowsWatchdog::getCommand() const return cmd; } -void -MSWindowsWatchdog::outputLoop(void*) +void MSWindowsWatchdog::output_loop() { // +1 char for \0 CHAR buffer[kOutputBufferSize + 1]; while (m_monitoring) { - + DWORD bytesRead; BOOL success = ReadFile(m_stdOutRead, buffer, kOutputBufferSize, &bytesRead, NULL); @@ -443,7 +437,7 @@ MSWindowsWatchdog::outputLoop(void*) if (m_fileLogOutputter != NULL) { m_fileLogOutputter->write(kINFO, buffer); } - } + } } } @@ -470,7 +464,7 @@ MSWindowsWatchdog::shutdownProcess(HANDLE handle, DWORD pid, int timeout) break; } else { - + double elapsed = (ARCH->time() - start); if (elapsed > timeout) { // if timeout reached, kill forcefully. @@ -500,7 +494,7 @@ MSWindowsWatchdog::shutdownExistingProcesses() PROCESSENTRY32 entry; entry.dwSize = sizeof(PROCESSENTRY32); - // get the first process, and if we can't do that then it's + // get the first process, and if we can't do that then it's // unlikely we can go any further BOOL gotEntry = Process32First(snapshot, &entry); if (!gotEntry) { @@ -517,7 +511,7 @@ MSWindowsWatchdog::shutdownExistingProcesses() if (_stricmp(entry.szExeFile, "barrierc.exe") == 0 || _stricmp(entry.szExeFile, "barriers.exe") == 0) { - + HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID); shutdownProcess(handle, entry.th32ProcessID, 10); } diff --git a/src/lib/platform/MSWindowsWatchdog.h b/src/lib/platform/MSWindowsWatchdog.h index 0a81521..0595ca0 100644 --- a/src/lib/platform/MSWindowsWatchdog.h +++ b/src/lib/platform/MSWindowsWatchdog.h @@ -6,7 +6,7 @@ * 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 @@ -48,8 +48,8 @@ public: void setFileLogOutputter(FileLogOutputter* outputter); private: - void mainLoop(void*); - void outputLoop(void*); + void main_loop(); + void output_loop(); void shutdownProcess(HANDLE handle, DWORD pid, int timeout); void shutdownExistingProcesses(); HANDLE duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES security); @@ -81,7 +81,7 @@ private: //! Relauncher error /*! -An error occured in the process watchdog. +An error occurred in the process watchdog. */ class XMSWindowsWatchdogError : public XBarrier { public: diff --git a/src/lib/platform/OSXClipboard.cpp b/src/lib/platform/OSXClipboard.cpp index e55c8e0..ff1779c 100644 --- a/src/lib/platform/OSXClipboard.cpp +++ b/src/lib/platform/OSXClipboard.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -52,7 +52,7 @@ OSXClipboard::OSXClipboard() : OSStatus syncErr = PasteboardSynchronize(m_pboard); if (syncErr != noErr) { - LOG((CLOG_DEBUG "failed to syncronize clipboard: error %i", syncErr)); + LOG((CLOG_DEBUG "failed to synchronize clipboard: error %i", syncErr)); } } @@ -90,7 +90,7 @@ OSXClipboard::synchronize() return true; } return false; -} +} void OSXClipboard::add(EFormat format, const std::string& data) { @@ -126,15 +126,15 @@ void OSXClipboard::add(EFormat format, const std::string& data) flavorType, dataRef, kPasteboardFlavorNoFlags); - + LOG((CLOG_DEBUG "added %d bytes to clipboard format: %d", data.size(), format)); } - + } } bool -OSXClipboard::open(Time time) const +OSXClipboard::open(Time time) const { if (m_pboard == NULL) return false; diff --git a/src/lib/platform/OSXClipboard.h b/src/lib/platform/OSXClipboard.h index b1f9801..9d66600 100644 --- a/src/lib/platform/OSXClipboard.h +++ b/src/lib/platform/OSXClipboard.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/OSXClipboardAnyTextConverter.cpp b/src/lib/platform/OSXClipboardAnyTextConverter.cpp index ae8dc4a..2513db5 100644 --- a/src/lib/platform/OSXClipboardAnyTextConverter.cpp +++ b/src/lib/platform/OSXClipboardAnyTextConverter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/OSXClipboardAnyTextConverter.h b/src/lib/platform/OSXClipboardAnyTextConverter.h index f057bae..987f2c5 100644 --- a/src/lib/platform/OSXClipboardAnyTextConverter.h +++ b/src/lib/platform/OSXClipboardAnyTextConverter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/OSXClipboardHTMLConverter.cpp b/src/lib/platform/OSXClipboardHTMLConverter.cpp index 46a3d0f..0a2f5ec 100644 --- a/src/lib/platform/OSXClipboardHTMLConverter.cpp +++ b/src/lib/platform/OSXClipboardHTMLConverter.cpp @@ -66,7 +66,7 @@ std::string OSXClipboardHTMLConverter::convertString(const std::string& data, CFRelease(stringRef); return {}; } - + CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, (UInt8*)buffer, buffSize, NULL); diff --git a/src/lib/platform/OSXClipboardTextConverter.cpp b/src/lib/platform/OSXClipboardTextConverter.cpp index a68258d..a4fb6ae 100644 --- a/src/lib/platform/OSXClipboardTextConverter.cpp +++ b/src/lib/platform/OSXClipboardTextConverter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -24,7 +24,7 @@ // OSXClipboardTextConverter // -OSXClipboardTextConverter::OSXClipboardTextConverter() +OSXClipboardTextConverter::OSXClipboardTextConverter() { // do nothing } @@ -59,12 +59,12 @@ std::string OSXClipboardTextConverter::convertString(const std::string& data, 0, false, NULL, 0, &buffSize); char* buffer = new char[buffSize]; - + if (buffer == NULL) { CFRelease(stringRef); return {}; } - + CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, (UInt8*)buffer, buffSize, NULL); @@ -72,7 +72,7 @@ std::string OSXClipboardTextConverter::convertString(const std::string& data, delete[] buffer; CFRelease(stringRef); - + return result; } diff --git a/src/lib/platform/OSXClipboardTextConverter.h b/src/lib/platform/OSXClipboardTextConverter.h index 8211f1e..5a4b51f 100644 --- a/src/lib/platform/OSXClipboardTextConverter.h +++ b/src/lib/platform/OSXClipboardTextConverter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/OSXClipboardUTF16Converter.cpp b/src/lib/platform/OSXClipboardUTF16Converter.cpp index 8411e92..4f13cc0 100644 --- a/src/lib/platform/OSXClipboardUTF16Converter.cpp +++ b/src/lib/platform/OSXClipboardUTF16Converter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/OSXClipboardUTF16Converter.h b/src/lib/platform/OSXClipboardUTF16Converter.h index b279c99..5e448df 100644 --- a/src/lib/platform/OSXClipboardUTF16Converter.h +++ b/src/lib/platform/OSXClipboardUTF16Converter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/OSXDragSimulator.h b/src/lib/platform/OSXDragSimulator.h index cb361ca..6dd73f4 100644 --- a/src/lib/platform/OSXDragSimulator.h +++ b/src/lib/platform/OSXDragSimulator.h @@ -28,7 +28,7 @@ void runCocoaApp(); void stopCocoaLoop(); void fakeDragging(const char* str, int cursorX, int cursorY); CFStringRef getCocoaDropTarget(); - + #if defined(__cplusplus) } #endif diff --git a/src/lib/platform/OSXDragSimulator.m b/src/lib/platform/OSXDragSimulator.m deleted file mode 100644 index affed38..0000000 --- a/src/lib/platform/OSXDragSimulator.m +++ /dev/null @@ -1,102 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2013-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. - */ - -#import "platform/OSXDragSimulator.h" - -#import "platform/OSXDragView.h" - -#import -#import -#import - -#if defined(MAC_OS_X_VERSION_10_7) - -NSWindow* g_dragWindow = NULL; -OSXDragView* g_dragView = NULL; -NSString* g_ext = NULL; - -void -runCocoaApp() -{ - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - [NSApplication sharedApplication]; - - NSWindow* window = [[NSWindow alloc] - initWithContentRect: NSMakeRect(0, 0, 3, 3) - styleMask: NSBorderlessWindowMask - backing: NSBackingStoreBuffered - defer: NO]; - [window setTitle: @""]; - [window setAlphaValue:0.1]; - [window makeKeyAndOrderFront:nil]; - - OSXDragView* dragView = [[OSXDragView alloc] initWithFrame:NSMakeRect(0, 0, 3, 3)]; - - g_dragWindow = window; - g_dragView = dragView; - [window setContentView: dragView]; - - NSLog(@"starting cocoa loop"); - [NSApp run]; - - NSLog(@"cocoa: release"); - [pool release]; -} - -void -stopCocoaLoop() -{ - [NSApp stop: g_dragWindow]; -} - -void -fakeDragging(const char* str, int cursorX, int cursorY) -{ - g_ext = [NSString stringWithUTF8String:str]; - - dispatch_async(dispatch_get_main_queue(), ^{ - NSRect screen = [[NSScreen mainScreen] frame]; - NSLog ( @"screen size: witdh = %f height = %f", screen.size.width, screen.size.height); - NSLog ( @"mouseLocation: %d %d", cursorX, cursorY); - - int newPosX = 0; - int newPosY = 0; - newPosX = cursorX - 1; - newPosY = screen.size.height - cursorY - 1; - - NSRect rect = NSMakeRect(newPosX, newPosY, 3, 3); - NSLog ( @"newPosX: %d", newPosX); - NSLog ( @"newPosY: %d", newPosY); - - [g_dragWindow setFrame:rect display:NO]; - [g_dragWindow makeKeyAndOrderFront:nil]; - [NSApp activateIgnoringOtherApps:YES]; - - [g_dragView setFileExt:g_ext]; - - CGEventRef down = CGEventCreateMouseEvent(CGEventSourceCreate(kCGEventSourceStateHIDSystemState), kCGEventLeftMouseDown, CGPointMake(cursorX, cursorY), kCGMouseButtonLeft); - CGEventPost(kCGHIDEventTap, down); - }); -} - -CFStringRef -getCocoaDropTarget() -{ - // HACK: sleep, wait for cocoa drop target updated first - usleep(1000000); - return [g_dragView getDropTarget]; -} - -#endif diff --git a/src/lib/platform/OSXDragSimulator.mm b/src/lib/platform/OSXDragSimulator.mm new file mode 100644 index 0000000..735aa4a --- /dev/null +++ b/src/lib/platform/OSXDragSimulator.mm @@ -0,0 +1,102 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2013-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. + */ + +#import "platform/OSXDragSimulator.h" + +#import "platform/OSXDragView.h" + +#import +#import +#import + +#if defined(MAC_OS_X_VERSION_10_7) + +NSWindow* g_dragWindow = NULL; +OSXDragView* g_dragView = NULL; +NSString* g_ext = NULL; + +void +runCocoaApp() +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + [NSApplication sharedApplication]; + + NSWindow* window = [[NSWindow alloc] + initWithContentRect: NSMakeRect(0, 0, 3, 3) + styleMask: NSBorderlessWindowMask + backing: NSBackingStoreBuffered + defer: NO]; + [window setTitle: @""]; + [window setAlphaValue:0.1]; + [window makeKeyAndOrderFront:nil]; + + OSXDragView* dragView = [[OSXDragView alloc] initWithFrame:NSMakeRect(0, 0, 3, 3)]; + + g_dragWindow = window; + g_dragView = dragView; + [window setContentView: dragView]; + + NSLog(@"starting cocoa loop"); + [NSApp run]; + + NSLog(@"cocoa: release"); + [pool release]; +} + +void +stopCocoaLoop() +{ + [NSApp stop: g_dragWindow]; +} + +void +fakeDragging(const char* str, int cursorX, int cursorY) +{ + g_ext = [NSString stringWithUTF8String:str]; + + dispatch_async(dispatch_get_main_queue(), ^{ + NSRect screen = [[NSScreen mainScreen] frame]; + NSLog ( @"screen size: width = %f height = %f", screen.size.width, screen.size.height); + NSLog ( @"mouseLocation: %d %d", cursorX, cursorY); + + int newPosX = 0; + int newPosY = 0; + newPosX = cursorX - 1; + newPosY = screen.size.height - cursorY - 1; + + NSRect rect = NSMakeRect(newPosX, newPosY, 3, 3); + NSLog ( @"newPosX: %d", newPosX); + NSLog ( @"newPosY: %d", newPosY); + + [g_dragWindow setFrame:rect display:NO]; + [g_dragWindow makeKeyAndOrderFront:nil]; + [NSApp activateIgnoringOtherApps:YES]; + + [g_dragView setFileExt:g_ext]; + + CGEventRef down = CGEventCreateMouseEvent(CGEventSourceCreate(kCGEventSourceStateHIDSystemState), kCGEventLeftMouseDown, CGPointMake(cursorX, cursorY), kCGMouseButtonLeft); + CGEventPost(kCGHIDEventTap, down); + }); +} + +CFStringRef +getCocoaDropTarget() +{ + // HACK: sleep, wait for cocoa drop target updated first + usleep(1000000); + return [g_dragView getDropTarget]; +} + +#endif diff --git a/src/lib/platform/OSXDragView.m b/src/lib/platform/OSXDragView.m deleted file mode 100644 index 67dac56..0000000 --- a/src/lib/platform/OSXDragView.m +++ /dev/null @@ -1,177 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2013-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 . - */ - -#import "platform/OSXDragView.h" - -#ifdef MAC_OS_X_VERSION_10_7 - -@implementation OSXDragView - -@dynamic draggingFormation; -@dynamic animatesToDestination; -@dynamic numberOfValidItemsForDrop; - -/* springLoadingHighlight is a property that will not be auto-synthesized by - clang. explicitly synthesizing it here as well as defining an empty handler - for resetSpringLoading() satisfies the compiler */ -@synthesize springLoadingHighlight = _springLoadingHighlight; - -/* unused */ -- (void) -resetSpringLoading -{ -} - -- (id) -initWithFrame:(NSRect)frame -{ - self = [super initWithFrame:frame]; - m_dropTarget = [[NSMutableString alloc] initWithCapacity:0]; - m_dragFileExt = [[NSMutableString alloc] initWithCapacity:0]; - return self; -} - -- (void) -drawRect:(NSRect)dirtyRect -{ -} - -- (BOOL) -acceptsFirstMouse:(NSEvent *)theEvent -{ - return YES; -} - -- (void) -mouseDown:(NSEvent *)theEvent -{ - NSLog ( @"cocoa mouse down"); - NSPoint dragPosition; - NSRect imageLocation; - dragPosition = [self convertPoint:[theEvent locationInWindow] - fromView:nil]; - - dragPosition.x -= 16; - dragPosition.y -= 16; - imageLocation.origin = dragPosition; - imageLocation.size = NSMakeSize(32,32); - [self dragPromisedFilesOfTypes:[NSArray arrayWithObject:m_dragFileExt] - fromRect:imageLocation - source:self - slideBack:NO - event:theEvent]; -} - -- (NSArray*) -namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination -{ - [m_dropTarget setString:@""]; - [m_dropTarget appendString:dropDestination.path]; - NSLog ( @"cocoa drop target: %@", m_dropTarget); - return nil; -} - -- (NSDragOperation) -draggingSourceOperationMaskForLocal:(BOOL)flag -{ - return NSDragOperationCopy; -} - -- (CFStringRef) -getDropTarget -{ - NSMutableString* string; - string = [[NSMutableString alloc] initWithCapacity:0]; - [string appendString:m_dropTarget]; - return (CFStringRef)string; -} - -- (void) -clearDropTarget -{ - [m_dropTarget setString:@""]; -} - -- (void) -setFileExt:(NSString*) ext -{ - [ext retain]; - [m_dragFileExt release]; - m_dragFileExt = ext; - NSLog(@"drag file ext: %@", m_dragFileExt); -} - -- (NSWindow *) -draggingDestinationWindow -{ - return nil; -} - -- (NSDragOperation) -draggingSourceOperationMask -{ - return NSDragOperationCopy; -} - -- (NSPoint)draggingLocation -{ - NSPoint point = NSMakePoint(0, 0); - return point; -} - -- (NSPoint)draggedImageLocation -{ - NSPoint point = NSMakePoint(0, 0); - return point; -} - -- (NSImage *)draggedImage -{ - return nil; -} - -- (NSPasteboard *)draggingPasteboard -{ - return nil; -} - -- (id)draggingSource -{ - return nil; -} - -- (NSInteger)draggingSequenceNumber -{ - return 0; -} - -- (void)slideDraggedImageTo:(NSPoint)screenPoint -{ -} - -- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context -{ - return NSDragOperationCopy; -} - -- (void)enumerateDraggingItemsWithOptions:(NSDraggingItemEnumerationOptions)enumOpts forView:(NSView *)view classes:(NSArray *)classArray searchOptions:(NSDictionary *)searchOptions usingBlock:(void (^)(NSDraggingItem *draggingItem, NSInteger idx, BOOL *stop))block -{ -} - -@end - -#endif diff --git a/src/lib/platform/OSXDragView.mm b/src/lib/platform/OSXDragView.mm new file mode 100644 index 0000000..67dac56 --- /dev/null +++ b/src/lib/platform/OSXDragView.mm @@ -0,0 +1,177 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2013-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 . + */ + +#import "platform/OSXDragView.h" + +#ifdef MAC_OS_X_VERSION_10_7 + +@implementation OSXDragView + +@dynamic draggingFormation; +@dynamic animatesToDestination; +@dynamic numberOfValidItemsForDrop; + +/* springLoadingHighlight is a property that will not be auto-synthesized by + clang. explicitly synthesizing it here as well as defining an empty handler + for resetSpringLoading() satisfies the compiler */ +@synthesize springLoadingHighlight = _springLoadingHighlight; + +/* unused */ +- (void) +resetSpringLoading +{ +} + +- (id) +initWithFrame:(NSRect)frame +{ + self = [super initWithFrame:frame]; + m_dropTarget = [[NSMutableString alloc] initWithCapacity:0]; + m_dragFileExt = [[NSMutableString alloc] initWithCapacity:0]; + return self; +} + +- (void) +drawRect:(NSRect)dirtyRect +{ +} + +- (BOOL) +acceptsFirstMouse:(NSEvent *)theEvent +{ + return YES; +} + +- (void) +mouseDown:(NSEvent *)theEvent +{ + NSLog ( @"cocoa mouse down"); + NSPoint dragPosition; + NSRect imageLocation; + dragPosition = [self convertPoint:[theEvent locationInWindow] + fromView:nil]; + + dragPosition.x -= 16; + dragPosition.y -= 16; + imageLocation.origin = dragPosition; + imageLocation.size = NSMakeSize(32,32); + [self dragPromisedFilesOfTypes:[NSArray arrayWithObject:m_dragFileExt] + fromRect:imageLocation + source:self + slideBack:NO + event:theEvent]; +} + +- (NSArray*) +namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination +{ + [m_dropTarget setString:@""]; + [m_dropTarget appendString:dropDestination.path]; + NSLog ( @"cocoa drop target: %@", m_dropTarget); + return nil; +} + +- (NSDragOperation) +draggingSourceOperationMaskForLocal:(BOOL)flag +{ + return NSDragOperationCopy; +} + +- (CFStringRef) +getDropTarget +{ + NSMutableString* string; + string = [[NSMutableString alloc] initWithCapacity:0]; + [string appendString:m_dropTarget]; + return (CFStringRef)string; +} + +- (void) +clearDropTarget +{ + [m_dropTarget setString:@""]; +} + +- (void) +setFileExt:(NSString*) ext +{ + [ext retain]; + [m_dragFileExt release]; + m_dragFileExt = ext; + NSLog(@"drag file ext: %@", m_dragFileExt); +} + +- (NSWindow *) +draggingDestinationWindow +{ + return nil; +} + +- (NSDragOperation) +draggingSourceOperationMask +{ + return NSDragOperationCopy; +} + +- (NSPoint)draggingLocation +{ + NSPoint point = NSMakePoint(0, 0); + return point; +} + +- (NSPoint)draggedImageLocation +{ + NSPoint point = NSMakePoint(0, 0); + return point; +} + +- (NSImage *)draggedImage +{ + return nil; +} + +- (NSPasteboard *)draggingPasteboard +{ + return nil; +} + +- (id)draggingSource +{ + return nil; +} + +- (NSInteger)draggingSequenceNumber +{ + return 0; +} + +- (void)slideDraggedImageTo:(NSPoint)screenPoint +{ +} + +- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context +{ + return NSDragOperationCopy; +} + +- (void)enumerateDraggingItemsWithOptions:(NSDraggingItemEnumerationOptions)enumOpts forView:(NSView *)view classes:(NSArray *)classArray searchOptions:(NSDictionary *)searchOptions usingBlock:(void (^)(NSDraggingItem *draggingItem, NSInteger idx, BOOL *stop))block +{ +} + +@end + +#endif diff --git a/src/lib/platform/OSXEventQueueBuffer.cpp b/src/lib/platform/OSXEventQueueBuffer.cpp index 8e18afc..e012c89 100644 --- a/src/lib/platform/OSXEventQueueBuffer.cpp +++ b/src/lib/platform/OSXEventQueueBuffer.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -83,11 +83,11 @@ OSXEventQueueBuffer::getEvent(Event& event, UInt32& dataID) else { UInt32 eventClass = GetEventClass(m_event); switch (eventClass) { - case 'Syne': + case 'Syne': dataID = GetEventKind(m_event); return kUser; - default: + default: event = Event(Event::kSystem, m_eventQueue->getSystemTarget(), &m_event); return kSystem; @@ -101,24 +101,24 @@ OSXEventQueueBuffer::addEvent(UInt32 dataID) EventRef event; OSStatus error = CreateEvent( kCFAllocatorDefault, - 'Syne', + 'Syne', dataID, 0, kEventAttributeNone, &event); if (error == noErr) { - + assert(m_carbonEventQueue != NULL); - + error = PostEventToQueue( m_carbonEventQueue, event, kEventPriorityStandard); - + ReleaseEvent(event); } - + return (error == noErr); } diff --git a/src/lib/platform/OSXEventQueueBuffer.h b/src/lib/platform/OSXEventQueueBuffer.h index 28c4a5d..8e0c903 100644 --- a/src/lib/platform/OSXEventQueueBuffer.h +++ b/src/lib/platform/OSXEventQueueBuffer.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/OSXKeyState.cpp b/src/lib/platform/OSXKeyState.cpp index 9db3c5d..aad2072 100644 --- a/src/lib/platform/OSXKeyState.cpp +++ b/src/lib/platform/OSXKeyState.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -43,6 +43,9 @@ static const UInt32 s_launchpadVK = 131; static const UInt32 s_osxNumLock = 1 << 16; +static const UInt32 s_int4VK = 0x8a; // international4 +static const UInt32 s_int5VK = 0x8b; // international5 + struct KeyEntry { public: KeyID m_keyID; @@ -97,7 +100,7 @@ static const KeyEntry s_controlKeys[] = { { kKeyKP_Divide, kVK_ANSI_KeypadDivide }, { kKeyKP_Subtract, kVK_ANSI_KeypadMinus }, { kKeyKP_Enter, kVK_ANSI_KeypadEnter }, - + // virtual key 110 is fn+enter and i have no idea what that's supposed // to map to. also the enter key with numlock on is a modifier but i // don't know which. @@ -118,11 +121,18 @@ static const KeyEntry s_controlKeys[] = { // toggle modifiers { kKeyNumLock, s_numLockVK }, { kKeyCapsLock, s_capsLockVK }, - + { kKeyMissionControl, s_missionControlVK }, { kKeyLaunchpad, s_launchpadVK }, { kKeyBrightnessUp, s_brightnessUp }, - { kKeyBrightnessDown, s_brightnessDown } + { kKeyBrightnessDown, s_brightnessDown }, + + // JIS keyboards only + { kKeyEisuToggle, kVK_JIS_Eisu }, + { kKeyKana, kVK_JIS_Kana }, + { kKeyMuhenkan, s_int5VK }, + { kKeyHenkan, s_int4VK }, + { kKeyZenkaku, kVK_ANSI_Grave } }; @@ -159,7 +169,7 @@ OSXKeyState::init() // build virtual key map for (size_t i = 0; i < sizeof(s_controlKeys) / sizeof(s_controlKeys[0]); ++i) { - + m_virtualKeyMap[s_controlKeys[i].m_virtualKey] = s_controlKeys[i].m_keyID; } @@ -214,11 +224,11 @@ OSXKeyState::mapModifiersToCarbon(UInt32 mask) const if ((mask & kCGEventFlagMaskNumericPad) != 0) { outMask |= s_osxNumLock; } - + return outMask; } -KeyButton +KeyButton OSXKeyState::mapKeyFromEvent(KeyIDs& ids, KeyModifierMask* maskOut, CGEventRef event) const { @@ -253,7 +263,7 @@ OSXKeyState::mapKeyFromEvent(KeyIDs& ids, } // get keyboard info - TISInputSourceRef currentKeyboardLayout = TISCopyCurrentKeyboardLayoutInputSource(); + TISInputSourceRef currentKeyboardLayout = TISCopyCurrentKeyboardLayoutInputSource(); if (currentKeyboardLayout == NULL) { return kKeyNone; @@ -338,27 +348,27 @@ CGEventFlags OSXKeyState::getModifierStateAsOSXFlags() { CGEventFlags modifiers = CGEventFlags(0); - + if (m_shiftPressed) { modifiers |= CGEventFlags(kCGEventFlagMaskShift); } - + if (m_controlPressed) { modifiers |= CGEventFlags(kCGEventFlagMaskControl); } - + if (m_altPressed) { modifiers |= CGEventFlags(kCGEventFlagMaskAlternate); } - + if (m_superPressed) { modifiers |= CGEventFlags(kCGEventFlagMaskCommand); } - + if (m_capsPressed) { modifiers |= CGEventFlags(kCGEventFlagMaskAlphaShift); } - + return modifiers; } @@ -400,12 +410,12 @@ OSXKeyState::pollActiveGroup() const TISInputSourceRef keyboardLayout = TISCopyCurrentKeyboardLayoutInputSource(); CFDataRef id = (CFDataRef)TISGetInputSourceProperty( keyboardLayout, kTISPropertyInputSourceID); - + GroupMap::const_iterator i = m_groupMap.find(id); if (i != m_groupMap.end()) { return i->second; } - + LOG((CLOG_DEBUG "can't get the active group, use the first group instead")); return 0; @@ -447,7 +457,7 @@ OSXKeyState::getKeyMap(barrier::KeyMap& keyMap) const void* resource; bool layoutValid = false; - + // add regular keys // try uchr resource first CFDataRef resourceRef = (CFDataRef)TISGetInputSourceProperty( @@ -475,19 +485,19 @@ static io_connect_t getEventDriver(void) static mach_port_t sEventDrvrRef = 0; mach_port_t masterPort, service, iter; kern_return_t kr; - + if (!sEventDrvrRef) { // Get master device port kr = IOMasterPort(bootstrap_port, &masterPort); assert(KERN_SUCCESS == kr); - + kr = IOServiceGetMatchingServices(masterPort, IOServiceMatching(kIOHIDSystemClass), &iter); assert(KERN_SUCCESS == kr); - + service = IOIteratorNext(iter); assert(service); - + kr = IOServiceOpen(service, mach_task_self(), kIOHIDParamConnectType, &sEventDrvrRef); assert(KERN_SUCCESS == kr); @@ -495,7 +505,7 @@ static io_connect_t getEventDriver(void) IOObjectRelease(service); IOObjectRelease(iter); } - + return sEventDrvrRef; } @@ -504,7 +514,7 @@ OSXKeyState::postHIDVirtualKey(const UInt8 virtualKeyCode, const bool postDown) { static UInt32 modifiers = 0; - + NXEventData event; IOGPoint loc = { 0, 0 }; UInt32 modifiersDelta = 0; @@ -541,7 +551,7 @@ OSXKeyState::postHIDVirtualKey(const UInt8 virtualKeyCode, m_capsPressed = postDown; break; } - + // update the modifier bit if (postDown) { modifiers |= modifiersDelta; @@ -549,7 +559,7 @@ OSXKeyState::postHIDVirtualKey(const UInt8 virtualKeyCode, else { modifiers &= ~modifiersDelta; } - + kern_return_t kr; event.key.keyCode = virtualKeyCode; kr = IOHIDPostEvent(getEventDriver(), NX_FLAGSCHANGED, loc, @@ -575,11 +585,11 @@ OSXKeyState::fakeKey(const Keystroke& keystroke) { switch (keystroke.m_type) { case Keystroke::kButton: { - + KeyButton button = keystroke.m_data.m_button.m_button; bool keyDown = keystroke.m_data.m_button.m_press; CGKeyCode virtualKey = mapKeyButtonToVirtualKey(button); - + LOG((CLOG_DEBUG1 " button=0x%04x virtualKey=0x%04x keyDown=%s", button, virtualKey, keyDown ? "down" : "up")); @@ -763,7 +773,7 @@ OSXKeyState::mapBarrierHotKeyToMac(KeyID key, KeyModifierMask mask, return false; } macVirtualKey = mapKeyButtonToVirtualKey(button); - + // calculate modifier mask macModifierMask = 0; if ((mask & KeyModifierShift) != 0) { @@ -784,10 +794,10 @@ OSXKeyState::mapBarrierHotKeyToMac(KeyID key, KeyModifierMask mask, if ((mask & KeyModifierNumLock) != 0) { macModifierMask |= s_osxNumLock; } - + return true; } - + void OSXKeyState::handleModifierKeys(void* target, KeyModifierMask oldMask, KeyModifierMask newMask) @@ -855,7 +865,7 @@ OSXKeyState::getGroups(GroupList& groups) const groups.clear(); for (CFIndex i = 0; i < n; ++i) { bool addToGroups = true; - TISInputSourceRef keyboardLayout = + TISInputSourceRef keyboardLayout = (TISInputSourceRef)CFArrayGetValueAtIndex(kbds, i); if (addToGroups) diff --git a/src/lib/platform/OSXKeyState.h b/src/lib/platform/OSXKeyState.h index 4d92860..e688394 100644 --- a/src/lib/platform/OSXKeyState.h +++ b/src/lib/platform/OSXKeyState.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -67,7 +67,7 @@ public: Still required in a few places for translation calls. */ KeyModifierMask mapModifiersToCarbon(UInt32 mask) const; - + //! Map key event to keys /*! Converts a key event into a sequence of KeyIDs and the shadow modifier @@ -149,7 +149,7 @@ private: static UInt32 mapKeyButtonToVirtualKey(KeyButton keyButton); void init(); - + // Post a key event to HID manager. It posts an event to HID client, a // much lower level than window manager which's the target from carbon // CGEventPost diff --git a/src/lib/platform/OSXMediaKeySimulator.m b/src/lib/platform/OSXMediaKeySimulator.m deleted file mode 100644 index 5aacd10..0000000 --- a/src/lib/platform/OSXMediaKeySimulator.m +++ /dev/null @@ -1,92 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2016 Symless. - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file COPYING that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#import "platform/OSXMediaKeySimulator.h" - -#import - -int convertKeyIDToNXKeyType(KeyID id) -{ - // hidsystem/ev_keymap.h - // NX_KEYTYPE_SOUND_UP 0 - // NX_KEYTYPE_SOUND_DOWN 1 - // NX_KEYTYPE_BRIGHTNESS_UP 2 - // NX_KEYTYPE_BRIGHTNESS_DOWN 3 - // NX_KEYTYPE_MUTE 7 - // NX_KEYTYPE_EJECT 14 - // NX_KEYTYPE_PLAY 16 - // NX_KEYTYPE_NEXT 17 - // NX_KEYTYPE_PREVIOUS 18 - // NX_KEYTYPE_FAST 19 - // NX_KEYTYPE_REWIND 20 - - int type = -1; - switch (id) { - case kKeyAudioUp: - type = 0; - break; - case kKeyAudioDown: - type = 1; - break; - case kKeyBrightnessUp: - type = 2; - break; - case kKeyBrightnessDown: - type = 3; - break; - case kKeyAudioMute: - type = 7; - break; - case kKeyEject: - type = 14; - break; - case kKeyAudioPlay: - type = 16; - break; - case kKeyAudioNext: - type = 17; - break; - case kKeyAudioPrev: - type = 18; - break; - default: - break; - } - - return type; -} - -bool -fakeNativeMediaKey(KeyID id) -{ - - NSEvent* downRef = [NSEvent otherEventWithType:NSSystemDefined - location: NSMakePoint(0, 0) modifierFlags:0xa00 - timestamp:0 windowNumber:0 context:0 subtype:8 - data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xa) << 8) - data2:-1]; - CGEventRef downEvent = [downRef CGEvent]; - - NSEvent* upRef = [NSEvent otherEventWithType:NSSystemDefined - location: NSMakePoint(0, 0) modifierFlags:0xa00 - timestamp:0 windowNumber:0 context:0 subtype:8 - data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xb) << 8) - data2:-1]; - CGEventRef upEvent = [upRef CGEvent]; - - CGEventPost(0, downEvent); - CGEventPost(0, upEvent); - - return true; -} diff --git a/src/lib/platform/OSXMediaKeySimulator.mm b/src/lib/platform/OSXMediaKeySimulator.mm new file mode 100644 index 0000000..efc4251 --- /dev/null +++ b/src/lib/platform/OSXMediaKeySimulator.mm @@ -0,0 +1,92 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2016 Symless. + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#import "platform/OSXMediaKeySimulator.h" + +#import + +int convertKeyIDToNXKeyType(KeyID id) +{ + // hidsystem/ev_keymap.h + // NX_KEYTYPE_SOUND_UP 0 + // NX_KEYTYPE_SOUND_DOWN 1 + // NX_KEYTYPE_BRIGHTNESS_UP 2 + // NX_KEYTYPE_BRIGHTNESS_DOWN 3 + // NX_KEYTYPE_MUTE 7 + // NX_KEYTYPE_EJECT 14 + // NX_KEYTYPE_PLAY 16 + // NX_KEYTYPE_NEXT 17 + // NX_KEYTYPE_PREVIOUS 18 + // NX_KEYTYPE_FAST 19 + // NX_KEYTYPE_REWIND 20 + + int type = -1; + switch (id) { + case kKeyAudioUp: + type = 0; + break; + case kKeyAudioDown: + type = 1; + break; + case kKeyBrightnessUp: + type = 2; + break; + case kKeyBrightnessDown: + type = 3; + break; + case kKeyAudioMute: + type = 7; + break; + case kKeyEject: + type = 14; + break; + case kKeyAudioPlay: + type = 16; + break; + case kKeyAudioNext: + type = 17; + break; + case kKeyAudioPrev: + type = 18; + break; + default: + break; + } + + return type; +} + +bool +fakeNativeMediaKey(KeyID id) +{ + + NSEvent* downRef = [NSEvent otherEventWithType:NSSystemDefined + location: NSMakePoint(0, 0) modifierFlags:0xa00 + timestamp:0 windowNumber:0 context:0 subtype:8 + data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xa) << 8) + data2:-1]; + CGEventRef downEvent = [downRef CGEvent]; + + NSEvent* upRef = [NSEvent otherEventWithType:NSSystemDefined + location: NSMakePoint(0, 0) modifierFlags:0xa00 + timestamp:0 windowNumber:0 context:0 subtype:8 + data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xb) << 8) + data2:-1]; + CGEventRef upEvent = [upRef CGEvent]; + + CGEventPost(kCGHIDEventTap, downEvent); + CGEventPost(kCGHIDEventTap, upEvent); + + return true; +} diff --git a/src/lib/platform/OSXMediaKeySupport.m b/src/lib/platform/OSXMediaKeySupport.m deleted file mode 100644 index 9c9dbc3..0000000 --- a/src/lib/platform/OSXMediaKeySupport.m +++ /dev/null @@ -1,154 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2016 Symless. - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file COPYING that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#import "platform/OSXMediaKeySupport.h" -#import -#import - -int convertKeyIDToNXKeyType(KeyID id) -{ - int type = -1; - - switch (id) { - case kKeyAudioUp: - type = NX_KEYTYPE_SOUND_UP; - break; - case kKeyAudioDown: - type = NX_KEYTYPE_SOUND_DOWN; - break; - case kKeyBrightnessUp: - type = NX_KEYTYPE_BRIGHTNESS_UP; - break; - case kKeyBrightnessDown: - type = NX_KEYTYPE_BRIGHTNESS_DOWN; - break; - case kKeyAudioMute: - type = NX_KEYTYPE_MUTE; - break; - case kKeyEject: - type = NX_KEYTYPE_EJECT; - break; - case kKeyAudioPlay: - type = NX_KEYTYPE_PLAY; - break; - case kKeyAudioNext: - type = NX_KEYTYPE_NEXT; - break; - case kKeyAudioPrev: - type = NX_KEYTYPE_PREVIOUS; - break; - default: - break; - } - - return type; -} - -static KeyID -convertNXKeyTypeToKeyID(uint32_t const type) -{ - KeyID id = 0; - - switch (type) { - case NX_KEYTYPE_SOUND_UP: - id = kKeyAudioUp; - break; - case NX_KEYTYPE_SOUND_DOWN: - id = kKeyAudioDown; - break; - case NX_KEYTYPE_MUTE: - id = kKeyAudioMute; - break; - case NX_KEYTYPE_EJECT: - id = kKeyEject; - break; - case NX_KEYTYPE_PLAY: - id = kKeyAudioPlay; - break; - case NX_KEYTYPE_FAST: - case NX_KEYTYPE_NEXT: - id = kKeyAudioNext; - break; - case NX_KEYTYPE_REWIND: - case NX_KEYTYPE_PREVIOUS: - id = kKeyAudioPrev; - break; - default: - break; - } - - return id; -} - -bool -isMediaKeyEvent(CGEventRef event) { - NSEvent* nsEvent = nil; - @try { - nsEvent = [NSEvent eventWithCGEvent: event]; - if ([nsEvent subtype] != 8) { - return false; - } - uint32_t const nxKeyId = ([nsEvent data1] & 0xFFFF0000) >> 16; - if (convertNXKeyTypeToKeyID (nxKeyId)) { - return true; - } - } @catch (NSException* e) { - } - return false; -} - -bool -getMediaKeyEventInfo(CGEventRef event, KeyID* const keyId, - bool* const down, bool* const isRepeat) { - NSEvent* nsEvent = nil; - @try { - nsEvent = [NSEvent eventWithCGEvent: event]; - } @catch (NSException* e) { - return false; - } - if (keyId) { - *keyId = convertNXKeyTypeToKeyID (([nsEvent data1] & 0xFFFF0000) >> 16); - } - if (down) { - *down = !([nsEvent data1] & 0x100); - } - if (isRepeat) { - *isRepeat = [nsEvent data1] & 0x1; - } - return true; -} - -bool -fakeNativeMediaKey(KeyID id) -{ - - NSEvent* downRef = [NSEvent otherEventWithType:NSSystemDefined - location: NSMakePoint(0, 0) modifierFlags:0xa00 - timestamp:0 windowNumber:0 context:0 subtype:8 - data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xa) << 8) - data2:-1]; - CGEventRef downEvent = [downRef CGEvent]; - - NSEvent* upRef = [NSEvent otherEventWithType:NSSystemDefined - location: NSMakePoint(0, 0) modifierFlags:0xa00 - timestamp:0 windowNumber:0 context:0 subtype:8 - data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xb) << 8) - data2:-1]; - CGEventRef upEvent = [upRef CGEvent]; - - CGEventPost(0, downEvent); - CGEventPost(0, upEvent); - - return true; -} diff --git a/src/lib/platform/OSXMediaKeySupport.mm b/src/lib/platform/OSXMediaKeySupport.mm new file mode 100644 index 0000000..a4d5767 --- /dev/null +++ b/src/lib/platform/OSXMediaKeySupport.mm @@ -0,0 +1,154 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2016 Symless. + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#import "platform/OSXMediaKeySupport.h" +#import +#import + +int convertKeyIDToNXKeyType(KeyID id) +{ + int type = -1; + + switch (id) { + case kKeyAudioUp: + type = NX_KEYTYPE_SOUND_UP; + break; + case kKeyAudioDown: + type = NX_KEYTYPE_SOUND_DOWN; + break; + case kKeyBrightnessUp: + type = NX_KEYTYPE_BRIGHTNESS_UP; + break; + case kKeyBrightnessDown: + type = NX_KEYTYPE_BRIGHTNESS_DOWN; + break; + case kKeyAudioMute: + type = NX_KEYTYPE_MUTE; + break; + case kKeyEject: + type = NX_KEYTYPE_EJECT; + break; + case kKeyAudioPlay: + type = NX_KEYTYPE_PLAY; + break; + case kKeyAudioNext: + type = NX_KEYTYPE_NEXT; + break; + case kKeyAudioPrev: + type = NX_KEYTYPE_PREVIOUS; + break; + default: + break; + } + + return type; +} + +static KeyID +convertNXKeyTypeToKeyID(uint32_t const type) +{ + KeyID id = 0; + + switch (type) { + case NX_KEYTYPE_SOUND_UP: + id = kKeyAudioUp; + break; + case NX_KEYTYPE_SOUND_DOWN: + id = kKeyAudioDown; + break; + case NX_KEYTYPE_MUTE: + id = kKeyAudioMute; + break; + case NX_KEYTYPE_EJECT: + id = kKeyEject; + break; + case NX_KEYTYPE_PLAY: + id = kKeyAudioPlay; + break; + case NX_KEYTYPE_FAST: + case NX_KEYTYPE_NEXT: + id = kKeyAudioNext; + break; + case NX_KEYTYPE_REWIND: + case NX_KEYTYPE_PREVIOUS: + id = kKeyAudioPrev; + break; + default: + break; + } + + return id; +} + +bool +isMediaKeyEvent(CGEventRef event) { + NSEvent* nsEvent = nil; + @try { + nsEvent = [NSEvent eventWithCGEvent: event]; + if ([nsEvent subtype] != 8) { + return false; + } + uint32_t const nxKeyId = ([nsEvent data1] & 0xFFFF0000) >> 16; + if (convertNXKeyTypeToKeyID (nxKeyId)) { + return true; + } + } @catch (NSException* e) { + } + return false; +} + +bool +getMediaKeyEventInfo(CGEventRef event, KeyID* const keyId, + bool* const down, bool* const isRepeat) { + NSEvent* nsEvent = nil; + @try { + nsEvent = [NSEvent eventWithCGEvent: event]; + } @catch (NSException* e) { + return false; + } + if (keyId) { + *keyId = convertNXKeyTypeToKeyID (([nsEvent data1] & 0xFFFF0000) >> 16); + } + if (down) { + *down = !([nsEvent data1] & 0x100); + } + if (isRepeat) { + *isRepeat = [nsEvent data1] & 0x1; + } + return true; +} + +bool +fakeNativeMediaKey(KeyID id) +{ + + NSEvent* downRef = [NSEvent otherEventWithType:NSSystemDefined + location: NSMakePoint(0, 0) modifierFlags:0xa00 + timestamp:0 windowNumber:0 context:0 subtype:8 + data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xa) << 8) + data2:-1]; + CGEventRef downEvent = [downRef CGEvent]; + + NSEvent* upRef = [NSEvent otherEventWithType:NSSystemDefined + location: NSMakePoint(0, 0) modifierFlags:0xa00 + timestamp:0 windowNumber:0 context:0 subtype:8 + data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xb) << 8) + data2:-1]; + CGEventRef upEvent = [upRef CGEvent]; + + CGEventPost(kCGHIDEventTap, downEvent); + CGEventPost(kCGHIDEventTap, upEvent); + + return true; +} diff --git a/src/lib/platform/OSXPasteboardPeeker.h b/src/lib/platform/OSXPasteboardPeeker.h index 5105262..b69dba8 100644 --- a/src/lib/platform/OSXPasteboardPeeker.h +++ b/src/lib/platform/OSXPasteboardPeeker.h @@ -26,7 +26,7 @@ extern "C" { #endif CFStringRef getDraggedFileURL(); - + #if defined(__cplusplus) } #endif diff --git a/src/lib/platform/OSXPasteboardPeeker.m b/src/lib/platform/OSXPasteboardPeeker.m deleted file mode 100644 index ab39e26..0000000 --- a/src/lib/platform/OSXPasteboardPeeker.m +++ /dev/null @@ -1,37 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2013-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. - */ - -#import "platform/OSXPasteboardPeeker.h" - -#import -#import -#import - -CFStringRef -getDraggedFileURL() -{ - NSString* pbName = NSDragPboard; - NSPasteboard* pboard = [NSPasteboard pasteboardWithName:pbName]; - - NSMutableString* string; - string = [[NSMutableString alloc] initWithCapacity:0]; - - NSArray* files = [pboard propertyListForType:NSFilenamesPboardType]; - for (id file in files) { - [string appendString: (NSString*)file]; - [string appendString: @"\0"]; - } - - return (CFStringRef)string; -} diff --git a/src/lib/platform/OSXPasteboardPeeker.mm b/src/lib/platform/OSXPasteboardPeeker.mm new file mode 100644 index 0000000..ab39e26 --- /dev/null +++ b/src/lib/platform/OSXPasteboardPeeker.mm @@ -0,0 +1,37 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2013-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. + */ + +#import "platform/OSXPasteboardPeeker.h" + +#import +#import +#import + +CFStringRef +getDraggedFileURL() +{ + NSString* pbName = NSDragPboard; + NSPasteboard* pboard = [NSPasteboard pasteboardWithName:pbName]; + + NSMutableString* string; + string = [[NSMutableString alloc] initWithCapacity:0]; + + NSArray* files = [pboard propertyListForType:NSFilenamesPboardType]; + for (id file in files) { + [string appendString: (NSString*)file]; + [string appendString: @"\0"]; + } + + return (CFStringRef)string; +} diff --git a/src/lib/platform/OSXScreen.h b/src/lib/platform/OSXScreen.h index 68c7c68..691b74c 100644 --- a/src/lib/platform/OSXScreen.h +++ b/src/lib/platform/OSXScreen.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -37,7 +37,7 @@ extern "C" { typedef int CGSConnectionID; CGError CGSSetConnectionProperty(CGSConnectionID cid, CGSConnectionID targetCID, CFStringRef key, CFTypeRef value); int _CGSDefaultConnection(); -} +} template @@ -98,10 +98,10 @@ public: virtual bool isPrimary() const; virtual void fakeDraggingFiles(DragFileList fileList); virtual std::string& getDraggingFilename(); - + const std::string& getDropTarget() const { return m_dropTarget; } void waitForCarbonLoop() const; - + protected: // IPlatformScreen overrides virtual void handleSystemEvent(const Event&, void*); @@ -112,7 +112,7 @@ private: void updateScreenShape(); void updateScreenShape(const CGDirectDisplayID, const CGDisplayChangeSummaryFlags); void postMouseEvent(CGPoint&) const; - + // convenience function to send events void sendEvent(Event::Type type, void* = NULL) const; void sendClipboardEvent(Event::Type type, ClipboardID id) const; @@ -124,16 +124,16 @@ private: // of the button pressed using the mac button mapping. bool onMouseButton(bool pressed, UInt16 macButton); bool onMouseWheel(SInt32 xDelta, SInt32 yDelta) const; - + void constructMouseButtonEventMap(); bool onKey(CGEventRef event); void onMediaKey(CGEventRef event); - + bool onHotKey(EventRef event) const; - - // Added here to allow the carbon cursor hack to be called. + + // Added here to allow the carbon cursor hack to be called. void showCursor(); void hideCursor(); @@ -172,9 +172,9 @@ private: static pascal OSStatus userSwitchCallback(EventHandlerCallRef nextHandler, EventRef theEvent, void* inUserData); - + // sleep / wakeup support - void watchSystemPowerThread(void*); + void watchSystemPowerThread(); static void testCanceled(CFRunLoopTimerRef timer, void*info); static void powerChangeCallback(void* refcon, io_service_t service, natural_t messageType, void* messageArgument); @@ -182,12 +182,12 @@ private: void* messageArgument); void handleConfirmSleep(const Event& event, void*); - + // global hotkey operating mode static bool isGlobalHotKeyOperatingModeAvailable(); static void setGlobalHotKeysEnabled(bool enabled); static bool getGlobalHotKeysEnabled(); - + // Quartz event tap support static CGEventRef handleCGInputEvent(CGEventTapProxy proxy, CGEventType type, @@ -197,12 +197,12 @@ private: CGEventType type, CGEventRef event, void* refcon); - + // convert CFString to char* static char* CFStringRefToUTF8String(CFStringRef aString); - - void getDropTargetThread(void*); - + + void get_drop_target_thread(); + private: struct HotKeyItem { public: @@ -225,13 +225,13 @@ private: kMouseButtonDown, kMouseButtonStateMax }; - + class MouseButtonState { public: void set(UInt32 button, EMouseButtonState state); bool any(); - void reset(); + void reset(); void overwrite(UInt32 buttons); bool test(UInt32 button) const; @@ -262,7 +262,7 @@ private: // mouse state mutable SInt32 m_xCursor, m_yCursor; mutable bool m_cursorPosValid; - + /* FIXME: this data structure is explicitly marked mutable due to a need to track the state of buttons since the remote side only lets us know of change events, and because the @@ -321,7 +321,7 @@ private: // global hotkey operating mode static bool s_testedForGHOM; static bool s_hasGHOM; - + // Quartz input event support CFMachPortRef m_eventTapPort; CFRunLoopSourceRef m_eventTapRLSR; @@ -336,10 +336,10 @@ private: bool m_autoShowHideCursor; IEventQueue* m_events; - + Thread* m_getDropTargetThread; std::string m_dropTarget; - + #if defined(MAC_OS_X_VERSION_10_7) Mutex* m_carbonLoopMutex; CondVar* m_carbonLoopReady; diff --git a/src/lib/platform/OSXScreen.mm b/src/lib/platform/OSXScreen.mm index 2b4594f..d41e321 100644 --- a/src/lib/platform/OSXScreen.mm +++ b/src/lib/platform/OSXScreen.mm @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -38,7 +38,6 @@ #include "base/Log.h" #include "base/IEventQueue.h" #include "base/TMethodEventJob.h" -#include "base/TMethodJob.h" #include #include @@ -110,10 +109,10 @@ OSXScreen::OSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCurso updateScreenShape(m_displayID, 0); m_screensaver = new OSXScreenSaver(m_events, getEventTarget()); m_keyState = new OSXKeyState(m_events); - + // only needed when running as a server. if (m_isPrimary) { - + #if defined(MAC_OS_X_VERSION_10_9) // we can't pass options to show the dialog, this must be done by the gui. if (!AXIsProcessTrusted()) { @@ -126,7 +125,7 @@ OSXScreen::OSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCurso } #endif } - + // install display manager notification handler CGDisplayRegisterReconfigurationCallback(displayReconfigurationCallback, this); @@ -157,8 +156,7 @@ OSXScreen::OSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCurso m_carbonLoopReady = new CondVar(m_carbonLoopMutex, false); #endif LOG((CLOG_DEBUG "starting watchSystemPowerThread")); - m_pmWatchThread = new Thread(new TMethodJob - (this, &OSXScreen::watchSystemPowerThread)); + m_pmWatchThread = new Thread([this](){ watchSystemPowerThread(); }); } catch (...) { m_events->removeHandler(m_events->forOSXScreen().confirmSleep(), @@ -166,7 +164,7 @@ OSXScreen::OSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCurso if (m_switchEventHandlerRef != 0) { RemoveEventHandler(m_switchEventHandlerRef); } - + CGDisplayRemoveReconfigurationCallback(displayReconfigurationCallback, this); delete m_keyState; @@ -217,7 +215,7 @@ OSXScreen::~OSXScreen() delete m_keyState; delete m_screensaver; - + #if defined(MAC_OS_X_VERSION_10_7) delete m_carbonLoopMutex; delete m_carbonLoopReady; @@ -273,7 +271,7 @@ OSXScreen::warpCursor(SInt32 x, SInt32 y) pos.x = x; pos.y = y; CGWarpMouseCursorPosition(pos); - + // save new cursor position m_xCursor = x; m_yCursor = y; @@ -325,7 +323,7 @@ OSXScreen::registerHotKey(KeyID key, KeyModifierMask mask) LOG((CLOG_DEBUG "could not map hotkey id=%04x mask=%04x", key, mask)); return 0; } - + // choose hotkey id UInt32 id; if (!m_oldHotKeyIDs.empty()) { @@ -351,7 +349,7 @@ OSXScreen::registerHotKey(KeyID key, KeyModifierMask mask) } else { EventHotKeyID hkid = { 'SNRG', (UInt32)id }; - OSStatus status = RegisterEventHotKey(macKey, macMask, hkid, + OSStatus status = RegisterEventHotKey(macKey, macMask, hkid, GetApplicationEventTarget(), 0, &ref); okay = (status == noErr); @@ -366,7 +364,7 @@ OSXScreen::registerHotKey(KeyID key, KeyModifierMask mask) } m_hotKeys.insert(std::make_pair(id, HotKeyItem(ref, macKey, macMask))); - + LOG((CLOG_DEBUG "registered hotkey %s (id=%04x mask=%04x) as id=%d", barrier::KeyMap::formatKey(key, mask).c_str(), key, mask, id)); return id; } @@ -468,7 +466,7 @@ OSXScreen::postMouseEvent(CGPoint& pos) const } } } - + CGEventType type = kCGEventMouseMoved; SInt8 button = m_buttonState.getFirstButtonDown(); @@ -478,10 +476,10 @@ OSXScreen::postMouseEvent(CGPoint& pos) const } CGEventRef event = CGEventCreateMouseEvent(NULL, type, pos, static_cast(button)); - + // Dragging events also need the click state CGEventSetIntegerValueField(event, kCGMouseEventClickState, m_clickState); - + // Fix for sticky keys CGEventFlags modifiers = m_keyState->getModifierStateAsOSXFlags(); CGEventSetFlags(event, modifiers); @@ -503,7 +501,7 @@ OSXScreen::postMouseEvent(CGPoint& pos) const CGEventSetDoubleValueField(event, kCGMouseEventDeltaY, deltaFY); CGEventPost(kCGHIDEventTap, event); - + CFRelease(event); } @@ -515,7 +513,7 @@ OSXScreen::fakeMouseButton(ButtonID id, bool press) if (index >= NumButtonIDs) { return; } - + CGPoint pos; if (!m_cursorPosValid) { SInt32 x, y; @@ -533,79 +531,77 @@ OSXScreen::fakeMouseButton(ButtonID id, bool press) // since we don't have double click distance in NX APIs // we define our own defaults. const double maxDiff = sqrt(2) + 0.0001; - + double clickTime = [NSEvent doubleClickInterval]; - + // As long as the click is within the time window and distance window // increase clickState (double click, triple click, etc) - // This will allow for higher than triple click but the quartz documenation + // This will allow for higher than triple click but the quartz documentation // does not specify that this should be limited to triple click if (press) { - if ((ARCH->time() - m_lastClickTime) <= clickTime && diff <= maxDiff){ + if ((ARCH->time() - m_lastClickTime) <= clickTime && diff <= maxDiff) { m_clickState++; } else { m_clickState = 1; } - + m_lastClickTime = ARCH->time(); } - - if (m_clickState == 1){ + + if (m_clickState == 1) { m_lastSingleClickXCursor = m_xCursor; m_lastSingleClickYCursor = m_yCursor; } - + EMouseButtonState state = press ? kMouseButtonDown : kMouseButtonUp; - + LOG((CLOG_DEBUG1 "faking mouse button id: %d press: %s", index, press ? "pressed" : "released")); - + MouseButtonEventMapType thisButtonMap = MouseButtonEventMap[index]; CGEventType type = thisButtonMap[state]; CGEventRef event = CGEventCreateMouseEvent(NULL, type, pos, static_cast(index)); - + CGEventSetIntegerValueField(event, kCGMouseEventClickState, m_clickState); - + // Fix for sticky keys CGEventFlags modifiers = m_keyState->getModifierStateAsOSXFlags(); CGEventSetFlags(event, modifiers); - + m_buttonState.set(index, state); CGEventPost(kCGHIDEventTap, event); - + CFRelease(event); - + if (!press && (id == kButtonLeft)) { if (m_fakeDraggingStarted) { - m_getDropTargetThread = new Thread(new TMethodJob( - this, &OSXScreen::getDropTargetThread)); + m_getDropTargetThread = new Thread([this](){ get_drop_target_thread(); }); } - + m_draggingStarted = false; } } -void -OSXScreen::getDropTargetThread(void*) +void OSXScreen::get_drop_target_thread() { #if defined(MAC_OS_X_VERSION_10_7) char* cstr = NULL; - + // wait for 5 secs for the drop destinaiton string to be filled. UInt32 timeout = ARCH->time() + 5; - + while (ARCH->time() < timeout) { CFStringRef cfstr = getCocoaDropTarget(); cstr = CFStringRefToUTF8String(cfstr); CFRelease(cfstr); - + if (cstr != NULL) { break; } ARCH->sleep(.1f); } - + if (cstr != NULL) { LOG((CLOG_DEBUG "drop target: %s", cstr)); m_dropTarget = cstr; @@ -626,12 +622,12 @@ OSXScreen::fakeMouseMove(SInt32 x, SInt32 y) if (m_fakeDraggingStarted) { m_buttonState.set(0, kMouseButtonDown); } - + // index 0 means left mouse button if (m_buttonState.test(0)) { m_draggingStarted = true; } - + // synthesize event CGPoint pos; pos.x = x; @@ -679,11 +675,11 @@ OSXScreen::fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const NULL, kCGScrollEventUnitLine, 2, mapScrollWheelFromBarrier(yDelta), -mapScrollWheelFromBarrier(xDelta)); - + // Fix for sticky keys CGEventFlags modifiers = m_keyState->getModifierStateAsOSXFlags(); CGEventSetFlags(scrollEvent, modifiers); - + CGEventPost(kCGHIDEventTap, scrollEvent); CFRelease(scrollEvent); } @@ -754,11 +750,11 @@ OSXScreen::enable() if (m_isPrimary) { // FIXME -- start watching jump zones - + // kCGEventTapOptionDefault = 0x00000000 (Missing in 10.4, so specified literally) m_eventTapPort = CGEventTapCreate(kCGHIDEventTap, kCGHeadInsertEventTap, kCGEventTapOptionDefault, - kCGEventMaskForAllEvents, - handleCGInputEvent, + kCGEventMaskForAllEvents, + handleCGInputEvent, this); } else { @@ -773,10 +769,10 @@ OSXScreen::enable() // there may be a better way to do this, but we register an event handler even if we're // not on the primary display (acting as a client). This way, if a local event comes in - // (either keyboard or mouse), we can make sure to show the cursor if we've hidden it. + // (either keyboard or mouse), we can make sure to show the cursor if we've hidden it. m_eventTapPort = CGEventTapCreate(kCGHIDEventTap, kCGHeadInsertEventTap, kCGEventTapOptionDefault, - kCGEventMaskForAllEvents, - handleCGInputEventSecondary, + kCGEventMaskForAllEvents, + handleCGInputEventSecondary, this); } @@ -798,9 +794,9 @@ OSXScreen::disable() if (m_autoShowHideCursor) { showCursor(); } - + // FIXME -- stop watching jump zones, stop capturing input - + if (m_eventTapRLSR) { CFRunLoopRemoveSource(CFRunLoopGetCurrent(), m_eventTapRLSR, kCFRunLoopDefaultMode); CFRelease(m_eventTapRLSR); @@ -846,7 +842,7 @@ OSXScreen::enter() io_registry_entry_t entry = IORegistryEntryFromPath( kIOMasterPortDefault, "IOService:/IOResources/IODisplayWrangler"); - + if (entry != MACH_PORT_NULL) { IORegistryEntrySetCFProperty(entry, CFSTR("IORequestIdle"), kCFBooleanFalse); IOObjectRelease(entry); @@ -863,15 +859,15 @@ bool OSXScreen::leave() { hideCursor(); - + if (isDraggingStarted()) { String& fileList = getDraggingFilename(); - + if (!m_isPrimary) { if (fileList.empty() == false) { ClientApp& app = ClientApp::instance(); Client* client = app.getClientPtr(); - + DragInformation di; di.setFilename(fileList); DragFileList dragFileList; @@ -881,7 +877,7 @@ OSXScreen::leave() dragFileList, info); client->sendDragInfo(fileCount, info, info.size()); LOG((CLOG_DEBUG "send dragging file to server")); - + // TODO: what to do with multiple file or even // a folder client->sendFileToServer(fileList.c_str()); @@ -889,7 +885,7 @@ OSXScreen::leave() } m_draggingStarted = false; } - + if (m_isPrimary) { avoidHesitatingCursor(); @@ -906,8 +902,8 @@ OSXScreen::setClipboard(ClipboardID, const IClipboard* src) { if (src != NULL) { LOG((CLOG_DEBUG "setting clipboard")); - Clipboard::copy(&m_pasteboard, src); - } + Clipboard::copy(&m_pasteboard, src); + } return true; } @@ -1036,16 +1032,16 @@ OSXScreen::handleSystemEvent(const Event& event, void*) } break; - case kEventClassKeyboard: + case kEventClassKeyboard: switch (GetEventKind(*carbonEvent)) { case kEventHotKeyPressed: case kEventHotKeyReleased: onHotKey(*carbonEvent); break; } - + break; - + case kEventClassWindow: // 2nd param was formerly GetWindowEventTarget(m_userInputWindow) which is 32-bit only, // however as m_userInputWindow is never initialized to anything we can take advantage of @@ -1076,7 +1072,7 @@ OSXScreen::handleSystemEvent(const Event& event, void*) } } -bool +bool OSXScreen::onMouseMove(CGFloat mx, CGFloat my) { LOG((CLOG_DEBUG2 "mouse move %+f,%+f", mx, my)); @@ -1140,7 +1136,7 @@ OSXScreen::onMouseMove(CGFloat mx, CGFloat my) return true; } -bool +bool OSXScreen::onMouseButton(bool pressed, UInt16 macButton) { // Buttons 2 and 3 are inverted on the mac @@ -1176,7 +1172,7 @@ OSXScreen::onMouseButton(bool pressed, UInt16 macButton) } } } - + if (macButton == kButtonLeft) { EMouseButtonState state = pressed ? kMouseButtonDown : kMouseButtonUp; m_buttonState.set(kButtonLeft - 1, state); @@ -1186,10 +1182,9 @@ OSXScreen::onMouseButton(bool pressed, UInt16 macButton) } else { if (m_fakeDraggingStarted) { - m_getDropTargetThread = new Thread(new TMethodJob( - this, &OSXScreen::getDropTargetThread)); + m_getDropTargetThread = new Thread([this](){ get_drop_target_thread(); }); } - + m_draggingStarted = false; } } @@ -1218,16 +1213,16 @@ OSXScreen::displayReconfigurationCallback(CGDirectDisplayID displayID, CGDisplay // Closing or opening the lid when an external monitor is // connected causes an kCGDisplayBeginConfigurationFlag event - CGDisplayChangeSummaryFlags mask = kCGDisplayBeginConfigurationFlag | kCGDisplayMovedFlag | - kCGDisplaySetModeFlag | kCGDisplayAddFlag | kCGDisplayRemoveFlag | - kCGDisplayEnabledFlag | kCGDisplayDisabledFlag | - kCGDisplayMirrorFlag | kCGDisplayUnMirrorFlag | + CGDisplayChangeSummaryFlags mask = kCGDisplayBeginConfigurationFlag | kCGDisplayMovedFlag | + kCGDisplaySetModeFlag | kCGDisplayAddFlag | kCGDisplayRemoveFlag | + kCGDisplayEnabledFlag | kCGDisplayDisabledFlag | + kCGDisplayMirrorFlag | kCGDisplayUnMirrorFlag | kCGDisplayDesktopShapeChangedFlag; - + LOG((CLOG_DEBUG1 "event: display was reconfigured: %x %x %x", flags, mask, flags & mask)); if (flags & mask) { /* Something actually did change */ - + LOG((CLOG_DEBUG1 "event: screen changed shape; refreshing dimensions")); screen->updateScreenShape(displayID, flags); } @@ -1274,7 +1269,7 @@ OSXScreen::onKey(CGEventRef event) m_activeModifierHotKeyMask = 0; } } - + return true; } @@ -1342,7 +1337,7 @@ OSXScreen::onKey(CGEventRef event) } void -OSXScreen::onMediaKey(CGEventRef event) +OSXScreen::onMediaKey(CGEventRef event) { KeyID keyID; bool down; @@ -1405,7 +1400,7 @@ OSXScreen::mapBarrierButtonToMac(UInt16 button) const return static_cast(button); } -ButtonID +ButtonID OSXScreen::mapMacButtonToBarrier(UInt16 macButton) const { switch (macButton) { @@ -1418,7 +1413,7 @@ OSXScreen::mapMacButtonToBarrier(UInt16 macButton) const case 3: return kButtonMiddle; } - + return static_cast(macButton); } @@ -1445,8 +1440,8 @@ OSXScreen::getScrollSpeed() const double scaling = 0.0; CFPropertyListRef pref = ::CFPreferencesCopyValue( - CFSTR("com.apple.scrollwheel.scaling") , - kCFPreferencesAnyApplication, + CFSTR("com.apple.scrollwheel.scaling") , + kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); if (pref != NULL) { @@ -1535,7 +1530,7 @@ OSXScreen::updateScreenShape() if (CGGetActiveDisplayList(0, NULL, &displayCount) != CGDisplayNoErr) { return; } - + if (displayCount == 0) { return; } @@ -1579,13 +1574,13 @@ OSXScreen::updateScreenShape() (displayCount == 1) ? "display" : "displays")); } -#pragma mark - +#pragma mark - // // FAST USER SWITCH NOTIFICATION SUPPORT // // OSXScreen::userSwitchCallback(void*) -// +// // gets called if a fast user switch occurs // @@ -1611,18 +1606,17 @@ OSXScreen::userSwitchCallback(EventHandlerCallRef nextHandler, return (CallNextEventHandler(nextHandler, theEvent)); } -#pragma mark - +#pragma mark - // // SLEEP/WAKEUP NOTIFICATION SUPPORT // // OSXScreen::watchSystemPowerThread(void*) -// -// main of thread monitoring system power (sleep/wakup) using a CFRunLoop +// +// main of thread monitoring system power (sleep/wakeup) using a CFRunLoop // -void -OSXScreen::watchSystemPowerThread(void*) +void OSXScreen::watchSystemPowerThread() { io_object_t notifier; IONotificationPortRef notificationPortRef; @@ -1641,7 +1635,7 @@ OSXScreen::watchSystemPowerThread(void*) CFRunLoopAddSource(m_pmRunloop, runloopSourceRef, kCFRunLoopCommonModes); } - + // thread is ready { Lock lock(m_pmMutex); @@ -1658,15 +1652,15 @@ OSXScreen::watchSystemPowerThread(void*) } LOG((CLOG_DEBUG "started watchSystemPowerThread")); - + LOG((CLOG_DEBUG "waiting for event loop")); m_events->waitForReady(); - + #if defined(MAC_OS_X_VERSION_10_7) { Lock lockCarbon(m_carbonLoopMutex); if (*m_carbonLoopReady == false) { - + // we signalling carbon loop ready before starting // unless we know how to do it within the loop LOG((CLOG_DEBUG "signalling carbon loop ready")); @@ -1676,12 +1670,12 @@ OSXScreen::watchSystemPowerThread(void*) } } #endif - + // start the run loop LOG((CLOG_DEBUG "starting carbon loop")); CFRunLoopRun(); LOG((CLOG_DEBUG "carbon loop has stopped")); - + // cleanup if (notificationPortRef) { CFRunLoopRemoveSource(m_pmRunloop, @@ -1716,7 +1710,7 @@ OSXScreen::handlePowerChangeRequest(natural_t messageType, void* messageArg) getEventTarget(), messageArg, Event::kDontFreeData)); return; - + case kIOMessageSystemHasPoweredOn: LOG((CLOG_DEBUG "system wakeup")); m_events->addEvent(Event(m_events->forIScreen().resume(), @@ -1742,16 +1736,16 @@ OSXScreen::handleConfirmSleep(const Event& event, void*) if (m_pmRootPort != 0) { // deliver suspend event immediately. m_events->addEvent(Event(m_events->forIScreen().suspend(), - getEventTarget(), NULL, + getEventTarget(), NULL, Event::kDeliverImmediately)); - + LOG((CLOG_DEBUG "system will sleep")); IOAllowPowerChange(m_pmRootPort, messageArg); } } } -#pragma mark - +#pragma mark - // // GLOBAL HOTKEY OPERATING MODE SUPPORT (10.3) @@ -1941,7 +1935,7 @@ OSXScreen::handleCGInputEvent(CGEventTapProxy proxy, case kCGEventMouseMoved: pos = CGEventGetLocation(event); screen->onMouseMove(pos.x, pos.y); - + // The system ignores our cursor-centering calls if // we don't return the event. This should be harmless, // but might register as slight movement to other apps @@ -1980,10 +1974,10 @@ OSXScreen::handleCGInputEvent(CGEventTapProxy proxy, } break; } - + LOG((CLOG_DEBUG3 "unknown quartz event type: 0x%02x", type)); } - + if (screen->m_isOnScreen) { return event; } else { @@ -1992,38 +1986,38 @@ OSXScreen::handleCGInputEvent(CGEventTapProxy proxy, } void -OSXScreen::MouseButtonState::set(UInt32 button, EMouseButtonState state) +OSXScreen::MouseButtonState::set(UInt32 button, EMouseButtonState state) { bool newState = (state == kMouseButtonDown); m_buttons.set(button, newState); } bool -OSXScreen::MouseButtonState::any() +OSXScreen::MouseButtonState::any() { return m_buttons.any(); } void -OSXScreen::MouseButtonState::reset() +OSXScreen::MouseButtonState::reset() { m_buttons.reset(); } void -OSXScreen::MouseButtonState::overwrite(UInt32 buttons) +OSXScreen::MouseButtonState::overwrite(UInt32 buttons) { m_buttons = std::bitset(buttons); } bool -OSXScreen::MouseButtonState::test(UInt32 button) const +OSXScreen::MouseButtonState::test(UInt32 button) const { return m_buttons.test(button); } SInt8 -OSXScreen::MouseButtonState::getFirstButtonDown() const +OSXScreen::MouseButtonState::getFirstButtonDown() const { if (m_buttons.any()) { for (unsigned short button = 0; button < m_buttons.size(); button++) { @@ -2041,7 +2035,7 @@ OSXScreen::CFStringRefToUTF8String(CFStringRef aString) if (aString == NULL) { return NULL; } - + CFIndex length = CFStringGetLength(aString); CFIndex maxSize = CFStringGetMaximumSizeForEncoding( length, diff --git a/src/lib/platform/OSXScreenSaver.cpp b/src/lib/platform/OSXScreenSaver.cpp index a0282d9..4af761a 100644 --- a/src/lib/platform/OSXScreenSaver.cpp +++ b/src/lib/platform/OSXScreenSaver.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -48,17 +48,17 @@ OSXScreenSaver::OSXScreenSaver(IEventQueue* events, void* eventTarget) : launchEventTypes[0].eventKind = kEventAppLaunched; launchEventTypes[1].eventClass = kEventClassApplication; launchEventTypes[1].eventKind = kEventAppTerminated; - + EventHandlerUPP launchTerminationEventHandler = NewEventHandlerUPP(launchTerminationCallback); InstallApplicationEventHandler(launchTerminationEventHandler, 2, launchEventTypes, this, &m_launchTerminationEventHandlerRef); DisposeEventHandlerUPP(launchTerminationEventHandler); - + m_screenSaverPSN.highLongOfPSN = 0; m_screenSaverPSN.lowLongOfPSN = 0; - + if (isActive()) { getProcessSerialNumber("ScreenSaverEngine", m_screenSaverPSN); } @@ -128,7 +128,7 @@ OSXScreenSaver::processTerminated(ProcessSerialNumber psn) Event(m_events->forIPrimaryScreen().screensaverDeactivated(), m_eventTarget)); } - + m_screenSaverPSN.highLongOfPSN = 0; m_screenSaverPSN.lowLongOfPSN = 0; } @@ -140,7 +140,7 @@ OSXScreenSaver::launchTerminationCallback( EventRef theEvent, void* userData) { OSStatus result; - ProcessSerialNumber psn; + ProcessSerialNumber psn; EventParamType actualType; ByteCount actualSize; diff --git a/src/lib/platform/OSXScreenSaver.h b/src/lib/platform/OSXScreenSaver.h index 07f2a7b..9a040a7 100644 --- a/src/lib/platform/OSXScreenSaver.h +++ b/src/lib/platform/OSXScreenSaver.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -36,11 +36,11 @@ public: virtual void activate(); virtual void deactivate(); virtual bool isActive() const; - + private: void processLaunched(ProcessSerialNumber psn); void processTerminated(ProcessSerialNumber psn); - + static pascal OSStatus launchTerminationCallback( EventHandlerCallRef nextHandler, diff --git a/src/lib/platform/OSXScreenSaverControl.h b/src/lib/platform/OSXScreenSaverControl.h index 76f8875..ff9d4f0 100644 --- a/src/lib/platform/OSXScreenSaverControl.h +++ b/src/lib/platform/OSXScreenSaverControl.h @@ -6,7 +6,7 @@ * 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 diff --git a/src/lib/platform/OSXScreenSaverUtil.h b/src/lib/platform/OSXScreenSaverUtil.h index 045553d..2ccb3c0 100644 --- a/src/lib/platform/OSXScreenSaverUtil.h +++ b/src/lib/platform/OSXScreenSaverUtil.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/OSXScreenSaverUtil.m b/src/lib/platform/OSXScreenSaverUtil.m deleted file mode 100644 index 6d82f10..0000000 --- a/src/lib/platform/OSXScreenSaverUtil.m +++ /dev/null @@ -1,83 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2004 Chris Schoeneman, Nick Bolton, Sorin Sbarnea - * - * 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. - */ - -#import "platform/OSXScreenSaverUtil.h" - -#import "platform/OSXScreenSaverControl.h" - -#import - -// -// screenSaverUtil functions -// -// Note: these helper functions exist only so we can avoid using ObjC++. -// autoconf/automake don't know about ObjC++ and I don't know how to -// teach them about it. -// - -void* -screenSaverUtilCreatePool() -{ - return [[NSAutoreleasePool alloc] init]; -} - -void -screenSaverUtilReleasePool(void* pool) -{ - [(NSAutoreleasePool*)pool release]; -} - -void* -screenSaverUtilCreateController() -{ - return [[ScreenSaverController controller] retain]; -} - -void -screenSaverUtilReleaseController(void* controller) -{ - [(ScreenSaverController*)controller release]; -} - -void -screenSaverUtilEnable(void* controller) -{ - [(ScreenSaverController*)controller setScreenSaverCanRun:YES]; -} - -void -screenSaverUtilDisable(void* controller) -{ - [(ScreenSaverController*)controller setScreenSaverCanRun:NO]; -} - -void -screenSaverUtilActivate(void* controller) -{ - [(ScreenSaverController*)controller setScreenSaverCanRun:YES]; - [(ScreenSaverController*)controller screenSaverStartNow]; -} - -void -screenSaverUtilDeactivate(void* controller, int isEnabled) -{ - [(ScreenSaverController*)controller screenSaverStopNow]; - [(ScreenSaverController*)controller setScreenSaverCanRun:isEnabled]; -} - -int -screenSaverUtilIsActive(void* controller) -{ - return [(ScreenSaverController*)controller screenSaverIsRunning]; -} diff --git a/src/lib/platform/OSXScreenSaverUtil.mm b/src/lib/platform/OSXScreenSaverUtil.mm new file mode 100644 index 0000000..6d82f10 --- /dev/null +++ b/src/lib/platform/OSXScreenSaverUtil.mm @@ -0,0 +1,83 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2004 Chris Schoeneman, Nick Bolton, Sorin Sbarnea + * + * 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. + */ + +#import "platform/OSXScreenSaverUtil.h" + +#import "platform/OSXScreenSaverControl.h" + +#import + +// +// screenSaverUtil functions +// +// Note: these helper functions exist only so we can avoid using ObjC++. +// autoconf/automake don't know about ObjC++ and I don't know how to +// teach them about it. +// + +void* +screenSaverUtilCreatePool() +{ + return [[NSAutoreleasePool alloc] init]; +} + +void +screenSaverUtilReleasePool(void* pool) +{ + [(NSAutoreleasePool*)pool release]; +} + +void* +screenSaverUtilCreateController() +{ + return [[ScreenSaverController controller] retain]; +} + +void +screenSaverUtilReleaseController(void* controller) +{ + [(ScreenSaverController*)controller release]; +} + +void +screenSaverUtilEnable(void* controller) +{ + [(ScreenSaverController*)controller setScreenSaverCanRun:YES]; +} + +void +screenSaverUtilDisable(void* controller) +{ + [(ScreenSaverController*)controller setScreenSaverCanRun:NO]; +} + +void +screenSaverUtilActivate(void* controller) +{ + [(ScreenSaverController*)controller setScreenSaverCanRun:YES]; + [(ScreenSaverController*)controller screenSaverStartNow]; +} + +void +screenSaverUtilDeactivate(void* controller, int isEnabled) +{ + [(ScreenSaverController*)controller screenSaverStopNow]; + [(ScreenSaverController*)controller setScreenSaverCanRun:isEnabled]; +} + +int +screenSaverUtilIsActive(void* controller) +{ + return [(ScreenSaverController*)controller screenSaverIsRunning]; +} diff --git a/src/lib/platform/OSXUchrKeyResource.cpp b/src/lib/platform/OSXUchrKeyResource.cpp index e0230e9..8d16bfb 100644 --- a/src/lib/platform/OSXUchrKeyResource.cpp +++ b/src/lib/platform/OSXUchrKeyResource.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 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 diff --git a/src/lib/platform/OSXUchrKeyResource.h b/src/lib/platform/OSXUchrKeyResource.h index 47b63c9..8e1a813 100644 --- a/src/lib/platform/OSXUchrKeyResource.h +++ b/src/lib/platform/OSXUchrKeyResource.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 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 @@ -27,7 +27,7 @@ typedef TISInputSourceRef KeyLayout; class OSXUchrKeyResource : public IOSXKeyResource { public: OSXUchrKeyResource(const void*, UInt32 keyboardType); - + // KeyResource overrides virtual bool isValid() const; virtual UInt32 getNumModifierCombinations() const; @@ -35,15 +35,15 @@ public: virtual UInt32 getNumButtons() const; virtual UInt32 getTableForModifier(UInt32 mask) const; virtual KeyID getKey(UInt32 table, UInt32 button) const; - + private: typedef std::vector KeySequence; - + bool getDeadKey(KeySequence& keys, UInt16 index) const; bool getKeyRecord(KeySequence& keys, UInt16 index, UInt16& state) const; bool addSequence(KeySequence& keys, UCKeyCharSeq c) const; - + private: const UCKeyboardLayout* m_resource; const UCKeyModifiersToTableNum* m_m; diff --git a/src/lib/platform/XWindowsClipboard.cpp b/src/lib/platform/XWindowsClipboard.cpp index b0da695..27321e5 100644 --- a/src/lib/platform/XWindowsClipboard.cpp +++ b/src/lib/platform/XWindowsClipboard.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -84,9 +84,13 @@ XWindowsClipboard::XWindowsClipboard(IXWindowsImpl* impl, Display* display, // add converters, most desired first m_converters.push_back(new XWindowsClipboardHTMLConverter(m_display, "text/html")); + m_converters.push_back(new XWindowsClipboardHTMLConverter(m_display, + "application/x-moz-nativehtml")); m_converters.push_back(new XWindowsClipboardBMPConverter(m_display)); m_converters.push_back(new XWindowsClipboardUTF8Converter(m_display, "text/plain;charset=UTF-8")); + m_converters.push_back(new XWindowsClipboardUTF8Converter(m_display, + "text/plain;charset=utf-8")); m_converters.push_back(new XWindowsClipboardUTF8Converter(m_display, "UTF8_STRING")); m_converters.push_back(new XWindowsClipboardUCS2Converter(m_display, diff --git a/src/lib/platform/XWindowsClipboard.h b/src/lib/platform/XWindowsClipboard.h index 091036e..5f1b6cb 100644 --- a/src/lib/platform/XWindowsClipboard.h +++ b/src/lib/platform/XWindowsClipboard.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -25,11 +25,7 @@ #include "common/stdvector.h" #include "XWindowsImpl.h" -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include -#endif +#include class IXWindowsClipboardConverter; diff --git a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp index f6fed1c..0190f1d 100644 --- a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp +++ b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h index 861b1b6..375d8cc 100644 --- a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h +++ b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/XWindowsClipboardBMPConverter.cpp b/src/lib/platform/XWindowsClipboardBMPConverter.cpp index fcfdc69..fd3325e 100644 --- a/src/lib/platform/XWindowsClipboardBMPConverter.cpp +++ b/src/lib/platform/XWindowsClipboardBMPConverter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/XWindowsClipboardBMPConverter.h b/src/lib/platform/XWindowsClipboardBMPConverter.h index 4afa788..12716d1 100644 --- a/src/lib/platform/XWindowsClipboardBMPConverter.h +++ b/src/lib/platform/XWindowsClipboardBMPConverter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/XWindowsClipboardHTMLConverter.cpp b/src/lib/platform/XWindowsClipboardHTMLConverter.cpp index 6ae98a7..a13e80e 100644 --- a/src/lib/platform/XWindowsClipboardHTMLConverter.cpp +++ b/src/lib/platform/XWindowsClipboardHTMLConverter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/XWindowsClipboardHTMLConverter.h b/src/lib/platform/XWindowsClipboardHTMLConverter.h index 9a4ce61..b2a1a1e 100644 --- a/src/lib/platform/XWindowsClipboardHTMLConverter.h +++ b/src/lib/platform/XWindowsClipboardHTMLConverter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/XWindowsClipboardTextConverter.cpp b/src/lib/platform/XWindowsClipboardTextConverter.cpp index 2e18d91..ee34f13 100644 --- a/src/lib/platform/XWindowsClipboardTextConverter.cpp +++ b/src/lib/platform/XWindowsClipboardTextConverter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/XWindowsClipboardTextConverter.h b/src/lib/platform/XWindowsClipboardTextConverter.h index 99cdbcb..14e6c0f 100644 --- a/src/lib/platform/XWindowsClipboardTextConverter.h +++ b/src/lib/platform/XWindowsClipboardTextConverter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/XWindowsClipboardUCS2Converter.cpp b/src/lib/platform/XWindowsClipboardUCS2Converter.cpp index d3d5e04..75dd70e 100644 --- a/src/lib/platform/XWindowsClipboardUCS2Converter.cpp +++ b/src/lib/platform/XWindowsClipboardUCS2Converter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/XWindowsClipboardUCS2Converter.h b/src/lib/platform/XWindowsClipboardUCS2Converter.h index 16d880a..0bedb7a 100644 --- a/src/lib/platform/XWindowsClipboardUCS2Converter.h +++ b/src/lib/platform/XWindowsClipboardUCS2Converter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/XWindowsClipboardUTF8Converter.cpp b/src/lib/platform/XWindowsClipboardUTF8Converter.cpp index f470cf1..a452706 100644 --- a/src/lib/platform/XWindowsClipboardUTF8Converter.cpp +++ b/src/lib/platform/XWindowsClipboardUTF8Converter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/XWindowsClipboardUTF8Converter.h b/src/lib/platform/XWindowsClipboardUTF8Converter.h index 2219ed2..bb6cafb 100644 --- a/src/lib/platform/XWindowsClipboardUTF8Converter.h +++ b/src/lib/platform/XWindowsClipboardUTF8Converter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/platform/XWindowsEventQueueBuffer.cpp b/src/lib/platform/XWindowsEventQueueBuffer.cpp index 8b8c3b5..397973f 100644 --- a/src/lib/platform/XWindowsEventQueueBuffer.cpp +++ b/src/lib/platform/XWindowsEventQueueBuffer.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -104,7 +104,7 @@ XWindowsEventQueueBuffer::waitForEvent(double dtimeout) char buf[16]; ssize_t read_response = read(m_pipefd[0], buf, 15); - + // with linux automake, warnings are treated as errors by default if (read_response < 0) { @@ -181,7 +181,7 @@ XWindowsEventQueueBuffer::waitForEvent(double dtimeout) retval = poll(pfds, 2, TIMEOUT_DELAY); //16ms = 60hz, but we make it > to play nicely with the cpu if (pfds[1].revents & POLLIN) { ssize_t read_response = read(m_pipefd[0], buf, 15); - + // with linux automake, warnings are treated as errors by default if (read_response < 0) { diff --git a/src/lib/platform/XWindowsEventQueueBuffer.h b/src/lib/platform/XWindowsEventQueueBuffer.h index 13f6b16..dc35bf0 100644 --- a/src/lib/platform/XWindowsEventQueueBuffer.h +++ b/src/lib/platform/XWindowsEventQueueBuffer.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -23,11 +23,7 @@ #include "common/stdvector.h" #include "XWindowsImpl.h" -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include -#endif +#include class IEventQueue; diff --git a/src/lib/platform/XWindowsKeyState.cpp b/src/lib/platform/XWindowsKeyState.cpp index 9fb71ca..088adc6 100644 --- a/src/lib/platform/XWindowsKeyState.cpp +++ b/src/lib/platform/XWindowsKeyState.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 @@ -24,18 +24,14 @@ #include #include -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include -# include -# define XK_MISCELLANY -# define XK_XKB_KEYS -# include +#include +#include +#define XK_MISCELLANY +#define XK_XKB_KEYS +#include #if HAVE_XKB_EXTENSION # include #endif -#endif static const size_t ModifiersFromXDefaultSize = 32; @@ -348,7 +344,7 @@ XWindowsKeyState::updateKeysymMap(barrier::KeyMap& keyMap) else { tmpKeysyms[maxKeysyms * i + j] = NoSymbol; } - } + } } m_impl->XFree(allKeysyms); allKeysyms = tmpKeysyms; diff --git a/src/lib/platform/XWindowsKeyState.h b/src/lib/platform/XWindowsKeyState.h index f790390..ef35dd4 100644 --- a/src/lib/platform/XWindowsKeyState.h +++ b/src/lib/platform/XWindowsKeyState.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2003 Chris Schoeneman - * + * * 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 @@ -23,18 +23,10 @@ #include "common/stdvector.h" #include "XWindowsImpl.h" -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include -# if HAVE_X11_EXTENSIONS_XTEST_H -# include -# else -# error The XTest extension is required to build barrier -# endif -# if HAVE_XKB_EXTENSION -# include -# endif +#include +#include +#if HAVE_XKB_EXTENSION +# include #endif class IEventQueue; @@ -136,7 +128,7 @@ private: bool m_lock; }; -#ifdef TEST_ENV +#ifdef BARRIER_TEST_ENV public: // yuck #endif typedef std::vector KeyModifierMaskList; @@ -169,7 +161,7 @@ private: // autorepeat state XKeyboardState m_keyboardState; -#ifdef TEST_ENV +#ifdef BARRIER_TEST_ENV public: SInt32 group() const { return m_group; } void group(const SInt32& group) { m_group = group; } diff --git a/src/lib/platform/XWindowsScreen.cpp b/src/lib/platform/XWindowsScreen.cpp index 5f1724c..8fb3569 100644 --- a/src/lib/platform/XWindowsScreen.cpp +++ b/src/lib/platform/XWindowsScreen.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -97,7 +97,7 @@ XWindowsScreen::XWindowsScreen( if (mouseScrollDelta==0) m_mouseScrollDelta=120; s_screen = this; - + if (!disableXInitThreads) { // initializes Xlib support for concurrent threads. if (m_impl->XInitThreads() == 0) @@ -266,14 +266,14 @@ XWindowsScreen::enter() m_impl->DPMSForceLevel(m_display, DPMSModeOn); } #endif - + // unmap the hider/grab window. this also ungrabs the mouse and // keyboard if they're grabbed. m_impl->XUnmapWindow(m_display, m_window); /* maybe call this if entering for the screensaver // set keyboard focus to root window. the screensaver should then - // pick up key events for when the user enters a password to unlock. + // pick up key events for when the user enters a password to unlock. XSetInputFocus(m_display, PointerRoot, PointerRoot, CurrentTime); */ @@ -877,7 +877,7 @@ XWindowsScreen::openDisplay(const char* displayName) { // get the DISPLAY if (displayName == NULL) { - displayName = getenv("DISPLAY"); + displayName = std::getenv("DISPLAY"); if (displayName == NULL) { displayName = ":0.0"; } diff --git a/src/lib/platform/XWindowsScreen.h b/src/lib/platform/XWindowsScreen.h index 5573839..581e91f 100644 --- a/src/lib/platform/XWindowsScreen.h +++ b/src/lib/platform/XWindowsScreen.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -24,11 +24,7 @@ #include "common/stdvector.h" #include "XWindowsImpl.h" -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include -#endif +#include class XWindowsClipboard; class XWindowsKeyState; diff --git a/src/lib/platform/XWindowsScreenSaver.cpp b/src/lib/platform/XWindowsScreenSaver.cpp index 5c4ef91..d8787ab 100644 --- a/src/lib/platform/XWindowsScreenSaver.cpp +++ b/src/lib/platform/XWindowsScreenSaver.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -26,31 +26,11 @@ #include "base/TMethodEventJob.h" #include -#if HAVE_X11_EXTENSIONS_XTEST_H -# include -#else -# error The XTest extension is required to build barrier -#endif +#include #if HAVE_X11_EXTENSIONS_DPMS_H extern "C" { # include # include -# if !HAVE_DPMS_PROTOTYPES -# undef DPMSModeOn -# undef DPMSModeStandby -# undef DPMSModeSuspend -# undef DPMSModeOff -# define DPMSModeOn 0 -# define DPMSModeStandby 1 -# define DPMSModeSuspend 2 -# define DPMSModeOff 3 -extern Bool DPMSQueryExtension(Display *, int *, int *); -extern Bool DPMSCapable(Display *); -extern Status DPMSEnable(Display *); -extern Status DPMSDisable(Display *); -extern Status DPMSForceLevel(Display *, CARD16); -extern Status DPMSInfo(Display *, CARD16 *, BOOL *); -# endif } #endif @@ -490,7 +470,7 @@ XWindowsScreenSaver::addWatchXScreenSaver(Window window) } // if successful and window uses override_redirect (like xscreensaver - // does) then watch it for property changes. + // does) then watch it for property changes. if (!error && attr.override_redirect == True) { error = false; { diff --git a/src/lib/platform/XWindowsScreenSaver.h b/src/lib/platform/XWindowsScreenSaver.h index 1761db2..00285ec 100644 --- a/src/lib/platform/XWindowsScreenSaver.h +++ b/src/lib/platform/XWindowsScreenSaver.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -23,11 +23,7 @@ #include "common/stdmap.h" #include "XWindowsImpl.h" -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include -#endif +#include class Event; class EventQueueTimer; @@ -119,7 +115,7 @@ private: // the X display Display* m_display; - // window to receive xscreensaver repsonses + // window to receive xscreensaver responses Window m_xscreensaverSink; // the target for the events we generate diff --git a/src/lib/platform/XWindowsUtil.cpp b/src/lib/platform/XWindowsUtil.cpp index 3c90bd6..7d4bb63 100644 --- a/src/lib/platform/XWindowsUtil.cpp +++ b/src/lib/platform/XWindowsUtil.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -1250,7 +1250,7 @@ XK_uhorn // map "Internet" keys to KeyIDs static const KeySym s_map1008FF[] = { - /* 0x00 */ 0, 0, kKeyBrightnessUp, kKeyBrightnessDown, 0, 0, 0, 0, + /* 0x00 */ 0, 0, kKeyBrightnessUp, kKeyBrightnessDown, 0, kKeyKbdBrightnessUp, kKeyKbdBrightnessDown, 0, /* 0x08 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */ 0, kKeyAudioDown, kKeyAudioMute, kKeyAudioUp, /* 0x14 */ kKeyAudioPlay, kKeyAudioStop, kKeyAudioPrev, kKeyAudioNext, @@ -1285,6 +1285,45 @@ static const KeySym s_map1008FF[] = /* 0xf8 */ 0, 0, 0, 0, 0, 0, 0, 0 }; +// map Sun keyboard keys to KeyIDs +// This is based on the the "Internet" keymap plus the missing keys +// Copy/Cut/Open/Paste/Props/Front +static const KeySym s_map1009FF[] = +{ + /* 0x00 */ 0, 0, kKeyBrightnessUp, kKeyBrightnessDown, 0, 0, 0, 0, + /* 0x08 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0x10 */ 0, kKeyAudioDown, kKeyAudioMute, kKeyAudioUp, + /* 0x14 */ kKeyAudioPlay, kKeyAudioStop, kKeyAudioPrev, kKeyAudioNext, + /* 0x18 */ kKeyWWWHome, kKeyAppMail, 0, kKeyWWWSearch, 0, 0, 0, 0, + /* 0x20 */ 0, 0, 0, 0, 0, 0, kKeyWWWBack, kKeyWWWForward, + /* 0x28 */ kKeyWWWStop, kKeyWWWRefresh, 0, 0, kKeyEject, 0, 0, 0, + /* 0x30 */ kKeyWWWFavorites, 0, kKeyAppMedia, 0, 0, 0, 0, 0, + /* 0x38 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0x40 */ kKeyAppUser1, kKeyAppUser2, 0, 0, 0, 0, 0, 0, + /* 0x48 */ 0, 0, kKeyMissionControl, kKeyLaunchpad, 0, 0, 0, 0, + /* 0x50 */ 0, 0, 0, 0, 0, 0, 0, kKeyCopy, + /* 0x58 */ kKeyCut, 0, 0, 0, 0, 0, 0, 0, + /* 0x60 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0x68 */ 0, 0, 0, kKeyOpen, 0, kKeyPaste, 0, 0, + /* 0x70 */ kKeyProps, kKeyFront, 0, 0, 0, 0, 0, 0, + /* 0x78 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0x80 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0x88 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0x90 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0x98 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xa0 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xa8 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xb0 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xb8 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xc0 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xc8 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xd0 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xd8 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xe0 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xe8 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xf0 */ 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xf8 */ 0, 0, 0, 0, 0, 0, 0, 0 +}; // // XWindowsUtil @@ -1546,6 +1585,10 @@ XWindowsUtil::mapKeySymToKeyID(KeySym k) // "Internet" keys return s_map1008FF[k & 0xff]; + case 0x1009ff00: + // Additional Left-side keys provided by Sun Microsystems USB keyboards + return s_map1009FF[k & 0xff]; + default: { // lookup character in table KeySymMap::const_iterator index = s_keySymToUCS4.find(k); diff --git a/src/lib/platform/XWindowsUtil.h b/src/lib/platform/XWindowsUtil.h index f5b3ea8..938c332 100644 --- a/src/lib/platform/XWindowsUtil.h +++ b/src/lib/platform/XWindowsUtil.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -22,11 +22,7 @@ #include "common/stdmap.h" #include "common/stdvector.h" -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include -#endif +#include #include @@ -123,7 +119,7 @@ public: This class sets an X error handler in the c'tor and restores the previous error handler in the d'tor. A lock should only be installed while the display is locked by the thread. - + ErrorLock() ignores errors ErrorLock(bool* flag) sets *flag to true if any error occurs */ diff --git a/src/lib/platform/synwinhk.h b/src/lib/platform/synwinhk.h index 4b2d8e3..8fc4290 100644 --- a/src/lib/platform/synwinhk.h +++ b/src/lib/platform/synwinhk.h @@ -3,11 +3,11 @@ * Copyright (C) 2018 Debauchee Open Source Group * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/BaseClientProxy.cpp b/src/lib/server/BaseClientProxy.cpp index 6ccd251..78c4220 100644 --- a/src/lib/server/BaseClientProxy.cpp +++ b/src/lib/server/BaseClientProxy.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2006 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/BaseClientProxy.h b/src/lib/server/BaseClientProxy.h index a2c9459..5d5dc06 100644 --- a/src/lib/server/BaseClientProxy.h +++ b/src/lib/server/BaseClientProxy.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/CMakeLists.txt b/src/lib/server/CMakeLists.txt index 5242d6d..e1ed692 100644 --- a/src/lib/server/CMakeLists.txt +++ b/src/lib/server/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 diff --git a/src/lib/server/ClientListener.cpp b/src/lib/server/ClientListener.cpp index 00067ba..75724bc 100644 --- a/src/lib/server/ClientListener.cpp +++ b/src/lib/server/ClientListener.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -36,25 +36,24 @@ ClientListener::ClientListener(const NetworkAddress& address, ISocketFactory* socketFactory, IEventQueue* events, - bool enableCrypto) : + ConnectionSecurityLevel security_level) : m_socketFactory(socketFactory), m_server(NULL), m_events(events), - m_useSecureNetwork(enableCrypto) + security_level_{security_level} { assert(m_socketFactory != NULL); try { - m_listen = m_socketFactory->createListen( - ARCH->getAddrFamily(address.getAddress()), - m_useSecureNetwork); + m_listen = m_socketFactory->createListen(ARCH->getAddrFamily(address.getAddress()), + security_level); // setup event handler m_events->adoptHandler(m_events->forIListenSocket().connecting(), m_listen, new TMethodEventJob(this, &ClientListener::handleClientConnecting)); - + // bind listen address LOG((CLOG_DEBUG1 "binding listen socket")); m_listen->bind(address); @@ -130,17 +129,17 @@ ClientListener::handleClientConnecting(const Event&, void*) if (socket == NULL) { return; } - + m_clientSockets.insert(socket); m_events->adoptHandler(m_events->forClientListener().accepted(), socket->getEventTarget(), new TMethodEventJob(this, &ClientListener::handleClientAccepted, socket)); - + // When using non SSL, server accepts clients immediately, while SSL // has to call secure accept which may require retry - if (!m_useSecureNetwork) { + if (security_level_ == ConnectionSecurityLevel::PLAINTEXT) { m_events->addEvent(Event(m_events->forClientListener().accepted(), socket->getEventTarget())); } @@ -152,7 +151,7 @@ ClientListener::handleClientAccepted(const Event&, void* vsocket) LOG((CLOG_NOTE "accepted client connection")); IDataSocket* socket = static_cast(vsocket); - + // filter socket messages, including a packetizing filter barrier::IStream* stream = new PacketStreamFilter(m_events, socket, false); assert(m_server != NULL); @@ -184,7 +183,6 @@ ClientListener::handleUnknownClient(const Event&, void* vclient) // get the real client proxy and install it ClientProxy* client = unknownClient->orphanClientProxy(); - bool handshakeOk = true; if (client != NULL) { // handshake was successful m_waitingClients.push_back(client); @@ -196,20 +194,17 @@ ClientListener::handleUnknownClient(const Event&, void* vclient) new TMethodEventJob(this, &ClientListener::handleClientDisconnected, client)); - } - else { - handshakeOk = false; + } else { + auto* stream = unknownClient->getStream(); + if (stream) { + stream->close(); + } } // now finished with unknown client m_events->removeHandler(m_events->forClientProxyUnknown().success(), client); m_events->removeHandler(m_events->forClientProxyUnknown().failure(), client); m_newClients.erase(unknownClient); - PacketStreamFilter* streamFileter = dynamic_cast(unknownClient->getStream()); - IDataSocket* socket = NULL; - if (streamFileter != NULL) { - socket = dynamic_cast(streamFileter->getStream()); - } delete unknownClient; } diff --git a/src/lib/server/ClientListener.h b/src/lib/server/ClientListener.h index b02cbb1..1debc2b 100644 --- a/src/lib/server/ClientListener.h +++ b/src/lib/server/ClientListener.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -23,6 +23,7 @@ #include "base/Event.h" #include "common/stddeque.h" #include "common/stdset.h" +#include "net/ConnectionSecurityLevel.h" class ClientProxy; class ClientProxyUnknown; @@ -36,10 +37,8 @@ class IDataSocket; class ClientListener { public: // The factories are adopted. - ClientListener(const NetworkAddress&, - ISocketFactory*, - IEventQueue* events, - bool enableCrypto); + ClientListener(const NetworkAddress&, ISocketFactory*, IEventQueue* events, + ConnectionSecurityLevel security_level); ~ClientListener(); //! @name manipulators @@ -86,6 +85,6 @@ private: WaitingClients m_waitingClients; Server* m_server; IEventQueue* m_events; - bool m_useSecureNetwork; + ConnectionSecurityLevel security_level_; ClientSockets m_clientSockets; }; diff --git a/src/lib/server/ClientProxy.cpp b/src/lib/server/ClientProxy.cpp index d91e186..76cdfa6 100644 --- a/src/lib/server/ClientProxy.cpp +++ b/src/lib/server/ClientProxy.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/ClientProxy.h b/src/lib/server/ClientProxy.h index a3d87cb..b641011 100644 --- a/src/lib/server/ClientProxy.h +++ b/src/lib/server/ClientProxy.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/ClientProxy1_0.cpp b/src/lib/server/ClientProxy1_0.cpp index 5cbaac2..33b0f15 100644 --- a/src/lib/server/ClientProxy1_0.cpp +++ b/src/lib/server/ClientProxy1_0.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -51,6 +51,10 @@ ClientProxy1_0::ClientProxy1_0(const std::string& name, barrier::IStream* stream stream->getEventTarget(), new TMethodEventJob(this, &ClientProxy1_0::handleDisconnect, NULL)); + m_events->adoptHandler(m_events->forIStream().inputFormatError(), + stream->getEventTarget(), + new TMethodEventJob(this, + &ClientProxy1_0::handleDisconnect, NULL)); m_events->adoptHandler(m_events->forIStream().outputShutdown(), stream->getEventTarget(), new TMethodEventJob(this, @@ -90,6 +94,8 @@ ClientProxy1_0::removeHandlers() getStream()->getEventTarget()); m_events->removeHandler(m_events->forIStream().outputShutdown(), getStream()->getEventTarget()); + m_events->removeHandler(m_events->forIStream().inputFormatError(), + getStream()->getEventTarget()); m_events->removeHandler(Event::kTimer, this); // remove timer @@ -148,9 +154,18 @@ ClientProxy1_0::handleData(const Event&, void*) } // parse message - LOG((CLOG_DEBUG2 "msg from \"%s\": %c%c%c%c", getName().c_str(), code[0], code[1], code[2], code[3])); - if (!(this->*m_parser)(code)) { - LOG((CLOG_ERR "invalid message from client \"%s\": %c%c%c%c", getName().c_str(), code[0], code[1], code[2], code[3])); + try { + LOG((CLOG_DEBUG2 "msg from \"%s\": %c%c%c%c", getName().c_str(), code[0], code[1], code[2], code[3])); + if (!(this->*m_parser)(code)) { + LOG((CLOG_ERR "invalid message from client \"%s\": %c%c%c%c", getName().c_str(), code[0], code[1], code[2], code[3])); + disconnect(); + return; + } + } catch (const XBadClient& e) { + // TODO: disconnect handling is currently dispersed across both parseMessage() and + // handleData() functions, we should collect that to a single place + + LOG((CLOG_ERR "protocol error from client: %s", e.what())); disconnect(); return; } @@ -173,6 +188,8 @@ ClientProxy1_0::parseHandshakeMessage(const UInt8* code) } else if (memcmp(code, kMsgDInfo, 4) == 0) { // future messages get parsed by parseMessage + // NOTE: we're taking address of virtual function here, + // not ClientProxy1_0 implementation of it. m_parser = &ClientProxy1_0::parseMessage; if (recvInfo()) { m_events->addEvent(Event(m_events->forClientProxy().ready(), getEventTarget())); diff --git a/src/lib/server/ClientProxy1_0.h b/src/lib/server/ClientProxy1_0.h index 98c68f3..45d7541 100644 --- a/src/lib/server/ClientProxy1_0.h +++ b/src/lib/server/ClientProxy1_0.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/ClientProxy1_1.cpp b/src/lib/server/ClientProxy1_1.cpp index bb33ac1..6d2e007 100644 --- a/src/lib/server/ClientProxy1_1.cpp +++ b/src/lib/server/ClientProxy1_1.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/ClientProxy1_1.h b/src/lib/server/ClientProxy1_1.h index ada4dcc..38fda52 100644 --- a/src/lib/server/ClientProxy1_1.h +++ b/src/lib/server/ClientProxy1_1.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/ClientProxy1_2.cpp b/src/lib/server/ClientProxy1_2.cpp index e9527ef..5457dc0 100644 --- a/src/lib/server/ClientProxy1_2.cpp +++ b/src/lib/server/ClientProxy1_2.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/ClientProxy1_2.h b/src/lib/server/ClientProxy1_2.h index 12d6b92..08b32fb 100644 --- a/src/lib/server/ClientProxy1_2.h +++ b/src/lib/server/ClientProxy1_2.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/ClientProxy1_3.cpp b/src/lib/server/ClientProxy1_3.cpp index d0031ce..5012a4e 100644 --- a/src/lib/server/ClientProxy1_3.cpp +++ b/src/lib/server/ClientProxy1_3.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2006 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/ClientProxy1_3.h b/src/lib/server/ClientProxy1_3.h index ad46cea..a459e1e 100644 --- a/src/lib/server/ClientProxy1_3.h +++ b/src/lib/server/ClientProxy1_3.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2006 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/ClientProxy1_4.cpp b/src/lib/server/ClientProxy1_4.cpp index 9b12976..bc58626 100644 --- a/src/lib/server/ClientProxy1_4.cpp +++ b/src/lib/server/ClientProxy1_4.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/ClientProxy1_4.h b/src/lib/server/ClientProxy1_4.h index cda090b..fa88234 100644 --- a/src/lib/server/ClientProxy1_4.h +++ b/src/lib/server/ClientProxy1_4.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/ClientProxy1_5.cpp b/src/lib/server/ClientProxy1_5.cpp index 40bba08..72c0bf8 100644 --- a/src/lib/server/ClientProxy1_5.cpp +++ b/src/lib/server/ClientProxy1_5.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2013-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 @@ -86,7 +86,7 @@ ClientProxy1_5::fileChunkReceived() getStream(), server->getReceivedFileData(), server->getExpectedFileSize()); - + if (result == kFinish) { m_events->addEvent(Event(m_events->forFile().fileRecieveCompleted(), server)); @@ -106,6 +106,6 @@ ClientProxy1_5::dragInfoReceived() UInt32 fileNum = 0; std::string content; ProtocolUtil::readf(getStream(), kMsgDDragInfo + 4, &fileNum, &content); - + m_server->dragInfoReceived(fileNum, content); } diff --git a/src/lib/server/ClientProxy1_5.h b/src/lib/server/ClientProxy1_5.h index 4087730..2051f3c 100644 --- a/src/lib/server/ClientProxy1_5.h +++ b/src/lib/server/ClientProxy1_5.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2013-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 diff --git a/src/lib/server/ClientProxy1_6.cpp b/src/lib/server/ClientProxy1_6.cpp index c829e84..29f3ce4 100644 --- a/src/lib/server/ClientProxy1_6.cpp +++ b/src/lib/server/ClientProxy1_6.cpp @@ -1,11 +1,11 @@ /* * barrier -- 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 @@ -88,7 +88,7 @@ ClientProxy1_6::recvClipboard() // save clipboard m_clipboard[id].m_clipboard.unmarshall(dataCached, 0); m_clipboard[id].m_sequenceNumber = seq; - + // notify ClipboardInfo* info = new ClipboardInfo; info->m_id = id; diff --git a/src/lib/server/ClientProxy1_6.h b/src/lib/server/ClientProxy1_6.h index 830696a..a4c2e5d 100644 --- a/src/lib/server/ClientProxy1_6.h +++ b/src/lib/server/ClientProxy1_6.h @@ -1,11 +1,11 @@ /* * barrier -- 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 diff --git a/src/lib/server/ClientProxyUnknown.cpp b/src/lib/server/ClientProxyUnknown.cpp index dc79da7..f9da361 100644 --- a/src/lib/server/ClientProxyUnknown.cpp +++ b/src/lib/server/ClientProxyUnknown.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 @@ -118,6 +118,10 @@ ClientProxyUnknown::addStreamHandlers() m_stream->getEventTarget(), new TMethodEventJob(this, &ClientProxyUnknown::handleDisconnect)); + m_events->adoptHandler(m_events->forIStream().inputFormatError(), + m_stream->getEventTarget(), + new TMethodEventJob(this, + &ClientProxyUnknown::handleDisconnect)); m_events->adoptHandler(m_events->forIStream().outputShutdown(), m_stream->getEventTarget(), new TMethodEventJob(this, @@ -149,6 +153,8 @@ ClientProxyUnknown::removeHandlers() m_stream->getEventTarget()); m_events->removeHandler(m_events->forIStream().inputShutdown(), m_stream->getEventTarget()); + m_events->removeHandler(m_events->forIStream().inputFormatError(), + m_stream->getEventTarget()); m_events->removeHandler(m_events->forIStream().outputShutdown(), m_stream->getEventTarget()); } diff --git a/src/lib/server/ClientProxyUnknown.h b/src/lib/server/ClientProxyUnknown.h index 5d59402..efb1b2b 100644 --- a/src/lib/server/ClientProxyUnknown.h +++ b/src/lib/server/ClientProxyUnknown.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2004 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/Config.cpp b/src/lib/server/Config.cpp index a47a391..bcdb88c 100644 --- a/src/lib/server/Config.cpp +++ b/src/lib/server/Config.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -1748,10 +1748,10 @@ std::ostream& operator<<(std::ostream& s, const Config& config) { // screens section - s << "section: screens" << std::endl; + s << "section: screens\n"; for (Config::const_iterator screen = config.begin(); screen != config.end(); ++screen) { - s << "\t" << screen->c_str() << ":" << std::endl; + s << "\t" << screen->c_str() << ":\n"; const Config::ScreenOptions* options = config.getOptions(*screen); if (options != NULL && options->size() > 0) { for (Config::ScreenOptions::const_iterator @@ -1760,31 +1760,31 @@ operator<<(std::ostream& s, const Config& config) const char* name = Config::getOptionName(option->first); std::string value = Config::getOptionValue(option->first, option->second); if (name != NULL && !value.empty()) { - s << "\t\t" << name << " = " << value << std::endl; + s << "\t\t" << name << " = " << value << "\n"; } } } } - s << "end" << std::endl; + s << "end\n"; // links section std::string neighbor; - s << "section: links" << std::endl; + s << "section: links\n"; for (Config::const_iterator screen = config.begin(); screen != config.end(); ++screen) { - s << "\t" << screen->c_str() << ":" << std::endl; + s << "\t" << screen->c_str() << ":\n"; for (Config::link_const_iterator link = config.beginNeighbor(*screen), - nend = config.endNeighbor(*screen); link != nend; ++link) { + nend = config.endNeighbor(*screen); link != nend; ++link) { s << "\t\t" << Config::dirName(link->first.getSide()) << Config::formatInterval(link->first.getInterval()) << " = " << link->second.getName().c_str() << Config::formatInterval(link->second.getInterval()) << - std::endl; + "\n"; } } - s << "end" << std::endl; + s << "end\n"; // aliases section (if there are any) if (config.m_map.size() != config.m_nameToCanonicalName.size()) { @@ -1802,20 +1802,20 @@ operator<<(std::ostream& s, const Config& config) // dump it std::string screen; - s << "section: aliases" << std::endl; + s << "section: aliases\n"; for (CMNameMap::const_iterator index = aliases.begin(); index != aliases.end(); ++index) { if (index->first != screen) { screen = index->first; - s << "\t" << screen.c_str() << ":" << std::endl; + s << "\t" << screen.c_str() << ":\n"; } - s << "\t\t" << index->second.c_str() << std::endl; + s << "\t\t" << index->second.c_str() << "\n"; } - s << "end" << std::endl; + s << "end\n"; } // options section - s << "section: options" << std::endl; + s << "section: options\n"; const Config::ScreenOptions* options = config.getOptions(""); if (options != NULL && options->size() > 0) { for (Config::ScreenOptions::const_iterator @@ -1824,16 +1824,16 @@ operator<<(std::ostream& s, const Config& config) const char* name = Config::getOptionName(option->first); std::string value = Config::getOptionValue(option->first, option->second); if (name != NULL && !value.empty()) { - s << "\t" << name << " = " << value << std::endl; + s << "\t" << name << " = " << value << "\n"; } } } if (config.m_barrierAddress.isValid()) { s << "\taddress = " << - config.m_barrierAddress.getHostname().c_str() << std::endl; + config.m_barrierAddress.getHostname().c_str() << "\n"; } s << config.m_inputFilter.format("\t"); - s << "end" << std::endl; + s << "end\n"; return s; } diff --git a/src/lib/server/Config.h b/src/lib/server/Config.h index c459393..17756a0 100644 --- a/src/lib/server/Config.h +++ b/src/lib/server/Config.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -174,7 +174,7 @@ public: Config(IEventQueue* events); virtual ~Config(); -#ifdef TEST_ENV +#ifdef BARRIER_TEST_ENV Config() : m_inputFilter(NULL) { } #endif diff --git a/src/lib/server/InputFilter.cpp b/src/lib/server/InputFilter.cpp index 38d9a84..a0dce17 100644 --- a/src/lib/server/InputFilter.cpp +++ b/src/lib/server/InputFilter.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2005 Chris Schoeneman - * + * * 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 @@ -191,7 +191,7 @@ std::string InputFilter::MouseButtonCondition::format() const return barrier::string::sprintf("mousebutton(%s%d)", key.c_str(), m_button); } -InputFilter::EFilterStatus +InputFilter::EFilterStatus InputFilter::MouseButtonCondition::match(const Event& event) { static const KeyModifierMask s_ignoreMask = @@ -252,7 +252,7 @@ InputFilter::EFilterStatus InputFilter::ScreenConnectedCondition::match(const Event& event) { if (event.getType() == m_events->forServer().connected()) { - Server::ScreenConnectedInfo* info = + Server::ScreenConnectedInfo* info = static_cast(event.getData()); if (m_screen == info->m_screen || m_screen.empty()) { return kActivate; @@ -312,7 +312,7 @@ InputFilter::LockCursorToScreenAction::perform(const Event& event) }; // send event - Server::LockCursorToScreenInfo* info = + Server::LockCursorToScreenInfo* info = Server::LockCursorToScreenInfo::alloc(s_state[m_mode]); m_events->addEvent(Event(m_events->forServer().lockCursorToScreen(), event.getTarget(), info, @@ -350,7 +350,7 @@ InputFilter::SwitchToScreenAction::perform(const Event& event) // event if it has one. std::string screen = m_screen; if (screen.empty() && event.getType() == m_events->forServer().connected()) { - Server::ScreenConnectedInfo* info = + Server::ScreenConnectedInfo* info = static_cast(event.getData()); screen = info->m_screen; } @@ -493,7 +493,7 @@ InputFilter::KeyboardBroadcastAction::perform(const Event& event) }; // send event - Server::KeyboardBroadcastInfo* info = + Server::KeyboardBroadcastInfo* info = Server::KeyboardBroadcastInfo::alloc(s_state[m_mode], m_screens); m_events->addEvent(Event(m_events->forServer().keyboardBroadcast(), event.getTarget(), info, @@ -569,7 +569,7 @@ InputFilter::KeystrokeAction::perform(const Event& event) Event::Type type = m_press ? m_events->forIKeyState().keyDown() : m_events->forIKeyState().keyUp(); - + m_events->addEvent(Event(m_events->forIPrimaryScreen().fakeInputBegin(), event.getTarget(), NULL, Event::kDeliverImmediately)); diff --git a/src/lib/server/InputFilter.h b/src/lib/server/InputFilter.h index 0cb99da..5e6ef9c 100644 --- a/src/lib/server/InputFilter.h +++ b/src/lib/server/InputFilter.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2005 Chris Schoeneman - * + * * 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 @@ -53,7 +53,7 @@ public: virtual void enablePrimary(PrimaryClient*); virtual void disablePrimary(PrimaryClient*); }; - + // KeystrokeCondition class KeystrokeCondition : public Condition { public: @@ -118,7 +118,7 @@ public: // ------------------------------------------------------------------------- // Input Filter Action Classes // ------------------------------------------------------------------------- - + class Action { public: Action(); @@ -129,7 +129,7 @@ public: virtual void perform(const Event&) = 0; }; - + // LockCursorToScreenAction class LockCursorToScreenAction : public Action { public: @@ -148,7 +148,7 @@ public: Mode m_mode; IEventQueue* m_events; }; - + // SwitchToScreenAction class SwitchToScreenAction : public Action { public: @@ -165,7 +165,7 @@ public: std::string m_screen; IEventQueue* m_events; }; - + // ToggleScreenAction class ToggleScreenAction : public Action { public: @@ -196,7 +196,7 @@ public: EDirection m_direction; IEventQueue* m_events; }; - + // KeyboardBroadcastAction class KeyboardBroadcastAction : public Action { public: @@ -333,7 +333,7 @@ public: InputFilter(const InputFilter&); virtual ~InputFilter(); -#ifdef TEST_ENV +#ifdef BARRIER_TEST_ENV InputFilter() : m_primaryClient(NULL) { } #endif diff --git a/src/lib/server/PrimaryClient.cpp b/src/lib/server/PrimaryClient.cpp index 04ae86c..6583e5d 100644 --- a/src/lib/server/PrimaryClient.cpp +++ b/src/lib/server/PrimaryClient.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 diff --git a/src/lib/server/PrimaryClient.h b/src/lib/server/PrimaryClient.h index 68b91e3..13be838 100644 --- a/src/lib/server/PrimaryClient.h +++ b/src/lib/server/PrimaryClient.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -37,7 +37,7 @@ public: PrimaryClient(const std::string& name, barrier::Screen* screen); ~PrimaryClient(); -#ifdef TEST_ENV +#ifdef BARRIER_TEST_ENV PrimaryClient() : BaseClientProxy("") { } #endif @@ -96,12 +96,12 @@ public: the edges of the screen, typically the center. */ void getCursorCenter(SInt32& x, SInt32& y) const; - + //! Get toggle key state /*! Returns the primary screen's current toggle modifier key state. */ - virtual KeyModifierMask + virtual KeyModifierMask getToggleMask() const; //! Get screen lock state diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 334049c..a169db1 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -39,7 +39,6 @@ #include "net/XSocket.h" #include "mt/Thread.h" #include "arch/Arch.h" -#include "base/TMethodJob.h" #include "base/IEventQueue.h" #include "base/Log.h" #include "base/TMethodEventJob.h" @@ -1136,9 +1135,9 @@ Server::processOptions() return; } - m_switchNeedsShift = false; // it seems if i don't add these + m_switchNeedsShift = false; // it seems if I don't add these m_switchNeedsControl = false; // lines, the 'reload config' option - m_switchNeedsAlt = false; // doesnt' work correct. + m_switchNeedsAlt = false; // doesn't work correct. bool newRelativeMoves = m_relativeMoves; for (Config::ScreenOptions::const_iterator index = options->begin(); @@ -1824,10 +1823,8 @@ Server::onMouseMovePrimary(SInt32 x, SInt32 y) && m_active != newScreen && m_waitDragInfoThread) { if (m_sendDragInfoThread == NULL) { - m_sendDragInfoThread = new Thread( - new TMethodJob( - this, - &Server::sendDragInfoThread, newScreen)); + m_sendDragInfoThread = new Thread([this, newScreen]() + { send_drag_info_thread(newScreen); }); } return false; @@ -1843,11 +1840,8 @@ Server::onMouseMovePrimary(SInt32 x, SInt32 y) return false; } -void -Server::sendDragInfoThread(void* arg) +void Server::send_drag_info_thread(BaseClientProxy* newScreen) { - BaseClientProxy* newScreen = static_cast(arg); - m_dragFileList.clear(); std::string& dragFileList = m_screen->getDraggingFilename(); if (!dragFileList.empty()) { @@ -2087,14 +2081,11 @@ void Server::onFileRecieveCompleted() { if (isReceivedFileSizeValid()) { - m_writeToDropDirThread = new Thread( - new TMethodJob( - this, &Server::writeToDropDirThread)); + m_writeToDropDirThread = new Thread([this]() { write_to_drop_dir_thread(); }); } } -void -Server::writeToDropDirThread(void*) +void Server::write_to_drop_dir_thread() { LOG((CLOG_DEBUG "starting write to drop dir thread")); @@ -2394,17 +2385,12 @@ Server::sendFileToClient(const char* filename) StreamChunker::interruptFile(); } - m_sendFileThread = new Thread( - new TMethodJob( - this, &Server::sendFileThread, - static_cast(const_cast(filename)))); + m_sendFileThread = new Thread([this, filename]() { send_file_thread(filename); }); } -void -Server::sendFileThread(void* data) +void Server::send_file_thread(const char* filename) { try { - 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/server/Server.h b/src/lib/server/Server.h index bfd0a7d..ae8b2bd 100644 --- a/src/lib/server/Server.h +++ b/src/lib/server/Server.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * 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 @@ -110,7 +110,7 @@ public: barrier::Screen* screen, IEventQueue* events, ServerArgs const& args); ~Server(); -#ifdef TEST_ENV +#ifdef BARRIER_TEST_ENV Server() : m_mock(true), m_config(NULL) { } void setActive(BaseClientProxy* active) { m_active = active; } #endif @@ -150,7 +150,7 @@ public: //! Store ClientListener pointer void setListener(ClientListener* p) { m_clientListener = p; } - + //@} //! @name accessors //@{ @@ -166,8 +166,8 @@ public: Set the \c list to the names of the currently connected clients. */ void getClients(std::vector& list) const; - - //! Return true if recieved file size is valid + + //! Return true if received file size is valid bool isReceivedFileSizeValid(); //! Return expected file data size @@ -356,15 +356,15 @@ private: // force the cursor off of \p client void forceLeaveClient(BaseClientProxy* client); - - // thread funciton for sending file - void sendFileThread(void*); - + + // thread function for sending file + void send_file_thread(const char* filename); + // thread function for writing file to drop directory - void writeToDropDirThread(void*); + void write_to_drop_dir_thread(); // thread function for sending drag information - void sendDragInfoThread(void*); + void send_drag_info_thread(BaseClientProxy* newScreen); // send drag info to new client screen void sendDragInfo(BaseClientProxy* newScreen); @@ -448,7 +448,7 @@ private: bool m_switchNeedsShift; bool m_switchNeedsControl; bool m_switchNeedsAlt; - + // relative mouse move option bool m_relativeMoves; diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt deleted file mode 100644 index daecb31..0000000 --- a/src/test/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -# barrier -- mouse and keyboard sharing utility -# Copyright (C) 2012-2016 Symless Ltd. -# Copyright (C) 2011 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_directories( - ../../ext/gtest - ../../ext/gtest/include - ../../ext/gmock - ../../ext/gmock/include) - -add_library(gtest STATIC ../../ext/gtest/src/gtest-all.cc) -add_library(gmock STATIC ../../ext/gmock/src/gmock-all.cc) - -if (UNIX) - # ignore warnings in gtest and gmock - set_target_properties(gtest PROPERTIES COMPILE_FLAGS "-w") - set_target_properties(gmock PROPERTIES COMPILE_FLAGS "-w") -endif() - -add_subdirectory(integtests) -add_subdirectory(unittests) diff --git a/src/test/global/TestEventQueue.cpp b/src/test/global/TestEventQueue.cpp index 4dd01e7..253e9ab 100644 --- a/src/test/global/TestEventQueue.cpp +++ b/src/test/global/TestEventQueue.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2013-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 @@ -23,7 +23,7 @@ #include void -TestEventQueue::raiseQuitEvent() +TestEventQueue::raiseQuitEvent() { addEvent(Event(Event::kQuit)); } diff --git a/src/test/global/TestEventQueue.h b/src/test/global/TestEventQueue.h index b932508..14568b6 100644 --- a/src/test/global/TestEventQueue.h +++ b/src/test/global/TestEventQueue.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2013-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 diff --git a/src/test/global/TestUtils.cpp b/src/test/global/TestUtils.cpp new file mode 100644 index 0000000..6a3193b --- /dev/null +++ b/src/test/global/TestUtils.cpp @@ -0,0 +1,37 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 "TestUtils.h" +#include + +namespace barrier { + +std::vector generate_pseudo_random_bytes(std::size_t seed, std::size_t size) +{ + std::mt19937_64 engine{seed}; + std::uniform_int_distribution dist{0, 255}; + std::vector bytes; + + bytes.reserve(size); + for (std::size_t i = 0; i < size; ++i) { + bytes.push_back(dist(engine)); + } + + return bytes; +} + +} // namespace barrier diff --git a/src/test/global/TestUtils.h b/src/test/global/TestUtils.h new file mode 100644 index 0000000..31050ec --- /dev/null +++ b/src/test/global/TestUtils.h @@ -0,0 +1,30 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 BARRIER_TEST_GLOBAL_TEST_UTILS_H +#define BARRIER_TEST_GLOBAL_TEST_UTILS_H + +#include +#include + +namespace barrier { + +std::vector generate_pseudo_random_bytes(std::size_t seed, std::size_t size); + +} // namespace barrier + +#endif // BARRIER_TEST_GLOBAL_TEST_UTILS_H diff --git a/src/test/global/gmock.h b/src/test/global/gmock.h index 64597f4..8a27440 100644 --- a/src/test/global/gmock.h +++ b/src/test/global/gmock.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-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 diff --git a/src/test/global/gtest.h b/src/test/global/gtest.h index 0b2acbc..55cb10f 100644 --- a/src/test/global/gtest.h +++ b/src/test/global/gtest.h @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-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 diff --git a/src/test/guitests/src/VersionCheckerTests.cpp b/src/test/guitests/src/VersionCheckerTests.cpp index 0efc5f9..82212a7 100644 --- a/src/test/guitests/src/VersionCheckerTests.cpp +++ b/src/test/guitests/src/VersionCheckerTests.cpp @@ -2,11 +2,11 @@ * barrier -- 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 diff --git a/src/test/guitests/src/VersionCheckerTests.h b/src/test/guitests/src/VersionCheckerTests.h index 7884f3a..4273701 100644 --- a/src/test/guitests/src/VersionCheckerTests.h +++ b/src/test/guitests/src/VersionCheckerTests.h @@ -2,11 +2,11 @@ * barrier -- 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 diff --git a/src/test/guitests/src/main.cpp b/src/test/guitests/src/main.cpp index 2ff6e72..6b7677e 100644 --- a/src/test/guitests/src/main.cpp +++ b/src/test/guitests/src/main.cpp @@ -2,11 +2,11 @@ * barrier -- 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 diff --git a/src/test/integtests/CMakeLists.txt b/src/test/integtests/CMakeLists.txt index 0460d8d..cdb8844 100644 --- a/src/test/integtests/CMakeLists.txt +++ b/src/test/integtests/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 @@ -68,8 +68,6 @@ endif() include_directories( ../../ - ../../../ext/gtest/include - ../../../ext/gmock/include ) if (UNIX) @@ -80,4 +78,4 @@ endif() add_executable(integtests ${sources}) target_link_libraries(integtests - arch base client common io ipc mt net platform server synlib gtest gmock ${libs} ${OPENSSL_LIBS}) + arch base client common io ipc mt net platform server synlib ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} ${libs} ${OPENSSL_LIBS}) diff --git a/src/test/integtests/Main.cpp b/src/test/integtests/Main.cpp index 76b42b6..f4eaca7 100644 --- a/src/test/integtests/Main.cpp +++ b/src/test/integtests/Main.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 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 @@ -44,7 +44,7 @@ main(int argc, char **argv) Arch arch; arch.init(); - + Log log; log.setFilter(kDEBUG2); @@ -67,7 +67,7 @@ main(int argc, char **argv) if (!lockFile.empty()) { unlock(lockFile); } - + // gtest seems to randomly finish with error codes (e.g. -1, -1073741819) // even when no tests have failed. not sure what causes this, but it // happens on all platforms and keeps leading to false positives. @@ -80,7 +80,7 @@ void lock(string lockFile) { double start = ARCH->time(); - + // keep checking until timeout is reached. while ((ARCH->time() - start) < LOCK_TIMEOUT) { @@ -102,7 +102,7 @@ lock(string lockFile) } void -unlock(string lockFile) +unlock(string lockFile) { remove(lockFile.c_str()); } diff --git a/src/test/integtests/ipc/IpcTests.cpp b/src/test/integtests/ipc/IpcTests.cpp index a0ee241..ce15d59 100644 --- a/src/test/integtests/ipc/IpcTests.cpp +++ b/src/test/integtests/ipc/IpcTests.cpp @@ -2,11 +2,11 @@ * barrier -- 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 @@ -19,7 +19,7 @@ // TODO: fix, tests failing intermittently on mac. #ifndef WINAPI_CARBON -#define TEST_ENV +#define BARRIER_TEST_ENV #include "test/global/TestEventQueue.h" #include "ipc/IpcServer.h" @@ -31,7 +31,6 @@ #include "net/SocketMultiplexer.h" #include "mt/Thread.h" #include "arch/Arch.h" -#include "base/TMethodJob.h" #include "base/String.h" #include "base/Log.h" #include "base/EventQueue.h" @@ -46,7 +45,7 @@ class IpcTests : public ::testing::Test public: IpcTests(); virtual ~IpcTests(); - + void connectToServer_handleMessageReceived(const Event&, void*); void sendMessageToServer_serverHandleMessageReceived(const Event&, void*); void sendMessageToClient_serverHandleClientConnected(const Event&, void*); @@ -76,15 +75,15 @@ TEST_F(IpcTests, connectToServer) m_events.forIpcServer().messageReceived(), &server, new TMethodEventJob( this, &IpcTests::connectToServer_handleMessageReceived)); - + IpcClient client(&m_events, &socketMultiplexer, TEST_IPC_PORT); client.connect(); - + m_events.initQuitTimeout(5); m_events.loop(); m_events.removeHandler(m_events.forIpcServer().messageReceived(), &server); m_events.cleanupQuitTimeout(); - + EXPECT_EQ(true, m_connectToServer_helloMessageReceived); EXPECT_EQ(true, m_connectToServer_hasClientNode); } @@ -94,13 +93,13 @@ TEST_F(IpcTests, sendMessageToServer) SocketMultiplexer socketMultiplexer; IpcServer server(&m_events, &socketMultiplexer, TEST_IPC_PORT); server.listen(); - + // event handler sends "test" command to server. m_events.adoptHandler( m_events.forIpcServer().messageReceived(), &server, new TMethodEventJob( this, &IpcTests::sendMessageToServer_serverHandleMessageReceived)); - + IpcClient client(&m_events, &socketMultiplexer, TEST_IPC_PORT); client.connect(); m_sendMessageToServer_client = &client; @@ -128,7 +127,7 @@ TEST_F(IpcTests, sendMessageToClient) IpcClient client(&m_events, &socketMultiplexer, TEST_IPC_PORT); client.connect(); - + m_events.adoptHandler( m_events.forIpcClient().messageReceived(), &client, new TMethodEventJob( diff --git a/src/test/integtests/net/NetworkTests.cpp b/src/test/integtests/net/NetworkTests.cpp index d404abc..92767bf 100644 --- a/src/test/integtests/net/NetworkTests.cpp +++ b/src/test/integtests/net/NetworkTests.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2013-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 @@ -18,7 +18,7 @@ // TODO: fix, tests failing intermittently on mac. #ifndef WINAPI_CARBON -#define TEST_ENV +#define BARRIER_TEST_ENV #include "test/mock/server/MockConfig.h" #include "test/mock/server/MockPrimaryClient.h" @@ -36,7 +36,6 @@ #include "net/TCPSocketFactory.h" #include "mt/Thread.h" #include "base/TMethodEventJob.h" -#include "base/TMethodJob.h" #include "base/Log.h" #include @@ -84,19 +83,19 @@ public: } void sendMockData(void* eventTarget); - + void sendToClient_mockData_handleClientConnected(const Event&, void* vlistener); void sendToClient_mockData_fileRecieveCompleted(const Event&, void*); - + void sendToClient_mockFile_handleClientConnected(const Event&, void* vlistener); void sendToClient_mockFile_fileRecieveCompleted(const Event& event, void*); - + void sendToServer_mockData_handleClientConnected(const Event&, void* vlistener); void sendToServer_mockData_fileRecieveCompleted(const Event& event, void*); void sendToServer_mockFile_handleClientConnected(const Event&, void* vlistener); void sendToServer_mockFile_fileRecieveCompleted(const Event& event, void*); - + public: TestEventQueue m_events; UInt8* m_mockData; @@ -111,16 +110,17 @@ TEST_F(NetworkTests, sendToClient_mockData) NetworkAddress serverAddress(TEST_HOST, TEST_PORT); serverAddress.resolve(); - + // server SocketMultiplexer serverSocketMultiplexer; TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer); - ClientListener listener(serverAddress, serverSocketFactory, &m_events, false); + ClientListener listener(serverAddress, serverSocketFactory, &m_events, + ConnectionSecurityLevel::PLAINTEXT); NiceMock serverScreen; NiceMock primaryClient; NiceMock serverConfig; NiceMock serverInputFilter; - + m_events.adoptHandler( m_events.forClientListener().connected(), &listener, new TMethodEventJob( @@ -128,7 +128,7 @@ TEST_F(NetworkTests, sendToClient_mockData) ON_CALL(serverConfig, isScreen(_)).WillByDefault(Return(true)); ON_CALL(serverConfig, getInputFilter()).WillByDefault(Return(&serverInputFilter)); - + ServerArgs serverArgs; serverArgs.m_enableDragDrop = true; Server server(serverConfig, &primaryClient, &serverScreen, &m_events, serverArgs); @@ -139,7 +139,7 @@ TEST_F(NetworkTests, sendToClient_mockData) NiceMock clientScreen; SocketMultiplexer clientSocketMultiplexer; TCPSocketFactory* clientSocketFactory = new TCPSocketFactory(&m_events, &clientSocketMultiplexer); - + ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape)); ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos)); @@ -148,7 +148,7 @@ TEST_F(NetworkTests, sendToClient_mockData) clientArgs.m_enableDragDrop = true; clientArgs.m_enableCrypto = false; Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, clientArgs); - + m_events.adoptHandler( m_events.forFile().fileRecieveCompleted(), &client, new TMethodEventJob( @@ -169,16 +169,17 @@ TEST_F(NetworkTests, sendToClient_mockFile) NetworkAddress serverAddress(TEST_HOST, TEST_PORT); serverAddress.resolve(); - + // server SocketMultiplexer serverSocketMultiplexer; TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer); - ClientListener listener(serverAddress, serverSocketFactory, &m_events, false); + ClientListener listener(serverAddress, serverSocketFactory, &m_events, + ConnectionSecurityLevel::PLAINTEXT); NiceMock serverScreen; NiceMock primaryClient; NiceMock serverConfig; NiceMock serverInputFilter; - + m_events.adoptHandler( m_events.forClientListener().connected(), &listener, new TMethodEventJob( @@ -186,7 +187,7 @@ TEST_F(NetworkTests, sendToClient_mockFile) ON_CALL(serverConfig, isScreen(_)).WillByDefault(Return(true)); ON_CALL(serverConfig, getInputFilter()).WillByDefault(Return(&serverInputFilter)); - + ServerArgs serverArgs; serverArgs.m_enableDragDrop = true; Server server(serverConfig, &primaryClient, &serverScreen, &m_events, serverArgs); @@ -197,7 +198,7 @@ TEST_F(NetworkTests, sendToClient_mockFile) NiceMock clientScreen; SocketMultiplexer clientSocketMultiplexer; TCPSocketFactory* clientSocketFactory = new TCPSocketFactory(&m_events, &clientSocketMultiplexer); - + ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape)); ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos)); @@ -206,7 +207,7 @@ TEST_F(NetworkTests, sendToClient_mockFile) clientArgs.m_enableDragDrop = true; clientArgs.m_enableCrypto = false; Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, clientArgs); - + m_events.adoptHandler( m_events.forFile().fileRecieveCompleted(), &client, new TMethodEventJob( @@ -230,7 +231,8 @@ TEST_F(NetworkTests, sendToServer_mockData) // server SocketMultiplexer serverSocketMultiplexer; TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer); - ClientListener listener(serverAddress, serverSocketFactory, &m_events, false); + ClientListener listener(serverAddress, serverSocketFactory, &m_events, + ConnectionSecurityLevel::PLAINTEXT); NiceMock serverScreen; NiceMock primaryClient; NiceMock serverConfig; @@ -238,7 +240,7 @@ TEST_F(NetworkTests, sendToServer_mockData) ON_CALL(serverConfig, isScreen(_)).WillByDefault(Return(true)); ON_CALL(serverConfig, getInputFilter()).WillByDefault(Return(&serverInputFilter)); - + ServerArgs serverArgs; serverArgs.m_enableDragDrop = true; Server server(serverConfig, &primaryClient, &serverScreen, &m_events, serverArgs); @@ -249,7 +251,7 @@ TEST_F(NetworkTests, sendToServer_mockData) NiceMock clientScreen; SocketMultiplexer clientSocketMultiplexer; TCPSocketFactory* clientSocketFactory = new TCPSocketFactory(&m_events, &clientSocketMultiplexer); - + ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape)); ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos)); @@ -257,7 +259,7 @@ TEST_F(NetworkTests, sendToServer_mockData) clientArgs.m_enableDragDrop = true; clientArgs.m_enableCrypto = false; Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, clientArgs); - + m_events.adoptHandler( m_events.forClientListener().connected(), &listener, new TMethodEventJob( @@ -287,7 +289,8 @@ TEST_F(NetworkTests, sendToServer_mockFile) // server SocketMultiplexer serverSocketMultiplexer; TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer); - ClientListener listener(serverAddress, serverSocketFactory, &m_events, false); + ClientListener listener(serverAddress, serverSocketFactory, &m_events, + ConnectionSecurityLevel::PLAINTEXT); NiceMock serverScreen; NiceMock primaryClient; NiceMock serverConfig; @@ -295,7 +298,7 @@ TEST_F(NetworkTests, sendToServer_mockFile) ON_CALL(serverConfig, isScreen(_)).WillByDefault(Return(true)); ON_CALL(serverConfig, getInputFilter()).WillByDefault(Return(&serverInputFilter)); - + ServerArgs serverArgs; serverArgs.m_enableDragDrop = true; Server server(serverConfig, &primaryClient, &serverScreen, &m_events, serverArgs); @@ -306,7 +309,7 @@ TEST_F(NetworkTests, sendToServer_mockFile) NiceMock clientScreen; SocketMultiplexer clientSocketMultiplexer; TCPSocketFactory* clientSocketFactory = new TCPSocketFactory(&m_events, &clientSocketMultiplexer); - + ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape)); ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos)); @@ -334,7 +337,7 @@ TEST_F(NetworkTests, sendToServer_mockFile) m_events.cleanupQuitTimeout(); } -void +void NetworkTests::sendToClient_mockData_handleClientConnected(const Event&, void* vlistener) { ClientListener* listener = static_cast(vlistener); @@ -352,7 +355,7 @@ NetworkTests::sendToClient_mockData_handleClientConnected(const Event&, void* vl sendMockData(server); } -void +void NetworkTests::sendToClient_mockData_fileRecieveCompleted(const Event& event, void*) { Client* client = static_cast(event.getTarget()); @@ -361,7 +364,7 @@ NetworkTests::sendToClient_mockData_fileRecieveCompleted(const Event& event, voi m_events.raiseQuitEvent(); } -void +void NetworkTests::sendToClient_mockFile_handleClientConnected(const Event&, void* vlistener) { ClientListener* listener = static_cast(vlistener); @@ -379,7 +382,7 @@ NetworkTests::sendToClient_mockFile_handleClientConnected(const Event&, void* vl server->sendFileToClient(kMockFilename); } -void +void NetworkTests::sendToClient_mockFile_fileRecieveCompleted(const Event& event, void*) { Client* client = static_cast(event.getTarget()); @@ -388,14 +391,14 @@ NetworkTests::sendToClient_mockFile_fileRecieveCompleted(const Event& event, voi m_events.raiseQuitEvent(); } -void +void NetworkTests::sendToServer_mockData_handleClientConnected(const Event&, void* vclient) { Client* client = static_cast(vclient); sendMockData(client); } -void +void NetworkTests::sendToServer_mockData_fileRecieveCompleted(const Event& event, void*) { Server* server = static_cast(event.getTarget()); @@ -404,14 +407,14 @@ NetworkTests::sendToServer_mockData_fileRecieveCompleted(const Event& event, voi m_events.raiseQuitEvent(); } -void +void NetworkTests::sendToServer_mockFile_handleClientConnected(const Event&, void* vclient) { Client* client = static_cast(vclient); client->sendFileToServer(kMockFilename); } -void +void NetworkTests::sendToServer_mockFile_fileRecieveCompleted(const Event& event, void*) { Server* server = static_cast(event.getTarget()); @@ -420,13 +423,13 @@ NetworkTests::sendToServer_mockFile_fileRecieveCompleted(const Event& event, voi m_events.raiseQuitEvent(); } -void +void NetworkTests::sendMockData(void* eventTarget) { // send first message (file size) String size = barrier::string::sizeTypeToString(kMockDataSize); FileChunk* sizeMessage = FileChunk::start(size); - + m_events.addEvent(Event(m_events.forFile().fileChunkSending(), eventTarget, sizeMessage)); // send chunk messages with incrementing chunk size @@ -452,7 +455,7 @@ NetworkTests::sendMockData(void* eventTarget) } } - + // send last message FileChunk* transferFinished = FileChunk::end(); m_events.addEvent(Event(m_events.forFile().fileChunkSending(), eventTarget, transferFinished)); diff --git a/src/test/integtests/platform/MSWindowsClipboardTests.cpp b/src/test/integtests/platform/MSWindowsClipboardTests.cpp index f9d09d1..edf5a97 100644 --- a/src/test/integtests/platform/MSWindowsClipboardTests.cpp +++ b/src/test/integtests/platform/MSWindowsClipboardTests.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 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 @@ -36,7 +36,7 @@ protected: } private: - void emptyClipboard() + void emptyClipboard() { MSWindowsClipboard clipboard(NULL); clipboard.open(0); diff --git a/src/test/integtests/platform/MSWindowsKeyStateTests.cpp b/src/test/integtests/platform/MSWindowsKeyStateTests.cpp index 9373d14..6f6edf5 100644 --- a/src/test/integtests/platform/MSWindowsKeyStateTests.cpp +++ b/src/test/integtests/platform/MSWindowsKeyStateTests.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 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 @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#define TEST_ENV +#define BARRIER_TEST_ENV #include "test/mock/barrier/MockEventQueue.h" #include "test/mock/barrier/MockKeyMap.h" @@ -24,7 +24,6 @@ #include "platform/MSWindowsDesks.h" #include "platform/MSWindowsScreen.h" #include "platform/MSWindowsScreenSaver.h" -#include "base/TMethodJob.h" #include "test/global/gtest.h" #include "test/global/gmock.h" @@ -50,10 +49,7 @@ protected: MSWindowsDesks* newDesks(IEventQueue* eventQueue) { - return new MSWindowsDesks( - true, false, m_screensaver, eventQueue, - new TMethodJob( - this, &MSWindowsKeyStateTests::updateKeysCB), false); + return new MSWindowsDesks(true, false, m_screensaver, eventQueue, [](){}, false); } void* getEventTarget() const @@ -62,9 +58,7 @@ protected: } private: - void updateKeysCB(void*) { } IScreenSaver* m_screensaver; - MSWindowsHook m_hook; }; TEST_F(MSWindowsKeyStateTests, disable_eventQueueNotUsed) @@ -73,7 +67,7 @@ TEST_F(MSWindowsKeyStateTests, disable_eventQueueNotUsed) MSWindowsDesks* desks = newDesks(&eventQueue); MockKeyMap keyMap; MSWindowsKeyState keyState(desks, getEventTarget(), &eventQueue, keyMap); - + EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(0); keyState.disable(); diff --git a/src/test/integtests/platform/OSXClipboardTests.cpp b/src/test/integtests/platform/OSXClipboardTests.cpp index 45b73bd..093c738 100644 --- a/src/test/integtests/platform/OSXClipboardTests.cpp +++ b/src/test/integtests/platform/OSXClipboardTests.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 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 @@ -25,9 +25,9 @@ TEST(OSXClipboardTests, empty_openCalled_returnsTrue) { OSXClipboard clipboard; clipboard.open(0); - + bool actual = clipboard.empty(); - + EXPECT_EQ(true, actual); } @@ -36,9 +36,9 @@ TEST(OSXClipboardTests, empty_singleFormat_hasReturnsFalse) OSXClipboard clipboard; clipboard.open(0); clipboard.add(OSXClipboard::kText, "barrier rocks!"); - + clipboard.empty(); - + bool actual = clipboard.has(OSXClipboard::kText); EXPECT_EQ(false, actual); } @@ -47,9 +47,9 @@ TEST(OSXClipboardTests, add_newValue_valueWasStored) { OSXClipboard clipboard; clipboard.open(0); - + clipboard.add(IClipboard::kText, "barrier rocks!"); - + String actual = clipboard.get(IClipboard::kText); EXPECT_EQ("barrier rocks!", actual); } @@ -58,10 +58,10 @@ TEST(OSXClipboardTests, add_replaceValue_valueWasReplaced) { OSXClipboard clipboard; clipboard.open(0); - + clipboard.add(IClipboard::kText, "barrier rocks!"); clipboard.add(IClipboard::kText, "maxivista sucks"); // haha, just kidding. - + String actual = clipboard.get(IClipboard::kText); EXPECT_EQ("maxivista sucks", actual); } @@ -69,18 +69,18 @@ TEST(OSXClipboardTests, add_replaceValue_valueWasReplaced) TEST(OSXClipboardTests, open_timeIsZero_returnsTrue) { OSXClipboard clipboard; - + bool actual = clipboard.open(0); - + EXPECT_EQ(true, actual); } TEST(OSXClipboardTests, open_timeIsOne_returnsTrue) { OSXClipboard clipboard; - + bool actual = clipboard.open(1); - + EXPECT_EQ(true, actual); } @@ -88,9 +88,9 @@ TEST(OSXClipboardTests, close_isOpen_noErrors) { OSXClipboard clipboard; clipboard.open(0); - + clipboard.close(); - + // can't assert anything } @@ -98,9 +98,9 @@ TEST(OSXClipboardTests, getTime_openWithNoEmpty_returnsOne) { OSXClipboard clipboard; clipboard.open(1); - + OSXClipboard::Time actual = clipboard.getTime(); - + // this behavior is different to that of Clipboard which only // returns the value passed into open(t) after empty() is called. EXPECT_EQ((UInt32)1, actual); @@ -111,9 +111,9 @@ TEST(OSXClipboardTests, getTime_openAndEmpty_returnsOne) OSXClipboard clipboard; clipboard.open(1); clipboard.empty(); - + OSXClipboard::Time actual = clipboard.getTime(); - + EXPECT_EQ((UInt32)1, actual); } @@ -123,9 +123,9 @@ TEST(OSXClipboardTests, has_withFormatAdded_returnsTrue) clipboard.open(0); clipboard.empty(); clipboard.add(IClipboard::kText, "barrier rocks!"); - + bool actual = clipboard.has(IClipboard::kText); - + EXPECT_EQ(true, actual); } @@ -134,9 +134,9 @@ TEST(OSXClipboardTests, has_withNoFormats_returnsFalse) OSXClipboard clipboard; clipboard.open(0); clipboard.empty(); - + bool actual = clipboard.has(IClipboard::kText); - + EXPECT_EQ(false, actual); } @@ -145,9 +145,9 @@ TEST(OSXClipboardTests, get_withNoFormats_returnsEmpty) OSXClipboard clipboard; clipboard.open(0); clipboard.empty(); - + String actual = clipboard.get(IClipboard::kText); - + EXPECT_EQ("", actual); } @@ -157,8 +157,8 @@ TEST(OSXClipboardTests, get_withFormatAdded_returnsExpected) clipboard.open(0); clipboard.empty(); clipboard.add(IClipboard::kText, "barrier rocks!"); - + String actual = clipboard.get(IClipboard::kText); - + EXPECT_EQ("barrier rocks!", actual); } diff --git a/src/test/integtests/platform/OSXScreenTests.cpp b/src/test/integtests/platform/OSXScreenTests.cpp index 96beb4d..390e22f 100644 --- a/src/test/integtests/platform/OSXScreenTests.cpp +++ b/src/test/integtests/platform/OSXScreenTests.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-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 diff --git a/src/test/integtests/platform/XWindowsClipboardTests.cpp b/src/test/integtests/platform/XWindowsClipboardTests.cpp index 652ee5e..52eacda 100644 --- a/src/test/integtests/platform/XWindowsClipboardTests.cpp +++ b/src/test/integtests/platform/XWindowsClipboardTests.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 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 @@ -33,12 +33,12 @@ protected: m_display = XOpenDisplay(NULL); int screen = DefaultScreen(m_display); Window root = XRootWindow(m_display, screen); - + XSetWindowAttributes attr; attr.do_not_propagate_mask = 0; attr.override_redirect = True; attr.cursor = Cursor(); - + m_window = XCreateWindow( m_display, root, 0, 0, 1, 1, 0, 0, InputOnly, CopyFromParent, 0, &attr); @@ -68,9 +68,9 @@ protected: TEST_F(CXWindowsClipboardTests, empty_openCalled_returnsTrue) { CXWindowsClipboard clipboard = createClipboard(); - + bool actual = clipboard.empty(); - + EXPECT_EQ(true, actual); } @@ -78,9 +78,9 @@ TEST_F(CXWindowsClipboardTests, empty_singleFormat_hasReturnsFalse) { CXWindowsClipboard clipboard = createClipboard(); clipboard.add(CXWindowsClipboard::kText, "barrier rocks!"); - + clipboard.empty(); - + bool actual = clipboard.has(CXWindowsClipboard::kText); EXPECT_FALSE(actual); } @@ -88,9 +88,9 @@ TEST_F(CXWindowsClipboardTests, empty_singleFormat_hasReturnsFalse) TEST_F(CXWindowsClipboardTests, add_newValue_valueWasStored) { CXWindowsClipboard clipboard = createClipboard(); - + clipboard.add(IClipboard::kText, "barrier rocks!"); - + String actual = clipboard.get(IClipboard::kText); EXPECT_EQ("barrier rocks!", actual); } @@ -98,10 +98,10 @@ TEST_F(CXWindowsClipboardTests, add_newValue_valueWasStored) TEST_F(CXWindowsClipboardTests, add_replaceValue_valueWasReplaced) { CXWindowsClipboard clipboard = createClipboard(); - + clipboard.add(IClipboard::kText, "barrier rocks!"); clipboard.add(IClipboard::kText, "maxivista sucks"); // haha, just kidding. - + String actual = clipboard.get(IClipboard::kText); EXPECT_EQ("maxivista sucks", actual); } @@ -109,10 +109,10 @@ TEST_F(CXWindowsClipboardTests, add_replaceValue_valueWasReplaced) TEST_F(CXWindowsClipboardTests, close_isOpen_noErrors) { CXWindowsClipboard clipboard = createClipboard(); - + // clipboard opened in createClipboard() clipboard.close(); - + // can't assert anything } @@ -120,27 +120,27 @@ TEST_F(CXWindowsClipboardTests, has_withFormatAdded_returnsTrue) { CXWindowsClipboard clipboard = createClipboard(); clipboard.add(IClipboard::kText, "barrier rocks!"); - + bool actual = clipboard.has(IClipboard::kText); - + EXPECT_EQ(true, actual); } TEST_F(CXWindowsClipboardTests, has_withNoFormats_returnsFalse) { CXWindowsClipboard clipboard = createClipboard(); - + bool actual = clipboard.has(IClipboard::kText); - + EXPECT_FALSE(actual); } TEST_F(CXWindowsClipboardTests, get_withNoFormats_returnsEmpty) { CXWindowsClipboard clipboard = createClipboard(); - + String actual = clipboard.get(IClipboard::kText); - + EXPECT_EQ("", actual); } @@ -148,9 +148,9 @@ TEST_F(CXWindowsClipboardTests, get_withFormatAdded_returnsExpected) { CXWindowsClipboard clipboard = createClipboard(); clipboard.add(IClipboard::kText, "barrier rocks!"); - + String actual = clipboard.get(IClipboard::kText); - + EXPECT_EQ("barrier rocks!", actual); } diff --git a/src/test/integtests/platform/XWindowsKeyStateTests.cpp b/src/test/integtests/platform/XWindowsKeyStateTests.cpp index 9f6716d..28d090f 100644 --- a/src/test/integtests/platform/XWindowsKeyStateTests.cpp +++ b/src/test/integtests/platform/XWindowsKeyStateTests.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#define TEST_ENV +#define BARRIER_TEST_ENV #include "test/mock/barrier/MockKeyMap.h" #include "test/mock/barrier/MockEventQueue.h" diff --git a/src/test/integtests/platform/XWindowsScreenSaverTests.cpp b/src/test/integtests/platform/XWindowsScreenSaverTests.cpp index c6a2710..a3af21d 100644 --- a/src/test/integtests/platform/XWindowsScreenSaverTests.cpp +++ b/src/test/integtests/platform/XWindowsScreenSaverTests.cpp @@ -23,6 +23,7 @@ #include "platform/XWindowsScreenSaver.h" #include "test/global/gtest.h" +#include #include using ::testing::_; @@ -30,7 +31,12 @@ using ::testing::_; // TODO: not working on build machine for some reason TEST(CXWindowsScreenSaverTests, activate_defaultScreen_todo) { - Display* display = XOpenDisplay(":0.0"); + const char* displayName = std::getenv("DISPLAY"); + if (displayName == NULL) { + displayName = ":0.0"; + } + + Display* display = XOpenDisplay(displayName); Window window = DefaultRootWindow(display); MockEventQueue eventQueue; EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(1); diff --git a/src/test/integtests/platform/XWindowsScreenTests.cpp b/src/test/integtests/platform/XWindowsScreenTests.cpp index d8f75e1..53f113e 100644 --- a/src/test/integtests/platform/XWindowsScreenTests.cpp +++ b/src/test/integtests/platform/XWindowsScreenTests.cpp @@ -20,16 +20,22 @@ #include "platform/XWindowsScreen.h" #include "test/global/gtest.h" +#include using ::testing::_; TEST(CXWindowsScreenTests, fakeMouseMove_nonPrimary_getCursorPosValuesCorrect) { + const char* displayName = std::getenv("DISPLAY"); + if (displayName == NULL) { + displayName = ":0.0"; + } + MockEventQueue eventQueue; EXPECT_CALL(eventQueue, adoptHandler(_, _, _)).Times(2); EXPECT_CALL(eventQueue, adoptBuffer(_)).Times(2); EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(2); - XWindowsScreen screen(new XWindowsImpl(), ":0.0", false, false, 0, &eventQueue); + XWindowsScreen screen(new XWindowsImpl(), displayName, false, false, 0, &eventQueue); screen.fakeMouseMove(10, 20); diff --git a/src/test/mock/barrier/MockApp.h b/src/test/mock/barrier/MockApp.h index 91745d3..fd4094d 100644 --- a/src/test/mock/barrier/MockApp.h +++ b/src/test/mock/barrier/MockApp.h @@ -17,7 +17,7 @@ #pragma once -#define TEST_ENV +#define BARRIER_TEST_ENV #include "barrier/App.h" diff --git a/src/test/mock/barrier/MockArgParser.h b/src/test/mock/barrier/MockArgParser.h index b1dc07c..35d4ff9 100644 --- a/src/test/mock/barrier/MockArgParser.h +++ b/src/test/mock/barrier/MockArgParser.h @@ -17,7 +17,7 @@ #pragma once -#define TEST_ENV +#define BARRIER_TEST_ENV #include "barrier/ArgParser.h" diff --git a/src/test/mock/barrier/MockEventQueue.h b/src/test/mock/barrier/MockEventQueue.h index 735b9fc..76175bb 100644 --- a/src/test/mock/barrier/MockEventQueue.h +++ b/src/test/mock/barrier/MockEventQueue.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 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 diff --git a/src/test/mock/barrier/MockKeyState.h b/src/test/mock/barrier/MockKeyState.h index 308e90a..d245ee6 100644 --- a/src/test/mock/barrier/MockKeyState.h +++ b/src/test/mock/barrier/MockKeyState.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 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 diff --git a/src/test/mock/barrier/MockScreen.h b/src/test/mock/barrier/MockScreen.h index 78c195a..3c05218 100644 --- a/src/test/mock/barrier/MockScreen.h +++ b/src/test/mock/barrier/MockScreen.h @@ -17,7 +17,7 @@ #pragma once -#define TEST_ENV +#define BARRIER_TEST_ENV #include "barrier/Screen.h" diff --git a/src/test/mock/ipc/MockIpcServer.h b/src/test/mock/ipc/MockIpcServer.h index 4124b41..5b09b39 100644 --- a/src/test/mock/ipc/MockIpcServer.h +++ b/src/test/mock/ipc/MockIpcServer.h @@ -34,7 +34,7 @@ public: MockIpcServer() : m_sendCond(ARCH->newCondVar()), m_sendMutex(ARCH->newMutex()) { } - + ~MockIpcServer() { if (m_sendCond != NULL) { ARCH->closeCondVar(m_sendCond); diff --git a/src/test/mock/server/MockConfig.h b/src/test/mock/server/MockConfig.h index 4161de0..c0b40dc 100644 --- a/src/test/mock/server/MockConfig.h +++ b/src/test/mock/server/MockConfig.h @@ -17,7 +17,7 @@ #pragma once -#define TEST_ENV +#define BARRIER_TEST_ENV #include "server/Config.h" diff --git a/src/test/mock/server/MockInputFilter.h b/src/test/mock/server/MockInputFilter.h index edf6de1..09aeee2 100644 --- a/src/test/mock/server/MockInputFilter.h +++ b/src/test/mock/server/MockInputFilter.h @@ -17,7 +17,7 @@ #pragma once -#define TEST_ENV +#define BARRIER_TEST_ENV #include "server/InputFilter.h" diff --git a/src/test/mock/server/MockPrimaryClient.h b/src/test/mock/server/MockPrimaryClient.h index 80f18a1..db76187 100644 --- a/src/test/mock/server/MockPrimaryClient.h +++ b/src/test/mock/server/MockPrimaryClient.h @@ -17,7 +17,7 @@ #pragma once -#define TEST_ENV +#define BARRIER_TEST_ENV #include "server/PrimaryClient.h" #include "base/String.h" diff --git a/src/test/mock/server/MockServer.h b/src/test/mock/server/MockServer.h index a45ee08..74ad1d0 100644 --- a/src/test/mock/server/MockServer.h +++ b/src/test/mock/server/MockServer.h @@ -17,7 +17,7 @@ #pragma once -#define TEST_ENV +#define BARRIER_TEST_ENV #include "server/Server.h" diff --git a/src/test/unittests/CMakeLists.txt b/src/test/unittests/CMakeLists.txt index c46375c..8cf5e9a 100644 --- a/src/test/unittests/CMakeLists.txt +++ b/src/test/unittests/CMakeLists.txt @@ -1,11 +1,11 @@ # barrier -- mouse and keyboard sharing utility # Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2009 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 @@ -50,8 +50,6 @@ list(APPEND headers ${platform_sources}) include_directories( ../../ - ../../../ext/gtest/include - ../../../ext/gmock/include ../../../ext ) @@ -67,4 +65,4 @@ endif() add_executable(unittests ${sources}) target_link_libraries(unittests - arch base client server common io net platform server synlib mt ipc gtest gmock ${libs} ${OPENSSL_LIBS}) + arch base client server common io net platform server synlib mt ipc ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} ${libs} ${OPENSSL_LIBS}) diff --git a/src/test/unittests/Main.cpp b/src/test/unittests/Main.cpp index 7f0d0fe..52ad252 100644 --- a/src/test/unittests/Main.cpp +++ b/src/test/unittests/Main.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 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 @@ -35,12 +35,12 @@ main(int argc, char **argv) Arch arch; arch.init(); - + Log log; log.setFilter(kDEBUG4); testing::InitGoogleTest(&argc, argv); - + // gtest seems to randomly finish with error codes (e.g. -1, -1073741819) // even when no tests have failed. not sure what causes this, but it // happens on all platforms and keeps leading to false positives. diff --git a/src/test/unittests/barrier/ArgParserTests.cpp b/src/test/unittests/barrier/ArgParserTests.cpp index e14877e..311162f 100644 --- a/src/test/unittests/barrier/ArgParserTests.cpp +++ b/src/test/unittests/barrier/ArgParserTests.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-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 diff --git a/src/test/unittests/barrier/ClientArgsParsingTests.cpp b/src/test/unittests/barrier/ClientArgsParsingTests.cpp index 5a1e7d0..7aaa5db 100644 --- a/src/test/unittests/barrier/ClientArgsParsingTests.cpp +++ b/src/test/unittests/barrier/ClientArgsParsingTests.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-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 diff --git a/src/test/unittests/barrier/ClipboardChunkTests.cpp b/src/test/unittests/barrier/ClipboardChunkTests.cpp index e0e37be..784dee8 100644 --- a/src/test/unittests/barrier/ClipboardChunkTests.cpp +++ b/src/test/unittests/barrier/ClipboardChunkTests.cpp @@ -1,11 +1,11 @@ /* * barrier -- 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 diff --git a/src/test/unittests/barrier/ClipboardTests.cpp b/src/test/unittests/barrier/ClipboardTests.cpp index f710751..c1afdfb 100644 --- a/src/test/unittests/barrier/ClipboardTests.cpp +++ b/src/test/unittests/barrier/ClipboardTests.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 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 @@ -192,7 +192,7 @@ TEST(ClipboardTests, marshall_withTextAdded_lastSizeCharIs14) EXPECT_EQ(14, (int)actual[11]); } -// TODO: there's some integer -> char encoding going on here. i find it +// TODO: there's some integer -> char encoding going on here. i find it // hard to believe that the clipboard is the only thing doing this. maybe // we should refactor this stuff out of the clipboard. TEST(ClipboardTests, marshall_withTextSize285_sizeCharsValid) @@ -212,12 +212,12 @@ TEST(ClipboardTests, marshall_withTextSize285_sizeCharsValid) String actual = clipboard.marshall(); - // 4 asserts here, but that's ok because we're really just asserting 1 + // 4 asserts here, but that's ok because we're really just asserting 1 // thing. the 32-bit size value is split into 4 chars. if the size is 285 - // (29 more than the 8-bit max size), the last char "rolls over" to 29 - // (this is caused by a bit-wise & on 0xff and 8-bit truncation). each - // char before the last stores a bit-shifted version of the number, each - // 1 more power than the last, which is done by bit-shifting [0] by 24, + // (29 more than the 8-bit max size), the last char "rolls over" to 29 + // (this is caused by a bit-wise & on 0xff and 8-bit truncation). each + // char before the last stores a bit-shifted version of the number, each + // 1 more power than the last, which is done by bit-shifting [0] by 24, // [1] by 16, [2] by 8 ([3] is not bit-shifted). EXPECT_EQ(0, actual[8]); // 285 >> 24 = 285 / (256^3) = 0 EXPECT_EQ(0, actual[9]); // 285 >> 16 = 285 / (256^2) = 0 diff --git a/src/test/unittests/barrier/GenericArgsParsingTests.cpp b/src/test/unittests/barrier/GenericArgsParsingTests.cpp index f43070b..7f19918 100644 --- a/src/test/unittests/barrier/GenericArgsParsingTests.cpp +++ b/src/test/unittests/barrier/GenericArgsParsingTests.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-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 @@ -50,7 +50,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_logLevelCmd_setLogLevel) ArgParser argParser(NULL); ArgsBase argsBase; argParser.setArgsBase(argsBase); - + argParser.parseGenericArgs(argc, kLogLevelCmd, i); String logFilter(argsBase.m_logFilter); @@ -68,7 +68,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_logFileCmd_saveLogFilename) ArgParser argParser(NULL); ArgsBase argsBase; argParser.setArgsBase(argsBase); - + argParser.parseGenericArgs(argc, kLogFileCmd, i); String logFile(argsBase.m_logFile); @@ -86,7 +86,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_logFileCmdWithSpace_saveLogFilena ArgParser argParser(NULL); ArgsBase argsBase; argParser.setArgsBase(argsBase); - + argParser.parseGenericArgs(argc, kLogFileCmdWithSpace, i); String logFile(argsBase.m_logFile); @@ -104,7 +104,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_noDeamonCmd_daemonFalse) ArgParser argParser(NULL); ArgsBase argsBase; argParser.setArgsBase(argsBase); - + argParser.parseGenericArgs(argc, kNoDeamonCmd, i); EXPECT_FALSE(argsBase.m_daemon); @@ -120,7 +120,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_deamonCmd_daemonTrue) ArgParser argParser(NULL); ArgsBase argsBase; argParser.setArgsBase(argsBase); - + argParser.parseGenericArgs(argc, kDeamonCmd, i); EXPECT_EQ(true, argsBase.m_daemon); @@ -136,7 +136,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_nameCmd_saveName) ArgParser argParser(NULL); ArgsBase argsBase; argParser.setArgsBase(argsBase); - + argParser.parseGenericArgs(argc, kNameCmd, i); EXPECT_EQ("mock", argsBase.m_name); @@ -152,7 +152,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_noRestartCmd_restartFalse) ArgParser argParser(NULL); ArgsBase argsBase; argParser.setArgsBase(argsBase); - + argParser.parseGenericArgs(argc, kNoRestartCmd, i); EXPECT_FALSE(argsBase.m_restartable); @@ -168,7 +168,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_restartCmd_restartTrue) ArgParser argParser(NULL); ArgsBase argsBase; argParser.setArgsBase(argsBase); - + argParser.parseGenericArgs(argc, kRestartCmd, i); EXPECT_EQ(true, argsBase.m_restartable); @@ -184,7 +184,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_backendCmd_backendTrue) ArgParser argParser(NULL); ArgsBase argsBase; argParser.setArgsBase(argsBase); - + argParser.parseGenericArgs(argc, kBackendCmd, i); EXPECT_EQ(true, argsBase.m_backend); @@ -200,7 +200,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_noHookCmd_noHookTrue) ArgParser argParser(NULL); ArgsBase argsBase; argParser.setArgsBase(argsBase); - + argParser.parseGenericArgs(argc, kNoHookCmd, i); EXPECT_EQ(true, argsBase.m_noHooks); @@ -219,7 +219,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_helpCmd_showHelp) ArgsBase argsBase; argParser.setArgsBase(argsBase); ON_CALL(app, help()).WillByDefault(Invoke(showMockHelp)); - + argParser.parseGenericArgs(argc, kHelpCmd, i); EXPECT_EQ(true, g_helpShowed); @@ -239,7 +239,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_versionCmd_showVersion) ArgsBase argsBase; argParser.setArgsBase(argsBase); ON_CALL(app, version()).WillByDefault(Invoke(showMockVersion)); - + argParser.parseGenericArgs(argc, kVersionCmd, i); EXPECT_EQ(true, g_versionShowed); @@ -255,7 +255,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_noTrayCmd_disableTrayTrue) ArgParser argParser(NULL); ArgsBase argsBase; argParser.setArgsBase(argsBase); - + argParser.parseGenericArgs(argc, kNoTrayCmd, i); EXPECT_EQ(true, argsBase.m_disableTray); @@ -271,7 +271,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_ipcCmd_enableIpcTrue) ArgParser argParser(NULL); ArgsBase argsBase; argParser.setArgsBase(argsBase); - + argParser.parseGenericArgs(argc, kIpcCmd, i); EXPECT_EQ(true, argsBase.m_enableIpc); @@ -288,7 +288,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_dragDropCmdOnNonLinux_enableDragD ArgParser argParser(NULL); ArgsBase argsBase; argParser.setArgsBase(argsBase); - + argParser.parseGenericArgs(argc, kDragDropCmd, i); EXPECT_EQ(true, argsBase.m_enableDragDrop); @@ -306,7 +306,7 @@ TEST(GenericArgsParsingTests, parseGenericArgs_dragDropCmdOnLinux_enableDragDrop ArgParser argParser(NULL); ArgsBase argsBase; argParser.setArgsBase(argsBase); - + argParser.parseGenericArgs(argc, kDragDropCmd, i); EXPECT_FALSE(argsBase.m_enableDragDrop); diff --git a/src/test/unittests/barrier/KeyMapTests.cpp b/src/test/unittests/barrier/KeyMapTests.cpp index 5980633..20c1c55 100644 --- a/src/test/unittests/barrier/KeyMapTests.cpp +++ b/src/test/unittests/barrier/KeyMapTests.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2016 Symless - * + * * 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 @@ -15,6 +15,8 @@ * along with this program. If not, see . */ +#define BARRIER_TEST_ENV + #include "barrier/KeyMap.h" #include "test/global/gtest.h" @@ -28,7 +30,7 @@ using ::testing::ReturnRef; using ::testing::SaveArg; namespace barrier { - + TEST(KeyMapTests, findBestKey_requiredDown_matchExactFirstItem) { KeyMap keyMap; @@ -44,7 +46,7 @@ TEST(KeyMapTests, findBestKey_requiredDown_matchExactFirstItem) EXPECT_EQ(0, keyMap.findBestKey(entryList, currentState, desiredState)); } - + TEST(KeyMapTests, findBestKey_requiredAndExtraSensitiveDown_matchExactFirstItem) { KeyMap keyMap; @@ -82,7 +84,7 @@ TEST(KeyMapTests, findBestKey_requiredAndExtraSensitiveDown_matchExactSecondItem EXPECT_EQ(1, keyMap.findBestKey(entryList, currentState, desiredState)); } - + TEST(KeyMapTests, findBestKey_extraSensitiveDown_matchExactSecondItem) { KeyMap keyMap; @@ -101,7 +103,7 @@ TEST(KeyMapTests, findBestKey_extraSensitiveDown_matchExactSecondItem) itemList2.push_back(item2); entryList.push_back(itemList1); entryList.push_back(itemList2); - + EXPECT_EQ(1, keyMap.findBestKey(entryList, currentState, desiredState)); } @@ -123,7 +125,7 @@ TEST(KeyMapTests, findBestKey_noRequiredDown_matchOneRequiredChangeItem) itemList2.push_back(item2); entryList.push_back(itemList1); entryList.push_back(itemList2); - + EXPECT_EQ(1, keyMap.findBestKey(entryList, currentState, desiredState)); } @@ -148,7 +150,7 @@ TEST(KeyMapTests, findBestKey_onlyOneRequiredDown_matchTwoRequiredChangesItem) EXPECT_EQ(1, keyMap.findBestKey(entryList, currentState, desiredState)); } - + TEST(KeyMapTests, findBestKey_noRequiredDown_cannotMatch) { KeyMap keyMap; @@ -161,31 +163,31 @@ TEST(KeyMapTests, findBestKey_noRequiredDown_cannotMatch) KeyModifierMask desiredState = 0; itemList.push_back(item); entryList.push_back(itemList); - + EXPECT_EQ(-1, keyMap.findBestKey(entryList, currentState, desiredState)); } - + TEST(KeyMapTests, isCommand_shiftMask_returnFalse) { KeyMap keyMap; KeyModifierMask mask= KeyModifierShift; - + EXPECT_FALSE(keyMap.isCommand(mask)); } - + TEST(KeyMapTests, isCommand_controlMask_returnTrue) { KeyMap keyMap; KeyModifierMask mask= KeyModifierControl; - + EXPECT_EQ(true, keyMap.isCommand(mask)); } - + TEST(KeyMapTests, isCommand_alternateMask_returnTrue) { KeyMap keyMap; KeyModifierMask mask= KeyModifierAlt; - + EXPECT_EQ(true, keyMap.isCommand(mask)); } @@ -193,15 +195,15 @@ TEST(KeyMapTests, isCommand_alternateGraphicMask_returnTrue) { KeyMap keyMap; KeyModifierMask mask= KeyModifierAltGr; - + EXPECT_EQ(true, keyMap.isCommand(mask)); } - + TEST(KeyMapTests, isCommand_metaMask_returnTrue) { KeyMap keyMap; KeyModifierMask mask= KeyModifierMeta; - + EXPECT_EQ(true, keyMap.isCommand(mask)); } @@ -209,8 +211,8 @@ TEST(KeyMapTests, isCommand_superMask_returnTrue) { KeyMap keyMap; KeyModifierMask mask= KeyModifierSuper; - + EXPECT_EQ(true, keyMap.isCommand(mask)); } - + } diff --git a/src/test/unittests/barrier/KeyStateTests.cpp b/src/test/unittests/barrier/KeyStateTests.cpp index d4154d8..bc41933 100644 --- a/src/test/unittests/barrier/KeyStateTests.cpp +++ b/src/test/unittests/barrier/KeyStateTests.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2011 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 @@ -100,7 +100,7 @@ TEST(KeyStateTests, sendKeyEvent_halfDuplex_addEventCalledTwice) KeyStateImpl keyState(eventQueue, keyMap); IKeyStateEvents keyStateEvents; keyStateEvents.setEvents(&eventQueue); - + ON_CALL(keyMap, isHalfDuplex(_, _)).WillByDefault(Return(true)); ON_CALL(eventQueue, forIKeyState()).WillByDefault(ReturnRef(keyStateEvents)); @@ -116,7 +116,7 @@ TEST(KeyStateTests, sendKeyEvent_keyRepeat_addEventCalledOnce) KeyStateImpl keyState(eventQueue, keyMap); IKeyStateEvents keyStateEvents; keyStateEvents.setEvents(&eventQueue); - + ON_CALL(eventQueue, forIKeyState()).WillByDefault(ReturnRef(keyStateEvents)); EXPECT_CALL(eventQueue, addEvent(_)).Times(1); @@ -131,7 +131,7 @@ TEST(KeyStateTests, sendKeyEvent_keyDown_addEventCalledOnce) KeyStateImpl keyState(eventQueue, keyMap); IKeyStateEvents keyStateEvents; keyStateEvents.setEvents(&eventQueue); - + ON_CALL(eventQueue, forIKeyState()).WillByDefault(ReturnRef(keyStateEvents)); EXPECT_CALL(eventQueue, addEvent(_)).Times(1); @@ -146,7 +146,7 @@ TEST(KeyStateTests, sendKeyEvent_keyUp_addEventCalledOnce) KeyStateImpl keyState(eventQueue, keyMap); IKeyStateEvents keyStateEvents; keyStateEvents.setEvents(&eventQueue); - + ON_CALL(eventQueue, forIKeyState()).WillByDefault(ReturnRef(keyStateEvents)); EXPECT_CALL(eventQueue, addEvent(_)).Times(1); diff --git a/src/test/unittests/base/StringTests.cpp b/src/test/unittests/base/StringTests.cpp index 39ad6e8..cc8e4fc 100644 --- a/src/test/unittests/base/StringTests.cpp +++ b/src/test/unittests/base/StringTests.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-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 @@ -56,12 +56,38 @@ TEST(StringTests, sprintf_formatWithArgument_formatedString) TEST(StringTests, toHex_plaintext_hexString) { - String subject = "foobar"; + std::vector subject{'f', 'o', 'o', 'b', 'a', 'r'}; int width = 2; - string::toHex(subject, width); + EXPECT_EQ("666f6f626172", string::to_hex(subject, width)); +} + +TEST(StringTests, fromhex_plaintext_string) +{ + auto result = string::from_hex("666f6f626172"); + std::string expected = "foobar"; + EXPECT_EQ(result, std::vector(expected.begin(), expected.end())); +} + +TEST(StringTests, fromhex_plaintext_string_colons) +{ + auto result = string::from_hex("66:6f:6f:62:61:72"); + std::string expected = "foobar"; + EXPECT_EQ(result, std::vector(expected.begin(), expected.end())); +} - EXPECT_EQ("666f6f626172", subject); +TEST(StringTests, fromhex_binary_string) +{ + auto result = string::from_hex("01020304050600fff9"); + auto expected = std::vector{1, 2, 3, 4, 5, 6, 0, 0xff, 0xf9}; + EXPECT_EQ(result, expected); +} + +TEST(StringTests, fromhex_invalid_string) +{ + EXPECT_TRUE(string::from_hex("66:6").empty()); + EXPECT_TRUE(string::from_hex("66:612").empty()); + EXPECT_TRUE(string::from_hex("66:WW").empty()); } TEST(StringTests, uppercase_lowercaseInput_uppercaseOutput) diff --git a/src/test/unittests/ipc/IpcLogOutputterTests.cpp b/src/test/unittests/ipc/IpcLogOutputterTests.cpp index bbfed9c..6db9ac9 100644 --- a/src/test/unittests/ipc/IpcLogOutputterTests.cpp +++ b/src/test/unittests/ipc/IpcLogOutputterTests.cpp @@ -1,11 +1,11 @@ /* * barrier -- 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 @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -#define TEST_ENV +#define BARRIER_TEST_ENV #include "test/mock/ipc/MockIpcServer.h" @@ -50,7 +50,7 @@ TEST(IpcLogOutputterTests, write_threadingEnabled_bufferIsSent) { MockIpcServer mockServer; mockServer.delegateToFake(); - + ON_CALL(mockServer, hasClients(_)).WillByDefault(Return(true)); EXPECT_CALL(mockServer, hasClients(_)).Times(AtLeast(3)); @@ -67,7 +67,7 @@ TEST(IpcLogOutputterTests, write_threadingEnabled_bufferIsSent) TEST(IpcLogOutputterTests, write_overBufferMaxSize_firstLineTruncated) { MockIpcServer mockServer; - + ON_CALL(mockServer, hasClients(_)).WillByDefault(Return(true)); EXPECT_CALL(mockServer, hasClients(_)).Times(1); EXPECT_CALL(mockServer, send(IpcLogLineMessageEq("mock 2\nmock 3\n"), _)).Times(1); @@ -85,7 +85,7 @@ TEST(IpcLogOutputterTests, write_overBufferMaxSize_firstLineTruncated) TEST(IpcLogOutputterTests, write_underBufferMaxSize_allLinesAreSent) { MockIpcServer mockServer; - + ON_CALL(mockServer, hasClients(_)).WillByDefault(Return(true)); EXPECT_CALL(mockServer, hasClients(_)).Times(1); @@ -107,7 +107,7 @@ TEST(IpcLogOutputterTests, write_underBufferMaxSize_allLinesAreSent) TEST(IpcLogOutputterTests, write_overBufferRateLimit_lastLineTruncated) { MockIpcServer mockServer; - + ON_CALL(mockServer, hasClients(_)).WillByDefault(Return(true)); EXPECT_CALL(mockServer, hasClients(_)).Times(2); @@ -123,7 +123,7 @@ TEST(IpcLogOutputterTests, write_overBufferRateLimit_lastLineTruncated) outputter.write(kNOTE, "mock 3"); outputter.sendBuffer(); - + // after waiting the time limit send another to make sure // we can log after the time limit passes. // HACK: sleep causes the unit test to fail intermittently, @@ -140,7 +140,7 @@ TEST(IpcLogOutputterTests, write_overBufferRateLimit_lastLineTruncated) TEST(IpcLogOutputterTests, write_underBufferRateLimit_allLinesAreSent) { MockIpcServer mockServer; - + ON_CALL(mockServer, hasClients(_)).WillByDefault(Return(true)); EXPECT_CALL(mockServer, hasClients(_)).Times(2); @@ -154,7 +154,7 @@ TEST(IpcLogOutputterTests, write_underBufferRateLimit_allLinesAreSent) outputter.write(kNOTE, "mock 1"); outputter.write(kNOTE, "mock 2"); outputter.sendBuffer(); - + // after waiting the time limit send another to make sure // we can log after the time limit passes. outputter.write(kNOTE, "mock 3"); diff --git a/src/test/unittests/net/FingerprintDatabaseTests.cpp b/src/test/unittests/net/FingerprintDatabaseTests.cpp new file mode 100644 index 0000000..61bed0e --- /dev/null +++ b/src/test/unittests/net/FingerprintDatabaseTests.cpp @@ -0,0 +1,95 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) Barrier contributors + + 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 "net/FingerprintDatabase.h" +#include "test/global/gtest.h" + +namespace barrier { + +TEST(FingerprintDatabase, parse_db_line) +{ + ASSERT_FALSE(FingerprintDatabase::parse_db_line("").valid()); + ASSERT_FALSE(FingerprintDatabase::parse_db_line("abcd").valid()); + ASSERT_FALSE(FingerprintDatabase::parse_db_line("v1:algo:something").valid()); + ASSERT_FALSE(FingerprintDatabase::parse_db_line("v2:algo:something").valid()); + ASSERT_FALSE(FingerprintDatabase::parse_db_line("v2:algo:01020304abc").valid()); + ASSERT_FALSE(FingerprintDatabase::parse_db_line("v2:algo:01020304ZZ").valid()); + ASSERT_EQ(FingerprintDatabase::parse_db_line("v2:algo:01020304ab"), + (FingerprintData{"algo", {1, 2, 3, 4, 0xab}})); +} + +TEST(FingerprintDatabase, read) +{ + std::istringstream stream; + stream.str(R"( +v2:algo1:01020304ab +v2:algo2:03040506ab +AB:CD:EF:00:01:02:03:04:05:06:07:08:09:10:11:12:13:14:15:16 +)"); + FingerprintDatabase db; + db.read_stream(stream); + + std::vector expected = { + { "algo1", { 1, 2, 3, 4, 0xab } }, + { "algo2", { 3, 4, 5, 6, 0xab } }, + { "sha1", { 0xab, 0xcd, 0xef, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16 } }, + }; + ASSERT_EQ(db.fingerprints(), expected); +} + +TEST(FingerprintDatabase, write) +{ + std::ostringstream stream; + + FingerprintDatabase db; + db.add_trusted({ "algo1", { 1, 2, 3, 4, 0xab } }); + db.add_trusted({ "algo2", { 3, 4, 5, 6, 0xab } }); + db.write_stream(stream); + + ASSERT_EQ(stream.str(), R"(v2:algo1:01020304ab +v2:algo2:03040506ab +)"); +} + +TEST(FingerprintDatabase, clear) +{ + FingerprintDatabase db; + db.add_trusted({ "algo1", { 1, 2, 3, 4, 0xab } }); + db.clear(); + ASSERT_TRUE(db.fingerprints().empty()); +} + +TEST(FingerprintDatabase, add_trusted_no_duplicates) +{ + FingerprintDatabase db; + db.add_trusted({ "algo1", { 1, 2, 3, 4, 0xab } }); + db.add_trusted({ "algo2", { 3, 4, 5, 6, 0xab } }); + db.add_trusted({ "algo1", { 1, 2, 3, 4, 0xab } }); + ASSERT_EQ(db.fingerprints().size(), 2); +} + +TEST(FingerprintDatabase, is_trusted) +{ + FingerprintDatabase db; + db.add_trusted({ "algo1", { 1, 2, 3, 4, 0xab } }); + ASSERT_TRUE(db.is_trusted({ "algo1", { 1, 2, 3, 4, 0xab } })); + ASSERT_FALSE(db.is_trusted({ "algo2", { 1, 2, 3, 4, 0xab } })); + ASSERT_FALSE(db.is_trusted({ "algo1", { 1, 2, 3, 4, 0xac } })); +} + +} // namespace barrier diff --git a/src/test/unittests/net/SecureUtilsTests.cpp b/src/test/unittests/net/SecureUtilsTests.cpp new file mode 100644 index 0000000..0cce693 --- /dev/null +++ b/src/test/unittests/net/SecureUtilsTests.cpp @@ -0,0 +1,73 @@ +/* + barrier -- mouse and keyboard sharing utility + Copyright (C) 2021 Barrier contributors + + 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 "net/SecureUtils.h" + +#include "test/global/gtest.h" +#include "test/global/TestUtils.h" + +namespace barrier { + +TEST(SecureUtilsTest, FormatSslFingerprintHexWithSeparators) +{ + auto fingerprint = generate_pseudo_random_bytes(0, 32); + ASSERT_EQ(format_ssl_fingerprint(fingerprint, true), + "28:FD:0A:98:8A:0E:A1:6C:D7:E8:6C:A7:EE:58:41:71:" + "CA:B2:8E:49:25:94:90:25:26:05:8D:AF:63:ED:2E:30"); +} + +TEST(SecureUtilsTest, CreateFingerprintRandomArt) +{ + ASSERT_EQ(create_fingerprint_randomart(generate_pseudo_random_bytes(0, 32)), + "+-----------------+\n" + "|*X+. . |\n" + "|*oo + |\n" + "| + = |\n" + "| B . . |\n" + "|.+... o S |\n" + "|E+ ++. . |\n" + "|B*++.. . |\n" + "|+o*o o . |\n" + "|+o*Bo . |\n" + "+-----------------+"); + ASSERT_EQ(create_fingerprint_randomart(generate_pseudo_random_bytes(1, 32)), + "+-----------------+\n" + "| .oo+ . .B=. |\n" + "| .o.+ . o o.= |\n" + "|o..+.. o . E * |\n" + "|oo..+ . * * |\n" + "|B o.....S. o . |\n" + "|+=o..... |\n" + "| + + . |\n" + "|o. .. |\n" + "|..o.. |\n" + "+-----------------+"); + ASSERT_EQ(create_fingerprint_randomart(generate_pseudo_random_bytes(2, 32)), + "+-----------------+\n" + "| ... .o.o.|\n" + "| o .=.E|\n" + "| . + o ...+.|\n" + "| * o = o ... |\n" + "| * + S & . |\n" + "| = + % @ |\n" + "| . . = X o |\n" + "| . . O . |\n" + "| . + |\n" + "+-----------------+"); +} + +} // namespace barrier diff --git a/src/test/unittests/platform/OSXKeyStateTests.cpp b/src/test/unittests/platform/OSXKeyStateTests.cpp index dd9e80f..0e4ec83 100644 --- a/src/test/unittests/platform/OSXKeyStateTests.cpp +++ b/src/test/unittests/platform/OSXKeyStateTests.cpp @@ -30,27 +30,27 @@ TEST(OSXKeyStateTests, mapModifiersFromOSX_OSXMask_returnBarrierMask) OSXKeyState keyState(&eventQueue, keyMap); KeyModifierMask outMask = 0; - + UInt32 shiftMask = 0 | kCGEventFlagMaskShift; outMask = keyState.mapModifiersFromOSX(shiftMask); EXPECT_EQ(KeyModifierShift, outMask); - + UInt32 ctrlMask = 0 | kCGEventFlagMaskControl; outMask = keyState.mapModifiersFromOSX(ctrlMask); EXPECT_EQ(KeyModifierControl, outMask); - + UInt32 altMask = 0 | kCGEventFlagMaskAlternate; outMask = keyState.mapModifiersFromOSX(altMask); EXPECT_EQ(KeyModifierAlt, outMask); - + UInt32 cmdMask = 0 | kCGEventFlagMaskCommand; outMask = keyState.mapModifiersFromOSX(cmdMask); EXPECT_EQ(KeyModifierSuper, outMask); - + UInt32 capsMask = 0 | kCGEventFlagMaskAlphaShift; outMask = keyState.mapModifiersFromOSX(capsMask); EXPECT_EQ(KeyModifierCapsLock, outMask); - + UInt32 numMask = 0 | kCGEventFlagMaskNumericPad; outMask = keyState.mapModifiersFromOSX(numMask); EXPECT_EQ(KeyModifierNumLock, outMask); -- cgit v1.2.3