1 /*
2 Copyright 2005-2017 Jay Sorg
3 
4 Permission to use, copy, modify, distribute, and sell this software and its
5 documentation for any purpose is hereby granted without fee, provided that
6 the above copyright notice appear in all copies and that both that
7 copyright notice and this permission notice appear in supporting
8 documentation.
9 
10 The above copyright notice and this permission notice shall be included in
11 all copies or substantial portions of the Software.
12 
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
16 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
17 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 
20 Client connection to xrdp
21 
22 */
23 
24 #include <xorg-server.h>
25 #include <xorgVersion.h>
26 #include <xf86.h>
27 
28 #include "xrdp_client_info.h"
29 
30 #ifndef _RDPCLIENTCON_H
31 #define _RDPCLIENTCON_H
32 
33 /* used in rdpGlyphs.c */
34 struct font_cache
35 {
36     int offset;
37     int baseline;
38     int width;
39     int height;
40     int crc;
41     int stamp;
42 };
43 
44 struct rdpup_os_bitmap
45 {
46     int used;
47     PixmapPtr pixmap;
48     rdpPixmapPtr priv;
49     int stamp;
50 };
51 
52 enum shared_memory_status {
53     SHM_UNINITIALIZED = 0,
54     SHM_RESIZING,
55     SHM_ACTIVE,
56     SHM_RFX_ACTIVE,
57     SHM_H264_ACTIVE
58 };
59 
60 /* one of these for each client */
61 struct _rdpClientCon
62 {
63     rdpPtr dev;
64 
65     int sck;
66     int sckControlListener;
67     int sckControl;
68     struct stream *out_s;
69     struct stream *in_s;
70 
71     int rectIdAck;
72     int rectId;
73     int connected; /* boolean. Set to False when I/O fails */
74     int begin; /* boolean */
75     int count;
76     struct rdpup_os_bitmap *osBitmaps;
77     int maxOsBitmaps;
78     int osBitmapStamp;
79     int osBitmapAllocSize;
80     int osBitmapNumUsed;
81     int doComposite;
82     int doGlyphCache;
83     int canDoPixToPix;
84     int doMultimon;
85 
86     int rdp_bpp; /* client depth */
87     int rdp_Bpp;
88     int rdp_Bpp_mask;
89     int rdp_width;
90     int rdp_height;
91     int rdp_format; /* XRDP_a8r8g8b8, XRDP_r5g6b5, ... */
92     int cap_left;
93     int cap_top;
94     int cap_width;
95     int cap_height;
96     int cap_stride_bytes;
97 
98     int rdpIndex; /* current os target */
99 
100     int conNumber;
101 
102     /* rdpGlyphs.c */
103     struct font_cache font_cache[12][256];
104     int font_stamp;
105 
106     struct xrdp_client_info client_info;
107 
108     uint8_t *shmemptr;
109     int shmemid;
110     int shmem_lineBytes;
111     RegionPtr shmRegion;
112     int rect_id;
113     int rect_id_ack;
114     enum shared_memory_status shmemstatus;
115 
116     OsTimerPtr updateTimer;
117     CARD32 lastUpdateTime; /* millisecond timestamp */
118     int updateScheduled; /* boolean */
119     int updateRetries;
120 
121     RegionPtr dirtyRegion;
122 
123     int num_rfx_crcs_alloc;
124     int *rfx_crcs;
125 
126     /* true = skip drawing */
127     int suppress_output;
128 
129     struct _rdpClientCon *next;
130     struct _rdpClientCon *prev;
131 };
132 
133 extern _X_EXPORT int
134 rdpClientConBeginUpdate(rdpPtr dev, rdpClientCon *clientCon);
135 extern _X_EXPORT int
136 rdpClientConEndUpdate(rdpPtr dev, rdpClientCon *clientCon);
137 extern _X_EXPORT int
138 rdpClientConSetFgcolor(rdpPtr dev, rdpClientCon *clientCon, int fgcolor);
139 extern _X_EXPORT void
140 rdpClientConSendArea(rdpPtr dev, rdpClientCon *clientCon,
141                      struct image_data *id, int x, int y, int w, int h);
142 extern _X_EXPORT int
143 rdpClientConFillRect(rdpPtr dev, rdpClientCon *clientCon,
144                      short x, short y, int cx, int cy);
145 extern _X_EXPORT int
146 rdpClientConCheck(ScreenPtr pScreen);
147 extern _X_EXPORT int
148 rdpClientConInit(rdpPtr dev);
149 extern _X_EXPORT int
150 rdpClientConDeinit(rdpPtr dev);
151 
152 extern _X_EXPORT int
153 rdpClientConDeleteOsSurface(rdpPtr dev, rdpClientCon *clientCon, int rdpindex);
154 
155 extern _X_EXPORT int
156 rdpClientConRemoveOsBitmap(rdpPtr dev, rdpClientCon *clientCon, int rdpindex);
157 
158 extern _X_EXPORT void
159 rdpClientConScheduleDeferredUpdate(rdpPtr dev);
160 extern _X_EXPORT int
161 rdpClientConCheckDirtyScreen(rdpPtr dev, rdpClientCon *clientCon);
162 extern _X_EXPORT int
163 rdpClientConAddDirtyScreenReg(rdpPtr dev, rdpClientCon *clientCon,
164                               RegionPtr reg);
165 extern _X_EXPORT int
166 rdpClientConAddDirtyScreenBox(rdpPtr dev, rdpClientCon *clientCon,
167                               BoxPtr box);
168 extern _X_EXPORT int
169 rdpClientConAddDirtyScreen(rdpPtr dev, rdpClientCon *clientCon,
170                            int x, int y, int cx, int cy);
171 extern _X_EXPORT void
172 rdpClientConGetScreenImageRect(rdpPtr dev, rdpClientCon *clientCon,
173                                struct image_data *id);
174 extern _X_EXPORT int
175 rdpClientConAddAllReg(rdpPtr dev, RegionPtr reg, DrawablePtr pDrawable);
176 extern _X_EXPORT int
177 rdpClientConAddAllBox(rdpPtr dev, BoxPtr box, DrawablePtr pDrawable);
178 extern _X_EXPORT int
179 rdpClientConSetCursor(rdpPtr dev, rdpClientCon *clientCon,
180                       short x, short y, uint8_t *cur_data, uint8_t *cur_mask);
181 extern _X_EXPORT int
182 rdpClientConSetCursorEx(rdpPtr dev, rdpClientCon *clientCon,
183                         short x, short y, uint8_t *cur_data,
184                         uint8_t *cur_mask, int bpp);
185 
186 #endif
187