diff options
| author | 2018-04-25 18:07:30 -0400 | |
|---|---|---|
| committer | 2018-04-25 18:07:30 -0400 | |
| commit | 9b1b081cfdb1c0fb6457278775e0823f8bc10f62 (patch) | |
| tree | ce8840148d8445055ba9e4f12263b2208f234c16 /src/cmd | |
Import Upstream version 2.0.0+dfsgupstream/2.0.0+dfsg
Diffstat (limited to 'src/cmd')
37 files changed, 2080 insertions, 0 deletions
diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt new file mode 100644 index 0000000..0fdfe33 --- /dev/null +++ b/src/cmd/CMakeLists.txt @@ -0,0 +1,24 @@ +# barrier -- mouse and keyboard sharing utility +# Copyright (C) 2012-2016 Symless Ltd. +# Copyright (C) 2011 Nick Bolton +# +# This package is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# found in the file LICENSE that should have accompanied this file. +# +# This package is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +add_subdirectory(barrierc) +add_subdirectory(barriers) +add_subdirectory(syntool) + +if (WIN32) + add_subdirectory(barrierd) +endif() + diff --git a/src/cmd/barrierc/.gitignore b/src/cmd/barrierc/.gitignore new file mode 100644 index 0000000..41a58c4 --- /dev/null +++ b/src/cmd/barrierc/.gitignore @@ -0,0 +1 @@ +/*.aps diff --git a/src/cmd/barrierc/CMakeLists.txt b/src/cmd/barrierc/CMakeLists.txt new file mode 100644 index 0000000..92276d2 --- /dev/null +++ b/src/cmd/barrierc/CMakeLists.txt @@ -0,0 +1,57 @@ +# barrier -- mouse and keyboard sharing utility +# Copyright (C) 2012-2016 Symless Ltd. +# Copyright (C) 2009 Nick Bolton +# +# This package is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# found in the file LICENSE that should have accompanied this file. +# +# This package is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 <http://www.gnu.org/licenses/>. + +set(sources + barrierc.cpp +) + +if (WIN32) + file(GLOB arch_headers "MSWindows*.h") + file(GLOB arch_sources "MSWindows*.cpp") + list(APPEND sources + resource.h + barrierc.ico + barrierc.rc + tb_error.ico + tb_idle.ico + tb_run.ico + tb_wait.ico + ) +elseif (APPLE) + file(GLOB arch_headers "OSX*.h") + file(GLOB arch_sources "OSX*.cpp") +elseif (UNIX) + file(GLOB arch_headers "XWindows*.h") + file(GLOB arch_sources "XWindows*.cpp") +endif() + +list(APPEND sources ${arch_sources}) +list(APPEND headers ${arch_headers}) + +if (BARRIER_ADD_HEADERS) + list(APPEND sources ${headers}) +endif() + +add_executable(barrierc ${sources}) +target_link_libraries(barrierc + arch base client common io mt net ipc platform server synlib ${libs} ${OPENSSL_LIBS}) + +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + install (TARGETS barrierc DESTINATION ${BARRIER_BUNDLE_BINARY_DIR}) +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + install (TARGETS barrierc DESTINATION bin) +endif() + diff --git a/src/cmd/barrierc/MSWindowsClientTaskBarReceiver.cpp b/src/cmd/barrierc/MSWindowsClientTaskBarReceiver.cpp new file mode 100644 index 0000000..8d17900 --- /dev/null +++ b/src/cmd/barrierc/MSWindowsClientTaskBarReceiver.cpp @@ -0,0 +1,376 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2003 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 <http://www.gnu.org/licenses/>. + */ + +#include "MSWindowsClientTaskBarReceiver.h" + +#include "resource.h" +#include "client/Client.h" +#include "platform/MSWindowsClipboard.h" +#include "platform/MSWindowsScreen.h" +#include "arch/win32/ArchTaskBarWindows.h" +#include "arch/win32/ArchMiscWindows.h" +#include "arch/Arch.h" +#include "base/EventQueue.h" +#include "base/log_outputters.h" +#include "base/EventTypes.h" + +// +// MSWindowsClientTaskBarReceiver +// + +const UINT MSWindowsClientTaskBarReceiver::s_stateToIconID[kMaxState] = +{ + IDI_TASKBAR_NOT_RUNNING, + IDI_TASKBAR_NOT_WORKING, + IDI_TASKBAR_NOT_CONNECTED, + IDI_TASKBAR_NOT_CONNECTED, + IDI_TASKBAR_CONNECTED +}; + +MSWindowsClientTaskBarReceiver::MSWindowsClientTaskBarReceiver( + HINSTANCE appInstance, const BufferedLogOutputter* logBuffer, IEventQueue* events) : + ClientTaskBarReceiver(events), + m_appInstance(appInstance), + m_window(NULL), + m_logBuffer(logBuffer) +{ + for (UInt32 i = 0; i < kMaxState; ++i) { + m_icon[i] = loadIcon(s_stateToIconID[i]); + } + m_menu = LoadMenu(m_appInstance, MAKEINTRESOURCE(IDR_TASKBAR)); + + // don't create the window yet. we'll create it on demand. this + // has the side benefit of being created in the thread used for + // the task bar. that's good because it means the existence of + // the window won't prevent changing the main thread's desktop. + + // add ourself to the task bar + ARCH->addReceiver(this); +} + +MSWindowsClientTaskBarReceiver::~MSWindowsClientTaskBarReceiver() +{ + cleanup(); +} + +void +MSWindowsClientTaskBarReceiver::cleanup() +{ + ARCH->removeReceiver(this); + for (UInt32 i = 0; i < kMaxState; ++i) { + deleteIcon(m_icon[i]); + } + DestroyMenu(m_menu); + destroyWindow(); +} + +void +MSWindowsClientTaskBarReceiver::showStatus() +{ + // create the window + createWindow(); + + // lock self while getting status + lock(); + + // get the current status + std::string status = getToolTip(); + + // done getting status + unlock(); + + // update dialog + HWND child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_STATUS); + SendMessage(child, WM_SETTEXT, 0, (LPARAM)status.c_str()); + + if (!IsWindowVisible(m_window)) { + // position it by the mouse + POINT cursorPos; + GetCursorPos(&cursorPos); + RECT windowRect; + GetWindowRect(m_window, &windowRect); + int x = cursorPos.x; + int y = cursorPos.y; + int fw = GetSystemMetrics(SM_CXDLGFRAME); + int fh = GetSystemMetrics(SM_CYDLGFRAME); + int ww = windowRect.right - windowRect.left; + int wh = windowRect.bottom - windowRect.top; + int sw = GetSystemMetrics(SM_CXFULLSCREEN); + int sh = GetSystemMetrics(SM_CYFULLSCREEN); + if (fw < 1) { + fw = 1; + } + if (fh < 1) { + fh = 1; + } + if (x + ww - fw > sw) { + x -= ww - fw; + } + else { + x -= fw; + } + if (x < 0) { + x = 0; + } + if (y + wh - fh > sh) { + y -= wh - fh; + } + else { + y -= fh; + } + if (y < 0) { + y = 0; + } + SetWindowPos(m_window, HWND_TOPMOST, x, y, ww, wh, + SWP_SHOWWINDOW); + } +} + +void +MSWindowsClientTaskBarReceiver::runMenu(int x, int y) +{ + // do popup menu. we need a window to pass to TrackPopupMenu(). + // the SetForegroundWindow() and SendMessage() calls around + // TrackPopupMenu() are to get the menu to be dismissed when + // another window gets activated and are just one of those + // win32 weirdnesses. + createWindow(); + SetForegroundWindow(m_window); + HMENU menu = GetSubMenu(m_menu, 0); + SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE); + HMENU logLevelMenu = GetSubMenu(menu, 3); + CheckMenuRadioItem(logLevelMenu, 0, 6, + CLOG->getFilter() - kERROR, MF_BYPOSITION); + int n = TrackPopupMenu(menu, + TPM_NONOTIFY | + TPM_RETURNCMD | + TPM_LEFTBUTTON | + TPM_RIGHTBUTTON, + x, y, 0, m_window, NULL); + SendMessage(m_window, WM_NULL, 0, 0); + + // perform the requested operation + switch (n) { + case IDC_TASKBAR_STATUS: + showStatus(); + break; + + case IDC_TASKBAR_LOG: + copyLog(); + break; + + case IDC_TASKBAR_SHOW_LOG: + ARCH->showConsole(true); + break; + + case IDC_TASKBAR_LOG_LEVEL_ERROR: + CLOG->setFilter(kERROR); + break; + + case IDC_TASKBAR_LOG_LEVEL_WARNING: + CLOG->setFilter(kWARNING); + break; + + case IDC_TASKBAR_LOG_LEVEL_NOTE: + CLOG->setFilter(kNOTE); + break; + + case IDC_TASKBAR_LOG_LEVEL_INFO: + CLOG->setFilter(kINFO); + break; + + case IDC_TASKBAR_LOG_LEVEL_DEBUG: + CLOG->setFilter(kDEBUG); + break; + + case IDC_TASKBAR_LOG_LEVEL_DEBUG1: + CLOG->setFilter(kDEBUG1); + break; + + case IDC_TASKBAR_LOG_LEVEL_DEBUG2: + CLOG->setFilter(kDEBUG2); + break; + + case IDC_TASKBAR_QUIT: + quit(); + break; + } +} + +void +MSWindowsClientTaskBarReceiver::primaryAction() +{ + showStatus(); +} + +const IArchTaskBarReceiver::Icon +MSWindowsClientTaskBarReceiver::getIcon() const +{ + return static_cast<Icon>(m_icon[getStatus()]); +} + +void +MSWindowsClientTaskBarReceiver::copyLog() const +{ + if (m_logBuffer != NULL) { + // collect log buffer + String data; + for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin(); + index != m_logBuffer->end(); ++index) { + data += *index; + data += "\n"; + } + + // copy log to clipboard + if (!data.empty()) { + MSWindowsClipboard clipboard(m_window); + clipboard.open(0); + clipboard.emptyUnowned(); + clipboard.add(IClipboard::kText, data); + clipboard.close(); + } + } +} + +void +MSWindowsClientTaskBarReceiver::onStatusChanged() +{ + if (IsWindowVisible(m_window)) { + showStatus(); + } +} + +HICON +MSWindowsClientTaskBarReceiver::loadIcon(UINT id) +{ + HANDLE icon = LoadImage(m_appInstance, + MAKEINTRESOURCE(id), + IMAGE_ICON, + 0, 0, + LR_DEFAULTCOLOR); + return static_cast<HICON>(icon); +} + +void +MSWindowsClientTaskBarReceiver::deleteIcon(HICON icon) +{ + if (icon != NULL) { + DestroyIcon(icon); + } +} + +void +MSWindowsClientTaskBarReceiver::createWindow() +{ + // ignore if already created + if (m_window != NULL) { + return; + } + + // get the status dialog + m_window = CreateDialogParam(m_appInstance, + MAKEINTRESOURCE(IDD_TASKBAR_STATUS), + NULL, + (DLGPROC)&MSWindowsClientTaskBarReceiver::staticDlgProc, + reinterpret_cast<LPARAM>( + static_cast<void*>(this))); + + // window should appear on top of everything, including (especially) + // the task bar. + LONG_PTR style = GetWindowLongPtr(m_window, GWL_EXSTYLE); + style |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST; + SetWindowLongPtr(m_window, GWL_EXSTYLE, style); + + // tell the task bar about this dialog + ArchTaskBarWindows::addDialog(m_window); +} + +void +MSWindowsClientTaskBarReceiver::destroyWindow() +{ + if (m_window != NULL) { + ArchTaskBarWindows::removeDialog(m_window); + DestroyWindow(m_window); + m_window = NULL; + } +} + +BOOL +MSWindowsClientTaskBarReceiver::dlgProc(HWND hwnd, + UINT msg, WPARAM wParam, LPARAM) +{ + switch (msg) { + case WM_INITDIALOG: + // use default focus + return TRUE; + + case WM_ACTIVATE: + // hide when another window is activated + if (LOWORD(wParam) == WA_INACTIVE) { + ShowWindow(hwnd, SW_HIDE); + } + break; + } + return FALSE; +} + +BOOL CALLBACK +MSWindowsClientTaskBarReceiver::staticDlgProc(HWND hwnd, + UINT msg, WPARAM wParam, LPARAM lParam) +{ + // if msg is WM_INITDIALOG, extract the MSWindowsClientTaskBarReceiver* + // and put it in the extra window data then forward the call. + MSWindowsClientTaskBarReceiver* self = NULL; + if (msg == WM_INITDIALOG) { + self = static_cast<MSWindowsClientTaskBarReceiver*>( + reinterpret_cast<void*>(lParam)); + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) lParam); + } + else { + // get the extra window data and forward the call + LONG_PTR data = GetWindowLongPtr(hwnd, GWLP_USERDATA); + if (data != 0) { + self = (MSWindowsClientTaskBarReceiver*) data; + } + } + + // forward the message + if (self != NULL) { + return self->dlgProc(hwnd, msg, wParam, lParam); + } + else { + return (msg == WM_INITDIALOG) ? TRUE : FALSE; + } +} + +IArchTaskBarReceiver* +createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events) +{ + ArchMiscWindows::setIcons( + (HICON)LoadImage(ArchMiscWindows::instanceWin32(), + MAKEINTRESOURCE(IDI_BARRIER), + IMAGE_ICON, + 32, 32, LR_SHARED), + (HICON)LoadImage(ArchMiscWindows::instanceWin32(), + MAKEINTRESOURCE(IDI_BARRIER), + IMAGE_ICON, + 16, 16, LR_SHARED)); + + return new MSWindowsClientTaskBarReceiver( + MSWindowsScreen::getWindowInstance(), logBuffer, events); +} diff --git a/src/cmd/barrierc/MSWindowsClientTaskBarReceiver.h b/src/cmd/barrierc/MSWindowsClientTaskBarReceiver.h new file mode 100644 index 0000000..91688e8 --- /dev/null +++ b/src/cmd/barrierc/MSWindowsClientTaskBarReceiver.h @@ -0,0 +1,68 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2003 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include "barrier/ClientTaskBarReceiver.h" + +#define WIN32_LEAN_AND_MEAN +#include <Windows.h> + +class BufferedLogOutputter; +class IEventQueue; + +//! Implementation of ClientTaskBarReceiver for Microsoft Windows +class MSWindowsClientTaskBarReceiver : public ClientTaskBarReceiver { +public: + MSWindowsClientTaskBarReceiver(HINSTANCE, const BufferedLogOutputter*, IEventQueue* events); + virtual ~MSWindowsClientTaskBarReceiver(); + + // IArchTaskBarReceiver overrides + virtual void showStatus(); + virtual void runMenu(int x, int y); + virtual void primaryAction(); + virtual const Icon getIcon() const; + void cleanup(); + +protected: + void copyLog() const; + + // ClientTaskBarReceiver overrides + virtual void onStatusChanged(); + +private: + HICON loadIcon(UINT); + void deleteIcon(HICON); + void createWindow(); + void destroyWindow(); + + BOOL dlgProc(HWND hwnd, + UINT msg, WPARAM wParam, LPARAM lParam); + static BOOL CALLBACK + staticDlgProc(HWND hwnd, + UINT msg, WPARAM wParam, LPARAM lParam); + +private: + HINSTANCE m_appInstance; + HWND m_window; + HMENU m_menu; + HICON m_icon[kMaxState]; + const BufferedLogOutputter* m_logBuffer; + + static const UINT s_stateToIconID[]; +}; diff --git a/src/cmd/barrierc/OSXClientTaskBarReceiver.cpp b/src/cmd/barrierc/OSXClientTaskBarReceiver.cpp new file mode 100644 index 0000000..7e79991 --- /dev/null +++ b/src/cmd/barrierc/OSXClientTaskBarReceiver.cpp @@ -0,0 +1,69 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2004 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 <http://www.gnu.org/licenses/>. + */ + +#include "OSXClientTaskBarReceiver.h" +#include "arch/Arch.h" + +// +// OSXClientTaskBarReceiver +// + +OSXClientTaskBarReceiver::OSXClientTaskBarReceiver( + const BufferedLogOutputter*, + IEventQueue* events) : + ClientTaskBarReceiver(events) +{ + // add ourself to the task bar + ARCH->addReceiver(this); +} + +OSXClientTaskBarReceiver::~OSXClientTaskBarReceiver() +{ + ARCH->removeReceiver(this); +} + +void +OSXClientTaskBarReceiver::showStatus() +{ + // do nothing +} + +void +OSXClientTaskBarReceiver::runMenu(int, int) +{ + // do nothing +} + +void +OSXClientTaskBarReceiver::primaryAction() +{ + // do nothing +} + +const IArchTaskBarReceiver::Icon +OSXClientTaskBarReceiver::getIcon() const +{ + return NULL; +} + +IArchTaskBarReceiver* +createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events) +{ + return new OSXClientTaskBarReceiver(logBuffer, events); +} + diff --git a/src/cmd/barrierc/OSXClientTaskBarReceiver.h b/src/cmd/barrierc/OSXClientTaskBarReceiver.h new file mode 100644 index 0000000..fcc763a --- /dev/null +++ b/src/cmd/barrierc/OSXClientTaskBarReceiver.h @@ -0,0 +1,37 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2004 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include "barrier/ClientTaskBarReceiver.h" + +class BufferedLogOutputter; +class IEventQueue; + +//! Implementation of ClientTaskBarReceiver for OS X +class OSXClientTaskBarReceiver : public ClientTaskBarReceiver { +public: + OSXClientTaskBarReceiver(const BufferedLogOutputter*, IEventQueue* events); + virtual ~OSXClientTaskBarReceiver(); + + // IArchTaskBarReceiver overrides + virtual void showStatus(); + virtual void runMenu(int x, int y); + virtual void primaryAction(); + virtual const Icon getIcon() const; +}; diff --git a/src/cmd/barrierc/XWindowsClientTaskBarReceiver.cpp b/src/cmd/barrierc/XWindowsClientTaskBarReceiver.cpp new file mode 100644 index 0000000..f56481c --- /dev/null +++ b/src/cmd/barrierc/XWindowsClientTaskBarReceiver.cpp @@ -0,0 +1,68 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2003 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 <http://www.gnu.org/licenses/>. + */ + +#include "XWindowsClientTaskBarReceiver.h" +#include "arch/Arch.h" + +// +// CXWindowsClientTaskBarReceiver +// + +CXWindowsClientTaskBarReceiver::CXWindowsClientTaskBarReceiver( + const BufferedLogOutputter*, + IEventQueue* events) : + ClientTaskBarReceiver(events) +{ + // add ourself to the task bar + ARCH->addReceiver(this); +} + +CXWindowsClientTaskBarReceiver::~CXWindowsClientTaskBarReceiver() +{ + ARCH->removeReceiver(this); +} + +void +CXWindowsClientTaskBarReceiver::showStatus() +{ + // do nothing +} + +void +CXWindowsClientTaskBarReceiver::runMenu(int, int) +{ + // do nothing +} + +void +CXWindowsClientTaskBarReceiver::primaryAction() +{ + // do nothing +} + +const IArchTaskBarReceiver::Icon +CXWindowsClientTaskBarReceiver::getIcon() const +{ + return NULL; +} + +IArchTaskBarReceiver* +createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events) +{ + return new CXWindowsClientTaskBarReceiver(logBuffer, events); +} diff --git a/src/cmd/barrierc/XWindowsClientTaskBarReceiver.h b/src/cmd/barrierc/XWindowsClientTaskBarReceiver.h new file mode 100644 index 0000000..73250d0 --- /dev/null +++ b/src/cmd/barrierc/XWindowsClientTaskBarReceiver.h @@ -0,0 +1,38 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2003 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include "barrier/ClientTaskBarReceiver.h" + +class BufferedLogOutputter; +class IEventQueue; + +//! Implementation of ClientTaskBarReceiver for X Windows +class CXWindowsClientTaskBarReceiver : public ClientTaskBarReceiver { +public: + CXWindowsClientTaskBarReceiver( + const BufferedLogOutputter*, IEventQueue* events); + virtual ~CXWindowsClientTaskBarReceiver(); + + // IArchTaskBarReceiver overrides + virtual void showStatus(); + virtual void runMenu(int x, int y); + virtual void primaryAction(); + virtual const Icon getIcon() const; +}; diff --git a/src/cmd/barrierc/barrierc.cpp b/src/cmd/barrierc/barrierc.cpp new file mode 100644 index 0000000..28d8efc --- /dev/null +++ b/src/cmd/barrierc/barrierc.cpp @@ -0,0 +1,58 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2002 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "barrier/ClientApp.h" +#include "arch/Arch.h" +#include "base/Log.h" +#include "base/EventQueue.h" + +#if WINAPI_MSWINDOWS +#include "MSWindowsClientTaskBarReceiver.h" +#elif WINAPI_XWINDOWS +#include "XWindowsClientTaskBarReceiver.h" +#elif WINAPI_CARBON +#include "OSXClientTaskBarReceiver.h" +#else +#error Platform not supported. +#endif + +int +main(int argc, char** argv) +{ +#if SYSAPI_WIN32 + // record window instance for tray icon, etc + ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL)); +#endif + + Arch arch; + arch.init(); + + Log log; + EventQueue events; + + ClientApp app(&events, createTaskBarReceiver); + int result = app.run(argc, argv); +#if SYSAPI_WIN32 + if (IsDebuggerPresent()) { + printf("\n\nHit a key to close...\n"); + getchar(); + } +#endif + return result; + +} diff --git a/src/cmd/barrierc/barrierc.ico b/src/cmd/barrierc/barrierc.ico Binary files differnew file mode 100644 index 0000000..6e90545 --- /dev/null +++ b/src/cmd/barrierc/barrierc.ico diff --git a/src/cmd/barrierc/barrierc.rc b/src/cmd/barrierc/barrierc.rc new file mode 100644 index 0000000..b34127c --- /dev/null +++ b/src/cmd/barrierc/barrierc.rc @@ -0,0 +1,141 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include <winresrc.h> +#if !defined(IDC_STATIC) +#define IDC_STATIC (-1) +#endif + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include <winresrc.h>\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_BARRIER ICON DISCARDABLE "barrierc.ico" +IDI_TASKBAR_NOT_RUNNING ICON DISCARDABLE "tb_idle.ico" +IDI_TASKBAR_NOT_WORKING ICON DISCARDABLE "tb_error.ico" +IDI_TASKBAR_NOT_CONNECTED ICON DISCARDABLE "tb_wait.ico" +IDI_TASKBAR_CONNECTED ICON DISCARDABLE "tb_run.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_TASKBAR_STATUS DIALOG DISCARDABLE 0, 0, 145, 18 +STYLE DS_MODALFRAME | WS_POPUP +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_TASKBAR_STATUS_STATUS,3,3,139,12,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_TASKBAR MENU DISCARDABLE +BEGIN + POPUP "Barrier" + BEGIN + MENUITEM "Show Status", IDC_TASKBAR_STATUS + MENUITEM "Show Log", IDC_TASKBAR_SHOW_LOG + MENUITEM "Copy Log To Clipboard", IDC_TASKBAR_LOG + POPUP "Set Log Level" + BEGIN + MENUITEM "Error", IDC_TASKBAR_LOG_LEVEL_ERROR + + MENUITEM "Warning", IDC_TASKBAR_LOG_LEVEL_WARNING + + MENUITEM "Note", IDC_TASKBAR_LOG_LEVEL_NOTE + + MENUITEM "Info", IDC_TASKBAR_LOG_LEVEL_INFO + + MENUITEM "Debug", IDC_TASKBAR_LOG_LEVEL_DEBUG + + MENUITEM "Debug1", IDC_TASKBAR_LOG_LEVEL_DEBUG1 + + MENUITEM "Debug2", IDC_TASKBAR_LOG_LEVEL_DEBUG2 + + END + MENUITEM SEPARATOR + MENUITEM "Quit", IDC_TASKBAR_QUIT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_FAILED "Barrier is about to quit with errors or warnings. Please check the log then click OK." + IDS_INIT_FAILED "Barrier failed to initialize: %{1}" + IDS_UNCAUGHT_EXCEPTION "Uncaught exception: %{1}" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/cmd/barrierc/resource.h b/src/cmd/barrierc/resource.h new file mode 100644 index 0000000..57b271e --- /dev/null +++ b/src/cmd/barrierc/resource.h @@ -0,0 +1,37 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by barrierc.rc +// +#define IDS_FAILED 1 +#define IDS_INIT_FAILED 2 +#define IDS_UNCAUGHT_EXCEPTION 3 +#define IDI_BARRIER 101 +#define IDI_TASKBAR_NOT_RUNNING 102 +#define IDI_TASKBAR_NOT_WORKING 103 +#define IDI_TASKBAR_NOT_CONNECTED 104 +#define IDI_TASKBAR_CONNECTED 105 +#define IDR_TASKBAR 107 +#define IDD_TASKBAR_STATUS 108 +#define IDC_TASKBAR_STATUS_STATUS 1000 +#define IDC_TASKBAR_QUIT 40001 +#define IDC_TASKBAR_STATUS 40002 +#define IDC_TASKBAR_LOG 40003 +#define IDC_TASKBAR_SHOW_LOG 40004 +#define IDC_TASKBAR_LOG_LEVEL_ERROR 40009 +#define IDC_TASKBAR_LOG_LEVEL_WARNING 40010 +#define IDC_TASKBAR_LOG_LEVEL_NOTE 40011 +#define IDC_TASKBAR_LOG_LEVEL_INFO 40012 +#define IDC_TASKBAR_LOG_LEVEL_DEBUG 40013 +#define IDC_TASKBAR_LOG_LEVEL_DEBUG1 40014 +#define IDC_TASKBAR_LOG_LEVEL_DEBUG2 40015 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 109 +#define _APS_NEXT_COMMAND_VALUE 40016 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/cmd/barrierc/tb_error.ico b/src/cmd/barrierc/tb_error.ico Binary files differnew file mode 100644 index 0000000..746a87c --- /dev/null +++ b/src/cmd/barrierc/tb_error.ico diff --git a/src/cmd/barrierc/tb_idle.ico b/src/cmd/barrierc/tb_idle.ico Binary files differnew file mode 100644 index 0000000..4e13a26 --- /dev/null +++ b/src/cmd/barrierc/tb_idle.ico diff --git a/src/cmd/barrierc/tb_run.ico b/src/cmd/barrierc/tb_run.ico Binary files differnew file mode 100644 index 0000000..88e160c --- /dev/null +++ b/src/cmd/barrierc/tb_run.ico diff --git a/src/cmd/barrierc/tb_wait.ico b/src/cmd/barrierc/tb_wait.ico Binary files differnew file mode 100644 index 0000000..257be0a --- /dev/null +++ b/src/cmd/barrierc/tb_wait.ico diff --git a/src/cmd/barrierd/CMakeLists.txt b/src/cmd/barrierd/CMakeLists.txt new file mode 100644 index 0000000..aeae94c --- /dev/null +++ b/src/cmd/barrierd/CMakeLists.txt @@ -0,0 +1,27 @@ +# barrier -- mouse and keyboard sharing utility +# Copyright (C) 2012-2016 Symless Ltd. +# Copyright (C) 2012 Nick Bolton +# +# This package is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# found in the file LICENSE that should have accompanied this file. +# +# This package is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 <http://www.gnu.org/licenses/>. + +file(GLOB headers "*.h") +file(GLOB sources "*.cpp") + +if (WIN32) + add_executable (barrierd WIN32 ${sources}) +else() + add_executable (barrierd ${sources}) +endif() + +target_link_libraries (barrierd + arch base common io ipc mt net platform synlib ${libs} ${OPENSSL_LIBS}) diff --git a/src/cmd/barrierd/barrierd.cpp b/src/cmd/barrierd/barrierd.cpp new file mode 100644 index 0000000..dd351f9 --- /dev/null +++ b/src/cmd/barrierd/barrierd.cpp @@ -0,0 +1,44 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2012 Nick Bolton + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 <http://www.gnu.org/licenses/>. + */ + +#include "barrier/win32/DaemonApp.h" + +#include <iostream> + +#ifdef SYSAPI_UNIX + +int +main(int argc, char** argv) +{ + DaemonApp app; + return app.run(argc, argv); +} + +#elif SYSAPI_WIN32 + +#define WIN32_LEAN_AND_MEAN +#include <Windows.h> + +int WINAPI +WinMain(HINSTANCE, HINSTANCE, LPSTR, int) +{ + DaemonApp app; + return app.run(__argc, __argv); +} + +#endif diff --git a/src/cmd/barriers/.gitignore b/src/cmd/barriers/.gitignore new file mode 100644 index 0000000..41a58c4 --- /dev/null +++ b/src/cmd/barriers/.gitignore @@ -0,0 +1 @@ +/*.aps diff --git a/src/cmd/barriers/CMakeLists.txt b/src/cmd/barriers/CMakeLists.txt new file mode 100644 index 0000000..e1871ee --- /dev/null +++ b/src/cmd/barriers/CMakeLists.txt @@ -0,0 +1,58 @@ +# barrier -- mouse and keyboard sharing utility +# Copyright (C) 2012-2016 Symless Ltd. +# Copyright (C) 2009 Nick Bolton +# +# This package is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# found in the file LICENSE that should have accompanied this file. +# +# This package is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 <http://www.gnu.org/licenses/>. + +set(sources + barriers.cpp +) + +if (WIN32) + file(GLOB arch_headers "MSWindows*.h") + file(GLOB arch_sources "MSWindows*.cpp") + list(APPEND sources + resource.h + barriers.ico + barriers.rc + tb_error.ico + tb_idle.ico + tb_run.ico + tb_wait.ico + ) +elseif (APPLE) + file(GLOB arch_headers "OSX*.h") + file(GLOB arch_sources "OSX*.cpp") +elseif (UNIX) + file(GLOB arch_headers "XWindows*.h") + file(GLOB arch_sources "XWindows*.cpp") +endif() + +list(APPEND sources ${arch_sources}) +list(APPEND headers ${arch_headers}) + +if (BARRIER_ADD_HEADERS) + list(APPEND sources ${headers}) +endif() + +add_executable(barriers ${sources}) +target_link_libraries(barriers + arch base client common io mt net ipc platform server synlib ${libs} ${OPENSSL_LIBS}) + +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + install (TARGETS barriers DESTINATION ${BARRIER_BUNDLE_BINARY_DIR}) +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + install (TARGETS barriers DESTINATION bin) +endif() + + diff --git a/src/cmd/barriers/MSWindowsServerTaskBarReceiver.cpp b/src/cmd/barriers/MSWindowsServerTaskBarReceiver.cpp new file mode 100644 index 0000000..a221dac --- /dev/null +++ b/src/cmd/barriers/MSWindowsServerTaskBarReceiver.cpp @@ -0,0 +1,408 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2003 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 <http://www.gnu.org/licenses/>. + */ + +#include "MSWindowsServerTaskBarReceiver.h" + +#include "resource.h" +#include "server/Server.h" +#include "platform/MSWindowsClipboard.h" +#include "platform/MSWindowsScreen.h" +#include "arch/win32/ArchTaskBarWindows.h" +#include "arch/win32/ArchMiscWindows.h" +#include "arch/Arch.h" +#include "base/EventQueue.h" +#include "base/IEventQueue.h" +#include "base/log_outputters.h" +#include "base/EventTypes.h" + +// +// MSWindowsServerTaskBarReceiver +// + +const UINT MSWindowsServerTaskBarReceiver::s_stateToIconID[kMaxState] = +{ + IDI_TASKBAR_NOT_RUNNING, + IDI_TASKBAR_NOT_WORKING, + IDI_TASKBAR_NOT_CONNECTED, + IDI_TASKBAR_CONNECTED +}; + +MSWindowsServerTaskBarReceiver::MSWindowsServerTaskBarReceiver( + HINSTANCE appInstance, const BufferedLogOutputter* logBuffer, IEventQueue* events) : + ServerTaskBarReceiver(events), + m_events(events), + m_appInstance(appInstance), + m_window(NULL), + m_logBuffer(logBuffer) +{ + for (UInt32 i = 0; i < kMaxState; ++i) { + m_icon[i] = loadIcon(s_stateToIconID[i]); + } + m_menu = LoadMenu(m_appInstance, MAKEINTRESOURCE(IDR_TASKBAR)); + + // don't create the window yet. we'll create it on demand. this + // has the side benefit of being created in the thread used for + // the task bar. that's good because it means the existence of + // the window won't prevent changing the main thread's desktop. + + // add ourself to the task bar + ARCH->addReceiver(this); +} + +void +MSWindowsServerTaskBarReceiver::cleanup() +{ + ARCH->removeReceiver(this); + for (UInt32 i = 0; i < kMaxState; ++i) { + deleteIcon(m_icon[i]); + } + DestroyMenu(m_menu); + destroyWindow(); +} + +MSWindowsServerTaskBarReceiver::~MSWindowsServerTaskBarReceiver() +{ + cleanup(); +} + +void +MSWindowsServerTaskBarReceiver::showStatus() +{ + // create the window + createWindow(); + + // lock self while getting status + lock(); + + // get the current status + std::string status = getToolTip(); + + // get the connect clients, if any + const Clients& clients = getClients(); + + // done getting status + unlock(); + + // update dialog + HWND child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_STATUS); + SendMessage(child, WM_SETTEXT, 0, (LPARAM)status.c_str()); + child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_CLIENTS); + SendMessage(child, LB_RESETCONTENT, 0, 0); + for (Clients::const_iterator index = clients.begin(); + index != clients.end(); ) { + const char* client = index->c_str(); + if (++index == clients.end()) { + SendMessage(child, LB_ADDSTRING, 0, (LPARAM)client); + } + else { + SendMessage(child, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)client); + } + } + + if (!IsWindowVisible(m_window)) { + // position it by the mouse + POINT cursorPos; + GetCursorPos(&cursorPos); + RECT windowRect; + GetWindowRect(m_window, &windowRect); + int x = cursorPos.x; + int y = cursorPos.y; + int fw = GetSystemMetrics(SM_CXDLGFRAME); + int fh = GetSystemMetrics(SM_CYDLGFRAME); + int ww = windowRect.right - windowRect.left; + int wh = windowRect.bottom - windowRect.top; + int sw = GetSystemMetrics(SM_CXFULLSCREEN); + int sh = GetSystemMetrics(SM_CYFULLSCREEN); + if (fw < 1) { + fw = 1; + } + if (fh < 1) { + fh = 1; + } + if (x + ww - fw > sw) { + x -= ww - fw; + } + else { + x -= fw; + } + if (x < 0) { + x = 0; + } + if (y + wh - fh > sh) { + y -= wh - fh; + } + else { + y -= fh; + } + if (y < 0) { + y = 0; + } + SetWindowPos(m_window, HWND_TOPMOST, x, y, ww, wh, + SWP_SHOWWINDOW); + } +} + +void +MSWindowsServerTaskBarReceiver::runMenu(int x, int y) +{ + // do popup menu. we need a window to pass to TrackPopupMenu(). + // the SetForegroundWindow() and SendMessage() calls around + // TrackPopupMenu() are to get the menu to be dismissed when + // another window gets activated and are just one of those + // win32 weirdnesses. + createWindow(); + SetForegroundWindow(m_window); + HMENU menu = GetSubMenu(m_menu, 0); + SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE); + HMENU logLevelMenu = GetSubMenu(menu, 3); + CheckMenuRadioItem(logLevelMenu, 0, 6, + CLOG->getFilter() - kERROR, MF_BYPOSITION); + int n = TrackPopupMenu(menu, + TPM_NONOTIFY | + TPM_RETURNCMD | + TPM_LEFTBUTTON | + TPM_RIGHTBUTTON, + x, y, 0, m_window, NULL); + SendMessage(m_window, WM_NULL, 0, 0); + + // perform the requested operation + switch (n) { + case IDC_TASKBAR_STATUS: + showStatus(); + break; + + case IDC_TASKBAR_LOG: + copyLog(); + break; + + case IDC_TASKBAR_SHOW_LOG: + ARCH->showConsole(true); + break; + + case IDC_RELOAD_CONFIG: + m_events->addEvent(Event(m_events->forServerApp().reloadConfig(), + m_events->getSystemTarget())); + break; + + case IDC_FORCE_RECONNECT: + m_events->addEvent(Event(m_events->forServerApp().forceReconnect(), + m_events->getSystemTarget())); + break; + + case ID_BARRIER_RESETSERVER: + m_events->addEvent(Event(m_events->forServerApp().resetServer(), + m_events->getSystemTarget())); + break; + + case IDC_TASKBAR_LOG_LEVEL_ERROR: + CLOG->setFilter(kERROR); + break; + + case IDC_TASKBAR_LOG_LEVEL_WARNING: + CLOG->setFilter(kWARNING); + break; + + case IDC_TASKBAR_LOG_LEVEL_NOTE: + CLOG->setFilter(kNOTE); + break; + + case IDC_TASKBAR_LOG_LEVEL_INFO: + CLOG->setFilter(kINFO); + break; + + case IDC_TASKBAR_LOG_LEVEL_DEBUG: + CLOG->setFilter(kDEBUG); + break; + + case IDC_TASKBAR_LOG_LEVEL_DEBUG1: + CLOG->setFilter(kDEBUG1); + break; + + case IDC_TASKBAR_LOG_LEVEL_DEBUG2: + CLOG->setFilter(kDEBUG2); + break; + + case IDC_TASKBAR_QUIT: + quit(); + break; + } +} + +void +MSWindowsServerTaskBarReceiver::primaryAction() +{ + showStatus(); +} + +const IArchTaskBarReceiver::Icon +MSWindowsServerTaskBarReceiver::getIcon() const +{ + return static_cast<Icon>(m_icon[getStatus()]); +} + +void +MSWindowsServerTaskBarReceiver::copyLog() const +{ + if (m_logBuffer != NULL) { + // collect log buffer + String data; + for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin(); + index != m_logBuffer->end(); ++index) { + data += *index; + data += "\n"; + } + + // copy log to clipboard + if (!data.empty()) { + MSWindowsClipboard clipboard(m_window); + clipboard.open(0); + clipboard.emptyUnowned(); + clipboard.add(IClipboard::kText, data); + clipboard.close(); + } + } +} + +void +MSWindowsServerTaskBarReceiver::onStatusChanged() +{ + if (IsWindowVisible(m_window)) { + showStatus(); + } +} + +HICON +MSWindowsServerTaskBarReceiver::loadIcon(UINT id) +{ + HANDLE icon = LoadImage(m_appInstance, + MAKEINTRESOURCE(id), + IMAGE_ICON, + 0, 0, + LR_DEFAULTCOLOR); + return static_cast<HICON>(icon); +} + +void +MSWindowsServerTaskBarReceiver::deleteIcon(HICON icon) +{ + if (icon != NULL) { + DestroyIcon(icon); + } +} + +void +MSWindowsServerTaskBarReceiver::createWindow() +{ + // ignore if already created + if (m_window != NULL) { + return; + } + + // get the status dialog + m_window = CreateDialogParam(m_appInstance, + MAKEINTRESOURCE(IDD_TASKBAR_STATUS), + NULL, + (DLGPROC)&MSWindowsServerTaskBarReceiver::staticDlgProc, + reinterpret_cast<LPARAM>( + static_cast<void*>(this))); + + // window should appear on top of everything, including (especially) + // the task bar. + LONG_PTR style = GetWindowLongPtr(m_window, GWL_EXSTYLE); + style |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST; + SetWindowLongPtr(m_window, GWL_EXSTYLE, style); + + // tell the task bar about this dialog + ArchTaskBarWindows::addDialog(m_window); +} + +void +MSWindowsServerTaskBarReceiver::destroyWindow() +{ + if (m_window != NULL) { + ArchTaskBarWindows::removeDialog(m_window); + DestroyWindow(m_window); + m_window = NULL; + } +} + +BOOL +MSWindowsServerTaskBarReceiver::dlgProc(HWND hwnd, + UINT msg, WPARAM wParam, LPARAM) +{ + switch (msg) { + case WM_INITDIALOG: + // use default focus + return TRUE; + + case WM_ACTIVATE: + // hide when another window is activated + if (LOWORD(wParam) == WA_INACTIVE) { + ShowWindow(hwnd, SW_HIDE); + } + break; + } + return FALSE; +} + +BOOL CALLBACK +MSWindowsServerTaskBarReceiver::staticDlgProc(HWND hwnd, + UINT msg, WPARAM wParam, LPARAM lParam) +{ + // if msg is WM_INITDIALOG, extract the MSWindowsServerTaskBarReceiver* + // and put it in the extra window data then forward the call. + MSWindowsServerTaskBarReceiver* self = NULL; + if (msg == WM_INITDIALOG) { + self = static_cast<MSWindowsServerTaskBarReceiver*>( + reinterpret_cast<void*>(lParam)); + SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); + } + else { + // get the extra window data and forward the call + LONG_PTR data = GetWindowLongPtr(hwnd, GWLP_USERDATA); + if (data != 0) { + self = static_cast<MSWindowsServerTaskBarReceiver*>( + reinterpret_cast<void*>(data)); + } + } + + // forward the message + if (self != NULL) { + return self->dlgProc(hwnd, msg, wParam, lParam); + } + else { + return (msg == WM_INITDIALOG) ? TRUE : FALSE; + } +} + +IArchTaskBarReceiver* +createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events) +{ + ArchMiscWindows::setIcons( + (HICON)LoadImage(ArchMiscWindows::instanceWin32(), + MAKEINTRESOURCE(IDI_BARRIER), + IMAGE_ICON, + 32, 32, LR_SHARED), + (HICON)LoadImage(ArchMiscWindows::instanceWin32(), + MAKEINTRESOURCE(IDI_BARRIER), + IMAGE_ICON, + 16, 16, LR_SHARED)); + + return new MSWindowsServerTaskBarReceiver( + MSWindowsScreen::getWindowInstance(), logBuffer, events); +} diff --git a/src/cmd/barriers/MSWindowsServerTaskBarReceiver.h b/src/cmd/barriers/MSWindowsServerTaskBarReceiver.h new file mode 100644 index 0000000..a308ab4 --- /dev/null +++ b/src/cmd/barriers/MSWindowsServerTaskBarReceiver.h @@ -0,0 +1,69 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2003 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include "barrier/ServerTaskBarReceiver.h" + +#define WIN32_LEAN_AND_MEAN +#include <Windows.h> + +class BufferedLogOutputter; +class IEventQueue; + +//! Implementation of ServerTaskBarReceiver for Microsoft Windows +class MSWindowsServerTaskBarReceiver : public ServerTaskBarReceiver { +public: + MSWindowsServerTaskBarReceiver(HINSTANCE, const BufferedLogOutputter*, IEventQueue* events); + virtual ~MSWindowsServerTaskBarReceiver(); + + // IArchTaskBarReceiver overrides + virtual void showStatus(); + virtual void runMenu(int x, int y); + virtual void primaryAction(); + virtual const Icon getIcon() const; + void cleanup(); + +protected: + void copyLog() const; + + // ServerTaskBarReceiver overrides + virtual void onStatusChanged(); + +private: + HICON loadIcon(UINT); + void deleteIcon(HICON); + void createWindow(); + void destroyWindow(); + + BOOL dlgProc(HWND hwnd, + UINT msg, WPARAM wParam, LPARAM lParam); + static BOOL CALLBACK + staticDlgProc(HWND hwnd, + UINT msg, WPARAM wParam, LPARAM lParam); + +private: + HINSTANCE m_appInstance; + HWND m_window; + HMENU m_menu; + HICON m_icon[kMaxState]; + const BufferedLogOutputter* m_logBuffer; + IEventQueue* m_events; + + static const UINT s_stateToIconID[]; +}; diff --git a/src/cmd/barriers/OSXServerTaskBarReceiver.cpp b/src/cmd/barriers/OSXServerTaskBarReceiver.cpp new file mode 100644 index 0000000..bbe8fd1 --- /dev/null +++ b/src/cmd/barriers/OSXServerTaskBarReceiver.cpp @@ -0,0 +1,67 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2004 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 <http://www.gnu.org/licenses/>. + */ + +#include "OSXServerTaskBarReceiver.h" +#include "arch/Arch.h" + +// +// OSXServerTaskBarReceiver +// + +OSXServerTaskBarReceiver::OSXServerTaskBarReceiver( + const BufferedLogOutputter*, IEventQueue* events) : + ServerTaskBarReceiver(events) +{ + // add ourself to the task bar + ARCH->addReceiver(this); +} + +OSXServerTaskBarReceiver::~OSXServerTaskBarReceiver() +{ + ARCH->removeReceiver(this); +} + +void +OSXServerTaskBarReceiver::showStatus() +{ + // do nothing +} + +void +OSXServerTaskBarReceiver::runMenu(int, int) +{ + // do nothing +} + +void +OSXServerTaskBarReceiver::primaryAction() +{ + // do nothing +} + +const IArchTaskBarReceiver::Icon +OSXServerTaskBarReceiver::getIcon() const +{ + return NULL; +} + +IArchTaskBarReceiver* +createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events) +{ + return new OSXServerTaskBarReceiver(logBuffer, events); +} diff --git a/src/cmd/barriers/OSXServerTaskBarReceiver.h b/src/cmd/barriers/OSXServerTaskBarReceiver.h new file mode 100644 index 0000000..ab6928f --- /dev/null +++ b/src/cmd/barriers/OSXServerTaskBarReceiver.h @@ -0,0 +1,36 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2004 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include "barrier/ServerTaskBarReceiver.h" + +class BufferedLogOutputter; + +//! Implementation of ServerTaskBarReceiver for OS X +class OSXServerTaskBarReceiver : public ServerTaskBarReceiver { +public: + OSXServerTaskBarReceiver(const BufferedLogOutputter*, IEventQueue* events); + virtual ~OSXServerTaskBarReceiver(); + + // IArchTaskBarReceiver overrides + virtual void showStatus(); + virtual void runMenu(int x, int y); + virtual void primaryAction(); + virtual const Icon getIcon() const; +}; diff --git a/src/cmd/barriers/XWindowsServerTaskBarReceiver.cpp b/src/cmd/barriers/XWindowsServerTaskBarReceiver.cpp new file mode 100644 index 0000000..7f525c5 --- /dev/null +++ b/src/cmd/barriers/XWindowsServerTaskBarReceiver.cpp @@ -0,0 +1,67 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2003 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 <http://www.gnu.org/licenses/>. + */ + +#include "XWindowsServerTaskBarReceiver.h" +#include "arch/Arch.h" + +// +// CXWindowsServerTaskBarReceiver +// + +CXWindowsServerTaskBarReceiver::CXWindowsServerTaskBarReceiver( + const BufferedLogOutputter*, IEventQueue* events) : + ServerTaskBarReceiver(events) +{ + // add ourself to the task bar + ARCH->addReceiver(this); +} + +CXWindowsServerTaskBarReceiver::~CXWindowsServerTaskBarReceiver() +{ + ARCH->removeReceiver(this); +} + +void +CXWindowsServerTaskBarReceiver::showStatus() +{ + // do nothing +} + +void +CXWindowsServerTaskBarReceiver::runMenu(int, int) +{ + // do nothing +} + +void +CXWindowsServerTaskBarReceiver::primaryAction() +{ + // do nothing +} + +const IArchTaskBarReceiver::Icon +CXWindowsServerTaskBarReceiver::getIcon() const +{ + return NULL; +} + +IArchTaskBarReceiver* +createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events) +{ + return new CXWindowsServerTaskBarReceiver(logBuffer, events); +} diff --git a/src/cmd/barriers/XWindowsServerTaskBarReceiver.h b/src/cmd/barriers/XWindowsServerTaskBarReceiver.h new file mode 100644 index 0000000..549a62f --- /dev/null +++ b/src/cmd/barriers/XWindowsServerTaskBarReceiver.h @@ -0,0 +1,38 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2003 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include "barrier/ServerTaskBarReceiver.h" + +class BufferedLogOutputter; +class IEventQueue; + +//! Implementation of ServerTaskBarReceiver for X Windows +class CXWindowsServerTaskBarReceiver : public ServerTaskBarReceiver { +public: + CXWindowsServerTaskBarReceiver( + const BufferedLogOutputter*, IEventQueue* events); + virtual ~CXWindowsServerTaskBarReceiver(); + + // IArchTaskBarReceiver overrides + virtual void showStatus(); + virtual void runMenu(int x, int y); + virtual void primaryAction(); + virtual const Icon getIcon() const; +}; diff --git a/src/cmd/barriers/barriers.cpp b/src/cmd/barriers/barriers.cpp new file mode 100644 index 0000000..cd67bcb --- /dev/null +++ b/src/cmd/barriers/barriers.cpp @@ -0,0 +1,57 @@ +/* + * barrier -- mouse and keyboard sharing utility + * Copyright (C) 2012-2016 Symless Ltd. + * Copyright (C) 2002 Chris Schoeneman + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file LICENSE that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "barrier/ServerApp.h" +#include "arch/Arch.h" +#include "base/Log.h" +#include "base/EventQueue.h" + +#if WINAPI_MSWINDOWS +#include "MSWindowsServerTaskBarReceiver.h" +#elif WINAPI_XWINDOWS +#include "XWindowsServerTaskBarReceiver.h" +#elif WINAPI_CARBON +#include "OSXServerTaskBarReceiver.h" +#else +#error Platform not supported. +#endif + +int +main(int argc, char** argv) +{ +#if SYSAPI_WIN32 + // record window instance for tray icon, etc + ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL)); +#endif + + Arch arch; + arch.init(); + + Log log; + EventQueue events; + + ServerApp app(&events, createTaskBarReceiver); + int result = app.run(argc, argv); +#if SYSAPI_WIN32 + if (IsDebuggerPresent()) { + printf("\n\nHit a key to close...\n"); + getchar(); + } +#endif + return result; +} diff --git a/src/cmd/barriers/barriers.ico b/src/cmd/barriers/barriers.ico Binary files differnew file mode 100644 index 0000000..6e90545 --- /dev/null +++ b/src/cmd/barriers/barriers.ico diff --git a/src/cmd/barriers/barriers.rc b/src/cmd/barriers/barriers.rc new file mode 100644 index 0000000..c4d263c --- /dev/null +++ b/src/cmd/barriers/barriers.rc @@ -0,0 +1,134 @@ +// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include <winresrc.h>
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include <winresrc.h>\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_BARRIER ICON "barriers.ico"
+IDI_TASKBAR_NOT_RUNNING ICON "tb_idle.ico"
+IDI_TASKBAR_NOT_WORKING ICON "tb_error.ico"
+IDI_TASKBAR_NOT_CONNECTED ICON "tb_wait.ico"
+IDI_TASKBAR_CONNECTED ICON "tb_run.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDR_TASKBAR MENU
+BEGIN
+ POPUP "Barrier"
+ BEGIN
+ MENUITEM "Show Status", IDC_TASKBAR_STATUS
+ MENUITEM "Show Log", IDC_TASKBAR_SHOW_LOG
+ MENUITEM "Copy Log To Clipboard", IDC_TASKBAR_LOG
+ POPUP "Set Log Level"
+ BEGIN
+ MENUITEM "Error", IDC_TASKBAR_LOG_LEVEL_ERROR
+ MENUITEM "Warning", IDC_TASKBAR_LOG_LEVEL_WARNING
+ MENUITEM "Note", IDC_TASKBAR_LOG_LEVEL_NOTE
+ MENUITEM "Info", IDC_TASKBAR_LOG_LEVEL_INFO
+ MENUITEM "Debug", IDC_TASKBAR_LOG_LEVEL_DEBUG
+ MENUITEM "Debug1", IDC_TASKBAR_LOG_LEVEL_DEBUG1
+ MENUITEM "Debug2", IDC_TASKBAR_LOG_LEVEL_DEBUG2
+ END
+ MENUITEM "Reload Configuration", IDC_RELOAD_CONFIG
+ MENUITEM "Force Reconnect", IDC_FORCE_RECONNECT
+ MENUITEM "Reset Server", ID_BARRIER_RESETSERVER
+ MENUITEM SEPARATOR
+ MENUITEM "Quit", IDC_TASKBAR_QUIT
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_TASKBAR_STATUS DIALOG 0, 0, 145, 60
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP
+FONT 8, "MS Sans Serif"
+BEGIN
+ EDITTEXT IDC_TASKBAR_STATUS_STATUS,3,3,139,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ LISTBOX IDC_TASKBAR_STATUS_CLIENTS,3,17,139,40,NOT LBS_NOTIFY | LBS_SORT | LBS_NOINTEGRALHEIGHT | LBS_NOSEL | WS_VSCROLL | WS_TABSTOP
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE
+BEGIN
+ IDS_FAILED "Barrier is about to quit with errors or warnings. Please check the log then click OK."
+ IDS_INIT_FAILED "Barrier failed to initialize: %{1}"
+ IDS_UNCAUGHT_EXCEPTION "Uncaught exception: %{1}"
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/src/cmd/barriers/resource.h b/src/cmd/barriers/resource.h new file mode 100644 index 0000000..9594db1 --- /dev/null +++ b/src/cmd/barriers/resource.h @@ -0,0 +1,42 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by barriers.rc +// +#define IDS_FAILED 1 +#define IDS_INIT_FAILED 2 +#define IDS_UNCAUGHT_EXCEPTION 3 +#define IDI_BARRIER 101 +#define IDI_TASKBAR_NOT_RUNNING 102 +#define IDI_TASKBAR_NOT_WORKING 103 +#define IDI_TASKBAR_NOT_CONNECTED 104 +#define IDI_TASKBAR_CONNECTED 105 +#define IDR_TASKBAR 107 +#define IDD_TASKBAR_STATUS 108 +#define IDC_TASKBAR_STATUS_STATUS 1000 +#define IDC_TASKBAR_STATUS_CLIENTS 1001 +#define IDC_TASKBAR_QUIT 40003 +#define IDC_TASKBAR_STATUS 40004 +#define IDC_TASKBAR_LOG 40005 +#define IDC_RELOAD_CONFIG 40006 +#define IDC_FORCE_RECONNECT 40007 +#define IDC_TASKBAR_SHOW_LOG 40008 +#define IDC_TASKBAR_LOG_LEVEL_ERROR 40009 +#define IDC_TASKBAR_LOG_LEVEL_WARNING 40010 +#define IDC_TASKBAR_LOG_LEVEL_NOTE 40011 +#define IDC_TASKBAR_LOG_LEVEL_INFO 40012 +#define IDC_TASKBAR_LOG_LEVEL_DEBUG 40013 +#define IDC_TASKBAR_LOG_LEVEL_DEBUG1 40014 +#define IDC_TASKBAR_LOG_LEVEL_DEBUG2 40015 +#define ID_BARRIER_RELOADSYSTEM 40016 +#define ID_BARRIER_RESETSERVER 40017 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 109 +#define _APS_NEXT_COMMAND_VALUE 40018 +#define _APS_NEXT_CONTROL_VALUE 1003 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/cmd/barriers/tb_error.ico b/src/cmd/barriers/tb_error.ico Binary files differnew file mode 100644 index 0000000..746a87c --- /dev/null +++ b/src/cmd/barriers/tb_error.ico diff --git a/src/cmd/barriers/tb_idle.ico b/src/cmd/barriers/tb_idle.ico Binary files differnew file mode 100644 index 0000000..4e13a26 --- /dev/null +++ b/src/cmd/barriers/tb_idle.ico diff --git a/src/cmd/barriers/tb_run.ico b/src/cmd/barriers/tb_run.ico Binary files differnew file mode 100644 index 0000000..88e160c --- /dev/null +++ b/src/cmd/barriers/tb_run.ico diff --git a/src/cmd/barriers/tb_wait.ico b/src/cmd/barriers/tb_wait.ico Binary files differnew file mode 100644 index 0000000..257be0a --- /dev/null +++ b/src/cmd/barriers/tb_wait.ico diff --git a/src/cmd/syntool/CMakeLists.txt b/src/cmd/syntool/CMakeLists.txt new file mode 100644 index 0000000..863d4f4 --- /dev/null +++ b/src/cmd/syntool/CMakeLists.txt @@ -0,0 +1,27 @@ +# 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 <http://www.gnu.org/licenses/>. + +file(GLOB headers "*.h") +file(GLOB sources "*.cpp") + +add_executable(syntool ${sources}) +target_link_libraries(syntool + synlib arch base client common io ipc mt net platform server ${libs} ${OPENSSL_LIBS}) + +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + install (TARGETS syntool DESTINATION ${BARRIER_BUNDLE_BINARY_DIR}) +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + install (TARGETS syntool DESTINATION bin) +endif() diff --git a/src/cmd/syntool/syntool.cpp b/src/cmd/syntool/syntool.cpp new file mode 100644 index 0000000..72d35b9 --- /dev/null +++ b/src/cmd/syntool/syntool.cpp @@ -0,0 +1,31 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + */ + +#include "barrier/ToolApp.h" +#include "arch/Arch.h" + +int +main(int argc, char** argv) +{ +#if SYSAPI_WIN32 + // record window instance for tray icon, etc + ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL)); +#endif + + ToolApp app; + return app.run(argc, argv); +} |
