aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmd/barriers
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/barriers')
-rw-r--r--src/cmd/barriers/.gitignore1
-rw-r--r--src/cmd/barriers/CMakeLists.txt58
-rw-r--r--src/cmd/barriers/MSWindowsServerTaskBarReceiver.cpp408
-rw-r--r--src/cmd/barriers/MSWindowsServerTaskBarReceiver.h69
-rw-r--r--src/cmd/barriers/OSXServerTaskBarReceiver.cpp67
-rw-r--r--src/cmd/barriers/OSXServerTaskBarReceiver.h36
-rw-r--r--src/cmd/barriers/XWindowsServerTaskBarReceiver.cpp67
-rw-r--r--src/cmd/barriers/XWindowsServerTaskBarReceiver.h38
-rw-r--r--src/cmd/barriers/barriers.cpp57
-rw-r--r--src/cmd/barriers/barriers.icobin0 -> 121502 bytes
-rw-r--r--src/cmd/barriers/barriers.rc134
-rw-r--r--src/cmd/barriers/resource.h42
-rw-r--r--src/cmd/barriers/tb_error.icobin0 -> 318 bytes
-rw-r--r--src/cmd/barriers/tb_idle.icobin0 -> 318 bytes
-rw-r--r--src/cmd/barriers/tb_run.icobin0 -> 318 bytes
-rw-r--r--src/cmd/barriers/tb_wait.icobin0 -> 318 bytes
16 files changed, 977 insertions, 0 deletions
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
new file mode 100644
index 0000000..6e90545
--- /dev/null
+++ b/src/cmd/barriers/barriers.ico
Binary files differ
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
new file mode 100644
index 0000000..746a87c
--- /dev/null
+++ b/src/cmd/barriers/tb_error.ico
Binary files differ
diff --git a/src/cmd/barriers/tb_idle.ico b/src/cmd/barriers/tb_idle.ico
new file mode 100644
index 0000000..4e13a26
--- /dev/null
+++ b/src/cmd/barriers/tb_idle.ico
Binary files differ
diff --git a/src/cmd/barriers/tb_run.ico b/src/cmd/barriers/tb_run.ico
new file mode 100644
index 0000000..88e160c
--- /dev/null
+++ b/src/cmd/barriers/tb_run.ico
Binary files differ
diff --git a/src/cmd/barriers/tb_wait.ico b/src/cmd/barriers/tb_wait.ico
new file mode 100644
index 0000000..257be0a
--- /dev/null
+++ b/src/cmd/barriers/tb_wait.ico
Binary files differ