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.
Files changed (30) hide show
  1. data/COPYING +674 -0
  2. data/COPYING.LESSER +165 -0
  3. data/LICENSE.txt +15 -0
  4. data/README.md +35 -0
  5. data/lib/spice-html5-rails/version.rb +7 -0
  6. data/lib/spice-html5-rails.rb +10 -0
  7. data/vendor/assets/javascripts/spice-html5.js +25 -0
  8. data/vendor/assets/javascripts/spiceHTML5/atKeynames.js +183 -0
  9. data/vendor/assets/javascripts/spiceHTML5/bitmap.js +51 -0
  10. data/vendor/assets/javascripts/spiceHTML5/cursor.js +92 -0
  11. data/vendor/assets/javascripts/spiceHTML5/display.js +806 -0
  12. data/vendor/assets/javascripts/spiceHTML5/enums.js +282 -0
  13. data/vendor/assets/javascripts/spiceHTML5/inputs.js +271 -0
  14. data/vendor/assets/javascripts/spiceHTML5/lz.js +166 -0
  15. data/vendor/assets/javascripts/spiceHTML5/main.js +177 -0
  16. data/vendor/assets/javascripts/spiceHTML5/png.js +256 -0
  17. data/vendor/assets/javascripts/spiceHTML5/quic.js +1335 -0
  18. data/vendor/assets/javascripts/spiceHTML5/spiceconn.js +455 -0
  19. data/vendor/assets/javascripts/spiceHTML5/spicedataview.js +96 -0
  20. data/vendor/assets/javascripts/spiceHTML5/spicemsg.js +883 -0
  21. data/vendor/assets/javascripts/spiceHTML5/spicetype.js +480 -0
  22. data/vendor/assets/javascripts/spiceHTML5/thirdparty/jsbn.js +589 -0
  23. data/vendor/assets/javascripts/spiceHTML5/thirdparty/prng4.js +79 -0
  24. data/vendor/assets/javascripts/spiceHTML5/thirdparty/rng.js +102 -0
  25. data/vendor/assets/javascripts/spiceHTML5/thirdparty/rsa.js +146 -0
  26. data/vendor/assets/javascripts/spiceHTML5/thirdparty/sha1.js +346 -0
  27. data/vendor/assets/javascripts/spiceHTML5/ticket.js +250 -0
  28. data/vendor/assets/javascripts/spiceHTML5/utils.js +261 -0
  29. data/vendor/assets/javascripts/spiceHTML5/wire.js +123 -0
  30. metadata +108 -0
