summaryrefslogtreecommitdiffstats
path: root/src/cmd/barrierc
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/barrierc')
-rw-r--r--src/cmd/barrierc/.gitignore1
-rw-r--r--src/cmd/barrierc/CMakeLists.txt57
-rw-r--r--src/cmd/barrierc/MSWindowsClientTaskBarReceiver.cpp376
-rw-r--r--src/cmd/barrierc/MSWindowsClientTaskBarReceiver.h68
-rw-r--r--src/cmd/barrierc/OSXClientTaskBarReceiver.cpp69
-rw-r--r--src/cmd/barrierc/OSXClientTaskBarReceiver.h37
-rw-r--r--src/cmd/barrierc/XWindowsClientTaskBarReceiver.cpp68
-rw-r--r--src/cmd/barrierc/XWindowsClientTaskBarReceiver.h38
-rw-r--r--src/cmd/barrierc/barrierc.cpp58
-rw-r--r--src/cmd/barrierc/barrierc.icobin0 -> 121502 bytes
-rw-r--r--src/cmd/barrierc/barrierc.rc141
-rw-r--r--src/cmd/barrierc/resource.h37
-rw-r--r--src/cmd/barrierc/tb_error.icobin0 -> 318 bytes
-rw-r--r--src/cmd/barrierc/tb_idle.icobin0 -> 318 bytes
-rw-r--r--src/cmd/barrierc/tb_run.icobin0 -> 318 bytes
-rw-r--r--src/cmd/barrierc/tb_wait.icobin0 -> 318 bytes
16 files changed, 950 insertions, 0 deletions
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
new file mode 100644
index 0000000..6e90545
--- /dev/null
+++ b/src/cmd/barrierc/barrierc.ico
Binary files differ
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
new file mode 100644
index 0000000..746a87c
--- /dev/null
+++ b/src/cmd/barrierc/tb_error.ico
Binary files differ
diff --git a/src/cmd/barrierc/tb_idle.ico b/src/cmd/barrierc/tb_idle.ico
new file mode 100644
index 0000000..4e13a26
--- /dev/null
+++ b/src/cmd/barrierc/tb_idle.ico
Binary files differ
diff --git a/src/cmd/barrierc/tb_run.ico b/src/cmd/barrierc/tb_run.ico
new file mode 100644
index 0000000..88e160c
--- /dev/null
+++ b/src/cmd/barrierc/tb_run.ico
Binary files differ
diff --git a/src/cmd/barrierc/tb_wait.ico b/src/cmd/barrierc/tb_wait.ico
new file mode 100644
index 0000000..257be0a
--- /dev/null
+++ b/src/cmd/barrierc/tb_wait.ico
Binary files differ