bfg-common 1.3.393 → 1.3.394

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 (85) hide show
  1. package/assets/img/icons/icons-sprite-dark-1.svg +1 -360
  2. package/assets/img/icons/icons-sprite-dark-2.svg +1 -296
  3. package/assets/img/icons/icons-sprite-dark-3.svg +1 -221
  4. package/assets/img/icons/icons-sprite-dark-4.svg +1 -247
  5. package/assets/img/icons/icons-sprite-light-1.svg +1 -360
  6. package/assets/img/icons/icons-sprite-light-2.svg +1 -296
  7. package/assets/img/icons/icons-sprite-light-3.svg +1 -221
  8. package/assets/img/icons/icons-sprite-light-4.svg +1 -247
  9. package/assets/localization/local_be.json +5 -1
  10. package/assets/localization/local_en.json +5 -1
  11. package/assets/localization/local_hy.json +5 -1
  12. package/assets/localization/local_kk.json +5 -1
  13. package/assets/localization/local_ru.json +5 -1
  14. package/assets/localization/local_zh.json +5 -1
  15. package/assets/scss/common/icons/icons.scss +0 -1
  16. package/components/atoms/loader/Loader.vue +30 -30
  17. package/components/atoms/loader/PreLoader.vue +38 -38
  18. package/components/atoms/switch/Switch.vue +111 -111
  19. package/components/atoms/table/compact/Compact.vue +526 -526
  20. package/components/common/adapterManager/ui/table/Header.vue +93 -93
  21. package/components/common/adapterManager/ui/table/Table.vue +162 -162
  22. package/components/common/context/Context.vue +99 -99
  23. package/components/common/lib/config/states.ts +126 -126
  24. package/components/common/resource/progressBlock/ProgressBlock.vue +142 -142
  25. package/components/common/split/horizontal/Horizontal.vue +70 -307
  26. package/components/common/split/horizontal/HorizontalOld.vue +307 -0
  27. package/components/common/vm/actions/add/Add.vue +602 -602
  28. package/components/common/vm/actions/clone/Clone.vue +518 -518
  29. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +273 -273
  30. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +697 -697
  31. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDrive.vue +256 -256
  32. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +458 -458
  33. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +304 -304
  34. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/NewPciDevice.vue +167 -167
  35. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbController.vue +82 -82
  36. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +32 -32
  37. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCard.vue +182 -182
  38. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptions.vue +114 -114
  39. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptions.vue +188 -188
  40. package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/Tools.vue +72 -72
  41. package/components/common/vm/actions/common/select/computeResource/ComputeResource.vue +164 -164
  42. package/components/common/vm/actions/common/select/name/Name.vue +235 -235
  43. package/components/common/vm/actions/common/select/storage/Storage.vue +198 -198
  44. package/components/common/vm/actions/editSettings/EditSettings.vue +316 -316
  45. package/components/common/weekSelect/lib/config/options.ts +10 -10
  46. package/components/common/wizards/datastore/add/Add.vue +436 -436
  47. package/components/common/wizards/datastore/add/lib/config/stepItems.ts +191 -191
  48. package/components/common/wizards/datastore/add/lib/models/interfaces.ts +38 -38
  49. package/components/common/wizards/datastore/add/lib/utils.ts +70 -70
  50. package/components/common/wizards/datastore/add/local/createName/CreateName.vue +160 -160
  51. package/components/common/wizards/datastore/add/nfs/Nfs.vue +112 -112
  52. package/components/common/wizards/datastore/add/nfs/accessibility/Accessibility.vue +104 -104
  53. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/lib/config/compatibleTable.ts +62 -62
  54. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/lib/config/hostsTableItems.ts +53 -53
  55. package/components/common/wizards/datastore/add/readyComplete/ReadyComplete.vue +86 -86
  56. package/components/common/wizards/datastore/add/readyComplete/lib/config/propertiesDetails.ts +184 -184
  57. package/components/common/wizards/datastore/add/sharedStorm/deviceSelection/DeviceSelection.vue +459 -459
  58. package/components/common/wizards/datastore/add/types/Types.vue +80 -80
  59. package/components/common/wizards/datastore/add/types/lib/config/typeOptions.ts +49 -49
  60. package/composables/useAppVersion.ts +21 -21
  61. package/composables/useEnvLanguage.ts +20 -20
  62. package/lib/utils/sendTask.ts +72 -72
  63. package/minify.js +146 -146
  64. package/package.json +1 -1
  65. package/plugins/spice-console/spice.console.ts +147 -147
  66. package/public/spice-console/application/codec.js +263 -263
  67. package/public/spice-console/lib/rasterEngine.js +907 -907
  68. package/public/spice-console/network/spicechannel.js +375 -375
  69. package/store/main/lib/interfaces.ts +9 -9
  70. package/store/tasks/actions.ts +133 -133
  71. package/store/tasks/getters.ts +25 -25
  72. package/store/tasks/lib/models/interfaces.ts +18 -18
  73. package/store/tasks/mutations.ts +58 -58
  74. package/store/tasks/state.ts +16 -16
  75. package/assets/img/icons/icons-sprite-dark-1-old.svg +0 -1
  76. package/assets/img/icons/icons-sprite-dark-2-old.svg +0 -1
  77. package/assets/img/icons/icons-sprite-dark-3-old.svg +0 -1
  78. package/assets/img/icons/icons-sprite-dark-4-old.svg +0 -1
  79. package/assets/img/icons/icons-sprite-dark-7.svg +0 -8
  80. package/assets/img/icons/icons-sprite-light-1-old.svg +0 -1
  81. package/assets/img/icons/icons-sprite-light-2-old.svg +0 -1
  82. package/assets/img/icons/icons-sprite-light-3-old.svg +0 -1
  83. package/assets/img/icons/icons-sprite-light-4-old.svg +0 -1
  84. package/assets/img/icons/icons-sprite-light-7.svg +0 -8
  85. package/assets/scss/common/icons/icons-7.scss +0 -29
