1 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
2  * Copyright 2014-2019 Pierre Ossman for Cendio AB
3  *
4  * This is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This software is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this software; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
17  * USA.
18  */
19 //
20 // ClientParams - structure describing the current state of the remote client
21 //
22 
23 #ifndef __RFB_CLIENTPARAMS_H__
24 #define __RFB_CLIENTPARAMS_H__
25 
26 #include <set>
27 
28 #include <rdr/types.h>
29 #include <rfb/Cursor.h>
30 #include <rfb/PixelFormat.h>
31 #include <rfb/ScreenSet.h>
32 
33 namespace rfb {
34 
35   const int subsampleUndefined = -1;
36   const int subsampleNone = 0;
37   const int subsampleGray = 1;
38   const int subsample2X = 2;
39   const int subsample4X = 3;
40   const int subsample8X = 4;
41   const int subsample16X = 5;
42 
43   class ClientParams {
44   public:
45     ClientParams();
46     ~ClientParams();
47 
48     int majorVersion;
49     int minorVersion;
50 
setVersion(int major,int minor)51     void setVersion(int major, int minor) {
52       majorVersion = major; minorVersion = minor;
53     }
isVersion(int major,int minor)54     bool isVersion(int major, int minor) const {
55       return majorVersion == major && minorVersion == minor;
56     }
beforeVersion(int major,int minor)57     bool beforeVersion(int major, int minor) const {
58       return (majorVersion < major ||
59               (majorVersion == major && minorVersion < minor));
60     }
afterVersion(int major,int minor)61     bool afterVersion(int major, int minor) const {
62       return !beforeVersion(major,minor+1);
63     }
64 
width()65     const int width() const { return width_; }
height()66     const int height() const { return height_; }
screenLayout()67     const ScreenSet& screenLayout() const { return screenLayout_; }
68     void setDimensions(int width, int height);
69     void setDimensions(int width, int height, const ScreenSet& layout);
70 
pf()71     const PixelFormat& pf() const { return pf_; }
72     void setPF(const PixelFormat& pf);
73 
name()74     const char* name() const { return name_; }
75     void setName(const char* name);
76 
cursor()77     const Cursor& cursor() const { return *cursor_; }
78     void setCursor(const Cursor& cursor);
79 
cursorPos()80     const Point& cursorPos() const { return cursorPos_; }
81     void setCursorPos(const Point& pos);
82 
83     bool supportsEncoding(rdr::S32 encoding) const;
84 
85     void setEncodings(int nEncodings, const rdr::S32* encodings);
86 
ledState()87     unsigned int ledState() { return ledState_; }
88     void setLEDState(unsigned int state);
89 
clipboardFlags()90     rdr::U32 clipboardFlags() const { return clipFlags; }
91     rdr::U32 clipboardSize(unsigned int format) const;
92     void setClipboardCaps(rdr::U32 flags, const rdr::U32* lengths);
93 
94     // Wrappers to check for functionality rather than specific
95     // encodings
96     bool supportsLocalCursor() const;
97     bool supportsCursorPosition() const;
98     bool supportsDesktopSize() const;
99     bool supportsLEDState() const;
100     bool supportsFence() const;
101     bool supportsContinuousUpdates() const;
102 
103     int compressLevel;
104     int qualityLevel;
105     int fineQualityLevel;
106     int subsampling;
107 
108   private:
109 
110     int width_;
111     int height_;
112     ScreenSet screenLayout_;
113 
114     PixelFormat pf_;
115     char* name_;
116     Cursor* cursor_;
117     Point cursorPos_;
118     std::set<rdr::S32> encodings_;
119     unsigned int ledState_;
120     rdr::U32 clipFlags;
121     rdr::U32 clipSizes[16];
122   };
123 }
124 #endif
125