EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
caps.js
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014-2015 Sylvain Peyrefitte
3 *
4 * This file is part of node-rdpjs.
5 *
6 * node-rdpjs is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20var type = require('../../core').type;
21var log = require('../../core').log;
22var error = require('../../core').error;
23
24/**
25 * @see http://msdn.microsoft.com/en-us/library/cc240486.aspx
26 */
27var CapsType = {
28 CAPSTYPE_GENERAL : 0x0001,
29 CAPSTYPE_BITMAP : 0x0002,
30 CAPSTYPE_ORDER : 0x0003,
31 CAPSTYPE_BITMAPCACHE : 0x0004,
32 CAPSTYPE_CONTROL : 0x0005,
33 CAPSTYPE_ACTIVATION : 0x0007,
34 CAPSTYPE_POINTER : 0x0008,
35 CAPSTYPE_SHARE : 0x0009,
36 CAPSTYPE_COLORCACHE : 0x000A,
37 CAPSTYPE_SOUND : 0x000C,
38 CAPSTYPE_INPUT : 0x000D,
39 CAPSTYPE_FONT : 0x000E,
40 CAPSTYPE_BRUSH : 0x000F,
41 CAPSTYPE_GLYPHCACHE : 0x0010,
42 CAPSTYPE_OFFSCREENCACHE : 0x0011,
43 CAPSTYPE_BITMAPCACHE_HOSTSUPPORT : 0x0012,
44 CAPSTYPE_BITMAPCACHE_REV2 : 0x0013,
45 CAPSTYPE_VIRTUALCHANNEL : 0x0014,
46 CAPSTYPE_DRAWNINEGRIDCACHE : 0x0015,
47 CAPSTYPE_DRAWGDIPLUS : 0x0016,
48 CAPSTYPE_RAIL : 0x0017,
49 CAPSTYPE_WINDOW : 0x0018,
50 CAPSETTYPE_COMPDESK : 0x0019,
51 CAPSETTYPE_MULTIFRAGMENTUPDATE : 0x001A,
52 CAPSETTYPE_LARGE_POINTER : 0x001B,
53 CAPSETTYPE_SURFACE_COMMANDS : 0x001C,
54 CAPSETTYPE_BITMAP_CODECS : 0x001D,
55 CAPSSETTYPE_FRAME_ACKNOWLEDGE : 0x001E
56};
57
58/**
59 * @see http://msdn.microsoft.com/en-us/library/cc240549.aspx
60 */
61var MajorType = {
62 OSMAJORTYPE_UNSPECIFIED : 0x0000,
63 OSMAJORTYPE_WINDOWS : 0x0001,
64 OSMAJORTYPE_OS2 : 0x0002,
65 OSMAJORTYPE_MACINTOSH : 0x0003,
66 OSMAJORTYPE_UNIX : 0x0004,
67 OSMAJORTYPE_IOS : 0x0005,
68 OSMAJORTYPE_OSX : 0x0006,
69 OSMAJORTYPE_ANDROID : 0x0007
70};
71
72/**
73 * @see http://msdn.microsoft.com/en-us/library/cc240549.aspx
74 */
75var MinorType = {
76 OSMINORTYPE_UNSPECIFIED : 0x0000,
77 OSMINORTYPE_WINDOWS_31X : 0x0001,
78 OSMINORTYPE_WINDOWS_95 : 0x0002,
79 OSMINORTYPE_WINDOWS_NT : 0x0003,
80 OSMINORTYPE_OS2_V21 : 0x0004,
81 OSMINORTYPE_POWER_PC : 0x0005,
82 OSMINORTYPE_MACINTOSH : 0x0006,
83 OSMINORTYPE_NATIVE_XSERVER : 0x0007,
84 OSMINORTYPE_PSEUDO_XSERVER : 0x0008,
85 OSMINORTYPE_WINDOWS_RT : 0x0009
86};
87
88/**
89 * @see http://msdn.microsoft.com/en-us/library/cc240549.aspx
90 */
91var GeneralExtraFlag = {
92 FASTPATH_OUTPUT_SUPPORTED : 0x0001,
93 NO_BITMAP_COMPRESSION_HDR : 0x0400,
94 LONG_CREDENTIALS_SUPPORTED : 0x0004,
95 AUTORECONNECT_SUPPORTED : 0x0008,
96 ENC_SALTED_CHECKSUM : 0x0010
97};
98
99var Boolean = {
100 FALSE : 0x00,
101 TRUE : 0x01
102};
103
104/**
105 * @see http://msdn.microsoft.com/en-us/library/cc240556.aspx
106 */
107var OrderFlag = {
108 NEGOTIATEORDERSUPPORT : 0x0002,
109 ZEROBOUNDSDELTASSUPPORT : 0x0008,
110 COLORINDEXSUPPORT : 0x0020,
111 SOLIDPATTERNBRUSHONLY : 0x0040,
112 ORDERFLAGS_EXTRA_FLAGS : 0x0080
113};
114
115/**
116 * @see http://msdn.microsoft.com/en-us/library/cc240556.aspx
117 */
118var Order = {
119 TS_NEG_DSTBLT_INDEX : 0x00,
120 TS_NEG_PATBLT_INDEX : 0x01,
121 TS_NEG_SCRBLT_INDEX : 0x02,
122 TS_NEG_MEMBLT_INDEX : 0x03,
123 TS_NEG_MEM3BLT_INDEX : 0x04,
124 TS_NEG_DRAWNINEGRID_INDEX : 0x07,
125 TS_NEG_LINETO_INDEX : 0x08,
126 TS_NEG_MULTI_DRAWNINEGRID_INDEX : 0x09,
127 TS_NEG_SAVEBITMAP_INDEX : 0x0B,
128 TS_NEG_MULTIDSTBLT_INDEX : 0x0F,
129 TS_NEG_MULTIPATBLT_INDEX : 0x10,
130 TS_NEG_MULTISCRBLT_INDEX : 0x11,
131 TS_NEG_MULTIOPAQUERECT_INDEX : 0x12,
132 TS_NEG_FAST_INDEX_INDEX : 0x13,
133 TS_NEG_POLYGON_SC_INDEX : 0x14,
134 TS_NEG_POLYGON_CB_INDEX : 0x15,
135 TS_NEG_POLYLINE_INDEX : 0x16,
136 TS_NEG_FAST_GLYPH_INDEX : 0x18,
137 TS_NEG_ELLIPSE_SC_INDEX : 0x19,
138 TS_NEG_ELLIPSE_CB_INDEX : 0x1A,
139 TS_NEG_INDEX_INDEX : 0x1B
140};
141
142var OrderEx = {
143 ORDERFLAGS_EX_CACHE_BITMAP_REV3_SUPPORT : 0x0002,
144 ORDERFLAGS_EX_ALTSEC_FRAME_MARKER_SUPPORT : 0x0004
145};
146
147/**
148 * @see http://msdn.microsoft.com/en-us/library/cc240563.aspx
149 */
150var InputFlags = {
151 INPUT_FLAG_SCANCODES : 0x0001,
152 INPUT_FLAG_MOUSEX : 0x0004,
153 INPUT_FLAG_FASTPATH_INPUT : 0x0008,
154 INPUT_FLAG_UNICODE : 0x0010,
155 INPUT_FLAG_FASTPATH_INPUT2 : 0x0020,
156 INPUT_FLAG_UNUSED1 : 0x0040,
157 INPUT_FLAG_UNUSED2 : 0x0080,
158 TS_INPUT_FLAG_MOUSE_HWHEEL : 0x0100
159};
160
161/**
162 * @see http://msdn.microsoft.com/en-us/library/cc240564.aspx
163 */
164var BrushSupport = {
165 BRUSH_DEFAULT : 0x00000000,
166 BRUSH_COLOR_8x8 : 0x00000001,
167 BRUSH_COLOR_FULL : 0x00000002
168};
169
170/**
171 * @see http://msdn.microsoft.com/en-us/library/cc240565.aspx
172 */
173var GlyphSupport = {
174 GLYPH_SUPPORT_NONE : 0x0000,
175 GLYPH_SUPPORT_PARTIAL : 0x0001,
176 GLYPH_SUPPORT_FULL : 0x0002,
177 GLYPH_SUPPORT_ENCODE : 0x0003
178};
179
180/**
181 * @see http://msdn.microsoft.com/en-us/library/cc240550.aspx
182 */
183var OffscreenSupportLevel = {
184 FALSE : 0x00000000,
185 TRUE : 0x00000001
186};
187
188/**
189 * @see http://msdn.microsoft.com/en-us/library/cc240551.aspx
190 */
191var VirtualChannelCompressionFlag = {
192 VCCAPS_NO_COMPR : 0x00000000,
193 VCCAPS_COMPR_SC : 0x00000001,
194 VCCAPS_COMPR_CS_8K : 0x00000002
195};
196
197/**
198 * @see http://msdn.microsoft.com/en-us/library/cc240552.aspx
199 */
200var SoundFlag = {
201 NONE : 0x0000,
202 SOUND_BEEPS_FLAG : 0x0001
203};
204
205/**
206 * @see http://msdn.microsoft.com/en-us/library/cc240549.aspx
207 * @param opt {object} type options
208 * @returns {type.Component}
209 */
210function generalCapability(opt) {
211 var self = {
212 __TYPE__ : CapsType.CAPSTYPE_GENERAL,
213 osMajorType : new type.UInt16Le(),
214 osMinorType : new type.UInt16Le(),
215 protocolVersion : new type.UInt16Le(0x0200, {constant : true}),
216 pad2octetsA : new type.UInt16Le(),
217 generalCompressionTypes : new type.UInt16Le(0, {constant : true}),
218 extraFlags : new type.UInt16Le(),
219 updateCapabilityFlag : new type.UInt16Le(0, {constant : true}),
220 remoteUnshareFlag : new type.UInt16Le(0, {constant : true}),
221 generalCompressionLevel : new type.UInt16Le(0, {constant : true}),
222 refreshRectSupport : new type.UInt8(),
223 suppressOutputSupport : new type.UInt8()
224 };
225
226 return new type.Component(self, opt);
227}
228
229/**
230 * @see http://msdn.microsoft.com/en-us/library/cc240554.aspx
231 * @param opt {object} type options
232 * @returns {type.Component}
233 */
234function bitmapCapability(opt) {
235 var self = {
236 __TYPE__ : CapsType.CAPSTYPE_BITMAP,
237 preferredBitsPerPixel : new type.UInt16Le(),
238 receive1BitPerPixel : new type.UInt16Le(0x0001),
239 receive4BitsPerPixel : new type.UInt16Le(0x0001),
240 receive8BitsPerPixel : new type.UInt16Le(0x0001),
241 desktopWidth : new type.UInt16Le(),
242 desktopHeight : new type.UInt16Le(),
243 pad2octets : new type.UInt16Le(),
244 desktopResizeFlag : new type.UInt16Le(),
245 bitmapCompressionFlag : new type.UInt16Le(0x0001, {constant : true}),
246 highColorFlags : new type.UInt8(0),
247 drawingFlags : new type.UInt8(),
248 multipleRectangleSupport : new type.UInt16Le(0x0001, {constant : true}),
249 pad2octetsB : new type.UInt16Le()
250 };
251
252 return new type.Component(self, opt);
253}
254
255/**
256 * @see http://msdn.microsoft.com/en-us/library/cc240556.aspx
257 * @param orders {type.BinaryString|null} list of available orders
258 * @param opt {object} type options
259 * @returns {type.Component}
260 */
261function orderCapability(orders, opt) {
262 if(orders && orders.size() !== 32) {
263 throw new error.FatalError('NODE_RDP_PROTOCOL_PDU_CAPS_BAD_ORDERS_SIZE');
264 }
265
266 var self = {
267 __TYPE__ : CapsType.CAPSTYPE_ORDER,
268 terminalDescriptor : new type.BinaryString(Buffer.from(Array(16 + 1).join('\x00'), 'binary'), {readLength : new type.CallableValue(16)}),
269 pad4octetsA : new type.UInt32Le(0),
270 desktopSaveXGranularity : new type.UInt16Le(1),
271 desktopSaveYGranularity : new type.UInt16Le(20),
272 pad2octetsA : new type.UInt16Le(0),
273 maximumOrderLevel : new type.UInt16Le(1),
274 numberFonts : new type.UInt16Le(),
275 orderFlags : new type.UInt16Le(OrderFlag.NEGOTIATEORDERSUPPORT),
276 orderSupport : orders || new type.Factory(function(s) {
277 self.orderSupport = new type.BinaryString(null, {readLength : new type.CallableValue(32)}).read(s);
278 }),
279 textFlags : new type.UInt16Le(),
280 orderSupportExFlags : new type.UInt16Le(),
281 pad4octetsB : new type.UInt32Le(),
282 desktopSaveSize : new type.UInt32Le(480 * 480),
283 pad2octetsC : new type.UInt16Le(),
284 pad2octetsD : new type.UInt16Le(),
285 textANSICodePage : new type.UInt16Le(0),
286 pad2octetsE : new type.UInt16Le()
287 };
288
289 return new type.Component(self, opt);
290}
291
292/**
293 * @see http://msdn.microsoft.com/en-us/library/cc240559.aspx
294 * @param opt type options
295 * @returns {type.Component}
296 */
297function bitmapCacheCapability(opt) {
298 var self = {
299 __TYPE__ : CapsType.CAPSTYPE_BITMAPCACHE,
300 pad1 : new type.UInt32Le(),
301 pad2 : new type.UInt32Le(),
302 pad3 : new type.UInt32Le(),
303 pad4 : new type.UInt32Le(),
304 pad5 : new type.UInt32Le(),
305 pad6 : new type.UInt32Le(),
306 cache0Entries : new type.UInt16Le(),
307 cache0MaximumCellSize : new type.UInt16Le(),
308 cache1Entries : new type.UInt16Le(),
309 cache1MaximumCellSize : new type.UInt16Le(),
310 cache2Entries : new type.UInt16Le(),
311 cache2MaximumCellSize : new type.UInt16Le()
312 };
313
314 return new type.Component(self, opt);
315}
316
317/**
318 *
319 * @param isServer {boolean} true if in server mode
320 * @param opt {object} type options
321 * @returns {type.Component}
322 */
323function pointerCapability(isServer, opt) {
324 var self = {
325 __TYPE__ : CapsType.CAPSTYPE_POINTER,
326 colorPointerFlag : new type.UInt16Le(),
327 colorPointerCacheSize : new type.UInt16Le(20),
328 //old version of rdp doesn't support ...
329 pointerCacheSize : new type.UInt16Le(null, {conditional : function() {
330 return isServer || false;
331 }})
332 };
333
334 return new type.Component(self, opt);
335}
336
337/**
338 * @see http://msdn.microsoft.com/en-us/library/cc240563.aspx
339 * @param opt {object} type options
340 * @returns {type.Component}
341 */
342function inputCapability(opt) {
343 var self = {
344 __TYPE__ : CapsType.CAPSTYPE_INPUT,
345 inputFlags : new type.UInt16Le(),
346 pad2octetsA : new type.UInt16Le(),
347 // same value as gcc.ClientCoreSettings.kbdLayout
348 keyboardLayout : new type.UInt32Le(),
349 // same value as gcc.ClientCoreSettings.keyboardType
350 keyboardType : new type.UInt32Le(),
351 // same value as gcc.ClientCoreSettings.keyboardSubType
352 keyboardSubType : new type.UInt32Le(),
353 // same value as gcc.ClientCoreSettings.keyboardFnKeys
354 keyboardFunctionKey : new type.UInt32Le(),
355 // same value as gcc.ClientCoreSettingrrs.imeFileName
356 imeFileName : new type.BinaryString(Buffer.from(Array(64 + 1).join('\x00'), 'binary'), {readLength : new type.CallableValue(64)})
357 };
358
359 return new type.Component(self, opt);
360}
361
362/**
363 * @see http://msdn.microsoft.com/en-us/library/cc240564.aspx
364 * @param opt {object} type options
365 * @returns {type.Component}
366 */
367function brushCapability(opt) {
368 var self = {
369 __TYPE__ : CapsType.CAPSTYPE_BRUSH,
370 brushSupportLevel : new type.UInt32Le(BrushSupport.BRUSH_DEFAULT)
371 };
372
373 return new type.Component(self, opt);
374}
375
376/**
377 * @see http://msdn.microsoft.com/en-us/library/cc240566.aspx
378 * @param opt {object} type options
379 * @returns {type.Component}
380 */
381function cacheEntry(opt) {
382 var self = {
383 cacheEntries : new type.UInt16Le(),
384 cacheMaximumCellSize : new type.UInt16Le()
385 };
386
387 return new type.Component(self, opt);
388}
389
390/**
391 * @see http://msdn.microsoft.com/en-us/library/cc240565.aspx
392 * @param entries {type.Component} cache entries
393 * @param opt {object} type options
394 * @returns {type.Component}
395 */
396function glyphCapability(entries, opt) {
397 var self = {
398 __TYPE__ : CapsType.CAPSTYPE_GLYPHCACHE,
399 glyphCache : entries || new type.Factory(function(s) {
400 self.glyphCache = new type.Component([]);
401 for(var i = 0; i < 10; i++) {
402 self.glyphCache.obj.push(cacheEntry().read(s));
403 }
404 }),
405 fragCache : new type.UInt32Le(),
406 // all fonts are sent with bitmap format (very expensive)
407 glyphSupportLevel : new type.UInt16Le(GlyphSupport.GLYPH_SUPPORT_NONE),
408 pad2octets : new type.UInt16Le()
409 };
410
411 return new type.Component(self, opt);
412}
413
414/**
415 * @see http://msdn.microsoft.com/en-us/library/cc240550.aspx
416 * @param opt {object} type options
417 * @returns {type.Component}
418 */
419function offscreenBitmapCacheCapability(opt) {
420 var self = {
421 __TYPE__ : CapsType.CAPSTYPE_OFFSCREENCACHE,
422 offscreenSupportLevel : new type.UInt32Le(OffscreenSupportLevel.FALSE),
423 offscreenCacheSize : new type.UInt16Le(),
424 offscreenCacheEntries : new type.UInt16Le()
425 };
426
427 return new type.Component(self, opt);
428}
429
430/**
431 * @see http://msdn.microsoft.com/en-us/library/cc240551.aspx
432 * @param opt {object} type options
433 * @returns {type.Component}
434 */
435function virtualChannelCapability(opt) {
436 var self = {
437 __TYPE__ : CapsType.CAPSTYPE_VIRTUALCHANNEL,
438 flags : new type.UInt32Le(VirtualChannelCompressionFlag.VCCAPS_NO_COMPR),
439 VCChunkSize : new type.UInt32Le(null, {optional : true})
440 };
441
442 return new type.Component(self, opt);
443}
444
445/**
446 * @see http://msdn.microsoft.com/en-us/library/cc240552.aspx
447 * @param opt {object} type options
448 * @returns {type.Component}
449 */
450function soundCapability(opt) {
451 var self = {
452 __TYPE__ : CapsType.CAPSTYPE_SOUND,
453 soundFlags : new type.UInt16Le(SoundFlag.NONE),
454 pad2octetsA : new type.UInt16Le()
455 };
456
457 return new type.Component(self, opt);
458}
459
460/**
461 * @see http://msdn.microsoft.com/en-us/library/cc240568.aspx
462 * @param opt {object} type options
463 * @returns {type.Component}
464 */
465function controlCapability(opt) {
466 var self = {
467 __TYPE__ : CapsType.CAPSTYPE_CONTROL,
468 controlFlags : new type.UInt16Le(),
469 remoteDetachFlag : new type.UInt16Le(),
470 controlInterest : new type.UInt16Le(0x0002),
471 detachInterest : new type.UInt16Le(0x0002)
472 };
473
474 return new type.Component(self, opt);
475}
476
477/**
478 * @see http://msdn.microsoft.com/en-us/library/cc240569.aspx
479 * @param opt {object} type options
480 * @returns {type.Component}
481 */
482function windowActivationCapability(opt) {
483 var self = {
484 __TYPE__ : CapsType.CAPSTYPE_ACTIVATION,
485 helpKeyFlag : new type.UInt16Le(),
486 helpKeyIndexFlag : new type.UInt16Le(),
487 helpExtendedKeyFlag : new type.UInt16Le(),
488 windowManagerKeyFlag : new type.UInt16Le()
489 };
490
491 return new type.Component(self, opt);
492}
493
494/**
495 * @see http://msdn.microsoft.com/en-us/library/cc240571.aspx
496 * @param opt {object} type options
497 * @returns {type.Component}
498 */
499function fontCapability(opt) {
500 var self = {
501 __TYPE__ : CapsType.CAPSTYPE_FONT,
502 fontSupportFlags : new type.UInt16Le(0x0001),
503 pad2octets : new type.UInt16Le()
504 };
505
506 return new type.Component(self, opt);
507}
508
509/**
510 * @see http://msdn.microsoft.com/en-us/library/cc241564.aspx
511 * @param opt {object} type options
512 * @returns {type.Component}
513 */
514function colorCacheCapability(opt) {
515 var self = {
516 __TYPE__ : CapsType.CAPSTYPE_COLORCACHE,
517 colorTableCacheSize : new type.UInt16Le(0x0006),
518 pad2octets : new type.UInt16Le()
519 };
520
521 return new type.Component(self, opt);
522}
523
524/**
525 * @see http://msdn.microsoft.com/en-us/library/cc240570.aspx
526 * @param opt {object} type options
527 * @returns {type.Component}
528 */
529function shareCapability(opt) {
530 var self = {
531 __TYPE__ : CapsType.CAPSTYPE_SHARE,
532 nodeId : new type.UInt16Le(),
533 pad2octets : new type.UInt16Le()
534 };
535
536 return new type.Component(self, opt);
537}
538
539/**
540 * @see http://msdn.microsoft.com/en-us/library/cc240649.aspx
541 * @param opt {object} type options
542 * @returns {type.Component}
543 */
544function multiFragmentUpdate(opt) {
545 var self = {
546 __TYPE__ : CapsType.CAPSETTYPE_MULTIFRAGMENTUPDATE,
547 MaxRequestSize : new type.UInt32Le(0)
548 };
549
550 return new type.Component(self, opt);
551}
552
553/**
554 * Capability wrapper packet
555 * @see http://msdn.microsoft.com/en-us/library/cc240486.aspx
556 * @param cap {type.Component}
557 * @param opt {object} type options
558 * @returns {type.Component}
559 */
560function capability(cap, opt) {
561 var self = {
562 capabilitySetType : new type.UInt16Le(function() {
563 return self.capability.obj.__TYPE__;
564 }),
565 lengthCapability : new type.UInt16Le(function() {
566 return new type.Component(self).size();
567 }),
568 capability : cap || new type.Factory(function(s) {
569 switch(self.capabilitySetType.value) {
570 case CapsType.CAPSTYPE_GENERAL:
571 self.capability = generalCapability({readLength : new type.CallableValue(function() {
572 return self.lengthCapability.value - 4;
573 })}).read(s);
574 break;
575 case CapsType.CAPSTYPE_BITMAP:
576 self.capability = bitmapCapability({readLength : new type.CallableValue(function() {
577 return self.lengthCapability.value - 4;
578 })}).read(s);
579 break;
580 case CapsType.CAPSTYPE_ORDER:
581 self.capability = orderCapability(null, {readLength : new type.CallableValue(function() {
582 return self.lengthCapability.value - 4;
583 })}).read(s);
584 break;
585 case CapsType.CAPSTYPE_BITMAPCACHE:
586 self.capability = bitmapCacheCapability({readLength : new type.CallableValue(function() {
587 return self.lengthCapability.value - 4;
588 })}).read(s);
589 break;
590 case CapsType.CAPSTYPE_POINTER:
591 self.capability = pointerCapability(false, {readLength : new type.CallableValue(function() {
592 return self.lengthCapability.value - 4;
593 })}).read(s);
594 break;
595 case CapsType.CAPSTYPE_INPUT:
596 self.capability = inputCapability({readLength : new type.CallableValue(function() {
597 return self.lengthCapability.value - 4;
598 })}).read(s);
599 break;
600 case CapsType.CAPSTYPE_BRUSH:
601 self.capability = brushCapability({readLength : new type.CallableValue(function() {
602 return self.lengthCapability.value - 4;
603 })}).read(s);
604 break;
605 case CapsType.CAPSTYPE_GLYPHCACHE:
606 self.capability = glyphCapability(null, {readLength : new type.CallableValue(function() {
607 return self.lengthCapability.value - 4;
608 })}).read(s);
609 break;
610 case CapsType.CAPSTYPE_OFFSCREENCACHE:
611 self.capability = offscreenBitmapCacheCapability({readLength : new type.CallableValue(function() {
612 return self.lengthCapability.value - 4;
613 })}).read(s);
614 break;
615 case CapsType.CAPSTYPE_VIRTUALCHANNEL:
616 self.capability = virtualChannelCapability({readLength : new type.CallableValue(function() {
617 return self.lengthCapability.value - 4;
618 })}).read(s);
619 break;
620 case CapsType.CAPSTYPE_SOUND:
621 self.capability = soundCapability({readLength : new type.CallableValue(function() {
622 return self.lengthCapability.value - 4;
623 })}).read(s);
624 break;
625 case CapsType.CAPSTYPE_CONTROL:
626 self.capability = controlCapability({readLength : new type.CallableValue(function() {
627 return self.lengthCapability.value - 4;
628 })}).read(s);
629 break;
630 case CapsType.CAPSTYPE_ACTIVATION:
631 self.capability = windowActivationCapability({readLength : new type.CallableValue(function() {
632 return self.lengthCapability.value - 4;
633 })}).read(s);
634 break;
635 case CapsType.CAPSTYPE_FONT:
636 self.capability = fontCapability({readLength : new type.CallableValue(function() {
637 return self.lengthCapability.value - 4;
638 })}).read(s);
639 break;
640 case CapsType.CAPSTYPE_COLORCACHE:
641 self.capability = colorCacheCapability({readLength : new type.CallableValue(function() {
642 return self.lengthCapability.value - 4;
643 })}).read(s);
644 break;
645 case CapsType.CAPSTYPE_SHARE:
646 self.capability = shareCapability({readLength : new type.CallableValue(function() {
647 return self.lengthCapability.value - 4;
648 })}).read(s);
649 break;
650 case CapsType.CAPSETTYPE_MULTIFRAGMENTUPDATE:
651 self.capability = multiFragmentUpdate({readLength : new type.CallableValue(function() {
652 return self.lengthCapability.value - 4;
653 })}).read(s);
654 break;
655 default:
656 log.debug('unknown capability ' + self.capabilitySetType.value);
657 self.capability = new type.BinaryString(null, {readLength : new type.CallableValue(function() {
658 return self.lengthCapability.value - 4;
659 })}).read(s);
660 }
661 })
662 };
663
664 return new type.Component(self, opt);
665}
666
667/**
668 * Module exports
669 */
670module.exports = {
671 CapsType : CapsType,
672 MajorType : MajorType,
673 MinorType : MinorType,
674 GeneralExtraFlag : GeneralExtraFlag,
675 Boolean : Boolean,
676 OrderFlag : OrderFlag,
677 Order : Order,
678 OrderEx : OrderEx,
679 InputFlags : InputFlags,
680 BrushSupport : BrushSupport,
681 GlyphSupport : GlyphSupport,
682 OffscreenSupportLevel : OffscreenSupportLevel,
683 VirtualChannelCompressionFlag : VirtualChannelCompressionFlag,
684 SoundFlag : SoundFlag,
685 generalCapability : generalCapability,
686 bitmapCapability : bitmapCapability,
687 orderCapability : orderCapability,
688 bitmapCacheCapability : bitmapCacheCapability,
689 pointerCapability : pointerCapability,
690 inputCapability : inputCapability,
691 brushCapability : brushCapability,
692 cacheEntry : cacheEntry,
693 glyphCapability : glyphCapability,
694 offscreenBitmapCacheCapability : offscreenBitmapCacheCapability,
695 virtualChannelCapability : virtualChannelCapability,
696 soundCapability : soundCapability,
697 controlCapability : controlCapability,
698 windowActivationCapability : windowActivationCapability,
699 fontCapability : fontCapability,
700 colorCacheCapability : colorCacheCapability,
701 shareCapability : shareCapability,
702 multiFragmentUpdate : multiFragmentUpdate,
703 capability : capability
704};