~serge-hallyn/ubuntu/raring/spice/spice-fixed2

« back to all changes in this revision

Viewing changes to client/generated_marshallers.cpp

  • Committer: Package Import Robot
  • Author(s): Liang Guo
  • Date: 2011-07-23 12:21:04 UTC
  • Revision ID: package-import@ubuntu.com-20110723122104-gvv70gd6ui6213qd
Tags: upstream-0.8.2
ImportĀ upstreamĀ versionĀ 0.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "common.h"
 
2
#include "messages.h"
 
3
#include "marshallers.h"
 
4
#include <string.h>
 
5
#include <assert.h>
 
6
#include <stdlib.h>
 
7
#include <stdio.h>
 
8
#include <spice/protocol.h>
 
9
#include <spice/macros.h>
 
10
#include <marshaller.h>
 
11
 
 
12
#ifdef _MSC_VER
 
13
#pragma warning(disable:4101)
 
14
#pragma warning(disable:4018)
 
15
#endif
 
16
 
 
17
static void spice_marshall_msgc_ack_sync(SpiceMarshaller *m, SpiceMsgcAckSync *msg)
 
18
{
 
19
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
20
    SpiceMsgcAckSync *src;
 
21
    src = (SpiceMsgcAckSync *)msg;
 
22
 
 
23
    spice_marshaller_add_uint32(m, src->generation);
 
24
}
 
25
 
 
26
static void spice_marshall_SpiceMsgEmpty(SpiceMarshaller *m, SpiceMsgEmpty *msg)
 
27
{
 
28
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
29
}
 
30
 
 
31
static void spice_marshall_msgc_pong(SpiceMarshaller *m, SpiceMsgPing *msg)
 
32
{
 
33
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
34
    SpiceMsgPing *src;
 
35
    src = (SpiceMsgPing *)msg;
 
36
 
 
37
    spice_marshaller_add_uint32(m, src->id);
 
38
    spice_marshaller_add_uint64(m, src->timestamp);
 
39
}
 
40
 
 
41
static void spice_marshall_SpiceMsgData(SpiceMarshaller *m, SpiceMsgData *msg)
 
42
{
 
43
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
44
}
 
45
 
 
46
static void spice_marshall_msgc_disconnecting(SpiceMarshaller *m, SpiceMsgDisconnect *msg)
 
47
{
 
48
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
49
    SpiceMsgDisconnect *src;
 
50
    src = (SpiceMsgDisconnect *)msg;
 
51
 
 
52
    spice_marshaller_add_uint64(m, src->time_stamp);
 
53
    spice_marshaller_add_uint32(m, src->reason);
 
54
}
 
55
 
 
56
static void spice_marshall_msgc_main_client_info(SpiceMarshaller *m, SpiceMsgcClientInfo *msg)
 
57
{
 
58
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
59
    SpiceMsgcClientInfo *src;
 
60
    src = (SpiceMsgcClientInfo *)msg;
 
61
 
 
62
    spice_marshaller_add_uint64(m, src->cache_size);
 
63
}
 
64
 
 
65
static void spice_marshall_msgc_main_mouse_mode_request(SpiceMarshaller *m, SpiceMsgcMainMouseModeRequest *msg)
 
66
{
 
67
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
68
    SpiceMsgcMainMouseModeRequest *src;
 
69
    src = (SpiceMsgcMainMouseModeRequest *)msg;
 
70
 
 
71
    spice_marshaller_add_uint16(m, src->mode);
 
72
}
 
73
 
 
74
static void spice_marshall_msgc_main_agent_start(SpiceMarshaller *m, SpiceMsgcMainAgentStart *msg)
 
75
{
 
76
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
77
    SpiceMsgcMainAgentStart *src;
 
78
    src = (SpiceMsgcMainAgentStart *)msg;
 
79
 
 
80
    spice_marshaller_add_uint32(m, src->num_tokens);
 
81
}
 
82
 
 
83
static void spice_marshall_msgc_main_agent_token(SpiceMarshaller *m, SpiceMsgcMainAgentTokens *msg)
 
84
{
 
85
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
86
    SpiceMsgcMainAgentTokens *src;
 
87
    src = (SpiceMsgcMainAgentTokens *)msg;
 
88
 
 
89
    spice_marshaller_add_uint32(m, src->num_tokens);
 
90
}
 
91
 
 
92
static void spice_marshall_msgc_display_init(SpiceMarshaller *m, SpiceMsgcDisplayInit *msg)
 
93
{
 
94
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
95
    SpiceMsgcDisplayInit *src;
 
96
    src = (SpiceMsgcDisplayInit *)msg;
 
97
 
 
98
    spice_marshaller_add_uint8(m, src->pixmap_cache_id);
 
99
    spice_marshaller_add_int64(m, src->pixmap_cache_size);
 
100
    spice_marshaller_add_uint8(m, src->glz_dictionary_id);
 
101
    spice_marshaller_add_int32(m, src->glz_dictionary_window_size);
 
102
}
 
