-
Notifications
You must be signed in to change notification settings - Fork 795
Expand file tree
/
Copy pathcliprdr.h
More file actions
165 lines (145 loc) · 5.85 KB
/
Copy pathcliprdr.h
File metadata and controls
165 lines (145 loc) · 5.85 KB
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
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef GUAC_RDP_CHANNELS_CLIPRDR_H
#define GUAC_RDP_CHANNELS_CLIPRDR_H
#include "common/clipboard.h"
#include <freerdp/client/cliprdr.h>
#include <freerdp/freerdp.h>
#include <guacamole/client.h>
#include <guacamole/user.h>
#include <winpr/stream.h>
#include <winpr/wtypes.h>
#include <pthread.h>
/**
* RDP clipboard, leveraging the "CLIPRDR" channel.
*/
typedef struct guac_rdp_clipboard {
/**
* The guac_client associated with the RDP connection. The broadcast
* socket of this client will receive any clipboard data received from the
* RDP server.
*/
guac_client* client;
/**
* CLIPRDR control interface.
*/
CliprdrClientContext* cliprdr;
/**
* The current clipboard contents.
*/
guac_common_clipboard* clipboard;
/**
* The format of the clipboard which was requested. Data received from
* the RDP server should conform to this format. This will be one of
* several legal clipboard format values defined within FreeRDP's WinPR
* library, such as CF_TEXT.
*/
UINT requested_format;
/**
* Whether a Format Data Request has been sent and is still awaiting a
* response. Prevents overlapping requests that desynchronize FreeRDP
* 3.x's internal CLIPRDR request tracking.
*/
int request_pending;
/**
* Lock protecting request_pending and requested_format against
* concurrent access from the CLIPRDR channel thread and user input
* threads.
*/
pthread_mutex_t request_lock;
} guac_rdp_clipboard;
/**
* Allocates a new guac_rdp_clipboard which has been initialized for processing
* of Guacamole clipboard data. Support for the RDP side of the clipboard (the
* CLIPRDR channel) must be loaded separately during FreeRDP's PreConnect event
* using guac_rdp_clipboard_load_plugin().
*
* @param client
* The guac_client associated with the Guacamole side of the RDP
* connection.
*
* @param buffer_size
* The buffer size in bytes.
*
* @return
* A newly-allocated instance of guac_rdp_clipboard which has been
* initialized for processing Guacamole clipboard data.
*/
guac_rdp_clipboard* guac_rdp_clipboard_alloc(guac_client* client, int buffer_size);
/**
* Initializes clipboard support for RDP and handling of the CLIPRDR channel.
* If failures occur, messages noting the specifics of those failures will be
* logged, and the RDP side of clipboard support will not be functional.
*
* This MUST be called within the PreConnect callback of the freerdp instance
* for CLIPRDR support to be loaded.
*
* @param clipboard
* The guac_rdp_clipboard instance which has been allocated for the current
* RDP connection.
*
* @param context
* The rdpContext associated with the FreeRDP side of the RDP connection.
*/
void guac_rdp_clipboard_load_plugin(guac_rdp_clipboard* clipboard,
rdpContext* context);
/**
* Frees the resources associated with clipboard support for RDP and handling
* of the CLIPRDR channel. Only resources specific to Guacamole are freed.
* Resources specific to FreeRDP's handling of the CLIPRDR channel will be
* freed by FreeRDP. If the provided guac_rdp_clipboard is NULL, this function
* has no effect.
*
* @param clipboard
* The guac_rdp_clipboard instance which was been allocated for the current
* RDP connection.
*/
void guac_rdp_clipboard_free(guac_rdp_clipboard* clipboard);
/**
* Handler for inbound clipboard data, received via the stream created by an
* inbound "clipboard" instruction. This handler will assign the
* stream-specific handlers for processing "blob" and "end" instructions which
* will eventually be received as clipboard data is sent. This specific handler
* is expected to be assigned to the guac_user object of any user that may send
* clipboard data. The guac_rdp_clipboard instance which will receive this data
* MUST already be stored on the guac_rdp_client structure associated with the
* current RDP connection.
*/
guac_user_clipboard_handler guac_rdp_clipboard_handler;
/**
* Handler for stream data related to clipboard, received via "blob"
* instructions for a stream which has already been created with an inbound
* "clipboard" instruction. This specific handler is assigned to the
* guac_stream structure associated with that clipboard stream by
* guac_rdp_clipboard_handler(). The guac_rdp_clipboard instance which will
* receive this data MUST already be stored on the guac_rdp_client structure
* associated with the current RDP connection.
*/
guac_user_blob_handler guac_rdp_clipboard_blob_handler;
/**
* Handler for end-of-stream related to clipboard, indicated via an "end"
* instruction for a stream which has already been created with an inbound
* "clipboard" instruction. This specific handler is assigned to the
* guac_stream structure associated with that clipboard stream by
* guac_rdp_clipboard_handler(). The guac_rdp_clipboard instance which will
* receive this data MUST already be stored on the guac_rdp_client structure
* associated with the current RDP connection.
*/
guac_user_end_handler guac_rdp_clipboard_end_handler;
#endif