spice-html5-rails 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +674 -0
- data/COPYING.LESSER +165 -0
- data/LICENSE.txt +15 -0
- data/README.md +35 -0
- data/lib/spice-html5-rails/version.rb +7 -0
- data/lib/spice-html5-rails.rb +10 -0
- data/vendor/assets/javascripts/spice-html5.js +25 -0
- data/vendor/assets/javascripts/spiceHTML5/atKeynames.js +183 -0
- data/vendor/assets/javascripts/spiceHTML5/bitmap.js +51 -0
- data/vendor/assets/javascripts/spiceHTML5/cursor.js +92 -0
- data/vendor/assets/javascripts/spiceHTML5/display.js +806 -0
- data/vendor/assets/javascripts/spiceHTML5/enums.js +282 -0
- data/vendor/assets/javascripts/spiceHTML5/inputs.js +271 -0
- data/vendor/assets/javascripts/spiceHTML5/lz.js +166 -0
- data/vendor/assets/javascripts/spiceHTML5/main.js +177 -0
- data/vendor/assets/javascripts/spiceHTML5/png.js +256 -0
- data/vendor/assets/javascripts/spiceHTML5/quic.js +1335 -0
- data/vendor/assets/javascripts/spiceHTML5/spiceconn.js +455 -0
- data/vendor/assets/javascripts/spiceHTML5/spicedataview.js +96 -0
- data/vendor/assets/javascripts/spiceHTML5/spicemsg.js +883 -0
- data/vendor/assets/javascripts/spiceHTML5/spicetype.js +480 -0
- data/vendor/assets/javascripts/spiceHTML5/thirdparty/jsbn.js +589 -0
- data/vendor/assets/javascripts/spiceHTML5/thirdparty/prng4.js +79 -0
- data/vendor/assets/javascripts/spiceHTML5/thirdparty/rng.js +102 -0
- data/vendor/assets/javascripts/spiceHTML5/thirdparty/rsa.js +146 -0
- data/vendor/assets/javascripts/spiceHTML5/thirdparty/sha1.js +346 -0
- data/vendor/assets/javascripts/spiceHTML5/ticket.js +250 -0
- data/vendor/assets/javascripts/spiceHTML5/utils.js +261 -0
- data/vendor/assets/javascripts/spiceHTML5/wire.js +123 -0
- metadata +108 -0
@@ -0,0 +1,883 @@
|
|
1
|
+
"use strict";
|
2
|
+
/*
|
3
|
+
Copyright (C) 2012 by Jeremy P. White <jwhite@codeweavers.com>
|
4
|
+
|
5
|
+
This file is part of spice-html5.
|
6
|
+
|
7
|
+
spice-html5 is free software: you can redistribute it and/or modify
|
8
|
+
it under the terms of the GNU Lesser General Public License as published by
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
spice-html5 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 Lesser General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU Lesser General Public License
|
18
|
+
along with spice-html5. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
*/
|
20
|
+
|
21
|
+
/*----------------------------------------------------------------------------
|
22
|
+
** Spice messages
|
23
|
+
** This file contains classes for passing messages to and from
|
24
|
+
** a spice server. This file should arguably be generated from
|
25
|
+
** spice.proto, but it was instead put together by hand.
|
26
|
+
**--------------------------------------------------------------------------*/
|
27
|
+
function SpiceLinkHeader(a, at)
|
28
|
+
{
|
29
|
+
this.magic = SPICE_MAGIC;
|
30
|
+
this.major_version = SPICE_VERSION_MAJOR;
|
31
|
+
this.minor_version = SPICE_VERSION_MINOR;
|
32
|
+
this.size = 0;
|
33
|
+
if (a !== undefined)
|
34
|
+
this.from_buffer(a, at);
|
35
|
+
}
|
36
|
+
|
37
|
+
SpiceLinkHeader.prototype =
|
38
|
+
{
|
39
|
+
from_buffer: function(a, at)
|
40
|
+
{
|
41
|
+
at = at || 0;
|
42
|
+
var dv = new SpiceDataView(a);
|
43
|
+
this.magic = "";
|
44
|
+
for (var i = 0; i < 4; i++)
|
45
|
+
this.magic += String.fromCharCode(dv.getUint8(at + i));
|
46
|
+
at += 4;
|
47
|
+
|
48
|
+
this.major_version = dv.getUint32(at, true); at += 4;
|
49
|
+
this.minor_version = dv.getUint32(at, true); at += 4;
|
50
|
+
this.size = dv.getUint32(at, true); at += 4;
|
51
|
+
},
|
52
|
+
|
53
|
+
to_buffer: function(a, at)
|
54
|
+
{
|
55
|
+
at = at || 0;
|
56
|
+
var dv = new SpiceDataView(a);
|
57
|
+
for (var i = 0; i < 4; i++)
|
58
|
+
dv.setUint8(at + i, this.magic.charCodeAt(i));
|
59
|
+
at += 4;
|
60
|
+
|
61
|
+
dv.setUint32(at, this.major_version, true); at += 4;
|
62
|
+
dv.setUint32(at, this.minor_version, true); at += 4;
|
63
|
+
dv.setUint32(at, this.size, true); at += 4;
|
64
|
+
},
|
65
|
+
buffer_size: function()
|
66
|
+
{
|
67
|
+
return 16;
|
68
|
+
},
|
69
|
+
}
|
70
|
+
|
71
|
+
function SpiceLinkMess(a, at)
|
72
|
+
{
|
73
|
+
this.connection_id = 0;
|
74
|
+
this.channel_type = 0;
|
75
|
+
this.channel_id = 0;
|
76
|
+
this.common_caps = [];
|
77
|
+
this.channel_caps = [];
|
78
|
+
|
79
|
+
if (a !== undefined)
|
80
|
+
this.from_buffer(a, at);
|
81
|
+
}
|
82
|
+
|
83
|
+
SpiceLinkMess.prototype =
|
84
|
+
{
|
85
|
+
from_buffer: function(a, at)
|
86
|
+
{
|
87
|
+
at = at || 0;
|
88
|
+
var i;
|
89
|
+
var orig_at = at;
|
90
|
+
var dv = new SpiceDataView(a);
|
91
|
+
this.connection_id = dv.getUint32(at, true); at += 4;
|
92
|
+
this.channel_type = dv.getUint8(at, true); at++;
|
93
|
+
this.channel_id = dv.getUint8(at, true); at++;
|
94
|
+
var num_common_caps = dv.getUint32(at, true); at += 4;
|
95
|
+
var num_channel_caps = dv.getUint32(at, true); at += 4;
|
96
|
+
var caps_offset = dv.getUint32(at, true); at += 4;
|
97
|
+
|
98
|
+
at = orig_at + caps_offset;
|
99
|
+
this.common_caps = [];
|
100
|
+
for (i = 0; i < num_common_caps; i++)
|
101
|
+
{
|
102
|
+
this.common_caps.unshift(dv.getUint32(at, true)); at += 4;
|
103
|
+
}
|
104
|
+
|
105
|
+
this.channel_caps = [];
|
106
|
+
for (i = 0; i < num_channel_caps; i++)
|
107
|
+
{
|
108
|
+
this.channel_caps.unshift(dv.getUint32(at, true)); at += 4;
|
109
|
+
}
|
110
|
+
},
|
111
|
+
|
112
|
+
to_buffer: function(a, at)
|
113
|
+
{
|
114
|
+
at = at || 0;
|
115
|
+
var orig_at = at;
|
116
|
+
var i;
|
117
|
+
var dv = new SpiceDataView(a);
|
118
|
+
dv.setUint32(at, this.connection_id, true); at += 4;
|
119
|
+
dv.setUint8(at, this.channel_type, true); at++;
|
120
|
+
dv.setUint8(at, this.channel_id, true); at++;
|
121
|
+
dv.setUint32(at, this.common_caps.length, true); at += 4;
|
122
|
+
dv.setUint32(at, this.channel_caps.length, true); at += 4;
|
123
|
+
dv.setUint32(at, (at - orig_at) + 4, true); at += 4;
|
124
|
+
|
125
|
+
for (i = 0; i < this.common_caps.length; i++)
|
126
|
+
{
|
127
|
+
dv.setUint32(at, this.common_caps[i], true); at += 4;
|
128
|
+
}
|
129
|
+
|
130
|
+
for (i = 0; i < this.channel_caps.length; i++)
|
131
|
+
{
|
132
|
+
dv.setUint32(at, this.channel_caps[i], true); at += 4;
|
133
|
+
}
|
134
|
+
},
|
135
|
+
buffer_size: function()
|
136
|
+
{
|
137
|
+
return 18 + (4 * this.common_caps.length) + (4 * this.channel_caps.length);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
function SpiceLinkReply(a, at)
|
142
|
+
{
|
143
|
+
this.error = 0;
|
144
|
+
this.pub_key = undefined;
|
145
|
+
this.common_caps = [];
|
146
|
+
this.channel_caps = [];
|
147
|
+
|
148
|
+
if (a !== undefined)
|
149
|
+
this.from_buffer(a, at);
|
150
|
+
}
|
151
|
+
|
152
|
+
SpiceLinkReply.prototype =
|
153
|
+
{
|
154
|
+
from_buffer: function(a, at)
|
155
|
+
{
|
156
|
+
at = at || 0;
|
157
|
+
var i;
|
158
|
+
var orig_at = at;
|
159
|
+
var dv = new SpiceDataView(a);
|
160
|
+
this.error = dv.getUint32(at, true); at += 4;
|
161
|
+
|
162
|
+
this.pub_key = create_rsa_from_mb(a, at);
|
163
|
+
at += SPICE_TICKET_PUBKEY_BYTES;
|
164
|
+
|
165
|
+
var num_common_caps = dv.getUint32(at, true); at += 4;
|
166
|
+
var num_channel_caps = dv.getUint32(at, true); at += 4;
|
167
|
+
var caps_offset = dv.getUint32(at, true); at += 4;
|
168
|
+
|
169
|
+
at = orig_at + caps_offset;
|
170
|
+
this.common_caps = [];
|
171
|
+
for (i = 0; i < num_common_caps; i++)
|
172
|
+
{
|
173
|
+
this.common_caps.unshift(dv.getUint32(at, true)); at += 4;
|
174
|
+
}
|
175
|
+
|
176
|
+
this.channel_caps = [];
|
177
|
+
for (i = 0; i < num_channel_caps; i++)
|
178
|
+
{
|
179
|
+
this.channel_caps.unshift(dv.getUint32(at, true)); at += 4;
|
180
|
+
}
|
181
|
+
},
|
182
|
+
}
|
183
|
+
|
184
|
+
function SpiceLinkAuthTicket(a, at)
|
185
|
+
{
|
186
|
+
this.auth_mechanism = 0;
|
187
|
+
this.encrypted_data = undefined;
|
188
|
+
}
|
189
|
+
|
190
|
+
SpiceLinkAuthTicket.prototype =
|
191
|
+
{
|
192
|
+
to_buffer: function(a, at)
|
193
|
+
{
|
194
|
+
at = at || 0;
|
195
|
+
var i;
|
196
|
+
var dv = new SpiceDataView(a);
|
197
|
+
dv.setUint32(at, this.auth_mechanism, true); at += 4;
|
198
|
+
for (i = 0; i < SPICE_TICKET_KEY_PAIR_LENGTH / 8; i++)
|
199
|
+
{
|
200
|
+
if (this.encrypted_data && i < this.encrypted_data.length)
|
201
|
+
dv.setUint8(at, this.encrypted_data[i], true);
|
202
|
+
else
|
203
|
+
dv.setUint8(at, 0, true);
|
204
|
+
at++;
|
205
|
+
}
|
206
|
+
},
|
207
|
+
buffer_size: function()
|
208
|
+
{
|
209
|
+
return 4 + (SPICE_TICKET_KEY_PAIR_LENGTH / 8);
|
210
|
+
}
|
211
|
+
}
|
212
|
+
|
213
|
+
function SpiceLinkAuthReply(a, at)
|
214
|
+
{
|
215
|
+
this.auth_code = 0;
|
216
|
+
if (a !== undefined)
|
217
|
+
this.from_buffer(a, at);
|
218
|
+
}
|
219
|
+
|
220
|
+
SpiceLinkAuthReply.prototype =
|
221
|
+
{
|
222
|
+
from_buffer: function(a, at)
|
223
|
+
{
|
224
|
+
at = at || 0;
|
225
|
+
var dv = new SpiceDataView(a);
|
226
|
+
this.auth_code = dv.getUint32(at, true); at += 4;
|
227
|
+
},
|
228
|
+
buffer_size: function()
|
229
|
+
{
|
230
|
+
return 4;
|
231
|
+
}
|
232
|
+
}
|
233
|
+
|
234
|
+
function SpiceMiniData(a, at)
|
235
|
+
{
|
236
|
+
this.type = 0;
|
237
|
+
this.size = 0;
|
238
|
+
this.data = undefined;
|
239
|
+
if (a !== undefined)
|
240
|
+
this.from_buffer(a, at);
|
241
|
+
}
|
242
|
+
|
243
|
+
SpiceMiniData.prototype =
|
244
|
+
{
|
245
|
+
from_buffer: function(a, at)
|
246
|
+
{
|
247
|
+
at = at || 0;
|
248
|
+
var i;
|
249
|
+
var dv = new SpiceDataView(a);
|
250
|
+
this.type = dv.getUint16(at, true); at += 2;
|
251
|
+
this.size = dv.getUint32(at, true); at += 4;
|
252
|
+
if (a.byteLength > at)
|
253
|
+
{
|
254
|
+
this.data = a.slice(at);
|
255
|
+
at += this.data.byteLength;
|
256
|
+
}
|
257
|
+
},
|
258
|
+
to_buffer : function(a, at)
|
259
|
+
{
|
260
|
+
at = at || 0;
|
261
|
+
var i;
|
262
|
+
var dv = new SpiceDataView(a);
|
263
|
+
dv.setUint16(at, this.type, true); at += 2;
|
264
|
+
dv.setUint32(at, this.data ? this.data.byteLength : 0, true); at += 4;
|
265
|
+
if (this.data && this.data.byteLength > 0)
|
266
|
+
{
|
267
|
+
var u8arr = new Uint8Array(this.data);
|
268
|
+
for (i = 0; i < u8arr.length; i++, at++)
|
269
|
+
dv.setUint8(at, u8arr[i], true);
|
270
|
+
}
|
271
|
+
},
|
272
|
+
build_msg : function(in_type, extra)
|
273
|
+
{
|
274
|
+
this.type = in_type;
|
275
|
+
this.size = extra.buffer_size();
|
276
|
+
this.data = new ArrayBuffer(this.size);
|
277
|
+
extra.to_buffer(this.data);
|
278
|
+
},
|
279
|
+
buffer_size: function()
|
280
|
+
{
|
281
|
+
if (this.data)
|
282
|
+
return 6 + this.data.byteLength;
|
283
|
+
else
|
284
|
+
return 6;
|
285
|
+
},
|
286
|
+
}
|
287
|
+
|
288
|
+
function SpiceMsgChannels(a, at)
|
289
|
+
{
|
290
|
+
this.num_of_channels = 0;
|
291
|
+
this.channels = [];
|
292
|
+
if (a !== undefined)
|
293
|
+
this.from_buffer(a, at);
|
294
|
+
}
|
295
|
+
|
296
|
+
SpiceMsgChannels.prototype =
|
297
|
+
{
|
298
|
+
from_buffer: function(a, at)
|
299
|
+
{
|
300
|
+
at = at || 0;
|
301
|
+
var i;
|
302
|
+
var dv = new SpiceDataView(a);
|
303
|
+
this.num_of_channels = dv.getUint32(at, true); at += 4;
|
304
|
+
for (i = 0; i < this.num_of_channels; i++)
|
305
|
+
{
|
306
|
+
var chan = new SpiceChannelId();
|
307
|
+
at = chan.from_dv(dv, at, a);
|
308
|
+
this.channels.push(chan);
|
309
|
+
}
|
310
|
+
},
|
311
|
+
}
|
312
|
+
|
313
|
+
function SpiceMsgMainInit(a, at)
|
314
|
+
{
|
315
|
+
this.from_buffer(a, at);
|
316
|
+
}
|
317
|
+
|
318
|
+
SpiceMsgMainInit.prototype =
|
319
|
+
{
|
320
|
+
from_buffer: function(a, at)
|
321
|
+
{
|
322
|
+
at = at || 0;
|
323
|
+
var dv = new SpiceDataView(a);
|
324
|
+
this.session_id = dv.getUint32(at, true); at += 4;
|
325
|
+
this.display_channels_hint = dv.getUint32(at, true); at += 4;
|
326
|
+
this.supported_mouse_modes = dv.getUint32(at, true); at += 4;
|
327
|
+
this.current_mouse_mode = dv.getUint32(at, true); at += 4;
|
328
|
+
this.agent_connected = dv.getUint32(at, true); at += 4;
|
329
|
+
this.agent_tokens = dv.getUint32(at, true); at += 4;
|
330
|
+
this.multi_media_time = dv.getUint32(at, true); at += 4;
|
331
|
+
this.ram_hint = dv.getUint32(at, true); at += 4;
|
332
|
+
},
|
333
|
+
}
|
334
|
+
|
335
|
+
function SpiceMsgMainMouseMode(a, at)
|
336
|
+
{
|
337
|
+
this.from_buffer(a, at);
|
338
|
+
}
|
339
|
+
|
340
|
+
SpiceMsgMainMouseMode.prototype =
|
341
|
+
{
|
342
|
+
from_buffer: function(a, at)
|
343
|
+
{
|
344
|
+
at = at || 0;
|
345
|
+
var dv = new SpiceDataView(a);
|
346
|
+
this.supported_modes = dv.getUint16(at, true); at += 2;
|
347
|
+
this.current_mode = dv.getUint16(at, true); at += 2;
|
348
|
+
},
|
349
|
+
}
|
350
|
+
|
351
|
+
function SpiceMsgSetAck(a, at)
|
352
|
+
{
|
353
|
+
this.from_buffer(a, at);
|
354
|
+
}
|
355
|
+
|
356
|
+
SpiceMsgSetAck.prototype =
|
357
|
+
{
|
358
|
+
from_buffer: function(a, at)
|
359
|
+
{
|
360
|
+
at = at || 0;
|
361
|
+
var dv = new SpiceDataView(a);
|
362
|
+
this.generation = dv.getUint32(at, true); at += 4;
|
363
|
+
this.window = dv.getUint32(at, true); at += 4;
|
364
|
+
},
|
365
|
+
}
|
366
|
+
|
367
|
+
function SpiceMsgcAckSync(ack)
|
368
|
+
{
|
369
|
+
this.generation = ack.generation;
|
370
|
+
}
|
371
|
+
|
372
|
+
SpiceMsgcAckSync.prototype =
|
373
|
+
{
|
374
|
+
to_buffer: function(a, at)
|
375
|
+
{
|
376
|
+
at = at || 0;
|
377
|
+
var dv = new SpiceDataView(a);
|
378
|
+
dv.setUint32(at, this.generation, true); at += 4;
|
379
|
+
},
|
380
|
+
buffer_size: function()
|
381
|
+
{
|
382
|
+
return 4;
|
383
|
+
}
|
384
|
+
}
|
385
|
+
|
386
|
+
function SpiceMsgcMainMouseModeRequest(mode)
|
387
|
+
{
|
388
|
+
this.mode = mode;
|
389
|
+
}
|
390
|
+
|
391
|
+
SpiceMsgcMainMouseModeRequest.prototype =
|
392
|
+
{
|
393
|
+
to_buffer: function(a, at)
|
394
|
+
{
|
395
|
+
at = at || 0;
|
396
|
+
var dv = new SpiceDataView(a);
|
397
|
+
dv.setUint16(at, this.mode, true); at += 2;
|
398
|
+
},
|
399
|
+
buffer_size: function()
|
400
|
+
{
|
401
|
+
return 2;
|
402
|
+
}
|
403
|
+
}
|
404
|
+
|
405
|
+
function SpiceMsgNotify(a, at)
|
406
|
+
{
|
407
|
+
this.from_buffer(a, at);
|
408
|
+
}
|
409
|
+
|
410
|
+
SpiceMsgNotify.prototype =
|
411
|
+
{
|
412
|
+
from_buffer: function(a, at)
|
413
|
+
{
|
414
|
+
at = at || 0;
|
415
|
+
var i;
|
416
|
+
var dv = new SpiceDataView(a);
|
417
|
+
this.time_stamp = [];
|
418
|
+
this.time_stamp[0] = dv.getUint32(at, true); at += 4;
|
419
|
+
this.time_stamp[1] = dv.getUint32(at, true); at += 4;
|
420
|
+
this.severity = dv.getUint32(at, true); at += 4;
|
421
|
+
this.visibility = dv.getUint32(at, true); at += 4;
|
422
|
+
this.what = dv.getUint32(at, true); at += 4;
|
423
|
+
this.message_len = dv.getUint32(at, true); at += 4;
|
424
|
+
this.message = "";
|
425
|
+
for (i = 0; i < this.message_len; i++)
|
426
|
+
{
|
427
|
+
var c = dv.getUint8(at, true); at++;
|
428
|
+
this.message += String.fromCharCode(c);
|
429
|
+
}
|
430
|
+
},
|
431
|
+
}
|
432
|
+
|
433
|
+
function SpiceMsgcDisplayInit()
|
434
|
+
{
|
435
|
+
this.pixmap_cache_id = 1;
|
436
|
+
this.glz_dictionary_id = 0;
|
437
|
+
this.pixmap_cache_size = 10 * 1024 * 1024;
|
438
|
+
this.glz_dictionary_window_size = 0;
|
439
|
+
}
|
440
|
+
|
441
|
+
SpiceMsgcDisplayInit.prototype =
|
442
|
+
{
|
443
|
+
to_buffer: function(a, at)
|
444
|
+
{
|
445
|
+
at = at || 0;
|
446
|
+
var dv = new SpiceDataView(a);
|
447
|
+
dv.setUint8(at, this.pixmap_cache_id, true); at++;
|
448
|
+
dv.setUint32(at, 0, true); at += 4;
|
449
|
+
dv.setUint32(at, this.pixmap_cache_size, true); at += 4;
|
450
|
+
dv.setUint8(at, this.glz_dictionary_id, true); at++;
|
451
|
+
dv.setUint32(at, this.glz_dictionary_window_size, true); at += 4;
|
452
|
+
},
|
453
|
+
buffer_size: function()
|
454
|
+
{
|
455
|
+
return 14;
|
456
|
+
}
|
457
|
+
}
|
458
|
+
|
459
|
+
function SpiceMsgDisplayBase()
|
460
|
+
{
|
461
|
+
}
|
462
|
+
|
463
|
+
SpiceMsgDisplayBase.prototype =
|
464
|
+
{
|
465
|
+
from_dv : function(dv, at, mb)
|
466
|
+
{
|
467
|
+
this.surface_id = dv.getUint32(at, true); at += 4;
|
468
|
+
this.box = new SpiceRect;
|
469
|
+
at = this.box.from_dv(dv, at, mb);
|
470
|
+
this.clip = new SpiceClip;
|
471
|
+
return this.clip.from_dv(dv, at, mb);
|
472
|
+
},
|
473
|
+
}
|
474
|
+
|
475
|
+
function SpiceMsgDisplayDrawCopy(a, at)
|
476
|
+
{
|
477
|
+
this.from_buffer(a, at);
|
478
|
+
}
|
479
|
+
|
480
|
+
SpiceMsgDisplayDrawCopy.prototype =
|
481
|
+
{
|
482
|
+
from_buffer: function(a, at)
|
483
|
+
{
|
484
|
+
at = at || 0;
|
485
|
+
var dv = new SpiceDataView(a);
|
486
|
+
this.base = new SpiceMsgDisplayBase;
|
487
|
+
at = this.base.from_dv(dv, at, a);
|
488
|
+
this.data = new SpiceCopy;
|
489
|
+
return this.data.from_dv(dv, at, a);
|
490
|
+
},
|
491
|
+
}
|
492
|
+
|
493
|
+
function SpiceMsgDisplayDrawFill(a, at)
|
494
|
+
{
|
495
|
+
this.from_buffer(a, at);
|
496
|
+
}
|
497
|
+
|
498
|
+
SpiceMsgDisplayDrawFill.prototype =
|
499
|
+
{
|
500
|
+
from_buffer: function(a, at)
|
501
|
+
{
|
502
|
+
at = at || 0;
|
503
|
+
var dv = new SpiceDataView(a);
|
504
|
+
this.base = new SpiceMsgDisplayBase;
|
505
|
+
at = this.base.from_dv(dv, at, a);
|
506
|
+
this.data = new SpiceFill;
|
507
|
+
return this.data.from_dv(dv, at, a);
|
508
|
+
},
|
509
|
+
}
|
510
|
+
|
511
|
+
function SpiceMsgDisplayCopyBits(a, at)
|
512
|
+
{
|
513
|
+
this.from_buffer(a, at);
|
514
|
+
}
|
515
|
+
|
516
|
+
SpiceMsgDisplayCopyBits.prototype =
|
517
|
+
{
|
518
|
+
from_buffer: function(a, at)
|
519
|
+
{
|
520
|
+
at = at || 0;
|
521
|
+
var dv = new SpiceDataView(a);
|
522
|
+
this.base = new SpiceMsgDisplayBase;
|
523
|
+
at = this.base.from_dv(dv, at, a);
|
524
|
+
this.src_pos = new SpicePoint;
|
525
|
+
return this.src_pos.from_dv(dv, at, a);
|
526
|
+
},
|
527
|
+
}
|
528
|
+
|
529
|
+
|
530
|
+
function SpiceMsgSurfaceCreate(a, at)
|
531
|
+
{
|
532
|
+
this.from_buffer(a, at);
|
533
|
+
}
|
534
|
+
|
535
|
+
SpiceMsgSurfaceCreate.prototype =
|
536
|
+
{
|
537
|
+
from_buffer: function(a, at)
|
538
|
+
{
|
539
|
+
at = at || 0;
|
540
|
+
var dv = new SpiceDataView(a);
|
541
|
+
this.surface = new SpiceSurface;
|
542
|
+
return this.surface.from_dv(dv, at, a);
|
543
|
+
},
|
544
|
+
}
|
545
|
+
|
546
|
+
function SpiceMsgSurfaceDestroy(a, at)
|
547
|
+
{
|
548
|
+
this.from_buffer(a, at);
|
549
|
+
}
|
550
|
+
|
551
|
+
SpiceMsgSurfaceDestroy.prototype =
|
552
|
+
{
|
553
|
+
from_buffer: function(a, at)
|
554
|
+
{
|
555
|
+
at = at || 0;
|
556
|
+
var dv = new SpiceDataView(a);
|
557
|
+
this.surface_id = dv.getUint32(at, true); at += 4;
|
558
|
+
},
|
559
|
+
}
|
560
|
+
|
561
|
+
function SpiceMsgInputsInit(a, at)
|
562
|
+
{
|
563
|
+
this.from_buffer(a, at);
|
564
|
+
}
|
565
|
+
|
566
|
+
SpiceMsgInputsInit.prototype =
|
567
|
+
{
|
568
|
+
from_buffer: function(a, at)
|
569
|
+
{
|
570
|
+
at = at || 0;
|
571
|
+
var dv = new SpiceDataView(a);
|
572
|
+
this.keyboard_modifiers = dv.getUint16(at, true); at += 2;
|
573
|
+
return at;
|
574
|
+
},
|
575
|
+
}
|
576
|
+
|
577
|
+
function SpiceMsgInputsKeyModifiers(a, at)
|
578
|
+
{
|
579
|
+
this.from_buffer(a, at);
|
580
|
+
}
|
581
|
+
|
582
|
+
SpiceMsgInputsKeyModifiers.prototype =
|
583
|
+
{
|
584
|
+
from_buffer: function(a, at)
|
585
|
+
{
|
586
|
+
at = at || 0;
|
587
|
+
var dv = new SpiceDataView(a);
|
588
|
+
this.keyboard_modifiers = dv.getUint16(at, true); at += 2;
|
589
|
+
return at;
|
590
|
+
},
|
591
|
+
}
|
592
|
+
|
593
|
+
function SpiceMsgCursorInit(a, at)
|
594
|
+
{
|
595
|
+
this.from_buffer(a, at);
|
596
|
+
}
|
597
|
+
|
598
|
+
SpiceMsgCursorInit.prototype =
|
599
|
+
{
|
600
|
+
from_buffer: function(a, at, mb)
|
601
|
+
{
|
602
|
+
at = at || 0;
|
603
|
+
var dv = new SpiceDataView(a);
|
604
|
+
this.position = new SpicePoint16;
|
605
|
+
at = this.position.from_dv(dv, at, mb);
|
606
|
+
this.trail_length = dv.getUint16(at, true); at += 2;
|
607
|
+
this.trail_frequency = dv.getUint16(at, true); at += 2;
|
608
|
+
this.visible = dv.getUint8(at, true); at ++;
|
609
|
+
this.cursor = new SpiceCursor;
|
610
|
+
return this.cursor.from_dv(dv, at, a);
|
611
|
+
},
|
612
|
+
}
|
613
|
+
|
614
|
+
|
615
|
+
function SpiceMsgCursorSet(a, at)
|
616
|
+
{
|
617
|
+
this.from_buffer(a, at);
|
618
|
+
}
|
619
|
+
|
620
|
+
SpiceMsgCursorSet.prototype =
|
621
|
+
{
|
622
|
+
from_buffer: function(a, at, mb)
|
623
|
+
{
|
624
|
+
at = at || 0;
|
625
|
+
var dv = new SpiceDataView(a);
|
626
|
+
this.position = new SpicePoint16;
|
627
|
+
at = this.position.from_dv(dv, at, mb);
|
628
|
+
this.visible = dv.getUint8(at, true); at ++;
|
629
|
+
this.cursor = new SpiceCursor;
|
630
|
+
return this.cursor.from_dv(dv, at, a);
|
631
|
+
},
|
632
|
+
}
|
633
|
+
|
634
|
+
|
635
|
+
function SpiceMsgcMousePosition(sc, e)
|
636
|
+
{
|
637
|
+
// FIXME - figure out how to correctly compute display_id
|
638
|
+
this.display_id = 0;
|
639
|
+
this.buttons_state = sc.buttons_state;
|
640
|
+
if (e)
|
641
|
+
{
|
642
|
+
this.x = e.clientX - sc.display.surfaces[sc.display.primary_surface].canvas.offsetLeft + document.body.scrollLeft;
|
643
|
+
this.y = e.clientY - sc.display.surfaces[sc.display.primary_surface].canvas.offsetTop + document.body.scrollTop;
|
644
|
+
sc.mousex = this.x;
|
645
|
+
sc.mousey = this.y;
|
646
|
+
}
|
647
|
+
else
|
648
|
+
{
|
649
|
+
this.x = this.y = this.buttons_state = 0;
|
650
|
+
}
|
651
|
+
}
|
652
|
+
|
653
|
+
SpiceMsgcMousePosition.prototype =
|
654
|
+
{
|
655
|
+
to_buffer: function(a, at)
|
656
|
+
{
|
657
|
+
at = at || 0;
|
658
|
+
var dv = new SpiceDataView(a);
|
659
|
+
dv.setUint32(at, this.x, true); at += 4;
|
660
|
+
dv.setUint32(at, this.y, true); at += 4;
|
661
|
+
dv.setUint16(at, this.buttons_state, true); at += 2;
|
662
|
+
dv.setUint8(at, this.display_id, true); at += 1;
|
663
|
+
return at;
|
664
|
+
},
|
665
|
+
buffer_size: function()
|
666
|
+
{
|
667
|
+
return 11;
|
668
|
+
}
|
669
|
+
}
|
670
|
+
|
671
|
+
function SpiceMsgcMouseMotion(sc, e)
|
672
|
+
{
|
673
|
+
// FIXME - figure out how to correctly compute display_id
|
674
|
+
this.display_id = 0;
|
675
|
+
this.buttons_state = sc.buttons_state;
|
676
|
+
if (e)
|
677
|
+
{
|
678
|
+
this.x = e.clientX - sc.display.surfaces[sc.display.primary_surface].canvas.offsetLeft;
|
679
|
+
this.y = e.clientY - sc.display.surfaces[sc.display.primary_surface].canvas.offsetTop;
|
680
|
+
|
681
|
+
if (sc.mousex !== undefined)
|
682
|
+
{
|
683
|
+
this.x -= sc.mousex;
|
684
|
+
this.y -= sc.mousey;
|
685
|
+
}
|
686
|
+
sc.mousex = e.clientX - sc.display.surfaces[sc.display.primary_surface].canvas.offsetLeft;
|
687
|
+
sc.mousey = e.clientY - sc.display.surfaces[sc.display.primary_surface].canvas.offsetTop;
|
688
|
+
}
|
689
|
+
else
|
690
|
+
{
|
691
|
+
this.x = this.y = this.buttons_state = 0;
|
692
|
+
}
|
693
|
+
}
|
694
|
+
|
695
|
+
/* Use the same functions as for MousePosition */
|
696
|
+
SpiceMsgcMouseMotion.prototype.to_buffer = SpiceMsgcMousePosition.prototype.to_buffer;
|
697
|
+
SpiceMsgcMouseMotion.prototype.buffer_size = SpiceMsgcMousePosition.prototype.buffer_size;
|
698
|
+
|
699
|
+
function SpiceMsgcMousePress(sc, e)
|
700
|
+
{
|
701
|
+
if (e)
|
702
|
+
{
|
703
|
+
this.button = e.button + 1;
|
704
|
+
this.buttons_state = 1 << e.button;
|
705
|
+
sc.buttons_state = this.buttons_state;
|
706
|
+
}
|
707
|
+
else
|
708
|
+
{
|
709
|
+
this.button = SPICE_MOUSE_BUTTON_LEFT;
|
710
|
+
this.buttons_state = SPICE_MOUSE_BUTTON_MASK_LEFT;
|
711
|
+
}
|
712
|
+
}
|
713
|
+
|
714
|
+
SpiceMsgcMousePress.prototype =
|
715
|
+
{
|
716
|
+
to_buffer: function(a, at)
|
717
|
+
{
|
718
|
+
at = at || 0;
|
719
|
+
var dv = new SpiceDataView(a);
|
720
|
+
dv.setUint8(at, this.button, true); at ++;
|
721
|
+
dv.setUint16(at, this.buttons_state, true); at += 2;
|
722
|
+
return at;
|
723
|
+
},
|
724
|
+
buffer_size: function()
|
725
|
+
{
|
726
|
+
return 3;
|
727
|
+
}
|
728
|
+
}
|
729
|
+
|
730
|
+
function SpiceMsgcMouseRelease(sc, e)
|
731
|
+
{
|
732
|
+
if (e)
|
733
|
+
{
|
734
|
+
this.button = e.button + 1;
|
735
|
+
this.buttons_state = 0;
|
736
|
+
sc.buttons_state = this.buttons_state;
|
737
|
+
}
|
738
|
+
else
|
739
|
+
{
|
740
|
+
this.button = SPICE_MOUSE_BUTTON_LEFT;
|
741
|
+
this.buttons_state = 0;
|
742
|
+
}
|
743
|
+
}
|
744
|
+
|
745
|
+
/* Use the same functions as for MousePress */
|
746
|
+
SpiceMsgcMouseRelease.prototype.to_buffer = SpiceMsgcMousePress.prototype.to_buffer;
|
747
|
+
SpiceMsgcMouseRelease.prototype.buffer_size = SpiceMsgcMousePress.prototype.buffer_size;
|
748
|
+
|
749
|
+
|
750
|
+
function SpiceMsgcKeyDown(e)
|
751
|
+
{
|
752
|
+
if (e)
|
753
|
+
{
|
754
|
+
this.code = keycode_to_start_scan(e.keyCode);
|
755
|
+
}
|
756
|
+
else
|
757
|
+
{
|
758
|
+
this.code = 0;
|
759
|
+
}
|
760
|
+
}
|
761
|
+
|
762
|
+
SpiceMsgcKeyDown.prototype =
|
763
|
+
{
|
764
|
+
to_buffer: function(a, at)
|
765
|
+
{
|
766
|
+
at = at || 0;
|
767
|
+
var dv = new SpiceDataView(a);
|
768
|
+
dv.setUint32(at, this.code, true); at += 4;
|
769
|
+
return at;
|
770
|
+
},
|
771
|
+
buffer_size: function()
|
772
|
+
{
|
773
|
+
return 4;
|
774
|
+
}
|
775
|
+
}
|
776
|
+
|
777
|
+
function SpiceMsgcKeyUp(e)
|
778
|
+
{
|
779
|
+
if (e)
|
780
|
+
{
|
781
|
+
this.code = keycode_to_end_scan(e.keyCode);
|
782
|
+
}
|
783
|
+
else
|
784
|
+
{
|
785
|
+
this.code = 0;
|
786
|
+
}
|
787
|
+
}
|
788
|
+
|
789
|
+
/* Use the same functions as for KeyDown */
|
790
|
+
SpiceMsgcKeyUp.prototype.to_buffer = SpiceMsgcKeyDown.prototype.to_buffer;
|
791
|
+
SpiceMsgcKeyUp.prototype.buffer_size = SpiceMsgcKeyDown.prototype.buffer_size;
|
792
|
+
|
793
|
+
function SpiceMsgDisplayStreamCreate(a, at)
|
794
|
+
{
|
795
|
+
this.from_buffer(a, at);
|
796
|
+
}
|
797
|
+
|
798
|
+
SpiceMsgDisplayStreamCreate.prototype =
|
799
|
+
{
|
800
|
+
from_buffer: function(a, at)
|
801
|
+
{
|
802
|
+
at = at || 0;
|
803
|
+
var dv = new SpiceDataView(a);
|
804
|
+
this.surface_id = dv.getUint32(at, true); at += 4;
|
805
|
+
this.id = dv.getUint32(at, true); at += 4;
|
806
|
+
this.flags = dv.getUint8(at, true); at += 1;
|
807
|
+
this.codec_type = dv.getUint8(at, true); at += 1;
|
808
|
+
/*stamp */ at += 8;
|
809
|
+
this.stream_width = dv.getUint32(at, true); at += 4;
|
810
|
+
this.stream_height = dv.getUint32(at, true); at += 4;
|
811
|
+
this.src_width = dv.getUint32(at, true); at += 4;
|
812
|
+
this.src_height = dv.getUint32(at, true); at += 4;
|
813
|
+
|
814
|
+
this.dest = new SpiceRect;
|
815
|
+
at = this.dest.from_dv(dv, at, a);
|
816
|
+
this.clip = new SpiceClip;
|
817
|
+
this.clip.from_dv(dv, at, a);
|
818
|
+
},
|
819
|
+
}
|
820
|
+
|
821
|
+
function SpiceStreamDataHeader(a, at)
|
822
|
+
{
|
823
|
+
}
|
824
|
+
|
825
|
+
SpiceStreamDataHeader.prototype =
|
826
|
+
{
|
827
|
+
from_dv : function(dv, at, mb)
|
828
|
+
{
|
829
|
+
this.id = dv.getUint32(at, true); at += 4;
|
830
|
+
this.multi_media_time = dv.getUint32(at, true); at += 4;
|
831
|
+
return at;
|
832
|
+
},
|
833
|
+
}
|
834
|
+
|
835
|
+
function SpiceMsgDisplayStreamData(a, at)
|
836
|
+
{
|
837
|
+
this.from_buffer(a, at);
|
838
|
+
}
|
839
|
+
|
840
|
+
SpiceMsgDisplayStreamData.prototype =
|
841
|
+
{
|
842
|
+
from_buffer: function(a, at)
|
843
|
+
{
|
844
|
+
at = at || 0;
|
845
|
+
var dv = new SpiceDataView(a);
|
846
|
+
this.base = new SpiceStreamDataHeader;
|
847
|
+
at = this.base.from_dv(dv, at, a);
|
848
|
+
this.data_size = dv.getUint32(at, true); at += 4;
|
849
|
+
this.data = dv.u8.subarray(at, at + this.data_size);
|
850
|
+
},
|
851
|
+
}
|
852
|
+
|
853
|
+
function SpiceMsgDisplayStreamClip(a, at)
|
854
|
+
{
|
855
|
+
this.from_buffer(a, at);
|
856
|
+
}
|
857
|
+
|
858
|
+
SpiceMsgDisplayStreamClip.prototype =
|
859
|
+
{
|
860
|
+
from_buffer: function(a, at)
|
861
|
+
{
|
862
|
+
at = at || 0;
|
863
|
+
var dv = new SpiceDataView(a);
|
864
|
+
this.id = dv.getUint32(at, true); at += 4;
|
865
|
+
this.clip = new SpiceClip;
|
866
|
+
this.clip.from_dv(dv, at, a);
|
867
|
+
},
|
868
|
+
}
|
869
|
+
|
870
|
+
function SpiceMsgDisplayStreamDestroy(a, at)
|
871
|
+
{
|
872
|
+
this.from_buffer(a, at);
|
873
|
+
}
|
874
|
+
|
875
|
+
SpiceMsgDisplayStreamDestroy.prototype =
|
876
|
+
{
|
877
|
+
from_buffer: function(a, at)
|
878
|
+
{
|
879
|
+
at = at || 0;
|
880
|
+
var dv = new SpiceDataView(a);
|
881
|
+
this.id = dv.getUint32(at, true); at += 4;
|
882
|
+
},
|
883
|
+
}
|