1 /*
2  * barrier -- mouse and keyboard sharing utility
3  * Copyright (C) 2012-2016 Symless Ltd.
4  * Copyright (C) 2002 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 "server/BaseClientProxy.h"
22 #include "base/Event.h"
23 #include "base/EventTypes.h"
24 
25 namespace barrier { class IStream; }
26 
27 //! Generic proxy for client
28 class ClientProxy : public BaseClientProxy {
29 public:
30     /*!
31     \c name is the name of the client.
32     */
33     ClientProxy(const std::string& name, barrier::IStream* adoptedStream);
34     ~ClientProxy();
35 
36     //! @name manipulators
37     //@{
38 
39     //! Disconnect
40     /*!
41     Ask the client to disconnect, using \p msg as the reason.
42     */
43     void                close(const char* msg);
44 
45     //@}
46     //! @name accessors
47     //@{
48 
49     //! Get stream
50     /*!
51     Returns the original stream passed to the c'tor.
52     */
53     barrier::IStream*    getStream() const;
54 
55     //@}
56 
57     // IScreen
58     virtual void*        getEventTarget() const;
59     virtual bool        getClipboard(ClipboardID id, IClipboard*) const = 0;
60     virtual void        getShape(SInt32& x, SInt32& y,
61                             SInt32& width, SInt32& height) const = 0;
62     virtual void        getCursorPos(SInt32& x, SInt32& y) const = 0;
63 
64     // IClient overrides
65     virtual void        enter(SInt32 xAbs, SInt32 yAbs,
66                             UInt32 seqNum, KeyModifierMask mask,
67                             bool forScreensaver) = 0;
68     virtual bool        leave() = 0;
69     virtual void        setClipboard(ClipboardID, const IClipboard*) = 0;
70     virtual void        grabClipboard(ClipboardID) = 0;
71     virtual void        setClipboardDirty(ClipboardID, bool) = 0;
72     virtual void        keyDown(KeyID, KeyModifierMask, KeyButton) = 0;
73     virtual void        keyRepeat(KeyID, KeyModifierMask,
74                             SInt32 count, KeyButton) = 0;
75     virtual void        keyUp(KeyID, KeyModifierMask, KeyButton) = 0;
76     virtual void        mouseDown(ButtonID) = 0;
77     virtual void        mouseUp(ButtonID) = 0;
78     virtual void        mouseMove(SInt32 xAbs, SInt32 yAbs) = 0;
79     virtual void        mouseRelativeMove(SInt32 xRel, SInt32 yRel) = 0;
80     virtual void        mouseWheel(SInt32 xDelta, SInt32 yDelta) = 0;
81     virtual void        screensaver(bool activate) = 0;
82     virtual void        resetOptions() = 0;
83     virtual void        setOptions(const OptionsList& options) = 0;
84     virtual void        sendDragInfo(UInt32 fileCount, const char* info,
85                             size_t size) = 0;
86     virtual void        fileChunkSending(UInt8 mark, char* data, size_t dataSize) = 0;
87 
88 private:
89     barrier::IStream*    m_stream;
90 };
91