From ed05dc2b2e6ecd57f723b914481b74317fa187bc Mon Sep 17 00:00:00 2001 From: walker0643 <> Date: Sun, 11 Mar 2018 12:29:48 -0400 Subject: [PATCH 1/8] set file extension in Save dialog for configuration files --- src/gui/src/MainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index ff9725c0..b92e5f7c 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -980,7 +980,7 @@ bool MainWindow::on_m_pButtonBrowseConfigFile_clicked() bool MainWindow::on_m_pActionSave_triggered() { - QString fileName = QFileDialog::getSaveFileName(this, tr("Save configuration as...")); + QString fileName = QFileDialog::getSaveFileName(this, tr("Save configuration as..."), QString(), tr("Barrier Configuration (*.sgc)")); if (!fileName.isEmpty() && !serverConfig().save(fileName)) { From b9a59c014fdefdec25fc18802d891905e6cb89fd Mon Sep 17 00:00:00 2001 From: walker0643 <> Date: Sun, 11 Mar 2018 12:48:59 -0400 Subject: [PATCH 2/8] don't build barrierd for non-windows platforms; removed some synergy-related legacy checks --- CMakeLists.txt | 9 ++++----- dist/wix/Product.wxs | 6 ------ src/CMakeLists.txt | 7 ++++--- src/cmd/CMakeLists.txt | 4 ++-- src/gui/CMakeLists.txt | 12 ++++++------ src/lib/arch/win32/ArchDaemonWindows.cpp | 10 +--------- src/lib/arch/win32/ArchDaemonWindows.h | 3 --- 7 files changed, 17 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27dccc96..c81584d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,9 +18,8 @@ cmake_minimum_required (VERSION 3.4) project (barrier C CXX) -option (BARRIER_BUILD_LEGACY_GUI "Build the legacy GUI" ON) -option (BARRIER_BUILD_LEGACY_SERVICE "Build the legacy service (barrierd)" ON) -option (BARRIER_BUILD_LEGACY_INSTALLER "Build the legacy installer" ON) +option (BARRIER_BUILD_GUI "Build the GUI" ON) +option (BARRIER_BUILD_INSTALLER "Build the installer" ON) set (CMAKE_CXX_STANDARD 14) set (CMAKE_CXX_EXTENSIONS OFF) @@ -355,7 +354,7 @@ macro (configure_files srcDir destDir) endforeach (templateFile) endmacro (configure_files) -if (${BARRIER_BUILD_LEGACY_INSTALLER}) +if (${BARRIER_BUILD_INSTALLER}) # # macOS app Bundle # @@ -393,6 +392,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") endif() else() - message (STATUS "NOT configuring the v1 installer") + message (STATUS "NOT configuring the installer") endif() add_subdirectory (src) diff --git a/dist/wix/Product.wxs b/dist/wix/Product.wxs index e2af4b08..5cb924ec 100644 --- a/dist/wix/Product.wxs +++ b/dist/wix/Product.wxs @@ -31,12 +31,6 @@ - - - - - - NOT LEGACY_UNINSTALL_EXISTS diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 911fef3c..3a8e83eb 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) -if (BARRIER_BUILD_LEGACY_GUI) -add_subdirectory(gui) -endif (BARRIER_BUILD_LEGACY_GUI) + +if (BARRIER_BUILD_GUI) + add_subdirectory(gui) +endif() diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index 0c6d1a92..0fdfe339 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -18,7 +18,7 @@ add_subdirectory(barrierc) add_subdirectory(barriers) add_subdirectory(syntool) -if (BARRIER_BUILD_LEGACY_SERVICE) +if (WIN32) add_subdirectory(barrierd) -endif (BARRIER_BUILD_LEGACY_SERVICE) +endif() diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index a5dc9874..5d248912 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -6,17 +6,17 @@ set (CMAKE_AUTORCC ON) set (CMAKE_AUTOUIC ON) set (CMAKE_INCLUDE_CURRENT_DIR ON) -file (GLOB LEGACY_GUI_SOURCE_FILES src/*.cpp src/*.h) -file (GLOB LEGACY_GUI_UI_FILES src/*.ui) +file (GLOB GUI_SOURCE_FILES src/*.cpp src/*.h) +file (GLOB GUI_UI_FILES src/*.ui) if (WIN32) - set (LEGACY_GUI_RC_FILES res/win/Barrier.rc) + set (GUI_RC_FILES res/win/Barrier.rc) endif() add_executable (barrier WIN32 - ${LEGACY_GUI_SOURCE_FILES} - ${LEGACY_GUI_UI_FILES} - ${LEGACY_GUI_RC_FILES} + ${GUI_SOURCE_FILES} + ${GUI_UI_FILES} + ${GUI_RC_FILES} res/Barrier.qrc ) diff --git a/src/lib/arch/win32/ArchDaemonWindows.cpp b/src/lib/arch/win32/ArchDaemonWindows.cpp index fdd50c43..efcf235d 100644 --- a/src/lib/arch/win32/ArchDaemonWindows.cpp +++ b/src/lib/arch/win32/ArchDaemonWindows.cpp @@ -697,15 +697,7 @@ ArchDaemonWindows::installDaemon() void ArchDaemonWindows::uninstallDaemon() { - // remove legacy services if installed. - if (isDaemonInstalled(LEGACY_SERVER_DAEMON_NAME)) { - uninstallDaemon(LEGACY_SERVER_DAEMON_NAME); - } - if (isDaemonInstalled(LEGACY_CLIENT_DAEMON_NAME)) { - uninstallDaemon(LEGACY_CLIENT_DAEMON_NAME); - } - - // remove new service if installed. + // remove service if installed. if (isDaemonInstalled(DEFAULT_DAEMON_NAME)) { uninstallDaemon(DEFAULT_DAEMON_NAME); } diff --git a/src/lib/arch/win32/ArchDaemonWindows.h b/src/lib/arch/win32/ArchDaemonWindows.h index ad69779e..2db97923 100644 --- a/src/lib/arch/win32/ArchDaemonWindows.h +++ b/src/lib/arch/win32/ArchDaemonWindows.h @@ -142,9 +142,6 @@ private: #define DEFAULT_DAEMON_NAME _T("Barrier") #define DEFAULT_DAEMON_INFO _T("Manages the Barrier foreground processes.") -#define LEGACY_SERVER_DAEMON_NAME _T("Barrier Server") -#define LEGACY_CLIENT_DAEMON_NAME _T("Barrier Client") - static const TCHAR* const g_daemonKeyPath[] = { _T("SOFTWARE"), _T("The Barrier Project"), From 51abdc281dd6c6aa3e18ff15a9dc357e058f402a Mon Sep 17 00:00:00 2001 From: walker0643 <> Date: Sun, 11 Mar 2018 13:14:45 -0400 Subject: [PATCH 3/8] make DaemonApp a win32-only target --- src/cmd/barrierd/barrierd.cpp | 2 +- src/lib/barrier/{ => win32}/DaemonApp.cpp | 52 +++-------------------- src/lib/barrier/{ => win32}/DaemonApp.h | 4 -- 3 files changed, 6 insertions(+), 52 deletions(-) rename src/lib/barrier/{ => win32}/DaemonApp.cpp (93%) rename src/lib/barrier/{ => win32}/DaemonApp.h (96%) diff --git a/src/cmd/barrierd/barrierd.cpp b/src/cmd/barrierd/barrierd.cpp index 30423c7a..dd351f9a 100644 --- a/src/cmd/barrierd/barrierd.cpp +++ b/src/cmd/barrierd/barrierd.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#include "barrier/DaemonApp.h" +#include "barrier/win32/DaemonApp.h" #include diff --git a/src/lib/barrier/DaemonApp.cpp b/src/lib/barrier/win32/DaemonApp.cpp similarity index 93% rename from src/lib/barrier/DaemonApp.cpp rename to src/lib/barrier/win32/DaemonApp.cpp index 8a431f95..62fecf8f 100644 --- a/src/lib/barrier/DaemonApp.cpp +++ b/src/lib/barrier/win32/DaemonApp.cpp @@ -16,10 +16,7 @@ * along with this program. If not, see . */ -// TODO: split this class into windows and unix to get rid -// of all the #ifdefs! - -#include "barrier/DaemonApp.h" +#include "barrier/win32/DaemonApp.h" #include "barrier/App.h" #include "barrier/ArgParser.h" @@ -37,8 +34,6 @@ #include "base/log_outputters.h" #include "base/Log.h" -#if SYSAPI_WIN32 - #include "arch/win32/ArchMiscWindows.h" #include "arch/win32/XArchWindows.h" #include "barrier/Screen.h" @@ -50,8 +45,6 @@ #define WIN32_LEAN_AND_MEAN #include -#endif - #include #include #include @@ -68,25 +61,15 @@ mainLoopStatic() } int -unixMainLoopStatic(int, const char**) -{ - return mainLoopStatic(); -} - -#if SYSAPI_WIN32 -int -winMainLoopStatic(int, const char**) +mainLoopStatic(int, const char**) { return ArchMiscWindows::runDaemon(mainLoopStatic); } -#endif DaemonApp::DaemonApp() : m_ipcServer(nullptr), m_ipcLogOutputter(nullptr), - #if SYSAPI_WIN32 m_watchdog(nullptr), - #endif m_events(nullptr), m_fileLogOutputter(nullptr) { @@ -100,10 +83,8 @@ DaemonApp::~DaemonApp() int DaemonApp::run(int argc, char** argv) { -#if SYSAPI_WIN32 // win32 instance needed for threading, etc. ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL)); -#endif Arch arch; arch.init(); @@ -115,10 +96,8 @@ DaemonApp::run(int argc, char** argv) bool uninstall = false; try { -#if SYSAPI_WIN32 // sends debug messages to visual studio console window. log.insert(new MSWindowsDebugOutputter()); -#endif // default log level to system setting. string logLevel = arch.setting("LogLevel"); @@ -133,7 +112,6 @@ DaemonApp::run(int argc, char** argv) if (arg == "/f" || arg == "-f") { foreground = true; } -#if SYSAPI_WIN32 else if (arg == "/install") { uninstall = true; arch.installDaemon(); @@ -143,7 +121,6 @@ DaemonApp::run(int argc, char** argv) arch.uninstallDaemon(); return kExitSuccess; } -#endif else { stringstream ss; ss << "Unrecognized argument: " << arg; @@ -158,11 +135,7 @@ DaemonApp::run(int argc, char** argv) mainLoop(false); } else { -#if SYSAPI_WIN32 - arch.daemonize("Barrier", winMainLoopStatic); -#elif SYSAPI_UNIX - arch.daemonize("Barrier", unixMainLoopStatic); -#endif + arch.daemonize("Barrier", mainLoopStatic); } return kExitSuccess; @@ -214,10 +187,8 @@ DaemonApp::mainLoop(bool daemonized) m_ipcLogOutputter = new IpcLogOutputter(*m_ipcServer, kIpcClientGui, true); CLOG->insert(m_ipcLogOutputter); -#if SYSAPI_WIN32 m_watchdog = new MSWindowsWatchdog(daemonized, false, *m_ipcServer, *m_ipcLogOutputter); m_watchdog->setFileLogOutputter(m_fileLogOutputter); -#endif m_events->adoptHandler( m_events->forIpcServer().messageReceived(), m_ipcServer, @@ -225,8 +196,6 @@ DaemonApp::mainLoop(bool daemonized) m_ipcServer->listen(); -#if SYSAPI_WIN32 - // install the platform event queue to handle service stop events. m_events->adoptBuffer(new MSWindowsEventQueueBuffer(m_events)); @@ -238,13 +207,11 @@ DaemonApp::mainLoop(bool daemonized) } m_watchdog->startAsync(); -#endif + m_events->loop(); -#if SYSAPI_WIN32 m_watchdog->stop(); delete m_watchdog; -#endif m_events->removeHandler( m_events->forIpcServer().messageReceived(), m_ipcServer); @@ -266,11 +233,7 @@ DaemonApp::mainLoop(bool daemonized) void DaemonApp::foregroundError(const char* message) { -#if SYSAPI_WIN32 MessageBox(NULL, message, "Barrier Service", MB_OK | MB_ICONERROR); -#elif SYSAPI_UNIX - cerr << message << endl; -#endif } std::string @@ -338,7 +301,6 @@ DaemonApp::handleIpcMessage(const Event& e, void*) } } -#if SYSAPI_WIN32 // eg. no log-to-file while running in foreground if (m_fileLogOutputter != nullptr) { String logFilename; @@ -354,7 +316,6 @@ DaemonApp::handleIpcMessage(const Event& e, void*) } m_fileLogOutputter->setLogFilename(logFilename.c_str()); } -#endif } else { LOG((CLOG_DEBUG "empty command, elevate=%d", cm->elevate())); @@ -372,12 +333,11 @@ DaemonApp::handleIpcMessage(const Event& e, void*) LOG((CLOG_ERR "failed to save settings, %s", e.what())); } -#if SYSAPI_WIN32 // tell the relauncher about the new command. this causes the // relauncher to stop the existing command and start the new // command. m_watchdog->setCommand(command, cm->elevate()); -#endif + break; } @@ -392,10 +352,8 @@ DaemonApp::handleIpcMessage(const Event& e, void*) LOG((CLOG_DEBUG "ipc hello, type=%s", type.c_str())); -#if SYSAPI_WIN32 const char * serverstatus = m_watchdog->isProcessActive() ? "active" : "not active"; LOG((CLOG_INFO "server status: %s", serverstatus)); -#endif m_ipcLogOutputter->notifyBuffer(); break; diff --git a/src/lib/barrier/DaemonApp.h b/src/lib/barrier/win32/DaemonApp.h similarity index 96% rename from src/lib/barrier/DaemonApp.h rename to src/lib/barrier/win32/DaemonApp.h index e2e7bdf1..2a8484b3 100644 --- a/src/lib/barrier/DaemonApp.h +++ b/src/lib/barrier/win32/DaemonApp.h @@ -27,9 +27,7 @@ class Event; class IpcLogOutputter; class FileLogOutputter; -#if SYSAPI_WIN32 class MSWindowsWatchdog; -#endif class DaemonApp { @@ -48,9 +46,7 @@ private: public: static DaemonApp* s_instance; -#if SYSAPI_WIN32 MSWindowsWatchdog* m_watchdog; -#endif private: IpcServer* m_ipcServer; From ea1c56364713e382e96e0d4bdd0997861f071990 Mon Sep 17 00:00:00 2001 From: walker0643 <> Date: Sun, 11 Mar 2018 13:20:51 -0400 Subject: [PATCH 4/8] make LogWindow wider --- src/gui/src/LogWindowBase.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/src/LogWindowBase.ui b/src/gui/src/LogWindowBase.ui index c7272a70..f3359474 100644 --- a/src/gui/src/LogWindowBase.ui +++ b/src/gui/src/LogWindowBase.ui @@ -6,7 +6,7 @@ 0 0 - 600 + 800 371 From 921a40c6841951fc6b744751f39c1a0dcf1b94ed Mon Sep 17 00:00:00 2001 From: walker0643 <> Date: Tue, 13 Mar 2018 12:11:17 -0400 Subject: [PATCH 5/8] silence avahi's bonjour warning --- src/gui/src/ZeroconfService.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/gui/src/ZeroconfService.cpp b/src/gui/src/ZeroconfService.cpp index 56618e44..02902ee5 100644 --- a/src/gui/src/ZeroconfService.cpp +++ b/src/gui/src/ZeroconfService.cpp @@ -27,6 +27,13 @@ #include #include +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#else +#include +#endif + static const QStringList preferedIPAddress( QStringList() << "192.168." << @@ -36,12 +43,29 @@ static const QStringList preferedIPAddress( const char* ZeroconfService:: m_ServerServiceName = "_barrierServerZeroconf._tcp"; const char* ZeroconfService:: m_ClientServiceName = "_barrierClientZeroconf._tcp"; +static void silence_avahi_warning() +{ + // the libavahi folks seemingly find Apple's bonjour API distasteful + // and are quite liberal in taking it out on users...unless we set + // this environmental variable before calling the avahi library. + // additionally, Microsoft does not give us a POSIX setenv() so + // we use their OS-specific API instead + const char *name = "AVAHI_COMPAT_NOWARN"; + const char *value = "1"; +#ifdef _WIN32 + SetEnvironmentVariable(name, value); +#else + setenv(name, value, 1); +#endif +} + ZeroconfService::ZeroconfService(MainWindow* mainWindow) : m_pMainWindow(mainWindow), m_pZeroconfBrowser(0), m_pZeroconfRegister(0), m_ServiceRegistered(false) { + silence_avahi_warning(); if (m_pMainWindow->barrierType() == MainWindow::barrierServer) { if (registerService(true)) { m_pZeroconfBrowser = new ZeroconfBrowser(this); From bac2999d3e06ba592d4b91c1af85459985930327 Mon Sep 17 00:00:00 2001 From: walker0643 <> Date: Tue, 13 Mar 2018 16:55:07 -0400 Subject: [PATCH 6/8] bump version to 2.0.0 --- cmake/Version.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/Version.cmake b/cmake/Version.cmake index ea565eb1..2f38df2e 100644 --- a/cmake/Version.cmake +++ b/cmake/Version.cmake @@ -1,5 +1,9 @@ cmake_minimum_required (VERSION 3.4) +set (BARRIER_VERSION_MAJOR 2) +set (BARRIER_VERSION_MINOR 0) +set (BARRIER_VERSION_PATCH 0) + # # Barrier Version # From a6008013194d892025c229f3340c01687eb8a927 Mon Sep 17 00:00:00 2001 From: walker0643 <> Date: Tue, 13 Mar 2018 17:06:16 -0400 Subject: [PATCH 7/8] support options to msbuild on windows --- clean_build.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clean_build.bat b/clean_build.bat index 9aebadd8..c5e2153e 100644 --- a/clean_build.bat +++ b/clean_build.bat @@ -27,7 +27,7 @@ if ERRORLEVEL 1 goto failed cd build cmake -G "Visual Studio 15 2017 Win64" -D CMAKE_BUILD_TYPE=%B_BUILD_TYPE% -D CMAKE_PREFIX_PATH="%B_QT_FULLPATH%" -D DNSSD_LIB="%B_BONJOUR%\Lib\x64\dnssd.lib" -D QT_VERSION=%B_QT_VER% .. if ERRORLEVEL 1 goto failed -echo @msbuild barrier.sln /p:Platform="x64" /p:Configuration=%B_BUILD_TYPE% /m > make.bat +echo @msbuild barrier.sln /p:Platform="x64" /p:Configuration=%B_BUILD_TYPE% /m %B_BUILD_OPTIONS% > make.bat call make.bat if ERRORLEVEL 1 goto failed if exist bin\Debug ( From 3389a980ea24785545e5e495ff8dc673025fa938 Mon Sep 17 00:00:00 2001 From: walker0643 <> Date: Tue, 13 Mar 2018 18:04:29 -0400 Subject: [PATCH 8/8] remove bogus check for logonui.exe. it was causing false-positives for the need to elevate --- src/lib/platform/MSWindowsWatchdog.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/lib/platform/MSWindowsWatchdog.cpp b/src/lib/platform/MSWindowsWatchdog.cpp index 677e1da7..ba1890e5 100644 --- a/src/lib/platform/MSWindowsWatchdog.cpp +++ b/src/lib/platform/MSWindowsWatchdog.cpp @@ -142,10 +142,7 @@ MSWindowsWatchdog::getUserToken(LPSECURITY_ATTRIBUTES security) // elevate for the uac dialog (consent.exe) but this would be pointless, // since barrier would re-launch as non-elevated after the desk switch, // and so would be unusable with the new elevated process taking focus. - if (m_elevateProcess - || m_autoElevated - || m_session.isProcessInSession("logonui.exe", NULL)) { - + if (m_elevateProcess || m_autoElevated) { LOG((CLOG_DEBUG "getting elevated token, %s", (m_elevateProcess ? "elevation required" : "at login screen"))); @@ -155,8 +152,7 @@ MSWindowsWatchdog::getUserToken(LPSECURITY_ATTRIBUTES security) } return duplicateProcessToken(process, security); - } - else { + } else { LOG((CLOG_DEBUG "getting non-elevated token")); return m_session.getUserToken(security); }