Welcome to mirror list, hosted at ThFree Co, Russian Federation.

rdp_plugin.h « rdp « remmina-plugins - gitlab.com/Remmina/Remmina.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 35395c5d5ffdd3a3bb11b7d9dd8b1cfc0eaf89d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/*
 * Remmina - The GTK+ Remote Desktop Client
 * Copyright (C) 2010-2011 Vic Lee
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 *  In addition, as a special exception, the copyright holders give
 *  permission to link the code of portions of this program with the
 *  OpenSSL library under certain conditions as described in each
 *  individual source file, and distribute linked combinations
 *  including the two.
 *  You must obey the GNU General Public License in all respects
 *  for all of the code used other than OpenSSL. *  If you modify
 *  file(s) with this exception, you may extend this exception to your
 *  version of the file(s), but you are not obligated to do so. *  If you
 *  do not wish to do so, delete this exception statement from your
 *  version. *  If you delete this exception statement from all source
 *  files in the program, then also delete it here.
 *
 */

#ifndef __REMMINA_RDP_H__
#define __REMMINA_RDP_H__

#include "common/remmina_plugin.h"
#include <freerdp/freerdp.h>
#include <freerdp/channels/channels.h>
#include <freerdp/codec/color.h>
#include <freerdp/codec/rfx.h>
#include <freerdp/gdi/gdi.h>
#include <freerdp/gdi/dc.h>
#include <freerdp/gdi/region.h>
#include <gdk/gdkx.h>

typedef struct rf_context rfContext;

#define LOCK_BUFFER(t)	  	if (t) {CANCEL_DEFER} pthread_mutex_lock(&rfi->mutex);
#define UNLOCK_BUFFER(t)	pthread_mutex_unlock(&rfi->mutex); if (t) {CANCEL_ASYNC}

#define GET_DATA(_rfi)		(rfContext*) g_object_get_data(G_OBJECT(_rfi), "plugin-data")

#define DEFAULT_QUALITY_0	0x6f
#define DEFAULT_QUALITY_1	0x07
#define DEFAULT_QUALITY_2	0x01
#define DEFAULT_QUALITY_9	0x80

extern RemminaPluginService* remmina_plugin_service;

struct rf_pointer
{
	rdpPointer pointer;
	GdkCursor* cursor;
};
typedef struct rf_pointer rfPointer;

struct rf_bitmap
{
	rdpBitmap bitmap;
	Pixmap pixmap;
	cairo_surface_t* surface;
};
typedef struct rf_bitmap rfBitmap;

struct rf_glyph
{
	rdpGlyph glyph;
	Pixmap pixmap;
};
typedef struct rf_glyph rfGlyph;

struct rf_context
{
	rdpContext _p;

	RemminaProtocolWidget* protocol_widget;

	/* main */
	rdpSettings* settings;
	freerdp* instance;
	// rdpChannels* channels;

	pthread_t thread;
	pthread_mutex_t mutex;
	gboolean scale;
	gboolean user_cancelled;

	GMutex* gmutex;
	GCond* gcond;

	RDP_PLUGIN_DATA rdpdr_data[5];
	RDP_PLUGIN_DATA drdynvc_data[5];
	gchar rdpsnd_options[20];

	RFX_CONTEXT* rfx_context;

	gboolean connected;

	gboolean sw_gdi;
	GtkWidget* drawing_area;
	gint scale_width;
	gint scale_height;
	gdouble scale_x;
	gdouble scale_y;
	guint scale_handler;
	gboolean use_client_keymap;

	HGDI_DC hdc;
	gint srcBpp;
	GdkDisplay* display;
	GdkVisual* visual;
	cairo_surface_t* surface;
	cairo_format_t cairo_format;
	gint bpp;
	gint width;
	gint height;
	gint scanline_pad;
	gint* colormap;
	HCLRCONV clrconv;
	UINT8* primary_buffer;

	guint object_id_seq;
	GHashTable* object_table;

	GAsyncQueue* ui_queue;
	guint ui_handler;

	GArray* pressed_keys;
	GAsyncQueue* event_queue;
	gint event_pipe[2];

	GAsyncQueue* clipboard_queue;
	UINT32 format;
	gboolean clipboard_wait;
	gulong clipboard_handler;
};

typedef enum
{
	REMMINA_RDP_EVENT_TYPE_SCANCODE,
	REMMINA_RDP_EVENT_TYPE_MOUSE
} RemminaPluginRdpEventType;

struct remmina_plugin_rdp_event
{
	RemminaPluginRdpEventType type;
	union
	{
		struct
		{
			BOOL up;
			BOOL extended;
			UINT8 key_code;
		} key_event;
		struct
		{
			UINT16 flags;
			UINT16 x;
			UINT16 y;
		} mouse_event;
	};
};
typedef struct remmina_plugin_rdp_event RemminaPluginRdpEvent;

typedef enum
{
	REMMINA_RDP_UI_UPDATE_REGION = 0,
	REMMINA_RDP_UI_CONNECTED,
	REMMINA_RDP_UI_CURSOR,
	REMMINA_RDP_UI_RFX,
	REMMINA_RDP_UI_NOCODEC,
	REMMINA_RDP_UI_CLIPBOARD
} RemminaPluginRdpUiType;

typedef enum
{
	REMMINA_RDP_UI_CLIPBOARD_FORMATLIST,
	REMMINA_RDP_UI_CLIPBOARD_GET_DATA,
	REMMINA_RDP_UI_CLIPBOARD_SET_DATA
} RemminaPluginRdpUiClipboardType;

typedef enum
{
	REMMINA_RDP_POINTER_NEW,
	REMMINA_RDP_POINTER_FREE,
	REMMINA_RDP_POINTER_SET,
	REMMINA_RDP_POINTER_NULL,
	REMMINA_RDP_POINTER_DEFAULT
} RemminaPluginRdpUiPointerType;

struct remmina_plugin_rdp_ui_object
{
	RemminaPluginRdpUiType type;
	union
	{
		struct
		{
			gint x;
			gint y;
			gint width;
			gint height;
		} region;
		struct
		{
			rfPointer* pointer;
			RemminaPluginRdpUiPointerType type;
		} cursor;
		struct
		{
			gint left;
			gint top;
			RFX_MESSAGE* message;
		} rfx;
		struct
		{
			gint left;
			gint top;
			gint width;
			gint height;
			UINT8* bitmap;
		} nocodec;
		struct
		{
			RemminaPluginRdpUiClipboardType type;
			GtkTargetList* targetlist;
			UINT32 format;
		} clipboard;
	};
};
typedef struct remmina_plugin_rdp_ui_object RemminaPluginRdpUiObject;

void rf_init(RemminaProtocolWidget* gp);
void rf_uninit(RemminaProtocolWidget* gp);
void rf_get_fds(RemminaProtocolWidget* gp, void** rfds, int* rcount);
BOOL rf_check_fds(RemminaProtocolWidget* gp);
void rf_queue_ui(RemminaProtocolWidget* gp, RemminaPluginRdpUiObject* ui);
void rf_object_free(RemminaProtocolWidget* gp, RemminaPluginRdpUiObject* obj);

#endif