ReactOS 0.4.15-dev-7846-g8ba6c66
cliprdr.c
Go to the documentation of this file.
1/* -*- c-basic-offset: 8 -*-
2 rdesktop: A Remote Desktop Protocol client.
3 Protocol services - Clipboard functions
4 Copyright (C) Erik Forsberg <forsberg@cendio.se> 2003
5 Copyright (C) Matthew Chapman 2003
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 along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20*/
21
22#include "rdesktop.h"
23
24#define CLIPRDR_CONNECT 1
25#define CLIPRDR_FORMAT_ANNOUNCE 2
26#define CLIPRDR_FORMAT_ACK 3
27#define CLIPRDR_DATA_REQUEST 4
28#define CLIPRDR_DATA_RESPONSE 5
29
30#define CLIPRDR_REQUEST 0
31#define CLIPRDR_RESPONSE 1
32#define CLIPRDR_ERROR 2
33
34static void
36{
37 STREAM s;
38
39 DEBUG_CLIPBOARD(("CLIPRDR send: type=%d, status=%d, length=%d\n", type, status, length));
40
41 s = channel_init(This, This->cliprdr.channel, length + 12);
46 out_uint32(s, 0); /* pad? */
48 channel_send(This, s, This->cliprdr.channel);
49}
50
51/* Helper which announces our readiness to supply clipboard data
52 in a single format (such as CF_TEXT) to the RDP side.
53 To announce more than one format at a time, use
54 cliprdr_send_native_format_announce.
55 */
56void
58{
59 uint8 buffer[36];
60
61 DEBUG_CLIPBOARD(("cliprdr_send_simple_native_format_announce\n"));
62
64 memset(buffer + 4, 0, sizeof(buffer) - 4); /* description */
66}
67
68/* Announces our readiness to supply clipboard data in multiple
69 formats, each denoted by a 36-byte format descriptor of
70 [ uint32 format + 32-byte description ].
71 */
72void
73cliprdr_send_native_format_announce(RDPCLIENT * This, uint8 * formats_data, uint32 formats_data_length)
74{
75 DEBUG_CLIPBOARD(("cliprdr_send_native_format_announce\n"));
76
78 formats_data_length);
79
80 if (formats_data != This->cliprdr.last_formats)
81 {
82 if (This->cliprdr.last_formats)
83 xfree(This->cliprdr.last_formats);
84
85 This->cliprdr.last_formats = xmalloc(formats_data_length);
86 memcpy(This->cliprdr.last_formats, formats_data, formats_data_length);
87 This->cliprdr.last_formats_length = formats_data_length;
88 }
89}
90
91void
93{
94 uint8 buffer[4];
95
96 DEBUG_CLIPBOARD(("cliprdr_send_data_request\n"));
99}
100
101void
103{
104 DEBUG_CLIPBOARD(("cliprdr_send_data\n"));
106}
107
108static void
110{
113 uint8 *data;
114
118 data = s->p;
119
120 DEBUG_CLIPBOARD(("CLIPRDR recv: type=%d, status=%d, length=%d\n", type, status, length));
121
122 if (status == CLIPRDR_ERROR)
123 {
124 switch (type)
125 {
127 /* FIXME: We seem to get this when we send an announce while the server is
128 still processing a paste. Try sending another announce. */
129 cliprdr_send_native_format_announce(This, This->cliprdr.last_formats,
130 This->cliprdr.last_formats_length);
131 break;
134 break;
135 default:
136 DEBUG_CLIPBOARD(("CLIPRDR error (type=%d)\n", type));
137 }
138
139 return;
140 }
141
142 switch (type)
143 {
144 case CLIPRDR_CONNECT:
146 break;
150 return;
152 break;
156 break;
159 break;
160 case 7: /* TODO: W2K3 SP1 sends this on connect with a value of 1 */
161 break;
162 default:
163 unimpl("CLIPRDR packet type %d\n", type);
164 }
165}
166
167void
169{
171}
172
173BOOL
175{
176 This->cliprdr.channel =
177 channel_register(This, "cliprdr",
181 return (This->cliprdr.channel != NULL);
182}
VCHANNEL * channel_register(char *name, uint32 flags, void(*callback)(STREAM))
Definition: channels.c:46
STREAM channel_init(VCHANNEL *channel, uint32 length)
Definition: channels.c:69
void channel_send(STREAM s, VCHANNEL *channel)
Definition: channels.c:79
#define CHANNEL_OPTION_ENCRYPT_RDP
Definition: constants.h:432
#define CHANNEL_OPTION_INITIALIZED
Definition: constants.h:431
#define CHANNEL_OPTION_SHOW_PROTOCOL
Definition: constants.h:434
#define CHANNEL_OPTION_COMPRESS_RDP
Definition: constants.h:433
#define s_mark_end(s)
Definition: parse.h:41
#define out_uint32_le(s, v)
Definition: parse.h:59
#define in_uint16_le(s, v)
Definition: parse.h:55
#define out_uint16_le(s, v)
Definition: parse.h:58
#define out_uint8p(s, v, n)
Definition: parse.h:93
#define out_uint32(s, v)
Definition: parse.h:85
#define in_uint32_le(s, v)
Definition: parse.h:56
void xfree(void *mem)
Definition: uimain.c:758
void ui_clip_format_announce(uint8 *data, uint32 length)
void ui_clip_sync(void)
void buf_out_uint32(uint8 *buffer, uint32 value)
Definition: secure.c:304
void ui_clip_request_failed(void)
void unimpl(char *format,...)
Definition: uimain.c:801
void ui_clip_request_data(uint32 format)
void ui_clip_handle_data(uint8 *data, uint32 length)
RD_BOOL cliprdr_init(void)
void * xmalloc(int size)
Definition: uimain.c:747
void ui_clip_set_mode(const char *optarg)
#define DEBUG_CLIPBOARD(args)
Definition: rdesktop.h:147
unsigned short uint16
Definition: types.h:30
unsigned int uint32
Definition: types.h:32
unsigned char uint8
Definition: types.h:28
const char * optarg
Definition: getopt.c:49
#define CLIPRDR_FORMAT_ANNOUNCE
Definition: cliprdr.c:25
static void cliprdr_process(RDPCLIENT *This, STREAM s)
Definition: cliprdr.c:109
#define CLIPRDR_FORMAT_ACK
Definition: cliprdr.c:26
void cliprdr_send_native_format_announce(RDPCLIENT *This, uint8 *formats_data, uint32 formats_data_length)
Definition: cliprdr.c:73
#define CLIPRDR_CONNECT
Definition: cliprdr.c:24
#define CLIPRDR_DATA_REQUEST
Definition: cliprdr.c:27
void cliprdr_send_data_request(RDPCLIENT *This, uint32 format)
Definition: cliprdr.c:92
void cliprdr_set_mode(RDPCLIENT *This, const char *optarg)
Definition: cliprdr.c:168
static void cliprdr_send_packet(RDPCLIENT *This, uint16 type, uint16 status, uint8 *data, uint32 length)
Definition: cliprdr.c:35
#define CLIPRDR_REQUEST
Definition: cliprdr.c:30
void cliprdr_send_simple_native_format_announce(RDPCLIENT *This, uint32 format)
Definition: cliprdr.c:57
void cliprdr_send_data(RDPCLIENT *This, uint8 *data, uint32 length)
Definition: cliprdr.c:102
#define CLIPRDR_DATA_RESPONSE
Definition: cliprdr.c:28
#define CLIPRDR_ERROR
Definition: cliprdr.c:32
#define CLIPRDR_RESPONSE
Definition: cliprdr.c:31
#define NULL
Definition: types.h:112
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLuint buffer
Definition: glext.h:5915
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define memset(x, y, z)
Definition: compat.h:39
Definition: ps.c:97
Definition: parse.h:23