1 /*
2  * barrier -- mouse and keyboard sharing utility
3  * Copyright (C) 2012-2016 Symless Ltd.
4  * Copyright (C) 2003 Chris Schoeneman
5  *
6  * This package is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * found in the file LICENSE that should have accompanied this file.
9  *
10  * This package is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include "barrier/ServerTaskBarReceiver.h"
22 
23 #define WIN32_LEAN_AND_MEAN
24 #include <Windows.h>
25 
26 class BufferedLogOutputter;
27 class IEventQueue;
28 
29 //! Implementation of ServerTaskBarReceiver for Microsoft Windows
30 class MSWindowsServerTaskBarReceiver : public ServerTaskBarReceiver {
31 public:
32     MSWindowsServerTaskBarReceiver(HINSTANCE, const BufferedLogOutputter*, IEventQueue* events);
33     virtual ~MSWindowsServerTaskBarReceiver();
34 
35     // IArchTaskBarReceiver overrides
36     virtual void        showStatus();
37     virtual void        runMenu(int x, int y);
38     virtual void        primaryAction();
39     virtual const Icon    getIcon() const;
40     void cleanup();
41 
42 protected:
43     void                copyLog() const;
44 
45     // ServerTaskBarReceiver overrides
46     virtual void        onStatusChanged();
47 
48 private:
49     HICON                loadIcon(UINT);
50     void                deleteIcon(HICON);
51     void                createWindow();
52     void                destroyWindow();
53 
54     BOOL                dlgProc(HWND hwnd,
55                             UINT msg, WPARAM wParam, LPARAM lParam);
56     static BOOL CALLBACK
57                         staticDlgProc(HWND hwnd,
58                             UINT msg, WPARAM wParam, LPARAM lParam);
59 
60 private:
61     HINSTANCE            m_appInstance;
62     HWND                m_window;
63     HMENU                m_menu;
64     HICON                m_icon[kMaxState];
65     const BufferedLogOutputter*    m_logBuffer;
66     IEventQueue*        m_events;
67 
68     static const UINT    s_stateToIconID[];
69 };
70