From fbc30002ab3438356c0476e70c4577a0310d52c0 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Tue, 21 Jul 2020 06:15:04 -0400 Subject: New upstream version 2.3.3+dfsg. --- src/CMakeLists.txt | 1 + src/cmd/barriers/barriers.cpp | 7 + src/gui/CMakeLists.txt | 4 +- src/gui/res/Barrier.qrc | 3 + src/gui/res/icons/32x32/barrier-connected-mask.png | Bin 0 -> 876 bytes src/gui/res/icons/32x32/barrier-connected-mask.svg | 114 ++++ .../res/icons/32x32/barrier-disconnected-mask.png | Bin 0 -> 732 bytes .../res/icons/32x32/barrier-disconnected-mask.svg | 102 ++++ .../res/icons/32x32/barrier-transfering-mask.png | Bin 0 -> 682 bytes .../res/icons/32x32/barrier-transfering-mask.svg | 148 ++++++ src/gui/res/lang/gui_sv.ts | 576 +++++++++++---------- src/gui/src/Action.cpp | 23 +- src/gui/src/Action.h | 4 +- src/gui/src/ActionDialog.cpp | 2 +- src/gui/src/ActionDialogBase.ui | 11 + src/gui/src/BaseConfig.h | 72 ++- src/gui/src/MainWindow.cpp | 30 +- src/gui/src/Screen.cpp | 65 ++- src/gui/src/Screen.h | 23 +- src/gui/src/ScreenSettingsDialog.cpp | 65 +-- src/gui/src/ServerConfig.cpp | 17 +- src/gui/src/ServerConfig.h | 4 +- src/gui/src/ServerConfigDialog.cpp | 20 +- src/gui/src/ServerConfigDialogBase.ui | 100 ++-- src/gui/src/SettingsDialog.cpp | 4 +- src/lib/arch/Arch.h | 4 +- src/lib/arch/ArchDaemonNone.h | 3 +- src/lib/arch/IArchDaemon.h | 4 +- src/lib/arch/IArchTaskBarReceiver.h | 6 +- src/lib/arch/XArch.h | 6 +- src/lib/arch/unix/ArchInternetUnix.cpp | 16 +- src/lib/arch/unix/ArchInternetUnix.h | 6 +- src/lib/arch/unix/ArchMultithreadPosix.cpp | 13 - src/lib/arch/unix/ArchNetworkBSD.cpp | 1 - src/lib/arch/unix/XArchUnix.h | 2 +- src/lib/arch/win32/ArchInternetWindows.cpp | 36 +- src/lib/arch/win32/ArchInternetWindows.h | 6 +- src/lib/arch/win32/ArchMiscWindows.cpp | 7 +- src/lib/arch/win32/ArchMiscWindows.h | 3 +- src/lib/arch/win32/XArchWindows.cpp | 4 +- src/lib/arch/win32/XArchWindows.h | 4 +- src/lib/barrier/ClientApp.cpp | 4 +- src/lib/barrier/PlatformScreen.h | 2 +- src/lib/barrier/ProtocolUtil.cpp | 3 +- src/lib/barrier/ProtocolUtil.h | 6 +- src/lib/barrier/ServerApp.cpp | 13 +- src/lib/barrier/StreamChunker.cpp | 2 +- src/lib/barrier/XBarrier.cpp | 30 +- src/lib/barrier/XBarrier.h | 34 +- src/lib/barrier/XScreen.cpp | 11 +- src/lib/barrier/XScreen.h | 4 +- src/lib/barrier/win32/DaemonApp.cpp | 5 +- src/lib/base/EventQueue.cpp | 9 +- src/lib/base/EventQueue.h | 6 +- src/lib/base/EventTypes.cpp | 1 + src/lib/base/EventTypes.h | 9 + src/lib/base/IEventQueue.h | 11 +- src/lib/base/Log.cpp | 1 - src/lib/base/String.cpp | 62 ++- src/lib/base/String.h | 40 +- src/lib/base/Unicode.cpp | 81 ++- src/lib/base/Unicode.h | 42 +- src/lib/base/XBase.cpp | 11 +- src/lib/base/XBase.h | 41 +- src/lib/base/log_outputters.cpp | 5 +- src/lib/base/log_outputters.h | 4 +- src/lib/client/Client.cpp | 20 +- src/lib/client/Client.h | 20 +- src/lib/client/ServerProxy.cpp | 10 +- src/lib/client/ServerProxy.h | 1 - src/lib/common/stdexcept.h | 23 - src/lib/io/XIO.cpp | 9 +- src/lib/ipc/IpcClientProxy.cpp | 4 +- src/lib/ipc/IpcLogOutputter.cpp | 10 +- src/lib/ipc/IpcLogOutputter.h | 7 +- src/lib/ipc/IpcMessage.cpp | 14 +- src/lib/ipc/IpcMessage.h | 14 +- src/lib/ipc/IpcServerProxy.cpp | 4 +- src/lib/mt/XMT.cpp | 3 +- src/lib/net/IDataSocket.h | 4 +- src/lib/net/NetworkAddress.cpp | 5 +- src/lib/net/NetworkAddress.h | 7 +- src/lib/net/SecureListenSocket.cpp | 3 +- src/lib/net/SecureSocket.cpp | 24 +- src/lib/net/SecureSocket.h | 18 +- src/lib/net/TCPSocket.cpp | 25 +- src/lib/net/TCPSocket.h | 3 +- src/lib/net/XSocket.cpp | 27 +- src/lib/net/XSocket.h | 15 +- src/lib/platform/MSWindowsClipboard.cpp | 9 +- src/lib/platform/MSWindowsClipboard.h | 14 +- .../MSWindowsClipboardAnyTextConverter.cpp | 24 +- .../platform/MSWindowsClipboardAnyTextConverter.h | 14 +- .../platform/MSWindowsClipboardBitmapConverter.cpp | 12 +- .../platform/MSWindowsClipboardBitmapConverter.h | 4 +- .../platform/MSWindowsClipboardHTMLConverter.cpp | 41 +- src/lib/platform/MSWindowsClipboardHTMLConverter.h | 6 +- .../platform/MSWindowsClipboardTextConverter.cpp | 12 +- src/lib/platform/MSWindowsClipboardTextConverter.h | 4 +- .../platform/MSWindowsClipboardUTF16Converter.cpp | 12 +- .../platform/MSWindowsClipboardUTF16Converter.h | 4 +- src/lib/platform/MSWindowsDesks.cpp | 12 +- src/lib/platform/MSWindowsDesks.h | 12 +- src/lib/platform/MSWindowsEventQueueBuffer.cpp | 16 +- src/lib/platform/MSWindowsEventQueueBuffer.h | 1 + src/lib/platform/MSWindowsKeyState.h | 1 - src/lib/platform/MSWindowsScreen.cpp | 13 +- src/lib/platform/MSWindowsScreen.h | 9 +- src/lib/platform/MSWindowsScreenSaver.h | 1 - src/lib/platform/MSWindowsSession.cpp | 5 +- src/lib/platform/MSWindowsSession.h | 4 +- src/lib/platform/MSWindowsUtil.cpp | 17 +- src/lib/platform/MSWindowsUtil.h | 6 +- src/lib/platform/MSWindowsWatchdog.cpp | 7 +- src/lib/platform/MSWindowsWatchdog.h | 8 +- src/lib/platform/OSXClipboard.cpp | 12 +- src/lib/platform/OSXClipboard.h | 12 +- .../platform/OSXClipboardAnyBitmapConverter.cpp | 6 +- src/lib/platform/OSXClipboardAnyBitmapConverter.h | 8 +- src/lib/platform/OSXClipboardAnyTextConverter.cpp | 16 +- src/lib/platform/OSXClipboardAnyTextConverter.h | 15 +- src/lib/platform/OSXClipboardBMPConverter.cpp | 12 +- src/lib/platform/OSXClipboardBMPConverter.h | 9 +- src/lib/platform/OSXClipboardHTMLConverter.cpp | 20 +- src/lib/platform/OSXClipboardHTMLConverter.h | 9 +- src/lib/platform/OSXClipboardTextConverter.cpp | 20 +- src/lib/platform/OSXClipboardTextConverter.h | 9 +- src/lib/platform/OSXClipboardUTF16Converter.cpp | 6 +- src/lib/platform/OSXClipboardUTF16Converter.h | 4 +- src/lib/platform/OSXDragView.m | 4 +- src/lib/platform/OSXKeyState.cpp | 12 +- src/lib/platform/OSXScreen.h | 6 +- src/lib/platform/XWindowsClipboard.cpp | 50 +- src/lib/platform/XWindowsClipboard.h | 30 +- .../XWindowsClipboardAnyBitmapConverter.cpp | 16 +- .../platform/XWindowsClipboardAnyBitmapConverter.h | 14 +- src/lib/platform/XWindowsClipboardBMPConverter.cpp | 12 +- src/lib/platform/XWindowsClipboardBMPConverter.h | 4 +- .../platform/XWindowsClipboardHTMLConverter.cpp | 6 +- src/lib/platform/XWindowsClipboardHTMLConverter.h | 4 +- .../platform/XWindowsClipboardTextConverter.cpp | 8 +- src/lib/platform/XWindowsClipboardTextConverter.h | 4 +- .../platform/XWindowsClipboardUCS2Converter.cpp | 6 +- src/lib/platform/XWindowsClipboardUCS2Converter.h | 4 +- .../platform/XWindowsClipboardUTF8Converter.cpp | 6 +- src/lib/platform/XWindowsClipboardUTF8Converter.h | 4 +- src/lib/platform/XWindowsEventQueueBuffer.cpp | 15 +- src/lib/platform/XWindowsEventQueueBuffer.h | 2 + src/lib/platform/XWindowsKeyState.cpp | 1 - src/lib/platform/XWindowsKeyState.h | 2 +- src/lib/platform/XWindowsScreen.cpp | 1 - src/lib/platform/XWindowsUtil.cpp | 24 +- src/lib/platform/XWindowsUtil.h | 24 +- src/lib/server/BaseClientProxy.cpp | 5 +- src/lib/server/BaseClientProxy.h | 7 +- src/lib/server/ClientProxy.cpp | 2 +- src/lib/server/ClientProxy.h | 3 +- src/lib/server/ClientProxy1_0.cpp | 3 +- src/lib/server/ClientProxy1_0.h | 2 +- src/lib/server/ClientProxy1_1.cpp | 3 +- src/lib/server/ClientProxy1_1.h | 2 +- src/lib/server/ClientProxy1_2.cpp | 3 +- src/lib/server/ClientProxy1_2.h | 2 +- src/lib/server/ClientProxy1_3.cpp | 3 +- src/lib/server/ClientProxy1_3.h | 2 +- src/lib/server/ClientProxy1_4.cpp | 3 +- src/lib/server/ClientProxy1_4.h | 3 +- src/lib/server/ClientProxy1_5.cpp | 9 +- src/lib/server/ClientProxy1_5.h | 3 +- src/lib/server/ClientProxy1_6.cpp | 7 +- src/lib/server/ClientProxy1_6.h | 3 +- src/lib/server/ClientProxyUnknown.cpp | 3 +- src/lib/server/Config.cpp | 349 ++++++------- src/lib/server/Config.h | 167 +++--- src/lib/server/InputFilter.cpp | 93 ++-- src/lib/server/InputFilter.h | 57 +- src/lib/server/PrimaryClient.cpp | 2 +- src/lib/server/PrimaryClient.h | 2 +- src/lib/server/Server.cpp | 56 +- src/lib/server/Server.h | 29 +- src/test/global/TestEventQueue.cpp | 2 +- src/test/global/TestEventQueue.h | 2 +- src/test/integtests/CMakeLists.txt | 42 +- src/test/integtests/arch/ArchInternetTests.cpp | 6 +- src/test/integtests/net/NetworkTests.cpp | 2 +- .../integtests/platform/MSWindowsKeyStateTests.cpp | 1 - .../integtests/platform/XWindowsKeyStateTests.cpp | 35 +- .../integtests/platform/XWindowsScreenTests.cpp | 5 +- src/test/mock/barrier/MockEventQueue.h | 2 +- src/test/unittests/CMakeLists.txt | 3 +- src/test/unittests/barrier/ClipboardChunkTests.cpp | 52 -- 191 files changed, 2104 insertions(+), 1779 deletions(-) create mode 100644 src/gui/res/icons/32x32/barrier-connected-mask.png create mode 100644 src/gui/res/icons/32x32/barrier-connected-mask.svg create mode 100644 src/gui/res/icons/32x32/barrier-disconnected-mask.png create mode 100644 src/gui/res/icons/32x32/barrier-disconnected-mask.svg create mode 100644 src/gui/res/icons/32x32/barrier-transfering-mask.png create mode 100644 src/gui/res/icons/32x32/barrier-transfering-mask.svg delete mode 100644 src/lib/common/stdexcept.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3a8e83e..55aad09 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,6 +19,7 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}/lib) add_subdirectory(lib) add_subdirectory(cmd) +add_subdirectory(test) if (BARRIER_BUILD_GUI) add_subdirectory(gui) diff --git a/src/cmd/barriers/barriers.cpp b/src/cmd/barriers/barriers.cpp index cd67bcb..21c4d80 100644 --- a/src/cmd/barriers/barriers.cpp +++ b/src/cmd/barriers/barriers.cpp @@ -38,6 +38,13 @@ main(int argc, char** argv) // record window instance for tray icon, etc ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL)); #endif + +#ifdef __APPLE__ + /* Silence "is calling TIS/TSM in non-main thread environment" as it is a red + herring that causes a lot of issues to be filed for the MacOS client/server. + */ + setenv("OS_ACTIVITY_DT_MODE", "NO", true); +#endif Arch arch; arch.init(); diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 9eaa67e..f29fd91 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.4) -find_package (Qt5 COMPONENTS Core Widgets Network) +find_package (Qt5 REQUIRED COMPONENTS Core Widgets Network) set (CMAKE_AUTOMOC ON) set (CMAKE_AUTORCC ON) set (CMAKE_AUTOUIC ON) @@ -48,6 +48,6 @@ target_link_libraries (barrier common) if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") install (TARGETS barrier DESTINATION ${BARRIER_BUNDLE_BINARY_DIR}) -elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "BSD") install (TARGETS barrier DESTINATION bin) endif() diff --git a/src/gui/res/Barrier.qrc b/src/gui/res/Barrier.qrc index 39da79e..ee6127d 100644 --- a/src/gui/res/Barrier.qrc +++ b/src/gui/res/Barrier.qrc @@ -54,5 +54,8 @@ image/spinning-wheel.gif icons/16x16/padlock.png icons/16x16/barrier-transfering.png + icons/32x32/barrier-connected-mask.png + icons/32x32/barrier-disconnected-mask.png + icons/32x32/barrier-transfering-mask.png diff --git a/src/gui/res/icons/32x32/barrier-connected-mask.png b/src/gui/res/icons/32x32/barrier-connected-mask.png new file mode 100644 index 0000000..7e17314 Binary files /dev/null and b/src/gui/res/icons/32x32/barrier-connected-mask.png differ diff --git a/src/gui/res/icons/32x32/barrier-connected-mask.svg b/src/gui/res/icons/32x32/barrier-connected-mask.svg new file mode 100644 index 0000000..e710bff --- /dev/null +++ b/src/gui/res/icons/32x32/barrier-connected-mask.svg @@ -0,0 +1,114 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/gui/res/icons/32x32/barrier-disconnected-mask.png b/src/gui/res/icons/32x32/barrier-disconnected-mask.png new file mode 100644 index 0000000..bedfa75 Binary files /dev/null and b/src/gui/res/icons/32x32/barrier-disconnected-mask.png differ diff --git a/src/gui/res/icons/32x32/barrier-disconnected-mask.svg b/src/gui/res/icons/32x32/barrier-disconnected-mask.svg new file mode 100644 index 0000000..aae4aea --- /dev/null +++ b/src/gui/res/icons/32x32/barrier-disconnected-mask.svg @@ -0,0 +1,102 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/gui/res/icons/32x32/barrier-transfering-mask.png b/src/gui/res/icons/32x32/barrier-transfering-mask.png new file mode 100644 index 0000000..90b69d1 Binary files /dev/null and b/src/gui/res/icons/32x32/barrier-transfering-mask.png differ diff --git a/src/gui/res/icons/32x32/barrier-transfering-mask.svg b/src/gui/res/icons/32x32/barrier-transfering-mask.svg new file mode 100644 index 0000000..ef7126a --- /dev/null +++ b/src/gui/res/icons/32x32/barrier-transfering-mask.svg @@ -0,0 +1,148 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/gui/res/lang/gui_sv.ts b/src/gui/res/lang/gui_sv.ts index 6a8420e..f0c239e 100644 --- a/src/gui/res/lang/gui_sv.ts +++ b/src/gui/res/lang/gui_sv.ts @@ -1,12 +1,14 @@ - + + + AboutDialogBase About Barrier - Om Barrier + Om 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> +Program för att dela tangentbord och mus. Plattformsöverskridande och öppen källkod.<br /><br /> +Copyright © 2012-2016 Symless Ltd.<br /> +Copyright © 2002-2012 Chris Schoeneman, Nick Bolton, Volker Lanz.<br /><br /> +Barrier är släppt under GNU General Public License (GPLv2).<br /><br /> +Barrier baseras på CosmoSynergy av Richard Lee and Adam Feder.<br /> +Barrier GUI baseras på QSynergy av Volker Lanz.<br /><br /> +Besök vår webbplats för hjälp och information (symless.com). +</p> Unknown - Okänd + Okänd Version: - Version: + Version: &Ok - &Ok + &OK @@ -49,97 +59,97 @@ Visit our website for help and info (symless.com). Configure Action - Konfigurera + Konfigurera åtgärd Choose the action to perform - Välj funktion som skall utföras + Välj den åtgärd som skall utföras Press a hotkey - Tryck ned en snabbtangent + Tryck ner en snabbtangent Release a hotkey - Släpp en snabbtangent + Släpp en snabbtangent Press and release a hotkey - Tryck ned och släpp en snabbtangent + Tryck ner och släpp en snabbtangent only on these screens - endast på dessa skärmar + endast på dessa skärmar Switch to screen - Växla till skärm + Växla till skärm Switch in direction - Växla i riktning + Växla i riktning left - vänster + vänster right - höger + höger up - upp + upp down - ner + ner Lock cursor to screen - Lås muspekaren till skärm + Lås muspekaren till skärm toggle - skifta + växla on - + off - Av + av This action is performed when - Detta utförs när + Denna åtgärd utförs när the hotkey is pressed - snabbtangenten trycks in + snabbtangenten trycks ner the hotkey is released - snabbtangenten släpps + snabbtangenten släpps @@ -147,17 +157,17 @@ Visit our website for help and info (symless.com). Dialog - + Dialog TextLabel - + Textetikett Ignore auto connect clients - + Ignorera klienter med automatisk anslutning @@ -165,12 +175,12 @@ Visit our website for help and info (symless.com). Hotkey - Snabbtangent + Snabbtangent Enter the specification for the hotkey: - Beskriv snabbtangenten: + Beskriv snabbtangenten: @@ -178,189 +188,193 @@ Visit our website for help and info (symless.com). &Start - Start + &Starta &File - Arkiv + &Arkiv &Edit - &Redigera + &Redigera &Window - Fönster + &Fönster &Help - Hjälp + &Hjälp <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>Du kör inte den senaste versionen av Barrier. Version <b>%1</b> finns tillgänglig för <a href="%2">nedladdning</a>.</p> + <p>Din version av Barrier är utdaterad. Version <b>%1</b> finns nu tillgänglig för <a href="%2">nerladdning</a>.</p> Program can not be started - Programmet kan inte startas + Programmet kan inte startas 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. - Programmet<br><br>%1<br><br>kunde inte startas, men det finns. Var vänlig och kontrollera att du har tillräckliga rättigheter för att köra detta program. + Programmet<br><br>%1<br><br>kunde inte startas, men det finns tillgängligt. Kontrollera att du har tillräckliga rättigheter för att köra detta program. Barrier client not found - Barrierklienten hittades inte + Barrier-klienten hittades inte The executable for the barrier client does not exist. - Den exekverbara filen för Barrierklienten existerar inte. + Barrier-klientens körbara fil saknas. Hostname is empty - Värddatornamnet är inte satt + Värdnamnet är tomt Please fill in a hostname for the barrier client to connect to. - Fyll i det värddatornamn som Barrierklienten skall ansluta till. + Fyll i det värdnamn som Barrier-klienten skall ansluta till. Cannot write configuration file - Kan inte spara konfigurationsfilen + Kan inte skriva konfigurationsfilen The temporary configuration file required to start barrier can not be written. - Den tillfälliga konfigurationsfilen som krävs för att kunna starta Barrier kan inte skapas. + Den tillfälliga konfigurationsfil som krävs för att starta Barrier, kan inte skrivas. Configuration filename invalid - Namnet på konfigurationsfilen är inte giltigt + Ogiltigt namn på konfigurationsfilen You have not filled in a valid configuration file for the barrier server. Do you want to browse for the configuration file now? - Du har inte fyllt i en giltig konfigurationsfil för Barrierservern. Vill du bläddra efter konfigurationsfilen nu? + Du har inte fyllt i en giltig konfigurationsfil för Barrier-servern. Vill du bläddra efter konfigurationsfilen nu? Barrier server not found - Barrierservern hittades inte + Barrier-servern hittades inte The executable for the barrier server does not exist. - Den körbara filen för Barrierservern existerar inte. + Barrier-serverns körbara fil finns inte. Barrier terminated with an error - Barrier avslutades med ett fel + Barrier avslutades med ett fel Barrier terminated unexpectedly with an exit code of %1.<br><br>Please see the log output for details. - Barrierterminalen avslutades oväntat med avbrottskoden %1.<br><br>Kontrollera loggdatan för detaljer. + Barrier avslutades oväntat med avbrottskoden %1.<br><br>Se loggdata för detaljerad info. &Stop - Stopp + &Stopp Please add the server (%1) to the grid. - + Lägg till servern (%1) i rutfältet. Please drag the new client screen (%1) to the desired position on the grid. - + Dra den nya klientskämen (%1) till önskad position i rutfältet. Failed to detect system architecture. - + Kunde inte identifiera systemarkitektur. Cancel - + Avbryt Failed to download Bonjour installer to location: %1 - + Kunde inte ladda ner Bonjour-installerare till platsen: %1 Do you want to enable auto config and install Bonjour? This feature helps you establish the connection. - + Vill du aktivera automatisk konfiguration och installation av Bonjour? + +Denna funktion hjälper dig att etablera anslutningen. Auto config feature requires Bonjour. Do you want to install Bonjour? - + Automatisk konfiguration kräver Bonjour. + +Vill du installera Bonjour? Barrier is starting. - Barrier startas. + Barrier startar. Barrier is running. - Barrier körs. + Barrier körs. Barrier is not running. - Barrier körs inte. + Barrier körs inte. Unknown - Okänd + Okänd Barrier - Barrier + Barrier Browse for a barriers config file - Bläddra efter Barriers konfigurationsfil. + Bläddra efter Barriers konfigurationsfil Barrier is now connected, You can close the config window. Barrier will remain connected in the background. - + Barrier är nu ansluten, du kan stänga konfigurationsfönstret. Barrier kommer att fortsätta vara ansluten i bakgrunden. Security question - + Säkerhetsfråga @@ -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. - + Litar du på fingeravtrycket? + +%1 + +Detta är en servers fingeravtryck. Du bör jämföra det här fingeravtrycket med det på serverns skärm. Om de två inte stämmer exakt, så är det förmodligen inte den server du förväntar dig (det kan vara en skadlig användare). + +Klicka "Ja" för att automatiskt lita på fingeravtrycket i framtida anslutningar. Klicka "Nej" för att avvisa det här fingeravtrycket och koppla från servern. Save configuration as... - Spara konfiguration som... + Spara konfigurationen som... Save failed - Sparades inte + Kunde inte spara Could not save configuration to file. - Kunde inte spara konfiguration till fil. + Kunde inte spara konfigurationen till fil. @@ -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 (dela den här datorns mus och tangentbord): Screen name: - Skärmnamn: + Skärmnamn: &Server IP: - Serverns IP: + &Serverns IP: &Start - Start + &Starta Use existing configuration: - Använd befintlig konfiguration: + Använd befintlig konfiguration: &Configuration file: - Konfigurationsfil: + &Konfigurationsfil: &Browse... - Bläddra... + &Bläddra... Configure interactively: - Konfigurera interaktivt: + Konfigurera interaktivt: &Configure Server... - Konfigurera server... + &Konfigurera server... Ready - Klar + Klar Log - Logg + Logg &Reload - Verkställ + &Uppdatera IP addresses: - IP-adresser: + IP-adresser: Fingerprint: - + Fingeravtryck: - &Client (use another computer's mouse and keyboard): - + &Client (use another computer's mouse and keyboard): + &Klient (använd en annan dators mus och tangenbord): Auto config - + Konfigurera automatiskt &About Barrier... - Om Barrier... + &Om Barrier... &Quit - Avsluta + A&vsluta Quit - Avsluta + Avsluta Run - Kör + Kör S&top - S&topp + S&topp Stop - Stopp + Stopp S&how Status - Visa Status + V&isa status &Hide - Dölj + &Dölj Hide - Dölj + Dölj &Show - Visa + &Visa Show - Visa + Visa Save configuration &as... - Spara konfiguration som... + S&para konfigurationen som... Save the interactively generated server configuration to a file. - Spara den interaktivt genererade serverkonfigurationen till en fil. + Spara den interaktivt skapade serverkonfigurationen till en fil. Settings - Inställningar + Inställningar Edit settings - Ändra inställningar + Ändra inställningar Run Wizard - Kör guiden + Kör guiden @@ -563,7 +583,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Unnamed - Namnlös + Namnlös @@ -571,28 +591,29 @@ To automatically trust this fingerprint for future connections, click Yes. To re Failed to get plugin directory. - + Kunde inte hämta mappen för insticksmoduler. Failed to get profile directory. - + Kunde inte hämta profilmappen. - Failed to download plugin '%1' to: %2 + Failed to download plugin '%1' to: %2 %3 - + Kunde inte ladda ner insticksmodulen "%1" till: %2 +%3 Could not get Windows architecture type. - + Kunde inte hämta Windows arkitekturtyp. Could not get Linux architecture type. - + Kunde inte hämta Linux arkitekturtyp. @@ -600,48 +621,48 @@ To automatically trust this fingerprint for future connections, click Yes. To re Setup Barrier - Ställ in Barrier + Ställ in Barrier Please wait... - + Vänta... Error: %1 - + Fel: %1 Setup complete. - + Inställning slutförd. - Downloading '%1' plugin (%2/%3)... - + Downloading '%1' plugin (%2/%3)... + Laddar ner "%1" (%2/%3)... Plugins installed successfully. - + Insticksmoduler korrekt installerade. Generating SSL certificate... - + Genererar SSL-certifikat... Downloading plugin: %1 (1/%2) - + Laddar ner insticksmodul: %1 (1/%2) Getting plugin list... - + Hämtar instickslista... @@ -649,17 +670,17 @@ To automatically trust this fingerprint for future connections, click Yes. To re Barrier Configurations (*.sgc);;All files (*.*) - Barrier-konfigurationer (*.sgc);;Alla filer (*.*) + Barrier-konfigurationer (*.sgc);;Alla filer (*.*) Barrier Configurations (*.conf);;All files (*.*) - Barrier-konfigurationer (*.conf);;Alla filer (*.*) + Barrier-konfigurationer (*.conf);;Alla filer (*.*) System tray is unavailable, quitting. - Systemfältet otillgängligt, avslutar. + Systemfältet otillgängligt, avslutar. @@ -667,22 +688,22 @@ To automatically trust this fingerprint for future connections, click Yes. To re Screen name is empty - Skärmnamnet är tomt + Skärmnamnet är tomt The screen name cannot be empty. Please either fill in a name or cancel the dialog. - Skärmnamnet kan inte vara tomt. Fyll i ett namn eller avbryt dialogrutan. + Skärmnamnet kan inte vara tomt. Fyll i ett namn eller avbryt. Screen name matches alias - Skärmnamn matchar alias + Skärmnamnet är samma som alias The screen name cannot be the same as an alias. Please either remove the alias or change the screen name. - Skärmnamnet kan inte vara samma som en alias. Var vänlig att antingen ta bort alias eller ändra skärmnamnet. + Skärmnamnet kan inte vara samma som alias. Ta antingen bort alias eller ändra skärmnamnet. @@ -690,37 +711,37 @@ To automatically trust this fingerprint for future connections, click Yes. To re Screen Settings - Skärminställningar + Skärminställningar Screen &name: - Skärmnamn: + Skärm&namn: A&liases - Alias + A&lias &Add - Lägg till + &Lägg till &Remove - Ta bort + &Ta bort &Modifier keys - Modifieringstangenter + &Modifieringstangenter &Shift: - Shift: + &Shift: @@ -729,7 +750,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Shift - Shift + Shift @@ -738,7 +759,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Ctrl - Ctrl + Ctrl @@ -747,7 +768,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Alt - Alt + Alt @@ -756,7 +777,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Meta - Meta + Meta @@ -765,7 +786,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Super - Super + Super @@ -774,82 +795,82 @@ To automatically trust this fingerprint for future connections, click Yes. To re None - Ingen + Ingen &Ctrl: - &Ctrl: + &Ctrl: Al&t: - Alt: + Al&t: M&eta: - Meta: + M%eta: S&uper: - Super: + S&uper: &Dead corners - Döda hörn + &Döda hörn Top-left - Över vänster + Vänster överkant Top-right - Över höger + Höger överkant Bottom-left - Nedre vänstra hörnet + Vänster underkant Bottom-right - Nedre höger + Höger underkant Corner Si&ze: - Hörnets storlek: + H&örnstorlek: &Fixes - Korrigeringar + &Korrigeringar Fix CAPS LOCK key - Korrigera CAPS LOCK + Korrigera CAPS LOCK Fix NUM LOCK key - Korrigera NUM LOCK + Korrigera NUM LOCK Fix SCROLL LOCK key - Korrigera SCROLL LOCK + Korrigera SCROLL LOCK Fix XTest for Xinerama - Korrigera XTest för Xinerama + Korrigera XTest för Xinerama @@ -857,7 +878,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>Skärm:<b>%1</b></center><br>Dubbelklicka för att ändra inställningar<br>Dra skärmen till papperskorgen för att ta bort den + <center>Skärm:<b>%1</b></center><br>Dubbelklicka för att ändra inställningar<br>Dra skärmen till papperskorgen för att ta bort den @@ -865,7 +886,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re Configure server - + Konfigurera server @@ -873,168 +894,168 @@ To automatically trust this fingerprint for future connections, click Yes. To re Server Configuration - Serverkonfiguration + Serverkonfiguration Screens and links - Skärmar och länkar + Skärmar och länkar Drag a screen from the grid to the trashcan to remove it. - Dra en skärm från rutnätet till papperskorgen för att ta bort den. + Dra en skärm från rutfältet till papperskorgen för att ta bort den. Configure the layout of your barrier server configuration. - Konfigurera layouten på din Barrier-konfiguration. + Konfigurera layouten på din Barrier serverkonfiguration. Drag this button to the grid to add a new screen. - Dra den här knappen till rutnätet för att lägga till en ny skärm. + Dra den här knappen till rutfältet för att lägga till en ny skärm. 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. - Dra nya skärmar till rutnätet eller flytta runt existerande. + Dra nya skärmar till rutfältet eller flytta runt befintliga. Dra en skärm till papperskorgen för att ta bort den. Dubbelklicka på en skärm för att ändra dess inställningar. Hotkeys - Snabbtangenter + Snabbtangenter &Hotkeys - Snabbtangenter + &Snabbtangenter &New - Ny + &Nytt &Edit - &Redigera + &Redigera &Remove - Ta bort + &Ta bort A&ctions - Åtgärder + &Åtgärder Ne&w - Ny + N&ytt E&dit - Ändra + Re&digera Re&move - Ta bort + Ta &bort Advanced server settings - Avancerade serverinställningar + Avancerade serverinställningar &Switch - Växla + &Växla Switch &after waiting - Växla efter väntan + V&äxla efter väntan ms - ms + ms Switch on double &tap within - Växla eller dubbelklicka inuti + Växla vid &dubbelklick inom &Options - Alternativ + &Alternativ &Check clients every - Kontrollera klienter varje + &Kontrollera klienter varje Use &relative mouse moves - Använd relativa musrörelser + Använd &relativa musrörelser S&ynchronize screen savers - Synkronisera skärmsläckare + Synkr&onisera skärmsläckare - Don't take &foreground window on Windows servers - Använd inte förgrundsfönster på Windowsservrar + Don't take &foreground window on Windows servers + Använd inte &förgrundsfönster på Windowsservrar Ignore auto config clients - + Ignorera automatiskt konfigurerade klienter &Dead corners - Döda hörn + &Döda hörn To&p-left - Övre vänstra hörnet + V&änster överkant Top-rig&ht - Övre högra hörnet + H&öger överkant &Bottom-left - Nedre vänstra hörnet + Vänster &underkant Bottom-ri&ght - Nedre högra hörnet + Höger u&nderkant Cor&ner Size: - Hörnstorlek: + Hö&rnstorlek: @@ -1042,20 +1063,20 @@ Dubbelklicka på en skärm för att ändra dess inställningar. Save log file to... - Spara loggfil till... + Spara loggfil till... Elevate Barrier - Förhöj Barriers behörighet + Höj Barriers behörighet 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. - Är du säker på att du vill förhöja Barriers behörighet? -Detta låter Barrier interagera med förhöjda processer och UAC-dialogen, men kan skapa program med processer som inte är förhöjda. Förhöj Barriers behörighet enbart om du verkligen måste. + Vill du verkligen höja Barriers behörighet? +Detta låter Barrier interagera med förhöjda processer och UAC-dialogen, men kan skapa program med processer som inte är förhöjda. Höj Barriers behörighet enbart om du verkligen måste. @@ -1063,107 +1084,107 @@ Detta låter Barrier interagera med förhöjda processer och UAC-dialogen, men k Settings - Inställningar + Inställningar Sc&reen name: - Skärmnamn: + Sk&ärmnamn: P&ort: - Port: + P&ort: &Interface: - Gränssnitt: + G&ränssnitt: Elevate mode - + Rättighetsläge &Hide on startup - + &Dölj vid programstart &Network Security - + &Nätverkssäkerhet Use &SSL encryption (unique certificate) - + Använd &SSL-kryptering (unikt certifikat) Logging - Loggning + Loggning &Logging level: - Loggningsnivå: + &Loggningsnivå: Log to file: - Logga till fil: + Logga till fil: Browse... - Bläddra: + Bläddra... Error - Fel + Fel &Language: - Språk: + &Språk: &Miscellaneous - &Övrigt + &Diverse Warning - Varning + Varning Note - Notering + Anteckning Info - Info + Information Debug - Felsök + Felsök Debug1 - Felsök1 + Felsök1 Debug2 - Felsök2 + Felsök2 @@ -1171,17 +1192,17 @@ Detta låter Barrier interagera med förhöjda processer och UAC-dialogen, men k Setup Barrier - Ställ in Barrier + Ställ in Barrier Please select an option. - Välj ett alternativ. + Välj ett alternativ. Please enter your email address and password. - Var vänlig skriv din e-postaddress och lösenord. + Ange din e-postadress och lösenord. @@ -1189,85 +1210,93 @@ Detta låter Barrier interagera med förhöjda processer och UAC-dialogen, men k Setup Barrier - Ställ in Barrier + Installera Barrier Welcome - Välkommen + Välkommen Thanks for installing Barrier! - Tack för att du installerar Barrier! + Tack för att du installerar 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). - Med Barrier kan du enkelt dela din mus och ditt tangentbord med flera datorer på ditt skrivbord, och det är Fri och Öppen mjukvara. För bara muspekaren över kanten på en datorskärm för att den skall dyka upp på nästa. Du kan till och med dela utklipp. Allt du behöver är en nätverksanslutning. Barrier är multiplattform (fungerar på både Windows, Mac OS X och 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). + Med Barrier kan du enkelt dela din mus och ditt tangentbord mellan flera datorer på ditt skrivbord, och det är fri och öppen källkod. För bara muspekaren över kanten på en datorskärm till en annan. Du kan till och med dela urklipp. Allt du behöver är en nätverksanslutning. Barrier är multiplattform (fungerar på både Windows, OSX och Linux). Activate - + Aktivera &Activate now... - + &Aktivera nu... Email: - + E-post: Password: - + Lösenord: <a href="https://symless.com/account/reset/">Forgot password</a> - + <a href="https://symless.com/account/reset/">Glömt lösenord</a> &Skip activation - + &Skippa aktivering - &Server (share this computer's mouse and keyboard) - + &Server (share this computer's mouse and keyboard) + &Server (dela denna dators mus och tangentbord) <!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;">Min primära mus och tangentbord är anslutna till den här datorn. Detta låter dig flytta musen över till en annan dators skärm. Det kan bara finnas en server i din installation.</span></p></body></html> - &Client (use another computer's mouse and keyboard) - + &Client (use another computer's mouse and keyboard) + &Klient (använd en annan dators mus och tangentbord) <!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;">Du har redan installerat en server. Den här datorn styrs med hjälp av serverns mus och tangentbord. Det kan finnas många klienter i din installation.</span></p></body></html> Server or Client? - Server eller klient? + Server eller klient? @@ -1275,22 +1304,22 @@ p, li { white-space: pre-wrap; } Failed to get profile directory. - + Kunde inte hämta profilmappen. SSL certificate generated. - + SSL-certifikat genererat. SSL fingerprint generated. - + SSL-fingeravtryck genererat. Failed to find SSL fingerprint. - + Kunde inte hitta SSL-fingeravtryck. @@ -1298,7 +1327,7 @@ p, li { white-space: pre-wrap; } Unknown - Okänd + Okänd @@ -1308,19 +1337,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 - + Ett fel uppstod när du försökte logga in. Kontakta supporten och ange följande uppgifter. + +%1 Login failed, invalid email or password. - Inloggning misslyckades, ogiltig e-postaddress eller lösenord. + Inloggning misslyckades. Ogiltig e-postaddress eller lösenord. Login failed, an error occurred. %1 - Inloggning misslyckades, ett problem inträffade. + Inloggning misslyckades. Ett fel uppstod. + %1 @@ -1330,8 +1362,10 @@ p, li { white-space: pre-wrap; } Server response: %1 - Inloggning misslyckades, ett problem inträffade. -Server svar: + Inloggning misslyckades. Ett fel uppstod. + +Serversvar: + %1 @@ -1339,19 +1373,23 @@ Server svar: An error occurred while trying to query the plugin list. Please contact the help desk, and provide the following details. %1 - + Ett fel uppstod när instickslistan anropades. Kontakta supporten och ange följande uppgifter. + +%1 Get plugin list failed, invalid user email or password. - + Kunde inte hämta instickslistan. Ogiltig e-postadress eller lösenord. Get plugin list failed, an error occurred. %1 - + Kunde inte hämta instickslistan. Ett fel uppstod. + +%1 @@ -1360,7 +1398,11 @@ Server svar: Server response: %1 - + Kunde inte hämta instickslistan. Ett fel uppstod. + +Serversvar: + +%1 @@ -1368,44 +1410,44 @@ Server response: zeroconf server detected: %1 - + zeroconf-server identifierad: %1 zeroconf client detected: %1 - + zeroconf-klient identifierad: %1 Zero configuration service - + Zero konfigurationstjänst Error code: %1. - + Felkod:%1. Unable to start the zeroconf: %1. - + Kunde inte starta zeroconf: %1. Barrier - Barrier + Barrier Failed to get local IP address. Please manually type in server address on your clients - + Kunde inte inhämta lokal IP-adress. Skriv in serveradressen manuellt, på dina klienter. %1 - + %1 - \ No newline at end of file + diff --git a/src/gui/src/Action.cpp b/src/gui/src/Action.cpp index 2e0f339..909e983 100644 --- a/src/gui/src/Action.cpp +++ b/src/gui/src/Action.cpp @@ -24,7 +24,8 @@ const char* Action::m_ActionTypeNames[] = { "keyDown", "keyUp", "keystroke", - "switchToScreen", "switchInDirection", "lockCursorToScreen", + "switchToScreen", "toggleScreen", + "switchInDirection", "lockCursorToScreen", "mouseDown", "mouseUp", "mousebutton" }; @@ -45,7 +46,13 @@ Action::Action() : QString Action::text() const { - QString text = QString(m_ActionTypeNames[keySequence().isMouseButton() ? type() + 6 : type() ]) + "("; + /* This function is used to save to config file which is for barriers to + * read. However the server config parse does not support functions with () + * 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() ? + type() + int(mouseDown) : type()]); switch (type()) { @@ -53,6 +60,7 @@ QString Action::text() const case keyUp: case keystroke: { + text += "("; text += keySequence().toString(); if (!keySequence().isMouseButton()) @@ -72,19 +80,29 @@ QString Action::text() const else text += ",*"; } + text += ")"; } break; case switchToScreen: + text += "("; text += switchScreenName(); + text += ")"; + break; + + case toggleScreen: break; case switchInDirection: + text += "("; text += m_SwitchDirectionNames[m_SwitchDirection]; + text += ")"; break; case lockCursorToScreen: + text += "("; text += m_LockCursorModeNames[m_LockCursorMode]; + text += ")"; break; default: @@ -92,7 +110,6 @@ QString Action::text() const break; } - text += ")"; return text; } diff --git a/src/gui/src/Action.h b/src/gui/src/Action.h index 2786842..b738f3b 100644 --- a/src/gui/src/Action.h +++ b/src/gui/src/Action.h @@ -36,7 +36,9 @@ class Action friend QTextStream& operator<<(QTextStream& outStream, const Action& action); public: - enum ActionType { keyDown, keyUp, keystroke, switchToScreen, switchInDirection, lockCursorToScreen, mouseDown, mouseUp, mousebutton }; + enum ActionType { keyDown, keyUp, keystroke, + switchToScreen, toggleScreen, switchInDirection, + lockCursorToScreen, mouseDown, mouseUp, mousebutton }; enum SwitchDirection { switchLeft, switchRight, switchUp, switchDown }; enum LockCursorMode { lockCursorToggle, lockCursonOn, lockCursorOff }; diff --git a/src/gui/src/ActionDialog.cpp b/src/gui/src/ActionDialog.cpp index 3565cfb..2796885 100644 --- a/src/gui/src/ActionDialog.cpp +++ b/src/gui/src/ActionDialog.cpp @@ -39,7 +39,7 @@ ActionDialog::ActionDialog(QWidget* parent, ServerConfig& config, Hotkey& hotkey // work around Qt Designer's lack of a QButtonGroup; we need it to get // at the button id of the checked radio button - QRadioButton* const typeButtons[] = { m_pRadioPress, m_pRadioRelease, m_pRadioPressAndRelease, m_pRadioSwitchToScreen, m_pRadioSwitchInDirection, m_pRadioLockCursorToScreen }; + QRadioButton* const typeButtons[] = { m_pRadioPress, m_pRadioRelease, m_pRadioPressAndRelease, m_pRadioSwitchToScreen, m_pRadioToggleScreen, m_pRadioSwitchInDirection, m_pRadioLockCursorToScreen }; for (unsigned int i = 0; i < sizeof(typeButtons) / sizeof(typeButtons[0]); i++) m_pButtonGroupType->addButton(typeButtons[i], i); diff --git a/src/gui/src/ActionDialogBase.ui b/src/gui/src/ActionDialogBase.ui index f6dff78..9c6ad0a 100644 --- a/src/gui/src/ActionDialogBase.ui +++ b/src/gui/src/ActionDialogBase.ui @@ -142,6 +142,17 @@ + + + + + + Toggle screen + + + + + diff --git a/src/gui/src/BaseConfig.h b/src/gui/src/BaseConfig.h index 2a34969..cf41ac6 100644 --- a/src/gui/src/BaseConfig.h +++ b/src/gui/src/BaseConfig.h @@ -26,61 +26,97 @@ class BaseConfig { - public: - enum Modifier { DefaultMod = -1, Shift, Ctrl, Alt, Meta, Super, None, NumModifiers }; - enum SwitchCorner { TopLeft, TopRight, BottomLeft, BottomRight, NumSwitchCorners }; - enum Fix { CapsLock, NumLock, ScrollLock, XTest, PreserveFocus, NumFixes }; +public: + enum class Modifier { + DefaultMod = -1, + Shift, + Ctrl, + Alt, + Meta, + Super, + None, + Count + }; + + enum class SwitchCorner { + TopLeft, + TopRight, + BottomLeft, + BottomRight, + Count + }; + + enum class Fix { + CapsLock, + NumLock, + ScrollLock, + XTest, + PreserveFocus, + Count + }; protected: BaseConfig() {} virtual ~BaseConfig() {} protected: - template - void readSettings(QSettings& settings, T1& array, const QString& arrayName, const T2& deflt) + template + void readSettings(QSettings& settings, QList& array, const QString& arrayName, + const T& deflt) { int entries = settings.beginReadArray(arrayName + "Array"); array.clear(); for (int i = 0; i < entries; i++) { settings.setArrayIndex(i); - QVariant v = settings.value(arrayName, deflt); - array.append(v.value()); + QVariant v = settings.value(arrayName, static_cast(deflt)); + array.append(static_cast(v.value())); } settings.endArray(); } - template - void readSettings(QSettings& settings, T1& array, const QString& arrayName, const T2& deflt, int entries) + template + void readSettings(QSettings& settings, QList& array, const QString& arrayName, + const T& deflt, int entries) { Q_ASSERT(array.size() >= entries); settings.beginReadArray(arrayName + "Array"); for (int i = 0; i < entries; i++) { settings.setArrayIndex(i); - QVariant v = settings.value(arrayName, deflt); - array[i] = v.value(); + QVariant v = settings.value(arrayName, static_cast(deflt)); + array[i] = static_cast(v.value()); } settings.endArray(); } - template - void writeSettings(QSettings& settings, const T& array, const QString& arrayName) const + template + void writeSettings(QSettings& settings, const QList& array, + const QString& arrayName) const { settings.beginWriteArray(arrayName + "Array"); for (int i = 0; i < array.size(); i++) { settings.setArrayIndex(i); - settings.setValue(arrayName, array[i]); + settings.setValue(arrayName, static_cast(array[i])); } settings.endArray(); } public: - static const char* modifierName(int idx) { return m_ModifierNames[idx]; } - static const char* fixName(int idx) { return m_FixNames[idx]; } - static const char* switchCornerName(int idx) { return m_SwitchCornerNames[idx]; } + static const char* modifierName(Modifier idx) + { + return m_ModifierNames[static_cast(idx)]; + } + static const char* fixName(Fix idx) + { + return m_FixNames[static_cast(idx)]; + } + static const char* switchCornerName(SwitchCorner idx) + { + return m_SwitchCornerNames[static_cast(idx)]; + } private: static const char* m_ModifierNames[]; diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index bcbb15b..01133bf 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -67,10 +67,17 @@ static const QString barrierConfigFilter(QObject::tr("Barrier Configurations (*. static const char* barrierIconFiles[] = { +#if defined(Q_OS_MAC) + ":/res/icons/32x32/barrier-disconnected-mask.png", + ":/res/icons/32x32/barrier-disconnected-mask.png", + ":/res/icons/32x32/barrier-connected-mask.png", + ":/res/icons/32x32/barrier-transfering-mask.png" +#else ":/res/icons/16x16/barrier-disconnected.png", ":/res/icons/16x16/barrier-disconnected.png", ":/res/icons/16x16/barrier-connected.png", ":/res/icons/16x16/barrier-transfering.png" +#endif }; static const char* barrierLargeIcon = ":/res/icons/256x256/barrier.ico"; @@ -288,8 +295,13 @@ void MainWindow::saveSettings() void MainWindow::setIcon(qBarrierState state) { - if (m_pTrayIcon) - m_pTrayIcon->setIcon(QIcon(barrierIconFiles[state])); + if (m_pTrayIcon) { + QIcon icon = QIcon(barrierIconFiles[state]); +#if defined(Q_OS_MAC) + icon.setIsMask(true); +#endif + m_pTrayIcon->setIcon(icon); + } } void MainWindow::trayActivated(QSystemTrayIcon::ActivationReason reason) @@ -333,7 +345,9 @@ void MainWindow::logError() void MainWindow::appendLogInfo(const QString& text) { - m_pLogWindow->appendInfo(text); + if (appConfig().logLevel() >= 3) { + m_pLogWindow->appendInfo(text); + } } void MainWindow::appendLogDebug(const QString& text) { @@ -524,10 +538,7 @@ void MainWindow::startBarrier() qDebug() << args; - // show command if debug log level... - if (appConfig().logLevel() >= 4) { - appendLogInfo(QString("command: %1 %2").arg(app, args.join(" "))); - } + appendLogDebug(QString("command: %1 %2").arg(app, args.join(" "))); appendLogInfo("config file: " + configFilename()); appendLogInfo("log level: " + appConfig().logLevelText()); @@ -584,9 +595,7 @@ bool MainWindow::clientArgs(QStringList& args, QString& app) args << "[" + serverIp + "]:" + QString::number(appConfig().port()); return true; } - } - - if (m_pLineEditHostname->text().isEmpty()) { + } else if (m_pLineEditHostname->text().isEmpty()) { show(); if (!m_SuppressEmptyServerWarning) { QMessageBox::warning(this, tr("Hostname is empty"), @@ -944,6 +953,7 @@ void MainWindow::updateSSLFingerprint() } if (m_AppConfig->getCryptoEnabled() && Fingerprint::local().fileExists()) { m_pLabelLocalFingerprint->setText(Fingerprint::local().readFirst()); + m_pLabelLocalFingerprint->setTextInteractionFlags(Qt::TextSelectableByMouse); } else { m_pLabelLocalFingerprint->setText("Disabled"); } diff --git a/src/gui/src/Screen.cpp b/src/gui/src/Screen.cpp index 880e78c..38d02e8 100644 --- a/src/gui/src/Screen.cpp +++ b/src/gui/src/Screen.cpp @@ -47,13 +47,13 @@ void Screen::init() // m_Modifiers, m_SwitchCorners and m_Fixes are QLists we use like fixed-size arrays, // thus we need to make sure to fill them with the required number of elements. - for (int i = 0; i < NumModifiers; i++) - modifiers() << i; + for (int i = 0; i < static_cast(Modifier::Count); i++) + modifiers() << static_cast(i); - for (int i = 0; i < NumSwitchCorners; i++) + for (int i = 0; i < static_cast(SwitchCorner::Count); i++) switchCorners() << false; - for (int i = 0; i < NumFixes; i++) + for (int i = 0; i < static_cast(Fix::Count); i++) fixes() << false; } @@ -66,10 +66,12 @@ void Screen::loadSettings(QSettings& settings) setSwitchCornerSize(settings.value("switchCornerSize").toInt()); - readSettings(settings, aliases(), "alias", QString("")); - readSettings(settings, modifiers(), "modifier", static_cast(DefaultMod), NumModifiers); - readSettings(settings, switchCorners(), "switchCorner", false, NumSwitchCorners); - readSettings(settings, fixes(), "fix", false, NumFixes); + readSettings(settings, aliases(), "alias", QString("")); + readSettings(settings, modifiers(), "modifier", Modifier::DefaultMod, + static_cast(Modifier::Count)); + readSettings(settings, switchCorners(), "switchCorner", false, + static_cast(SwitchCorner::Count)); + readSettings(settings, fixes(), "fix", false, static_cast(Fix::Count)); } void Screen::saveSettings(QSettings& settings) const @@ -81,27 +83,35 @@ void Screen::saveSettings(QSettings& settings) const settings.setValue("switchCornerSize", switchCornerSize()); - writeSettings(settings, aliases(), "alias"); - writeSettings(settings, modifiers(), "modifier"); - writeSettings(settings, switchCorners(), "switchCorner"); - writeSettings(settings, fixes(), "fix"); + writeSettings(settings, aliases(), "alias"); + writeSettings(settings, modifiers(), "modifier"); + writeSettings(settings, switchCorners(), "switchCorner"); + writeSettings(settings, fixes(), "fix"); } QTextStream& Screen::writeScreensSection(QTextStream& outStream) const { outStream << "\t" << name() << ":" << endl; - for (int i = 0; i < modifiers().size(); i++) - if (modifier(i) != i) - outStream << "\t\t" << modifierName(i) << " = " << modifierName(modifier(i)) << endl; + for (int i = 0; i < modifiers().size(); i++) { + auto mod = static_cast(i); + if (modifier(mod) != mod) { + outStream << "\t\t" << modifierName(mod) << " = " << modifierName(modifier(mod)) + << endl; + } + } - for (int i = 0; i < fixes().size(); i++) - outStream << "\t\t" << fixName(i) << " = " << (fixes()[i] ? "true" : "false") << endl; + for (int i = 0; i < fixes().size(); i++) { + auto fix = static_cast(i); + outStream << "\t\t" << fixName(fix) << " = " << (fixes()[i] ? "true" : "false") << endl; + } outStream << "\t\t" << "switchCorners = none "; - for (int i = 0; i < switchCorners().size(); i++) - if (switchCorners()[i]) - outStream << "+" << switchCornerName(i) << " "; + for (int i = 0; i < switchCorners().size(); i++) { + if (switchCorners()[i]) { + outStream << "+" << switchCornerName(static_cast(i)) << " "; + } + } outStream << endl; outStream << "\t\t" << "switchCornerSize = " << switchCornerSize() << endl; @@ -124,11 +134,16 @@ QTextStream& Screen::writeAliasesSection(QTextStream& outStream) const QDataStream& operator<<(QDataStream& outStream, const Screen& screen) { + QList modifiers; + for (auto mod : screen.modifiers()) { + modifiers.push_back(static_cast(mod)); + } + return outStream << screen.name() << screen.switchCornerSize() << screen.aliases() - << screen.modifiers() + << modifiers << screen.switchCorners() << screen.fixes() ; @@ -136,12 +151,18 @@ QDataStream& operator<<(QDataStream& outStream, const Screen& screen) QDataStream& operator>>(QDataStream& inStream, Screen& screen) { + QList modifiers; return inStream >> screen.m_Name >> screen.m_SwitchCornerSize >> screen.m_Aliases - >> screen.m_Modifiers + >> modifiers >> screen.m_SwitchCorners >> screen.m_Fixes ; + + screen.m_Modifiers.clear(); + for (auto mod : modifiers) { + screen.m_Modifiers.push_back(static_cast(mod)); + } } diff --git a/src/gui/src/Screen.h b/src/gui/src/Screen.h index 6d9c668..d728af1 100644 --- a/src/gui/src/Screen.h +++ b/src/gui/src/Screen.h @@ -50,12 +50,17 @@ class Screen : public BaseConfig const QStringList& aliases() const { return m_Aliases; } bool isNull() const { return m_Name.isEmpty(); } - int modifier(int m) const { return m_Modifiers[m] == DefaultMod ? m : m_Modifiers[m]; } - const QList& modifiers() const { return m_Modifiers; } - bool switchCorner(int c) const { return m_SwitchCorners[c]; } + Modifier modifier(Modifier m) const + { + Modifier overriddenModifier = m_Modifiers[static_cast(m)]; + return overriddenModifier == Modifier::DefaultMod ? m : overriddenModifier; + } + + const QList& modifiers() const { return m_Modifiers; } + bool switchCorner(SwitchCorner c) const { return m_SwitchCorners[static_cast(c)]; } const QList& switchCorners() const { return m_SwitchCorners; } int switchCornerSize() const { return m_SwitchCornerSize; } - bool fix(Fix f) const { return m_Fixes[f]; } + bool fix(Fix f) const { return m_Fixes[static_cast(f)]; } const QList& fixes() const { return m_Fixes; } void loadSettings(QSettings& settings); @@ -73,13 +78,13 @@ class Screen : public BaseConfig void setPixmap(const QPixmap& pixmap) { m_Pixmap = pixmap; } QStringList& aliases() { return m_Aliases; } - void setModifier(int m, int n) { m_Modifiers[m] = n; } - QList& modifiers() { return m_Modifiers; } + void setModifier(Modifier m, Modifier n) { m_Modifiers[static_cast(m)] = n; } + QList& modifiers() { return m_Modifiers; } void addAlias(const QString& alias) { m_Aliases.append(alias); } - void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; } + void setSwitchCorner(SwitchCorner c, bool on) { m_SwitchCorners[static_cast(c)] = on; } QList& switchCorners() { return m_SwitchCorners; } void setSwitchCornerSize(int val) { m_SwitchCornerSize = val; } - void setFix(int f, bool on) { m_Fixes[f] = on; } + void setFix(Fix f, bool on) { m_Fixes[static_cast(f)] = on; } QList& fixes() { return m_Fixes; } void setSwapped(bool on) { m_Swapped = on; } @@ -88,7 +93,7 @@ class Screen : public BaseConfig QString m_Name; QStringList m_Aliases; - QList m_Modifiers; + QList m_Modifiers; QList m_SwitchCorners; int m_SwitchCornerSize; QList m_Fixes; diff --git a/src/gui/src/ScreenSettingsDialog.cpp b/src/gui/src/ScreenSettingsDialog.cpp index 3023b6d..123bb8a 100644 --- a/src/gui/src/ScreenSettingsDialog.cpp +++ b/src/gui/src/ScreenSettingsDialog.cpp @@ -52,23 +52,23 @@ ScreenSettingsDialog::ScreenSettingsDialog(QWidget* parent, Screen* pScreen) : for (int i = 0; i < m_pScreen->aliases().count(); i++) new QListWidgetItem(m_pScreen->aliases()[i], m_pListAliases); - m_pComboBoxShift->setCurrentIndex(m_pScreen->modifier(Screen::Shift)); - m_pComboBoxCtrl->setCurrentIndex(m_pScreen->modifier(Screen::Ctrl)); - m_pComboBoxAlt->setCurrentIndex(m_pScreen->modifier(Screen::Alt)); - m_pComboBoxMeta->setCurrentIndex(m_pScreen->modifier(Screen::Meta)); - m_pComboBoxSuper->setCurrentIndex(m_pScreen->modifier(Screen::Super)); - - m_pCheckBoxCornerTopLeft->setChecked(m_pScreen->switchCorner(Screen::TopLeft)); - m_pCheckBoxCornerTopRight->setChecked(m_pScreen->switchCorner(Screen::TopRight)); - m_pCheckBoxCornerBottomLeft->setChecked(m_pScreen->switchCorner(Screen::BottomLeft)); - m_pCheckBoxCornerBottomRight->setChecked(m_pScreen->switchCorner(Screen::BottomRight)); + m_pComboBoxShift->setCurrentIndex(static_cast(m_pScreen->modifier(Screen::Modifier::Shift))); + m_pComboBoxCtrl->setCurrentIndex(static_cast(m_pScreen->modifier(Screen::Modifier::Ctrl))); + m_pComboBoxAlt->setCurrentIndex(static_cast(m_pScreen->modifier(Screen::Modifier::Alt))); + m_pComboBoxMeta->setCurrentIndex(static_cast(m_pScreen->modifier(Screen::Modifier::Meta))); + m_pComboBoxSuper->setCurrentIndex(static_cast(m_pScreen->modifier(Screen::Modifier::Super))); + + m_pCheckBoxCornerTopLeft->setChecked(m_pScreen->switchCorner(Screen::SwitchCorner::TopLeft)); + m_pCheckBoxCornerTopRight->setChecked(m_pScreen->switchCorner(Screen::SwitchCorner::TopRight)); + m_pCheckBoxCornerBottomLeft->setChecked(m_pScreen->switchCorner(Screen::SwitchCorner::BottomLeft)); + m_pCheckBoxCornerBottomRight->setChecked(m_pScreen->switchCorner(Screen::SwitchCorner::BottomRight)); m_pSpinBoxSwitchCornerSize->setValue(m_pScreen->switchCornerSize()); - m_pCheckBoxCapsLock->setChecked(m_pScreen->fix(Screen::CapsLock)); - m_pCheckBoxNumLock->setChecked(m_pScreen->fix(Screen::NumLock)); - m_pCheckBoxScrollLock->setChecked(m_pScreen->fix(Screen::ScrollLock)); - m_pCheckBoxXTest->setChecked(m_pScreen->fix(Screen::XTest)); - m_pCheckBoxPreserveFocus->setChecked(m_pScreen->fix(Screen::PreserveFocus)); + m_pCheckBoxCapsLock->setChecked(m_pScreen->fix(Screen::Fix::CapsLock)); + m_pCheckBoxNumLock->setChecked(m_pScreen->fix(Screen::Fix::NumLock)); + m_pCheckBoxScrollLock->setChecked(m_pScreen->fix(Screen::Fix::ScrollLock)); + m_pCheckBoxXTest->setChecked(m_pScreen->fix(Screen::Fix::XTest)); + m_pCheckBoxPreserveFocus->setChecked(m_pScreen->fix(Screen::Fix::PreserveFocus)); } void ScreenSettingsDialog::accept() @@ -100,23 +100,28 @@ void ScreenSettingsDialog::accept() m_pScreen->addAlias(alias); } - m_pScreen->setModifier(Screen::Shift, m_pComboBoxShift->currentIndex()); - m_pScreen->setModifier(Screen::Ctrl, m_pComboBoxCtrl->currentIndex()); - m_pScreen->setModifier(Screen::Alt, m_pComboBoxAlt->currentIndex()); - m_pScreen->setModifier(Screen::Meta, m_pComboBoxMeta->currentIndex()); - m_pScreen->setModifier(Screen::Super, m_pComboBoxSuper->currentIndex()); - - m_pScreen->setSwitchCorner(Screen::TopLeft, m_pCheckBoxCornerTopLeft->isChecked()); - m_pScreen->setSwitchCorner(Screen::TopRight, m_pCheckBoxCornerTopRight->isChecked()); - m_pScreen->setSwitchCorner(Screen::BottomLeft, m_pCheckBoxCornerBottomLeft->isChecked()); - m_pScreen->setSwitchCorner(Screen::BottomRight, m_pCheckBoxCornerBottomRight->isChecked()); + m_pScreen->setModifier(Screen::Modifier::Shift, + static_cast(m_pComboBoxShift->currentIndex())); + m_pScreen->setModifier(Screen::Modifier::Ctrl, + static_cast(m_pComboBoxCtrl->currentIndex())); + m_pScreen->setModifier(Screen::Modifier::Alt, + static_cast(m_pComboBoxAlt->currentIndex())); + m_pScreen->setModifier(Screen::Modifier::Meta, + static_cast(m_pComboBoxMeta->currentIndex())); + m_pScreen->setModifier(Screen::Modifier::Super, + static_cast(m_pComboBoxSuper->currentIndex())); + + m_pScreen->setSwitchCorner(Screen::SwitchCorner::TopLeft, m_pCheckBoxCornerTopLeft->isChecked()); + m_pScreen->setSwitchCorner(Screen::SwitchCorner::TopRight, m_pCheckBoxCornerTopRight->isChecked()); + m_pScreen->setSwitchCorner(Screen::SwitchCorner::BottomLeft, m_pCheckBoxCornerBottomLeft->isChecked()); + m_pScreen->setSwitchCorner(Screen::SwitchCorner::BottomRight, m_pCheckBoxCornerBottomRight->isChecked()); m_pScreen->setSwitchCornerSize(m_pSpinBoxSwitchCornerSize->value()); - m_pScreen->setFix(Screen::CapsLock, m_pCheckBoxCapsLock->isChecked()); - m_pScreen->setFix(Screen::NumLock, m_pCheckBoxNumLock->isChecked()); - m_pScreen->setFix(Screen::ScrollLock, m_pCheckBoxScrollLock->isChecked()); - m_pScreen->setFix(Screen::XTest, m_pCheckBoxXTest->isChecked()); - m_pScreen->setFix(Screen::PreserveFocus, m_pCheckBoxPreserveFocus->isChecked()); + m_pScreen->setFix(Screen::Fix::CapsLock, m_pCheckBoxCapsLock->isChecked()); + m_pScreen->setFix(Screen::Fix::NumLock, m_pCheckBoxNumLock->isChecked()); + m_pScreen->setFix(Screen::Fix::ScrollLock, m_pCheckBoxScrollLock->isChecked()); + m_pScreen->setFix(Screen::Fix::XTest, m_pCheckBoxXTest->isChecked()); + m_pScreen->setFix(Screen::Fix::PreserveFocus, m_pCheckBoxPreserveFocus->isChecked()); QDialog::accept(); } diff --git a/src/gui/src/ServerConfig.cpp b/src/gui/src/ServerConfig.cpp index d7d1a77..9fedd1e 100644 --- a/src/gui/src/ServerConfig.cpp +++ b/src/gui/src/ServerConfig.cpp @@ -88,8 +88,9 @@ void ServerConfig::init() screens().clear(); // m_NumSwitchCorners is used as a fixed size array. See Screen::init() - for (int i = 0; i < NumSwitchCorners; i++) + for (int i = 0; i < static_cast(SwitchCorner::Count); i++) { switchCorners() << false; + } // There must always be screen objects for each cell in the screens QList. Unused screens // are identified by having an empty name. @@ -119,7 +120,7 @@ void ServerConfig::saveSettings() settings().setValue("enableDragAndDrop", enableDragAndDrop()); settings().setValue("clipboardSharing", clipboardSharing()); - writeSettings(settings(), switchCorners(), "switchCorner"); + writeSettings(settings(), switchCorners(), "switchCorner"); settings().beginWriteArray("screens"); for (int i = 0; i < screens().size(); i++) @@ -164,7 +165,8 @@ void ServerConfig::loadSettings() setEnableDragAndDrop(settings().value("enableDragAndDrop", true).toBool()); setClipboardSharing(settings().value("clipboardSharing", true).toBool()); - readSettings(settings(), switchCorners(), "switchCorner", false, NumSwitchCorners); + readSettings(settings(), switchCorners(), "switchCorner", false, + static_cast(SwitchCorner::Count)); int numScreens = settings().beginReadArray("screens"); Q_ASSERT(numScreens <= screens().size()); @@ -258,9 +260,12 @@ QTextStream& operator<<(QTextStream& outStream, const ServerConfig& config) outStream << "\t" << "switchDoubleTap = " << config.switchDoubleTap() << endl; outStream << "\t" << "switchCorners = none "; - for (int i = 0; i < config.switchCorners().size(); i++) - if (config.switchCorners()[i]) - outStream << "+" << config.switchCornerName(i) << " "; + for (int i = 0; i < config.switchCorners().size(); i++) { + auto corner = static_cast(i); + if (config.switchCorners()[i]) { + outStream << "+" << config.switchCornerName(corner) << " "; + } + } outStream << endl; outStream << "\t" << "switchCornerSize = " << config.switchCornerSize() << endl; diff --git a/src/gui/src/ServerConfig.h b/src/gui/src/ServerConfig.h index 65cbbac..c9648b0 100644 --- a/src/gui/src/ServerConfig.h +++ b/src/gui/src/ServerConfig.h @@ -56,7 +56,7 @@ class ServerConfig : public BaseConfig int switchDelay() const { return m_SwitchDelay; } bool hasSwitchDoubleTap() const { return m_HasSwitchDoubleTap; } int switchDoubleTap() const { return m_SwitchDoubleTap; } - bool switchCorner(int c) const { return m_SwitchCorners[c]; } + 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; } @@ -87,7 +87,7 @@ class ServerConfig : public BaseConfig void setSwitchDelay(int val) { m_SwitchDelay = val; } void haveSwitchDoubleTap(bool on) { m_HasSwitchDoubleTap = on; } void setSwitchDoubleTap(int val) { m_SwitchDoubleTap = val; } - void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; } + void setSwitchCorner(SwitchCorner c, bool on) { m_SwitchCorners[static_cast(c)] = on; } void setSwitchCornerSize(int val) { m_SwitchCornerSize = val; } void setIgnoreAutoConfigClient(bool on) { m_IgnoreAutoConfigClient = on; } void setEnableDragAndDrop(bool on) { m_EnableDragAndDrop = on; } diff --git a/src/gui/src/ServerConfigDialog.cpp b/src/gui/src/ServerConfigDialog.cpp index 799cfc8..2e7ffc9 100644 --- a/src/gui/src/ServerConfigDialog.cpp +++ b/src/gui/src/ServerConfigDialog.cpp @@ -48,10 +48,10 @@ ServerConfigDialog::ServerConfigDialog(QWidget* parent, ServerConfig& config, co m_pCheckBoxSwitchDoubleTap->setChecked(serverConfig().hasSwitchDoubleTap()); m_pSpinBoxSwitchDoubleTap->setValue(serverConfig().switchDoubleTap()); - m_pCheckBoxCornerTopLeft->setChecked(serverConfig().switchCorner(BaseConfig::TopLeft)); - m_pCheckBoxCornerTopRight->setChecked(serverConfig().switchCorner(BaseConfig::TopRight)); - m_pCheckBoxCornerBottomLeft->setChecked(serverConfig().switchCorner(BaseConfig::BottomLeft)); - m_pCheckBoxCornerBottomRight->setChecked(serverConfig().switchCorner(BaseConfig::BottomRight)); + m_pCheckBoxCornerTopLeft->setChecked(serverConfig().switchCorner(BaseConfig::SwitchCorner::TopLeft)); + m_pCheckBoxCornerTopRight->setChecked(serverConfig().switchCorner(BaseConfig::SwitchCorner::TopRight)); + m_pCheckBoxCornerBottomLeft->setChecked(serverConfig().switchCorner(BaseConfig::SwitchCorner::BottomLeft)); + m_pCheckBoxCornerBottomRight->setChecked(serverConfig().switchCorner(BaseConfig::SwitchCorner::BottomRight)); m_pSpinBoxSwitchCornerSize->setValue(serverConfig().switchCornerSize()); m_pCheckBoxIgnoreAutoConfigClient->setChecked(serverConfig().ignoreAutoConfigClient()); @@ -95,10 +95,14 @@ void ServerConfigDialog::accept() serverConfig().haveSwitchDoubleTap(m_pCheckBoxSwitchDoubleTap->isChecked()); serverConfig().setSwitchDoubleTap(m_pSpinBoxSwitchDoubleTap->value()); - serverConfig().setSwitchCorner(BaseConfig::TopLeft, m_pCheckBoxCornerTopLeft->isChecked()); - serverConfig().setSwitchCorner(BaseConfig::TopRight, m_pCheckBoxCornerTopRight->isChecked()); - serverConfig().setSwitchCorner(BaseConfig::BottomLeft, m_pCheckBoxCornerBottomLeft->isChecked()); - serverConfig().setSwitchCorner(BaseConfig::BottomRight, m_pCheckBoxCornerBottomRight->isChecked()); + serverConfig().setSwitchCorner(BaseConfig::SwitchCorner::TopLeft, + m_pCheckBoxCornerTopLeft->isChecked()); + serverConfig().setSwitchCorner(BaseConfig::SwitchCorner::TopRight, + m_pCheckBoxCornerTopRight->isChecked()); + serverConfig().setSwitchCorner(BaseConfig::SwitchCorner::BottomLeft, + m_pCheckBoxCornerBottomLeft->isChecked()); + serverConfig().setSwitchCorner(BaseConfig::SwitchCorner::BottomRight, + m_pCheckBoxCornerBottomRight->isChecked()); serverConfig().setSwitchCornerSize(m_pSpinBoxSwitchCornerSize->value()); serverConfig().setIgnoreAutoConfigClient(m_pCheckBoxIgnoreAutoConfigClient->isChecked()); serverConfig().setEnableDragAndDrop(m_pCheckBoxEnableDragAndDrop->isChecked()); diff --git a/src/gui/src/ServerConfigDialogBase.ui b/src/gui/src/ServerConfigDialogBase.ui index c360420..9c2e747 100644 --- a/src/gui/src/ServerConfigDialogBase.ui +++ b/src/gui/src/ServerConfigDialogBase.ui @@ -334,53 +334,67 @@ Double click on a screen to edit its settings. - + - - - true - - - Switch on double &tap within - - + + + + + true + + + Switch on double &tap within + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + 10 + + + 10000 + + + 10 + + + 250 + + + + + + + ms + + + + - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - 10 - - - 10000 - - - 10 - - - 250 - - - - - + - ms + Bump against the screen edge with the mouse pointer twice in quick succession. + + + true diff --git a/src/gui/src/SettingsDialog.cpp b/src/gui/src/SettingsDialog.cpp index 15f7067..24bb86c 100644 --- a/src/gui/src/SettingsDialog.cpp +++ b/src/gui/src/SettingsDialog.cpp @@ -31,8 +31,6 @@ #include #include -static const char networkSecurity[] = "ns"; - SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), Ui::SettingsDialogBase(), @@ -136,4 +134,4 @@ void SettingsDialog::on_m_pComboLanguage_currentIndexChanged(int index) { QString ietfCode = m_pComboLanguage->itemData(index).toString(); QBarrierApplication::getInstance()->switchTranslator(ietfCode); -} \ No newline at end of file +} diff --git a/src/lib/arch/Arch.h b/src/lib/arch/Arch.h index c062d6f..940a2e3 100644 --- a/src/lib/arch/Arch.h +++ b/src/lib/arch/Arch.h @@ -54,9 +54,7 @@ # include "arch/unix/ArchConsoleUnix.h" # include "arch/unix/ArchDaemonUnix.h" # include "arch/unix/ArchLogUnix.h" -# if HAVE_PTHREAD -# include "arch/unix/ArchMultithreadPosix.h" -# endif +# include "arch/unix/ArchMultithreadPosix.h" # include "arch/unix/ArchNetworkBSD.h" # include "arch/unix/ArchSleepUnix.h" # include "arch/unix/ArchStringUnix.h" diff --git a/src/lib/arch/ArchDaemonNone.h b/src/lib/arch/ArchDaemonNone.h index fd59758..e02405f 100644 --- a/src/lib/arch/ArchDaemonNone.h +++ b/src/lib/arch/ArchDaemonNone.h @@ -19,6 +19,7 @@ #pragma once #include "arch/IArchDaemon.h" +#include #define ARCH_DAEMON ArchDaemonNone @@ -46,5 +47,5 @@ public: virtual bool isDaemonInstalled(const char* name); virtual void installDaemon(); virtual void uninstallDaemon(); - virtual std::string commandLine() const; + virtual std::string commandLine() const; }; diff --git a/src/lib/arch/IArchDaemon.h b/src/lib/arch/IArchDaemon.h index a4983d3..23a34f2 100644 --- a/src/lib/arch/IArchDaemon.h +++ b/src/lib/arch/IArchDaemon.h @@ -19,7 +19,7 @@ #pragma once #include "common/IInterface.h" -#include "base/String.h" +#include //! Interface for architecture dependent daemonizing /*! @@ -122,7 +122,7 @@ public: /*! Gets the command line with which the application was started. */ - virtual std::string commandLine() const = 0; + virtual std::string commandLine() const = 0; //@} }; diff --git a/src/lib/arch/IArchTaskBarReceiver.h b/src/lib/arch/IArchTaskBarReceiver.h index 8a925b4..997c8ae 100644 --- a/src/lib/arch/IArchTaskBarReceiver.h +++ b/src/lib/arch/IArchTaskBarReceiver.h @@ -18,8 +18,8 @@ #pragma once -#include "base/String.h" #include "common/IInterface.h" +#include class IScreen; class INode; @@ -88,9 +88,9 @@ public: to set the tooltip is left to sublclasses. Getting and setting the icon must be thread safe. */ - virtual std::string getToolTip() const = 0; + virtual std::string getToolTip() const = 0; - virtual void updateStatus(INode*, const String& errorMsg) = 0; + virtual void updateStatus(INode*, const std::string& errorMsg) = 0; virtual void cleanup() {} diff --git a/src/lib/arch/XArch.h b/src/lib/arch/XArch.h index 457c620..8484d06 100644 --- a/src/lib/arch/XArch.h +++ b/src/lib/arch/XArch.h @@ -20,7 +20,7 @@ #include "common/common.h" #include "common/stdstring.h" -#include "common/stdexcept.h" +#include //! Generic thread exception /*! @@ -56,7 +56,7 @@ string for that error code. class XArchEval { public: XArchEval() { } - virtual ~XArchEval() _NOEXCEPT { } + virtual ~XArchEval() noexcept { } virtual std::string eval() const = 0; }; @@ -66,7 +66,7 @@ class XArch : public std::runtime_error { public: XArch(XArchEval* adopted) : std::runtime_error(adopted->eval()) { delete adopted; } XArch(const std::string& msg) : std::runtime_error(msg) { } - virtual ~XArch() _NOEXCEPT { } + virtual ~XArch() noexcept { } }; // Macro to declare XArch derived types diff --git a/src/lib/arch/unix/ArchInternetUnix.cpp b/src/lib/arch/unix/ArchInternetUnix.cpp index fd1e135..76966dc 100644 --- a/src/lib/arch/unix/ArchInternetUnix.cpp +++ b/src/lib/arch/unix/ArchInternetUnix.cpp @@ -28,8 +28,8 @@ class CurlFacade { public: CurlFacade(); ~CurlFacade(); - String get(const String& url); - String urlEncode(const String& url); + std::string get(const std::string& url); + std::string urlEncode(const std::string& url); private: CURL* m_curl; @@ -39,15 +39,13 @@ private: // ArchInternetUnix // -String -ArchInternetUnix::get(const String& url) +std::string ArchInternetUnix::get(const std::string& url) { CurlFacade curl; return curl.get(url); } -String -ArchInternetUnix::urlEncode(const String& url) +std::string ArchInternetUnix::urlEncode(const std::string& url) { CurlFacade curl; return curl.urlEncode(url); @@ -87,8 +85,7 @@ CurlFacade::~CurlFacade() curl_global_cleanup(); } -String -CurlFacade::get(const String& url) +std::string CurlFacade::get(const std::string& url) { curl_easy_setopt(m_curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, curlWriteCallback); @@ -110,8 +107,7 @@ CurlFacade::get(const String& url) return result; } -String -CurlFacade::urlEncode(const String& url) +std::string CurlFacade::urlEncode(const std::string& url) { char* resultCStr = curl_easy_escape(m_curl, url.c_str(), 0); diff --git a/src/lib/arch/unix/ArchInternetUnix.h b/src/lib/arch/unix/ArchInternetUnix.h index 2413d8f..66de656 100644 --- a/src/lib/arch/unix/ArchInternetUnix.h +++ b/src/lib/arch/unix/ArchInternetUnix.h @@ -19,10 +19,10 @@ #define ARCH_INTERNET ArchInternetUnix -#include "base/String.h" +#include class ArchInternetUnix { public: - String get(const String& url); - String urlEncode(const String& url); + std::string get(const std::string& url); + std::string urlEncode(const std::string& url); }; diff --git a/src/lib/arch/unix/ArchMultithreadPosix.cpp b/src/lib/arch/unix/ArchMultithreadPosix.cpp index c9ddc6c..4866edc 100644 --- a/src/lib/arch/unix/ArchMultithreadPosix.cpp +++ b/src/lib/arch/unix/ArchMultithreadPosix.cpp @@ -36,17 +36,6 @@ #define SIGWAKEUP SIGUSR1 -#if !HAVE_PTHREAD_SIGNAL - // boy, is this platform broken. forget about pthread signal - // handling and let signals through to every process. barrier - // will not terminate cleanly when it gets SIGTERM or SIGINT. -# define pthread_sigmask sigprocmask -# define pthread_kill(tid_, sig_) kill(0, (sig_)) -# define sigwait(set_, sig_) -# undef HAVE_POSIX_SIGWAIT -# define HAVE_POSIX_SIGWAIT 1 -#endif - static void setSignalSet(sigset_t* sigset) @@ -344,9 +333,7 @@ ArchMultithreadPosix::newThread(ThreadFunc func, void* data) // can't tell the difference. if (!m_newThreadCalled) { m_newThreadCalled = true; -#if HAVE_PTHREAD_SIGNAL startSignalHandler(); -#endif } // note that the child thread will wait until we release this mutex diff --git a/src/lib/arch/unix/ArchNetworkBSD.cpp b/src/lib/arch/unix/ArchNetworkBSD.cpp index 2a9259c..496c988 100644 --- a/src/lib/arch/unix/ArchNetworkBSD.cpp +++ b/src/lib/arch/unix/ArchNetworkBSD.cpp @@ -690,7 +690,6 @@ ArchNetworkBSD::nameToAddr(const std::string& name) // allocate address ArchNetAddressImpl* addr = new ArchNetAddressImpl; - char ipstr[INET6_ADDRSTRLEN]; struct addrinfo hints; struct addrinfo *p; int ret; diff --git a/src/lib/arch/unix/XArchUnix.h b/src/lib/arch/unix/XArchUnix.h index ae62f4c..93d6d62 100644 --- a/src/lib/arch/unix/XArchUnix.h +++ b/src/lib/arch/unix/XArchUnix.h @@ -24,7 +24,7 @@ class XArchEvalUnix : public XArchEval { public: XArchEvalUnix(int error) : m_error(error) { } - virtual ~XArchEvalUnix() _NOEXCEPT { } + virtual ~XArchEvalUnix() noexcept { } virtual std::string eval() const; diff --git a/src/lib/arch/win32/ArchInternetWindows.cpp b/src/lib/arch/win32/ArchInternetWindows.cpp index 7f69c7f..8a28fde 100644 --- a/src/lib/arch/win32/ArchInternetWindows.cpp +++ b/src/lib/arch/win32/ArchInternetWindows.cpp @@ -18,6 +18,7 @@ #include "arch/win32/ArchInternetWindows.h" #include "arch/win32/XArchWindows.h" #include "arch/Arch.h" +#include "base/String.h" #include "common/Version.h" #include @@ -25,19 +26,19 @@ #include struct WinINetUrl { - String m_scheme; - String m_host; - String m_path; + std::string m_scheme; + std::string m_host; + std::string m_path; INTERNET_PORT m_port; DWORD m_flags; }; class WinINetRequest { public: - WinINetRequest(const String& url); + WinINetRequest(const std::string& url); ~WinINetRequest(); - String send(); + std::string send(); void openSession(); void connect(); void openRequest(); @@ -54,15 +55,13 @@ private: // ArchInternetWindows // -String -ArchInternetWindows::get(const String& url) +std::string ArchInternetWindows::get(const std::string& url) { WinINetRequest request(url); return request.send(); } -String -ArchInternetWindows::urlEncode(const String& url) +std::string ArchInternetWindows::urlEncode(const std::string& url) { TCHAR buffer[1024]; DWORD bufferSize = sizeof(buffer); @@ -71,7 +70,7 @@ ArchInternetWindows::urlEncode(const String& url) throw XArch(new XArchEvalWindows()); } - String result(buffer); + std::string result(buffer); // the win32 url encoding funcitons are pretty useless (to us) and only // escape "unsafe" chars, but not + or =, so we need to replace these @@ -86,9 +85,9 @@ ArchInternetWindows::urlEncode(const String& url) // WinINetRequest // -static WinINetUrl parseUrl(const String& url); +static WinINetUrl parseUrl(const std::string& url); -WinINetRequest::WinINetRequest(const String& url) : +WinINetRequest::WinINetRequest(const std::string& url) : m_session(NULL), m_connect(NULL), m_request(NULL), @@ -112,8 +111,7 @@ WinINetRequest::~WinINetRequest() } } -String -WinINetRequest::send() +std::string WinINetRequest::send() { if (m_used) { throw XArch("class is one time use."); @@ -124,7 +122,7 @@ WinINetRequest::send() connect(); openRequest(); - String headers("Content-Type: text/html"); + std::string headers("Content-Type: text/html"); if (!HttpSendRequest(m_request, headers.c_str(), (DWORD)headers.length(), NULL, NULL)) { throw XArch(new XArchEvalWindows()); } @@ -142,8 +140,7 @@ WinINetRequest::send() return result.str(); } -void -WinINetRequest::openSession() +void WinINetRequest::openSession() { std::stringstream userAgent; userAgent << "Barrier "; @@ -200,8 +197,7 @@ WinINetRequest::openRequest() // nb: i tried to use InternetCrackUrl here, but couldn't quite get that to // work. here's some (less robust) code to split the url into components. // this works fine with simple urls, but doesn't consider the full url spec. -static WinINetUrl -parseUrl(const String& url) +static WinINetUrl parseUrl(const std::string& url) { WinINetUrl parsed; @@ -215,7 +211,7 @@ parseUrl(const String& url) parsed.m_port = INTERNET_DEFAULT_HTTP_PORT; parsed.m_flags = 0; - if (parsed.m_scheme.find("https") != String::npos) { + if (parsed.m_scheme.find("https") != std::string::npos) { parsed.m_port = INTERNET_DEFAULT_HTTPS_PORT; parsed.m_flags = INTERNET_FLAG_SECURE; } diff --git a/src/lib/arch/win32/ArchInternetWindows.h b/src/lib/arch/win32/ArchInternetWindows.h index bab8d3c..3ef5747 100644 --- a/src/lib/arch/win32/ArchInternetWindows.h +++ b/src/lib/arch/win32/ArchInternetWindows.h @@ -19,10 +19,10 @@ #define ARCH_INTERNET ArchInternetWindows -#include "base/String.h" +#include class ArchInternetWindows { public: - String get(const String& url); - String urlEncode(const String& url); + std::string get(const std::string& url); + std::string urlEncode(const std::string& url); }; diff --git a/src/lib/arch/win32/ArchMiscWindows.cpp b/src/lib/arch/win32/ArchMiscWindows.cpp index 924afa2..2c022b1 100644 --- a/src/lib/arch/win32/ArchMiscWindows.cpp +++ b/src/lib/arch/win32/ArchMiscWindows.cpp @@ -431,7 +431,7 @@ ArchMiscWindows::wakeupDisplay() bool ArchMiscWindows::wasLaunchedAsService() { - String name; + std::string name; if (!getParentProcessName(name)) { LOG((CLOG_ERR "cannot determine if process was launched as service")); return false; @@ -440,8 +440,7 @@ ArchMiscWindows::wasLaunchedAsService() return (name == SERVICE_LAUNCHER); } -bool -ArchMiscWindows::getParentProcessName(String &name) +bool ArchMiscWindows::getParentProcessName(std::string &name) { PROCESSENTRY32 parentEntry; if (!getParentProcessEntry(parentEntry)){ @@ -521,4 +520,4 @@ ArchMiscWindows::setInstanceWin32(HINSTANCE instance) { assert(instance != NULL); s_instanceWin32 = instance; -} \ No newline at end of file +} diff --git a/src/lib/arch/win32/ArchMiscWindows.h b/src/lib/arch/win32/ArchMiscWindows.h index 0ecd79d..91cd8f5 100644 --- a/src/lib/arch/win32/ArchMiscWindows.h +++ b/src/lib/arch/win32/ArchMiscWindows.h @@ -21,7 +21,6 @@ #include "common/common.h" #include "common/stdstring.h" #include "common/stdset.h" -#include "base/String.h" #define WIN32_LEAN_AND_MEAN #include @@ -163,7 +162,7 @@ public: static bool wasLaunchedAsService(); //! Returns true if we got the parent process name. - static bool getParentProcessName(String &name); + static bool getParentProcessName(std::string &name); static HINSTANCE instanceWin32(); diff --git a/src/lib/arch/win32/XArchWindows.cpp b/src/lib/arch/win32/XArchWindows.cpp index eeec0e1..e116eda 100644 --- a/src/lib/arch/win32/XArchWindows.cpp +++ b/src/lib/arch/win32/XArchWindows.cpp @@ -25,7 +25,7 @@ // std::string -XArchEvalWindows::eval() const throw() +XArchEvalWindows::eval() const noexcept { char* cmsg; if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | @@ -51,7 +51,7 @@ XArchEvalWindows::eval() const throw() // std::string -XArchEvalWinsock::eval() const throw() +XArchEvalWinsock::eval() const noexcept { // built-in windows function for looking up error message strings // may not look up network error messages correctly. we'll have diff --git a/src/lib/arch/win32/XArchWindows.h b/src/lib/arch/win32/XArchWindows.h index 10106b1..4fb2a23 100644 --- a/src/lib/arch/win32/XArchWindows.h +++ b/src/lib/arch/win32/XArchWindows.h @@ -30,7 +30,7 @@ public: XArchEvalWindows(DWORD error) : m_error(error) { } virtual ~XArchEvalWindows() { } - virtual std::string eval() const; + virtual std::string eval() const noexcept; private: DWORD m_error; @@ -42,7 +42,7 @@ public: XArchEvalWinsock(int error) : m_error(error) { } virtual ~XArchEvalWinsock() { } - virtual std::string eval() const; + virtual std::string eval() const noexcept; private: int m_error; diff --git a/src/lib/barrier/ClientApp.cpp b/src/lib/barrier/ClientApp.cpp index a91312d..b1a7661 100644 --- a/src/lib/barrier/ClientApp.cpp +++ b/src/lib/barrier/ClientApp.cpp @@ -282,7 +282,9 @@ ClientApp::scheduleClientRestart(double retryTime) void ClientApp::handleClientConnected(const Event&, void*) { - LOG((CLOG_NOTE "connected to server")); + // using CLOG_PRINT here allows the GUI to see that the client is connected + // regardless of which log level is set + LOG((CLOG_PRINT "connected to server")); resetRestartTimeout(); updateStatus(); } diff --git a/src/lib/barrier/PlatformScreen.h b/src/lib/barrier/PlatformScreen.h index 82cbfaa..38bf8de 100644 --- a/src/lib/barrier/PlatformScreen.h +++ b/src/lib/barrier/PlatformScreen.h @@ -20,7 +20,7 @@ #include "barrier/IPlatformScreen.h" #include "barrier/DragInformation.h" -#include "common/stdexcept.h" +#include //! Base screen implementation /*! diff --git a/src/lib/barrier/ProtocolUtil.cpp b/src/lib/barrier/ProtocolUtil.cpp index 42fe69c..e742687 100644 --- a/src/lib/barrier/ProtocolUtil.cpp +++ b/src/lib/barrier/ProtocolUtil.cpp @@ -20,6 +20,7 @@ #include "io/IStream.h" #include "base/Log.h" #include "common/stdvector.h" +#include "base/String.h" #include #include @@ -538,7 +539,7 @@ ProtocolUtil::read(barrier::IStream* stream, void* vbuffer, UInt32 count) // String -XIOReadMismatch::getWhat() const throw() +XIOReadMismatch::getWhat() const noexcept { return format("XIOReadMismatch", "ProtocolUtil::readf() mismatch"); } diff --git a/src/lib/barrier/ProtocolUtil.h b/src/lib/barrier/ProtocolUtil.h index 78bb5ca..9930cfc 100644 --- a/src/lib/barrier/ProtocolUtil.h +++ b/src/lib/barrier/ProtocolUtil.h @@ -47,7 +47,7 @@ public: - \%1I -- converts std::vector* to 1 byte integers - \%2I -- converts std::vector* to 2 byte integers in NBO - \%4I -- converts std::vector* to 4 byte integers in NBO - - \%s -- converts String* to stream of bytes + - \%s -- converts std::string* to stream of bytes - \%S -- converts integer N and const UInt8* to stream of N bytes */ static void writef(barrier::IStream*, @@ -67,7 +67,7 @@ public: - \%1I -- reads 1 byte integers; arg is std::vector* - \%2I -- reads NBO 2 byte integers; arg is std::vector* - \%4I -- reads NBO 4 byte integers; arg is std::vector* - - \%s -- reads bytes; argument must be a String*, \b not a char* + - \%s -- reads bytes; argument must be a std::string*, \b not a char* */ static bool readf(barrier::IStream*, const char* fmt, ...); @@ -92,5 +92,5 @@ match the format. class XIOReadMismatch : public XIO { public: // XBase overrides - virtual String getWhat() const throw(); + virtual std::string getWhat() const noexcept; }; diff --git a/src/lib/barrier/ServerApp.cpp b/src/lib/barrier/ServerApp.cpp index 318673c..18cf935 100644 --- a/src/lib/barrier/ServerApp.cpp +++ b/src/lib/barrier/ServerApp.cpp @@ -555,15 +555,18 @@ ServerApp::startServer() m_server->setListener(listener); m_listener = listener; updateStatus(); - LOG((CLOG_NOTE "started server (%s), waiting for clients", family)); + + // using CLOG_PRINT here allows the GUI to see that the server is started + // regardless of which log level is set + LOG((CLOG_PRINT "started server (%s), waiting for clients", family)); m_serverState = kStarted; return true; } catch (XSocketAddressInUse& e) { - LOG((CLOG_WARN "cannot listen for clients: %s", e.what())); + LOG((CLOG_ERR "cannot listen for clients: %s", e.what())); closeClientListener(listener); updateStatus(String("cannot listen for clients: ") + e.what()); - retryTime = 10.0; + retryTime = 1.0; } catch (XBase& e) { LOG((CLOG_CRIT "failed to start server: %s", e.what())); @@ -684,9 +687,9 @@ ServerApp::handleNoClients(const Event&, void*) void ServerApp::handleScreenSwitched(const Event& e, void*) { - Server::SwitchToScreenInfo* info = (Server::SwitchToScreenInfo*)(e.getData()); - #ifdef WINAPI_XWINDOWS + Server::SwitchToScreenInfo* info = (Server::SwitchToScreenInfo*)(e.getData()); + if (!args().m_screenChangeScript.empty()) { LOG((CLOG_INFO "Running shell script for screen \"%s\"", info->m_screen)); diff --git a/src/lib/barrier/StreamChunker.cpp b/src/lib/barrier/StreamChunker.cpp index 8b8971c..579d02f 100644 --- a/src/lib/barrier/StreamChunker.cpp +++ b/src/lib/barrier/StreamChunker.cpp @@ -29,9 +29,9 @@ #include "base/Log.h" #include "base/Stopwatch.h" #include "base/String.h" -#include "common/stdexcept.h" #include +#include using namespace std; diff --git a/src/lib/barrier/XBarrier.cpp b/src/lib/barrier/XBarrier.cpp index 49a015e..7fe3577 100644 --- a/src/lib/barrier/XBarrier.cpp +++ b/src/lib/barrier/XBarrier.cpp @@ -23,8 +23,7 @@ // XBadClient // -String -XBadClient::getWhat() const throw() +String XBadClient::getWhat() const noexcept { return "XBadClient"; } @@ -41,20 +40,17 @@ XIncompatibleClient::XIncompatibleClient(int major, int minor) : // do nothing } -int -XIncompatibleClient::getMajor() const throw() +int XIncompatibleClient::getMajor() const noexcept { return m_major; } -int -XIncompatibleClient::getMinor() const throw() +int XIncompatibleClient::getMinor() const noexcept { return m_minor; } -String -XIncompatibleClient::getWhat() const throw() +String XIncompatibleClient::getWhat() const noexcept { return format("XIncompatibleClient", "incompatible client %{1}.%{2}", barrier::string::sprintf("%d", m_major).c_str(), @@ -72,14 +68,12 @@ XDuplicateClient::XDuplicateClient(const String& name) : // do nothing } -const String& -XDuplicateClient::getName() const throw() +const String& XDuplicateClient::getName() const noexcept { return m_name; } -String -XDuplicateClient::getWhat() const throw() +String XDuplicateClient::getWhat() const noexcept { return format("XDuplicateClient", "duplicate client %{1}", m_name.c_str()); } @@ -95,14 +89,12 @@ XUnknownClient::XUnknownClient(const String& name) : // do nothing } -const String& -XUnknownClient::getName() const throw() +const String& XUnknownClient::getName() const noexcept { return m_name; } -String -XUnknownClient::getWhat() const throw() +String XUnknownClient::getWhat() const noexcept { return format("XUnknownClient", "unknown client %{1}", m_name.c_str()); } @@ -118,14 +110,12 @@ XExitApp::XExitApp(int code) : // do nothing } -int -XExitApp::getCode() const throw() +int XExitApp::getCode() const noexcept { return m_code; } -String -XExitApp::getWhat() const throw() +String XExitApp::getWhat() const noexcept { return format( "XExitApp", "exiting with code %{1}", diff --git a/src/lib/barrier/XBarrier.h b/src/lib/barrier/XBarrier.h index fdf5213..fef931e 100644 --- a/src/lib/barrier/XBarrier.h +++ b/src/lib/barrier/XBarrier.h @@ -47,14 +47,14 @@ public: //@{ //! Get client's major version number - int getMajor() const throw(); + int getMajor() const noexcept; //! Get client's minor version number - int getMinor() const throw(); + int getMinor() const noexcept; //@} protected: - virtual String getWhat() const throw(); + virtual std::string getWhat() const noexcept; private: int m_major; @@ -68,23 +68,22 @@ a client that is already connected. */ class XDuplicateClient : public XBarrier { public: - XDuplicateClient(const String& name); - virtual ~XDuplicateClient() _NOEXCEPT { } + XDuplicateClient(const std::string& name); + virtual ~XDuplicateClient() noexcept { } //! @name accessors //@{ //! Get client's name - virtual const String& - getName() const throw(); + virtual const std::string& getName() const noexcept; //@} protected: - virtual String getWhat() const throw(); + virtual std::string getWhat() const noexcept; private: - String m_name; + std::string m_name; }; //! Client not in map exception @@ -94,23 +93,22 @@ unknown to the server. */ class XUnknownClient : public XBarrier { public: - XUnknownClient(const String& name); - virtual ~XUnknownClient() _NOEXCEPT { } + XUnknownClient(const std::string& name); + virtual ~XUnknownClient() noexcept { } //! @name accessors //@{ //! Get the client's name - virtual const String& - getName() const throw(); + virtual const std::string& getName() const noexcept; //@} protected: - virtual String getWhat() const throw(); + virtual std::string getWhat() const noexcept; private: - String m_name; + std::string m_name; }; //! Generic exit eception @@ -122,13 +120,13 @@ exit(int). class XExitApp : public XBarrier { public: XExitApp(int code); - virtual ~XExitApp() _NOEXCEPT { } + virtual ~XExitApp() noexcept { } //! Get the exit code - int getCode() const throw(); + int getCode() const noexcept; protected: - virtual String getWhat() const throw(); + 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 a202240..3398423 100644 --- a/src/lib/barrier/XScreen.cpp +++ b/src/lib/barrier/XScreen.cpp @@ -22,8 +22,7 @@ // XScreenOpenFailure // -String -XScreenOpenFailure::getWhat() const throw() +std::string XScreenOpenFailure::getWhat() const noexcept { return format("XScreenOpenFailure", "unable to open screen"); } @@ -33,8 +32,7 @@ XScreenOpenFailure::getWhat() const throw() // XScreenXInputFailure // -String -XScreenXInputFailure::getWhat() const throw() +std::string XScreenXInputFailure::getWhat() const noexcept { return ""; } @@ -50,7 +48,7 @@ XScreenUnavailable::XScreenUnavailable(double timeUntilRetry) : // do nothing } -XScreenUnavailable::~XScreenUnavailable() _NOEXCEPT +XScreenUnavailable::~XScreenUnavailable() noexcept { // do nothing } @@ -61,8 +59,7 @@ XScreenUnavailable::getRetryTime() const return m_timeUntilRetry; } -String -XScreenUnavailable::getWhat() const throw() +std::string XScreenUnavailable::getWhat() const noexcept { return format("XScreenUnavailable", "unable to open screen"); } diff --git a/src/lib/barrier/XScreen.h b/src/lib/barrier/XScreen.h index 0cb511e..f8fe7a7 100644 --- a/src/lib/barrier/XScreen.h +++ b/src/lib/barrier/XScreen.h @@ -47,7 +47,7 @@ public: trying to open the screen again. */ XScreenUnavailable(double timeUntilRetry); - virtual ~XScreenUnavailable() _NOEXCEPT; + virtual ~XScreenUnavailable() noexcept; //! @name manipulators //@{ @@ -61,7 +61,7 @@ public: //@} protected: - virtual String getWhat() const throw(); + virtual std::string getWhat() const noexcept; private: double m_timeUntilRetry; diff --git a/src/lib/barrier/win32/DaemonApp.cpp b/src/lib/barrier/win32/DaemonApp.cpp index eafd893..482c465 100644 --- a/src/lib/barrier/win32/DaemonApp.cpp +++ b/src/lib/barrier/win32/DaemonApp.cpp @@ -353,7 +353,10 @@ DaemonApp::handleIpcMessage(const Event& e, void*) LOG((CLOG_DEBUG "ipc hello, type=%s", type.c_str())); const char * serverstatus = m_watchdog->isProcessActive() ? "active" : "not active"; - LOG((CLOG_INFO "server status: %s", serverstatus)); + + // using CLOG_PRINT here allows the GUI to see that the server status + // regardless of which log level is set + LOG((CLOG_PRINT "server status: %s", serverstatus)); m_ipcLogOutputter->notifyBuffer(); break; diff --git a/src/lib/base/EventQueue.cpp b/src/lib/base/EventQueue.cpp index fe8cff5..2429522 100644 --- a/src/lib/base/EventQueue.cpp +++ b/src/lib/base/EventQueue.cpp @@ -436,12 +436,6 @@ EventQueue::removeHandlers(void* target) } } -bool -EventQueue::isEmpty() const -{ - return (m_buffer->isEmpty() && getNextTimerTimeout() != 0.0); -} - IEventJob* EventQueue::getHandler(Event::Type type, void* target) const { @@ -553,8 +547,7 @@ EventQueue::getNextTimerTimeout() const return m_timerQueue.top(); } -Event::Type -EventQueue::getRegisteredType(const String& name) const +Event::Type EventQueue::getRegisteredType(const std::string& name) const { NameMap::const_iterator found = m_nameMap.find(name); if (found != m_nameMap.end()) diff --git a/src/lib/base/EventQueue.h b/src/lib/base/EventQueue.h index 0a2179b..842c5ca 100644 --- a/src/lib/base/EventQueue.h +++ b/src/lib/base/EventQueue.h @@ -58,11 +58,9 @@ public: virtual void removeHandlers(void* target); virtual Event::Type registerTypeOnce(Event::Type& type, const char* name); - virtual bool isEmpty() const; virtual IEventJob* getHandler(Event::Type type, void* target) const; virtual const char* getTypeName(Event::Type type); - virtual Event::Type - getRegisteredType(const String& name) const; + virtual Event::Type getRegisteredType(const std::string& name) const; void* getSystemTarget(); virtual void waitForReady() const; @@ -108,7 +106,7 @@ private: typedef std::map EventTable; typedef std::vector EventIDList; typedef std::map TypeMap; - typedef std::map NameMap; + typedef std::map NameMap; typedef std::map TypeHandlerTable; typedef std::map HandlerTable; diff --git a/src/lib/base/EventTypes.cpp b/src/lib/base/EventTypes.cpp index 9a3e46c..2ba2077 100644 --- a/src/lib/base/EventTypes.cpp +++ b/src/lib/base/EventTypes.cpp @@ -133,6 +133,7 @@ REGISTER_EVENT(Server, error) REGISTER_EVENT(Server, connected) REGISTER_EVENT(Server, disconnected) REGISTER_EVENT(Server, switchToScreen) +REGISTER_EVENT(Server, toggleScreen) REGISTER_EVENT(Server, switchInDirection) REGISTER_EVENT(Server, keyboardBroadcast) REGISTER_EVENT(Server, lockCursorToScreen) diff --git a/src/lib/base/EventTypes.h b/src/lib/base/EventTypes.h index d044c86..f81617e 100644 --- a/src/lib/base/EventTypes.h +++ b/src/lib/base/EventTypes.h @@ -432,6 +432,7 @@ public: m_connected(Event::kUnknown), m_disconnected(Event::kUnknown), m_switchToScreen(Event::kUnknown), + m_toggleScreen(Event::kUnknown), m_switchInDirection(Event::kUnknown), m_keyboardBroadcast(Event::kUnknown), m_lockCursorToScreen(Event::kUnknown), @@ -470,6 +471,13 @@ public: */ Event::Type switchToScreen(); + //! Get toggle screen event type + /*! + Returns the toggle screen event type. The server responds to this + by toggling screens. These is no event data. + */ + Event::Type toggleScreen(); + //! Get switch in direction event type /*! Returns the switch in direction event type. The server responds to this @@ -508,6 +516,7 @@ private: Event::Type m_connected; Event::Type m_disconnected; Event::Type m_switchToScreen; + Event::Type m_toggleScreen; Event::Type m_switchInDirection; Event::Type m_keyboardBroadcast; Event::Type m_lockCursorToScreen; diff --git a/src/lib/base/IEventQueue.h b/src/lib/base/IEventQueue.h index cd4f0b3..150595c 100644 --- a/src/lib/base/IEventQueue.h +++ b/src/lib/base/IEventQueue.h @@ -20,7 +20,7 @@ #include "common/IInterface.h" #include "base/Event.h" -#include "base/String.h" +#include class IEventJob; class IEventQueueBuffer; @@ -189,13 +189,6 @@ public: //! @name accessors //@{ - //! Test if queue is empty - /*! - Returns true iff the queue has no events in it, including timer - events. - */ - virtual bool isEmpty() const = 0; - //! Get an event handler /*! Finds and returns the event handler for the \p type, \p target pair @@ -214,7 +207,7 @@ public: /*! Returns the registered type for an event for a given name. */ - virtual Event::Type getRegisteredType(const String& name) const = 0; + virtual Event::Type getRegisteredType(const std::string& name) const = 0; //! Get the system event type target /*! diff --git a/src/lib/base/Log.cpp b/src/lib/base/Log.cpp index 1252ed9..a3b328d 100644 --- a/src/lib/base/Log.cpp +++ b/src/lib/base/Log.cpp @@ -19,7 +19,6 @@ #include "arch/Arch.h" #include "arch/XArch.h" #include "base/Log.h" -#include "base/String.h" #include "base/log_outputters.h" #include "common/Version.h" diff --git a/src/lib/base/String.cpp b/src/lib/base/String.cpp index 97b8997..1ab3623 100644 --- a/src/lib/base/String.cpp +++ b/src/lib/base/String.cpp @@ -35,17 +35,17 @@ namespace barrier { namespace string { -String +std::string format(const char* fmt, ...) { va_list args; va_start(args, fmt); - String result = vformat(fmt, args); + std::string result = vformat(fmt, args); va_end(args); return result; } -String +std::string vformat(const char* fmt, va_list args) { // find highest indexed substitution and the locations of substitutions @@ -111,7 +111,7 @@ vformat(const char* fmt, va_list args) } // substitute - String result; + std::string result; result.reserve(resultLength); size_t src = 0; for (int i = 0; i < n; ++i) { @@ -124,13 +124,13 @@ vformat(const char* fmt, va_list args) return result; } -String +std::string sprintf(const char* fmt, ...) { char tmp[1024]; char* buffer = tmp; int len = (int)(sizeof(tmp) / sizeof(tmp[0])); - String result; + std::string result; while (buffer != NULL) { // try printing into the buffer va_list args; @@ -162,23 +162,23 @@ sprintf(const char* fmt, ...) void findReplaceAll( - String& subject, - const String& find, - const String& replace) + std::string& subject, + const std::string& find, + const std::string& replace) { size_t pos = 0; - while ((pos = subject.find(find, pos)) != String::npos) { + while ((pos = subject.find(find, pos)) != std::string::npos) { subject.replace(pos, find.length(), replace); pos += replace.length(); } } -String -removeFileExt(String filename) +std::string +removeFileExt(std::string filename) { size_t dot = filename.find_last_of('.'); - if (dot == String::npos) { + if (dot == std::string::npos) { return filename; } @@ -186,7 +186,7 @@ removeFileExt(String filename) } void -toHex(String& subject, int width, const char fill) +toHex(std::string& subject, int width, const char fill) { std::stringstream ss; ss << std::hex; @@ -198,18 +198,18 @@ toHex(String& subject, int width, const char fill) } void -uppercase(String& subject) +uppercase(std::string& subject) { std::transform(subject.begin(), subject.end(), subject.begin(), ::toupper); } void -removeChar(String& subject, const char c) +removeChar(std::string& subject, const char c) { subject.erase(std::remove(subject.begin(), subject.end(), c), subject.end()); } -String +std::string sizeTypeToString(size_t n) { std::stringstream ss; @@ -218,7 +218,7 @@ sizeTypeToString(size_t n) } size_t -stringToSizeType(String string) +stringToSizeType(std::string string) { std::istringstream iss(string); size_t value; @@ -226,14 +226,14 @@ stringToSizeType(String string) return value; } -std::vector -splitString(String string, const char c) +std::vector +splitString(std::string string, const char c) { - std::vector results; + std::vector results; size_t head = 0; size_t separator = string.find(c); - while (separator != String::npos) { + while (separator != std::string::npos) { if (head!=separator) { results.push_back(string.substr(head, separator - head)); } @@ -252,26 +252,22 @@ splitString(String string, const char c) // CaselessCmp // -bool -CaselessCmp::cmpEqual( - const String::value_type& a, - const String::value_type& b) +bool CaselessCmp::cmpEqual(const std::string::value_type& a, + const std::string::value_type& b) { // should use std::tolower but not in all versions of libstdc++ have it return tolower(a) == tolower(b); } -bool -CaselessCmp::cmpLess( - const String::value_type& a, - const String::value_type& b) +bool CaselessCmp::cmpLess(const std::string::value_type& a, + const std::string::value_type& b) { // should use std::tolower but not in all versions of libstdc++ have it return tolower(a) < tolower(b); } bool -CaselessCmp::less(const String& a, const String& b) +CaselessCmp::less(const std::string& a, const std::string& b) { return std::lexicographical_compare( a.begin(), a.end(), @@ -280,13 +276,13 @@ CaselessCmp::less(const String& a, const String& b) } bool -CaselessCmp::equal(const String& a, const String& b) +CaselessCmp::equal(const std::string& a, const std::string& b) { return !(less(a, b) || less(b, a)); } bool -CaselessCmp::operator()(const String& a, const String& b) const +CaselessCmp::operator()(const std::string& a, const std::string& b) const { return less(a, b); } diff --git a/src/lib/base/String.h b/src/lib/base/String.h index 3661461..73526b4 100644 --- a/src/lib/base/String.h +++ b/src/lib/base/String.h @@ -29,7 +29,7 @@ typedef std::string String; namespace barrier { -//! String utilities +//! std::string utilities /*! Provides functions for string manipulation. */ @@ -45,67 +45,67 @@ characters and conversion specifications introduced by `\%': All arguments in the variable list are const char*. Positional elements are indexed from 1. */ -String format(const char* fmt, ...); +std::string format(const char* fmt, ...); //! Format positional arguments /*! Same as format() except takes va_list. */ -String vformat(const char* fmt, va_list); +std::string vformat(const char* fmt, va_list); //! Print a string using sprintf-style formatting /*! -Equivalent to sprintf() except the result is returned as a String. +Equivalent to sprintf() except the result is returned as a std::string. */ -String sprintf(const char* fmt, ...); +std::string sprintf(const char* fmt, ...); //! Find and replace all /*! Finds \c find inside \c subject and replaces it with \c replace */ -void findReplaceAll(String& subject, const String& find, const String& replace); +void findReplaceAll(std::string& subject, const std::string& find, const std::string& replace); //! Remove file extension /*! Finds the last dot and remove all characters from the dot to the end */ -String removeFileExt(String filename); +std::string removeFileExt(std::string filename); //! Convert into hexdecimal /*! Convert each character in \c subject into hexdecimal form with \c width */ -void toHex(String& subject, int width, const char fill = '0'); +void toHex(std::string& subject, int width, const char fill = '0'); //! Convert to all uppercase /*! Convert each character in \c subject to uppercase */ -void uppercase(String& subject); +void uppercase(std::string& subject); //! Remove all specific char in suject /*! Remove all specific \c c in \c suject */ -void removeChar(String& subject, const char c); +void removeChar(std::string& subject, const char c); //! Convert a size type to a string /*! Convert an size type to a string */ -String sizeTypeToString(size_t n); +std::string sizeTypeToString(size_t n); //! Convert a string to a size type /*! Convert an a \c string to an size type */ -size_t stringToSizeType(String string); +size_t stringToSizeType(std::string string); //! Split a string into substrings /*! Split a \c string that separated by a \c c into substrings */ -std::vector splitString(String string, const char c); +std::vector splitString(std::string string, const char c); //! Case-insensitive comparisons /*! @@ -114,21 +114,21 @@ This class provides case-insensitve comparison functions. class CaselessCmp { public: //! Same as less() - bool operator()(const String& a, const String& b) const; + bool operator()(const std::string& a, const std::string& b) const; //! Returns true iff \c a is lexicographically less than \c b - static bool less(const String& a, const String& b); + static bool less(const std::string& a, const std::string& b); //! Returns true iff \c a is lexicographically equal to \c b - static bool equal(const String& a, const String& b); + static bool equal(const std::string& a, const std::string& b); //! Returns true iff \c a is lexicographically less than \c b - static bool cmpLess(const String::value_type& a, - const String::value_type& b); + static bool cmpLess(const std::string::value_type& a, + const std::string::value_type& b); //! Returns true iff \c a is lexicographically equal to \c b - static bool cmpEqual(const String::value_type& a, - const String::value_type& b); + static bool cmpEqual(const std::string::value_type& a, + const std::string::value_type& b); }; } diff --git a/src/lib/base/Unicode.cpp b/src/lib/base/Unicode.cpp index 90a166f..05b0212 100644 --- a/src/lib/base/Unicode.cpp +++ b/src/lib/base/Unicode.cpp @@ -98,7 +98,7 @@ UInt32 Unicode::s_invalid = 0x0000ffff; UInt32 Unicode::s_replacement = 0x0000fffd; bool -Unicode::isUTF8(const String& src) +Unicode::isUTF8(const std::string& src) { // convert and test each character const UInt8* data = reinterpret_cast(src.c_str()); @@ -110,15 +110,14 @@ Unicode::isUTF8(const String& src) return true; } -String -Unicode::UTF8ToUCS2(const String& src, bool* errors) +std::string Unicode::UTF8ToUCS2(const std::string& src, bool* errors) { // default to success resetError(errors); // get size of input string and reserve some space in output UInt32 n = (UInt32)src.size(); - String dst; + std::string dst; dst.reserve(2 * n); // convert each character @@ -139,15 +138,15 @@ Unicode::UTF8ToUCS2(const String& src, bool* errors) return dst; } -String -Unicode::UTF8ToUCS4(const String& src, bool* errors) +std::string +Unicode::UTF8ToUCS4(const std::string& src, bool* errors) { // default to success resetError(errors); // get size of input string and reserve some space in output UInt32 n = (UInt32)src.size(); - String dst; + std::string dst; dst.reserve(4 * n); // convert each character @@ -163,15 +162,15 @@ Unicode::UTF8ToUCS4(const String& src, bool* errors) return dst; } -String -Unicode::UTF8ToUTF16(const String& src, bool* errors) +std::string +Unicode::UTF8ToUTF16(const std::string& src, bool* errors) { // default to success resetError(errors); // get size of input string and reserve some space in output UInt32 n = (UInt32)src.size(); - String dst; + std::string dst; dst.reserve(2 * n); // convert each character @@ -201,15 +200,15 @@ Unicode::UTF8ToUTF16(const String& src, bool* errors) return dst; } -String -Unicode::UTF8ToUTF32(const String& src, bool* errors) +std::string +Unicode::UTF8ToUTF32(const std::string& src, bool* errors) { // default to success resetError(errors); // get size of input string and reserve some space in output UInt32 n = (UInt32)src.size(); - String dst; + std::string dst; dst.reserve(4 * n); // convert each character @@ -229,8 +228,8 @@ Unicode::UTF8ToUTF32(const String& src, bool* errors) return dst; } -String -Unicode::UTF8ToText(const String& src, bool* errors) +std::string +Unicode::UTF8ToText(const std::string& src, bool* errors) { // default to success resetError(errors); @@ -243,7 +242,7 @@ Unicode::UTF8ToText(const String& src, bool* errors) int len = ARCH->convStringWCToMB(NULL, tmp, size, errors); char* mbs = new char[len + 1]; ARCH->convStringWCToMB(mbs, tmp, size, errors); - String text(mbs, len); + std::string text(mbs, len); // clean up delete[] mbs; @@ -252,8 +251,8 @@ Unicode::UTF8ToText(const String& src, bool* errors) return text; } -String -Unicode::UCS2ToUTF8(const String& src, bool* errors) +std::string +Unicode::UCS2ToUTF8(const std::string& src, bool* errors) { // default to success resetError(errors); @@ -263,8 +262,8 @@ Unicode::UCS2ToUTF8(const String& src, bool* errors) return doUCS2ToUTF8(reinterpret_cast(src.data()), n, errors); } -String -Unicode::UCS4ToUTF8(const String& src, bool* errors) +std::string +Unicode::UCS4ToUTF8(const std::string& src, bool* errors) { // default to success resetError(errors); @@ -274,8 +273,8 @@ Unicode::UCS4ToUTF8(const String& src, bool* errors) return doUCS4ToUTF8(reinterpret_cast(src.data()), n, errors); } -String -Unicode::UTF16ToUTF8(const String& src, bool* errors) +std::string +Unicode::UTF16ToUTF8(const std::string& src, bool* errors) { // default to success resetError(errors); @@ -285,8 +284,8 @@ Unicode::UTF16ToUTF8(const String& src, bool* errors) return doUTF16ToUTF8(reinterpret_cast(src.data()), n, errors); } -String -Unicode::UTF32ToUTF8(const String& src, bool* errors) +std::string +Unicode::UTF32ToUTF8(const std::string& src, bool* errors) { // default to success resetError(errors); @@ -296,8 +295,8 @@ Unicode::UTF32ToUTF8(const String& src, bool* errors) return doUTF32ToUTF8(reinterpret_cast(src.data()), n, errors); } -String -Unicode::textToUTF8(const String& src, bool* errors) +std::string +Unicode::textToUTF8(const std::string& src, bool* errors) { // default to success resetError(errors); @@ -309,7 +308,7 @@ Unicode::textToUTF8(const String& src, bool* errors) ARCH->convStringMBToWC(wcs, src.c_str(), n, errors); // convert to UTF8 - String utf8 = wideCharToUTF8(wcs, len, errors); + std::string utf8 = wideCharToUTF8(wcs, len, errors); // clean up delete[] wcs; @@ -318,10 +317,10 @@ Unicode::textToUTF8(const String& src, bool* errors) } wchar_t* -Unicode::UTF8ToWideChar(const String& src, UInt32& size, bool* errors) +Unicode::UTF8ToWideChar(const std::string& src, UInt32& size, bool* errors) { // convert to platform's wide character encoding - String tmp; + std::string tmp; switch (ARCH->getWideCharEncoding()) { case IArchString::kUCS2: tmp = UTF8ToUCS2(src, errors); @@ -353,12 +352,12 @@ Unicode::UTF8ToWideChar(const String& src, UInt32& size, bool* errors) return dst; } -String +std::string Unicode::wideCharToUTF8(const wchar_t* src, UInt32 size, bool* errors) { // convert from platform's wide character encoding. // note -- this must include a wide nul character (independent of - // the String's nul character). + // the std::string's nul character). switch (ARCH->getWideCharEncoding()) { case IArchString::kUCS2: return doUCS2ToUTF8(reinterpret_cast(src), size, errors); @@ -374,15 +373,15 @@ Unicode::wideCharToUTF8(const wchar_t* src, UInt32 size, bool* errors) default: assert(0 && "unknown wide character encoding"); - return String(); + return std::string(); } } -String +std::string Unicode::doUCS2ToUTF8(const UInt8* data, UInt32 n, bool* errors) { // make some space - String dst; + std::string dst; dst.reserve(n); // check if first character is 0xfffe or 0xfeff @@ -414,11 +413,11 @@ Unicode::doUCS2ToUTF8(const UInt8* data, UInt32 n, bool* errors) return dst; } -String +std::string Unicode::doUCS4ToUTF8(const UInt8* data, UInt32 n, bool* errors) { // make some space - String dst; + std::string dst; dst.reserve(n); // check if first character is 0xfffe or 0xfeff @@ -450,11 +449,11 @@ Unicode::doUCS4ToUTF8(const UInt8* data, UInt32 n, bool* errors) return dst; } -String +std::string Unicode::doUTF16ToUTF8(const UInt8* data, UInt32 n, bool* errors) { // make some space - String dst; + std::string dst; dst.reserve(n); // check if first character is 0xfffe or 0xfeff @@ -512,11 +511,11 @@ Unicode::doUTF16ToUTF8(const UInt8* data, UInt32 n, bool* errors) return dst; } -String +std::string Unicode::doUTF32ToUTF8(const UInt8* data, UInt32 n, bool* errors) { // make some space - String dst; + std::string dst; dst.reserve(n); // check if first character is 0xfffe or 0xfeff @@ -728,7 +727,7 @@ Unicode::fromUTF8(const UInt8*& data, UInt32& n) } void -Unicode::toUTF8(String& dst, UInt32 c, bool* errors) +Unicode::toUTF8(std::string& dst, UInt32 c, bool* errors) { UInt8 data[6]; diff --git a/src/lib/base/Unicode.h b/src/lib/base/Unicode.h index 1391c1e..9bf83ae 100644 --- a/src/lib/base/Unicode.h +++ b/src/lib/base/Unicode.h @@ -18,8 +18,8 @@ #pragma once -#include "base/String.h" #include "common/basic_types.h" +#include //! Unicode utility functions /*! @@ -36,7 +36,7 @@ public: Returns true iff the string contains a valid sequence of UTF-8 encoded characters. */ - static bool isUTF8(const String&); + static bool isUTF8(const std::string&); //! Convert from UTF-8 to UCS-2 encoding /*! @@ -44,7 +44,7 @@ public: is set to true iff any character could not be encoded in UCS-2. Decoding errors do not set *errors. */ - static String UTF8ToUCS2(const String&, bool* errors = NULL); + static std::string UTF8ToUCS2(const std::string&, bool* errors = NULL); //! Convert from UTF-8 to UCS-4 encoding /*! @@ -52,7 +52,7 @@ public: is set to true iff any character could not be encoded in UCS-4. Decoding errors do not set *errors. */ - static String UTF8ToUCS4(const String&, bool* errors = NULL); + static std::string UTF8ToUCS4(const std::string&, bool* errors = NULL); //! Convert from UTF-8 to UTF-16 encoding /*! @@ -60,7 +60,7 @@ public: is set to true iff any character could not be encoded in UTF-16. Decoding errors do not set *errors. */ - static String UTF8ToUTF16(const String&, bool* errors = NULL); + static std::string UTF8ToUTF16(const std::string&, bool* errors = NULL); //! Convert from UTF-8 to UTF-32 encoding /*! @@ -68,7 +68,7 @@ public: is set to true iff any character could not be encoded in UTF-32. Decoding errors do not set *errors. */ - static String UTF8ToUTF32(const String&, bool* errors = NULL); + static std::string UTF8ToUTF32(const std::string&, bool* errors = NULL); //! Convert from UTF-8 to the current locale encoding /*! @@ -76,42 +76,42 @@ public: NULL then *errors is set to true iff any character could not be encoded. Decoding errors do not set *errors. */ - static String UTF8ToText(const String&, bool* errors = NULL); + static std::string UTF8ToText(const std::string&, bool* errors = NULL); //! Convert from UCS-2 to UTF-8 /*! Convert from UCS-2 to UTF-8. If errors is not NULL then *errors is set to true iff any character could not be decoded. */ - static String UCS2ToUTF8(const String&, bool* errors = NULL); + static std::string UCS2ToUTF8(const std::string&, bool* errors = NULL); //! Convert from UCS-4 to UTF-8 /*! Convert from UCS-4 to UTF-8. If errors is not NULL then *errors is set to true iff any character could not be decoded. */ - static String UCS4ToUTF8(const String&, bool* errors = NULL); + static std::string UCS4ToUTF8(const std::string&, bool* errors = NULL); //! Convert from UTF-16 to UTF-8 /*! Convert from UTF-16 to UTF-8. If errors is not NULL then *errors is set to true iff any character could not be decoded. */ - static String UTF16ToUTF8(const String&, bool* errors = NULL); + static std::string UTF16ToUTF8(const std::string&, bool* errors = NULL); //! Convert from UTF-32 to UTF-8 /*! Convert from UTF-32 to UTF-8. If errors is not NULL then *errors is set to true iff any character could not be decoded. */ - static String UTF32ToUTF8(const String&, bool* errors = NULL); + static std::string UTF32ToUTF8(const std::string&, bool* errors = NULL); //! Convert from the current locale encoding to UTF-8 /*! Convert from the current locale encoding to UTF-8. If errors is not NULL then *errors is set to true iff any character could not be decoded. */ - static String textToUTF8(const String&, bool* errors = NULL); + static std::string textToUTF8(const std::string&, bool* errors = NULL); //@} @@ -120,23 +120,21 @@ private: // to the platform). caller must delete[] the returned string. the // string is *not* nul terminated; the length (in characters) is // returned in size. - static wchar_t* UTF8ToWideChar(const String&, - UInt32& size, bool* errors); + static wchar_t* UTF8ToWideChar(const std::string&, UInt32& size, bool* errors); // convert nul terminated wchar_t string (in platform's native // encoding) to UTF8. - static String wideCharToUTF8(const wchar_t*, - UInt32 size, bool* errors); + static std::string wideCharToUTF8(const wchar_t*, UInt32 size, bool* errors); // internal conversion to UTF8 - static String doUCS2ToUTF8(const UInt8* src, UInt32 n, bool* errors); - static String doUCS4ToUTF8(const UInt8* src, UInt32 n, bool* errors); - static String doUTF16ToUTF8(const UInt8* src, UInt32 n, bool* errors); - static String doUTF32ToUTF8(const UInt8* src, UInt32 n, bool* errors); + static std::string doUCS2ToUTF8(const UInt8* src, UInt32 n, bool* errors); + static std::string doUCS4ToUTF8(const UInt8* src, UInt32 n, bool* errors); + static std::string doUTF16ToUTF8(const UInt8* src, UInt32 n, bool* errors); + static std::string doUTF32ToUTF8(const UInt8* src, UInt32 n, bool* errors); // convert characters to/from UTF8 - static UInt32 fromUTF8(const UInt8*& src, UInt32& size); - static void toUTF8(String& dst, UInt32 c, bool* errors); + static UInt32 fromUTF8(const UInt8*& src, UInt32& size); + static void toUTF8(std::string& dst, UInt32 c, bool* errors); private: static UInt32 s_invalid; diff --git a/src/lib/base/XBase.cpp b/src/lib/base/XBase.cpp index 29ae927..cb0db2e 100644 --- a/src/lib/base/XBase.cpp +++ b/src/lib/base/XBase.cpp @@ -32,19 +32,19 @@ XBase::XBase() : // do nothing } -XBase::XBase(const String& msg) : +XBase::XBase(const std::string& msg) : std::runtime_error(msg) { // do nothing } -XBase::~XBase() _NOEXCEPT +XBase::~XBase() noexcept { // do nothing } const char* -XBase::what() const _NOEXCEPT +XBase::what() const noexcept { const char* what = std::runtime_error::what(); if (strlen(what) == 0) { @@ -54,14 +54,13 @@ XBase::what() const _NOEXCEPT return what; } -String -XBase::format(const char* /*id*/, const char* fmt, ...) const throw() +std::string XBase::format(const char* /*id*/, const char* fmt, ...) const noexcept { // FIXME -- lookup message string using id as an index. set // fmt to that string if it exists. // format - String result; + std::string result; va_list args; va_start(args, fmt); try { diff --git a/src/lib/base/XBase.h b/src/lib/base/XBase.h index 3064b6c..59b700e 100644 --- a/src/lib/base/XBase.h +++ b/src/lib/base/XBase.h @@ -18,8 +18,8 @@ #pragma once -#include "base/String.h" -#include "common/stdexcept.h" +#include +#include //! Exception base class /*! @@ -30,15 +30,15 @@ public: //! Use getWhat() as the result of what() XBase(); //! Use \c msg as the result of what() - XBase(const String& msg); - virtual ~XBase() _NOEXCEPT; + XBase(const std::string& msg); + virtual ~XBase() noexcept; //! Reason for exception - virtual const char* what() const _NOEXCEPT; + virtual const char* what() const noexcept; protected: //! Get a human readable string describing the exception - virtual String getWhat() const throw() { return ""; } + virtual std::string getWhat() const noexcept { return ""; } //! Format a string /*! @@ -46,47 +46,46 @@ protected: no format can be found, then replaces positional parameters in the format string and returns the result. */ - virtual String format(const char* id, - const char* defaultFormat, ...) const throw(); + virtual std::string format(const char* id, const char* defaultFormat, ...) const noexcept; private: - mutable String m_what; + mutable std::string m_what; }; /*! \def XBASE_SUBCLASS Convenience macro to subclass from XBase (or a subclass of it), -providing the c'tor taking a const String&. getWhat() is not +providing the c'tor taking a const std::string&. getWhat() is not declared. */ #define XBASE_SUBCLASS(name_, super_) \ class name_ : public super_ { \ public: \ name_() : super_() { } \ - name_(const String& msg) : super_(msg) { } \ - virtual ~name_() _NOEXCEPT { } \ + name_(const std::string& msg) : super_(msg) { } \ + virtual ~name_() noexcept { } \ } /*! \def XBASE_SUBCLASS Convenience macro to subclass from XBase (or a subclass of it), -providing the c'tor taking a const String&. getWhat() must be +providing the c'tor taking a const std::string&. getWhat() must be implemented. */ #define XBASE_SUBCLASS_WHAT(name_, super_) \ class name_ : public super_ { \ public: \ name_() : super_() { } \ - name_(const String& msg) : super_(msg) { } \ - virtual ~name_() _NOEXCEPT { } \ + name_(const std::string& msg) : super_(msg) { } \ + virtual ~name_() noexcept { } \ \ protected: \ - virtual String getWhat() const throw(); \ + virtual std::string getWhat() const noexcept; \ } /*! \def XBASE_SUBCLASS_FORMAT Convenience macro to subclass from XBase (or a subclass of it), -providing the c'tor taking a const String&. what() is overridden +providing the c'tor taking a const std::string&. what() is overridden to call getWhat() when first called; getWhat() can format the error message and can call what() to get the message passed to the c'tor. @@ -98,10 +97,10 @@ private: \ \ public: \ name_() : super_(), m_state(kDone) { } \ - name_(const String& msg) : super_(msg), m_state(kFirst) { } \ - virtual ~name_() _NOEXCEPT { } \ + name_(const std::string& msg) : super_(msg), m_state(kFirst) { } \ + virtual ~name_() noexcept { } \ \ - virtual const char* what() const _NOEXCEPT \ + virtual const char* what() const noexcept \ { \ if (m_state == kFirst) { \ m_state = kFormat; \ @@ -117,7 +116,7 @@ public: \ } \ \ protected: \ - virtual String getWhat() const throw(); \ + virtual std::string getWhat() const noexcept; \ \ private: \ mutable EState m_state; \ diff --git a/src/lib/base/log_outputters.cpp b/src/lib/base/log_outputters.cpp index 8e56c26..af53192 100644 --- a/src/lib/base/log_outputters.cpp +++ b/src/lib/base/log_outputters.cpp @@ -19,6 +19,7 @@ #include "base/log_outputters.h" #include "base/TMethodJob.h" #include "arch/Arch.h" +#include "base/String.h" #include @@ -228,7 +229,7 @@ BufferedLogOutputter::write(ELevel, const char* message) while (m_buffer.size() >= m_maxBufferSize) { m_buffer.pop_front(); } - m_buffer.push_back(String(message)); + m_buffer.push_back(std::string(message)); return true; } @@ -272,7 +273,7 @@ FileLogOutputter::write(ELevel level, const char *message) m_handle.close(); if (moveFile) { - String oldLogFilename = barrier::string::sprintf("%s.1", m_fileName.c_str()); + std::string oldLogFilename = barrier::string::sprintf("%s.1", m_fileName.c_str()); remove(oldLogFilename.c_str()); rename(m_fileName.c_str(), oldLogFilename.c_str()); } diff --git a/src/lib/base/log_outputters.h b/src/lib/base/log_outputters.h index c4940aa..15f1e7a 100644 --- a/src/lib/base/log_outputters.h +++ b/src/lib/base/log_outputters.h @@ -20,12 +20,12 @@ #include "mt/Thread.h" #include "base/ILogOutputter.h" -#include "base/String.h" #include "common/basic_types.h" #include "common/stddeque.h" #include #include +#include //! Stop traversing log chain outputter /*! @@ -126,7 +126,7 @@ This outputter records the last N log messages. */ class BufferedLogOutputter : public ILogOutputter { private: - typedef std::deque Buffer; + typedef std::deque Buffer; public: typedef Buffer::const_iterator const_iterator; diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp index 2158ee2..96d2c67 100644 --- a/src/lib/client/Client.cpp +++ b/src/lib/client/Client.cpp @@ -38,23 +38,21 @@ #include "base/IEventQueue.h" #include "base/TMethodEventJob.h" #include "base/TMethodJob.h" -#include "common/stdexcept.h" #include #include #include +#include #include // // Client // -Client::Client( - IEventQueue* events, - const String& name, const NetworkAddress& address, - ISocketFactory* socketFactory, - barrier::Screen* screen, - ClientArgs const& args) : +Client::Client(IEventQueue* events, const std::string& name, const NetworkAddress& address, + ISocketFactory* socketFactory, + barrier::Screen* screen, + ClientArgs const& args) : m_mock(false), m_name(name), m_serverAddress(address), @@ -373,7 +371,7 @@ Client::setOptions(const OptionsList& options) m_screen->setOptions(options); } -String +std::string Client::getName() const { return m_name; @@ -403,7 +401,7 @@ Client::sendClipboard(ClipboardID id) m_timeClipboard[id] = clipboard.getTime(); // marshall the data - String data = clipboard.marshall(); + std::string data = clipboard.marshall(); // save and send data if different or not yet sent if (!m_sentClipboard[id] || data != m_dataClipboard[id]) { @@ -783,7 +781,7 @@ Client::writeToDropDirThread(void*) } void -Client::dragInfoReceived(UInt32 fileNum, String data) +Client::dragInfoReceived(UInt32 fileNum, std::string data) { // TODO: fix duplicate function from CServer if (!m_args.m_enableDragDrop) { @@ -830,7 +828,7 @@ Client::sendFileThread(void* filename) } void -Client::sendDragInfo(UInt32 fileCount, String& info, size_t size) +Client::sendDragInfo(UInt32 fileCount, std::string& info, size_t size) { m_server->sendDragInfo(fileCount, info.c_str(), size); } diff --git a/src/lib/client/Client.h b/src/lib/client/Client.h index 7ac515d..7e566be 100644 --- a/src/lib/client/Client.h +++ b/src/lib/client/Client.h @@ -48,7 +48,7 @@ public: public: FailInfo(const char* what) : m_retry(false), m_what(what) { } bool m_retry; - String m_what; + std::string m_what; }; public: @@ -57,7 +57,7 @@ public: as its name and \p address as the server's address and \p factory to create the socket. \p screen is the local screen. */ - Client(IEventQueue* events, const String& name, + Client(IEventQueue* events, const std::string& name, const NetworkAddress& address, ISocketFactory* socketFactory, barrier::Screen* screen, ClientArgs const& args); @@ -86,13 +86,13 @@ public: virtual void handshakeComplete(); //! Received drag information - void dragInfoReceived(UInt32 fileNum, String data); + void dragInfoReceived(UInt32 fileNum, std::string data); //! 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, String& info, size_t size); + void sendDragInfo(UInt32 fileCount, std::string& info, size_t size); //@} @@ -126,7 +126,7 @@ public: size_t& getExpectedFileSize() { return m_expectedFileSize; } //! Return received file data - String& getReceivedFileData() { return m_receivedFileData; } + std::string& getReceivedFileData() { return m_receivedFileData; } //! Return drag file list DragFileList getDragFileList() { return m_dragFileList; } @@ -160,7 +160,7 @@ public: virtual void screensaver(bool activate); virtual void resetOptions(); virtual void setOptions(const OptionsList& options); - virtual String getName() const; + virtual std::string getName() const; private: void sendClipboard(ClipboardID); @@ -198,7 +198,7 @@ public: bool m_mock; private: - String m_name; + std::string m_name; NetworkAddress m_serverAddress; ISocketFactory* m_socketFactory; barrier::Screen* m_screen; @@ -212,12 +212,12 @@ private: bool m_ownClipboard[kClipboardEnd]; bool m_sentClipboard[kClipboardEnd]; IClipboard::Time m_timeClipboard[kClipboardEnd]; - String m_dataClipboard[kClipboardEnd]; + std::string m_dataClipboard[kClipboardEnd]; IEventQueue* m_events; std::size_t m_expectedFileSize; - String m_receivedFileData; + std::string m_receivedFileData; DragFileList m_dragFileList; - String m_dragFileExt; + std::string m_dragFileExt; Thread* m_sendFileThread; Thread* m_writeToDropDirThread; TCPSocket* m_socket; diff --git a/src/lib/client/ServerProxy.cpp b/src/lib/client/ServerProxy.cpp index 4fbf76a..c067f13 100644 --- a/src/lib/client/ServerProxy.cpp +++ b/src/lib/client/ServerProxy.cpp @@ -361,7 +361,7 @@ ServerProxy::onGrabClipboard(ClipboardID id) void ServerProxy::onClipboardChanged(ClipboardID id, const IClipboard* clipboard) { - String data = IClipboard::marshall(clipboard); + std::string data = IClipboard::marshall(clipboard); LOG((CLOG_DEBUG "sending clipboard %d seqnum=%d", id, m_seqNum)); StreamChunker::sendClipboard(data, data.size(), id, m_seqNum, m_events, this); @@ -550,7 +550,7 @@ void ServerProxy::setClipboard() { // parse - static String dataCached; + static std::string dataCached; ClipboardID id; UInt32 seq; @@ -872,7 +872,7 @@ ServerProxy::fileChunkReceived() } else if (result == kStart) { if (m_client->getDragFileList().size() > 0) { - String filename = m_client->getDragFileList().at(0).getFilename(); + std::string filename = m_client->getDragFileList().at(0).getFilename(); LOG((CLOG_DEBUG "start receiving %s", filename.c_str())); } } @@ -883,7 +883,7 @@ ServerProxy::dragInfoReceived() { // parse UInt32 fileNum = 0; - String content; + std::string content; ProtocolUtil::readf(m_stream, kMsgDDragInfo + 4, &fileNum, &content); m_client->dragInfoReceived(fileNum, content); @@ -904,6 +904,6 @@ ServerProxy::fileChunkSending(UInt8 mark, char* data, size_t dataSize) void ServerProxy::sendDragInfo(UInt32 fileCount, const char* info, size_t size) { - String data(info, size); + std::string data(info, size); ProtocolUtil::writef(m_stream, kMsgDDragInfo, fileCount, &data); } diff --git a/src/lib/client/ServerProxy.h b/src/lib/client/ServerProxy.h index 2ad711a..abca4c3 100644 --- a/src/lib/client/ServerProxy.h +++ b/src/lib/client/ServerProxy.h @@ -22,7 +22,6 @@ #include "barrier/key_types.h" #include "base/Event.h" #include "base/Stopwatch.h" -#include "base/String.h" class Client; class ClientInfo; diff --git a/src/lib/common/stdexcept.h b/src/lib/common/stdexcept.h deleted file mode 100644 index 2bd96b3..0000000 --- a/src/lib/common/stdexcept.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 - * 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 - -// apple declares _NOEXCEPT -#ifndef _NOEXCEPT -# define _NOEXCEPT throw() -#endif diff --git a/src/lib/io/XIO.cpp b/src/lib/io/XIO.cpp index 1299d23..911fa87 100644 --- a/src/lib/io/XIO.cpp +++ b/src/lib/io/XIO.cpp @@ -22,8 +22,7 @@ // XIOClosed // -String -XIOClosed::getWhat() const throw() +std::string XIOClosed::getWhat() const noexcept { return format("XIOClosed", "already closed"); } @@ -33,8 +32,7 @@ XIOClosed::getWhat() const throw() // XIOEndOfStream // -String -XIOEndOfStream::getWhat() const throw() +std::string XIOEndOfStream::getWhat() const noexcept { return format("XIOEndOfStream", "reached end of stream"); } @@ -44,8 +42,7 @@ XIOEndOfStream::getWhat() const throw() // XIOWouldBlock // -String -XIOWouldBlock::getWhat() const throw() +std::string XIOWouldBlock::getWhat() const noexcept { return format("XIOWouldBlock", "stream operation would block"); } diff --git a/src/lib/ipc/IpcClientProxy.cpp b/src/lib/ipc/IpcClientProxy.cpp index 5104277..432cc8c 100644 --- a/src/lib/ipc/IpcClientProxy.cpp +++ b/src/lib/ipc/IpcClientProxy.cpp @@ -141,7 +141,7 @@ IpcClientProxy::send(const IpcMessage& message) switch (message.type()) { case kIpcLogLine: { const IpcLogLineMessage& llm = static_cast(message); - const String logLine = llm.logLine(); + const std::string logLine = llm.logLine(); ProtocolUtil::writef(&m_stream, kIpcMsgLogLine, &logLine); break; } @@ -171,7 +171,7 @@ IpcClientProxy::parseHello() IpcCommandMessage* IpcClientProxy::parseCommand() { - String command; + std::string command; UInt8 elevate; ProtocolUtil::readf(&m_stream, kIpcMsgCommand + 4, &command, &elevate); diff --git a/src/lib/ipc/IpcLogOutputter.cpp b/src/lib/ipc/IpcLogOutputter.cpp index b62c76a..44ecdba 100644 --- a/src/lib/ipc/IpcLogOutputter.cpp +++ b/src/lib/ipc/IpcLogOutputter.cpp @@ -44,8 +44,8 @@ IpcLogOutputter::IpcLogOutputter(IpcServer& ipcServer, EIpcClientType clientType m_running(false), m_notifyCond(ARCH->newCondVar()), m_notifyMutex(ARCH->newMutex()), - m_bufferThreadId(0), m_bufferWaiting(false), + m_bufferThreadId(0), m_bufferMaxSize(kBufferMaxSize), m_bufferRateWriteLimit(kBufferRateWriteLimit), m_bufferRateTimeLimit(kBufferRateTimeLimit), @@ -109,8 +109,7 @@ IpcLogOutputter::write(ELevel, const char* text) return true; } -void -IpcLogOutputter::appendBuffer(const String& text) +void IpcLogOutputter::appendBuffer(const std::string& text) { std::lock_guard lock(m_bufferMutex); @@ -173,8 +172,7 @@ IpcLogOutputter::notifyBuffer() ARCH->broadcastCondVar(m_notifyCond); } -String -IpcLogOutputter::getChunk(size_t count) +std::string IpcLogOutputter::getChunk(size_t count) { std::lock_guard lock(m_bufferMutex); @@ -182,7 +180,7 @@ IpcLogOutputter::getChunk(size_t count) count = m_buffer.size(); } - String chunk; + std::string chunk; for (size_t i = 0; i < count; i++) { chunk.append(m_buffer.front()); chunk.append("\n"); diff --git a/src/lib/ipc/IpcLogOutputter.h b/src/lib/ipc/IpcLogOutputter.h index 2f1b98c..cc7b2fe 100644 --- a/src/lib/ipc/IpcLogOutputter.h +++ b/src/lib/ipc/IpcLogOutputter.h @@ -21,6 +21,7 @@ #include "arch/Arch.h" #include "arch/IArchMultithread.h" #include "base/ILogOutputter.h" +#include "base/String.h" #include "ipc/Ipc.h" #include @@ -92,12 +93,12 @@ public: private: void init(); void bufferThread(void*); - String getChunk(size_t count); - void appendBuffer(const String& text); + std::string getChunk(size_t count); + void appendBuffer(const std::string& text); bool isRunning(); private: - typedef std::deque Buffer; + typedef std::deque Buffer; IpcServer& m_ipcServer; Buffer m_buffer; diff --git a/src/lib/ipc/IpcMessage.cpp b/src/lib/ipc/IpcMessage.cpp index deef22d..9c321cb 100644 --- a/src/lib/ipc/IpcMessage.cpp +++ b/src/lib/ipc/IpcMessage.cpp @@ -47,9 +47,9 @@ IpcShutdownMessage::~IpcShutdownMessage() { } -IpcLogLineMessage::IpcLogLineMessage(const String& logLine) : -IpcMessage(kIpcLogLine), -m_logLine(logLine) +IpcLogLineMessage::IpcLogLineMessage(const std::string& logLine) : + IpcMessage(kIpcLogLine), + m_logLine(logLine) { } @@ -57,10 +57,10 @@ IpcLogLineMessage::~IpcLogLineMessage() { } -IpcCommandMessage::IpcCommandMessage(const String& command, bool elevate) : -IpcMessage(kIpcCommand), -m_command(command), -m_elevate(elevate) +IpcCommandMessage::IpcCommandMessage(const std::string& command, bool elevate) : + IpcMessage(kIpcCommand), + m_command(command), + m_elevate(elevate) { } diff --git a/src/lib/ipc/IpcMessage.h b/src/lib/ipc/IpcMessage.h index 5cc3d79..d37ebc3 100644 --- a/src/lib/ipc/IpcMessage.h +++ b/src/lib/ipc/IpcMessage.h @@ -20,8 +20,8 @@ #include "ipc/Ipc.h" #include "base/EventTypes.h" -#include "base/String.h" #include "base/Event.h" +#include class IpcMessage : public EventData { public: @@ -58,28 +58,28 @@ public: class IpcLogLineMessage : public IpcMessage { public: - IpcLogLineMessage(const String& logLine); + IpcLogLineMessage(const std::string& logLine); virtual ~IpcLogLineMessage(); //! Gets the log line. - String logLine() const { return m_logLine; } + std::string logLine() const { return m_logLine; } private: - String m_logLine; + std::string m_logLine; }; class IpcCommandMessage : public IpcMessage { public: - IpcCommandMessage(const String& command, bool elevate); + IpcCommandMessage(const std::string& command, bool elevate); virtual ~IpcCommandMessage(); //! Gets the command. - String command() const { return m_command; } + std::string command() const { return m_command; } //! Gets whether or not the process should be elevated on MS Windows. bool elevate() const { return m_elevate; } private: - String m_command; + std::string m_command; bool m_elevate; }; diff --git a/src/lib/ipc/IpcServerProxy.cpp b/src/lib/ipc/IpcServerProxy.cpp index 820e1ab..49b3e00 100644 --- a/src/lib/ipc/IpcServerProxy.cpp +++ b/src/lib/ipc/IpcServerProxy.cpp @@ -94,7 +94,7 @@ IpcServerProxy::send(const IpcMessage& message) case kIpcCommand: { const IpcCommandMessage& cm = static_cast(message); - const String command = cm.command(); + std::string command = cm.command(); ProtocolUtil::writef(&m_stream, kIpcMsgCommand, &command); break; } @@ -108,7 +108,7 @@ IpcServerProxy::send(const IpcMessage& message) IpcLogLineMessage* IpcServerProxy::parseLogLine() { - String logLine; + std::string logLine; ProtocolUtil::readf(&m_stream, kIpcMsgLogLine + 4, &logLine); // must be deleted by event handler. diff --git a/src/lib/mt/XMT.cpp b/src/lib/mt/XMT.cpp index 9aa5852..2274a6b 100644 --- a/src/lib/mt/XMT.cpp +++ b/src/lib/mt/XMT.cpp @@ -22,8 +22,7 @@ // XMTThreadUnavailable // -String -XMTThreadUnavailable::getWhat() const throw() +std::string XMTThreadUnavailable::getWhat() const noexcept { return format("XMTThreadUnavailable", "cannot create thread"); } diff --git a/src/lib/net/IDataSocket.h b/src/lib/net/IDataSocket.h index dc07df5..c77a99c 100644 --- a/src/lib/net/IDataSocket.h +++ b/src/lib/net/IDataSocket.h @@ -20,8 +20,8 @@ #include "net/ISocket.h" #include "io/IStream.h" -#include "base/String.h" #include "base/EventTypes.h" +#include //! Data stream socket interface /*! @@ -33,7 +33,7 @@ public: class ConnectionFailedInfo { public: ConnectionFailedInfo(const char* what) : m_what(what) { } - String m_what; + std::string m_what; }; IDataSocket(IEventQueue* events) { } diff --git a/src/lib/net/NetworkAddress.cpp b/src/lib/net/NetworkAddress.cpp index 8d60567..c8ea9c6 100644 --- a/src/lib/net/NetworkAddress.cpp +++ b/src/lib/net/NetworkAddress.cpp @@ -96,7 +96,7 @@ NetworkAddress::NetworkAddress(const NetworkAddress& addr) : // do nothing } -NetworkAddress::NetworkAddress(const String& hostname, int port) : +NetworkAddress::NetworkAddress(const std::string& hostname, int port) : m_address(NULL), m_hostname(hostname), m_port(port) @@ -196,8 +196,7 @@ NetworkAddress::getPort() const return m_port; } -String -NetworkAddress::getHostname() const +std::string NetworkAddress::getHostname() const { return m_hostname; } diff --git a/src/lib/net/NetworkAddress.h b/src/lib/net/NetworkAddress.h index cbd15f5..87dc1e4 100644 --- a/src/lib/net/NetworkAddress.h +++ b/src/lib/net/NetworkAddress.h @@ -18,7 +18,6 @@ #pragma once -#include "base/String.h" #include "base/EventTypes.h" #include "arch/IArchNetwork.h" @@ -49,7 +48,7 @@ public: is thrown with an error of \c XSocketAddress::kBadPort. The hostname is not resolved by the c'tor; use \c resolve to do that. */ - NetworkAddress(const String& hostname, int port); + NetworkAddress(const std::string& hostname, int port); NetworkAddress(const NetworkAddress&); @@ -109,7 +108,7 @@ public: /*! Returns the hostname passed to the c'tor sans any port suffix. */ - String getHostname() const; + std::string getHostname() const; //@} @@ -118,6 +117,6 @@ private: private: ArchNetAddress m_address; - String m_hostname; + std::string m_hostname; int m_port; }; diff --git a/src/lib/net/SecureListenSocket.cpp b/src/lib/net/SecureListenSocket.cpp index 7af905e..a137f39 100644 --- a/src/lib/net/SecureListenSocket.cpp +++ b/src/lib/net/SecureListenSocket.cpp @@ -23,6 +23,7 @@ #include "net/TSocketMultiplexerMethodJob.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" }; @@ -54,7 +55,7 @@ SecureListenSocket::accept() setListeningJob(); } - String certificateFilename = barrier::string::sprintf("%s/%s/%s", + std::string certificateFilename = barrier::string::sprintf("%s/%s/%s", DataDirectories::profile().c_str(), s_certificateDir, s_certificateFilename); diff --git a/src/lib/net/SecureSocket.cpp b/src/lib/net/SecureSocket.cpp index 99f626e..855e16b 100644 --- a/src/lib/net/SecureSocket.cpp +++ b/src/lib/net/SecureSocket.cpp @@ -23,6 +23,7 @@ #include "mt/Lock.h" #include "arch/XArch.h" #include "base/Log.h" +#include "base/String.h" #include "common/DataDirectories.h" #include @@ -328,8 +329,7 @@ SecureSocket::initSsl(bool server) initContext(server); } -bool -SecureSocket::loadCertificates(String& filename) +bool SecureSocket::loadCertificates(std::string& filename) { if (filename.empty()) { showError("ssl certificate is not specified"); @@ -341,7 +341,7 @@ SecureSocket::loadCertificates(String& filename) file.close(); if (!exist) { - String errorMsg("ssl certificate doesn't exist: "); + std::string errorMsg("ssl certificate doesn't exist: "); errorMsg.append(filename); showError(errorMsg.c_str()); return false; @@ -630,14 +630,13 @@ SecureSocket::showError(const char* reason) LOG((CLOG_ERR "%s", reason)); } - String error = getError(); + std::string error = getError(); if (!error.empty()) { LOG((CLOG_ERR "%s", error.c_str())); } } -String -SecureSocket::getError() +std::string SecureSocket::getError() { unsigned long e = ERR_get_error(); @@ -659,8 +658,7 @@ SecureSocket::disconnect() sendEvent(getEvents()->forIStream().inputShutdown()); } -void -SecureSocket::formatFingerprint(String& fingerprint, bool hex, bool separator) +void SecureSocket::formatFingerprint(std::string& fingerprint, bool hex, bool separator) { if (hex) { // to hexidecimal @@ -696,11 +694,11 @@ SecureSocket::verifyCertFingerprint() } // format fingerprint into hexdecimal format with colon separator - String fingerprint(reinterpret_cast(tempFingerprint), tempFingerprintLen); + std::string fingerprint(reinterpret_cast(tempFingerprint), tempFingerprintLen); formatFingerprint(fingerprint); LOG((CLOG_NOTE "server fingerprint: %s", fingerprint.c_str())); - String trustedServersFilename; + std::string trustedServersFilename; trustedServersFilename = barrier::string::sprintf( "%s/%s/%s", DataDirectories::profile().c_str(), @@ -711,7 +709,7 @@ SecureSocket::verifyCertFingerprint() LOG((CLOG_NOTE "trustedServersFilename: %s", trustedServersFilename.c_str() )); // check if this fingerprint exist - String fileLine; + std::string fileLine; std::ifstream file; file.open(trustedServersFilename.c_str()); @@ -761,7 +759,7 @@ MultiplexerJobStatus SecureSocket::serviceConnect(ISocketMultiplexerJob* job, // If status > 0, success if (status > 0) { sendEvent(m_events->forIDataSocket().secureConnected()); - return {true, newJob()}; + return newJobOrStopServicing(); } // Retry case @@ -793,7 +791,7 @@ MultiplexerJobStatus SecureSocket::serviceAccept(ISocketMultiplexerJob* job, // If status > 0, success if (status > 0) { sendEvent(m_events->forClientListener().accepted()); - return {true, newJob()}; + return newJobOrStopServicing(); } // Retry case diff --git a/src/lib/net/SecureSocket.h b/src/lib/net/SecureSocket.h index 773b508..c602e2d 100644 --- a/src/lib/net/SecureSocket.h +++ b/src/lib/net/SecureSocket.h @@ -39,23 +39,23 @@ public: ~SecureSocket(); // ISocket overrides - void close(); + void close() override; // IDataSocket overrides - virtual void connect(const NetworkAddress&); + virtual void connect(const NetworkAddress&) override; std::unique_ptr newJob() override; - bool isFatal() const { return m_fatal; } + bool isFatal() const override { return m_fatal; } void isFatal(bool b) { m_fatal = b; } bool isSecureReady(); void secureConnect(); void secureAccept(); int secureRead(void* buffer, int size, int& read); int secureWrite(const void* buffer, int size, int& wrote); - EJobResult doRead(); - EJobResult doWrite(); + EJobResult doRead() override; + EJobResult doWrite() override; void initSsl(bool server); - bool loadCertificates(String& CertFile); + bool loadCertificates(std::string& CertFile); private: // SSL @@ -66,11 +66,9 @@ private: bool showCertificate(); void checkResult(int n, int& retry); void showError(const char* reason = NULL); - String getError(); + std::string getError(); void disconnect(); - void formatFingerprint(String& fingerprint, - bool hex = true, - bool separator = true); + void formatFingerprint(std::string& fingerprint, bool hex = true, bool separator = true); bool verifyCertFingerprint(); MultiplexerJobStatus serviceConnect(ISocketMultiplexerJob*, bool, bool, bool); diff --git a/src/lib/net/TCPSocket.cpp b/src/lib/net/TCPSocket.cpp index 4f4251a..09a8f17 100644 --- a/src/lib/net/TCPSocket.cpp +++ b/src/lib/net/TCPSocket.cpp @@ -403,6 +403,15 @@ void TCPSocket::setJob(std::unique_ptr&& job) } } +MultiplexerJobStatus TCPSocket::newJobOrStopServicing() +{ + auto new_job = newJob(); + if (new_job) + return {true, std::move(new_job)}; + else + return {false, {}}; +} + std::unique_ptr TCPSocket::newJob() { // note -- must have m_mutex locked on entry @@ -519,22 +528,14 @@ MultiplexerJobStatus TCPSocket::serviceConnecting(ISocketMultiplexerJob* job, bo catch (XArchNetwork& e) { sendConnectionFailedEvent(e.what()); onDisconnected(); - auto new_job = newJob(); - if (new_job) - return {true, std::move(new_job)}; - else - return {false, {}}; + return newJobOrStopServicing(); } } if (write) { sendEvent(m_events->forIDataSocket().connected()); onConnected(); - auto new_job = newJob(); - if (new_job) - return {true, std::move(new_job)}; - else - return {false, {}}; + return newJobOrStopServicing(); } return {true, {}}; @@ -548,7 +549,7 @@ MultiplexerJobStatus TCPSocket::serviceConnected(ISocketMultiplexerJob* job, if (error) { sendEvent(m_events->forISocket().disconnected()); onDisconnected(); - return {true, newJob()}; + return newJobOrStopServicing(); } EJobResult writeResult = kRetry; @@ -603,7 +604,7 @@ MultiplexerJobStatus TCPSocket::serviceConnected(ISocketMultiplexerJob* job, if (writeResult == kBreak || readResult == kBreak) { return {false, {}}; } else if (writeResult == kNew || readResult == kNew) { - return {true, newJob()}; + return newJobOrStopServicing(); } else { return {true, {}}; } diff --git a/src/lib/net/TCPSocket.h b/src/lib/net/TCPSocket.h index 2889135..0b98888 100644 --- a/src/lib/net/TCPSocket.h +++ b/src/lib/net/TCPSocket.h @@ -76,7 +76,8 @@ protected: void removeJob(); void setJob(std::unique_ptr&& job); - + MultiplexerJobStatus newJobOrStopServicing(); + bool isReadable() { return m_readable; } bool isWritable() { return m_writable; } diff --git a/src/lib/net/XSocket.cpp b/src/lib/net/XSocket.cpp index 13e0fc3..eed7a26 100644 --- a/src/lib/net/XSocket.cpp +++ b/src/lib/net/XSocket.cpp @@ -23,8 +23,7 @@ // XSocketAddress // -XSocketAddress::XSocketAddress(EError error, - const String& hostname, int port) _NOEXCEPT : +XSocketAddress::XSocketAddress(EError error, const std::string& hostname, int port) noexcept : m_error(error), m_hostname(hostname), m_port(port) @@ -32,26 +31,22 @@ XSocketAddress::XSocketAddress(EError error, // do nothing } -XSocketAddress::EError -XSocketAddress::getError() const throw() +XSocketAddress::EError XSocketAddress::getError() const noexcept { return m_error; } -String -XSocketAddress::getHostname() const throw() +std::string XSocketAddress::getHostname() const noexcept { return m_hostname; } -int -XSocketAddress::getPort() const throw() +int XSocketAddress::getPort() const noexcept { return m_port; } -String -XSocketAddress::getWhat() const throw() +std::string XSocketAddress::getWhat() const noexcept { static const char* s_errorID[] = { "XSocketAddressUnknown", @@ -77,8 +72,7 @@ XSocketAddress::getWhat() const throw() // XSocketIOClose // -String -XSocketIOClose::getWhat() const throw() +std::string XSocketIOClose::getWhat() const noexcept { return format("XSocketIOClose", "close: %{1}", what()); } @@ -88,8 +82,7 @@ XSocketIOClose::getWhat() const throw() // XSocketBind // -String -XSocketBind::getWhat() const throw() +std::string XSocketBind::getWhat() const noexcept { return format("XSocketBind", "cannot bind address: %{1}", what()); } @@ -99,8 +92,7 @@ XSocketBind::getWhat() const throw() // XSocketConnect // -String -XSocketConnect::getWhat() const throw() +std::string XSocketConnect::getWhat() const noexcept { return format("XSocketConnect", "cannot connect socket: %{1}", what()); } @@ -110,8 +102,7 @@ XSocketConnect::getWhat() const throw() // XSocketCreate // -String -XSocketCreate::getWhat() const throw() +std::string XSocketCreate::getWhat() const noexcept { return format("XSocketCreate", "cannot create socket: %{1}", what()); } diff --git a/src/lib/net/XSocket.h b/src/lib/net/XSocket.h index be02b5b..d12278e 100644 --- a/src/lib/net/XSocket.h +++ b/src/lib/net/XSocket.h @@ -20,7 +20,6 @@ #include "io/XIO.h" #include "base/XBase.h" -#include "base/String.h" #include "common/basic_types.h" //! Generic socket exception @@ -41,28 +40,28 @@ public: kBadPort //!< The port is invalid }; - XSocketAddress(EError, const String& hostname, int port) _NOEXCEPT; - virtual ~XSocketAddress() _NOEXCEPT { } + XSocketAddress(EError, const std::string& hostname, int port) noexcept; + virtual ~XSocketAddress() noexcept { } //! @name accessors //@{ //! Get the error code - EError getError() const throw(); + EError getError() const noexcept; //! Get the hostname - String getHostname() const throw(); + std::string getHostname() const noexcept; //! Get the port - int getPort() const throw(); + int getPort() const noexcept; //@} protected: // XBase overrides - virtual String getWhat() const throw(); + virtual std::string getWhat() const noexcept; private: EError m_error; - String m_hostname; + std::string m_hostname; int m_port; }; diff --git a/src/lib/platform/MSWindowsClipboard.cpp b/src/lib/platform/MSWindowsClipboard.cpp index 8ab50df..20445d4 100644 --- a/src/lib/platform/MSWindowsClipboard.cpp +++ b/src/lib/platform/MSWindowsClipboard.cpp @@ -98,7 +98,7 @@ MSWindowsClipboard::empty() } void -MSWindowsClipboard::add(EFormat format, const String& data) +MSWindowsClipboard::add(EFormat format, const std::string& data) { LOG((CLOG_DEBUG "add %d bytes to clipboard format: %d", data.size(), format)); @@ -165,8 +165,7 @@ MSWindowsClipboard::has(EFormat format) const return false; } -String -MSWindowsClipboard::get(EFormat format) const +std::string MSWindowsClipboard::get(EFormat format) const { // find the converter for the first clipboard format we can handle IMSWindowsClipboardConverter* converter = NULL; @@ -183,7 +182,7 @@ MSWindowsClipboard::get(EFormat format) const // if no converter then we don't recognize any formats if (converter == NULL) { LOG((CLOG_WARN "no converter for format %d", format)); - return String(); + return {}; } // get a handle to the clipboard data @@ -192,7 +191,7 @@ MSWindowsClipboard::get(EFormat format) const // nb: can't cause this using integ tests; this is only caused when // the selected converter returns an invalid format -- which you // cannot cause using public functions. - return String(); + return {}; } // convert diff --git a/src/lib/platform/MSWindowsClipboard.h b/src/lib/platform/MSWindowsClipboard.h index 3e92a39..35ccb56 100644 --- a/src/lib/platform/MSWindowsClipboard.h +++ b/src/lib/platform/MSWindowsClipboard.h @@ -55,21 +55,21 @@ public: // IClipboard overrides virtual bool empty(); - virtual void add(EFormat, const String& data); + virtual void add(EFormat, const std::string& data); virtual bool open(Time) const; virtual void close() const; virtual Time getTime() const; virtual bool has(EFormat) const; - virtual String get(EFormat) const; + virtual std::string get(EFormat) const; void setFacade(IMSWindowsClipboardFacade& facade); private: void clearConverters(); - UINT convertFormatToWin32(EFormat) const; - HANDLE convertTextToWin32(const String& data) const; - String convertTextFromWin32(HANDLE) const; + UINT convertFormatToWin32(EFormat) const; + HANDLE convertTextToWin32(const std::string& data) const; + std::string convertTextFromWin32(HANDLE) const; static UINT getOwnershipFormat(); @@ -105,9 +105,9 @@ public: // the input data must be in the IClipboard format returned by // getFormat(). the return data will be in the win32 clipboard // format returned by getWin32Format(), allocated by GlobalAlloc(). - virtual HANDLE fromIClipboard(const String&) const = 0; + virtual HANDLE fromIClipboard(const std::string&) const = 0; // convert from the win32 clipboard format to the IClipboard format // (i.e., the reverse of fromIClipboard()). - virtual String toIClipboard(HANDLE data) const = 0; + virtual std::string toIClipboard(HANDLE data) const = 0; }; diff --git a/src/lib/platform/MSWindowsClipboardAnyTextConverter.cpp b/src/lib/platform/MSWindowsClipboardAnyTextConverter.cpp index decbad6..85a7dbe 100644 --- a/src/lib/platform/MSWindowsClipboardAnyTextConverter.cpp +++ b/src/lib/platform/MSWindowsClipboardAnyTextConverter.cpp @@ -38,11 +38,10 @@ MSWindowsClipboardAnyTextConverter::getFormat() const return IClipboard::kText; } -HANDLE -MSWindowsClipboardAnyTextConverter::fromIClipboard(const String& data) const +HANDLE MSWindowsClipboardAnyTextConverter::fromIClipboard(const std::string& data) const { // convert linefeeds and then convert to desired encoding - String text = doFromIClipboard(convertLinefeedToWin32(data)); + std::string text = doFromIClipboard(convertLinefeedToWin32(data)); UInt32 size = (UInt32)text.size(); // copy to memory handle @@ -63,18 +62,17 @@ MSWindowsClipboardAnyTextConverter::fromIClipboard(const String& data) const return gData; } -String -MSWindowsClipboardAnyTextConverter::toIClipboard(HANDLE data) const +std::string MSWindowsClipboardAnyTextConverter::toIClipboard(HANDLE data) const { // get datator const char* src = (const char*)GlobalLock(data); UInt32 srcSize = (UInt32)GlobalSize(data); if (src == NULL || srcSize <= 1) { - return String(); + return {}; } // convert text - String text = doToIClipboard(String(src, srcSize)); + std::string text = doToIClipboard(std::string(src, srcSize)); // release handle GlobalUnlock(data); @@ -83,9 +81,7 @@ MSWindowsClipboardAnyTextConverter::toIClipboard(HANDLE data) const return convertLinefeedToUnix(text); } -String -MSWindowsClipboardAnyTextConverter::convertLinefeedToWin32( - const String& src) const +std::string MSWindowsClipboardAnyTextConverter::convertLinefeedToWin32(const std::string& src) const { // note -- we assume src is a valid UTF-8 string @@ -102,7 +98,7 @@ MSWindowsClipboardAnyTextConverter::convertLinefeedToWin32( } // allocate new string - String dst; + std::string dst; dst.reserve(src.size() + numNewlines); // copy string, converting newlines @@ -117,9 +113,7 @@ MSWindowsClipboardAnyTextConverter::convertLinefeedToWin32( return dst; } -String -MSWindowsClipboardAnyTextConverter::convertLinefeedToUnix( - const String& src) const +std::string MSWindowsClipboardAnyTextConverter::convertLinefeedToUnix(const std::string& src) const { // count newlines in string UInt32 numNewlines = 0; @@ -134,7 +128,7 @@ MSWindowsClipboardAnyTextConverter::convertLinefeedToUnix( } // allocate new string - String dst; + std::string dst; dst.reserve(src.size()); // copy string, converting newlines diff --git a/src/lib/platform/MSWindowsClipboardAnyTextConverter.h b/src/lib/platform/MSWindowsClipboardAnyTextConverter.h index cabdb0b..622d281 100644 --- a/src/lib/platform/MSWindowsClipboardAnyTextConverter.h +++ b/src/lib/platform/MSWindowsClipboardAnyTextConverter.h @@ -31,8 +31,8 @@ public: virtual IClipboard::EFormat getFormat() const; virtual UINT getWin32Format() const = 0; - virtual HANDLE fromIClipboard(const String&) const; - virtual String toIClipboard(HANDLE) const; + virtual HANDLE fromIClipboard(const std::string&) const; + virtual std::string toIClipboard(HANDLE) const; protected: //! Convert from IClipboard format @@ -40,18 +40,18 @@ protected: Do UTF-8 conversion only. Memory handle allocation and linefeed conversion is done by this class. doFromIClipboard() must include the nul terminator in the returned string (not - including the String's nul terminator). + including the std::string's nul terminator). */ - virtual String doFromIClipboard(const String&) const = 0; + virtual std::string doFromIClipboard(const std::string&) const = 0; //! Convert to IClipboard format /*! Do UTF-8 conversion only. Memory handle allocation and linefeed conversion is done by this class. */ - virtual String doToIClipboard(const String&) const = 0; + virtual std::string doToIClipboard(const std::string&) const = 0; private: - String convertLinefeedToWin32(const String&) const; - String convertLinefeedToUnix(const String&) const; + std::string convertLinefeedToWin32(const std::string&) const; + std::string convertLinefeedToUnix(const std::string&) const; }; diff --git a/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp b/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp index 16bd4bf..7d38fda 100644 --- a/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp +++ b/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp @@ -46,8 +46,7 @@ MSWindowsClipboardBitmapConverter::getWin32Format() const return CF_DIB; } -HANDLE -MSWindowsClipboardBitmapConverter::fromIClipboard(const String& data) const +HANDLE MSWindowsClipboardBitmapConverter::fromIClipboard(const std::string& data) const { // copy to memory handle HGLOBAL gData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, data.size()); @@ -67,13 +66,12 @@ MSWindowsClipboardBitmapConverter::fromIClipboard(const String& data) const return gData; } -String -MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const +std::string MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const { // get datator LPVOID src = GlobalLock(data); if (src == NULL) { - return String(); + return {}; } UInt32 srcSize = (UInt32)GlobalSize(data); @@ -85,7 +83,7 @@ MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const bitmap->bmiHeader.biBitCount == 32) && bitmap->bmiHeader.biCompression == BI_RGB) { // already in canonical form - String image(static_cast(src), srcSize); + std::string image(static_cast(src), srcSize); GlobalUnlock(data); return image; } @@ -138,7 +136,7 @@ MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const GdiFlush(); // extract data - String image((const char*)&info, info.biSize); + std::string image((const char*)&info, info.biSize); image.append((const char*)raw, 4 * w * h); // clean up GDI diff --git a/src/lib/platform/MSWindowsClipboardBitmapConverter.h b/src/lib/platform/MSWindowsClipboardBitmapConverter.h index 52b5547..2733884 100644 --- a/src/lib/platform/MSWindowsClipboardBitmapConverter.h +++ b/src/lib/platform/MSWindowsClipboardBitmapConverter.h @@ -31,6 +31,6 @@ public: virtual IClipboard::EFormat getFormat() const; virtual UINT getWin32Format() const; - virtual HANDLE fromIClipboard(const String&) const; - virtual String toIClipboard(HANDLE) const; + virtual HANDLE fromIClipboard(const std::string&) const; + virtual std::string toIClipboard(HANDLE) const; }; diff --git a/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp b/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp index 347a224..a1f1212 100644 --- a/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp +++ b/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp @@ -46,15 +46,14 @@ MSWindowsClipboardHTMLConverter::getWin32Format() const return m_format; } -String -MSWindowsClipboardHTMLConverter::doFromIClipboard(const String& data) const +std::string MSWindowsClipboardHTMLConverter::doFromIClipboard(const std::string& data) const { // prepare to CF_HTML format prefix and suffix - String prefix("Version:0.9\r\nStartHTML:0000000105\r\n" + std::string prefix("Version:0.9\r\nStartHTML:0000000105\r\n" "EndHTML:ZZZZZZZZZZ\r\n" "StartFragment:XXXXXXXXXX\r\nEndFragment:YYYYYYYYYY\r\n" ""); - String suffix("\r\n"); + std::string suffix("\r\n"); // Get byte offsets for header UInt32 StartFragment = (UInt32)prefix.size(); @@ -75,45 +74,43 @@ MSWindowsClipboardHTMLConverter::doFromIClipboard(const String& data) const return prefix; } -String -MSWindowsClipboardHTMLConverter::doToIClipboard(const String& data) const +std::string MSWindowsClipboardHTMLConverter::doToIClipboard(const std::string& data) const { // get fragment start/end args - String startArg = findArg(data, "StartFragment"); - String endArg = findArg(data, "EndFragment"); + std::string startArg = findArg(data, "StartFragment"); + std::string endArg = findArg(data, "EndFragment"); if (startArg.empty() || endArg.empty()) { - return String(); + return std::string(); } // convert args to integers SInt32 start = (SInt32)atoi(startArg.c_str()); SInt32 end = (SInt32)atoi(endArg.c_str()); if (start <= 0 || end <= 0 || start >= end) { - return String(); + return std::string(); } // extract the fragment return data.substr(start, end - start); } -String -MSWindowsClipboardHTMLConverter::findArg( - const String& data, const String& name) const +std::string MSWindowsClipboardHTMLConverter::findArg(const std::string& data, + const std::string& name) const { - String::size_type i = data.find(name); - if (i == String::npos) { - return String(); + std::string::size_type i = data.find(name); + if (i == std::string::npos) { + return std::string(); } i = data.find_first_of(":\r\n", i); - if (i == String::npos || data[i] != ':') { - return String(); + if (i == std::string::npos || data[i] != ':') { + return std::string(); } i = data.find_first_of("0123456789\r\n", i + 1); - if (i == String::npos || data[i] == '\r' || data[i] == '\n') { - return String(); + if (i == std::string::npos || data[i] == '\r' || data[i] == '\n') { + return std::string(); } - String::size_type j = data.find_first_not_of("0123456789", i); - if (j == String::npos) { + std::string::size_type j = data.find_first_not_of("0123456789", i); + if (j == std::string::npos) { j = data.size(); } return data.substr(i, j - i); diff --git a/src/lib/platform/MSWindowsClipboardHTMLConverter.h b/src/lib/platform/MSWindowsClipboardHTMLConverter.h index 66c8045..51607a7 100644 --- a/src/lib/platform/MSWindowsClipboardHTMLConverter.h +++ b/src/lib/platform/MSWindowsClipboardHTMLConverter.h @@ -34,11 +34,11 @@ public: protected: // MSWindowsClipboardAnyTextConverter overrides - virtual String doFromIClipboard(const String&) const; - virtual String doToIClipboard(const String&) const; + virtual std::string doFromIClipboard(const std::string&) const; + virtual std::string doToIClipboard(const std::string&) const; private: - String findArg(const String& data, const String& name) const; + std::string findArg(const std::string& data, const std::string& name) const; private: UINT m_format; diff --git a/src/lib/platform/MSWindowsClipboardTextConverter.cpp b/src/lib/platform/MSWindowsClipboardTextConverter.cpp index 360c72c..1500e7e 100644 --- a/src/lib/platform/MSWindowsClipboardTextConverter.cpp +++ b/src/lib/platform/MSWindowsClipboardTextConverter.cpp @@ -40,20 +40,18 @@ MSWindowsClipboardTextConverter::getWin32Format() const return CF_TEXT; } -String -MSWindowsClipboardTextConverter::doFromIClipboard(const String& data) const +std::string MSWindowsClipboardTextConverter::doFromIClipboard(const std::string& data) const { // convert and add nul terminator return Unicode::UTF8ToText(data) += '\0'; } -String -MSWindowsClipboardTextConverter::doToIClipboard(const String& data) const +std::string MSWindowsClipboardTextConverter::doToIClipboard(const std::string& data) const { // convert and truncate at first nul terminator - String dst = Unicode::textToUTF8(data); - String::size_type n = dst.find('\0'); - if (n != String::npos) { + std::string dst = Unicode::textToUTF8(data); + std::string::size_type n = dst.find('\0'); + if (n != std::string::npos) { dst.erase(n); } return dst; diff --git a/src/lib/platform/MSWindowsClipboardTextConverter.h b/src/lib/platform/MSWindowsClipboardTextConverter.h index fb081c3..6e265a2 100644 --- a/src/lib/platform/MSWindowsClipboardTextConverter.h +++ b/src/lib/platform/MSWindowsClipboardTextConverter.h @@ -32,6 +32,6 @@ public: protected: // MSWindowsClipboardAnyTextConverter overrides - virtual String doFromIClipboard(const String&) const; - virtual String doToIClipboard(const String&) const; + virtual std::string doFromIClipboard(const std::string&) const; + virtual std::string doToIClipboard(const std::string&) const; }; diff --git a/src/lib/platform/MSWindowsClipboardUTF16Converter.cpp b/src/lib/platform/MSWindowsClipboardUTF16Converter.cpp index 0f8642a..4b72717 100644 --- a/src/lib/platform/MSWindowsClipboardUTF16Converter.cpp +++ b/src/lib/platform/MSWindowsClipboardUTF16Converter.cpp @@ -40,20 +40,18 @@ MSWindowsClipboardUTF16Converter::getWin32Format() const return CF_UNICODETEXT; } -String -MSWindowsClipboardUTF16Converter::doFromIClipboard(const String& data) const +std::string MSWindowsClipboardUTF16Converter::doFromIClipboard(const std::string& data) const { // convert and add nul terminator return Unicode::UTF8ToUTF16(data).append(sizeof(wchar_t), 0); } -String -MSWindowsClipboardUTF16Converter::doToIClipboard(const String& data) const +std::string MSWindowsClipboardUTF16Converter::doToIClipboard(const std::string& data) const { // convert and strip nul terminator - String dst = Unicode::UTF16ToUTF8(data); - String::size_type n = dst.find('\0'); - if (n != String::npos) { + std::string dst = Unicode::UTF16ToUTF8(data); + std::string::size_type n = dst.find('\0'); + if (n != std::string::npos) { dst.erase(n); } return dst; diff --git a/src/lib/platform/MSWindowsClipboardUTF16Converter.h b/src/lib/platform/MSWindowsClipboardUTF16Converter.h index e7222bc..1a9d435 100644 --- a/src/lib/platform/MSWindowsClipboardUTF16Converter.h +++ b/src/lib/platform/MSWindowsClipboardUTF16Converter.h @@ -32,6 +32,6 @@ public: protected: // MSWindowsClipboardAnyTextConverter overrides - virtual String doFromIClipboard(const String&) const; - virtual String doToIClipboard(const String&) const; + virtual std::string doFromIClipboard(const std::string&) const; + virtual std::string doToIClipboard(const std::string&) const; }; diff --git a/src/lib/platform/MSWindowsDesks.cpp b/src/lib/platform/MSWindowsDesks.cpp index e47aeaa..768ccb4 100644 --- a/src/lib/platform/MSWindowsDesks.cpp +++ b/src/lib/platform/MSWindowsDesks.cpp @@ -746,8 +746,7 @@ MSWindowsDesks::deskThread(void* vdesk) } } -MSWindowsDesks::Desk* -MSWindowsDesks::addDesk(const String& name, HDESK hdesk) +MSWindowsDesks::Desk* MSWindowsDesks::addDesk(const std::string& name, HDESK hdesk) { Desk* desk = new Desk; desk->m_name = name; @@ -782,7 +781,7 @@ MSWindowsDesks::checkDesk() // get current desktop. if we already know about it then return. Desk* desk; HDESK hdesk = openInputDesktop(); - String name = getDesktopName(hdesk); + std::string name = getDesktopName(hdesk); Desks::const_iterator index = m_desks.find(name); if (index == m_desks.end()) { desk = addDesk(name, hdesk); @@ -900,18 +899,17 @@ MSWindowsDesks::closeDesktop(HDESK desk) } } -String -MSWindowsDesks::getDesktopName(HDESK desk) +std::string MSWindowsDesks::getDesktopName(HDESK desk) { if (desk == NULL) { - return String(); + return {}; } else { DWORD size; GetUserObjectInformation(desk, UOI_NAME, NULL, 0, &size); TCHAR* name = (TCHAR*)alloca(size + sizeof(TCHAR)); GetUserObjectInformation(desk, UOI_NAME, name, size, &size); - String result(name); + std::string result(name); return result; } } diff --git a/src/lib/platform/MSWindowsDesks.h b/src/lib/platform/MSWindowsDesks.h index da93c34..6e5e709 100644 --- a/src/lib/platform/MSWindowsDesks.h +++ b/src/lib/platform/MSWindowsDesks.h @@ -25,8 +25,8 @@ #include "barrier/option_types.h" #include "mt/CondVar.h" #include "mt/Mutex.h" -#include "base/String.h" #include "common/stdmap.h" +#include #define WIN32_LEAN_AND_MEAN #include @@ -195,7 +195,7 @@ public: private: class Desk { public: - String m_name; + std::string m_name; Thread* m_thread; DWORD m_threadID; DWORD m_targetID; @@ -204,7 +204,7 @@ private: HWND m_foregroundWindow; bool m_lowLevel; }; - typedef std::map Desks; + typedef std::map Desks; // initialization and shutdown operations HCURSOR createBlankCursor() const; @@ -222,7 +222,7 @@ private: void deskThread(void* vdesk); // desk switch checking and handling - Desk* addDesk(const String& name, HDESK hdesk); + Desk* addDesk(const std::string& name, HDESK hdesk); void removeDesks(); void checkDesk(); bool isDeskAccessible(const Desk* desk) const; @@ -238,7 +238,7 @@ private: // desk API wrappers HDESK openInputDesktop(); void closeDesktop(HDESK); - String getDesktopName(HDESK); + std::string getDesktopName(HDESK); // our desk window procs static LRESULT CALLBACK primaryDeskProc(HWND, UINT, WPARAM, LPARAM); @@ -276,7 +276,7 @@ private: // the current desk and it's name Desk* m_activeDesk; - String m_activeDeskName; + std::string m_activeDeskName; // one desk per desktop and a cond var to communicate with it Mutex m_mutex; diff --git a/src/lib/platform/MSWindowsEventQueueBuffer.cpp b/src/lib/platform/MSWindowsEventQueueBuffer.cpp index f6de157..3111367 100644 --- a/src/lib/platform/MSWindowsEventQueueBuffer.cpp +++ b/src/lib/platform/MSWindowsEventQueueBuffer.cpp @@ -21,6 +21,7 @@ #include "arch/win32/ArchMiscWindows.h" #include "mt/Thread.h" #include "base/IEventQueue.h" +#include // // EventQueueTimer @@ -48,6 +49,15 @@ MSWindowsEventQueueBuffer::MSWindowsEventQueueBuffer(IEventQueue* events) : // make sure this thread has a message queue MSG dummy; PeekMessage(&dummy, NULL, WM_USER, WM_USER, PM_NOREMOVE); + + m_os_supported_message_types = QS_ALLINPUT; + if (!IsWindows8OrGreater()) + { + // don't use QS_POINTER, QS_TOUCH + // because they can cause GetQueueStatus() to always return 0 and we miss events + // since those flags are confusing Windows 7. See QTBUG-29097 for related info + m_os_supported_message_types &= ~(QS_TOUCH | QS_POINTER); + } } MSWindowsEventQueueBuffer::~MSWindowsEventQueueBuffer() @@ -79,7 +89,7 @@ MSWindowsEventQueueBuffer::waitForEvent(double timeout) // cancellation but that's okay because we're run in the main // thread and we never cancel that thread. HANDLE dummy[1]; - MsgWaitForMultipleObjects(0, dummy, FALSE, t, QS_ALLINPUT); + MsgWaitForMultipleObjects(0, dummy, FALSE, t, m_os_supported_message_types); } IEventQueueBuffer::Type @@ -128,9 +138,7 @@ MSWindowsEventQueueBuffer::addEvent(UInt32 dataID) bool MSWindowsEventQueueBuffer::isEmpty() const { - // don't use QS_POINTER, QS_TOUCH, or any meta-flags that include them (like QS_ALLINPUT) - // because they can cause GetQueueStatus() to always return 0 and we miss events - return (HIWORD(GetQueueStatus(QS_POSTMESSAGE)) == 0); + return (HIWORD(GetQueueStatus(m_os_supported_message_types)) == 0); } EventQueueTimer* diff --git a/src/lib/platform/MSWindowsEventQueueBuffer.h b/src/lib/platform/MSWindowsEventQueueBuffer.h index 6a0f9f9..bc9bde1 100644 --- a/src/lib/platform/MSWindowsEventQueueBuffer.h +++ b/src/lib/platform/MSWindowsEventQueueBuffer.h @@ -47,4 +47,5 @@ private: MSG m_event; UINT m_daemonQuit; IEventQueue* m_events; + UINT m_os_supported_message_types; }; diff --git a/src/lib/platform/MSWindowsKeyState.h b/src/lib/platform/MSWindowsKeyState.h index b226d8b..3c5fa40 100644 --- a/src/lib/platform/MSWindowsKeyState.h +++ b/src/lib/platform/MSWindowsKeyState.h @@ -19,7 +19,6 @@ #pragma once #include "barrier/KeyState.h" -#include "base/String.h" #include "common/stdvector.h" #define WIN32_LEAN_AND_MEAN diff --git a/src/lib/platform/MSWindowsScreen.cpp b/src/lib/platform/MSWindowsScreen.cpp index 2717034..df10270 100644 --- a/src/lib/platform/MSWindowsScreen.cpp +++ b/src/lib/platform/MSWindowsScreen.cpp @@ -38,7 +38,6 @@ #include "arch/Arch.h" #include "base/FunctionJob.h" #include "base/Log.h" -#include "base/String.h" #include "base/IEventQueue.h" #include "base/TMethodEventJob.h" #include "base/TMethodJob.h" @@ -150,7 +149,7 @@ MSWindowsScreen::MSWindowsScreen( // 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 = String(desktopPath); + m_desktopPath = std::string(desktopPath); LOG((CLOG_DEBUG "using desktop for drop target: %s", m_desktopPath.c_str())); } else { @@ -378,7 +377,7 @@ MSWindowsScreen::leave() void MSWindowsScreen::sendDragThread(void*) { - String& draggingFilename = getDraggingFilename(); + std::string& draggingFilename = getDraggingFilename(); size_t size = draggingFilename.size(); if (draggingFilename.empty() == false) { @@ -1867,8 +1866,7 @@ MSWindowsScreen::fakeDraggingFiles(DragFileList fileList) // exception from being thrown. } -String& -MSWindowsScreen::getDraggingFilename() +std::string& MSWindowsScreen::getDraggingFilename() { if (m_draggingStarted) { m_dropTarget->clearDraggingFilename(); @@ -1894,7 +1892,7 @@ MSWindowsScreen::getDraggingFilename() fakeKeyUp(1); fakeMouseButton(kButtonLeft, false); - String filename; + std::string filename; DOUBLE timeout = ARCH->time() + .5f; while (ARCH->time() < timeout) { ARCH->sleep(.05f); @@ -1923,8 +1921,7 @@ MSWindowsScreen::getDraggingFilename() return m_draggingFilename; } -const String& -MSWindowsScreen::getDropTarget() const +const std::string& MSWindowsScreen::getDropTarget() const { return m_desktopPath; } diff --git a/src/lib/platform/MSWindowsScreen.h b/src/lib/platform/MSWindowsScreen.h index 14cd505..49e09df 100644 --- a/src/lib/platform/MSWindowsScreen.h +++ b/src/lib/platform/MSWindowsScreen.h @@ -25,7 +25,7 @@ #include "platform/synwinhk.h" #include "mt/CondVar.h" #include "mt/Mutex.h" -#include "base/String.h" +#include #define WIN32_LEAN_AND_MEAN #include @@ -118,9 +118,8 @@ public: virtual void setSequenceNumber(UInt32); virtual bool isPrimary() const; virtual void fakeDraggingFiles(DragFileList fileList); - virtual String& getDraggingFilename(); - virtual const String& - getDropTarget() const; + virtual std::string& getDraggingFilename(); + virtual const std::string& getDropTarget() const; protected: // IPlatformScreen overrides @@ -333,7 +332,7 @@ private: IEventQueue* m_events; - String m_desktopPath; + std::string m_desktopPath; MSWindowsDropTarget* m_dropTarget; diff --git a/src/lib/platform/MSWindowsScreenSaver.h b/src/lib/platform/MSWindowsScreenSaver.h index 91df181..a117370 100644 --- a/src/lib/platform/MSWindowsScreenSaver.h +++ b/src/lib/platform/MSWindowsScreenSaver.h @@ -19,7 +19,6 @@ #pragma once #include "barrier/IScreenSaver.h" -#include "base/String.h" #define WIN32_LEAN_AND_MEAN #include diff --git a/src/lib/platform/MSWindowsSession.cpp b/src/lib/platform/MSWindowsSession.cpp index 63e8d8f..8d4f8ce 100644 --- a/src/lib/platform/MSWindowsSession.cpp +++ b/src/lib/platform/MSWindowsSession.cpp @@ -172,10 +172,9 @@ MSWindowsSession::nextProcessEntry(HANDLE snapshot, LPPROCESSENTRY32 entry) return gotEntry; } -String -MSWindowsSession::getActiveDesktopName() +std::string MSWindowsSession::getActiveDesktopName() { - String result; + std::string result; try { HDESK hd = OpenInputDesktop(0, TRUE, GENERIC_READ); if (hd != NULL) { diff --git a/src/lib/platform/MSWindowsSession.h b/src/lib/platform/MSWindowsSession.h index d777141..e14d7e2 100644 --- a/src/lib/platform/MSWindowsSession.h +++ b/src/lib/platform/MSWindowsSession.h @@ -17,7 +17,7 @@ #pragma once -#include "base/String.h" +#include #define WIN32_LEAN_AND_MEAN #include @@ -42,7 +42,7 @@ public: void updateActiveSession(); - String getActiveDesktopName(); + std::string getActiveDesktopName(); private: BOOL nextProcessEntry(HANDLE snapshot, LPPROCESSENTRY32 entry); diff --git a/src/lib/platform/MSWindowsUtil.cpp b/src/lib/platform/MSWindowsUtil.cpp index b657906..b6b809f 100644 --- a/src/lib/platform/MSWindowsUtil.cpp +++ b/src/lib/platform/MSWindowsUtil.cpp @@ -18,29 +18,26 @@ #include "platform/MSWindowsUtil.h" -#include "base/String.h" - #include +#include "base/String.h" // // MSWindowsUtil // -String -MSWindowsUtil::getString(HINSTANCE instance, DWORD id) +std::string MSWindowsUtil::getString(HINSTANCE instance, DWORD id) { char* msg = NULL; int n = LoadString(instance, id, reinterpret_cast(&msg), 0); if (n <= 0) { - return String(); + return {}; } - return String (msg, n); + return std::string (msg, n); } -String -MSWindowsUtil::getErrorString(HINSTANCE hinstance, DWORD error, DWORD id) +std::string MSWindowsUtil::getErrorString(HINSTANCE hinstance, DWORD error, DWORD id) { char* buffer; if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | @@ -52,12 +49,12 @@ MSWindowsUtil::getErrorString(HINSTANCE hinstance, DWORD error, DWORD id) (LPTSTR)&buffer, 0, NULL) == 0) { - String errorString = barrier::string::sprintf("%d", error); + std::string errorString = barrier::string::sprintf("%d", error); return barrier::string::format(getString(hinstance, id).c_str(), errorString.c_str()); } else { - String result(buffer); + std::string result(buffer); LocalFree(buffer); return result; } diff --git a/src/lib/platform/MSWindowsUtil.h b/src/lib/platform/MSWindowsUtil.h index 29eef2e..59f2eac 100644 --- a/src/lib/platform/MSWindowsUtil.h +++ b/src/lib/platform/MSWindowsUtil.h @@ -18,7 +18,7 @@ #pragma once -#include "base/String.h" +#include #define WINDOWS_LEAN_AND_MEAN #include @@ -29,14 +29,14 @@ public: /*! Gets a string for \p id from the string table of \p instance. */ - static String getString(HINSTANCE instance, DWORD id); + static std::string getString(HINSTANCE instance, DWORD id); //! Get error string /*! Gets a system error message for \p error. If the error cannot be found return the string for \p id, replacing ${1} with \p error. */ - static String getErrorString(HINSTANCE, DWORD error, DWORD id); + static std::string getErrorString(HINSTANCE, DWORD error, DWORD id); //! Create directory /*! diff --git a/src/lib/platform/MSWindowsWatchdog.cpp b/src/lib/platform/MSWindowsWatchdog.cpp index 9856b5d..0aa5505 100644 --- a/src/lib/platform/MSWindowsWatchdog.cpp +++ b/src/lib/platform/MSWindowsWatchdog.cpp @@ -327,8 +327,7 @@ MSWindowsWatchdog::startProcess() } } -BOOL -MSWindowsWatchdog::doStartProcessAsSelf(String& command) +BOOL MSWindowsWatchdog::doStartProcessAsSelf(std::string& command) { DWORD creationFlags = NORMAL_PRIORITY_CLASS | @@ -347,8 +346,8 @@ MSWindowsWatchdog::doStartProcessAsSelf(String& command) return CreateProcess(NULL, LPSTR(command.c_str()), NULL, NULL, FALSE, creationFlags, NULL, NULL, &si, &m_processInfo); } -BOOL -MSWindowsWatchdog::doStartProcessAsUser(String& command, HANDLE userToken, LPSECURITY_ATTRIBUTES sa) +BOOL MSWindowsWatchdog::doStartProcessAsUser(std::string& command, HANDLE userToken, + LPSECURITY_ATTRIBUTES sa) { // clear, as we're reusing process info struct ZeroMemory(&m_processInfo, sizeof(PROCESS_INFORMATION)); diff --git a/src/lib/platform/MSWindowsWatchdog.h b/src/lib/platform/MSWindowsWatchdog.h index 7a1f661..0a81521 100644 --- a/src/lib/platform/MSWindowsWatchdog.h +++ b/src/lib/platform/MSWindowsWatchdog.h @@ -55,8 +55,8 @@ private: HANDLE duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES security); HANDLE getUserToken(LPSECURITY_ATTRIBUTES security); void startProcess(); - BOOL doStartProcessAsUser(String& command, HANDLE userToken, LPSECURITY_ATTRIBUTES sa); - BOOL doStartProcessAsSelf(String& command); + BOOL doStartProcessAsUser(std::string& command, HANDLE userToken, LPSECURITY_ATTRIBUTES sa); + BOOL doStartProcessAsSelf(std::string& command); private: Thread* m_thread; @@ -85,8 +85,8 @@ An error occured in the process watchdog. */ class XMSWindowsWatchdogError : public XBarrier { public: - XMSWindowsWatchdogError(const String& msg) : XBarrier(msg) { } + XMSWindowsWatchdogError(const std::string& msg) : XBarrier(msg) { } // XBase overrides - virtual String getWhat() const throw() { return what(); } + virtual std::string getWhat() const noexcept { return what(); } }; diff --git a/src/lib/platform/OSXClipboard.cpp b/src/lib/platform/OSXClipboard.cpp index 710b471..e55c8e0 100644 --- a/src/lib/platform/OSXClipboard.cpp +++ b/src/lib/platform/OSXClipboard.cpp @@ -92,8 +92,7 @@ OSXClipboard::synchronize() return false; } - void -OSXClipboard::add(EFormat format, const String & data) +void OSXClipboard::add(EFormat format, const std::string& data) { if (m_pboard == NULL) return; @@ -116,7 +115,7 @@ OSXClipboard::add(EFormat format, const String & data) // skip converters for other formats if (converter->getFormat() == format) { - String osXData = converter->fromIClipboard(data); + std::string osXData = converter->fromIClipboard(data); CFStringRef flavorType = converter->getOSXFormat(); CFDataRef dataRef = CFDataCreate(kCFAllocatorDefault, (UInt8 *)osXData.data(), osXData.size()); PasteboardItemID itemID = 0; @@ -185,12 +184,11 @@ OSXClipboard::has(EFormat format) const return false; } -String -OSXClipboard::get(EFormat format) const +std::string OSXClipboard::get(EFormat format) const { CFStringRef type; PasteboardItemID item; - String result; + std::string result; if (m_pboard == NULL) return result; @@ -229,7 +227,7 @@ OSXClipboard::get(EFormat format) const throw err; } - result = String((char *) CFDataGetBytePtr(buffer), CFDataGetLength(buffer)); + result = std::string((char *) CFDataGetBytePtr(buffer), CFDataGetLength(buffer)); } catch (OSStatus err) { LOG((CLOG_DEBUG "exception thrown in OSXClipboard::get MacError (%d)", err)); diff --git a/src/lib/platform/OSXClipboard.h b/src/lib/platform/OSXClipboard.h index ba25c32..b1f9801 100644 --- a/src/lib/platform/OSXClipboard.h +++ b/src/lib/platform/OSXClipboard.h @@ -21,6 +21,7 @@ #include "barrier/IClipboard.h" #include +#include #include class IOSXClipboardConverter; @@ -36,12 +37,12 @@ public: // IClipboard overrides virtual bool empty(); - virtual void add(EFormat, const String& data); + virtual void add(EFormat, const std::string& data); virtual bool open(Time) const; virtual void close() const; virtual Time getTime() const; virtual bool has(EFormat) const; - virtual String get(EFormat) const; + virtual std::string get(EFormat) const; bool synchronize(); private: @@ -72,8 +73,7 @@ public: getFormat() const = 0; //! returns the scrap flavor type that this object converts from/to - virtual CFStringRef - getOSXFormat() const = 0; + virtual CFStringRef getOSXFormat() const = 0; //! Convert from IClipboard format /*! @@ -82,14 +82,14 @@ public: getFormat(). The return data will be in the scrap format returned by getOSXFormat(). */ - virtual String fromIClipboard(const String&) const = 0; + virtual std::string fromIClipboard(const std::string&) const = 0; //! Convert to IClipboard format /*! Convert from the carbon scrap format to the IClipboard format (i.e., the reverse of fromIClipboard()). */ - virtual String toIClipboard(const String&) const = 0; + virtual std::string toIClipboard(const std::string&) const = 0; //@} }; diff --git a/src/lib/platform/OSXClipboardAnyBitmapConverter.cpp b/src/lib/platform/OSXClipboardAnyBitmapConverter.cpp index 73f64c7..8b1b6d4 100644 --- a/src/lib/platform/OSXClipboardAnyBitmapConverter.cpp +++ b/src/lib/platform/OSXClipboardAnyBitmapConverter.cpp @@ -35,14 +35,12 @@ OSXClipboardAnyBitmapConverter::getFormat() const return IClipboard::kBitmap; } -String -OSXClipboardAnyBitmapConverter::fromIClipboard(const String& data) const +std::string OSXClipboardAnyBitmapConverter::fromIClipboard(const std::string& data) const { return doFromIClipboard(data); } -String -OSXClipboardAnyBitmapConverter::toIClipboard(const String& data) const +std::string OSXClipboardAnyBitmapConverter::toIClipboard(const std::string& data) const { return doToIClipboard(data); } diff --git a/src/lib/platform/OSXClipboardAnyBitmapConverter.h b/src/lib/platform/OSXClipboardAnyBitmapConverter.h index 277e75d..78f7809 100644 --- a/src/lib/platform/OSXClipboardAnyBitmapConverter.h +++ b/src/lib/platform/OSXClipboardAnyBitmapConverter.h @@ -30,19 +30,19 @@ public: virtual IClipboard::EFormat getFormat() const; virtual CFStringRef getOSXFormat() const = 0; - virtual String fromIClipboard(const String &) const; - virtual String toIClipboard(const String &) const; + virtual std::string fromIClipboard(const std::string &) const; + virtual std::string toIClipboard(const std::string &) const; protected: //! Convert from IClipboard format /*! Do UTF-8 conversion and linefeed conversion. */ - virtual String doFromIClipboard(const String&) const = 0; + virtual std::string doFromIClipboard(const std::string&) const = 0; //! Convert to IClipboard format /*! Do UTF-8 conversion and Linefeed conversion. */ - virtual String doToIClipboard(const String&) const = 0; + virtual std::string doToIClipboard(const std::string&) const = 0; }; diff --git a/src/lib/platform/OSXClipboardAnyTextConverter.cpp b/src/lib/platform/OSXClipboardAnyTextConverter.cpp index 7095006..ae8dc4a 100644 --- a/src/lib/platform/OSXClipboardAnyTextConverter.cpp +++ b/src/lib/platform/OSXClipboardAnyTextConverter.cpp @@ -40,15 +40,13 @@ OSXClipboardAnyTextConverter::getFormat() const return IClipboard::kText; } -String -OSXClipboardAnyTextConverter::fromIClipboard(const String& data) const +std::string OSXClipboardAnyTextConverter::fromIClipboard(const std::string& data) const { // convert linefeeds and then convert to desired encoding return doFromIClipboard(convertLinefeedToMacOS(data)); } -String -OSXClipboardAnyTextConverter::toIClipboard(const String& data) const +std::string OSXClipboardAnyTextConverter::toIClipboard(const std::string& data) const { // convert text then newlines return convertLinefeedToUnix(doToIClipboard(data)); @@ -68,21 +66,19 @@ isCR(char ch) return (ch == '\r'); } -String -OSXClipboardAnyTextConverter::convertLinefeedToMacOS(const String& src) +std::string OSXClipboardAnyTextConverter::convertLinefeedToMacOS(const std::string& src) { // note -- we assume src is a valid UTF-8 string - String copy = src; + std::string copy = src; std::replace_if(copy.begin(), copy.end(), isLF, '\r'); return copy; } -String -OSXClipboardAnyTextConverter::convertLinefeedToUnix(const String& src) +std::string OSXClipboardAnyTextConverter::convertLinefeedToUnix(const std::string& src) { - String copy = src; + std::string copy = src; std::replace_if(copy.begin(), copy.end(), isCR, '\n'); diff --git a/src/lib/platform/OSXClipboardAnyTextConverter.h b/src/lib/platform/OSXClipboardAnyTextConverter.h index ea42994..f057bae 100644 --- a/src/lib/platform/OSXClipboardAnyTextConverter.h +++ b/src/lib/platform/OSXClipboardAnyTextConverter.h @@ -29,25 +29,24 @@ public: // IOSXClipboardConverter overrides virtual IClipboard::EFormat getFormat() const; - virtual CFStringRef - getOSXFormat() const = 0; - virtual String fromIClipboard(const String &) const; - virtual String toIClipboard(const String &) const; + virtual CFStringRef getOSXFormat() const = 0; + virtual std::string fromIClipboard(const std::string &) const; + virtual std::string toIClipboard(const std::string &) const; protected: //! Convert from IClipboard format /*! Do UTF-8 conversion and linefeed conversion. */ - virtual String doFromIClipboard(const String&) const = 0; + virtual std::string doFromIClipboard(const std::string&) const = 0; //! Convert to IClipboard format /*! Do UTF-8 conversion and Linefeed conversion. */ - virtual String doToIClipboard(const String&) const = 0; + virtual std::string doToIClipboard(const std::string&) const = 0; private: - static String convertLinefeedToMacOS(const String&); - static String convertLinefeedToUnix(const String&); + static std::string convertLinefeedToMacOS(const std::string&); + static std::string convertLinefeedToUnix(const std::string&); }; diff --git a/src/lib/platform/OSXClipboardBMPConverter.cpp b/src/lib/platform/OSXClipboardBMPConverter.cpp index 51c44ec..ac74fbb 100644 --- a/src/lib/platform/OSXClipboardBMPConverter.cpp +++ b/src/lib/platform/OSXClipboardBMPConverter.cpp @@ -91,8 +91,7 @@ OSXClipboardBMPConverter::getOSXFormat() const return CFSTR("com.microsoft.bmp"); } -String -OSXClipboardBMPConverter::fromIClipboard(const String& bmp) const +std::string OSXClipboardBMPConverter::fromIClipboard(const std::string& bmp) const { LOG((CLOG_DEBUG1 "ENTER OSXClipboardBMPConverter::doFromIClipboard()")); // create BMP image @@ -104,21 +103,20 @@ OSXClipboardBMPConverter::fromIClipboard(const String& bmp) const toLE(dst, static_cast(0)); toLE(dst, static_cast(0)); toLE(dst, static_cast(14 + 40)); - return String(reinterpret_cast(header), 14) + bmp; + return std::string(reinterpret_cast(header), 14) + bmp; } -String -OSXClipboardBMPConverter::toIClipboard(const String& bmp) const +std::string OSXClipboardBMPConverter::toIClipboard(const std::string& bmp) const { // make sure data is big enough for a BMP file if (bmp.size() <= 14 + 40) { - return String(); + return {}; } // check BMP file header const UInt8* rawBMPHeader = reinterpret_cast(bmp.data()); if (rawBMPHeader[0] != 'B' || rawBMPHeader[1] != 'M') { - return String(); + return {}; } // get offset to image data diff --git a/src/lib/platform/OSXClipboardBMPConverter.h b/src/lib/platform/OSXClipboardBMPConverter.h index 400831d..f841bee 100644 --- a/src/lib/platform/OSXClipboardBMPConverter.h +++ b/src/lib/platform/OSXClipboardBMPConverter.h @@ -34,11 +34,10 @@ public: getOSXFormat() const; // OSXClipboardAnyBMPConverter overrides - virtual String fromIClipboard(const String&) const; - virtual String toIClipboard(const String&) const; + virtual std::string fromIClipboard(const std::string&) const; + virtual std::string toIClipboard(const std::string&) const; // generic encoding converter - static String convertString(const String& data, - CFStringEncoding fromEncoding, - CFStringEncoding toEncoding); + static std::string convertString(const std::string& data, CFStringEncoding fromEncoding, + CFStringEncoding toEncoding); }; diff --git a/src/lib/platform/OSXClipboardHTMLConverter.cpp b/src/lib/platform/OSXClipboardHTMLConverter.cpp index b5fdb77..46a3d0f 100644 --- a/src/lib/platform/OSXClipboardHTMLConverter.cpp +++ b/src/lib/platform/OSXClipboardHTMLConverter.cpp @@ -42,18 +42,16 @@ OSXClipboardHTMLConverter::getOSXFormat() const return CFSTR("public.html"); } -String -OSXClipboardHTMLConverter::convertString( - const String& data, - CFStringEncoding fromEncoding, - CFStringEncoding toEncoding) +std::string OSXClipboardHTMLConverter::convertString(const std::string& data, + CFStringEncoding fromEncoding, + CFStringEncoding toEncoding) { CFStringRef stringRef = CFStringCreateWithCString( kCFAllocatorDefault, data.c_str(), fromEncoding); if (stringRef == NULL) { - return String(); + return {}; } CFIndex buffSize; @@ -66,13 +64,13 @@ OSXClipboardHTMLConverter::convertString( if (buffer == NULL) { CFRelease(stringRef); - return String(); + return {}; } CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, (UInt8*)buffer, buffSize, NULL); - String result(buffer, buffSize); + std::string result(buffer, buffSize); delete[] buffer; CFRelease(stringRef); @@ -80,15 +78,13 @@ OSXClipboardHTMLConverter::convertString( return result; } -String -OSXClipboardHTMLConverter::doFromIClipboard(const String& data) const +std::string OSXClipboardHTMLConverter::doFromIClipboard(const std::string& data) const { return convertString(data, kCFStringEncodingUTF8, CFStringGetSystemEncoding()); } -String -OSXClipboardHTMLConverter::doToIClipboard(const String& data) const +std::string OSXClipboardHTMLConverter::doToIClipboard(const std::string& data) const { return convertString(data, CFStringGetSystemEncoding(), kCFStringEncodingUTF8); diff --git a/src/lib/platform/OSXClipboardHTMLConverter.h b/src/lib/platform/OSXClipboardHTMLConverter.h index 21c2b82..a821e25 100644 --- a/src/lib/platform/OSXClipboardHTMLConverter.h +++ b/src/lib/platform/OSXClipboardHTMLConverter.h @@ -34,11 +34,10 @@ public: protected: // OSXClipboardAnyTextConverter overrides - virtual String doFromIClipboard(const String&) const; - virtual String doToIClipboard(const String&) const; + virtual std::string doFromIClipboard(const std::string&) const; + virtual std::string doToIClipboard(const std::string&) const; // generic encoding converter - static String convertString(const String& data, - CFStringEncoding fromEncoding, - CFStringEncoding toEncoding); + static std::string convertString(const std::string& data, CFStringEncoding fromEncoding, + CFStringEncoding toEncoding); }; diff --git a/src/lib/platform/OSXClipboardTextConverter.cpp b/src/lib/platform/OSXClipboardTextConverter.cpp index c18ad3f..a68258d 100644 --- a/src/lib/platform/OSXClipboardTextConverter.cpp +++ b/src/lib/platform/OSXClipboardTextConverter.cpp @@ -40,18 +40,16 @@ OSXClipboardTextConverter::getOSXFormat() const return CFSTR("public.plain-text"); } -String -OSXClipboardTextConverter::convertString( - const String& data, - CFStringEncoding fromEncoding, - CFStringEncoding toEncoding) +std::string OSXClipboardTextConverter::convertString(const std::string& data, + CFStringEncoding fromEncoding, + CFStringEncoding toEncoding) { CFStringRef stringRef = CFStringCreateWithCString(kCFAllocatorDefault, data.c_str(), fromEncoding); if (stringRef == NULL) { - return String(); + return {}; } CFIndex buffSize; @@ -64,13 +62,13 @@ OSXClipboardTextConverter::convertString( if (buffer == NULL) { CFRelease(stringRef); - return String(); + return {}; } CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, (UInt8*)buffer, buffSize, NULL); - String result(buffer, buffSize); + std::string result(buffer, buffSize); delete[] buffer; CFRelease(stringRef); @@ -78,15 +76,13 @@ OSXClipboardTextConverter::convertString( return result; } -String -OSXClipboardTextConverter::doFromIClipboard(const String& data) const +std::string OSXClipboardTextConverter::doFromIClipboard(const std::string& data) const { return convertString(data, kCFStringEncodingUTF8, CFStringGetSystemEncoding()); } -String -OSXClipboardTextConverter::doToIClipboard(const String& data) const +std::string OSXClipboardTextConverter::doToIClipboard(const std::string& data) const { return convertString(data, CFStringGetSystemEncoding(), kCFStringEncodingUTF8); diff --git a/src/lib/platform/OSXClipboardTextConverter.h b/src/lib/platform/OSXClipboardTextConverter.h index 55d82ce..8211f1e 100644 --- a/src/lib/platform/OSXClipboardTextConverter.h +++ b/src/lib/platform/OSXClipboardTextConverter.h @@ -32,11 +32,10 @@ public: protected: // OSXClipboardAnyTextConverter overrides - virtual String doFromIClipboard(const String&) const; - virtual String doToIClipboard(const String&) const; + virtual std::string doFromIClipboard(const std::string&) const; + virtual std::string doToIClipboard(const std::string&) const; // generic encoding converter - static String convertString(const String& data, - CFStringEncoding fromEncoding, - CFStringEncoding toEncoding); + static std::string convertString(const std::string& data, CFStringEncoding fromEncoding, + CFStringEncoding toEncoding); }; diff --git a/src/lib/platform/OSXClipboardUTF16Converter.cpp b/src/lib/platform/OSXClipboardUTF16Converter.cpp index 02d8fa3..8411e92 100644 --- a/src/lib/platform/OSXClipboardUTF16Converter.cpp +++ b/src/lib/platform/OSXClipboardUTF16Converter.cpp @@ -40,15 +40,13 @@ OSXClipboardUTF16Converter::getOSXFormat() const return CFSTR("public.utf16-plain-text"); } -String -OSXClipboardUTF16Converter::doFromIClipboard(const String& data) const +std::string OSXClipboardUTF16Converter::doFromIClipboard(const std::string& data) const { // convert and add nul terminator return Unicode::UTF8ToUTF16(data); } -String -OSXClipboardUTF16Converter::doToIClipboard(const String& data) const +std::string OSXClipboardUTF16Converter::doToIClipboard(const std::string& data) const { // convert and strip nul terminator return Unicode::UTF16ToUTF8(data); diff --git a/src/lib/platform/OSXClipboardUTF16Converter.h b/src/lib/platform/OSXClipboardUTF16Converter.h index 10bb595..b279c99 100644 --- a/src/lib/platform/OSXClipboardUTF16Converter.h +++ b/src/lib/platform/OSXClipboardUTF16Converter.h @@ -32,6 +32,6 @@ public: protected: // OSXClipboardAnyTextConverter overrides - virtual String doFromIClipboard(const String&) const; - virtual String doToIClipboard(const String&) const; + virtual std::string doFromIClipboard(const std::string&) const; + virtual std::string doToIClipboard(const std::string&) const; }; diff --git a/src/lib/platform/OSXDragView.m b/src/lib/platform/OSXDragView.m index 9f77499..67dac56 100644 --- a/src/lib/platform/OSXDragView.m +++ b/src/lib/platform/OSXDragView.m @@ -129,13 +129,13 @@ draggingSourceOperationMask - (NSPoint)draggingLocation { - NSPoint point; + NSPoint point = NSMakePoint(0, 0); return point; } - (NSPoint)draggedImageLocation { - NSPoint point; + NSPoint point = NSMakePoint(0, 0); return point; } diff --git a/src/lib/platform/OSXKeyState.cpp b/src/lib/platform/OSXKeyState.cpp index 9d8f429..9db3c5d 100644 --- a/src/lib/platform/OSXKeyState.cpp +++ b/src/lib/platform/OSXKeyState.cpp @@ -337,26 +337,26 @@ OSXKeyState::fakeMediaKey(KeyID id) CGEventFlags OSXKeyState::getModifierStateAsOSXFlags() { - CGEventFlags modifiers = 0; + CGEventFlags modifiers = CGEventFlags(0); if (m_shiftPressed) { - modifiers |= kCGEventFlagMaskShift; + modifiers |= CGEventFlags(kCGEventFlagMaskShift); } if (m_controlPressed) { - modifiers |= kCGEventFlagMaskControl; + modifiers |= CGEventFlags(kCGEventFlagMaskControl); } if (m_altPressed) { - modifiers |= kCGEventFlagMaskAlternate; + modifiers |= CGEventFlags(kCGEventFlagMaskAlternate); } if (m_superPressed) { - modifiers |= kCGEventFlagMaskCommand; + modifiers |= CGEventFlags(kCGEventFlagMaskCommand); } if (m_capsPressed) { - modifiers |= kCGEventFlagMaskAlphaShift; + modifiers |= CGEventFlags(kCGEventFlagMaskAlphaShift); } return modifiers; diff --git a/src/lib/platform/OSXScreen.h b/src/lib/platform/OSXScreen.h index bbddfb9..68c7c68 100644 --- a/src/lib/platform/OSXScreen.h +++ b/src/lib/platform/OSXScreen.h @@ -97,9 +97,9 @@ public: virtual void setSequenceNumber(UInt32); virtual bool isPrimary() const; virtual void fakeDraggingFiles(DragFileList fileList); - virtual String& getDraggingFilename(); + virtual std::string& getDraggingFilename(); - const String& getDropTarget() const { return m_dropTarget; } + const std::string& getDropTarget() const { return m_dropTarget; } void waitForCarbonLoop() const; protected: @@ -338,7 +338,7 @@ private: IEventQueue* m_events; Thread* m_getDropTargetThread; - String m_dropTarget; + std::string m_dropTarget; #if defined(MAC_OS_X_VERSION_10_7) Mutex* m_carbonLoopMutex; diff --git a/src/lib/platform/XWindowsClipboard.cpp b/src/lib/platform/XWindowsClipboard.cpp index b2c17f9..b0da695 100644 --- a/src/lib/platform/XWindowsClipboard.cpp +++ b/src/lib/platform/XWindowsClipboard.cpp @@ -170,7 +170,7 @@ XWindowsClipboard::addSimpleRequest(Window requestor, } // handle targets - String data; + std::string data; Atom type = None; int format = 0; if (target == m_atomTargets) { @@ -303,8 +303,7 @@ XWindowsClipboard::empty() return true; } -void -XWindowsClipboard::add(EFormat format, const String& data) +void XWindowsClipboard::add(EFormat format, const std::string& data) { assert(m_open); assert(m_owner); @@ -387,8 +386,7 @@ XWindowsClipboard::has(EFormat format) const return m_added[format]; } -String -XWindowsClipboard::get(EFormat format) const +std::string XWindowsClipboard::get(EFormat format) const { assert(m_open); @@ -513,7 +511,7 @@ XWindowsClipboard::icccmFillCache() // instead of the correct type ATOM; allow either. const Atom atomTargets = m_atomTargets; Atom target; - String data; + std::string data; if (!icccmGetSelection(atomTargets, &target, &data) || (target != m_atomAtom && target != m_atomTargets)) { LOG((CLOG_DEBUG1 "selection doesn't support TARGETS")); @@ -557,7 +555,7 @@ XWindowsClipboard::icccmFillCache() // get the data Atom actualTarget; - String targetData; + std::string targetData; if (!icccmGetSelection(target, &actualTarget, &targetData)) { LOG((CLOG_DEBUG1 " no data for target %s", XWindowsUtil::atomToString(m_display, target).c_str())); continue; @@ -573,7 +571,7 @@ XWindowsClipboard::icccmFillCache() bool XWindowsClipboard::icccmGetSelection(Atom target, - Atom* actualTarget, String* data) const + Atom* actualTarget, std::string* data) const { assert(actualTarget != NULL); assert(data != NULL); @@ -597,7 +595,7 @@ IClipboard::Time XWindowsClipboard::icccmGetTime() const { Atom actualTarget; - String data; + std::string data; if (icccmGetSelection(m_atomTimestamp, &actualTarget, &data) && actualTarget == m_atomInteger) { Time time = *reinterpret_cast(data.data()); @@ -668,7 +666,7 @@ XWindowsClipboard::motifOwnsClipboard() const // get the Motif clipboard header property from the root window Atom target; SInt32 format; - String data; + std::string data; Window root = RootWindow(m_display, DefaultScreen(m_display)); if (!XWindowsUtil::getWindowProperty(m_display, root, m_atomMotifClipHeader, @@ -697,7 +695,7 @@ XWindowsClipboard::motifFillCache() // get the Motif clipboard header property from the root window Atom target; SInt32 format; - String data; + std::string data; Window root = RootWindow(m_display, DefaultScreen(m_display)); if (!XWindowsUtil::getWindowProperty(m_display, root, m_atomMotifClipHeader, @@ -741,13 +739,13 @@ XWindowsClipboard::motifFillCache() static_cast(data.data())); // get the available formats - typedef std::map MotifFormatMap; + typedef std::map MotifFormatMap; MotifFormatMap motifFormats; for (SInt32 i = 0; i < numFormats; ++i) { // get Motif format property from the root window sprintf(name, "_MOTIF_CLIP_ITEM_%d", formats[i]); Atom atomFormat = m_impl->XInternAtom(m_display, name, False); - String data; + std::string data; if (!XWindowsUtil::getWindowProperty(m_display, root, atomFormat, &data, &target, &format, False)) { @@ -797,7 +795,7 @@ XWindowsClipboard::motifFillCache() // get the data (finally) Atom actualTarget; - String targetData; + std::string targetData; if (!motifGetSelection(&motifFormat, &actualTarget, &targetData)) { LOG((CLOG_DEBUG1 " no data for target %s", XWindowsUtil::atomToString(m_display, target).c_str())); continue; @@ -813,7 +811,7 @@ XWindowsClipboard::motifFillCache() bool XWindowsClipboard::motifGetSelection(const MotifClipFormat* format, - Atom* actualTarget, String* data) const + Atom* actualTarget, std::string* data) const { // if the current clipboard owner and the owner indicated by the // motif clip header are the same then transfer via a property on @@ -849,7 +847,7 @@ XWindowsClipboard::insertMultipleReply(Window requestor, // get the requested targets Atom target; SInt32 format; - String data; + std::string data; if (!XWindowsUtil::getWindowProperty(m_display, requestor, property, &data, &target, &format, False)) { // can't get the requested targets @@ -887,7 +885,7 @@ XWindowsClipboard::insertMultipleReply(Window requestor, // add reply for MULTIPLE request insertReply(new Reply(requestor, m_atomMultiple, - time, property, String(), None, 32)); + time, property, std::string(), None, 32)); return true; } @@ -1101,7 +1099,7 @@ XWindowsClipboard::sendReply(Reply* reply) LOG((CLOG_DEBUG2 "properties of 0x%08x:", reply->m_requestor)); for (int i = 0; i < n; ++i) { Atom target; - String data; + std::string data; char* name = m_impl->XGetAtomName(m_display, props[i]); if (!XWindowsUtil::getWindowProperty(m_display, reply->m_requestor, @@ -1112,9 +1110,9 @@ XWindowsClipboard::sendReply(Reply* reply) // if there are any non-ascii characters in string // then print the binary data. static const char* hex = "0123456789abcdef"; - for (String::size_type j = 0; j < data.size(); ++j) { + for (std::string::size_type j = 0; j < data.size(); ++j) { if (data[j] < 32 || data[j] > 126) { - String tmp; + std::string tmp; tmp.reserve(data.size() * 3); for (j = 0; j < data.size(); ++j) { unsigned char v = (unsigned char)data[j]; @@ -1221,8 +1219,7 @@ XWindowsClipboard::wasOwnedAtTime(::Time time) const return (/*when >= 0 &&*/ when <= duration); } -Atom -XWindowsClipboard::getTargetsData(String& data, int* format) const +Atom XWindowsClipboard::getTargetsData(std::string& data, int* format) const { assert(format != NULL); @@ -1246,8 +1243,7 @@ XWindowsClipboard::getTargetsData(String& data, int* format) const return m_atomAtom; } -Atom -XWindowsClipboard::getTimestampData(String& data, int* format) const +Atom XWindowsClipboard::getTimestampData(std::string& data, int* format) const { assert(format != NULL); @@ -1285,7 +1281,7 @@ XWindowsClipboard::CICCCMGetClipboard::~CICCCMGetClipboard() bool XWindowsClipboard::CICCCMGetClipboard::readClipboard(Display* display, - Atom selection, Atom target, Atom* actualTarget, String* data) + Atom selection, Atom target, Atom* actualTarget, std::string* data) { assert(actualTarget != NULL); assert(data != NULL); @@ -1430,7 +1426,7 @@ XWindowsClipboard::CICCCMGetClipboard::processEvent( // get the data from the property Atom target; - const String::size_type oldSize = m_data->size(); + const std::string::size_type oldSize = m_data->size(); if (!XWindowsUtil::getWindowProperty(display, m_requestor, m_property, m_data, &target, NULL, True)) { // unable to read property @@ -1515,7 +1511,7 @@ XWindowsClipboard::Reply::Reply(Window requestor, Atom target, ::Time time) : } XWindowsClipboard::Reply::Reply(Window requestor, Atom target, ::Time time, - Atom property, const String& data, Atom type, int format) : + Atom property, const std::string& data, Atom type, int format) : m_requestor(requestor), m_target(target), m_time(time), diff --git a/src/lib/platform/XWindowsClipboard.h b/src/lib/platform/XWindowsClipboard.h index f00c3fc..091036e 100644 --- a/src/lib/platform/XWindowsClipboard.h +++ b/src/lib/platform/XWindowsClipboard.h @@ -90,12 +90,12 @@ public: // IClipboard overrides virtual bool empty(); - virtual void add(EFormat, const String& data); + virtual void add(EFormat, const std::string& data); virtual bool open(Time) const; virtual void close() const; virtual Time getTime() const; virtual bool has(EFormat) const; - virtual String get(EFormat) const; + virtual std::string get(EFormat) const; private: // remove all converters from our list @@ -148,7 +148,7 @@ private: // cannot be performed (in which case *actualTarget == None). bool readClipboard(Display* display, Atom selection, Atom target, - Atom* actualTarget, String* data); + Atom* actualTarget, std::string* data); private: bool processEvent(Display* display, XEvent* event); @@ -169,7 +169,7 @@ private: bool m_reading; // the converted selection data - String* m_data; + std::string* m_data; // the actual type of the data. if this is None then the // selection owner cannot convert to the requested type. @@ -224,8 +224,8 @@ private: class Reply { public: Reply(Window, Atom target, ::Time); - Reply(Window, Atom target, ::Time, Atom property, - const String& data, Atom type, int format); + Reply(Window, Atom target, ::Time, Atom property, const std::string& data, + Atom type, int format); public: // information about the request @@ -241,7 +241,7 @@ private: bool m_done; // the data to send and its type and format - String m_data; + std::string m_data; Atom m_type; int m_format; @@ -254,8 +254,7 @@ private: // ICCCM interoperability methods void icccmFillCache(); - bool icccmGetSelection(Atom target, - Atom* actualTarget, String* data) const; + bool icccmGetSelection(Atom target, Atom* actualTarget, std::string* data) const; Time icccmGetTime() const; // motif interoperability methods @@ -263,8 +262,7 @@ private: void motifUnlockClipboard() const; bool motifOwnsClipboard() const; void motifFillCache(); - bool motifGetSelection(const MotifClipFormat*, - Atom* actualTarget, String* data) const; + bool motifGetSelection(const MotifClipFormat*, Atom* actualTarget, std::string* data) const; Time motifGetTime() const; // reply methods @@ -281,8 +279,8 @@ private: bool wasOwnedAtTime(::Time) const; // data conversion methods - Atom getTargetsData(String&, int* format) const; - Atom getTimestampData(String&, int* format) const; + Atom getTargetsData(std::string&, int* format) const; + Atom getTimestampData(std::string&, int* format) const; private: typedef std::vector ConverterList; @@ -306,7 +304,7 @@ private: bool m_cached; Time m_cacheTime; bool m_added[kNumFormats]; - String m_data[kNumFormats]; + std::string m_data[kNumFormats]; // conversion request replies ReplyMap m_replies; @@ -368,14 +366,14 @@ public: getFormat(). The return data will be in the X selection format returned by getAtom(). */ - virtual String fromIClipboard(const String&) const = 0; + virtual std::string fromIClipboard(const std::string&) const = 0; //! Convert to IClipboard format /*! Convert from the X selection format to the IClipboard format (i.e., the reverse of fromIClipboard()). */ - virtual String toIClipboard(const String&) const = 0; + virtual std::string toIClipboard(const std::string&) const = 0; //@} }; diff --git a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp index 493b1e8..f6fed1c 100644 --- a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp +++ b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp @@ -122,8 +122,7 @@ XWindowsClipboardAnyBitmapConverter::getDataSize() const return 8; } -String -XWindowsClipboardAnyBitmapConverter::fromIClipboard(const String& bmp) const +std::string XWindowsClipboardAnyBitmapConverter::fromIClipboard(const std::string& bmp) const { // fill BMP info header with native-endian data CBMPInfoHeader infoHeader; @@ -145,7 +144,7 @@ XWindowsClipboardAnyBitmapConverter::fromIClipboard(const String& bmp) const infoHeader.biWidth == 0 || infoHeader.biHeight == 0 || infoHeader.biPlanes != 0 || infoHeader.biCompression != 0 || (infoHeader.biBitCount != 24 && infoHeader.biBitCount != 32)) { - return String(); + return {}; } // convert to image format @@ -160,14 +159,13 @@ XWindowsClipboardAnyBitmapConverter::fromIClipboard(const String& bmp) const } } -String -XWindowsClipboardAnyBitmapConverter::toIClipboard(const String& image) const +std::string XWindowsClipboardAnyBitmapConverter::toIClipboard(const std::string& image) const { // convert to raw BMP data UInt32 w, h, depth; - String rawBMP = doToIClipboard(image, w, h, depth); + std::string rawBMP = doToIClipboard(image, w, h, depth); if (rawBMP.empty() || w == 0 || h == 0 || (depth != 24 && depth != 32)) { - return String(); + return {}; } // fill BMP info header with little-endian data @@ -186,6 +184,6 @@ XWindowsClipboardAnyBitmapConverter::toIClipboard(const String& image) const toLE(dst, static_cast(0)); // construct image - return String(reinterpret_cast(infoHeader), - sizeof(infoHeader)) + rawBMP; + return std::string(reinterpret_cast(infoHeader), + sizeof(infoHeader)) + rawBMP; } diff --git a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h index d723a33..861b1b6 100644 --- a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h +++ b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h @@ -32,29 +32,27 @@ public: getFormat() const; virtual Atom getAtom() const = 0; virtual int getDataSize() const; - virtual String fromIClipboard(const String&) const; - virtual String toIClipboard(const String&) const; + virtual std::string fromIClipboard(const std::string&) const; + virtual std::string toIClipboard(const std::string&) const; protected: //! Convert from IClipboard format /*! Convert raw BGR pixel data to another image format. */ - virtual String doBGRFromIClipboard(const UInt8* bgrData, - UInt32 w, UInt32 h) const = 0; + virtual std::string doBGRFromIClipboard(const UInt8* bgrData, UInt32 w, UInt32 h) const = 0; //! Convert from IClipboard format /*! Convert raw BGRA pixel data to another image format. */ - virtual String doBGRAFromIClipboard(const UInt8* bgrData, - UInt32 w, UInt32 h) const = 0; + virtual std::string doBGRAFromIClipboard(const UInt8* bgrData, UInt32 w, UInt32 h) const = 0; //! Convert to IClipboard format /*! Convert an image into raw BGR or BGRA image data and store the width, height, and image depth (24 or 32). */ - virtual String doToIClipboard(const String&, - UInt32& w, UInt32& h, UInt32& depth) const = 0; + virtual std::string doToIClipboard(const std::string&, UInt32& w, UInt32& h, + UInt32& depth) const = 0; }; diff --git a/src/lib/platform/XWindowsClipboardBMPConverter.cpp b/src/lib/platform/XWindowsClipboardBMPConverter.cpp index b4def5b..fcfdc69 100644 --- a/src/lib/platform/XWindowsClipboardBMPConverter.cpp +++ b/src/lib/platform/XWindowsClipboardBMPConverter.cpp @@ -101,8 +101,7 @@ XWindowsClipboardBMPConverter::getDataSize() const return 8; } -String -XWindowsClipboardBMPConverter::fromIClipboard(const String& bmp) const +std::string XWindowsClipboardBMPConverter::fromIClipboard(const std::string& bmp) const { // create BMP image UInt8 header[14]; @@ -113,21 +112,20 @@ XWindowsClipboardBMPConverter::fromIClipboard(const String& bmp) const toLE(dst, static_cast(0)); toLE(dst, static_cast(0)); toLE(dst, static_cast(14 + 40)); - return String(reinterpret_cast(header), 14) + bmp; + return std::string(reinterpret_cast(header), 14) + bmp; } -String -XWindowsClipboardBMPConverter::toIClipboard(const String& bmp) const +std::string XWindowsClipboardBMPConverter::toIClipboard(const std::string& bmp) const { // make sure data is big enough for a BMP file if (bmp.size() <= 14 + 40) { - return String(); + return {}; } // check BMP file header const UInt8* rawBMPHeader = reinterpret_cast(bmp.data()); if (rawBMPHeader[0] != 'B' || rawBMPHeader[1] != 'M') { - return String(); + return {}; } // get offset to image data diff --git a/src/lib/platform/XWindowsClipboardBMPConverter.h b/src/lib/platform/XWindowsClipboardBMPConverter.h index d7813a0..4afa788 100644 --- a/src/lib/platform/XWindowsClipboardBMPConverter.h +++ b/src/lib/platform/XWindowsClipboardBMPConverter.h @@ -32,8 +32,8 @@ public: getFormat() const; virtual Atom getAtom() const; virtual int getDataSize() const; - virtual String fromIClipboard(const String&) const; - virtual String toIClipboard(const String&) const; + virtual std::string fromIClipboard(const std::string&) const; + virtual std::string toIClipboard(const std::string&) const; private: Atom m_atom; diff --git a/src/lib/platform/XWindowsClipboardHTMLConverter.cpp b/src/lib/platform/XWindowsClipboardHTMLConverter.cpp index 32db724..6ae98a7 100644 --- a/src/lib/platform/XWindowsClipboardHTMLConverter.cpp +++ b/src/lib/platform/XWindowsClipboardHTMLConverter.cpp @@ -54,14 +54,12 @@ XWindowsClipboardHTMLConverter::getDataSize() const return 8; } -String -XWindowsClipboardHTMLConverter::fromIClipboard(const String& data) const +std::string XWindowsClipboardHTMLConverter::fromIClipboard(const std::string& data) const { return Unicode::UTF8ToUTF16(data); } -String -XWindowsClipboardHTMLConverter::toIClipboard(const String& data) const +std::string XWindowsClipboardHTMLConverter::toIClipboard(const std::string& data) const { return Unicode::UTF16ToUTF8(data); } diff --git a/src/lib/platform/XWindowsClipboardHTMLConverter.h b/src/lib/platform/XWindowsClipboardHTMLConverter.h index 013aa99..9a4ce61 100644 --- a/src/lib/platform/XWindowsClipboardHTMLConverter.h +++ b/src/lib/platform/XWindowsClipboardHTMLConverter.h @@ -34,8 +34,8 @@ public: getFormat() const; virtual Atom getAtom() const; virtual int getDataSize() const; - virtual String fromIClipboard(const String&) const; - virtual String toIClipboard(const String&) const; + virtual std::string fromIClipboard(const std::string&) const; + virtual std::string toIClipboard(const std::string&) const; private: Atom m_atom; diff --git a/src/lib/platform/XWindowsClipboardTextConverter.cpp b/src/lib/platform/XWindowsClipboardTextConverter.cpp index 71b7a84..2e18d91 100644 --- a/src/lib/platform/XWindowsClipboardTextConverter.cpp +++ b/src/lib/platform/XWindowsClipboardTextConverter.cpp @@ -54,18 +54,16 @@ XWindowsClipboardTextConverter::getDataSize() const return 8; } -String -XWindowsClipboardTextConverter::fromIClipboard(const String& data) const +std::string XWindowsClipboardTextConverter::fromIClipboard(const std::string& data) const { return Unicode::UTF8ToText(data); } -String -XWindowsClipboardTextConverter::toIClipboard(const String& data) const +std::string XWindowsClipboardTextConverter::toIClipboard(const std::string& data) const { // convert to UTF-8 bool errors; - String utf8 = Unicode::textToUTF8(data, &errors); + std::string utf8 = Unicode::textToUTF8(data, &errors); // if there were decoding errors then, to support old applications // that don't understand UTF-8 but can report the exact binary diff --git a/src/lib/platform/XWindowsClipboardTextConverter.h b/src/lib/platform/XWindowsClipboardTextConverter.h index 0e6d598..99cdbcb 100644 --- a/src/lib/platform/XWindowsClipboardTextConverter.h +++ b/src/lib/platform/XWindowsClipboardTextConverter.h @@ -34,8 +34,8 @@ public: getFormat() const; virtual Atom getAtom() const; virtual int getDataSize() const; - virtual String fromIClipboard(const String&) const; - virtual String toIClipboard(const String&) const; + virtual std::string fromIClipboard(const std::string&) const; + virtual std::string toIClipboard(const std::string&) const; private: Atom m_atom; diff --git a/src/lib/platform/XWindowsClipboardUCS2Converter.cpp b/src/lib/platform/XWindowsClipboardUCS2Converter.cpp index 988b909..d3d5e04 100644 --- a/src/lib/platform/XWindowsClipboardUCS2Converter.cpp +++ b/src/lib/platform/XWindowsClipboardUCS2Converter.cpp @@ -54,14 +54,12 @@ XWindowsClipboardUCS2Converter::getDataSize() const return 16; } -String -XWindowsClipboardUCS2Converter::fromIClipboard(const String& data) const +std::string XWindowsClipboardUCS2Converter::fromIClipboard(const std::string& data) const { return Unicode::UTF8ToUCS2(data); } -String -XWindowsClipboardUCS2Converter::toIClipboard(const String& data) const +std::string XWindowsClipboardUCS2Converter::toIClipboard(const std::string& data) const { return Unicode::UCS2ToUTF8(data); } diff --git a/src/lib/platform/XWindowsClipboardUCS2Converter.h b/src/lib/platform/XWindowsClipboardUCS2Converter.h index 6491408..16d880a 100644 --- a/src/lib/platform/XWindowsClipboardUCS2Converter.h +++ b/src/lib/platform/XWindowsClipboardUCS2Converter.h @@ -34,8 +34,8 @@ public: getFormat() const; virtual Atom getAtom() const; virtual int getDataSize() const; - virtual String fromIClipboard(const String&) const; - virtual String toIClipboard(const String&) const; + virtual std::string fromIClipboard(const std::string&) const; + virtual std::string toIClipboard(const std::string&) const; private: Atom m_atom; diff --git a/src/lib/platform/XWindowsClipboardUTF8Converter.cpp b/src/lib/platform/XWindowsClipboardUTF8Converter.cpp index 0e43cce..f470cf1 100644 --- a/src/lib/platform/XWindowsClipboardUTF8Converter.cpp +++ b/src/lib/platform/XWindowsClipboardUTF8Converter.cpp @@ -52,14 +52,12 @@ XWindowsClipboardUTF8Converter::getDataSize() const return 8; } -String -XWindowsClipboardUTF8Converter::fromIClipboard(const String& data) const +std::string XWindowsClipboardUTF8Converter::fromIClipboard(const std::string& data) const { return data; } -String -XWindowsClipboardUTF8Converter::toIClipboard(const String& data) const +std::string XWindowsClipboardUTF8Converter::toIClipboard(const std::string& data) const { return data; } diff --git a/src/lib/platform/XWindowsClipboardUTF8Converter.h b/src/lib/platform/XWindowsClipboardUTF8Converter.h index e3eeca0..2219ed2 100644 --- a/src/lib/platform/XWindowsClipboardUTF8Converter.h +++ b/src/lib/platform/XWindowsClipboardUTF8Converter.h @@ -34,8 +34,8 @@ public: getFormat() const; virtual Atom getAtom() const; virtual int getDataSize() const; - virtual String fromIClipboard(const String&) const; - virtual String toIClipboard(const String&) const; + virtual std::string fromIClipboard(const std::string&) const; + virtual std::string toIClipboard(const std::string&) const; private: Atom m_atom; diff --git a/src/lib/platform/XWindowsEventQueueBuffer.cpp b/src/lib/platform/XWindowsEventQueueBuffer.cpp index 78f0e5a..8b8c3b5 100644 --- a/src/lib/platform/XWindowsEventQueueBuffer.cpp +++ b/src/lib/platform/XWindowsEventQueueBuffer.cpp @@ -82,6 +82,19 @@ XWindowsEventQueueBuffer::~XWindowsEventQueueBuffer() close(m_pipefd[1]); } +int XWindowsEventQueueBuffer::getPendingCountLocked() +{ + Lock lock(&m_mutex); + // work around a bug in old libx11 which causes the first XPending not to read events under + // certain conditions. The issue happens when libx11 has not yet received replies for all + // flushed events. In that case, internally XPending will not try to process received events + // as the reply for the last event was not found. As a result, XPending will return the number + // of pending events without regard to the events it has just read. + // https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/1 fixes this on libx11 side. + m_impl->XPending(m_display); + return m_impl->XPending(m_display); +} + void XWindowsEventQueueBuffer::waitForEvent(double dtimeout) { @@ -163,7 +176,7 @@ XWindowsEventQueueBuffer::waitForEvent(double dtimeout) // we want to give the cpu a chance s owe up this to 25ms #define TIMEOUT_DELAY 25 - while (((dtimeout < 0.0) || (remaining > 0)) && QLength(m_display)==0 && retval==0){ + while (((dtimeout < 0.0) || (remaining > 0)) && getPendingCountLocked() == 0 && retval == 0) { #if HAVE_POLL retval = poll(pfds, 2, TIMEOUT_DELAY); //16ms = 60hz, but we make it > to play nicely with the cpu if (pfds[1].revents & POLLIN) { diff --git a/src/lib/platform/XWindowsEventQueueBuffer.h b/src/lib/platform/XWindowsEventQueueBuffer.h index e49b282..13f6b16 100644 --- a/src/lib/platform/XWindowsEventQueueBuffer.h +++ b/src/lib/platform/XWindowsEventQueueBuffer.h @@ -51,6 +51,8 @@ public: private: void flush(); + int getPendingCountLocked(); + private: typedef std::vector EventList; IXWindowsImpl* m_impl; diff --git a/src/lib/platform/XWindowsKeyState.cpp b/src/lib/platform/XWindowsKeyState.cpp index 37fd5e8..9fb71ca 100644 --- a/src/lib/platform/XWindowsKeyState.cpp +++ b/src/lib/platform/XWindowsKeyState.cpp @@ -20,7 +20,6 @@ #include "platform/XWindowsUtil.h" #include "base/Log.h" -#include "base/String.h" #include "common/stdmap.h" #include diff --git a/src/lib/platform/XWindowsKeyState.h b/src/lib/platform/XWindowsKeyState.h index f42f7ac..f790390 100644 --- a/src/lib/platform/XWindowsKeyState.h +++ b/src/lib/platform/XWindowsKeyState.h @@ -173,6 +173,6 @@ private: public: SInt32 group() const { return m_group; } void group(const SInt32& group) { m_group = group; } - KeyModifierMaskList modifierFromX() const { return m_modifierFromX; } + KeyModifierMaskList& modifierFromX() { return m_modifierFromX; } #endif }; diff --git a/src/lib/platform/XWindowsScreen.cpp b/src/lib/platform/XWindowsScreen.cpp index e5db1a3..5f1724c 100644 --- a/src/lib/platform/XWindowsScreen.cpp +++ b/src/lib/platform/XWindowsScreen.cpp @@ -30,7 +30,6 @@ #include "arch/Arch.h" #include "base/Log.h" #include "base/Stopwatch.h" -#include "base/String.h" #include "base/IEventQueue.h" #include "base/TMethodEventJob.h" diff --git a/src/lib/platform/XWindowsUtil.cpp b/src/lib/platform/XWindowsUtil.cpp index 65448e8..3c90bd6 100644 --- a/src/lib/platform/XWindowsUtil.cpp +++ b/src/lib/platform/XWindowsUtil.cpp @@ -1294,7 +1294,7 @@ XWindowsUtil::KeySymMap XWindowsUtil::s_keySymToUCS4; bool XWindowsUtil::getWindowProperty(Display* display, Window window, - Atom property, String* data, Atom* type, + Atom property, std::string* data, Atom* type, SInt32* format, bool deleteProperty) { assert(display != NULL); @@ -1608,8 +1608,7 @@ XWindowsUtil::getModifierBitForKeySym(KeySym keysym) } } -String -XWindowsUtil::atomToString(Display* display, Atom atom) +std::string XWindowsUtil::atomToString(Display* display, Atom atom) { if (atom == 0) { return "None"; @@ -1622,20 +1621,19 @@ XWindowsUtil::atomToString(Display* display, Atom atom) return barrier::string::sprintf(" (%d)", (int)atom); } else { - String msg = barrier::string::sprintf("%s (%d)", name, (int)atom); + std::string msg = barrier::string::sprintf("%s (%d)", name, (int)atom); XFree(name); return msg; } } -String -XWindowsUtil::atomsToString(Display* display, const Atom* atom, UInt32 num) +std::string XWindowsUtil::atomsToString(Display* display, const Atom* atom, UInt32 num) { char** names = new char*[num]; bool error = false; XWindowsUtil::ErrorLock lock(display, &error); XGetAtomNames(display, const_cast(atom), (int)num, names); - String msg; + std::string msg; if (error) { for (UInt32 i = 0; i < num; ++i) { msg += barrier::string::sprintf(" (%d), ", (int)atom[i]); @@ -1654,8 +1652,7 @@ XWindowsUtil::atomsToString(Display* display, const Atom* atom, UInt32 num) return msg; } -void -XWindowsUtil::convertAtomProperty(String& data) +void XWindowsUtil::convertAtomProperty(std::string& data) { // as best i can tell, 64-bit systems don't pack Atoms into properties // as 32-bit numbers but rather as the 64-bit numbers they are. that @@ -1669,22 +1666,19 @@ XWindowsUtil::convertAtomProperty(String& data) } } -void -XWindowsUtil::appendAtomData(String& data, Atom atom) +void XWindowsUtil::appendAtomData(std::string& data, Atom atom) { data.append(reinterpret_cast(&atom), sizeof(Atom)); } -void -XWindowsUtil::replaceAtomData(String& data, UInt32 index, Atom atom) +void XWindowsUtil::replaceAtomData(std::string& data, UInt32 index, Atom atom) { data.replace(index * sizeof(Atom), sizeof(Atom), reinterpret_cast(&atom), sizeof(Atom)); } -void -XWindowsUtil::appendTimeData(String& data, Time time) +void XWindowsUtil::appendTimeData(std::string& data, Time time) { data.append(reinterpret_cast(&time), sizeof(Time)); } diff --git a/src/lib/platform/XWindowsUtil.h b/src/lib/platform/XWindowsUtil.h index 4df888f..f5b3ea8 100644 --- a/src/lib/platform/XWindowsUtil.h +++ b/src/lib/platform/XWindowsUtil.h @@ -18,7 +18,6 @@ #pragma once -#include "base/String.h" #include "base/EventTypes.h" #include "common/stdmap.h" #include "common/stdvector.h" @@ -29,6 +28,8 @@ # include #endif +#include + //! X11 utility functions class XWindowsUtil { public: @@ -42,10 +43,9 @@ public: if \c format is not NULL. If \c deleteProperty is true then the property is deleted after being read. */ - static bool getWindowProperty(Display*, - Window window, Atom property, - String* data, Atom* type, - SInt32* format, bool deleteProperty); + static bool getWindowProperty(Display*, Window window, Atom property, + std::string* data, Atom* type, + SInt32* format, bool deleteProperty); //! Set property /*! @@ -81,44 +81,42 @@ public: /*! Converts \p atom to its string representation. */ - static String atomToString(Display*, Atom atom); + static std::string atomToString(Display*, Atom atom); //! Convert several Atoms to a string /*! Converts each atom in \p atoms to its string representation and concatenates the results. */ - static String atomsToString(Display* display, - const Atom* atom, UInt32 num); + static std::string atomsToString(Display* display, const Atom* atom, UInt32 num); //! Prepare a property of atoms for use /*! 64-bit systems may need to modify a property's data if it's a list of Atoms before using it. */ - static void convertAtomProperty(String& data); + static void convertAtomProperty(std::string& data); //! Append an Atom to property data /*! Converts \p atom to a 32-bit on-the-wire format and appends it to \p data. */ - static void appendAtomData(String& data, Atom atom); + static void appendAtomData(std::string& data, Atom atom); //! Replace an Atom in property data /*! Converts \p atom to a 32-bit on-the-wire format and replaces the atom at index \p index in \p data. */ - static void replaceAtomData(String& data, - UInt32 index, Atom atom); + static void replaceAtomData(std::string& data, UInt32 index, Atom atom); //! Append an Time to property data /*! Converts \p time to a 32-bit on-the-wire format and appends it to \p data. */ - static void appendTimeData(String& data, Time time); + static void appendTimeData(std::string& data, Time time); //! X11 error handler /*! diff --git a/src/lib/server/BaseClientProxy.cpp b/src/lib/server/BaseClientProxy.cpp index b9c5339..6ccd251 100644 --- a/src/lib/server/BaseClientProxy.cpp +++ b/src/lib/server/BaseClientProxy.cpp @@ -22,7 +22,7 @@ // BaseClientProxy // -BaseClientProxy::BaseClientProxy(const String& name) : +BaseClientProxy::BaseClientProxy(const std::string& name) : m_name(name), m_x(0), m_y(0) @@ -49,8 +49,7 @@ BaseClientProxy::getJumpCursorPos(SInt32& x, SInt32& y) const y = m_y; } -String -BaseClientProxy::getName() const +std::string BaseClientProxy::getName() const { return m_name; } diff --git a/src/lib/server/BaseClientProxy.h b/src/lib/server/BaseClientProxy.h index c7c23ff..a2c9459 100644 --- a/src/lib/server/BaseClientProxy.h +++ b/src/lib/server/BaseClientProxy.h @@ -19,7 +19,6 @@ #pragma once #include "barrier/IClient.h" -#include "base/String.h" namespace barrier { class IStream; } @@ -29,7 +28,7 @@ public: /*! \c name is the name of the client. */ - BaseClientProxy(const String& name); + BaseClientProxy(const std::string& name); ~BaseClientProxy(); //! @name manipulators @@ -89,11 +88,11 @@ public: virtual void sendDragInfo(UInt32 fileCount, const char* info, size_t size) = 0; virtual void fileChunkSending(UInt8 mark, char* data, size_t dataSize) = 0; - virtual String getName() const; + virtual std::string getName() const; virtual barrier::IStream* getStream() const = 0; private: - String m_name; + std::string m_name; SInt32 m_x, m_y; }; diff --git a/src/lib/server/ClientProxy.cpp b/src/lib/server/ClientProxy.cpp index 5a28248..d91e186 100644 --- a/src/lib/server/ClientProxy.cpp +++ b/src/lib/server/ClientProxy.cpp @@ -27,7 +27,7 @@ // ClientProxy // -ClientProxy::ClientProxy(const String& name, barrier::IStream* stream) : +ClientProxy::ClientProxy(const std::string& name, barrier::IStream* stream) : BaseClientProxy(name), m_stream(stream) { diff --git a/src/lib/server/ClientProxy.h b/src/lib/server/ClientProxy.h index 726ded4..a3d87cb 100644 --- a/src/lib/server/ClientProxy.h +++ b/src/lib/server/ClientProxy.h @@ -20,7 +20,6 @@ #include "server/BaseClientProxy.h" #include "base/Event.h" -#include "base/String.h" #include "base/EventTypes.h" namespace barrier { class IStream; } @@ -31,7 +30,7 @@ public: /*! \c name is the name of the client. */ - ClientProxy(const String& name, barrier::IStream* adoptedStream); + ClientProxy(const std::string& name, barrier::IStream* adoptedStream); ~ClientProxy(); //! @name manipulators diff --git a/src/lib/server/ClientProxy1_0.cpp b/src/lib/server/ClientProxy1_0.cpp index ee805c6..5cbaac2 100644 --- a/src/lib/server/ClientProxy1_0.cpp +++ b/src/lib/server/ClientProxy1_0.cpp @@ -31,7 +31,8 @@ // ClientProxy1_0 // -ClientProxy1_0::ClientProxy1_0(const String& name, barrier::IStream* stream, IEventQueue* events) : +ClientProxy1_0::ClientProxy1_0(const std::string& name, barrier::IStream* stream, + IEventQueue* events) : ClientProxy(name, stream), m_heartbeatTimer(NULL), m_parser(&ClientProxy1_0::parseHandshakeMessage), diff --git a/src/lib/server/ClientProxy1_0.h b/src/lib/server/ClientProxy1_0.h index 0720232..98c68f3 100644 --- a/src/lib/server/ClientProxy1_0.h +++ b/src/lib/server/ClientProxy1_0.h @@ -29,7 +29,7 @@ class IEventQueue; //! Proxy for client implementing protocol version 1.0 class ClientProxy1_0 : public ClientProxy { public: - ClientProxy1_0(const String& name, barrier::IStream* adoptedStream, IEventQueue* events); + ClientProxy1_0(const std::string& name, barrier::IStream* adoptedStream, IEventQueue* events); ~ClientProxy1_0(); // IScreen diff --git a/src/lib/server/ClientProxy1_1.cpp b/src/lib/server/ClientProxy1_1.cpp index b7eb4c4..bb33ac1 100644 --- a/src/lib/server/ClientProxy1_1.cpp +++ b/src/lib/server/ClientProxy1_1.cpp @@ -27,7 +27,8 @@ // ClientProxy1_1 // -ClientProxy1_1::ClientProxy1_1(const String& name, barrier::IStream* stream, IEventQueue* events) : +ClientProxy1_1::ClientProxy1_1(const std::string& name, barrier::IStream* stream, + IEventQueue* events) : ClientProxy1_0(name, stream, events) { // do nothing diff --git a/src/lib/server/ClientProxy1_1.h b/src/lib/server/ClientProxy1_1.h index cdb674d..ada4dcc 100644 --- a/src/lib/server/ClientProxy1_1.h +++ b/src/lib/server/ClientProxy1_1.h @@ -23,7 +23,7 @@ //! Proxy for client implementing protocol version 1.1 class ClientProxy1_1 : public ClientProxy1_0 { public: - ClientProxy1_1(const String& name, barrier::IStream* adoptedStream, IEventQueue* events); + ClientProxy1_1(const std::string& name, barrier::IStream* adoptedStream, IEventQueue* events); ~ClientProxy1_1(); // IClient overrides diff --git a/src/lib/server/ClientProxy1_2.cpp b/src/lib/server/ClientProxy1_2.cpp index 2dd13cf..e9527ef 100644 --- a/src/lib/server/ClientProxy1_2.cpp +++ b/src/lib/server/ClientProxy1_2.cpp @@ -25,7 +25,8 @@ // ClientProxy1_1 // -ClientProxy1_2::ClientProxy1_2(const String& name, barrier::IStream* stream, IEventQueue* events) : +ClientProxy1_2::ClientProxy1_2(const std::string& name, barrier::IStream* stream, + IEventQueue* events) : ClientProxy1_1(name, stream, events) { // do nothing diff --git a/src/lib/server/ClientProxy1_2.h b/src/lib/server/ClientProxy1_2.h index f6ffe94..12d6b92 100644 --- a/src/lib/server/ClientProxy1_2.h +++ b/src/lib/server/ClientProxy1_2.h @@ -25,7 +25,7 @@ class IEventQueue; //! Proxy for client implementing protocol version 1.2 class ClientProxy1_2 : public ClientProxy1_1 { public: - ClientProxy1_2(const String& name, barrier::IStream* adoptedStream, IEventQueue* events); + ClientProxy1_2(const std::string& name, barrier::IStream* adoptedStream, IEventQueue* events); ~ClientProxy1_2(); // IClient overrides diff --git a/src/lib/server/ClientProxy1_3.cpp b/src/lib/server/ClientProxy1_3.cpp index 34ea0c8..d0031ce 100644 --- a/src/lib/server/ClientProxy1_3.cpp +++ b/src/lib/server/ClientProxy1_3.cpp @@ -30,7 +30,8 @@ // ClientProxy1_3 // -ClientProxy1_3::ClientProxy1_3(const String& name, barrier::IStream* stream, IEventQueue* events) : +ClientProxy1_3::ClientProxy1_3(const std::string& name, barrier::IStream* stream, + IEventQueue* events) : ClientProxy1_2(name, stream, events), m_keepAliveRate(kKeepAliveRate), m_keepAliveTimer(NULL), diff --git a/src/lib/server/ClientProxy1_3.h b/src/lib/server/ClientProxy1_3.h index ff2ed0a..ad46cea 100644 --- a/src/lib/server/ClientProxy1_3.h +++ b/src/lib/server/ClientProxy1_3.h @@ -23,7 +23,7 @@ //! Proxy for client implementing protocol version 1.3 class ClientProxy1_3 : public ClientProxy1_2 { public: - ClientProxy1_3(const String& name, barrier::IStream* adoptedStream, IEventQueue* events); + ClientProxy1_3(const std::string& name, barrier::IStream* adoptedStream, IEventQueue* events); ~ClientProxy1_3(); // IClient overrides diff --git a/src/lib/server/ClientProxy1_4.cpp b/src/lib/server/ClientProxy1_4.cpp index 43c708d..9b12976 100644 --- a/src/lib/server/ClientProxy1_4.cpp +++ b/src/lib/server/ClientProxy1_4.cpp @@ -31,7 +31,8 @@ // ClientProxy1_4 // -ClientProxy1_4::ClientProxy1_4(const String& name, barrier::IStream* stream, Server* server, IEventQueue* events) : +ClientProxy1_4::ClientProxy1_4(const std::string& name, barrier::IStream* stream, Server* server, + IEventQueue* events) : ClientProxy1_3(name, stream, events), m_server(server) { assert(m_server != NULL); diff --git a/src/lib/server/ClientProxy1_4.h b/src/lib/server/ClientProxy1_4.h index 6c55965..cda090b 100644 --- a/src/lib/server/ClientProxy1_4.h +++ b/src/lib/server/ClientProxy1_4.h @@ -25,7 +25,8 @@ class Server; //! Proxy for client implementing protocol version 1.4 class ClientProxy1_4 : public ClientProxy1_3 { public: - ClientProxy1_4(const String& name, barrier::IStream* adoptedStream, Server* server, IEventQueue* events); + ClientProxy1_4(const std::string& name, barrier::IStream* adoptedStream, Server* server, + IEventQueue* events); ~ClientProxy1_4(); //! @name accessors diff --git a/src/lib/server/ClientProxy1_5.cpp b/src/lib/server/ClientProxy1_5.cpp index 43fd0b7..40bba08 100644 --- a/src/lib/server/ClientProxy1_5.cpp +++ b/src/lib/server/ClientProxy1_5.cpp @@ -31,7 +31,8 @@ // ClientProxy1_5 // -ClientProxy1_5::ClientProxy1_5(const String& name, barrier::IStream* stream, Server* server, IEventQueue* events) : +ClientProxy1_5::ClientProxy1_5(const std::string& name, barrier::IStream* stream, Server* server, + IEventQueue* events) : ClientProxy1_4(name, stream, server, events), m_events(events) { @@ -50,7 +51,7 @@ ClientProxy1_5::~ClientProxy1_5() void ClientProxy1_5::sendDragInfo(UInt32 fileCount, const char* info, size_t size) { - String data(info, size); + std::string data(info, size); ProtocolUtil::writef(getStream(), kMsgDDragInfo, fileCount, &data); } @@ -92,7 +93,7 @@ ClientProxy1_5::fileChunkReceived() } else if (result == kStart) { if (server->getFakeDragFileList().size() > 0) { - String filename = server->getFakeDragFileList().at(0).getFilename(); + std::string filename = server->getFakeDragFileList().at(0).getFilename(); LOG((CLOG_DEBUG "start receiving %s", filename.c_str())); } } @@ -103,7 +104,7 @@ ClientProxy1_5::dragInfoReceived() { // parse UInt32 fileNum = 0; - String content; + 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 776de03..4087730 100644 --- a/src/lib/server/ClientProxy1_5.h +++ b/src/lib/server/ClientProxy1_5.h @@ -27,7 +27,8 @@ class IEventQueue; //! Proxy for client implementing protocol version 1.5 class ClientProxy1_5 : public ClientProxy1_4 { public: - ClientProxy1_5(const String& name, barrier::IStream* adoptedStream, Server* server, IEventQueue* events); + ClientProxy1_5(const std::string& name, barrier::IStream* adoptedStream, Server* server, + IEventQueue* events); ~ClientProxy1_5(); virtual void sendDragInfo(UInt32 fileCount, const char* info, size_t size); diff --git a/src/lib/server/ClientProxy1_6.cpp b/src/lib/server/ClientProxy1_6.cpp index a0d2621..c829e84 100644 --- a/src/lib/server/ClientProxy1_6.cpp +++ b/src/lib/server/ClientProxy1_6.cpp @@ -29,7 +29,8 @@ // ClientProxy1_6 // -ClientProxy1_6::ClientProxy1_6(const String& name, barrier::IStream* stream, Server* server, IEventQueue* events) : +ClientProxy1_6::ClientProxy1_6(const std::string& name, barrier::IStream* stream, Server* server, + IEventQueue* events) : ClientProxy1_5(name, stream, server, events), m_events(events) { @@ -52,7 +53,7 @@ ClientProxy1_6::setClipboard(ClipboardID id, const IClipboard* clipboard) m_clipboard[id].m_dirty = false; Clipboard::copy(&m_clipboard[id].m_clipboard, clipboard); - String data = m_clipboard[id].m_clipboard.marshall(); + std::string data = m_clipboard[id].m_clipboard.marshall(); size_t size = data.size(); LOG((CLOG_DEBUG "sending clipboard %d to \"%s\"", id, getName().c_str())); @@ -71,7 +72,7 @@ bool ClientProxy1_6::recvClipboard() { // parse message - static String dataCached; + static std::string dataCached; ClipboardID id; UInt32 seq; diff --git a/src/lib/server/ClientProxy1_6.h b/src/lib/server/ClientProxy1_6.h index 838cb02..830696a 100644 --- a/src/lib/server/ClientProxy1_6.h +++ b/src/lib/server/ClientProxy1_6.h @@ -25,7 +25,8 @@ class IEventQueue; //! Proxy for client implementing protocol version 1.6 class ClientProxy1_6 : public ClientProxy1_5 { public: - ClientProxy1_6(const String& name, barrier::IStream* adoptedStream, Server* server, IEventQueue* events); + ClientProxy1_6(const std::string& name, barrier::IStream* adoptedStream, Server* server, + IEventQueue* events); ~ClientProxy1_6(); virtual void setClipboard(ClipboardID id, const IClipboard* clipboard); diff --git a/src/lib/server/ClientProxyUnknown.cpp b/src/lib/server/ClientProxyUnknown.cpp index f929108..dc79da7 100644 --- a/src/lib/server/ClientProxyUnknown.cpp +++ b/src/lib/server/ClientProxyUnknown.cpp @@ -32,7 +32,6 @@ #include "io/IStream.h" #include "io/XIO.h" #include "base/Log.h" -#include "base/String.h" #include "base/IEventQueue.h" #include "base/TMethodEventJob.h" @@ -176,7 +175,7 @@ ClientProxyUnknown::handleData(const Event&, void*) { LOG((CLOG_DEBUG1 "parsing hello reply")); - String name(""); + std::string name(""); try { // limit the maximum length of the hello UInt32 n = m_stream->getSize(); diff --git a/src/lib/server/Config.cpp b/src/lib/server/Config.cpp index 3cf60a5..a47a391 100644 --- a/src/lib/server/Config.cpp +++ b/src/lib/server/Config.cpp @@ -48,7 +48,7 @@ Config::~Config() } bool -Config::addScreen(const String& name) +Config::addScreen(const std::string& name) { // alias name must not exist if (m_nameToCanonicalName.find(name) != m_nameToCanonicalName.end()) { @@ -64,12 +64,10 @@ Config::addScreen(const String& name) return true; } -bool -Config::renameScreen(const String& oldName, - const String& newName) +bool Config::renameScreen(const std::string& oldName, const std::string& newName) { // get canonical name and find cell - String oldCanonical = getCanonicalName(oldName); + std::string oldCanonical = getCanonicalName(oldName); CellMap::iterator index = m_map.find(oldCanonical); if (index == m_map.end()) { return false; @@ -111,11 +109,10 @@ Config::renameScreen(const String& oldName, return true; } -void -Config::removeScreen(const String& name) +void Config::removeScreen(const std::string& name) { // get canonical name and find cell - String canonical = getCanonicalName(name); + std::string canonical = getCanonicalName(name); CellMap::iterator index = m_map.find(canonical); if (index == m_map.end()) { return; @@ -149,8 +146,7 @@ Config::removeAllScreens() m_nameToCanonicalName.clear(); } -bool -Config::addAlias(const String& canonical, const String& alias) +bool Config::addAlias(const std::string& canonical, const std::string& alias) { // alias name must not exist if (m_nameToCanonicalName.find(alias) != m_nameToCanonicalName.end()) { @@ -168,8 +164,7 @@ Config::addAlias(const String& canonical, const String& alias) return true; } -bool -Config::removeAlias(const String& alias) +bool Config::removeAlias(const std::string& alias) { // must not be a canonical name if (m_map.find(alias) != m_map.end()) { @@ -188,8 +183,7 @@ Config::removeAlias(const String& alias) return true; } -bool -Config::removeAliases(const String& canonical) +bool Config::removeAliases(const std::string& canonical) { // must be a canonical name if (m_map.find(canonical) == m_map.end()) { @@ -224,12 +218,9 @@ Config::removeAllAliases() } } -bool -Config::connect(const String& srcName, - EDirection srcSide, - float srcStart, float srcEnd, - const String& dstName, - float dstStart, float dstEnd) +bool Config::connect(const std::string& srcName, EDirection srcSide, + float srcStart, float srcEnd, const std::string& dstName, + float dstStart, float dstEnd) { assert(srcSide >= kFirstDirection && srcSide <= kLastDirection); @@ -245,8 +236,7 @@ Config::connect(const String& srcName, return index->second.add(srcEdge, dstEdge); } -bool -Config::disconnect(const String& srcName, EDirection srcSide) +bool Config::disconnect(const std::string& srcName, EDirection srcSide) { assert(srcSide >= kFirstDirection && srcSide <= kLastDirection); @@ -262,8 +252,7 @@ Config::disconnect(const String& srcName, EDirection srcSide) return true; } -bool -Config::disconnect(const String& srcName, EDirection srcSide, float position) +bool Config::disconnect(const std::string& srcName, EDirection srcSide, float position) { assert(srcSide >= kFirstDirection && srcSide <= kLastDirection); @@ -285,8 +274,7 @@ Config::setBarrierAddress(const NetworkAddress& addr) m_barrierAddress = addr; } -bool -Config::addOption(const String& name, OptionID option, OptionValue value) +bool Config::addOption(const std::string& name, OptionID option, OptionValue value) { // find options ScreenOptions* options = NULL; @@ -308,8 +296,7 @@ Config::addOption(const String& name, OptionID option, OptionValue value) return true; } -bool -Config::removeOption(const String& name, OptionID option) +bool Config::removeOption(const std::string& name, OptionID option) { // find options ScreenOptions* options = NULL; @@ -331,8 +318,7 @@ Config::removeOption(const String& name, OptionID option) return true; } -bool -Config::removeOptions(const String& name) +bool Config::removeOptions(const std::string& name) { // find options ScreenOptions* options = NULL; @@ -354,8 +340,7 @@ Config::removeOptions(const String& name) return true; } -bool -Config::isValidScreenName(const String& name) const +bool Config::isValidScreenName(const std::string& name) const { // name is valid if matches validname // name ::= [_A-Za-z0-9] | [_A-Za-z0-9][-_A-Za-z0-9]*[_A-Za-z0-9] @@ -370,7 +355,7 @@ Config::isValidScreenName(const String& name) const } // check each dot separated part - String::size_type b = 0; + std::string::size_type b = 0; for (;;) { // accept trailing . if (b == name.size()) { @@ -378,8 +363,8 @@ Config::isValidScreenName(const String& name) const } // find end of part - String::size_type e = name.find('.', b); - if (e == String::npos) { + std::string::size_type e = name.find('.', b); + if (e == std::string::npos) { e = name.size(); } @@ -395,7 +380,7 @@ Config::isValidScreenName(const String& name) const } // check interior characters - for (String::size_type i = b; i < e; ++i) { + for (std::string::size_type i = b; i < e; ++i) { if (!isalnum(name[i]) && name[i] != '_' && name[i] != '-') { return false; } @@ -437,40 +422,38 @@ Config::endAll() const } bool -Config::isScreen(const String& name) const +Config::isScreen(const std::string& name) const { return (m_nameToCanonicalName.count(name) > 0); } bool -Config::isCanonicalName(const String& name) const +Config::isCanonicalName(const std::string& name) const { return (!name.empty() && CaselessCmp::equal(getCanonicalName(name), name)); } -String -Config::getCanonicalName(const String& name) const +std::string Config::getCanonicalName(const std::string& name) const { NameMap::const_iterator index = m_nameToCanonicalName.find(name); if (index == m_nameToCanonicalName.end()) { - return String(); + return std::string(); } else { return index->second; } } -String -Config::getNeighbor(const String& srcName, EDirection srcSide, - float position, float* positionOut) const +std::string Config::getNeighbor(const std::string& srcName, EDirection srcSide, + float position, float* positionOut) const { assert(srcSide >= kFirstDirection && srcSide <= kLastDirection); // find source cell CellMap::const_iterator index = m_map.find(getCanonicalName(srcName)); if (index == m_map.end()) { - return String(); + return std::string(); } // find edge @@ -491,15 +474,13 @@ Config::getNeighbor(const String& srcName, EDirection srcSide, } } -bool -Config::hasNeighbor(const String& srcName, EDirection srcSide) const +bool Config::hasNeighbor(const std::string& srcName, EDirection srcSide) const { return hasNeighbor(srcName, srcSide, 0.0f, 1.0f); } -bool -Config::hasNeighbor(const String& srcName, EDirection srcSide, - float start, float end) const +bool Config::hasNeighbor(const std::string& srcName, EDirection srcSide, + float start, float end) const { assert(srcSide >= kFirstDirection && srcSide <= kLastDirection); @@ -512,16 +493,14 @@ Config::hasNeighbor(const String& srcName, EDirection srcSide, return index->second.overlaps(CellEdge(srcSide, Interval(start, end))); } -Config::link_const_iterator -Config::beginNeighbor(const String& srcName) const +Config::link_const_iterator Config::beginNeighbor(const std::string& srcName) const { CellMap::const_iterator index = m_map.find(getCanonicalName(srcName)); assert(index != m_map.end()); return index->second.begin(); } -Config::link_const_iterator -Config::endNeighbor(const String& srcName) const +Config::link_const_iterator Config::endNeighbor(const std::string& srcName) const { CellMap::const_iterator index = m_map.find(getCanonicalName(srcName)); assert(index != m_map.end()); @@ -534,8 +513,7 @@ Config::getBarrierAddress() const return m_barrierAddress; } -const Config::ScreenOptions* -Config::getOptions(const String& name) const +const Config::ScreenOptions* Config::getOptions(const std::string& name) const { // find options const ScreenOptions* options = NULL; @@ -641,8 +619,7 @@ Config::getInputFilter() return &m_inputFilter; } -String -Config::formatInterval(const Interval& x) +std::string Config::formatInterval(const Interval& x) { if (x.first == 0.0f && x.second == 1.0f) { return ""; @@ -660,7 +637,7 @@ Config::readSection(ConfigReadContext& s) static const char s_links[] = "links"; static const char s_aliases[] = "aliases"; - String line; + std::string line; if (!s.readLine(line)) { // no more sections return; @@ -672,13 +649,13 @@ Config::readSection(ConfigReadContext& s) } // get section name - String::size_type i = line.find_first_not_of(" \t", sizeof(s_section) - 1); - if (i == String::npos) { + std::string::size_type i = line.find_first_not_of(" \t", sizeof(s_section) - 1); + if (i == std::string::npos) { throw XConfigRead(s, "section name is missing"); } - String name = line.substr(i); + std::string name = line.substr(i); i = name.find_first_of(" \t"); - if (i != String::npos) { + if (i != std::string::npos) { throw XConfigRead(s, "unexpected data after section name"); } @@ -703,7 +680,7 @@ Config::readSection(ConfigReadContext& s) void Config::readSectionOptions(ConfigReadContext& s) { - String line; + std::string line; while (s.readLine(line)) { // check for end of section if (line == "end") { @@ -714,8 +691,8 @@ Config::readSectionOptions(ConfigReadContext& s) // nameAndArgs := [(arg[,...])] // values := valueAndArgs[,valueAndArgs]... // valueAndArgs := [(arg[,...])] - String::size_type i = 0; - String name, value; + std::string::size_type i = 0; + std::string name, value; ConfigReadContext::ArgList nameArgs, valueArgs; s.parseNameWithArgs("name", line, "=", i, name, nameArgs); ++i; @@ -728,8 +705,7 @@ Config::readSectionOptions(ConfigReadContext& s) m_barrierAddress.resolve(); } catch (XSocketAddress& e) { - throw XConfigRead(s, - String("invalid address argument ") + e.what()); + throw XConfigRead(s, std::string("invalid address argument ") + e.what()); } } else if (name == "heartbeat") { @@ -799,7 +775,7 @@ Config::readSectionOptions(ConfigReadContext& s) if (i < line.length() && line[i] == ';') { // allow trailing ';' i = line.find_first_not_of(" \t", i + 1); - if (i == String::npos) { + if (i == std::string::npos) { i = line.length(); } else { @@ -825,9 +801,9 @@ Config::readSectionOptions(ConfigReadContext& s) void Config::readSectionScreens(ConfigReadContext& s) { - String line; - String screen; - while (s.readLine(line)) { + std::string line; + std::string screen; + while (s.readLine(line)) { // check for end of section if (line == "end") { return; @@ -853,21 +829,21 @@ Config::readSectionScreens(ConfigReadContext& s) } else { // parse argument: `=' - String::size_type i = line.find_first_of(" \t="); + std::string::size_type i = line.find_first_of(" \t="); if (i == 0) { throw XConfigRead(s, "missing argument name"); } - if (i == String::npos) { + if (i == std::string::npos) { throw XConfigRead(s, "missing ="); } - String name = line.substr(0, i); + std::string name = line.substr(0, i); i = line.find_first_not_of(" \t", i); - if (i == String::npos || line[i] != '=') { + if (i == std::string::npos || line[i] != '=') { throw XConfigRead(s, "missing ="); } i = line.find_first_not_of(" \t", i + 1); - String value; - if (i != String::npos) { + std::string value; + if (i != std::string::npos) { value = line.substr(i); } @@ -936,8 +912,8 @@ Config::readSectionScreens(ConfigReadContext& s) void Config::readSectionLinks(ConfigReadContext& s) { - String line; - String screen; + std::string line; + std::string screen; while (s.readLine(line)) { // check for end of section if (line == "end") { @@ -965,8 +941,8 @@ Config::readSectionLinks(ConfigReadContext& s) // the stuff in brackets is optional. interval values must be // in the range [0,100] and start < end. if not given the // interval is taken to be (0,100). - String::size_type i = 0; - String side, dstScreen, srcArgString, dstArgString; + std::string::size_type i = 0; + std::string side, dstScreen, srcArgString, dstArgString; ConfigReadContext::ArgList srcArgs, dstArgs; s.parseNameWithArgs("link", line, "=", i, side, srcArgs); ++i; @@ -1009,8 +985,8 @@ Config::readSectionLinks(ConfigReadContext& s) void Config::readSectionAliases(ConfigReadContext& s) { - String line; - String screen; + std::string line; + std::string screen; while (s.readLine(line)) { // check for end of section if (line == "end") { @@ -1049,9 +1025,8 @@ Config::readSectionAliases(ConfigReadContext& s) } -InputFilter::Condition* -Config::parseCondition(ConfigReadContext& s, - const String& name, const std::vector& args) +InputFilter::Condition* Config::parseCondition(ConfigReadContext& s, const std::string& name, + const std::vector& args) { if (name == "keystroke") { if (args.size() != 1) { @@ -1078,7 +1053,7 @@ Config::parseCondition(ConfigReadContext& s, throw XConfigRead(s, "syntax for condition: connect([screen])"); } - String screen = args[0]; + std::string screen = args[0]; if (isScreen(screen)) { screen = getCanonicalName(screen); } @@ -1092,10 +1067,9 @@ Config::parseCondition(ConfigReadContext& s, throw XConfigRead(s, "unknown argument \"%{1}\"", name); } -void -Config::parseAction(ConfigReadContext& s, - const String& name, const std::vector& args, - InputFilter::Rule& rule, bool activate) +void Config::parseAction(ConfigReadContext& s, const std::string& name, + const std::vector& args, + InputFilter::Rule& rule, bool activate) { InputFilter::Action* action; @@ -1109,7 +1083,7 @@ Config::parseAction(ConfigReadContext& s, keyInfo = s.parseKeystroke(args[0]); } else { - std::set screens; + std::set screens; parseScreens(s, args[1], screens); keyInfo = s.parseKeystroke(args[0], screens); } @@ -1171,7 +1145,7 @@ Config::parseAction(ConfigReadContext& s, throw XConfigRead(s, "syntax for action: switchToScreen(name)"); } - String screen = args[0]; + std::string screen = args[0]; if (isScreen(screen)) { screen = getCanonicalName(screen); } @@ -1182,6 +1156,10 @@ Config::parseAction(ConfigReadContext& s, action = new InputFilter::SwitchToScreenAction(m_events, screen); } + else if (name == "toggleScreen") { + action = new InputFilter::ToggleScreenAction(m_events); + } + else if (name == "switchInDirection") { if (args.size() != 1) { throw XConfigRead(s, "syntax for action: switchInDirection()"); @@ -1258,7 +1236,7 @@ Config::parseAction(ConfigReadContext& s, } } - std::set screens; + std::set screens; if (args.size() >= 2) { parseScreens(s, args[1], screens); } @@ -1273,22 +1251,21 @@ Config::parseAction(ConfigReadContext& s, rule.adoptAction(action, activate); } -void -Config::parseScreens(ConfigReadContext& c, - const String& s, std::set& screens) const +void Config::parseScreens(ConfigReadContext& c, const std::string& s, + std::set& screens) const { screens.clear(); - String::size_type i = 0; + std::string::size_type i = 0; while (i < s.size()) { // find end of next screen name - String::size_type j = s.find(':', i); - if (j == String::npos) { + std::string::size_type j = s.find(':', i); + if (j == std::string::npos) { j = s.size(); } // extract name - String rawName; + std::string rawName; i = s.find_first_not_of(" \t", i); if (i < j) { rawName = s.substr(i, s.find_last_not_of(" \t", j - 1) - i + 1); @@ -1299,7 +1276,7 @@ Config::parseScreens(ConfigReadContext& c, screens.insert("*"); } else if (!rawName.empty()) { - String name = getCanonicalName(rawName); + std::string name = getCanonicalName(rawName); if (name.empty()) { throw XConfigRead(c, "unknown screen name \"%{1}\"", rawName); } @@ -1386,8 +1363,7 @@ Config::getOptionName(OptionID id) return NULL; } -String -Config::getOptionValue(OptionID id, OptionValue value) +std::string Config::getOptionValue(OptionID id, OptionValue value) { if (id == kOptionHalfDuplexCapsLock || id == kOptionHalfDuplexNumLock || @@ -1463,17 +1439,16 @@ Config::getOptionValue(OptionID id, OptionValue value) // Config::Name // -Config::Name::Name(Config* config, const String& name) : +Config::Name::Name(Config* config, const std::string& name) : m_config(config), m_name(config->getCanonicalName(name)) { // do nothing } -bool -Config::Name::operator==(const String& name) const +bool Config::Name::operator==(const std::string& name) const { - String canonical = m_config->getCanonicalName(name); + std::string canonical = m_config->getCanonicalName(name); return CaselessCmp::equal(canonical, m_name); } @@ -1496,8 +1471,7 @@ Config::CellEdge::CellEdge(EDirection side, const Interval& interval) init("", side, interval); } -Config::CellEdge::CellEdge(const String& name, - EDirection side, const Interval& interval) +Config::CellEdge::CellEdge(const std::string& name, EDirection side, const Interval& interval) { assert(interval.first >= 0.0f); assert(interval.second <= 1.0f); @@ -1511,9 +1485,7 @@ Config::CellEdge::~CellEdge() // do nothing } -void -Config::CellEdge::init(const String& name, EDirection side, - const Interval& interval) +void Config::CellEdge::init(const std::string& name, EDirection side, const Interval& interval) { assert(side != kNoDirection); @@ -1528,14 +1500,12 @@ Config::CellEdge::getInterval() const return m_interval; } -void -Config::CellEdge::setName(const String& newName) +void Config::CellEdge::setName(const std::string& newName) { m_name = newName; } -String -Config::CellEdge::getName() const +std::string Config::CellEdge::getName() const { return m_name; } @@ -1662,8 +1632,7 @@ Config::Cell::remove(const Name& name) } } -void -Config::Cell::rename(const Name& oldName, const String& newName) +void Config::Cell::rename(const Name& oldName, const std::string& newName) { for (EdgeLinks::iterator j = m_neighbors.begin(); j != m_neighbors.end(); ++j) { @@ -1789,8 +1758,7 @@ operator<<(std::ostream& s, const Config& config) option = options->begin(); option != options->end(); ++option) { const char* name = Config::getOptionName(option->first); - String value = Config::getOptionValue(option->first, - option->second); + std::string value = Config::getOptionValue(option->first, option->second); if (name != NULL && !value.empty()) { s << "\t\t" << name << " = " << value << std::endl; } @@ -1800,7 +1768,7 @@ operator<<(std::ostream& s, const Config& config) s << "end" << std::endl; // links section - String neighbor; + std::string neighbor; s << "section: links" << std::endl; for (Config::const_iterator screen = config.begin(); screen != config.end(); ++screen) { @@ -1821,8 +1789,7 @@ operator<<(std::ostream& s, const Config& config) // aliases section (if there are any) if (config.m_map.size() != config.m_nameToCanonicalName.size()) { // map canonical to alias - typedef std::multimap CMNameMap; + typedef std::multimap CMNameMap; CMNameMap aliases; for (Config::NameMap::const_iterator index = config.m_nameToCanonicalName.begin(); @@ -1834,7 +1801,7 @@ operator<<(std::ostream& s, const Config& config) } // dump it - String screen; + std::string screen; s << "section: aliases" << std::endl; for (CMNameMap::const_iterator index = aliases.begin(); index != aliases.end(); ++index) { @@ -1855,8 +1822,7 @@ operator<<(std::ostream& s, const Config& config) option = options->begin(); option != options->end(); ++option) { const char* name = Config::getOptionName(option->first); - String value = Config::getOptionValue(option->first, - option->second); + std::string value = Config::getOptionValue(option->first, option->second); if (name != NULL && !value.empty()) { s << "\t" << name << " = " << value << std::endl; } @@ -1889,24 +1855,23 @@ ConfigReadContext::~ConfigReadContext() // do nothing } -bool -ConfigReadContext::readLine(String& line) +bool ConfigReadContext::readLine(std::string& line) { ++m_line; while (std::getline(m_stream, line)) { // strip leading whitespace - String::size_type i = line.find_first_not_of(" \t"); - if (i != String::npos) { - line.erase(0, i); + std::string::size_type i = line.find_first_not_of(" \t"); + if (i != std::string::npos) { + line.erase(0, i); } // strip comments and then trailing whitespace i = line.find('#'); - if (i != String::npos) { + if (i != std::string::npos) { line.erase(i); } i = line.find_last_not_of(" \r\t"); - if (i != String::npos) { + if (i != std::string::npos) { line.erase(i + 1); } @@ -1942,8 +1907,7 @@ ConfigReadContext::operator!() const return !m_stream; } -OptionValue -ConfigReadContext::parseBoolean(const String& arg) const +OptionValue ConfigReadContext::parseBoolean(const std::string& arg) const { if (CaselessCmp::equal(arg, "true")) { return static_cast(true); @@ -1954,8 +1918,7 @@ ConfigReadContext::parseBoolean(const String& arg) const throw XConfigRead(*this, "invalid boolean argument \"%{1}\"", arg); } -OptionValue -ConfigReadContext::parseInt(const String& arg) const +OptionValue ConfigReadContext::parseInt(const std::string& arg) const { const char* s = arg.c_str(); char* end; @@ -1972,8 +1935,7 @@ ConfigReadContext::parseInt(const String& arg) const return value; } -OptionValue -ConfigReadContext::parseModifierKey(const String& arg) const +OptionValue ConfigReadContext::parseModifierKey(const std::string& arg) const { if (CaselessCmp::equal(arg, "shift")) { return static_cast(kKeyModifierIDShift); @@ -1999,8 +1961,7 @@ ConfigReadContext::parseModifierKey(const String& arg) const throw XConfigRead(*this, "invalid argument \"%{1}\"", arg); } -OptionValue -ConfigReadContext::parseCorner(const String& arg) const +OptionValue ConfigReadContext::parseCorner(const std::string& arg) const { if (CaselessCmp::equal(arg, "left")) { return kTopLeftMask | kBottomLeftMask; @@ -2035,22 +1996,21 @@ ConfigReadContext::parseCorner(const String& arg) const throw XConfigRead(*this, "invalid argument \"%{1}\"", arg); } -OptionValue -ConfigReadContext::parseCorners(const String& args) const +OptionValue ConfigReadContext::parseCorners(const std::string& args) const { // find first token - String::size_type i = args.find_first_not_of(" \t", 0); - if (i == String::npos) { + std::string::size_type i = args.find_first_not_of(" \t", 0); + if (i == std::string::npos) { throw XConfigRead(*this, "missing corner argument"); } - String::size_type j = args.find_first_of(" \t", i); + std::string::size_type j = args.find_first_of(" \t", i); // parse first corner token OptionValue corners = parseCorner(args.substr(i, j - i)); // get +/- i = args.find_first_not_of(" \t", j); - while (i != String::npos) { + while (i != std::string::npos) { // parse +/- bool add; if (args[i] == '-') { @@ -2060,15 +2020,14 @@ ConfigReadContext::parseCorners(const String& args) const add = true; } else { - throw XConfigRead(*this, - "invalid corner operator \"%{1}\"", - String(args.c_str() + i, 1)); + throw XConfigRead(*this, "invalid corner operator \"%{1}\"", + std::string(args.c_str() + i, 1)); } // get next corner token i = args.find_first_not_of(" \t", i + 1); j = args.find_first_of(" \t", i); - if (i == String::npos) { + if (i == std::string::npos) { throw XConfigRead(*this, "missing corner argument"); } @@ -2114,21 +2073,19 @@ ConfigReadContext::parseInterval(const ArgList& args) const return Config::Interval(startValue / 100.0f, endValue / 100.0f); } -void -ConfigReadContext::parseNameWithArgs( - const String& type, const String& line, - const String& delim, String::size_type& index, - String& name, ArgList& args) const +void ConfigReadContext::parseNameWithArgs(const std::string& type, const std::string& line, + const std::string& delim, std::string::size_type& index, + std::string& name, ArgList& args) const { // skip leading whitespace - String::size_type i = line.find_first_not_of(" \t", index); - if (i == String::npos) { - throw XConfigRead(*this, String("missing ") + type); + std::string::size_type i = line.find_first_not_of(" \t", index); + if (i == std::string::npos) { + throw XConfigRead(*this, std::string("missing ") + type); } // find end of name - String::size_type j = line.find_first_of(" \t(" + delim, i); - if (j == String::npos) { + std::string::size_type j = line.find_first_of(" \t(" + delim, i); + if (j == std::string::npos) { j = line.length(); } @@ -2137,15 +2094,15 @@ ConfigReadContext::parseNameWithArgs( args.clear(); // is it okay to not find a delimiter? - bool needDelim = (!delim.empty() && delim.find('\n') == String::npos); + bool needDelim = (!delim.empty() && delim.find('\n') == std::string::npos); // skip whitespace i = line.find_first_not_of(" \t", j); - if (i == String::npos && needDelim) { + if (i == std::string::npos && needDelim) { // expected delimiter but didn't find it - throw XConfigRead(*this, String("missing ") + delim[0]); + throw XConfigRead(*this, std::string("missing ") + delim[0]); } - if (i == String::npos) { + if (i == std::string::npos) { // no arguments index = line.length(); return; @@ -2161,18 +2118,18 @@ ConfigReadContext::parseNameWithArgs( // parse arguments j = line.find_first_of(",)", i); - while (j != String::npos) { + while (j != std::string::npos) { // extract arg - String arg(line.substr(i, j - i)); + std::string arg(line.substr(i, j - i)); i = j; // trim whitespace j = arg.find_first_not_of(" \t"); - if (j != String::npos) { + if (j != std::string::npos) { arg.erase(0, j); } j = arg.find_last_not_of(" \t"); - if (j != String::npos) { + if (j != std::string::npos) { arg.erase(j + 1); } @@ -2192,7 +2149,7 @@ ConfigReadContext::parseNameWithArgs( } // verify ')' - if (j == String::npos) { + if (j == std::string::npos) { // expected ) throw XConfigRead(*this, "missing )"); } @@ -2202,17 +2159,17 @@ ConfigReadContext::parseNameWithArgs( // skip whitespace j = line.find_first_not_of(" \t", i); - if (j == String::npos && needDelim) { + if (j == std::string::npos && needDelim) { // expected delimiter but didn't find it - throw XConfigRead(*this, String("missing ") + delim[0]); + throw XConfigRead(*this, std::string("missing ") + delim[0]); } // verify delimiter - if (needDelim && delim.find(line[j]) == String::npos) { - throw XConfigRead(*this, String("expected ") + delim[0]); + if (needDelim && delim.find(line[j]) == std::string::npos) { + throw XConfigRead(*this, std::string("expected ") + delim[0]); } - if (j == String::npos) { + if (j == std::string::npos) { j = line.length(); } @@ -2220,17 +2177,15 @@ ConfigReadContext::parseNameWithArgs( return; } -IPlatformScreen::KeyInfo* -ConfigReadContext::parseKeystroke(const String& keystroke) const +IPlatformScreen::KeyInfo* ConfigReadContext::parseKeystroke(const std::string& keystroke) const { - return parseKeystroke(keystroke, std::set()); + return parseKeystroke(keystroke, std::set()); } -IPlatformScreen::KeyInfo* -ConfigReadContext::parseKeystroke(const String& keystroke, - const std::set& screens) const +IPlatformScreen::KeyInfo* ConfigReadContext::parseKeystroke(const std::string& keystroke, + const std::set& screens) const { - String s = keystroke; + std::string s = keystroke; KeyModifierMask mask; if (!barrier::KeyMap::parseModifiers(s, mask)) { @@ -2250,9 +2205,9 @@ ConfigReadContext::parseKeystroke(const String& keystroke, } IPlatformScreen::ButtonInfo* -ConfigReadContext::parseMouse(const String& mouse) const +ConfigReadContext::parseMouse(const std::string& mouse) const { - String s = mouse; + std::string s = mouse; KeyModifierMask mask; if (!barrier::KeyMap::parseModifiers(s, mask)) { @@ -2271,10 +2226,9 @@ ConfigReadContext::parseMouse(const String& mouse) const return IPlatformScreen::ButtonInfo::alloc(button, mask); } -KeyModifierMask -ConfigReadContext::parseModifier(const String& modifiers) const +KeyModifierMask ConfigReadContext::parseModifier(const std::string& modifiers) const { - String s = modifiers; + std::string s = modifiers; KeyModifierMask mask; if (!barrier::KeyMap::parseModifiers(s, mask)) { @@ -2288,10 +2242,9 @@ ConfigReadContext::parseModifier(const String& modifiers) const return mask; } -String -ConfigReadContext::concatArgs(const ArgList& args) +std::string ConfigReadContext::concatArgs(const ArgList& args) { - String s("("); + std::string s("("); for (size_t i = 0; i < args.size(); ++i) { if (i != 0) { s += ","; @@ -2307,29 +2260,27 @@ ConfigReadContext::concatArgs(const ArgList& args) // Config I/O exceptions // -XConfigRead::XConfigRead(const ConfigReadContext& context, - const String& error) : +XConfigRead::XConfigRead(const ConfigReadContext& context, const std::string& error) : m_error(barrier::string::sprintf("line %d: %s", context.getLineNumber(), error.c_str())) { // do nothing } -XConfigRead::XConfigRead(const ConfigReadContext& context, - const char* errorFmt, const String& arg) : +XConfigRead::XConfigRead(const ConfigReadContext& context, const char* errorFmt, + const std::string& arg) : m_error(barrier::string::sprintf("line %d: ", context.getLineNumber()) + barrier::string::format(errorFmt, arg.c_str())) { // do nothing } -XConfigRead::~XConfigRead() _NOEXCEPT +XConfigRead::~XConfigRead() noexcept { // do nothing } -String -XConfigRead::getWhat() const throw() +std::string XConfigRead::getWhat() const noexcept { return format("XConfigRead", "read error: %{1}", m_error.c_str()); } diff --git a/src/lib/server/Config.h b/src/lib/server/Config.h index 69b01c4..c459393 100644 --- a/src/lib/server/Config.h +++ b/src/lib/server/Config.h @@ -23,7 +23,6 @@ #include "barrier/protocol_types.h" #include "barrier/IPlatformScreen.h" #include "net/NetworkAddress.h" -#include "base/String.h" #include "base/XBase.h" #include "common/stdmap.h" #include "common/stdset.h" @@ -37,11 +36,11 @@ class IEventQueue; namespace std { template <> struct iterator_traits { - typedef String value_type; + typedef std::string value_type; typedef ptrdiff_t difference_type; typedef bidirectional_iterator_tag iterator_category; - typedef String* pointer; - typedef String& reference; + typedef std::string* pointer; + typedef std::string& reference; }; }; @@ -64,12 +63,12 @@ public: public: CellEdge(EDirection side, float position); CellEdge(EDirection side, const Interval&); - CellEdge(const String& name, EDirection side, const Interval&); + CellEdge(const std::string& name, EDirection side, const Interval&); ~CellEdge(); Interval getInterval() const; - void setName(const String& newName); - String getName() const; + void setName(const std::string& newName); + std::string getName() const; EDirection getSide() const; bool overlaps(const CellEdge&) const; bool isInside(float x) const; @@ -88,11 +87,10 @@ public: bool operator!=(const CellEdge&) const; private: - void init(const String& name, EDirection side, - const Interval&); + void init(const std::string& name, EDirection side, const Interval&); private: - String m_name; + std::string m_name; EDirection m_side; Interval m_interval; }; @@ -100,13 +98,13 @@ public: private: class Name { public: - Name(Config*, const String& name); + Name(Config*, const std::string& name); - bool operator==(const String& name) const; + bool operator==(const std::string& name) const; private: Config* m_config; - String m_name; + std::string m_name; }; class Cell { @@ -120,7 +118,7 @@ private: void remove(EDirection side); void remove(EDirection side, float position); void remove(const Name& destinationName); - void rename(const Name& oldName, const String& newName); + void rename(const Name& oldName, const std::string& newName); bool hasEdge(const CellEdge&) const; bool overlaps(const CellEdge&) const; @@ -140,8 +138,8 @@ private: public: ScreenOptions m_options; }; - typedef std::map CellMap; - typedef std::map NameMap; + typedef std::map CellMap; + typedef std::map NameMap; public: typedef Cell::const_iterator link_const_iterator; @@ -156,8 +154,8 @@ public: m_i = i.m_i; return *this; } - String operator*() { return m_i->first; } - const String* operator->() { return &(m_i->first); } + std::string operator*() { return m_i->first; } + const std::string* operator->() { return &(m_i->first); } const_iterator& operator++() { ++m_i; return *this; } const_iterator operator++(int) { return const_iterator(m_i++); } const_iterator& operator--() { --m_i; return *this; } @@ -188,15 +186,14 @@ public: Adds a screen, returning true iff successful. If a screen or alias with the given name exists then it fails. */ - bool addScreen(const String& name); + bool addScreen(const std::string& name); //! Rename screen /*! Renames a screen. All references to the name are updated. Returns true iff successful. */ - bool renameScreen(const String& oldName, - const String& newName); + bool renameScreen(const std::string& oldName, const std::string& newName); //! Remove screen /*! @@ -204,7 +201,7 @@ public: disconnects any connections to the screen. \c name may be an alias. */ - void removeScreen(const String& name); + void removeScreen(const std::string& name); //! Remove all screens /*! @@ -219,22 +216,21 @@ public: Returns false if the alias name already exists or the canonical name is unknown, otherwise returns true. */ - bool addAlias(const String& canonical, - const String& alias); + bool addAlias(const std::string& canonical, const std::string& alias); //! Remove alias /*! Removes an alias for a screen name. It returns false if the alias is unknown or a canonical name, otherwise returns true. */ - bool removeAlias(const String& alias); + bool removeAlias(const std::string& alias); //! Remove aliases /*! Removes all aliases for a canonical screen name. It returns false if the canonical name is unknown, otherwise returns true. */ - bool removeAliases(const String& canonical); + bool removeAliases(const std::string& canonical); //! Remove all aliases /*! @@ -258,19 +254,15 @@ public: and all of \c srcStart, \c srcEnd, \c dstStart, or \c dstEnd must be inside the range [0,1]. */ - bool connect(const String& srcName, - EDirection srcSide, - float srcStart, float srcEnd, - const String& dstName, - float dstStart, float dstEnd); + bool connect(const std::string& srcName, EDirection srcSide, float srcStart, float srcEnd, + const std::string& dstName, float dstStart, float dstEnd); //! Disconnect screens /*! Removes all connections created by connect() on side \c srcSide. Returns false if \c srcName is unknown. */ - bool disconnect(const String& srcName, - EDirection srcSide); + bool disconnect(const std::string& srcName, EDirection srcSide); //! Disconnect screens /*! @@ -278,8 +270,7 @@ public: covering position \c position. Returns false if \c srcName is unknown. */ - bool disconnect(const String& srcName, - EDirection srcSide, float position); + bool disconnect(const std::string& srcName, EDirection srcSide, float position); //! Set server address /*! @@ -294,8 +285,7 @@ public: existing option's value if there is one. Returns true iff \c name is a known screen. */ - bool addOption(const String& name, - OptionID option, OptionValue value); + bool addOption(const std::string& name, OptionID option, OptionValue value); //! Remove a screen option /*! @@ -303,14 +293,14 @@ public: nothing if the option doesn't exist on the screen. Returns true iff \c name is a known screen. */ - bool removeOption(const String& name, OptionID option); + bool removeOption(const std::string& name, OptionID option); //! Remove a screen options /*! Removes all options and values from the named screen. Returns true iff \c name is a known screen. */ - bool removeOptions(const String& name); + bool removeOptions(const std::string& name); //! Get the hot key input filter /*! @@ -328,7 +318,7 @@ public: /*! Returns true iff \c name is a valid screen name. */ - bool isValidScreenName(const String& name) const; + bool isValidScreenName(const std::string& name) const; //! Get beginning (canonical) screen name iterator const_iterator begin() const; @@ -344,20 +334,20 @@ public: /*! Returns true iff \c name names a screen. */ - virtual bool isScreen(const String& name) const; + virtual bool isScreen(const std::string& name) const; //! Test for canonical screen name /*! Returns true iff \c name is the canonical name of a screen. */ - bool isCanonicalName(const String& name) const; + bool isCanonicalName(const std::string& name) const; //! Get canonical name /*! Returns the canonical name of a screen or the empty string if the name is unknown. Returns the canonical name if one is given. */ - String getCanonicalName(const String& name) const; + std::string getCanonicalName(const std::string& name) const; //! Get neighbor /*! @@ -367,7 +357,7 @@ public: saves the position on the neighbor in \c positionOut if it's not \c NULL. */ - String getNeighbor(const String&, EDirection, + std::string getNeighbor(const std::string&, EDirection, float position, float* positionOut) const; //! Check for neighbor @@ -375,20 +365,19 @@ public: Returns \c true if the screen has a neighbor anywhere along the edge given by the direction. */ - bool hasNeighbor(const String&, EDirection) const; + bool hasNeighbor(const std::string&, EDirection) const; //! Check for neighbor /*! Returns \c true if the screen has a neighbor in the given range along the edge given by the direction. */ - bool hasNeighbor(const String&, EDirection, - float start, float end) const; + bool hasNeighbor(const std::string&, EDirection, float start, float end) const; //! Get beginning neighbor iterator - link_const_iterator beginNeighbor(const String&) const; + link_const_iterator beginNeighbor(const std::string&) const; //! Get ending neighbor iterator - link_const_iterator endNeighbor(const String&) const; + link_const_iterator endNeighbor(const std::string&) const; //! Get the server address const NetworkAddress& @@ -400,8 +389,7 @@ public: if the screen is unknown and an empty collection if there are no options. */ - const ScreenOptions* - getOptions(const String& name) const; + const ScreenOptions* getOptions(const std::string& name) const; //! Check for lock to screen action /*! @@ -446,7 +434,7 @@ public: /*! Returns an interval as a parseable string. */ - static String formatInterval(const Interval&); + static std::string formatInterval(const Interval&); //@} @@ -457,19 +445,16 @@ private: void readSectionLinks(ConfigReadContext&); void readSectionAliases(ConfigReadContext&); - InputFilter::Condition* - parseCondition(ConfigReadContext&, - const String& condition, - const std::vector& args); - void parseAction(ConfigReadContext&, - const String& action, - const std::vector& args, - InputFilter::Rule&, bool activate); - - void parseScreens(ConfigReadContext&, const String&, - std::set& screens) const; + InputFilter::Condition* parseCondition(ConfigReadContext&, const std::string& condition, + const std::vector& args); + + void parseAction(ConfigReadContext&, const std::string& action, + const std::vector& args, InputFilter::Rule&, bool activate); + + void parseScreens(ConfigReadContext&, const std::string&, std::set& screens) const; + static const char* getOptionName(OptionID); - static String getOptionValue(OptionID, OptionValue); + static std::string getOptionValue(OptionID, OptionValue); private: CellMap m_map; @@ -487,42 +472,41 @@ Maintains a context when reading a configuration from a stream. */ class ConfigReadContext { public: - typedef std::vector ArgList; + typedef std::vector ArgList; ConfigReadContext(std::istream&, SInt32 firstLine = 1); ~ConfigReadContext(); - bool readLine(String&); + bool readLine(std::string&); UInt32 getLineNumber() const; bool operator!() const; - OptionValue parseBoolean(const String&) const; - OptionValue parseInt(const String&) const; - OptionValue parseModifierKey(const String&) const; - OptionValue parseCorner(const String&) const; - OptionValue parseCorners(const String&) const; - Config::Interval - parseInterval(const ArgList& args) const; - void parseNameWithArgs( - const String& type, const String& line, - const String& delim, String::size_type& index, - String& name, ArgList& args) const; - IPlatformScreen::KeyInfo* - parseKeystroke(const String& keystroke) const; - IPlatformScreen::KeyInfo* - parseKeystroke(const String& keystroke, - const std::set& screens) const; - IPlatformScreen::ButtonInfo* - parseMouse(const String& mouse) const; - KeyModifierMask parseModifier(const String& modifiers) const; + OptionValue parseBoolean(const std::string&) const; + OptionValue parseInt(const std::string&) const; + OptionValue parseModifierKey(const std::string&) const; + OptionValue parseCorner(const std::string&) const; + OptionValue parseCorners(const std::string&) const; + + Config::Interval parseInterval(const ArgList& args) const; + + void parseNameWithArgs(const std::string& type, const std::string& line, + const std::string& delim, std::string::size_type& index, + std::string& name, ArgList& args) const; + + IPlatformScreen::KeyInfo* parseKeystroke(const std::string& keystroke) const; + IPlatformScreen::KeyInfo* parseKeystroke(const std::string& keystroke, + const std::set& screens) const; + IPlatformScreen::ButtonInfo* parseMouse(const std::string& mouse) const; + KeyModifierMask parseModifier(const std::string& modifiers) const; + std::istream& getStream() const { return m_stream; }; private: // not implemented ConfigReadContext& operator=(const ConfigReadContext&); - static String concatArgs(const ArgList& args); + static std::string concatArgs(const ArgList& args); private: std::istream& m_stream; @@ -535,15 +519,14 @@ Thrown when a configuration stream cannot be parsed. */ class XConfigRead : public XBase { public: - XConfigRead(const ConfigReadContext& context, const String&); - XConfigRead(const ConfigReadContext& context, - const char* errorFmt, const String& arg); - virtual ~XConfigRead() _NOEXCEPT; + XConfigRead(const ConfigReadContext& context, const std::string&); + XConfigRead(const ConfigReadContext& contex, const char* errorFmt, const std::string& arg); + virtual ~XConfigRead() noexcept; protected: // XBase overrides - virtual String getWhat() const throw(); + virtual std::string getWhat() const noexcept; private: - String m_error; + std::string m_error; }; diff --git a/src/lib/server/InputFilter.cpp b/src/lib/server/InputFilter.cpp index 9e73f45..38d9a84 100644 --- a/src/lib/server/InputFilter.cpp +++ b/src/lib/server/InputFilter.cpp @@ -95,8 +95,7 @@ InputFilter::KeystrokeCondition::clone() const return new KeystrokeCondition(m_events, m_key, m_mask); } -String -InputFilter::KeystrokeCondition::format() const +std::string InputFilter::KeystrokeCondition::format() const { return barrier::string::sprintf("keystroke(%s)", barrier::KeyMap::formatKey(m_key, m_mask).c_str()); @@ -183,10 +182,9 @@ InputFilter::MouseButtonCondition::clone() const return new MouseButtonCondition(m_events, m_button, m_mask); } -String -InputFilter::MouseButtonCondition::format() const +std::string InputFilter::MouseButtonCondition::format() const { - String key = barrier::KeyMap::formatKey(kKeyNone, m_mask); + std::string key = barrier::KeyMap::formatKey(kKeyNone, m_mask); if (!key.empty()) { key += "+"; } @@ -226,8 +224,8 @@ InputFilter::MouseButtonCondition::match(const Event& event) return status; } -InputFilter::ScreenConnectedCondition::ScreenConnectedCondition( - IEventQueue* events, const String& screen) : +InputFilter::ScreenConnectedCondition::ScreenConnectedCondition(IEventQueue* events, + const std::string& screen) : m_screen(screen), m_events(events) { @@ -245,8 +243,7 @@ InputFilter::ScreenConnectedCondition::clone() const return new ScreenConnectedCondition(m_events, m_screen); } -String -InputFilter::ScreenConnectedCondition::format() const +std::string InputFilter::ScreenConnectedCondition::format() const { return barrier::string::sprintf("connect(%s)", m_screen.c_str()); } @@ -298,8 +295,7 @@ InputFilter::LockCursorToScreenAction::clone() const return new LockCursorToScreenAction(*this); } -String -InputFilter::LockCursorToScreenAction::format() const +std::string InputFilter::LockCursorToScreenAction::format() const { static const char* s_mode[] = { "off", "on", "toggle" }; @@ -323,16 +319,15 @@ InputFilter::LockCursorToScreenAction::perform(const Event& event) Event::kDeliverImmediately)); } -InputFilter::SwitchToScreenAction::SwitchToScreenAction( - IEventQueue* events, const String& screen) : +InputFilter::SwitchToScreenAction::SwitchToScreenAction(IEventQueue* events, + const std::string& screen) : m_screen(screen), m_events(events) { // do nothing } -String -InputFilter::SwitchToScreenAction::getScreen() const +std::string InputFilter::SwitchToScreenAction::getScreen() const { return m_screen; } @@ -343,8 +338,7 @@ InputFilter::SwitchToScreenAction::clone() const return new SwitchToScreenAction(*this); } -String -InputFilter::SwitchToScreenAction::format() const +std::string InputFilter::SwitchToScreenAction::format() const { return barrier::string::sprintf("switchToScreen(%s)", m_screen.c_str()); } @@ -354,7 +348,7 @@ InputFilter::SwitchToScreenAction::perform(const Event& event) { // pick screen name. if m_screen is empty then use the screen from // event if it has one. - String screen = m_screen; + std::string screen = m_screen; if (screen.empty() && event.getType() == m_events->forServer().connected()) { Server::ScreenConnectedInfo* info = static_cast(event.getData()); @@ -369,6 +363,32 @@ InputFilter::SwitchToScreenAction::perform(const Event& event) Event::kDeliverImmediately)); } +InputFilter::ToggleScreenAction::ToggleScreenAction(IEventQueue* events) : + m_events(events) +{ + // do nothing +} + +InputFilter::Action* +InputFilter::ToggleScreenAction::clone() const +{ + return new ToggleScreenAction(*this); +} + +String +InputFilter::ToggleScreenAction::format() const +{ + return barrier::string::sprintf("toggleScreen"); +} + +void +InputFilter::ToggleScreenAction::perform(const Event& event) +{ + m_events->addEvent(Event(m_events->forServer().toggleScreen(), + event.getTarget(), NULL, + Event::kDeliverImmediately)); +} + InputFilter::SwitchInDirectionAction::SwitchInDirectionAction( IEventQueue* events, EDirection direction) : m_direction(direction), @@ -389,8 +409,7 @@ InputFilter::SwitchInDirectionAction::clone() const return new SwitchInDirectionAction(*this); } -String -InputFilter::SwitchInDirectionAction::format() const +std::string InputFilter::SwitchInDirectionAction::format() const { static const char* s_names[] = { "", @@ -421,10 +440,8 @@ InputFilter::KeyboardBroadcastAction::KeyboardBroadcastAction( // do nothing } -InputFilter::KeyboardBroadcastAction::KeyboardBroadcastAction( - IEventQueue* events, - Mode mode, - const std::set& screens) : +InputFilter::KeyboardBroadcastAction::KeyboardBroadcastAction(IEventQueue* events, Mode mode, + const std::set& screens) : m_mode(mode), m_screens(IKeyState::KeyInfo::join(screens)), m_events(events) @@ -438,10 +455,9 @@ InputFilter::KeyboardBroadcastAction::getMode() const return m_mode; } -std::set -InputFilter::KeyboardBroadcastAction::getScreens() const +std::set InputFilter::KeyboardBroadcastAction::getScreens() const { - std::set screens; + std::set screens; IKeyState::KeyInfo::split(m_screens.c_str(), screens); return screens; } @@ -452,8 +468,7 @@ InputFilter::KeyboardBroadcastAction::clone() const return new KeyboardBroadcastAction(*this); } -String -InputFilter::KeyboardBroadcastAction::format() const +std::string InputFilter::KeyboardBroadcastAction::format() const { static const char* s_mode[] = { "off", "on", "toggle" }; static const char* s_name = "keyboardBroadcast"; @@ -525,8 +540,7 @@ InputFilter::KeystrokeAction::clone() const return new KeystrokeAction(m_events, info, m_press); } -String -InputFilter::KeystrokeAction::format() const +std::string InputFilter::KeystrokeAction::format() const { const char* type = formatName(); @@ -607,12 +621,11 @@ InputFilter::MouseButtonAction::clone() const return new MouseButtonAction(m_events, info, m_press); } -String -InputFilter::MouseButtonAction::format() const +std::string InputFilter::MouseButtonAction::format() const { const char* type = formatName(); - String key = barrier::KeyMap::formatKey(kKeyNone, m_buttonInfo->m_mask); + std::string key = barrier::KeyMap::formatKey(kKeyNone, m_buttonInfo->m_mask); return barrier::string::sprintf("%s(%s%s%d)", type, key.c_str(), key.empty() ? "" : "+", m_buttonInfo->m_button); @@ -820,10 +833,9 @@ InputFilter::Rule::handleEvent(const Event& event) return true; } -String -InputFilter::Rule::format() const +std::string InputFilter::Rule::format() const { - String s; + std::string s; if (m_condition != NULL) { // condition s += m_condition->format(); @@ -1019,10 +1031,9 @@ InputFilter::setPrimaryClient(PrimaryClient* client) } } -String -InputFilter::format(const String& linePrefix) const +std::string InputFilter::format(const std::string& linePrefix) const { - String s; + std::string s; for (RuleList::const_iterator i = m_ruleList.begin(); i != m_ruleList.end(); ++i) { s += linePrefix; @@ -1048,7 +1059,7 @@ InputFilter::operator==(const InputFilter& x) const // compare rule lists. the easiest way to do that is to format each // rule into a string, sort the strings, then compare the results. - std::vector aList, bList; + std::vector aList, bList; for (RuleList::const_iterator i = m_ruleList.begin(); i != m_ruleList.end(); ++i) { aList.push_back(i->format()); diff --git a/src/lib/server/InputFilter.h b/src/lib/server/InputFilter.h index 73afe97..0cb99da 100644 --- a/src/lib/server/InputFilter.h +++ b/src/lib/server/InputFilter.h @@ -22,7 +22,6 @@ #include "barrier/mouse_types.h" #include "barrier/protocol_types.h" #include "barrier/IPlatformScreen.h" -#include "base/String.h" #include "common/stdmap.h" #include "common/stdset.h" @@ -47,7 +46,7 @@ public: virtual ~Condition(); virtual Condition* clone() const = 0; - virtual String format() const = 0; + virtual std::string format() const = 0; virtual EFilterStatus match(const Event&) = 0; @@ -67,7 +66,7 @@ public: // Condition overrides virtual Condition* clone() const; - virtual String format() const; + virtual std::string format() const; virtual EFilterStatus match(const Event&); virtual void enablePrimary(PrimaryClient*); virtual void disablePrimary(PrimaryClient*); @@ -91,7 +90,7 @@ public: // Condition overrides virtual Condition* clone() const; - virtual String format() const; + virtual std::string format() const; virtual EFilterStatus match(const Event&); private: @@ -103,16 +102,16 @@ public: // ScreenConnectedCondition class ScreenConnectedCondition : public Condition { public: - ScreenConnectedCondition(IEventQueue* events, const String& screen); + ScreenConnectedCondition(IEventQueue* events, const std::string& screen); virtual ~ScreenConnectedCondition(); // Condition overrides virtual Condition* clone() const; - virtual String format() const; + virtual std::string format() const; virtual EFilterStatus match(const Event&); private: - String m_screen; + std::string m_screen; IEventQueue* m_events; }; @@ -126,7 +125,7 @@ public: virtual ~Action(); virtual Action* clone() const = 0; - virtual String format() const = 0; + virtual std::string format() const = 0; virtual void perform(const Event&) = 0; }; @@ -142,7 +141,7 @@ public: // Action overrides virtual Action* clone() const; - virtual String format() const; + virtual std::string format() const; virtual void perform(const Event&); private: @@ -153,20 +152,34 @@ public: // SwitchToScreenAction class SwitchToScreenAction : public Action { public: - SwitchToScreenAction(IEventQueue* events, const String& screen); + SwitchToScreenAction(IEventQueue* events, const std::string& screen); - String getScreen() const; + std::string getScreen() const; // Action overrides virtual Action* clone() const; - virtual String format() const; + virtual std::string format() const; virtual void perform(const Event&); private: - String m_screen; + std::string m_screen; IEventQueue* m_events; }; + // ToggleScreenAction + class ToggleScreenAction : public Action { + public: + ToggleScreenAction(IEventQueue* events); + + // Action overrides + virtual Action* clone() const; + virtual String format() const; + virtual void perform(const Event&); + + private: + IEventQueue* m_events; + }; + // SwitchInDirectionAction class SwitchInDirectionAction : public Action { public: @@ -176,7 +189,7 @@ public: // Action overrides virtual Action* clone() const; - virtual String format() const; + virtual std::string format() const; virtual void perform(const Event&); private: @@ -190,19 +203,19 @@ public: enum Mode { kOff, kOn, kToggle }; KeyboardBroadcastAction(IEventQueue* events, Mode = kToggle); - KeyboardBroadcastAction(IEventQueue* events, Mode, const std::set& screens); + KeyboardBroadcastAction(IEventQueue* events, Mode, const std::set& screens); Mode getMode() const; - std::set getScreens() const; + std::set getScreens() const; // Action overrides virtual Action* clone() const; - virtual String format() const; + virtual std::string format() const; virtual void perform(const Event&); private: Mode m_mode; - String m_screens; + std::string m_screens; IEventQueue* m_events; }; @@ -219,7 +232,7 @@ public: // Action overrides virtual Action* clone() const; - virtual String format() const; + virtual std::string format() const; virtual void perform(const Event&); protected: @@ -245,7 +258,7 @@ public: // Action overrides virtual Action* clone() const; - virtual String format() const; + virtual std::string format() const; virtual void perform(const Event&); protected: @@ -287,7 +300,7 @@ public: bool handleEvent(const Event&); // convert rule to a string - String format() const; + std::string format() const; // get the rule's condition const Condition* @@ -340,7 +353,7 @@ public: virtual void setPrimaryClient(PrimaryClient* client); // convert rules to a string - String format(const String& linePrefix) const; + std::string format(const std::string& linePrefix) const; // get number of rules UInt32 getNumRules() const; diff --git a/src/lib/server/PrimaryClient.cpp b/src/lib/server/PrimaryClient.cpp index 4c9fe50..04ae86c 100644 --- a/src/lib/server/PrimaryClient.cpp +++ b/src/lib/server/PrimaryClient.cpp @@ -26,7 +26,7 @@ // PrimaryClient // -PrimaryClient::PrimaryClient(const String& name, barrier::Screen* screen) : +PrimaryClient::PrimaryClient(const std::string& name, barrier::Screen* screen) : BaseClientProxy(name), m_screen(screen), m_fakeInputCount(0) diff --git a/src/lib/server/PrimaryClient.h b/src/lib/server/PrimaryClient.h index 4296aaa..68b91e3 100644 --- a/src/lib/server/PrimaryClient.h +++ b/src/lib/server/PrimaryClient.h @@ -34,7 +34,7 @@ public: /*! \c name is the name of the server and \p screen is primary screen. */ - PrimaryClient(const String& name, barrier::Screen* screen); + PrimaryClient(const std::string& name, barrier::Screen* screen); ~PrimaryClient(); #ifdef TEST_ENV diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 12aedd0..334049c 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -43,14 +43,13 @@ #include "base/IEventQueue.h" #include "base/Log.h" #include "base/TMethodEventJob.h" -#include "common/stdexcept.h" #include #include #include #include #include - +#include // // Server // @@ -101,7 +100,7 @@ Server::Server( assert(config.isScreen(primaryClient->getName())); assert(m_screen != NULL); - String primaryName = getName(primaryClient); + std::string primaryName = getName(primaryClient); // clear clipboards for (ClipboardID id = 0; id < kClipboardEnd; ++id) { @@ -163,6 +162,10 @@ Server::Server( m_inputFilter, new TMethodEventJob(this, &Server::handleSwitchToScreenEvent)); + m_events->adoptHandler(m_events->forServer().toggleScreen(), + m_inputFilter, + new TMethodEventJob(this, + &Server::handleToggleScreenEvent)); m_events->adoptHandler(m_events->forServer().switchInDirection(), m_inputFilter, new TMethodEventJob(this, @@ -370,7 +373,7 @@ Server::getNumClients() const } void -Server::getClients(std::vector& list) const +Server::getClients(std::vector& list) const { list.clear(); for (ClientList::const_iterator index = m_clients.begin(); @@ -379,10 +382,9 @@ Server::getClients(std::vector& list) const } } -String -Server::getName(const BaseClientProxy* client) const +std::string Server::getName(const BaseClientProxy* client) const { - String name = m_config->getCanonicalName(client->getName()); + std::string name = m_config->getCanonicalName(client->getName()); if (name.empty()) { name = client->getName(); } @@ -600,7 +602,7 @@ Server::getNeighbor(BaseClientProxy* src, assert(src != NULL); // get source screen name - String srcName = getName(src); + std::string srcName = getName(src); assert(!srcName.empty()); LOG((CLOG_DEBUG2 "find neighbor on %s of \"%s\"", Config::dirName(dir), srcName.c_str())); @@ -610,7 +612,7 @@ Server::getNeighbor(BaseClientProxy* src, // search for the closest neighbor that exists in direction dir float tTmp; for (;;) { - String dstName(m_config->getNeighbor(srcName, dir, t, &tTmp)); + std::string dstName(m_config->getNeighbor(srcName, dir, t, &tTmp)); // if nothing in that direction then return NULL. if the // destination is the source then we can make no more @@ -755,7 +757,7 @@ Server::avoidJumpZone(BaseClientProxy* dst, return; } - const String dstName(getName(dst)); + const std::string dstName(getName(dst)); SInt32 dx, dy, dw, dh; dst->getShape(dx, dy, dw, dh); float t = mapToFraction(dst, dir, x, y); @@ -1407,6 +1409,24 @@ Server::handleSwitchToScreenEvent(const Event& event, void*) } } +void +Server::handleToggleScreenEvent(const Event& event, void*) +{ + std::string current = getName(m_active); + ClientList::const_iterator index = m_clients.find(current); + if (index == m_clients.end()) { + LOG((CLOG_DEBUG1 "screen \"%s\" not active", current.c_str())); + } + else { + ++index; + if (index == m_clients.end()) { + index = m_clients.begin(); + } + jumpToScreen(index->second); + } +} + + void Server::handleSwitchInDirectionEvent(const Event& event, void*) { @@ -1533,7 +1553,7 @@ Server::onClipboardChanged(BaseClientProxy* sender, sender->getClipboard(id, &clipboard.m_clipboard); // ignore if data hasn't changed - String data = clipboard.m_clipboard.marshall(); + std::string data = clipboard.m_clipboard.marshall(); if (data == clipboard.m_clipboardData) { LOG((CLOG_DEBUG "ignored screen \"%s\" update of clipboard %d (unchanged)", clipboard.m_clipboardOwner.c_str(), id)); return; @@ -1703,7 +1723,7 @@ Server::onMouseUp(ButtonID id) if (m_args.m_enableDragDrop) { if (!m_screen->isOnScreen()) { - String& file = m_screen->getDraggingFilename(); + std::string& file = m_screen->getDraggingFilename(); if (!file.empty()) { sendFileToClient(file.c_str()); } @@ -1829,7 +1849,7 @@ Server::sendDragInfoThread(void* arg) BaseClientProxy* newScreen = static_cast(arg); m_dragFileList.clear(); - String& dragFileList = m_screen->getDraggingFilename(); + std::string& dragFileList = m_screen->getDraggingFilename(); if (!dragFileList.empty()) { DragInformation di; di.setFilename(dragFileList); @@ -1856,7 +1876,7 @@ Server::sendDragInfoThread(void* arg) void Server::sendDragInfo(BaseClientProxy* newScreen) { - String infoString; + std::string infoString; UInt32 fileCount = DragInformation::setupDragInfo(m_dragFileList, infoString); if (fileCount > 0) { @@ -2089,7 +2109,7 @@ Server::writeToDropDirThread(void*) bool Server::addClient(BaseClientProxy* client) { - String name = getName(client); + std::string name = getName(client); if (m_clients.count(name) != 0) { return false; } @@ -2313,7 +2333,7 @@ Server::LockCursorToScreenInfo::alloc(State state) // Server::SwitchToScreenInfo* -Server::SwitchToScreenInfo::alloc(const String& screen) +Server::SwitchToScreenInfo::alloc(const std::string& screen) { SwitchToScreenInfo* info = (SwitchToScreenInfo*)malloc(sizeof(SwitchToScreenInfo) + @@ -2351,7 +2371,7 @@ Server::KeyboardBroadcastInfo::alloc(State state) } Server::KeyboardBroadcastInfo* -Server::KeyboardBroadcastInfo::alloc(State state, const String& screens) +Server::KeyboardBroadcastInfo::alloc(State state, const std::string& screens) { KeyboardBroadcastInfo* info = (KeyboardBroadcastInfo*)malloc(sizeof(KeyboardBroadcastInfo) + @@ -2396,7 +2416,7 @@ Server::sendFileThread(void* data) } void -Server::dragInfoReceived(UInt32 fileNum, String content) +Server::dragInfoReceived(UInt32 fileNum, std::string content) { if (!m_args.m_enableDragDrop) { LOG((CLOG_DEBUG "drag drop not enabled, ignoring drag info.")); diff --git a/src/lib/server/Server.h b/src/lib/server/Server.h index 609af21..bfd0a7d 100644 --- a/src/lib/server/Server.h +++ b/src/lib/server/Server.h @@ -62,7 +62,7 @@ public: //! Switch to screen data class SwitchToScreenInfo { public: - static SwitchToScreenInfo* alloc(const String& screen); + static SwitchToScreenInfo* alloc(const std::string& screen); public: // this is a C-string; this type is a variable size structure @@ -81,10 +81,10 @@ public: //! Screen connected data class ScreenConnectedInfo { public: - ScreenConnectedInfo(String screen) : m_screen(screen) { } + ScreenConnectedInfo(std::string screen) : m_screen(screen) { } public: - String m_screen; // was char[1] + std::string m_screen; }; //! Keyboard broadcast data @@ -94,7 +94,7 @@ public: static KeyboardBroadcastInfo* alloc(State state = kToggle); static KeyboardBroadcastInfo* alloc(State state, - const String& screens); + const std::string& screens); public: State m_state; @@ -146,7 +146,7 @@ public: void sendFileToClient(const char* filename); //! Received dragging information from client - void dragInfoReceived(UInt32 fileNum, String content); + void dragInfoReceived(UInt32 fileNum, std::string content); //! Store ClientListener pointer void setListener(ClientListener* p) { m_clientListener = p; } @@ -165,7 +165,7 @@ public: /*! Set the \c list to the names of the currently connected clients. */ - void getClients(std::vector& list) const; + void getClients(std::vector& list) const; //! Return true if recieved file size is valid bool isReceivedFileSizeValid(); @@ -174,7 +174,7 @@ public: size_t& getExpectedFileSize() { return m_expectedFileSize; } //! Return received file data - String& getReceivedFileData() { return m_receivedFileData; } + std::string& getReceivedFileData() { return m_receivedFileData; } //! Return fake drag file list DragFileList getFakeDragFileList() { return m_fakeDragFileList; } @@ -183,7 +183,7 @@ public: private: // get canonical name of client - String getName(const BaseClientProxy*) const; + std::string getName(const BaseClientProxy*) const; // get the sides of the primary screen that have neighbors UInt32 getActivePrimarySides() const; @@ -308,6 +308,7 @@ private: void handleClientDisconnected(const Event&, void*); void handleClientCloseTimeout(const Event&, void*); void handleSwitchToScreenEvent(const Event&, void*); + void handleToggleScreenEvent(const Event&, void*); void handleSwitchInDirectionEvent(const Event&, void*); void handleKeyboardBroadcastEvent(const Event&,void*); void handleLockCursorToScreenEvent(const Event&, void*); @@ -378,8 +379,8 @@ private: public: Clipboard m_clipboard; - String m_clipboardData; - String m_clipboardOwner; + std::string m_clipboardData; + std::string m_clipboardOwner; UInt32 m_clipboardSeqNum; }; @@ -387,7 +388,7 @@ private: PrimaryClient* m_primaryClient; // all clients (including the primary client) indexed by name - typedef std::map ClientList; + typedef std::map ClientList; typedef std::set ClientSet; ClientList m_clients; ClientSet m_clientSet; @@ -454,7 +455,7 @@ private: // flag whether or not we have broadcasting enabled and the screens to // which we should send broadcasted keys. bool m_keyboardBroadcasting; - String m_keyboardBroadcastingScreens; + std::string m_keyboardBroadcastingScreens; // screen locking (former scroll lock) bool m_lockedToScreen; @@ -466,12 +467,12 @@ private: // file transfer size_t m_expectedFileSize; - String m_receivedFileData; + std::string m_receivedFileData; DragFileList m_dragFileList; DragFileList m_fakeDragFileList; Thread* m_sendFileThread; Thread* m_writeToDropDirThread; - String m_dragFileExt; + std::string m_dragFileExt; bool m_ignoreFileTransfer; bool m_enableClipboard; diff --git a/src/test/global/TestEventQueue.cpp b/src/test/global/TestEventQueue.cpp index d202922..4dd01e7 100644 --- a/src/test/global/TestEventQueue.cpp +++ b/src/test/global/TestEventQueue.cpp @@ -20,7 +20,7 @@ #include "base/Log.h" #include "base/TMethodEventJob.h" #include "base/SimpleEventQueueBuffer.h" -#include "common/stdexcept.h" +#include void TestEventQueue::raiseQuitEvent() diff --git a/src/test/global/TestEventQueue.h b/src/test/global/TestEventQueue.h index a6cf0ca..b932508 100644 --- a/src/test/global/TestEventQueue.h +++ b/src/test/global/TestEventQueue.h @@ -19,7 +19,7 @@ #include "base/EventQueue.h" -class EventQueueTimer; +class EventQueueTimer {}; class TestEventQueue : public EventQueue { public: diff --git a/src/test/integtests/CMakeLists.txt b/src/test/integtests/CMakeLists.txt index a412ecc..0460d8d 100644 --- a/src/test/integtests/CMakeLists.txt +++ b/src/test/integtests/CMakeLists.txt @@ -14,24 +14,37 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -file(GLOB_RECURSE headers "*.h") -file(GLOB_RECURSE sources "*.cpp") - -# remove platform files (specific platform added later). -file(GLOB_RECURSE remove_platform "platform/*") -list(REMOVE_ITEM headers ${remove_platform}) -list(REMOVE_ITEM sources ${remove_platform}) +set(headers +) +set(sources + arch/ArchInternetTests.cpp + ipc/IpcTests.cpp + net/NetworkTests.cpp + Main.cpp +) # platform if (WIN32) - file(GLOB platform_sources "platform/MSWindows*.cpp") - file(GLOB platform_headers "platform/MSWindows*.h") + set(platform_sources + platform/MSWindowsClipboardTests.cpp + platform/MSWindowsKeyStateTests.cpp + ) + set(platform_headers) elseif (APPLE) - file(GLOB platform_sources "platform/OSX*.cpp") - file(GLOB platform_headers "platform/OSX*.h") + set(platform_sources + platform/OSXClipboardTests.cpp + platform/OSXKeyStateTests.cpp + platform/OSXScreenTests.cpp + ) + set(platform_headers) elseif (UNIX) - file(GLOB platform_sources "platform/XWindows*.cpp") - file(GLOB platform_headers "platform/XWindows*.h") + set(platform_sources + platform/XWindowsClipboardTests.cpp + platform/XWindowsKeyStateTests.cpp + platform/XWindowsScreenSaverTests.cpp + platform/XWindowsScreenTests.cpp + ) + set(platform_headers) endif() list(APPEND sources ${platform_sources}) @@ -55,7 +68,6 @@ endif() include_directories( ../../ - ../../lib/ ../../../ext/gtest/include ../../../ext/gmock/include ) @@ -68,4 +80,4 @@ endif() add_executable(integtests ${sources}) target_link_libraries(integtests - arch base client common io ipc mt net platform server barrier gtest gmock ${libs} ${OPENSSL_LIBS}) + arch base client common io ipc mt net platform server synlib gtest gmock ${libs} ${OPENSSL_LIBS}) diff --git a/src/test/integtests/arch/ArchInternetTests.cpp b/src/test/integtests/arch/ArchInternetTests.cpp index 722df2f..a384c64 100644 --- a/src/test/integtests/arch/ArchInternetTests.cpp +++ b/src/test/integtests/arch/ArchInternetTests.cpp @@ -22,16 +22,16 @@ #define TEST_URL "https://symless.com/tests/?testString" //#define TEST_URL "http://localhost/barrier/tests/?testString" -TEST(ArchInternetTests, get) +TEST(ArchInternetTests, DISABLED_get) { ARCH_INTERNET internet; - String result = internet.get(TEST_URL); + std::string result = internet.get(TEST_URL); ASSERT_EQ("Hello world!", result); } TEST(ArchInternetTests, urlEncode) { ARCH_INTERNET internet; - String result = internet.urlEncode("hello=+&world"); + std::string result = internet.urlEncode("hello=+&world"); ASSERT_EQ("hello%3D%2B%26world", result); } diff --git a/src/test/integtests/net/NetworkTests.cpp b/src/test/integtests/net/NetworkTests.cpp index 4a9a9f0..d404abc 100644 --- a/src/test/integtests/net/NetworkTests.cpp +++ b/src/test/integtests/net/NetworkTests.cpp @@ -38,7 +38,7 @@ #include "base/TMethodEventJob.h" #include "base/TMethodJob.h" #include "base/Log.h" -#include "common/stdexcept.h" +#include #include "test/global/gtest.h" #include diff --git a/src/test/integtests/platform/MSWindowsKeyStateTests.cpp b/src/test/integtests/platform/MSWindowsKeyStateTests.cpp index f3f9e32..9373d14 100644 --- a/src/test/integtests/platform/MSWindowsKeyStateTests.cpp +++ b/src/test/integtests/platform/MSWindowsKeyStateTests.cpp @@ -40,7 +40,6 @@ class MSWindowsKeyStateTests : public ::testing::Test protected: virtual void SetUp() { - m_hook.loadLibrary(); m_screensaver = new MSWindowsScreenSaver(); } diff --git a/src/test/integtests/platform/XWindowsKeyStateTests.cpp b/src/test/integtests/platform/XWindowsKeyStateTests.cpp index ea8ce44..9f6716d 100644 --- a/src/test/integtests/platform/XWindowsKeyStateTests.cpp +++ b/src/test/integtests/platform/XWindowsKeyStateTests.cpp @@ -76,8 +76,7 @@ TEST_F(XWindowsKeyStateTests, setActiveGroup_pollAndSet_groupIsZero) { MockKeyMap keyMap; MockEventQueue eventQueue; - XWindowsKeyState keyState( - m_display, true, &eventQueue, keyMap); + XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap); keyState.setActiveGroup(XWindowsKeyState::kGroupPollAndSet); @@ -88,8 +87,7 @@ TEST_F(XWindowsKeyStateTests, setActiveGroup_poll_groupIsNotSet) { MockKeyMap keyMap; MockEventQueue eventQueue; - XWindowsKeyState keyState( - m_display, true, &eventQueue, keyMap); + XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap); keyState.setActiveGroup(XWindowsKeyState::kGroupPoll); @@ -100,8 +98,7 @@ TEST_F(XWindowsKeyStateTests, setActiveGroup_customGroup_groupWasSet) { MockKeyMap keyMap; MockEventQueue eventQueue; - XWindowsKeyState keyState( - m_display, true, &eventQueue, keyMap); + XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap); keyState.setActiveGroup(1); @@ -112,8 +109,7 @@ TEST_F(XWindowsKeyStateTests, mapModifiersFromX_zeroState_zeroMask) { MockKeyMap keyMap; MockEventQueue eventQueue; - XWindowsKeyState keyState( - m_display, true, &eventQueue, keyMap); + XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap); int mask = keyState.mapModifiersFromX(0); @@ -124,8 +120,7 @@ TEST_F(XWindowsKeyStateTests, mapModifiersToX_zeroMask_resultIsTrue) { MockKeyMap keyMap; MockEventQueue eventQueue; - XWindowsKeyState keyState( - m_display, true, &eventQueue, keyMap); + XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap); unsigned int modifiers = 0; bool result = keyState.mapModifiersToX(0, modifiers); @@ -137,8 +132,7 @@ TEST_F(XWindowsKeyStateTests, fakeCtrlAltDel_default_returnsFalse) { MockKeyMap keyMap; MockEventQueue eventQueue; - XWindowsKeyState keyState( - m_display, true, &eventQueue, keyMap); + XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap); bool result = keyState.fakeCtrlAltDel(); @@ -149,21 +143,18 @@ TEST_F(XWindowsKeyStateTests, pollActiveModifiers_defaultState_returnsZero) { MockKeyMap keyMap; MockEventQueue eventQueue; - XWindowsKeyState keyState( - m_display, true, &eventQueue, keyMap); + XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap); KeyModifierMask actual = keyState.pollActiveModifiers(); ASSERT_EQ(0, actual); } -#if 0 // TODO: fix, causes sigsegv TEST_F(XWindowsKeyStateTests, pollActiveModifiers_shiftKeyDownThenUp_masksAreCorrect) { MockKeyMap keyMap; MockEventQueue eventQueue; - XWindowsKeyState keyState( - m_display, true, &eventQueue, keyMap); + XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap); // set mock modifier mapping std::fill(keyState.modifierFromX().begin(), keyState.modifierFromX().end(), 0); @@ -189,14 +180,12 @@ TEST_F(XWindowsKeyStateTests, pollActiveModifiers_shiftKeyDownThenUp_masksAreCor EXPECT_TRUE((modUp & KeyModifierShift) == 0) << "shift key still in mask - make sure no keys are being held down"; } -#endif TEST_F(XWindowsKeyStateTests, pollActiveGroup_defaultState_returnsZero) { MockKeyMap keyMap; MockEventQueue eventQueue; - XWindowsKeyState keyState( - m_display, true, &eventQueue, keyMap); + XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap); SInt32 actual = keyState.pollActiveGroup(); @@ -207,8 +196,7 @@ TEST_F(XWindowsKeyStateTests, pollActiveGroup_positiveGroup_returnsGroup) { MockKeyMap keyMap; MockEventQueue eventQueue; - XWindowsKeyState keyState( - m_display, true, &eventQueue, keyMap); + XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap); keyState.group(3); @@ -222,8 +210,7 @@ TEST_F(XWindowsKeyStateTests, pollActiveGroup_xkb_areEqual) #if HAVE_XKB_EXTENSION MockKeyMap keyMap; MockEventQueue eventQueue; - XWindowsKeyState keyState( - m_display, true, &eventQueue, keyMap); + XWindowsKeyState keyState(new XWindowsImpl(), m_display, true, &eventQueue, keyMap); // reset the group keyState.group(-1); diff --git a/src/test/integtests/platform/XWindowsScreenTests.cpp b/src/test/integtests/platform/XWindowsScreenTests.cpp index b74599c..d8f75e1 100644 --- a/src/test/integtests/platform/XWindowsScreenTests.cpp +++ b/src/test/integtests/platform/XWindowsScreenTests.cpp @@ -29,12 +29,11 @@ TEST(CXWindowsScreenTests, fakeMouseMove_nonPrimary_getCursorPosValuesCorrect) EXPECT_CALL(eventQueue, adoptHandler(_, _, _)).Times(2); EXPECT_CALL(eventQueue, adoptBuffer(_)).Times(2); EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(2); - XWindowsScreen screen( - ":0.0", false, false, 0, &eventQueue); + XWindowsScreen screen(new XWindowsImpl(), ":0.0", false, false, 0, &eventQueue); screen.fakeMouseMove(10, 20); - int x, y; + SInt32 x, y; screen.getCursorPos(x, y); ASSERT_EQ(10, x); ASSERT_EQ(20, y); diff --git a/src/test/mock/barrier/MockEventQueue.h b/src/test/mock/barrier/MockEventQueue.h index f273736..735b9fc 100644 --- a/src/test/mock/barrier/MockEventQueue.h +++ b/src/test/mock/barrier/MockEventQueue.h @@ -41,7 +41,7 @@ public: MOCK_METHOD1(dispatchEvent, bool(const Event&)); MOCK_CONST_METHOD2(getHandler, IEventJob*(Event::Type, void*)); MOCK_METHOD1(deleteTimer, void(EventQueueTimer*)); - MOCK_CONST_METHOD1(getRegisteredType, Event::Type(const String&)); + MOCK_CONST_METHOD1(getRegisteredType, Event::Type(const std::string&)); MOCK_METHOD0(getSystemTarget, void*()); MOCK_METHOD0(forClient, ClientEvents&()); MOCK_METHOD0(forIStream, IStreamEvents&()); diff --git a/src/test/unittests/CMakeLists.txt b/src/test/unittests/CMakeLists.txt index 3d21a2b..c46375c 100644 --- a/src/test/unittests/CMakeLists.txt +++ b/src/test/unittests/CMakeLists.txt @@ -50,7 +50,6 @@ list(APPEND headers ${platform_sources}) include_directories( ../../ - ../../lib/ ../../../ext/gtest/include ../../../ext/gmock/include ../../../ext @@ -68,4 +67,4 @@ endif() add_executable(unittests ${sources}) target_link_libraries(unittests - arch base client server common io net platform server barrier mt ipc gtest gmock ${libs} ${OPENSSL_LIBS}) + arch base client server common io net platform server synlib mt ipc gtest gmock ${libs} ${OPENSSL_LIBS}) diff --git a/src/test/unittests/barrier/ClipboardChunkTests.cpp b/src/test/unittests/barrier/ClipboardChunkTests.cpp index 9dc4a5e..e0e37be 100644 --- a/src/test/unittests/barrier/ClipboardChunkTests.cpp +++ b/src/test/unittests/barrier/ClipboardChunkTests.cpp @@ -22,7 +22,6 @@ TEST(ClipboardChunkTests, start_formatStartChunk) { -<<<<<<< HEAD ClipboardID id = 0; UInt32 sequence = 0; String mockDataSize("10"); @@ -34,28 +33,12 @@ TEST(ClipboardChunkTests, start_formatStartChunk) EXPECT_EQ('1', chunk->m_chunk[6]); EXPECT_EQ('0', chunk->m_chunk[7]); EXPECT_EQ('\0', chunk->m_chunk[8]); -======= - ClipboardID id = 0; - UInt32 sequence = 0; - String mockDataSize("10"); - ClipboardChunk* chunk = ClipboardChunk::start(id, sequence, mockDataSize); - UInt32 temp_m_chunk; - memcpy(&temp_m_chunk, &(chunk->m_chunk[1]), 4); - - EXPECT_EQ(id, chunk->m_chunk[0]); - EXPECT_EQ(sequence, temp_m_chunk); - EXPECT_EQ(kDataStart, chunk->m_chunk[5]); - EXPECT_EQ('1', chunk->m_chunk[6]); - EXPECT_EQ('0', chunk->m_chunk[7]); - EXPECT_EQ('\0', chunk->m_chunk[8]); ->>>>>>> master delete chunk; } TEST(ClipboardChunkTests, data_formatDataChunk) { -<<<<<<< HEAD ClipboardID id = 0; UInt32 sequence = 1; String mockData("mock data"); @@ -74,35 +57,12 @@ TEST(ClipboardChunkTests, data_formatDataChunk) EXPECT_EQ('t', chunk->m_chunk[13]); EXPECT_EQ('a', chunk->m_chunk[14]); EXPECT_EQ('\0', chunk->m_chunk[15]); -======= - ClipboardID id = 0; - UInt32 sequence = 1; - String mockData("mock data"); - ClipboardChunk* chunk = ClipboardChunk::data(id, sequence, mockData); - UInt32 temp_m_chunk; - memcpy(&temp_m_chunk, &(chunk->m_chunk[1]), 4); - - EXPECT_EQ(id, chunk->m_chunk[0]); - EXPECT_EQ(sequence, temp_m_chunk); - EXPECT_EQ(kDataChunk, chunk->m_chunk[5]); - EXPECT_EQ('m', chunk->m_chunk[6]); - EXPECT_EQ('o', chunk->m_chunk[7]); - EXPECT_EQ('c', chunk->m_chunk[8]); - EXPECT_EQ('k', chunk->m_chunk[9]); - EXPECT_EQ(' ', chunk->m_chunk[10]); - EXPECT_EQ('d', chunk->m_chunk[11]); - EXPECT_EQ('a', chunk->m_chunk[12]); - EXPECT_EQ('t', chunk->m_chunk[13]); - EXPECT_EQ('a', chunk->m_chunk[14]); - EXPECT_EQ('\0', chunk->m_chunk[15]); ->>>>>>> master delete chunk; } TEST(ClipboardChunkTests, end_formatDataChunk) { -<<<<<<< HEAD ClipboardID id = 1; UInt32 sequence = 1; ClipboardChunk* chunk = ClipboardChunk::end(id, sequence); @@ -111,18 +71,6 @@ TEST(ClipboardChunkTests, end_formatDataChunk) EXPECT_EQ(sequence, (UInt32)chunk->m_chunk[1]); EXPECT_EQ(kDataEnd, chunk->m_chunk[5]); EXPECT_EQ('\0', chunk->m_chunk[6]); -======= - ClipboardID id = 1; - UInt32 sequence = 1; - ClipboardChunk* chunk = ClipboardChunk::end(id, sequence); - UInt32 temp_m_chunk; - memcpy(&temp_m_chunk, &(chunk->m_chunk[1]), 4); - - EXPECT_EQ(id, chunk->m_chunk[0]); - EXPECT_EQ(sequence, temp_m_chunk); - EXPECT_EQ(kDataEnd, chunk->m_chunk[5]); - EXPECT_EQ('\0', chunk->m_chunk[6]); ->>>>>>> master delete chunk; } -- cgit v1.2.3