@@ -1,375 +1,375 @@
1
- /*
2
- Copyright (c) 2016 eyeOS
3
-
4
- This file is part of Open365.
5
-
6
- Open365 is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU Affero General Public License as
8
- published by the Free Software Foundation, either version 3 of the
9
- License, or (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 Affero General Public License for more details.
15
-
16
- You should have received a copy of the GNU Affero General Public License
17
- along with this program. If not, see <http://www.gnu.org/licenses/>.
18
- */
19
-
20
- //Must fire event types: connectionId and message
21
-
22
- wdi.SpiceChannel = $.spcExtend(wdi.EventObject.prototype, {
23
- counter: 0,
24
- ackWindow: 0,
25
- connectionId: 0,
26
- socketQ: null,
27
- packetReassembler: null,
28
- channel: 1,
29
- codec: wdi.SpiceVideoCodecType.SPICE_VIDEO_CODEC_TYPE_MJPEG,
30
- proxy: null,
31
- token: null,
32
-
33
- init: function (c) {
34
- this.superInit()
35
- this.socketQ = c.socketQ || new wdi.SocketQueue()
36
- this.packetReassembler =
37
- c.packetReassembler ||
38
- wdi.ReassemblerFactory.getPacketReassembler(this.socketQ)
39
- this.setListeners()
40
- this.ackWindow = 0
41
-
42
- // var _this = this
43
- // setInterval(() => {
44
- // var body = new wdi.RedPing({id: 0, time: new Date().getTime()}).marshall();
45
- // _this.sendObject(body, wdi.SpiceVars.SPICE_MSGC_PONG);
46
- // }, 60_00)
47
- },
48
-
49
- // startHandshakeTimeout: function () {
50
- // var self = this
51
- // this.handshakeTimeout = window.setTimeout(function () {
52
- // var err = new Error('Handshake timeout')
53
- // err.code = 4200
54
- // wdi.Debug.error('Handshake timeout reached, raising error')
55
- // self.fire('error', err)
56
- // }, 5000)
57
- // },
58
-
59
- fireHandshakeTimeoutError: function () {
60
- var err = new Error('Handshake timeout')
61
- err.code = 4200
62
- wdi.Debug.error('Handshake timeout reached, raising error')
63
- this.fire('error', err)
64
- },
65
-
66
- // cancelHandshakeTimeout: function () {
67
- // clearTimeout(this.handshakeTimeout)
68
- // },
69
-
70
- setListeners: function () {
71
- var date
72
- var self = this
73
- this.packetReassembler.addListener(
74
- 'packetComplete',
75
- function (e) {
76
- var rawMessage = e
77
- if (rawMessage.status === 'spicePacket') {
78
- wdi.Debug.log('packetComplete spicePacket')
79
- // self.cancelHandshakeTimeout()
80
- if (wdi.logOperations) {
81
- wdi.DataLogger.logNetworkTime()
82
- date = Date.now()
83
- }
84
- var rsm = this.getRawSpiceMessage(rawMessage.data)
85
- if (rsm) {
86
- if (
87
- wdi.logOperations &&
88
- rsm.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY
89
- ) {
90
- wdi.DataLogger.setStartTime(date)
91
- }
92
- this.fire('message', rsm)
93
- }
94
- } else if (rawMessage.status === 'reply') {
95
- wdi.Debug.log('packetComplete reply')
96
- var packet = this.getRedLinkReplyBytes(rawMessage.data)
97
- this.send(packet)
98
- } else if (rawMessage.status === 'errorCode') {
99
- wdi.Debug.log('packetComplete errorCode')
100
- var packet = this.getErrorCodeBytes(rawMessage.data)
101
- if (packet) {
102
- this.send(packet)
103
- if (this.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY) {
104
- // Custom code
105
- // Set codec
106
- this.changeCodec(this.codec)
107
- // Custom code end
108
- }
109
- }
110
- this.fire('channelConnected')
111
- } else {
112
- self.fireHandshakeTimeoutError()
113
- }
114
- },
115
- this
116
- )
117
-
118
- this.socketQ.addListener(
119
- 'open',
120
- function () {
121
- var packet = this.getRedLinkMessBytes()
122
- this.send(packet)
123
- this.proxy ? this.proxy.end() : false
124
- },
125
- this
126
- )
127
-
128
- this.socketQ.addListener(
129
- 'close',
130
- function (e) {
131
- if (this.channel === 1) {
132
- this.fire('error', e)
133
- }
134
- this.socketQ.disconnect()
135
- },
136
- this
137
- )
138
-
139
- this.socketQ.addListener(
140
- 'error',
141
- function (e) {
142
- this.fire('error', e)
143
- this.socketQ.disconnect()
144
- },
145
- this
146
- )
147
- },
148
-
149
- changeCodec: function (codec) {
150
- this.sendObject(
151
- [
152
- ...wdi.SpiceObject.numberTo16(2),
153
- ...wdi.SpiceObject.numberTo16(codec),
154
- ...wdi.SpiceObject.numberTo16(3),
155
- ],
156
- wdi.SpiceVars.SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE
157
- )
158
-
159
- wdi.currentCodec = codec
160
-
161
- console.log(`codec changed: ${codec}`)
162
- },
163
-
164
- connect: function (connectionInfo, channel, connectionId, proxy) {
165
- var url = wdi.Utils.generateWebSocketUrl(
166
- connectionInfo.protocol,
167
- connectionInfo.host,
168
- connectionInfo.port,
169
- connectionInfo.vmHost,
170
- connectionInfo.vmPort,
171
- 'spice',
172
- connectionInfo.vmInfoToken,
173
- connectionInfo.vmid
174
- )
175
- this.channel = channel
176
- this.connectionId = connectionId || 0
177
- this.socketQ.connect(url)
178
- // this.startHandshakeTimeout()
179
- this.proxy = proxy
180
- this.token = connectionInfo.token
181
- this.packetReassembler.start()
182
- },
183
-
184
- disconnect: function () {
185
- wdi.Debug.log('spicechannel disconnect')
186
- this.counter = 0
187
- this.ackWindow = 0
188
- this.connectionId = 0
189
- this.socketQ.disconnect()
190
- this.socketQ = null
191
- this.packetReassembler.dispose()
192
- this.packetReassembler = null
193
- this.channel = 1
194
- this.proxy = null
195
- this.token = null
196
- },
197
-
198
- send: function (data, flush) {
199
- this.socketQ.send(data, flush)
200
- },
201
-
202
- sendObject: function (data, type, flush) {
203
- // TODO: Unhardcode this value
204
- var bufSize = 2048
205
- for (var current = 0; current < data.length; current += bufSize) {
206
- var part = data.slice(current, current + bufSize)
207
- var packet = new wdi.SpiceDataHeader({
208
- type: type,
209
- size: part.length,
210
- }).marshall()
211
-
212
- packet = packet.concat(part)
213
-
214
- this.send(packet, flush)
215
- }
216
- },
217
-
218
- // Custom code
219
- arrayOfNumberToUint32: function (arrayOfNumber) {
220
- let v = 0
221
- for (let n of arrayOfNumber) {
222
- v |= 1 << n
223
- }
224
- return v
225
- },
226
- // Custom code end
227
-
228
- setAckWindow: function (window) {
229
- this.ackWindow = window
230
- this.counter = 0
231
- },
232
-
233
- getRawSpiceMessage: function (rawData) {
234
- var headerQueue = wdi.GlobalPool.create('ViewQueue')
235
- var body = wdi.GlobalPool.create('ViewQueue')
236
-
237
- var header = new Uint8Array(
238
- rawData,
239
- 0,
240
- wdi.SpiceDataHeader.prototype.objectSize
241
- )
242
- headerQueue.setData(header)
243
- var headerObj = new wdi.SpiceDataHeader().demarshall(headerQueue)
244
- wdi.GlobalPool.discard('ViewQueue', headerQueue)
245
- var rawBody = rawData.subarray(wdi.SpiceDataHeader.prototype.objectSize)
246
- body.setData(rawBody)
247
-
248
- this.counter++
249
-
250
- if (this.ackWindow && this.counter === this.ackWindow) {
251
- this.counter = 0
252
- var ack = new wdi.SpiceDataHeader({
253
- type: wdi.SpiceVars.SPICE_MSGC_ACK,
254
- size: 0,
255
- }).marshall()
256
- this.send(ack)
257
- }
258
-
259
- var packet = wdi.PacketLinkFactory.extract(headerObj, body) || false
260
- if (packet) {
261
- wdi.PacketLinkProcess.process(headerObj, packet, this)
262
- wdi.GlobalPool.discard('ViewQueue', body)
263
- return false
264
- } else {
265
- var rawSpiceMessage = wdi.GlobalPool.create('RawSpiceMessage')
266
- rawSpiceMessage.set(headerObj, body, this.channel)
267
- return rawSpiceMessage
268
- }
269
- },
270
-
271
- //This functions are to avoid hardcoded values on logic
272
- getRedLinkReplyBytes: function (data) {
273
- if (this.token) {
274
- var newq = new wdi.ViewQueue()
275
- newq.setData(data)
276
- newq.eatBytes(wdi.SpiceLinkHeader.prototype.objectSize)
277
- var myBody = new wdi.SpiceLinkReply().demarshall(newq)
278
-
279
- //Returnnig void bytes or encrypted ticket
280
- var key = wdi.SpiceObject.stringHexToBytes(
281
- RSA_public_encrypt(this.token, myBody.pub_key)
282
- )
283
- return key
284
- } else {
285
- return wdi.SpiceObject.stringToBytesPadding('', 128)
286
- }
287
- },
288
-
289
- getRedLinkMessBytes: function () {
290
- // var header = new wdi.SpiceLinkHeader({magic:1363428690, major_version:2, minor_version:2, size:22}).marshall();
291
- // var body = new wdi.SpiceLinkMess({
292
- // connection_id:this.connectionId,
293
- // channel_type:this.channel,
294
- // caps_offset:18,
295
- // num_common_caps: 1,
296
- // num_channel_caps: 0,
297
- // common_caps: (1 << wdi.SpiceVars.SPICE_COMMON_CAP_MINI_HEADER)
298
- // }).marshall();
299
-
300
- // Custom code
301
- // TODO uncomment this code for send caps
302
- var header = new wdi.SpiceLinkHeader({
303
- magic: 1363428690,
304
- major_version: 2,
305
- minor_version: 2,
306
- size: 26,
307
- }).marshall()
308
- var body = new wdi.SpiceLinkMess({
309
- connection_id: this.connectionId,
310
- channel_type: this.channel,
311
- caps_offset: 18,
312
- num_common_caps: 1,
313
- num_channel_caps: 1,
314
- common_caps: 1 << wdi.SpiceVars.SPICE_COMMON_CAP_MINI_HEADER,
315
- channel_caps: this.arrayOfNumberToUint32([
316
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_SIZED_STREAM,
317
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_STREAM_REPORT,
318
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_MONITORS_CONFIG,
319
-
320
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_MULTI_CODEC,
321
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE,
322
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_MJPEG,
323
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_VP8,
324
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_H264,
325
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_VP9,
326
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_H265,
327
-
328
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_LZ4_COMPRESSION,
329
- wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_PREF_COMPRESSION,
330
- ]),
331
- }).marshall()
332
- // Custom code end
333
-
334
- return header.concat(body)
335
- },
336
-
337
- getErrorCodeBytes: function (data) {
338
- var errorQ = wdi.GlobalPool.create('ViewQueue')
339
- errorQ.setData(data)
340
- var errorCode = wdi.SpiceObject.bytesToInt32NoAllocate(errorQ)
341
- wdi.GlobalPool.discard('ViewQueue', errorQ)
342
- if (errorCode === 0) {
343
- if (this.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY) {
344
- var redDisplayInit = new wdi.SpiceDataHeader({
345
- type: wdi.SpiceVars.SPICE_MSGC_DISPLAY_INIT,
346
- size: 14,
347
- }).marshall()
348
- //TODO: ultrahardcoded value here, move to configuration
349
-
350
- //DUE To high level storage the memory specified for cache
351
- //is 2-3 times bigger than expected.
352
- var cache_size = 1
353
-
354
- var body = new wdi.SpiceCDisplayInit({
355
- pixmap_cache_id: 1,
356
- pixmap_cache_size: cache_size,
357
- glz_dictionary_id: 0,
358
- glz_dictionary_window_size: 0,
359
- }).marshall()
360
-
361
- return redDisplayInit.concat(body)
362
- } else if (this.channel == wdi.SpiceVars.SPICE_CHANNEL_MAIN) {
363
- return new wdi.SpiceDataHeader({
364
- type: wdi.SpiceVars.SPICE_MSGC_MAIN_ATTACH_CHANNELS,
365
- size: 0,
366
- }).marshall()
367
- }
368
- } else {
369
- throw new wdi.Exception({
370
- message: 'Server refused client',
371
- errorCode: 2,
372
- })
373
- }
374
- },
375
- })
1
+ /*
2
+ Copyright (c) 2016 eyeOS
3
+
4
+ This file is part of Open365.
5
+
6
+ Open365 is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Affero General Public License as
8
+ published by the Free Software Foundation, either version 3 of the
9
+ License, or (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 Affero General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Affero General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ //Must fire event types: connectionId and message
21
+
22
+ wdi.SpiceChannel = $.spcExtend(wdi.EventObject.prototype, {
23
+ counter: 0,
24
+ ackWindow: 0,
25
+ connectionId: 0,
26
+ socketQ: null,
27
+ packetReassembler: null,
28
+ channel: 1,
29
+ codec: wdi.SpiceVideoCodecType.SPICE_VIDEO_CODEC_TYPE_MJPEG,
30
+ proxy: null,
31
+ token: null,
32
+
33
+ init: function (c) {
34
+ this.superInit()
35
+ this.socketQ = c.socketQ || new wdi.SocketQueue()
36
+ this.packetReassembler =
37
+ c.packetReassembler ||
38
+ wdi.ReassemblerFactory.getPacketReassembler(this.socketQ)
39
+ this.setListeners()
40
+ this.ackWindow = 0
41
+
42
+ // var _this = this
43
+ // setInterval(() => {
44
+ // var body = new wdi.RedPing({id: 0, time: new Date().getTime()}).marshall();
45
+ // _this.sendObject(body, wdi.SpiceVars.SPICE_MSGC_PONG);
46
+ // }, 60_00)
47
+ },
48
+
49
+ // startHandshakeTimeout: function () {
50
+ // var self = this
51
+ // this.handshakeTimeout = window.setTimeout(function () {
52
+ // var err = new Error('Handshake timeout')
53
+ // err.code = 4200
54
+ // wdi.Debug.error('Handshake timeout reached, raising error')
55
+ // self.fire('error', err)
56
+ // }, 5000)
57
+ // },
58
+
59
+ fireHandshakeTimeoutError: function () {
60
+ var err = new Error('Handshake timeout')
61
+ err.code = 4200
62
+ wdi.Debug.error('Handshake timeout reached, raising error')
63
+ this.fire('error', err)
64
+ },
65
+
66
+ // cancelHandshakeTimeout: function () {
67
+ // clearTimeout(this.handshakeTimeout)
68
+ // },
69
+
70
+ setListeners: function () {
71
+ var date
72
+ var self = this
73
+ this.packetReassembler.addListener(
74
+ 'packetComplete',
75
+ function (e) {
76
+ var rawMessage = e
77
+ if (rawMessage.status === 'spicePacket') {
78
+ wdi.Debug.log('packetComplete spicePacket')
79
+ // self.cancelHandshakeTimeout()
80
+ if (wdi.logOperations) {
81
+ wdi.DataLogger.logNetworkTime()
82
+ date = Date.now()
83
+ }
84
+ var rsm = this.getRawSpiceMessage(rawMessage.data)
85
+ if (rsm) {
86
+ if (
87
+ wdi.logOperations &&
88
+ rsm.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY
89
+ ) {
90
+ wdi.DataLogger.setStartTime(date)
91
+ }
92
+ this.fire('message', rsm)
93
+ }
94
+ } else if (rawMessage.status === 'reply') {
95
+ wdi.Debug.log('packetComplete reply')
96
+ var packet = this.getRedLinkReplyBytes(rawMessage.data)
97
+ this.send(packet)
98
+ } else if (rawMessage.status === 'errorCode') {
99
+ wdi.Debug.log('packetComplete errorCode')
100
+ var packet = this.getErrorCodeBytes(rawMessage.data)
101
+ if (packet) {
102
+ this.send(packet)
103
+ if (this.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY) {
104
+ // Custom code
105
+ // Set codec
106
+ this.changeCodec(this.codec)
107
+ // Custom code end
108
+ }
109
+ }
110
+ this.fire('channelConnected')
111
+ } else {
112
+ self.fireHandshakeTimeoutError()
113
+ }
114
+ },
115
+ this
116
+ )
117
+
118
+ this.socketQ.addListener(
119
+ 'open',
120
+ function () {
121
+ var packet = this.getRedLinkMessBytes()
122
+ this.send(packet)
123
+ this.proxy ? this.proxy.end() : false
124
+ },
125
+ this
126
+ )
127
+
128
+ this.socketQ.addListener(
129
+ 'close',
130
+ function (e) {
131
+ if (this.channel === 1) {
132
+ this.fire('error', e)
133
+ }
134
+ this.socketQ.disconnect()
135
+ },
136
+ this
137
+ )
138
+
139
+ this.socketQ.addListener(
140
+ 'error',
141
+ function (e) {
142
+ this.fire('error', e)
143
+ this.socketQ.disconnect()
144
+ },
145
+ this
146
+ )
147
+ },
148
+
149
+ changeCodec: function (codec) {
150
+ this.sendObject(
151
+ [
152
+ ...wdi.SpiceObject.numberTo16(2),
153
+ ...wdi.SpiceObject.numberTo16(codec),
154
+ ...wdi.SpiceObject.numberTo16(3),
155
+ ],
156
+ wdi.SpiceVars.SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE
157
+ )
158
+
159
+ wdi.currentCodec = codec
160
+
161
+ console.log(`codec changed: ${codec}`)
162
+ },
163
+
164
+ connect: function (connectionInfo, channel, connectionId, proxy) {
165
+ var url = wdi.Utils.generateWebSocketUrl(
166
+ connectionInfo.protocol,
167
+ connectionInfo.host,
168
+ connectionInfo.port,
169
+ connectionInfo.vmHost,
170
+ connectionInfo.vmPort,
171
+ 'spice',
172
+ connectionInfo.vmInfoToken,
173
+ connectionInfo.vmid
174
+ )
175
+ this.channel = channel
176
+ this.connectionId = connectionId || 0
177
+ this.socketQ.connect(url)
178
+ // this.startHandshakeTimeout()
179
+ this.proxy = proxy
180
+ this.token = connectionInfo.token
181
+ this.packetReassembler.start()
182
+ },
183
+
184
+ disconnect: function () {
185
+ wdi.Debug.log('spicechannel disconnect')
186
+ this.counter = 0
187
+ this.ackWindow = 0
188
+ this.connectionId = 0
189
+ this.socketQ.disconnect()
190
+ this.socketQ = null
191
+ this.packetReassembler.dispose()
192
+ this.packetReassembler = null
193
+ this.channel = 1
194
+ this.proxy = null
195
+ this.token = null
196
+ },
197
+
198
+ send: function (data, flush) {
199
+ this.socketQ.send(data, flush)
200
+ },
201
+
202
+ sendObject: function (data, type, flush) {
203
+ // TODO: Unhardcode this value
204
+ var bufSize = 2048
205
+ for (var current = 0; current < data.length; current += bufSize) {
206
+ var part = data.slice(current, current + bufSize)
207
+ var packet = new wdi.SpiceDataHeader({
208
+ type: type,
209
+ size: part.length,
210
+ }).marshall()
211
+
212
+ packet = packet.concat(part)
213
+
214
+ this.send(packet, flush)
215
+ }
216
+ },
217
+
218
+ // Custom code
219
+ arrayOfNumberToUint32: function (arrayOfNumber) {
220
+ let v = 0
221
+ for (let n of arrayOfNumber) {
222
+ v |= 1 << n
223
+ }
224
+ return v
225
+ },
226
+ // Custom code end
227
+
228
+ setAckWindow: function (window) {
229
+ this.ackWindow = window
230
+ this.counter = 0
231
+ },
232
+
233
+ getRawSpiceMessage: function (rawData) {
234
+ var headerQueue = wdi.GlobalPool.create('ViewQueue')
235
+ var body = wdi.GlobalPool.create('ViewQueue')
236
+
237
+ var header = new Uint8Array(
238
+ rawData,
239
+ 0,
240
+ wdi.SpiceDataHeader.prototype.objectSize
241
+ )
242
+ headerQueue.setData(header)
243
+ var headerObj = new wdi.SpiceDataHeader().demarshall(headerQueue)
244
+ wdi.GlobalPool.discard('ViewQueue', headerQueue)
245
+ var rawBody = rawData.subarray(wdi.SpiceDataHeader.prototype.objectSize)
246
+ body.setData(rawBody)
247
+
248
+ this.counter++
249
+
250
+ if (this.ackWindow && this.counter === this.ackWindow) {
251
+ this.counter = 0
252
+ var ack = new wdi.SpiceDataHeader({
253
+ type: wdi.SpiceVars.SPICE_MSGC_ACK,
254
+ size: 0,
255
+ }).marshall()
256
+ this.send(ack)
257
+ }
258
+
259
+ var packet = wdi.PacketLinkFactory.extract(headerObj, body) || false
260
+ if (packet) {
261
+ wdi.PacketLinkProcess.process(headerObj, packet, this)
262
+ wdi.GlobalPool.discard('ViewQueue', body)
263
+ return false
264
+ } else {
265
+ var rawSpiceMessage = wdi.GlobalPool.create('RawSpiceMessage')
266
+ rawSpiceMessage.set(headerObj, body, this.channel)
267
+ return rawSpiceMessage
268
+ }
269
+ },
270
+
271
+ //This functions are to avoid hardcoded values on logic
272
+ getRedLinkReplyBytes: function (data) {
273
+ if (this.token) {
274
+ var newq = new wdi.ViewQueue()
275
+ newq.setData(data)
276
+ newq.eatBytes(wdi.SpiceLinkHeader.prototype.objectSize)
277
+ var myBody = new wdi.SpiceLinkReply().demarshall(newq)
278
+
279
+ //Returnnig void bytes or encrypted ticket
280
+ var key = wdi.SpiceObject.stringHexToBytes(
281
+ RSA_public_encrypt(this.token, myBody.pub_key)
282
+ )
283
+ return key
284
+ } else {
285
+ return wdi.SpiceObject.stringToBytesPadding('', 128)
286
+ }
287
+ },
288
+
289
+ getRedLinkMessBytes: function () {
290
+ // var header = new wdi.SpiceLinkHeader({magic:1363428690, major_version:2, minor_version:2, size:22}).marshall();
291
+ // var body = new wdi.SpiceLinkMess({
292
+ // connection_id:this.connectionId,
293
+ // channel_type:this.channel,
294
+ // caps_offset:18,
295
+ // num_common_caps: 1,
296
+ // num_channel_caps: 0,
297
+ // common_caps: (1 << wdi.SpiceVars.SPICE_COMMON_CAP_MINI_HEADER)
298
+ // }).marshall();
299
+
300
+ // Custom code
301
+ // TODO uncomment this code for send caps
302
+ var header = new wdi.SpiceLinkHeader({
303
+ magic: 1363428690,
304
+ major_version: 2,
305
+ minor_version: 2,
306
+ size: 26,
307
+ }).marshall()
308
+ var body = new wdi.SpiceLinkMess({
309
+ connection_id: this.connectionId,
310
+ channel_type: this.channel,
311
+ caps_offset: 18,
312
+ num_common_caps: 1,
313
+ num_channel_caps: 1,
314
+ common_caps: 1 << wdi.SpiceVars.SPICE_COMMON_CAP_MINI_HEADER,
315
+ channel_caps: this.arrayOfNumberToUint32([
316
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_SIZED_STREAM,
317
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_STREAM_REPORT,
318
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_MONITORS_CONFIG,
319
+
320
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_MULTI_CODEC,
321
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE,
322
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_MJPEG,
323
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_VP8,
324
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_H264,
325
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_VP9,
326
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_H265,
327
+
328
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_LZ4_COMPRESSION,
329
+ wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_PREF_COMPRESSION,
330
+ ]),
331
+ }).marshall()
332
+ // Custom code end
333
+
334
+ return header.concat(body)
335
+ },
336
+
337
+ getErrorCodeBytes: function (data) {
338
+ var errorQ = wdi.GlobalPool.create('ViewQueue')
339
+ errorQ.setData(data)
340
+ var errorCode = wdi.SpiceObject.bytesToInt32NoAllocate(errorQ)
341
+ wdi.GlobalPool.discard('ViewQueue', errorQ)
342
+ if (errorCode === 0) {
343
+ if (this.channel === wdi.SpiceVars.SPICE_CHANNEL_DISPLAY) {
344
+ var redDisplayInit = new wdi.SpiceDataHeader({
345
+ type: wdi.SpiceVars.SPICE_MSGC_DISPLAY_INIT,
346
+ size: 14,
347
+ }).marshall()
348
+ //TODO: ultrahardcoded value here, move to configuration
349
+
350
+ //DUE To high level storage the memory specified for cache
351
+ //is 2-3 times bigger than expected.
352
+ var cache_size = 1
353
+
354
+ var body = new wdi.SpiceCDisplayInit({
355
+ pixmap_cache_id: 1,
356
+ pixmap_cache_size: cache_size,
357
+ glz_dictionary_id: 0,
358
+ glz_dictionary_window_size: 0,
359
+ }).marshall()
360
+
361
+ return redDisplayInit.concat(body)
362
+ } else if (this.channel == wdi.SpiceVars.SPICE_CHANNEL_MAIN) {
363
+ return new wdi.SpiceDataHeader({
364
+ type: wdi.SpiceVars.SPICE_MSGC_MAIN_ATTACH_CHANNELS,
365
+ size: 0,
366
+ }).marshall()
367
+ }
368
+ } else {
369
+ throw new wdi.Exception({
370
+ message: 'Server refused client',
371
+ errorCode: 2,
372
+ })
373
+ }
374
+ },
375
+ })