103
 
 
104
static void spice_marshall_msgc_inputs_key_down(SpiceMarshaller *m, SpiceMsgcKeyDown *msg)
 
105
{
 
106
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
107
    SpiceMsgcKeyDown *src;
 
108
    src = (SpiceMsgcKeyDown *)msg;
 
109
 
 
110
    spice_marshaller_add_uint32(m, src->code);
 
111
}
 
112
 
 
113
static void spice_marshall_msgc_inputs_key_up(SpiceMarshaller *m, SpiceMsgcKeyUp *msg)
 
114
{
 
115
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
116
    SpiceMsgcKeyUp *src;
 
117
    src = (SpiceMsgcKeyUp *)msg;
 
118
 
 
119
    spice_marshaller_add_uint32(m, src->code);
 
120
}
 
121
 
 
122
static void spice_marshall_msgc_inputs_key_modifiers(SpiceMarshaller *m, SpiceMsgcKeyModifiers *msg)
 
123
{
 
124
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
125
    SpiceMsgcKeyModifiers *src;
 
126
    src = (SpiceMsgcKeyModifiers *)msg;
 
127
 
 
128
    spice_marshaller_add_uint16(m, src->modifiers);
 
129
}
 
130
 
 
131
static void spice_marshall_msgc_inputs_mouse_motion(SpiceMarshaller *m, SpiceMsgcMouseMotion *msg)
 
132
{
 
133
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
134
    SpiceMsgcMouseMotion *src;
 
135
    src = (SpiceMsgcMouseMotion *)msg;
 
136
 
 
137
    spice_marshaller_add_int32(m, src->dx);
 
138
    spice_marshaller_add_int32(m, src->dy);
 
139
    spice_marshaller_add_uint16(m, src->buttons_state);
 
140
}
 
141
 
 
142
static void spice_marshall_msgc_inputs_mouse_position(SpiceMarshaller *m, SpiceMsgcMousePosition *msg)
 
143
{
 
144
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
145
    SpiceMsgcMousePosition *src;
 
146
    src = (SpiceMsgcMousePosition *)msg;
 
147
 
 
148
    spice_marshaller_add_uint32(m, src->x);
 
149
    spice_marshaller_add_uint32(m, src->y);
 
150
    spice_marshaller_add_uint16(m, src->buttons_state);
 
151
    spice_marshaller_add_uint8(m, src->display_id);
 
152
}
 
153
 
 
154
static void spice_marshall_msgc_inputs_mouse_press(SpiceMarshaller *m, SpiceMsgcMousePress *msg)
 
155
{
 
156
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
157
    SpiceMsgcMousePress *src;
 
158
    src = (SpiceMsgcMousePress *)msg;
 
159
 
 
160
    spice_marshaller_add_uint8(m, src->button);
 
161
    spice_marshaller_add_uint16(m, src->buttons_state);
 
162
}
 
163
 
 
164
static void spice_marshall_msgc_inputs_mouse_release(SpiceMarshaller *m, SpiceMsgcMouseRelease *msg)
 
165
{
 
166
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
167
    SpiceMsgcMouseRelease *src;
 
168
    src = (SpiceMsgcMouseRelease *)msg;
 
169
 
 
170
    spice_marshaller_add_uint8(m, src->button);
 
171
    spice_marshaller_add_uint16(m, src->buttons_state);
 
172
}
 
173
 
 
174
static void spice_marshall_msgc_record_data(SpiceMarshaller *m, SpiceMsgcRecordPacket *msg)
 
175
{
 
176
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
177
    SpiceMsgcRecordPacket *src;
 
178
    src = (SpiceMsgcRecordPacket *)msg;
 
179
 
 
180
    spice_marshaller_add_uint32(m, src->time);
 
181
    /* Don't marshall @nomarshal data */
 
182
}
 
183
 
 
184
static void spice_marshall_msgc_record_mode(SpiceMarshaller *m, SpiceMsgcRecordMode *msg)
 
185
{
 
186
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
187
    SpiceMsgcRecordMode *src;
 
188
    src = (SpiceMsgcRecordMode *)msg;
 
189
 
 
190
    spice_marshaller_add_uint32(m, src->time);
 
191
    spice_marshaller_add_uint16(m, src->mode);
 
192
    /* Remaining data must be appended manually */
 
193
}
 
194
 
 
195
static void spice_marshall_msgc_record_start_mark(SpiceMarshaller *m, SpiceMsgcRecordStartMark *msg)
 
