Remmina - The GTK+ Remote Desktop Client  v1.4.2
Remmina is a remote desktop client written in GTK+, aiming to be useful for system administrators and travellers, who need to work with lots of remote computers in front of either large monitors or tiny netbooks. Remmina supports multiple network protocols in an integrated and consistent user interface. Currently RDP, VNC, NX, XDMCP and SSH are supported.
rdp_plugin.h
Go to the documentation of this file.
1 /*
2  * Remmina - The GTK+ Remote Desktop Client
3  * Copyright (C) 2010-2011 Vic Lee
4  * Copyright (C) 2014-2015 Antenore Gatta, Fabio Castelli, Giovanni Panozzo
5  * Copyright (C) 2016-2020 Antenore Gatta, Giovanni Panozzo
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  * In addition, as a special exception, the copyright holders give
23  * permission to link the code of portions of this program with the
24  * OpenSSL library under certain conditions as described in each
25  * individual source file, and distribute linked combinations
26  * including the two.
27  * You must obey the GNU General Public License in all respects
28  * for all of the code used other than OpenSSL. * If you modify
29  * file(s) with this exception, you may extend this exception to your
30  * version of the file(s), but you are not obligated to do so. * If you
31  * do not wish to do so, delete this exception statement from your
32  * version. * If you delete this exception statement from all source
33  * files in the program, then also delete it here.
34  *
35  */
36 
37 #pragma once
38 
39 #include "common/remmina_plugin.h"
40 #include <freerdp/freerdp.h>
41 #include <freerdp/version.h>
42 #include <freerdp/channels/channels.h>
43 #include <freerdp/codec/color.h>
44 #include <freerdp/codec/rfx.h>
45 #include <freerdp/gdi/gdi.h>
46 #include <freerdp/gdi/dc.h>
47 #include <freerdp/gdi/region.h>
48 #include <freerdp/client/cliprdr.h>
49 #include <freerdp/client/disp.h>
50 #include <gdk/gdkx.h>
51 
52 #include <winpr/clipboard.h>
53 
54 
55 /* Constants to workaround FreeRDP issue #5417 (min resolution in AVC mode) */
56 #define AVC_MIN_DESKTOP_WIDTH 642
57 #define AVC_MIN_DESKTOP_HEIGHT 480
58 
59 typedef struct rf_context rfContext;
60 
61 #define GET_PLUGIN_DATA(gp) (rfContext *)g_object_get_data(G_OBJECT(gp), "plugin-data")
62 
63 #define DEFAULT_QUALITY_0 0x6f
64 #define DEFAULT_QUALITY_1 0x07
65 #define DEFAULT_QUALITY_2 0x01
66 #define DEFAULT_QUALITY_9 0x80
67 
69 
70 struct rf_clipboard {
72  CliprdrClientContext * context;
73  wClipboard * system;
75 
76  UINT32 format;
78 
79  pthread_mutex_t transfer_clip_mutex;
80  pthread_cond_t transfer_clip_cond;
82  gpointer srv_data;
83 };
84 typedef struct rf_clipboard rfClipboard;
85 
86 
87 struct rf_pointer {
88  rdpPointer pointer;
89  GdkCursor * cursor;
90 };
91 typedef struct rf_pointer rfPointer;
92 
93 struct rf_bitmap {
94  rdpBitmap bitmap;
95  Pixmap pixmap;
96  cairo_surface_t * surface;
97 };
98 typedef struct rf_bitmap rfBitmap;
99 
100 struct rf_glyph {
101  rdpGlyph glyph;
102  Pixmap pixmap;
103 };
104 typedef struct rf_glyph rfGlyph;
105 
106 typedef enum {
116 
119  union {
120  struct {
121  BOOL up;
122  BOOL extended;
123  UINT8 key_code;
124  UINT32 unicode_code;
125  } key_event;
126  struct {
127  UINT16 flags;
128  UINT16 x;
129  UINT16 y;
130  BOOL extended;
131  } mouse_event;
132  struct {
133  CLIPRDR_FORMAT_LIST *pFormatList;
134  } clipboard_formatlist;
135  struct {
136  BYTE * data;
137  int size;
138  } clipboard_formatdataresponse;
139  struct {
140  CLIPRDR_FORMAT_DATA_REQUEST *pFormatDataRequest;
141  } clipboard_formatdatarequest;
142  struct {
143  gint width;
144  gint height;
148  } monitor_layout;
149  };
150 };
152 
153 typedef enum {
163 
164 typedef enum {
170 
171 typedef enum {
179 
180 typedef enum {
184 
185 typedef struct {
186  gint x, y, w, h;
187 } region;
188 
191  gboolean sync;
192  gboolean complete;
193  pthread_mutex_t sync_wait_mutex;
194  pthread_cond_t sync_wait_cond;
195  union {
196  struct {
198  gint ninvalid;
199  } reg;
200  struct {
201  rdpContext * context;
204  } cursor;
205  struct {
206  gint left;
207  gint top;
208  RFX_MESSAGE * message;
209  } rfx;
210  struct {
211  gint left;
212  gint top;
213  gint width;
214  gint height;
215  UINT8 * bitmap;
216  } nocodec;
217  struct {
219  GtkTargetList * targetlist;
220  UINT32 format;
222  gpointer data;
223  } clipboard;
224  struct {
226  } event;
227  struct {
228  gint x;
229  gint y;
230  } pos;
231  };
232  /* We can also return values here, usually integers*/
233  int retval;
234  /* Some functions also may return a pointer. */
235  void * retptr;
236 };
237 
239  unsigned orig_keycode;
242 
243 struct rf_context {
244  rdpContext context;
245  DEFINE_RDP_CLIENT_COMMON();
246 
248 
249  /* main */
250  rdpSettings * settings;
251  freerdp * instance;
252 
255  gboolean user_cancelled;
257 
258  CliprdrClientContext * cliprdr;
259  DispClientContext * dispcontext;
260 
261  RDP_PLUGIN_DATA rdpdr_data[5];
262  RDP_PLUGIN_DATA drdynvc_data[5];
263  gchar rdpsnd_options[20];
264 
265  RFX_CONTEXT * rfx_context;
266  gboolean rdpgfxchan;
267 
268  gboolean connected;
269  gboolean is_reconnecting;
270  /* orphaned: rf_context has still one or more libfreerdp thread active,
271  * but no longer maintained by an open RemminaProtocolWidget/tab.
272  * When the orphaned thread terminates, we must cleanup rf_context.
273  */
274  gboolean orphaned;
277 
278  gboolean sw_gdi;
279  GtkWidget * drawing_area;
282  gdouble scale_x;
283  gdouble scale_y;
286 
287  gint srcBpp;
288  GdkDisplay * display;
289  GdkVisual * visual;
290  cairo_surface_t * surface;
291  cairo_format_t cairo_format;
292  gint bpp;
294  gint * colormap;
295 
297  GHashTable * object_table;
298 
299  GAsyncQueue * ui_queue;
300  pthread_mutex_t ui_queue_mutex;
301  guint ui_handler;
302 
303  GArray * pressed_keys;
304  GAsyncQueue * event_queue;
305  gint event_pipe[2];
306  HANDLE event_handle;
307 
309 
310  GArray * keymap; /* Array of RemminaPluginRdpKeymapEntry */
311 
313 
314  enum { REMMINA_POSTCONNECT_ERROR_OK = 0, REMMINA_POSTCONNECT_ERROR_GDI_INIT = 1, REMMINA_POSTCONNECT_ERROR_NO_H264 } postconnect_error;
315 };
316 
318 
321 void rf_get_fds(RemminaProtocolWidget *gp, void **rfds, int *rcount);
324 
void remmina_rdp_event_event_push(RemminaProtocolWidget *gp, const RemminaPluginRdpEvent *e)
Definition: rdp_event.c:92
CliprdrClientContext * context
Definition: rdp_plugin.h:72
gboolean thread_cancelled
Definition: rdp_plugin.h:256
gboolean is_reconnecting
Definition: rdp_plugin.h:269
gulong clipboard_handler
Definition: rdp_plugin.h:77
RemminaPluginRdpUiClipboardType type
Definition: rdp_plugin.h:218
gint y
Definition: rdp_plugin.h:186
Pixmap pixmap
Definition: rdp_plugin.h:95
guint delayed_monitor_layout_handler
Definition: rdp_plugin.h:284
RemminaPluginRdpUiEeventType
Definition: rdp_plugin.h:180
gboolean user_cancelled
Definition: rdp_plugin.h:255
CLIPRDR_FORMAT_LIST * pFormatList
Definition: rdp_plugin.h:133
gboolean attempt_interactive_authentication
Definition: rdp_plugin.h:312
gdouble scale_y
Definition: rdp_plugin.h:283
RemminaPluginRdpUiType
Definition: rdp_plugin.h:153
enum rf_clipboard::@39 srv_clip_data_wait
cairo_surface_t * surface
Definition: rdp_plugin.h:290
pthread_t remmina_plugin_thread
Definition: rdp_plugin.h:253
RemminaPluginService * remmina_plugin_service
Definition: rdp_plugin.c:89
pthread_mutex_t transfer_clip_mutex
Definition: rdp_plugin.h:79
gboolean rdpgfxchan
Definition: rdp_plugin.h:266
int requestedFormatId
Definition: rdp_plugin.h:74
guint ui_handler
Definition: rdp_plugin.h:301
void rf_object_free(RemminaProtocolWidget *gp, RemminaPluginRdpUiObject *obj)
GdkDisplay * display
Definition: rdp_plugin.h:288
GAsyncQueue * ui_queue
Definition: rdp_plugin.h:299
RemminaPluginRdpEventType
Definition: rdp_plugin.h:106
pthread_mutex_t sync_wait_mutex
Definition: rdp_plugin.h:193
RemminaProtocolWidget * protocol_widget
Definition: rdp_plugin.h:247
int reconnect_nattempt
Definition: rdp_plugin.h:276
void rf_init(RemminaProtocolWidget *gp)
rfContext * rfi
Definition: rdp_plugin.h:71
GdkVisual * visual
Definition: rdp_plugin.h:289
gdouble scale_x
Definition: rdp_plugin.h:282
gpointer srv_data
Definition: rdp_plugin.h:82
rdpBitmap bitmap
Definition: rdp_plugin.h:94
GtkTargetList * targetlist
Definition: rdp_plugin.h:219
BOOL rf_check_fds(RemminaProtocolWidget *gp)
int reconnect_maxattempts
Definition: rdp_plugin.h:275
RemminaPluginRdpEventType type
Definition: rdp_plugin.h:118
RemminaPluginRdpUiPointerType type
Definition: rdp_plugin.h:203
pthread_cond_t transfer_clip_cond
Definition: rdp_plugin.h:80
rdpPointer pointer
Definition: rdp_plugin.h:88
Pixmap pixmap
Definition: rdp_plugin.h:102
unsigned translated_keycode
Definition: rdp_plugin.h:240
GtkWidget * drawing_area
Definition: rdp_plugin.h:279
cairo_format_t cairo_format
Definition: rdp_plugin.h:291
RemminaPluginRdpUiClipboardType
Definition: rdp_plugin.h:164
gboolean use_client_keymap
Definition: rdp_plugin.h:285
GArray * keymap
Definition: rdp_plugin.h:310
RemminaPluginRdpUiPointerType
Definition: rdp_plugin.h:171
gint scanline_pad
Definition: rdp_plugin.h:293
unsigned orig_keycode
Definition: rdp_plugin.h:239
GdkCursor * cursor
Definition: rdp_plugin.h:89
wClipboard * system
Definition: rdp_plugin.h:73
void rf_uninit(RemminaProtocolWidget *gp)
struct remmina_plugin_rdp_keymap_entry RemminaPluginRdpKeymapEntry
gint * colormap
Definition: rdp_plugin.h:294
void rf_get_fds(RemminaProtocolWidget *gp, void **rfds, int *rcount)
guint object_id_seq
Definition: rdp_plugin.h:296
GAsyncQueue * event_queue
Definition: rdp_plugin.h:304
pthread_cond_t sync_wait_cond
Definition: rdp_plugin.h:194
rfClipboard clipboard
Definition: rdp_plugin.h:308
HANDLE event_handle
Definition: rdp_plugin.h:306
GHashTable * object_table
Definition: rdp_plugin.h:297
RemminaScaleMode
Definition: types.h:117
CLIPRDR_FORMAT_DATA_REQUEST * pFormatDataRequest
Definition: rdp_plugin.h:140
gint srcBpp
Definition: rdp_plugin.h:287
gboolean connected
Definition: rdp_plugin.h:268
RemminaScaleMode scale
Definition: rdp_plugin.h:254
freerdp * instance
Definition: rdp_plugin.h:251
DispClientContext * dispcontext
Definition: rdp_plugin.h:259
RemminaPluginRdpUiEeventType type
Definition: rdp_plugin.h:225
GArray * pressed_keys
Definition: rdp_plugin.h:303
rdpSettings * settings
Definition: rdp_plugin.h:250
gint scale_height
Definition: rdp_plugin.h:281
Definition: rdp_plugin.h:238
UINT32 format
Definition: rdp_plugin.h:76
RFX_CONTEXT * rfx_context
Definition: rdp_plugin.h:265
gboolean orphaned
Definition: rdp_plugin.h:274
rdpGlyph glyph
Definition: rdp_plugin.h:101
rdpContext context
Definition: rdp_plugin.h:244
gint scale_width
Definition: rdp_plugin.h:280
pthread_mutex_t ui_queue_mutex
Definition: rdp_plugin.h:300
cairo_surface_t * surface
Definition: rdp_plugin.h:96
gboolean sw_gdi
Definition: rdp_plugin.h:278
RemminaPluginRdpUiType type
Definition: rdp_plugin.h:190
CliprdrClientContext * cliprdr
Definition: rdp_plugin.h:258