@@ -0,0 +1,480 @@
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 types
23
+ ** This file contains classes for common spice types.
24
+ ** Generally, they are used as helpers in reading and writing messages
25
+ ** to and from the server.
26
+ **--------------------------------------------------------------------------*/
27
+
28
+ function SpiceChannelId()
29
+ {
30
+ }
31
+ SpiceChannelId.prototype =
32
+ {
33
+ from_dv: function(dv, at, mb)
34
+ {
35
+ this.type = dv.getUint8(at, true); at ++;
36
+ this.id = dv.getUint8(at, true); at ++;
37
+ return at;
38
+ },
39
+ }
40
+
41
+ function SpiceRect()
42
+ {
43
+ }
44
+
45
+ SpiceRect.prototype =
46
+ {
47
+ from_dv: function(dv, at, mb)
48
+ {
49
+ this.top = dv.getUint32(at, true); at += 4;
50
+ this.left = dv.getUint32(at, true); at += 4;
51
+ this.bottom = dv.getUint32(at, true); at += 4;
52
+ this.right = dv.getUint32(at, true); at += 4;
53
+ return at;
54
+ },
55
+ is_same_size : function(r)
56
+ {
57
+ if ((this.bottom - this.top) == (r.bottom - r.top) &&
58
+ (this.right - this.left) == (r.right - r.left) )
59
+ return true;
60
+
61
+ return false;
62
+ },
63
+ }
64
+
65
+ function SpiceClipRects()
66
+ {
67
+ }
68
+
69
+ SpiceClipRects.prototype =
70
+ {
71
+ from_dv: function(dv, at, mb)
72
+ {
73
+ var i;
74
+ this.num_rects = dv.getUint32(at, true); at += 4;
75
+ if (this.num_rects > 0)
76
+ this.rects = [];
77
+ for (i = 0; i < this.num_rects; i++)
78
+ {
79
+ this.rects[i] = new SpiceRect();
80
+ at = this.rects[i].from_dv(dv, at, mb);
81
+ }
82
+ return at;
83
+ },
84
+ }
85
+
86
+ function SpiceClip()
87
+ {
88
+ }
89
+
90
+ SpiceClip.prototype =
91
+ {
92
+ from_dv: function(dv, at, mb)
93
+ {
94
+ this.type = dv.getUint8(at, true); at ++;
95
+ if (this.type == SPICE_CLIP_TYPE_RECTS)
96
+ {
97
+ this.rects = new SpiceClipRects();
98
+ at = this.rects.from_dv(dv, at, mb);
99
+ }
100
+ return at;
101
+ },
102
+ }
103
+
104
+ function SpiceImageDescriptor()
105
+ {
106
+ }
107
+
108
+ SpiceImageDescriptor.prototype =
109
+ {
110
+ from_dv: function(dv, at, mb)
111
+ {
112
+ this.id = dv.getUint32(at, true); at += 4;
113
+ this.id += (dv.getUint32(at, true) << 32); at += 4;
114
+ this.type = dv.getUint8(at, true); at ++;
115
+ this.flags = dv.getUint8(at, true); at ++;
116
+ this.width = dv.getUint32(at, true); at += 4;
117
+ this.height= dv.getUint32(at, true); at += 4;
118
+ return at;
119
+ },
120
+ }
121
+
122
+ function SpicePalette()
123
+ {
124
+ }
125
+
126
+ SpicePalette.prototype =
127
+ {
128
+ from_dv: function(dv, at, mb)
129
+ {
130
+ var i;
131
+ this.unique = [];
132
+ this.unique[0] = dv.getUint32(at, true); at += 4;
133
+ this.unique[1] = dv.getUint32(at, true); at += 4;
134
+ this.num_ents = dv.getUint16(at, true); at += 2;
135
+ this.ents = [];
136
+ for (i = 0; i < this.num_ents; i++)
137
+ {
138
+ this.ents[i] = dv.getUint32(at, true); at += 4;
139
+ }
140
+ return at;
141
+ },
142
+ }
143
+
144
+ function SpiceBitmap()
145
+ {
146
+ }
147
+
148
+ SpiceBitmap.prototype =
149
+ {
150
+ from_dv: function(dv, at, mb)
151
+ {
152
+ this.format = dv.getUint8(at, true); at++;
153
+ this.flags = dv.getUint8(at, true); at++;
154
+ this.x = dv.getUint32(at, true); at += 4;
155
+ this.y = dv.getUint32(at, true); at += 4;
156
+ this.stride = dv.getUint32(at, true); at += 4;
157
+ if (this.flags & SPICE_BITMAP_FLAGS_PAL_FROM_CACHE)
158
+ {
159
+ this.palette_id = [];
160
+ this.palette_id[0] = dv.getUint32(at, true); at += 4;
161
+ this.palette_id[1] = dv.getUint32(at, true); at += 4;
162
+ }
163
+ else
164
+ {
165
+ var offset = dv.getUint32(at, true); at += 4;
166
+ if (offset == 0)
167
+ this.palette = null;
168
+ else
169
+ {
170
+ this.palette = new SpicePalette;
171
+ this.palette.from_dv(dv, offset, mb);
172
+ }
173
+ }
174
+ // FIXME - should probably constrain this to the offset
175
+ // of palette, if non zero
176
+ this.data = mb.slice(at);
177
+ at += this.data.byteLength;
178
+ return at;
179
+ },
180
+ }
181
+
182
+ function SpiceImage()
183
+ {
184
+ }
185
+
186
+ SpiceImage.prototype =
187
+ {
188
+ from_dv: function(dv, at, mb)
189
+ {
190
+ this.descriptor = new SpiceImageDescriptor;
191
+ at = this.descriptor.from_dv(dv, at, mb);
192
+
193
+ if (this.descriptor.type == SPICE_IMAGE_TYPE_LZ_RGB)
194
+ {
195
+ this.lz_rgb = new Object();
196
+ this.lz_rgb.length = dv.getUint32(at, true); at += 4;
197
+ var initial_at = at;
198
+ this.lz_rgb.magic = "";
199
+ for (var i = 3; i >= 0; i--)
200
+ this.lz_rgb.magic += String.fromCharCode(dv.getUint8(at + i));
201
+ at += 4;
202
+
203
+ // NOTE: The endian change is *correct*
204
+ this.lz_rgb.version = dv.getUint32(at); at += 4;
205
+ this.lz_rgb.type = dv.getUint32(at); at += 4;
206
+ this.lz_rgb.width = dv.getUint32(at); at += 4;
207
+ this.lz_rgb.height = dv.getUint32(at); at += 4;
208
+ this.lz_rgb.stride = dv.getUint32(at); at += 4;
209
+ this.lz_rgb.top_down = dv.getUint32(at); at += 4;
210
+
211
+ var header_size = at - initial_at;
212
+
213
+ this.lz_rgb.data = mb.slice(at, this.lz_rgb.length + at - header_size);
214
+ at += this.lz_rgb.data.byteLength;
215
+
216
+ }
217
+
218
+ if (this.descriptor.type == SPICE_IMAGE_TYPE_BITMAP)
219
+ {
220
+ this.bitmap = new SpiceBitmap;
221
+ at = this.bitmap.from_dv(dv, at, mb);
222
+ }
223
+
224
+ if (this.descriptor.type == SPICE_IMAGE_TYPE_SURFACE)
225
+ {
226
+ this.surface_id = dv.getUint32(at, true); at += 4;
227
+ }
228
+
229
+ if (this.descriptor.type == SPICE_IMAGE_TYPE_JPEG)
230
+ {
231
+ this.jpeg = new Object;
232
+ this.jpeg.data_size = dv.getUint32(at, true); at += 4;
233
+ this.jpeg.data = mb.slice(at);
234
+ at += this.jpeg.data.byteLength;
235
+ }
236
+
237
+ if (this.descriptor.type == SPICE_IMAGE_TYPE_JPEG_ALPHA)
238
+ {
239
+ this.jpeg_alpha = new Object;
240
+ this.jpeg_alpha.flags = dv.getUint8(at, true); at += 1;
241
+ this.jpeg_alpha.jpeg_size = dv.getUint32(at, true); at += 4;
242
+ this.jpeg_alpha.data_size = dv.getUint32(at, true); at += 4;
243
+ this.jpeg_alpha.data = mb.slice(at, this.jpeg_alpha.jpeg_size + at);
244
+ at += this.jpeg_alpha.data.byteLength;
245
+ // Alpha channel is an LZ image
246
+ this.jpeg_alpha.alpha = new Object();
247
+ this.jpeg_alpha.alpha.length = this.jpeg_alpha.data_size - this.jpeg_alpha.jpeg_size;
248
+ var initial_at = at;
249
+ this.jpeg_alpha.alpha.magic = "";
250
+ for (var i = 3; i >= 0; i--)
251
+ this.jpeg_alpha.alpha.magic += String.fromCharCode(dv.getUint8(at + i));
252
+ at += 4;
253
+
254
+ // NOTE: The endian change is *correct*
255
+ this.jpeg_alpha.alpha.version = dv.getUint32(at); at += 4;
256
+ this.jpeg_alpha.alpha.type = dv.getUint32(at); at += 4;
257
+ this.jpeg_alpha.alpha.width = dv.getUint32(at); at += 4;
258
+ this.jpeg_alpha.alpha.height = dv.getUint32(at); at += 4;
259
+ this.jpeg_alpha.alpha.stride = dv.getUint32(at); at += 4;
260
+ this.jpeg_alpha.alpha.top_down = dv.getUint32(at); at += 4;
261
+
262
+ var header_size = at - initial_at;
263
+
264
+ this.jpeg_alpha.alpha.data = mb.slice(at, this.jpeg_alpha.alpha.length + at - header_size);
265
+ at += this.jpeg_alpha.alpha.data.byteLength;
266
+ }
267
+
268
+ if (this.descriptor.type == SPICE_IMAGE_TYPE_QUIC)
269
+ {
270
+ this.quic = new SpiceQuic;
271
+ at = this.quic.from_dv(dv, at, mb);
272
+ }
273
+ return at;
274
+ },
275
+ }
276
+
277
+
278
+ function SpiceQMask()
279
+ {
280
+ }
281
+
282
+ SpiceQMask.prototype =
283
+ {
284
+ from_dv: function(dv, at, mb)
285
+ {
286
+ this.flags = dv.getUint8(at, true); at++;
287
+ this.pos = new SpicePoint;
288
+ at = this.pos.from_dv(dv, at, mb);
289
+ var offset = dv.getUint32(at, true); at += 4;
290
+ if (offset == 0)
291
+ {
292
+ this.bitmap = null;
293
+ return at;
294
+ }
295
+
296
+ this.bitmap = new SpiceImage;
297
+ return this.bitmap.from_dv(dv, offset, mb);
298
+ },
299
+ }
300
+
301
+
302
+ function SpicePattern()
303
+ {
304
+ }
305
+
306
+ SpicePattern.prototype =
307
+ {
308
+ from_dv: function(dv, at, mb)
309
+ {
310
+ var offset = dv.getUint32(at, true); at += 4;
311
+ if (offset == 0)
312
+ {
313
+ this.pat = null;
314
+ }
315
+ else
316
+ {
317
+ this.pat = new SpiceImage;
318
+ this.pat.from_dv(dv, offset, mb);
319
+ }
320
+
321
+ this.pos = new SpicePoint;
322
+ return this.pos.from_dv(dv, at, mb);
323
+ }
324
+ }
325
+
326
+ function SpiceBrush()
327
+ {
328
+ }
329
+
330
+ SpiceBrush.prototype =
331
+ {
332
+ from_dv: function(dv, at, mb)
333
+ {
334
+ this.type = dv.getUint8(at, true); at ++;
335
+ if (this.type == SPICE_BRUSH_TYPE_SOLID)
336
+ {
337
+ this.color = dv.getUint32(at, true); at += 4;
338
+ }
339
+ else if (this.type == SPICE_BRUSH_TYPE_PATTERN)
340
+ {
341
+ this.pattern = new SpicePattern;
342
+ at = this.pattern.from_dv(dv, at, mb);
343
+ }
344
+ return at;
345
+ },
346
+ }
347
+
348
+ function SpiceFill()
349
+ {
350
+ }
351
+
352
+ SpiceFill.prototype =
353
+ {
354
+ from_dv: function(dv, at, mb)
355
+ {
356
+ this.brush = new SpiceBrush;
357
+ at = this.brush.from_dv(dv, at, mb);
358
+ this.rop_descriptor = dv.getUint16(at, true); at += 2;
359
+ this.mask = new SpiceQMask;
360
+ return this.mask.from_dv(dv, at, mb);
361
+ },
362
+ }
363
+
364
+
365
+ function SpiceCopy()
366
+ {
367
+ }
368
+
369
+ SpiceCopy.prototype =
370
+ {
371
+ from_dv: function(dv, at, mb)
372
+ {
373
+ var offset = dv.getUint32(at, true); at += 4;
374
+ if (offset == 0)
375
+ {
376
+ this.src_bitmap = null;
377
+ }
378
+ else
379
+ {
380
+ this.src_bitmap = new SpiceImage;
381
+ this.src_bitmap.from_dv(dv, offset, mb);
382
+ }
383
+ this.src_area = new SpiceRect;
384
+ at = this.src_area.from_dv(dv, at, mb);
385
+ this.rop_descriptor = dv.getUint16(at, true); at += 2;
386
+ this.scale_mode = dv.getUint8(at, true); at ++;
387
+ this.mask = new SpiceQMask;
388
+ return this.mask.from_dv(dv, at, mb);
389
+ },
390
+ }
391
+
392
+ function SpicePoint16()
393
+ {
394
+ }
395
+
396
+ SpicePoint16.prototype =
397
+ {
398
+ from_dv: function(dv, at, mb)
399
+ {
400
+ this.x = dv.getUint16(at, true); at += 2;
401
+ this.y = dv.getUint16(at, true); at += 2;
402
+ return at;
403
+ },
404
+ }
405
+
406
+ function SpicePoint()
407
+ {
408
+ }
409
+
410
+ SpicePoint.prototype =
411
+ {
412
+ from_dv: function(dv, at, mb)
413
+ {
414
+ this.x = dv.getUint32(at, true); at += 4;
415
+ this.y = dv.getUint32(at, true); at += 4;
416
+ return at;
417
+ },
418
+ }
419
+
420
+ function SpiceCursorHeader()
421
+ {
422
+ }
423
+
424
+ SpiceCursorHeader.prototype =
425
+ {
426
+ from_dv: function(dv, at, mb)
427
+ {
428
+ this.unique = [];
429
+ this.unique[0] = dv.getUint32(at, true); at += 4;
430
+ this.unique[1] = dv.getUint32(at, true); at += 4;
431
+ this.type = dv.getUint8(at, true); at ++;
432
+ this.width = dv.getUint16(at, true); at += 2;
433
+ this.height = dv.getUint16(at, true); at += 2;
434
+ this.hot_spot_x = dv.getUint16(at, true); at += 2;
435
+ this.hot_spot_y = dv.getUint16(at, true); at += 2;
436
+ return at;
437
+ },
438
+ }
439
+
440
+ function SpiceCursor()
441
+ {
442
+ }
443
+
444
+ SpiceCursor.prototype =
445
+ {
446
+ from_dv: function(dv, at, mb)
447
+ {
448
+ this.flags = dv.getUint16(at, true); at += 2;
449
+ if (this.flags & SPICE_CURSOR_FLAGS_NONE)
450
+ this.header = null;
451
+ else
452
+ {
453
+ this.header = new SpiceCursorHeader;
454
+ at = this.header.from_dv(dv, at, mb);
455
+ this.data = mb.slice(at);
456
+ at += this.data.byteLength;
457
+ }
458
+ return at;
459
+ },
460
+ }
461
+
462
+ function SpiceSurface()
463
+ {
464
+ }
465
+
466
+ SpiceSurface.prototype =
467
+ {
468
+ from_dv: function(dv, at, mb)
469
+ {
470
+ this.surface_id = dv.getUint32(at, true); at += 4;
471
+ this.width = dv.getUint32(at, true); at += 4;
472
+ this.height = dv.getUint32(at, true); at += 4;
473
+ this.format = dv.getUint32(at, true); at += 4;
474
+ this.flags = dv.getUint32(at, true); at += 4;
475
+ return at;
476
+ },
477
+ }
478
+
479
+ /* FIXME - SpiceImage types lz_plt, jpeg, zlib_glz, and jpeg_alpha are
480
+ completely unimplemented */