196
{
 
197
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
198
    SpiceMsgcRecordStartMark *src;
 
199
    src = (SpiceMsgcRecordStartMark *)msg;
 
200
 
 
201
    spice_marshaller_add_uint32(m, src->time);
 
202
}
 
203
 
 
204
SPICE_GNUC_UNUSED static void spice_marshall_array_uint8(SpiceMarshaller *m, uint8_t *ptr, int count)
 
205
{
 
206
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
207
    uint32_t i;
 
208
 
 
209
    for (i = 0; i < count; i++) {
 
210
        spice_marshaller_add_uint8(m, *ptr++);
 
211
    }
 
212
}
 
213
 
 
214
static void spice_marshall_msgc_tunnel_service_add(SpiceMarshaller *m, SpiceMsgcTunnelAddGenericService *msg, SpiceMarshaller **name_out, SpiceMarshaller **description_out)
 
215
{
 
216
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
217
    SpiceMsgcTunnelAddGenericService *src;
 
218
    uint32_t i;
 
219
    *name_out = NULL;
 
220
    *description_out = NULL;
 
221
    src = (SpiceMsgcTunnelAddGenericService *)msg;
 
222
 
 
223
    spice_marshaller_add_uint16(m, src->type);
 
224
    spice_marshaller_add_uint32(m, src->id);
 
225
    spice_marshaller_add_uint32(m, src->group);
 
226
    spice_marshaller_add_uint32(m, src->port);
 
227
    *name_out = spice_marshaller_get_ptr_submarshaller(m, 0);
 
228
    *description_out = spice_marshaller_get_ptr_submarshaller(m, 0);
 
229
    if (src->type == SPICE_TUNNEL_SERVICE_TYPE_IPP) {
 
230
        uint8_t *ipv4__element;
 
231
        spice_marshaller_add_uint16(m, src->u.ip.type);
 
232
        if (src->u.ip.type == SPICE_TUNNEL_IP_TYPE_IPv4) {
 
233
            ipv4__element = src->u.ip.u.ipv4;
 
234
            for (i = 0; i < 4; i++) {
 
235
                spice_marshaller_add_uint8(m, *ipv4__element);
 
236
                ipv4__element++;
 
237
            }
 
238
        }
 
239
    }
 
240
}
 
241
 
 
242
static void spice_marshall_msgc_tunnel_service_remove(SpiceMarshaller *m, SpiceMsgcTunnelRemoveService *msg)
 
243
{
 
244
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
245
    SpiceMsgcTunnelRemoveService *src;
 
246
    src = (SpiceMsgcTunnelRemoveService *)msg;
 
247
 
 
248
    spice_marshaller_add_uint32(m, src->id);
 
249
}
 
250
 
 
251
static void spice_marshall_msgc_tunnel_socket_open_ack(SpiceMarshaller *m, SpiceMsgcTunnelSocketOpenAck *msg)
 
252
{
 
253
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
254
    SpiceMsgcTunnelSocketOpenAck *src;
 
255
    src = (SpiceMsgcTunnelSocketOpenAck *)msg;
 
256
 
 
257
    spice_marshaller_add_uint16(m, src->connection_id);
 
258
    spice_marshaller_add_uint32(m, src->tokens);
 
259
}
 
260
 
 
261
static void spice_marshall_msgc_tunnel_socket_open_nack(SpiceMarshaller *m, SpiceMsgcTunnelSocketOpenNack *msg)
 
262
{
 
263
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
264
    SpiceMsgcTunnelSocketOpenNack *src;
 
265
    src = (SpiceMsgcTunnelSocketOpenNack *)msg;
 
266
 
 
267
    spice_marshaller_add_uint16(m, src->connection_id);
 
268
}
 
269
 
 
270
static void spice_marshall_msgc_tunnel_socket_fin(SpiceMarshaller *m, SpiceMsgcTunnelSocketFin *msg)
 
271
{
 
272
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
273
    SpiceMsgcTunnelSocketFin *src;
 
274
    src = (SpiceMsgcTunnelSocketFin *)msg;
 
275
 
 
276
    spice_marshaller_add_uint16(m, src->connection_id);
 
277
}
 
278
 
 
279
static void spice_marshall_msgc_tunnel_socket_closed(SpiceMarshaller *m, SpiceMsgcTunnelSocketClosed *msg)
 
280
{
 
281
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
282
    SpiceMsgcTunnelSocketClosed *src;
 
283
    src = (SpiceMsgcTunnelSocketClosed *)msg;
 
284
 
 
285
    spice_marshaller_add_uint16(m, src->connection_id);
 
286
}
 
287
 
 
288
static void spice_marshall_msgc_tunnel_socket_closed_ack(SpiceMarshaller *m, SpiceMsgcTunnelSocketClosedAck *msg)
 
