-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
3522 lines (3100 loc) · 108 KB
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
@file utils.js
File that contains utility methods for DOM-style operations
*/
///////////////////////////////////////////////////////////////////////
// BEGIN AdobeProperty
/**
A property class that allows you to Get() and Set() a value and Bind()
that value to DOM elements or arbitrary functions to automagically
have things happen when the property changes.
*/
function AdobeProperty(inValue)
{
this.value = inValue;
}
AdobeProperty.prototype.Get = function()
{
return this.value;
}
AdobeProperty.prototype.Set = function(inValue)
{
if (this.value != inValue)
{
this.value = inValue;
if (this.objects)
{
for (var n = 0; n < this.objects.length; n++)
{
this._BindNotify(this.objects[n]);
}
}
}
}
AdobeProperty.prototype.Bind = function(inObject, inMethod)
{
var bRet = false;
if (inObject)
{
var bindRecord = { obj: inObject, method: inMethod };
if (this._BindNotify(bindRecord))
{
if (!this.objects)
this.objects = new Array();
this.objects.push(bindRecord);
// Input elements get bi-directional
if (inObject.nodeType == 1 && (inObject.nodeName == "INPUT" || inObject.nodeName == "SELECT"))
{
var thisCB = this;
// Should preserve any existing onchange...
inObject.onchange = function() { thisCB.Set(this.value); };
}
bRet = true;
}
}
return bRet;
}
AdobeProperty.prototype._BindNotify = function(inBindRecord)
{
var bRet = false;
if (!inBindRecord || !inBindRecord.obj)
return bRet;
// If the bound method is a function, use it as a filter for the value.
var targetValue = this.value;
if ("function" == typeof inBindRecord.method)
targetValue = inBindRecord.method(this.value);
switch (typeof inBindRecord.obj)
{
case "function":
// Bound to a function, just call it with the property value
inBindRecord.obj(targetValue);
bRet = true;
break;
case "string":
// Bound to a string, set the value
inBindRecord.obj = targetValue;
bRet = true;
break;
case "object":
// Bound to an object, then we try a few different things
// 0. An object with a valid method bound
if ("string" == typeof inBindRecord.method && "function" == typeof inBindRecord.obj[inBindRecord.method])
{
inBindRecord.obj[inBindRecord.method](targetValue);
bRet = true;
}
// 1. An element
else if (1 == inBindRecord.obj.nodeType)
{
// For form fields, set the value
if ("INPUT" == inBindRecord.obj.nodeName || "SELECT" == inBindRecord.obj.nodeName)
{
inBindRecord.obj.value = targetValue;
}
// Other elements, replace the content
else
{
while (inBindRecord.obj.lastChild)
inBindRecord.obj.removeChild(inBindRecord.obj.lastChild);
inBindRecord.obj.appendChild(document.createTextNode(targetValue));
}
bRet = true;
}
// 2. An attribute or text node
else if (2 == inBindRecord.obj.nodeType || 3 == inBindRecord.obj.nodeType)
{
inBindRecord.obj.nodeValue = targetValue;
bRet = true;
}
// 3. An object with a Set() method
else if (inBindRecord.obj.Set && "function" == typeof inBindRecord.obj.Set)
{
inBindRecord.obj.Set(targetValue);
bRet = true;
}
// 4. An object with a value property
else if (undefined != inBindRecord.obj.value && (typeof inBindRecord.obj.value == typeof targetValue))
{
inBindRecord.obj.value = targetValue;
bRet = true;
}
// 5. Don't know what to do
break;
default:
// Unhandled type
}
return bRet;
}
// END AdobeProperty
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// BEGIN WizardAlert
/**
Modal alert widget.
*/
function WizardAlert(inContainerProxy)
{
this.session = inContainerProxy;
this.title = null;
this.body = null;
this.buttons = new Array();
if (!this.alertTemplate)
{
var alertPathArray = new Array(this.session.GetResourcesPath(), "/common/alert/alert.html");
var alertPath = _concatPaths(alertPathArray, this.session.GetDefaultProperties().platform);
var alertContents = this.session.LoadFile(alertPath);
this.alertTemplate = alertContents.data;
// doctor up the root path to the CSS
var cssURIArray = new Array(this.session.GetResourcesPath(), "/common/alert");
var cssURI = "file://" + _concatPaths(cssURIArray, this.session.GetDefaultProperties().platform);
this.alertTemplate = ExpandTokens(this.alertTemplate, { CSSRoot: cssURI });
}
if (!this.alertTemplate || this.alertTemplate.length <= 0)
{
throw "Unable to load alert.html";
}
}
/**
Run (show) the alert.
*/
WizardAlert.prototype.Run = function()
{
// Formulate a token map to fill in the alert template.
var repMap = new Object();
// Title and body
if (this.session.localization)
repMap.AlertWindowTitle = this.session.localization.GetString("locAlertWindowTitle", "Installer Alert");
else
repMap.AlertWindowTitle = "Installer Alert";
repMap.AlertTitle = this.title;
repMap.AlertBody = this.body;
// Button text padding
var buttonBuffer = " "; // they look like spaces, but they are Special
// Buttons
repMap.AlertButtons = "";
for (var bi = 0; bi < this.buttons.length; bi++)
{
// Setup standard button attributes
var attributes = {
type: "button",
value: buttonBuffer + this.buttons[bi].label + buttonBuffer,
onclick: "window.external.UIExitDialog('" + this.buttons[bi].returnCode + "');",
onfocus: "setFocus(this);"
};
var html = "<input";
var attr = null;
// Standard attributs
for (attr in attributes)
{
html += " " + attr + "=\"" + attributes[attr] + "\"";
}
// User supplied attributes augment or override
for (attr in this.buttons[bi].attributes)
{
html += " " + attr + "=\"" + this.buttons[bi].attributes[attr] + "\"";
}
html += "/>";
repMap.AlertButtons += html;
}
return this.session.UIShowModalAlert(ExpandTokens(this.alertTemplate, repMap));
}
/**
Set the title. This will be automatically wrapped in an <h1> but may contain other HTML markup.
*/
WizardAlert.prototype.SetTitle = function(inTitle)
{
this.title = inTitle;
}
/**
Set the body. This will automatically be wrapped in a <div> and should contain appropriate markup, for example <p> tags.
*/
WizardAlert.prototype.SetBody = function(inBody)
{
this.body = inBody;
}
/**
Add an alert button. Buttons are displayed left to right in the order added. An optional map can be supplied to augment or override the attributes in the generated <input type="button" ... /> fragment.
*/
WizardAlert.prototype.AddButton = function(inButtonLabel, inReturnCode, inOptAttributes)
{
this.buttons.push({ label: inButtonLabel, returnCode: inReturnCode, attributes: inOptAttributes });
}
/**
A class to generate standard alerts used in a couple different places.
*/
function StandardAlert(inContainerProxy, inLocalizationObj)
{
this.containerProxy = inContainerProxy;
this.localizationObj = inLocalizationObj;
}
/**
Utility string lookup method to simplify handling the case where we don't have a Localization object
handy.
*/
StandardAlert.prototype._LoadText = function(inStringID, inDefaultText, inPropertyMap)
{
var locText = inDefaultText;
if (null == inPropertyMap)
{
inPropertyMap = this.containerProxy.GetDefaultProperties();
}
if (null != this.localizationObj)
{
locText = this.localizationObj.GetString(inStringID, inDefaultText, inPropertyMap);
}
return locText;
}
/**
Standard invalid user credentials alert.
*/
StandardAlert.prototype.InvalidUserCredentials = function()
{
var a = new WizardAlert(this.containerProxy);
a.SetTitle(this._LoadText("locInvalidUserCredentialsTitle", "Invalid User Credentials"));
a.SetBody("<p>" + this._LoadText("locInvalidUserCredentialsBody", "You do not have sufficient security credentials to install this software.") + "<p>");
a.AddButton(this._LoadText("locBtnQuit", "Quit"), "2");
return a.Run();
}
/**
Standard Setup already running alert.
*/
StandardAlert.prototype.SetupAlreadyRunning = function()
{
var a = new WizardAlert(this.containerProxy);
a.SetTitle(this._LoadText("locSetupRunningTitle", "Setup Already Running"));
a.SetBody("<p>" + this._LoadText("locSetupRunningBody", "You can only install one Adobe product at a time. Please complete the other installation before attempting to install this product." + "</p>"));
a.AddButton(this._LoadText("locBtnQuit", "Quit"), "2");
return a.Run();
}
/**
Standard bootstrap failure alert.
*/
StandardAlert.prototype.BootstrapInstallFailure = function(inExitCode, inErrorArgs)
{
var propMap = this.containerProxy.GetDefaultProperties();
var errorText = "";
if (inErrorArgs["MSIErrorText"])
errorText += inErrorArgs["MSIErrorText"];
if (inErrorArgs["ARKErrorText"])
errorText += inErrorArgs["ARKErrorText"];
var locTitle = this._LoadText("locBootstrapFailedTitle", "Setup Failed");
var locBody = "<p>" + this._LoadText("locBootstrapFailedBody", "Setup failed to bootstrap.") + "</p>";
if (errorText && errorText.length > 0)
{
var errorTextNode = document.createElement("p");
errorTextNode.id = "alertErrorText";
var errorText = document.createTextNode(errorText);
errorTextNode.appendChild(errorText);
locBody += errorTextNode.innerHTML;
}
var a = new WizardAlert(this.containerProxy);
a.SetTitle(locTitle);
a.SetBody(locBody);
a.AddButton(this._LoadText("locBtnQuit", "Quit"), "2");
return a.Run();
}
// END WizardAlert
///////////////////////////////////////////////////////////////////////
function FormatLogHeader(inHeaderText)
{
return "______ " + inHeaderText + " ______"
}
/**
Compare two versions that are in a.b.c.d format.
@retval <0 iff version1 < version2
@retval 0 iff version1 == version2
@retval >0 iff version1 > version2
*/
function compareVersions(version1, version2)
{
var versionDelimsRE = /[,.]/;
var versionArray1 = version1.split(versionDelimsRE);
var versionArray2 = version2.split(versionDelimsRE);
var returnVal = 0;
var maxComponents = (versionArray1.length < versionArray2.length) ? versionArray2.length : versionArray1.length;
for (var i=0; i < maxComponents; ++i)
{
if (versionArray1.length < i)
{
versionArray1.push(0);
}
if (versionArray2.length < i)
{
versionArray2.push(0);
}
if (Number(versionArray1[i]) > Number(versionArray2[i]))
{
returnVal = 1;
}
else if (Number(versionArray1[i]) < Number(versionArray2[i]))
{
returnVal = -1;
}
if (returnVal != 0)
{
break;
}
}
return returnVal;
}
function _getSupportedLanguagesArray(inContainerProxy)
{
var sessionSupportedLanguages = new Array();
var payloadMap = inContainerProxy.GetSessionData().payloadMap;
var mapFamilyNameToLangs = new Object();
for (var adobeCode in payloadMap)
{
var payload = payloadMap[adobeCode];
var satisfiesObj = payloadMap[adobeCode].Satisfies;
var keyPair = satisfiesObj.family + satisfiesObj.productName;
var langs = mapFamilyNameToLangs[keyPair];
if (langs == null)
{
langs = new Object();
}
// Update the langs object
if (payload.isLanguageIndependent != null &&
true == payload.isLanguageIndependent)
{
var allLangs = getAllSupportedLanguagesArray();
for (var langIndex = 0; langIndex < allLangs.length; ++langIndex)
{
langs[allLangs[langIndex]] = 1;
}
}
else
{
for (var langIndex = 0; langIndex < payload.Languages.length; ++langIndex)
{
langs[payload.Languages[langIndex]] = 1;
}
}
mapFamilyNameToLangs[keyPair] = langs;
}
var firstIteration = true;
for (var keyPair in mapFamilyNameToLangs)
{
// Get all the languages and intersect that with the existing set
if (firstIteration)
{
var supportedLangMap = mapFamilyNameToLangs[keyPair];
for (eachSupportedLang in supportedLangMap)
{
sessionSupportedLanguages.push(eachSupportedLang);
}
firstIteration = false;
}
else
{
if (sessionSupportedLanguages.length <= 0)
{
break;
}
// Remove any element that doesn't exist
var updatedSupportedLangs = new Array();
for (var supportedIndex = 0; supportedIndex < sessionSupportedLanguages.length; ++supportedIndex)
{
if (mapFamilyNameToLangs[keyPair][sessionSupportedLanguages[supportedIndex]] != null)
{
updatedSupportedLangs.push(sessionSupportedLanguages[supportedIndex]);
}
}
sessionSupportedLanguages = updatedSupportedLangs;
}
}
return sessionSupportedLanguages;
}
/**
Test to see if this install supports only a single language
@retval "" the installer supports more locales or none
@retval string the installer supports locale <string>
*/
function _extendScriptGetSingleLanguage()
{
var returnVal = "";
try
{
var sendContainerProxy = new ContainerProxy;
if (sendContainerProxy)
{
var langArray = _getSupportedLanguagesArray(sendContainerProxy);
if (1 == langArray.length)
returnVal = langArray[0];
}
}
catch (ex)
{
}
return returnVal;
}
/**
Given an InstallerSession instance, traverse the payloads and determine how much disk space is required on each volume.
*/
function _calculateRequiredSpace(inInstallerSession)
{
var mapRootToSize = inInstallerSession.OperationSize().roots;
var mapVolumeToSize = new Object();
var dirTokenMap = inInstallerSession.GetDirectoryTokenMap();
dirTokenMap["[INSTALLDIR]"] = inInstallerSession.properties["INSTALLDIR"];
for (var eachRoot in mapRootToSize)
{
var fullPath = dirTokenMap[eachRoot];
if (null == fullPath)
{
throw "Unsupported directory token: " + eachRoot;
}
var volumeInfo = inInstallerSession.GetVolumeStatisticsFromPath(fullPath);
if (!volumeInfo || !volumeInfo.rootPath)
{
throw "Unable to get volume statistics for path: " + fullPath;
}
var currentSize = mapVolumeToSize[volumeInfo.rootPath];
if (null == currentSize)
{
currentSize = 0;
}
currentSize += mapRootToSize[eachRoot];
mapVolumeToSize[volumeInfo.rootPath] = currentSize;
}
return mapVolumeToSize;
}
/**
Object that contains the status information for the current install operation.
*/
function InstallOperationStatus(inInstallerSession)
{
/** Current session */
this.installerSession = inInstallerSession;
/** The InstallerPayload that we're currently operating on */
this.currentPayloadObj = null;
/** Total number of operations that are going to be performed */
this.totalOperations = 0;
/** Normalized progress 0 <= n <= 100 */
this.totalProgress = 0;
/** Current operation index. [0, totalOperations) */
this.currentOperation = 0;
/** Current relative disk index, from the set of media we are installing right now */
this.currentRelativeDiskIndex = 0;
/** Current media name, if any */
this.currentMediaName = null;
/** Number of payloads for this disk that have been installed */
this.mediaPayloadsInstalled = 0;
/** Total media count */
this.mediaCount = 0;
/** System Info */
this.systemInfo = inInstallerSession.GetSystemInfo();
/** Last known media path **/
this.lastMediaPath = null;
/** Boolean to see if we can move on in media check loop **/
this.foundOrCancelled = false;
/** Current status object. The status object has the following form:
obj.message
--- All operation types --
obj.message.code Integer. 0 == success. Other values are context sensitive. See PayloadOperationConstants.h
--- InstallPayload Data ---
obj.isRunning Integer [0, 1]
obj.percentComplete Integer [0 - 100]
obj.message.args Array of arguments that are associated with the current obj.message.code value
--- Simulation Data ---
obj.message.simulateResults Anonymous object scoping payload results from CAPS simulation test
obj.message.simulationResults.conflicting Array of AdobeCodes that would be in conflict were this operation successful
obj.message.simulationResults.upgraded Array of AdobeCodes that would be upgraded were this operation successful
obj.message.simulationResults.corrupted Array of AdobeCodes that would be orphaned if this operation were successful. Bootstrapper specific
*/
this.operationStatus = null;
/** Flag that's set if the last operation encountered an error and
we need to release from the progress since the operation
won't necessarily have a percentComplete value */
this.operationsComplete = false;
this.percentPayload = null;
/** Flag indicating that we should exit the workflow because the user selected cancel */
this.exitOperationsLoop = false;
this.updateProgress = function()
{
this.operationStatus = this.installerSession.GetInstallStatus();
if (this.operationStatus != null)
{
if (this.operationStatus.percentComplete != null)
{
this.percentPayload = this.operationStatus.percentComplete;
if (this.totalOperations > 0)
{
if (100 == this.operationStatus.percentComplete &&
this.currentOperation == (this.totalOperations-1))
{
this.totalProgress = 100;
}
else
{
var intervalSize = 1;
if (this.totalOperations != 0)
intervalSize = 100/this.totalOperations;
if (intervalSize < 1)
intervalSize = 1;
var offset = (this.currentOperation)*intervalSize;
offset += ((this.operationStatus.percentComplete * intervalSize)/100);
this.totalProgress = offset;
}
}
}
}
//this.installerSession.LogDebug("totalProgress: " + this.totalProgress);
}
this.isCurrentOperationComplete = function()
{
var isComplete = false;
if (this.operationStatus &&
this.operationStatus.isRunning == 0)
{
isComplete = true;
}
return isComplete;
}
this.areAllOperationsComplete = function()
{
var allComplete = this.operationsComplete;
if (!allComplete)
{
if (this.totalOperations == (this.currentOperation+1))
{
allComplete = this.isCurrentOperationComplete();
}
}
return allComplete;
}
}
function InstallOperationsQueue(inInstallerSession, inStatusCallback, inCancelCallback)
{
this.installerSession = inInstallerSession;
this.callbackMethod = inStatusCallback;
this.cancelCallback = inCancelCallback;
this.installOperationStatus = new InstallOperationStatus(inInstallerSession);
this._operationsQueue = null;
this.estimatedSize = 0;
this.reverse = false; // True if we are uninstalling.
this.Open = function()
{
var didOpen = false;
if (null == this._operationsQueue)
{
this._operationsQueue = new Array();
// Walk through the session payloads collecting ones with an interesting action.
// But we don't allow mixed installs and removes as they are a little too interesting.
var installCount = 0;
var removeCount = 0;
LogPayloadSet(this.installerSession, "InstallOperationsQueue Unordered operations", this.installerSession.sessionPayloads,
function(p) { return "with operation " + p.GetInstallerAction(); });
for (var adobeCode in this.installerSession.sessionPayloads)
{
var payload = this.installerSession.sessionPayloads[adobeCode];
payload.SetOperationResult(null);
switch (payload.GetInstallerAction())
{
case kInstallerActionInstall:
case kInstallerActionRepair:
installCount++;
this._operationsQueue.push(payload);
var opSize = payload.OperationSize(true);
if (opSize && opSize.totalBytes)
{
var addSize = (opSize.totalBytes/1024);
if (addSize < 1)
addSize = 1;
this.estimatedSize += Math.ceil(addSize);
}
break;
case kInstallerActionRemove:
removeCount++;
this._operationsQueue.push(payload);
break;
}
}
if (installCount > 0 && removeCount > 0)
{
this.installerSession.LogError("InstallOperationsQueue: Installing and removing payloads in the same run is not supported");
}
else if (this._operationsQueue.length > 0)
{
// We have somthing to do, sort the queue
this._operationsQueue.sort(PayloadSortOperationOrder);
if (removeCount > 0)
{
this.reverse = true;
this._operationsQueue.reverse();
}
LogPayloadSet(this.installerSession, "InstallOperationsQueue Ordered operations", this._operationsQueue,
function(p) { return "with operation " + p.GetInstallerAction(); });
// Negative one so we can PopInstruction and start with 0
this.installOperationStatus.currentOperation = -1;
this.installOperationStatus.totalOperations = this._operationsQueue.length;
didOpen = true;
}
else
{
this.installerSession.LogError("InstallOperationsQueue: Instruction set is empty");
}
}
return didOpen;
}
this.PopInstruction = function(inIntervalCallback)
{
var retValue = null;
while (retValue == null
&& (this.installOperationStatus.currentOperation+1) < this.installOperationStatus.totalOperations)
{
this.installOperationStatus.currentOperation += 1;
this.installerSession.LogDebug("Testing operation: " + this.installOperationStatus.currentOperation);
retValue = this._operationsQueue[this.installOperationStatus.currentOperation];
// If all the dependencies are satisfied, then return it, otherwise
// propagate the error and skip to the next one.
this.installerSession.LogDebug("Popping instruction for payload " + retValue.LogID());
// Test if the user canceled. Note: this may also be
// set via this.callbackMethod which is used in the operation status polling to pickup
// a cancel in the middle of an operation. Both methods have a site effect of setting
// the exitOperationsLoop property of the installOperationStatus object.
if (this.cancelCallback && "function" == typeof this.cancelCallback)
{
this.cancelCallback(this.installOperationStatus);
}
// If the user canceled then we need to short circuit
if (this.installOperationStatus.exitOperationsLoop == true)
{
// Set the install status for all remaining payloads to complete
this.installerSession.LogDebug("User exited workflow.");
if (retValue)
{
this.installerSession.LogDebug("Marking payload " + retValue.LogID() + " as canceled");
this.installOperationStatus.operationStatus = new Object();
this.installOperationStatus.operationStatus.isRunning = false;
this.installOperationStatus.operationStatus.percentComplete = 100;
this.installOperationStatus.operationStatus.message = new Object();
this.installOperationStatus.operationStatus.message.code = 1; // OR_UserCancel
this.installerSession.LogDebug("Status object");
this.installerSession.LogDebug(this.installOperationStatus.operationStatus);
var aPayload = this.installerSession.sessionPayloads[retValue.GetAdobeCode()];
if (aPayload != null)
{
aPayload.SetOperationResult(this.installOperationStatus.operationStatus);
this.installerSession.LogDebug("Set payload canceled status");
}
else
{
this.installerSession.LogDebug("Unable to get payload to set status");
}
}
else
{
this.installerSession.LogDebug("Current operation is null");
}
retValue = null;
}
else
{
// Make sure that whatever we needed has already happened...
// But restrect checks to payloads in our operation queue. The full requirement
// set should have been validated upstream.
var requiredOpsArray = this.reverse ? retValue.GetSatisfiedArray() : retValue.GetRequiredArray();
requiredOpsArray = PayloadIntersect(requiredOpsArray, this._operationsQueue);
LogPayloadSet(this.installerSession, "Dependent operations for " + retValue.LogID(), requiredOpsArray);
for (var i =0; i < requiredOpsArray.length; ++i)
{
var aPayload = requiredOpsArray[i];
this.installerSession.LogDebug("Checking operation result for " + aPayload.LogID());
var operationResult = aPayload.GetOperationResult();
if (null == operationResult)
{
this.installerSession.LogDebug("Required operation status is null, skipping current operation");
// So clearly we're null as well
retValue = null;
break;
}
else if (operationResult && operationResult._error)
{
}
else if (operationResult)
{
// This operation should be complete. If it is, and there's
// an error, make that our result as well
if (operationResult.message && operationResult.message.code)
{
if (operationResult.percentComplete >= 100)
{
if (operationResult.message &&
!this.installerSession.IsOperationCodeSuccess(operationResult.message.code))
{
this.installerSession.LogError("Skipping operation because required operation failed with code: " + operationResult.message.code);
if (retValue != null)
{
this.installerSession.LogError("Setting dependent operation result");
retValue.SetOperationResult(operationResult);
// If this is the last operation we need to set the special flag
if (this.installOperationStatus.currentOperation+1 == this.installOperationStatus.totalOperations)
{
this.installOperationStatus.operationsComplete = true;
}
}
retValue = null;
break;
}
}
}
}
else
{
// Bad error somewhere...
this.installerSession.LogError("Skipping operation because required operation failed with error: " + status.operationStatus._error);
retValue.SetOperationResult(null);
retValue = null;
break;
}
}
}
this.installOperationStatus.currentPayloadObj = retValue;
}
return retValue;
}
}
function _simulatePayloadOperations(inInstallerSession)
{
var didVerify = false;
var preflightQueue = new InstallOperationsQueue(inInstallerSession);
if (preflightQueue.Open())
{
try
{
var openSession = inInstallerSession.OpenCAPSSimulation();
if (openSession.success)
{
var poppedInstruction = null;
while (null != (poppedInstruction = preflightQueue.PopInstruction()))
{
// We just do this to the information that
// is available in the GetOperationResult is the same between the simulation
// and the thread-based model
var installOperationStatus = new InstallOperationStatus(inInstallerSession);
installOperationStatus.currentPayloadObj = poppedInstruction;
installOperationStatus.operationStatus = inInstallerSession.SimulateInstallPayload(poppedInstruction.GetAdobeCode(), poppedInstruction.GetInstallerAction(), inInstallerSession.properties);
poppedInstruction.SetOperationResult(installOperationStatus.operationStatus);
}
inInstallerSession.CloseCAPSSimulation();
}
}
catch (ex)
{
didVerify = false;
}
}
return didVerify;
}
/**
Method to sequence and execute the individual payloads in the current session.
@param inInstallerSession Existing installer session instance
@param inStatusCallback Callback method to invoke with status object
@param inCancelCallback Callback method returning true to continue operations, false to stop
*/
var _gInstallOperationsQueue = null;
var _gPollingIntervalName = null;
function _doPayloadOperations(inInstallerSession, inStatusCallback, inCancelCallback)
{
// Get the total number of operations.
try
{
_gInstallOperationsQueue = new InstallOperationsQueue(inInstallerSession, inStatusCallback, inCancelCallback);
if (_gInstallOperationsQueue.Open())
{
inInstallerSession.LogDebug("Opened installation queue");
var poppedInstruction = _gInstallOperationsQueue.PopInstruction();
if (poppedInstruction)
{
// Set the media information in the property map
var payloadObject = inInstallerSession.payloadMap[poppedInstruction.GetAdobeCode()];
if (payloadObject && payloadObject.MediaInfo)
{
_gInstallOperationsQueue.installOperationStatus.lastMediaPath = inInstallerSession.properties["mediaPath"];
inInstallerSession.properties["mediaType"] = payloadObject.MediaInfo.type;
inInstallerSession.properties["mediaVolumeIndex"] = payloadObject.MediaInfo.volumeIndex;
inInstallerSession.properties["mediaPath"] = payloadObject.MediaInfo.path;
inInstallerSession.properties["mediaName"] = payloadObject.MediaInfo.mediaName;
_gInstallOperationsQueue.installOperationStatus.currentRelativeDiskIndex = 1;
_gInstallOperationsQueue.installOperationStatus.currentMediaName = payloadObject.MediaInfo.mediaName;
_gInstallOperationsQueue.installOperationStatus.mediaPayloadsInstalled = 0;
// See if we need to swap and prompt if we do
DetectSwap(payloadObject, poppedInstruction.GetInstallerAction());
}
else
{
inInstallerSession.properties["mediaType"] = "0";
inInstallerSession.properties["mediaVolumeIndex"] = "1";
inInstallerSession.properties["mediaPath"] = "";
inInstallerSession.properties["mediaName"] = "";
_gInstallOperationsQueue.installOperationStatus.currentRelativeDiskIndex = 1;
}
// Get all the payloads with an install operation and sum them. This is the "AddRemoveEstimatedSize" value
inInstallerSession.properties["AddRemoveInfoEstimatedSize"] = _gInstallOperationsQueue.estimatedSize;
// We'll get the rest of it in the callback method
inInstallerSession.InstallPayload(poppedInstruction.GetAdobeCode(), poppedInstruction.GetInstallerAction(), inInstallerSession.properties);
if(inInstallerSession.UIHosted())
{
_gInstallOperationsQueue.installerSession.LogInfo("Setting interval");
_gPollingIntervalName = window.setTimeout("_pollOperationStatus()", 200);
}
else
{
_gInstallOperationsQueue.installerSession.LogInfo("Setting callback for silent");
_gPollingIntervalName = "_pollOperationStatus()";
eval("_pollOperationStatus()");
}
}
}
else
{
throw "Unable to open operation queue";
}
}
catch (ex)
{
if (inInstallerSession)
inInstallerSession.LogError("error creating instructions: " + ex);
}
}
function _pollOperationStatus()
{
try
{
if (!_gInstallOperationsQueue)
{
return;
}
if (_gPollingIntervalName != null && _gInstallOperationsQueue.installerSession.UIHosted())
{
//_gInstallOperationsQueue.installerSession.LogDebug("Destroying interval: " + _gPollingIntervalName);
//clearInterval(_gPollingIntervalName);
_gPollingIntervalName = null;
}
else if (_gPollingIntervalName)
{
_gInstallOperationsQueue.installerSession.LogDebug("Destroying interval: " + _gPollingIntervalName);
_gPollingIntervalName = null;
}
//_gInstallOperationsQueue.installerSession.LogDebug("updating progress");
_gInstallOperationsQueue.installOperationStatus.updateProgress();
try
{
_gInstallOperationsQueue.callbackMethod(_gInstallOperationsQueue.installOperationStatus);
}
catch (ex)
{