289
{
 
290
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
291
    SpiceMsgcTunnelSocketClosedAck *src;
 
292
    src = (SpiceMsgcTunnelSocketClosedAck *)msg;
 
293
 
 
294
    spice_marshaller_add_uint16(m, src->connection_id);
 
295
}
 
296
 
 
297
static void spice_marshall_msgc_tunnel_socket_data(SpiceMarshaller *m, SpiceMsgcTunnelSocketData *msg)
 
298
{
 
299
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
300
    SpiceMsgcTunnelSocketData *src;
 
301
    src = (SpiceMsgcTunnelSocketData *)msg;
 
302
 
 
303
    spice_marshaller_add_uint16(m, src->connection_id);
 
304
    /* Remaining data must be appended manually */
 
305
}
 
306
 
 
307
static void spice_marshall_msgc_tunnel_socket_token(SpiceMarshaller *m, SpiceMsgcTunnelSocketTokens *msg)
 
308
{
 
309
    SPICE_GNUC_UNUSED SpiceMarshaller *m2;
 
310
    SpiceMsgcTunnelSocketTokens *src;
 
311
    src = (SpiceMsgcTunnelSocketTokens *)msg;
 
312
 
 
313
    spice_marshaller_add_uint16(m, src->connection_id);
 
314
    spice_marshaller_add_uint32(m, src->num_tokens);
 
315
}
 
316
 
 
317
SpiceMessageMarshallers * spice_message_marshallers_get(void)
 
318
{
 
319
    static SpiceMessageMarshallers marshallers = {NULL};
 
320
 
 
321
    marshallers.msg_SpiceMsgData = spice_marshall_SpiceMsgData;
 
322
    marshallers.msg_SpiceMsgEmpty = spice_marshall_SpiceMsgEmpty;
 
323
    marshallers.msgc_ack_sync = spice_marshall_msgc_ack_sync;
 
324
    marshallers.msgc_disconnecting = spice_marshall_msgc_disconnecting;
 
325
    marshallers.msgc_display_init = spice_marshall_msgc_display_init;
 
326
    marshallers.msgc_inputs_key_down = spice_marshall_msgc_inputs_key_down;
 
327
    marshallers.msgc_inputs_key_modifiers = spice_marshall_msgc_inputs_key_modifiers;
 
328
    marshallers.msgc_inputs_key_up = spice_marshall_msgc_inputs_key_up;
 
329
    marshallers.msgc_inputs_mouse_motion = spice_marshall_msgc_inputs_mouse_motion;
 
330
    marshallers.msgc_inputs_mouse_position = spice_marshall_msgc_inputs_mouse_position;
 
331
    marshallers.msgc_inputs_mouse_press = spice_marshall_msgc_inputs_mouse_press;
 
332
    marshallers.msgc_inputs_mouse_release = spice_marshall_msgc_inputs_mouse_release;
 
333
    marshallers.msgc_main_agent_start = spice_marshall_msgc_main_agent_start;
 
334
    marshallers.msgc_main_agent_token = spice_marshall_msgc_main_agent_token;
 
335
    marshallers.msgc_main_client_info = spice_marshall_msgc_main_client_info;
 
336
    marshallers.msgc_main_mouse_mode_request = spice_marshall_msgc_main_mouse_mode_request;
 
337
    marshallers.msgc_pong = spice_marshall_msgc_pong;
 
338
    marshallers.msgc_record_data = spice_marshall_msgc_record_data;
 
339
    marshallers.msgc_record_mode = spice_marshall_msgc_record_mode;
 
340
    marshallers.msgc_record_start_mark = spice_marshall_msgc_record_start_mark;
 
341
    marshallers.msgc_tunnel_service_add = spice_marshall_msgc_tunnel_service_add;
 
342
    marshallers.msgc_tunnel_service_remove = spice_marshall_msgc_tunnel_service_remove;
 
343
    marshallers.msgc_tunnel_socket_closed = spice_marshall_msgc_tunnel_socket_closed;
 
344
    marshallers.msgc_tunnel_socket_closed_ack = spice_marshall_msgc_tunnel_socket_closed_ack;
 
345
    marshallers.msgc_tunnel_socket_data = spice_marshall_msgc_tunnel_socket_data;
 
346
    marshallers.msgc_tunnel_socket_fin = spice_marshall_msgc_tunnel_socket_fin;
 
347
    marshallers.msgc_tunnel_socket_open_ack = spice_marshall_msgc_tunnel_socket_open_ack;
 
348
    marshallers.msgc_tunnel_socket_open_nack = spice_marshall_msgc_tunnel_socket_open_nack;
 
349
    marshallers.msgc_tunnel_socket_token = spice_marshall_msgc_tunnel_socket_token;
 
350
 
 
351
    return &marshallers;
 
352
}
 
353