a9a6b45af65238d633b616d110dd6678a9078ed2
[openafs.git] / src / WINNT / install / InstallShield5 / setup.rul
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1998  Transarc Corporation.
4 // All rights reserved.
5 //
6 //
7 //    File Name:  Setup.rul
8 //
9 //  Description:  InstallShield script
10 //
11 ////////////////////////////////////////////////////////////////////////////////
12
13
14 // Include header files
15
16     #include "sdlang.h"
17     #include "sddialog.h"
18
19 ////////////////////// string defines ////////////////////////////
20
21         // If the user places a file with this name in the same directory as
22         // the setup files, only the client component will be available for
23         // install.  The contents of this file are not used.
24         #define ALLOW_ONLY_CLIENT_FLAG_FILENAME         "setup.co"
25
26         // The release types
27         #define RELEASE_TYPE_GA         "GA"
28         #define RELEASE_TYPE_BETA               "Beta"
29         
30         // Client logon dll names
31         #define FULL_CLIENT_LOGON_DLL   "Client\\PROGRAM\\afslogon.dll"
32         #define LIGHT_CLIENT_LOGON_DLL  "Client\\PROGRAM\\afslog95.dll"
33
34         // Uninstall log file names for each component
35     #define SERVER_UNINST_LOGFILE_NAME          "Server_Uninst.isu"
36     #define CLIENT_UNINST_LOGFILE_NAME          "Client_Uninst.isu"
37     #define LIGHT_CLIENT_UNINST_LOGFILE_NAME    "Light_Client_Uninst.isu"
38     #define CC_UNINST_LOGFILE_NAME                      "CC_Uninst.isu"
39     #define DOCS_UNINST_LOGFILE_NAME                    "Docs_Uninst.isu"
40
41         // Uninstall dll names for each component
42         #define SERVER_UNINST_DLL_NAME                          "ServerUninst.dll"
43         #define CLIENT_UNINST_DLL_NAME                          "ClientUninst.dll"
44         #define CC_UNINST_DLL_NAME                                      "CCUninst.dll"
45         #define LIGHT_CLIENT_UNINST_DLL_NAME            "LightClientUninst.dll"
46         #define DOCS_UNINST_DLL_NAME                            "DocsUninst.dll"
47         
48         // These are the components the user sees
49         #define CLIENT_COMP_NAME                        "Client"
50         #define LIGHT_CLIENT_COMP_NAME          "Light_Client"
51         #define SERVER_COMP_NAME                        "Server"
52         #define CC_COMP_NAME                            "Control_Center"
53
54         // Light Client platform components
55         #define LIGHT95_CLIENT_COMP_NAME                "Light_Client\\Win95"
56         #define LIGHT98_CLIENT_COMP_NAME                "Light_Client\\Win98"
57
58         // This is added to autoexec.bat on Win95 systems
59         #define LIGHT95_CLIENT_PROTSEQ                  "AFS_RPC_PROTSEQ=ncacn_ip_tcp"
60                 
61     // Language components
62         #define LANG_COMP_NAME                                  "Languages"
63     #define LANG_ENGLISH_COMP_NAME          "Languages\\Lang_English"
64     #define LANG_SIMP_CHINESE_COMP_NAME     "Languages\\Lang_Simp_Chinese"
65     #define LANG_TRAD_CHINESE_COMP_NAME     "Languages\\Lang_Trad_Chinese"
66     #define LANG_KOREAN_COMP_NAME           "Languages\\Lang_Korean"
67     #define LANG_JAPANESE_COMP_NAME         "Languages\\Lang_Japanese"
68     #define LANG_GERMAN_COMP_NAME           "Languages\\Lang_German"
69     #define LANG_SPANISH_COMP_NAME          "Languages\\Lang_Spanish"
70     #define LANG_PORTUGUESE_COMP_NAME       "Languages\\Lang_Portuguese"
71
72         // Documentation components
73         #define DOCS_COMP_NAME                                  "Documentation"
74         #define DOCS_ENGLISH_COMP_NAME                  "Documentation\\English"
75         #define DOCS_JAPANESE_COMP_NAME                 "Documentation\\Japanese"
76         #define DOCS_KOREAN_COMP_NAME                   "Documentation\\Korean"
77         #define DOCS_SIMP_CHINESE_COMP_NAME             "Documentation\\Simp_Chinese"
78         #define DOCS_TRAD_CHINESE_COMP_NAME             "Documentation\\Trad_Chinese"
79         #define DOCS_GERMAN_COMP_NAME                   "Documentation\\German"
80         #define DOCS_SPANISH_COMP_NAME                  "Documentation\\Spanish"
81         #define DOCS_PORTUGUESE_COMP_NAME               "Documentation\\Portuguese"
82         
83         // Readme files components
84         #define README_COMP_NAME                                "Readme"
85         #define README_ENGLISH_COMP_NAME                "Readme\\English"
86         #define README_JAPANESE_COMP_NAME               "Readme\\Japanese"
87         #define README_KOREAN_COMP_NAME                 "Readme\\Korean"
88         #define README_SIMP_CHINESE_COMP_NAME   "Readme\\Simp_Chinese"
89         #define README_TRAD_CHINESE_COMP_NAME   "Readme\\Trad_Chinese"
90         #define README_GERMAN_COMP_NAME         "Readme\\German"
91         #define README_SPANISH_COMP_NAME                "Readme\\Spanish"
92         #define README_PORTUGUESE_COMP_NAME             "Readme\\Portuguese"
93
94         // License filenames
95         #define LICENSE_ENGLISH_FILENAME                "License\\en_US.rtf"
96         #define LICENSE_JAPANESE_FILENAME               "License\\ja_JP.rtf"
97         #define LICENSE_KOREAN_FILENAME                 "License\\ko_KR.rtf"
98         #define LICENSE_SIMP_CHINESE_FILENAME   "License\\zh_CN.rtf"
99         #define LICENSE_TRAD_CHINESE_FILENAME   "License\\zh_TW.rtf"
100         #define LICENSE_GERMAN_FILENAME                 "License\\de_DE.rtf"
101         #define LICENSE_SPANISH_FILENAME                "License\\es_ES.rtf"
102         #define LICENSE_PORTUGUESE_FILENAME             "License\\pt_BR.rtf"
103
104         #define SETUP_UTILS_DLL_PATH    "InstallUtils.dll"
105
106         // Some registry keys
107         #define MSUNINSTALL_KEY         "\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
108         #define COMPANY_REG_KEY                 "Software\\TransarcCorporation\\"
109         #define CONFIG_INFO_KEY                 "Software\\AfsPreservedConfigInfo"
110         
111         #define CLIENT_SERVICE_NAME             "TransarcAFSDaemon"
112
113         // Client help file names
114         #define CLIENT_HELP_FILE_NAME           "Common\\afs-nt.hlp"
115         #define LIGHT_CLIENT_HELP_FILE_NAME     "Common\\afs-light.hlp"
116         
117         #define MAX_STRING_LEN  512
118
119         // Install actions
120         #define ACTION_NONE                     0
121         #define ACTION_INSTALL          1
122         #define ACTION_REINSTALL        2
123         #define ACTION_UPGRADE          3
124         #define ACTION_DOWNGRADE        4
125
126         // Documenation start menu info
127         #define DOCUMENTATION_CMD_PATH                  "Documentation\\Html\\index.htm"
128         #define DOCUMENTATION_ARGS                              ""
129
130         #define DOCUMENTATION_LICENSE_PATH              "Documentation\\Html\\license.rtf"
131
132         // Application start menu info
133         #define CFG_WIZARD_CMD_PATH                              "Server\\usr\\afs\\bin\\afssvrcfg.exe"
134         #define CFG_WIZARD_ARGS                                 "/wizard"
135         #define CREDS_TOOL_CMD_PATH                             "Client\\Program\\afscreds.exe"
136         #define CREDS_TOOL_ARGS                                 "/show"
137         #define CLIENT_HELP_CMD_PATH                    "Common\\afs-nt.hlp"
138         #define CLIENT_HELP_ARGS                                ""
139         #define LIGHT_CLIENT_HELP_CMD_PATH              "Common\\afs-light.hlp"
140         #define LIGHT_CLIENT_HELP_ARGS                  ""
141         #define SERVER_MANAGER_CMD_PATH                 "Control Center\\TaAfsServerManager.exe"
142         #define SERVER_MANAGER_ARGS                             ""
143         #define ACCT_MANAGER_CMD_PATH                   "Control Center\\TaAfsAccountManager.exe"
144         #define ACCT_MANAGER_ARGS                               ""
145
146         #define CELLSERVDB_FILENAME                             "afsdcell.ini"
147
148         #define SERVER  1
149         #define CLIENT  2
150         #define LCLIENT 4
151         #define CC      8
152         #define DOCS    16
153
154                 
155
156 //////////////////// installation declarations ///////////////////
157
158 typedef VERINFO
159 begin
160         int nMajorVersion;
161         int nMinorVersion;
162         int nPatchLevel;
163         int nBetaLevel;
164         string szReleaseType[32];
165         string szTitle[32];
166 end;
167
168
169 //      NOTE:   There is a problem with the IS registry set functionality in that if
170 //                      you specify to write a value under an existing key, at uninstall time
171 //                      not just the value will be removed, but the KEY AND ALL ITS SUBKEYS
172 //                      will also be removed.  So the registry sets can only be used to
173 //                      create entries in the registry that are for values under keys that
174 //                      we create.
175 //
176 //                      There are some values that we need to create that live under existing
177 //                      NT keys, so when we create them we must turn off logging.  The
178 //                      szNoLogRegistrySets tell us which to create without logging.
179
180 typedef APPINFO
181 begin
182         string  szCompName[64];
183         string  szCompanyName[64];
184         string  szProductName[128];
185         VERINFO Ver;                                            // Version of this product
186         VERINFO iVer;                                           // Verison of this product that is already installed
187         string  szProductKey[128];
188         BOOL    bUseUninstDLL;
189         string  szUninstDllName[64];
190         string  szUninstLogfileName[64];
191         string  szUninstKey[128];
192         string  szAppPath[256];                         // Below TARGETDIR
193         string  szBinPath[256];                         // Path to binaries and uninstall dll
194         BOOL    bAddToPath;                                     // TRUE if bin path should be added to path env var
195         string  szUninstDisplayName[128];
196         string  szRegistrySets[256];            // Comma separated list of registry sets to install
197         string  szNoLogRegistrySets[256];       // Comma separated list of registry sets to install without logging
198         int     nInstallAction;
199         BOOL    bInstallSucceeded;
200 end;
201
202
203
204 // ----- DLL function prototypes -----
205
206
207 // ----- DLL prototypes -----
208
209      // your DLL prototypes
210     prototype int InstallUtils.InstallServerService(string);
211     prototype int InstallUtils.InstallClientService(string);
212     prototype int InstallUtils.AddToPath(string);
213         prototype int InstallUtils.AddToNetworkProviderOrder(string);
214         prototype int InstallUtils.CheckIfAdmin();
215         prototype int InstallUtils.SetSilentMode();
216         prototype int InstallUtils.WriteToInstallErrorLog(string);
217         prototype int InstallUtils.RestoreConfigInfo(int);
218         prototype int InstallUtils.Eradicate34Client();
219         prototype int InstallUtils.Upgrade34ClientConfigInfo();
220     prototype int InstallUtils.IsWin98();
221         prototype int InstallUtils.ShowLicense(string,string);
222
223
224 // ---- script function prototypes -----
225
226     // generated by the Project Wizard
227     prototype ShowDialogs();
228     prototype MoveFileData();
229     prototype HandleMoveDataError( NUMBER );
230     prototype ProcessBeforeDataMove(APPINFO POINTER);
231     prototype ProcessAfterDataMove();
232     prototype SetupRegistry();
233     prototype CleanUpInstall();
234     prototype SetupInstall();
235     prototype SetupScreen();
236     prototype CheckRequirements();
237     prototype DialogShowSdWelcome();
238     prototype DialogShowSdAskDestPath();
239     prototype DialogShowSdSetupType();
240     prototype DialogShowSdSelectFolder();
241     prototype DialogShowSdFinishReboot();
242
243     // your script function prototypes
244         prototype FixTargetPaths();
245         prototype SetupAppInfo();
246         prototype LocalizeComponents();
247         prototype LocalizeComponentStatusText (STRING);
248         prototype InstallApp(APPINFO POINTER);  
249         prototype DialogShowSdAskComponentDialog();
250         prototype ShowIsSelected(string);
251         prototype ShowSelectedComponents();
252         prototype ConfigClientService();
253         prototype ConfigServerService();
254         prototype AddPath(string);
255         prototype AddBinPaths();
256         prototype ConfigUninstallDLL(APPINFO POINTER);
257         prototype CreateServerDirs();
258         prototype SetUserVars();
259         prototype SetNetworkProviderOrder();
260         prototype CreateRegistrySets(string);
261         prototype ConfigAfsCreds();
262         prototype GetLicenseFilename(BYREF string);
263         prototype GetNlsComps(BYREF string, BYREF string, BYREF string, BYREF string);
264         prototype DetectInstalledComponents();
265         prototype IsAppInstalled(APPINFO POINTER);
266         prototype ProcessCompsOnCmdLn(string);
267         prototype ParseCommandLine();
268         prototype GetVersionNumber(string);
269         prototype GetInstallAction(string, BOOL, string, string, string, string, APPINFO POINTER);
270         prototype GetInstallActions();
271         prototype ClientSelectedOrInstalled();
272         prototype RenameUninstDll(APPINFO POINTER);     
273         prototype RemoveInstalledBits(string);
274         prototype PrepareForWSPPInstall();
275         prototype CreateStartMenuEntries();
276     prototype ShowError(string, int);
277     prototype GetDateTimeString(BYREF string);
278         prototype OnlyInstallingDocs();
279         prototype CreateDirs();
280         prototype AddShortCut(string, string, string, string);
281         prototype CheckCopyCellServDB();
282         prototype RestorePreviousConfigs();
283         prototype RemoveCurrentVersion(APPINFO POINTER);
284         prototype DoesConfigInfoExist(APPINFO POINTER);
285         prototype UnselectComps();
286     prototype AnyNonUpgradableSoftwareInstalled();
287         prototype RemoveAllCurrentVersions();
288         prototype AppVersionOk(BOOL, BOOL, APPINFO POINTER);
289         prototype SetupVerInfo(APPINFO POINTER, string, string, string, string, string, string, BOOL);
290         prototype NotUpgradable(APPINFO POINTER);
291         prototype CompareVersions(APPINFO POINTER);
292
293     // ----- global variables ------
294
295     // generated by the Project Wizard
296     BOOL        bWin95, bWin98, bWinNT, bIsShellExplorer, bInstallAborted, bIs32BitSetup;
297     STRING      svDir;
298     STRING      svName, svCompany, svSerial;
299     STRING      svDefGroup;
300     STRING      szAppPath;
301     STRING      svSetupType;
302         NUMBER          nResult;
303         
304     // your global variables
305         APPINFO         appFullClient;
306         APPINFO         appLightClient;
307         APPINFO         appServer;
308         APPINFO         appControlCenter;
309     APPINFO     appDocs;
310         APPINFO POINTER pApp;
311
312         BOOL            bFullClientSel, bServerSel, bCcSel, bLightClientSel, bDocsSel;
313         string          szCommonBinPath;
314         string          szCodePage;
315         BOOL            bClientInstalled, bServerInstalled, bCcInstalled, bLightClientInstalled, bDocsInstalled;
316     string              szLangComp, szReadmeComp, szDocsComp;
317
318         // WSPP support vars
319         BOOL            bWSPPInstall;
320         BOOL            bPreinstallReplace;
321
322
323 ///////////////////////////////////////////////////////////////////////////////
324 //
325 //   MAIN PROGRAM
326 //
327 //      The setup begins here by hiding the visible setup
328 //      window.  This is done to allow all the titles, images, etc. to
329 //      be established before showing the main window.  The setup is
330 //      then performed in a series of calls to script defined functions,
331 //      with error checking at each step.
332 //
333 ///////////////////////////////////////////////////////////////////////////////
334 program
335     Disable( BACKGROUND );
336
337         if (UseDLL(SUPPORTDIR ^ SETUP_UTILS_DLL_PATH) < 0) then
338         ShowError(@SETUPUTILS_NOT_FOUND, SEVERE);
339         bInstallAborted = TRUE;
340         goto end_install;
341     endif;
342
343     SetupInstall();
344
345     CheckRequirements();
346
347         ParseCommandLine();
348         
349         SetupAppInfo();
350
351         LocalizeComponents();
352
353         DetectInstalledComponents();
354
355         // Can't upgrade, downgrade, or reinstall the light client, so if it is
356         // already installed, we must abort.  This is because on Win9x, we can't
357         // move in-use files, and so we can't silently uninstall the light client,
358         // which upgrade, downgrade, and reinstall require.
359         if (bLightClientInstalled && !bWinNT) then
360                 ShowError(@LIGHT_CLIENT_ALREADY_INSTALLED_MSG, SEVERE);
361                 bInstallAborted = TRUE;
362                 goto end_install;
363         endif;
364
365         if (AnyNonUpgradableSoftwareInstalled()) then
366                 ShowError(@NON_UPGRADABLE_SOFTWARE_INSTALLED_ERROR_MSG, SEVERE);
367                 bInstallAborted = TRUE;
368                 goto end_install;
369         endif;
370
371         GetInstallActions();
372
373         if (bWSPPInstall) then
374                 SetSilentMode();        // Tells the InstallUtils dll to run silently
375                 PrepareForWSPPInstall();
376         else
377                 // Ask user what to install
378                 SetupScreen();
379         if (ShowDialogs()<0) goto end_install;
380     endif;
381
382         // The AFS path must not contain spaces.  AFS code will break if it does.
383         LongPathToShortPath(TARGETDIR);
384
385         // Determine which comps to install to get the proper NLS files.
386     GetNlsComps(szLangComp, szReadmeComp, szDocsComp, szCodePage);
387
388         SetUserVars();
389
390         CreateDirs();
391
392         // Uninstall current versions before we install
393         RemoveAllCurrentVersions();
394
395         // Install the Client
396         if (bFullClientSel) then
397                 pApp = &appFullClient;
398                 if (InstallApp(pApp) < 0) goto end_install;
399         endif;
400
401         // Install the Light Client
402         if (bLightClientSel) then
403                 pApp = &appLightClient;
404                 if (InstallApp(pApp) < 0) goto end_install;
405                 if (bWin95) then
406                         EzBatchAddString(LIGHT95_CLIENT_PROTSEQ, "", AFTER | REPLACE);
407                 endif;
408         endif;
409
410         // Install the Server
411         if (bServerSel) then
412                 pApp = &appServer;
413                 if (InstallApp(pApp) < 0) goto end_install;
414                 CreateServerDirs();
415         endif;
416
417         // Install the Control Center
418         if (bCcSel) then
419                 pApp = &appControlCenter;
420                 if (InstallApp(pApp) < 0) goto end_install;
421         endif;
422
423         // Install the Docs
424         if (bDocsSel) then
425                 appDocs.szCompName = szDocsComp;
426                 pApp = &appDocs;
427                 if (InstallApp(pApp) < 0) goto end_install;
428         endif;
429
430         // If we installed the server, then configure the bos service
431         if (bServerSel) then
432                 if (ConfigServerService() < 0) goto end_install;
433         endif;
434
435         // If we installed the full client, then configure the client service
436         // and add the NetworkProviderOrder value.
437         if (bFullClientSel) then
438                 if (ConfigClientService() < 0) goto end_install;
439         // I'm commenting out the line below.  This will result in integrated
440         // login being off after an install.  If you want it to be on after an
441         // install, then uncomment the line.
442                 // if (SetNetworkProviderOrder() < 0) goto end_install;
443         endif;
444
445         if (bFullClientSel || bLightClientSel) then
446                 ConfigAfsCreds();
447         endif;
448
449         RestorePreviousConfigs();
450
451         AddPath(szCommonBinPath);
452
453     // If not only installing docs, then set BATCH_INSTALL to true,
454     // which will cause setup to want to reboot the computer.
455         if (OnlyInstallingDocs() == FALSE) then
456                 BATCH_INSTALL = TRUE;
457         endif;
458
459         CreateStartMenuEntries();
460
461         if (bFullClientSel || bLightClientSel || bCcSel) then
462                 CheckCopyCellServDB();
463         endif;
464
465         end_install:
466
467         UnUseDLL(SUPPORTDIR ^ SETUP_UTILS_DLL_PATH);
468
469     CleanUpInstall();
470
471     // If an unrecoverable error occurred, clean up
472     // the partial installation. Otherwise, exit normally.
473     if (bInstallAborted) then
474         abort;
475     endif;
476
477 endprogram
478
479 ///////////////////////////////////////////////////////////////////////////////
480 //
481 // Function:  ShowDialogs
482 //
483 //  Purpose:  This function manages the display and navigation of
484 //            the standard dialogs that exist in a setup.
485 //
486 ///////////////////////////////////////////////////////////////////////////////
487 function ShowDialogs()
488     NUMBER  nResult;
489     STRING      szTargetLicense;
490     STRING      szSourceLicense;
491 begin
492     Dlg_Start:
493     // beginning of dialogs label
494
495     Dlg_SdWelcome:
496     nResult = DialogShowSdWelcome();
497     if (nResult = BACK) goto Dlg_Start;
498
499     Dlg_License:
500     szTargetLicense = DOCUMENTATION_LICENSE_PATH;
501     GetLicenseFilename (szSourceLicense);
502     Disable( DIALOGCACHE );
503     nResult = ShowLicense(szTargetLicense,szSourceLicense);
504     if (nResult = 0) then
505         abort;
506     endif;
507     Enable( DIALOGCACHE );
508
509         Dlg_SdCompDlg:
510         nResult = DialogShowSdAskComponentDialog();
511         if (nResult = BACK) goto Dlg_License;
512
513     Dlg_SdSelectFolder:
514     nResult = DialogShowSdSelectFolder();
515     if (nResult = BACK) goto Dlg_SdCompDlg;
516
517     return 0;
518
519 end;
520
521
522 ///////////////////////////////////////////////////////////////////////////////
523 //
524 //  Function: NotUpgradable
525 //
526 //  Purpose: This function will return TRUE if the passed in version is not
527 //           upgradable.
528 //
529 ///////////////////////////////////////////////////////////////////////////////
530 function NotUpgradable(pApp)
531 begin
532         // The 3.5 beta is not upgradable
533         if ((pApp->iVer.nMajorVersion = 3) && (pApp->iVer.nMinorVersion = 5) && (pApp->iVer.nPatchLevel = 0) && (pApp->iVer.szReleaseType = RELEASE_TYPE_BETA)) then
534                 return TRUE;
535         endif;
536         
537         return FALSE;
538 end;
539
540
541 ///////////////////////////////////////////////////////////////////////////////
542 //
543 //  Function: AnyNonUpgradableSoftwareInstalled
544 //
545 //  Purpose: This function will return TRUE if any non-upgradable software is
546 //           installed.
547 //
548 ///////////////////////////////////////////////////////////////////////////////
549 function AnyNonUpgradableSoftwareInstalled()
550 begin
551         if (NotUpgradable(&appFullClient) ||
552             NotUpgradable(&appServer) ||
553                 NotUpgradable(&appControlCenter) ||
554                 NotUpgradable(&appLightClient) ||
555                 NotUpgradable(&appDocs))
556         then
557                 return TRUE;
558         endif;
559         
560         return FALSE;
561 end;
562
563
564 ///////////////////////////////////////////////////////////////////////////////
565 //
566 //  Function: UnselectComps
567 //
568 //  Purpose: This function unselects all of the componenets so that we can
569 //           completely control what gets installed.  We will select each
570 //           component at the time when we want to install it.
571 //
572 ///////////////////////////////////////////////////////////////////////////////
573 function UnselectComps()
574 begin
575         ComponentSelectItem(MEDIA, SERVER_COMP_NAME, FALSE);
576         ComponentSelectItem(MEDIA, CLIENT_COMP_NAME, FALSE);
577         ComponentSelectItem(MEDIA, LIGHT_CLIENT_COMP_NAME, FALSE);
578         ComponentSelectItem(MEDIA, CC_COMP_NAME, FALSE);
579         ComponentSelectItem(MEDIA, DOCS_COMP_NAME, FALSE);
580         ComponentSelectItem(MEDIA, LANG_COMP_NAME, FALSE);
581         ComponentSelectItem(MEDIA, LANG_ENGLISH_COMP_NAME, FALSE);
582         ComponentSelectItem(MEDIA, LANG_SIMP_CHINESE_COMP_NAME, FALSE);
583         ComponentSelectItem(MEDIA, LANG_TRAD_CHINESE_COMP_NAME, FALSE);
584         ComponentSelectItem(MEDIA, LANG_KOREAN_COMP_NAME, FALSE);
585         ComponentSelectItem(MEDIA, LANG_JAPANESE_COMP_NAME, FALSE);
586         ComponentSelectItem(MEDIA, LANG_GERMAN_COMP_NAME, FALSE);
587         ComponentSelectItem(MEDIA, LANG_SPANISH_COMP_NAME, FALSE);
588         ComponentSelectItem(MEDIA, LANG_PORTUGUESE_COMP_NAME, FALSE);
589         ComponentSelectItem(MEDIA, README_COMP_NAME, FALSE);
590         ComponentSelectItem(MEDIA, README_ENGLISH_COMP_NAME, FALSE);
591         ComponentSelectItem(MEDIA, README_JAPANESE_COMP_NAME, FALSE);
592         ComponentSelectItem(MEDIA, README_KOREAN_COMP_NAME, FALSE);
593         ComponentSelectItem(MEDIA, README_SIMP_CHINESE_COMP_NAME, FALSE);
594         ComponentSelectItem(MEDIA, README_TRAD_CHINESE_COMP_NAME, FALSE);
595         ComponentSelectItem(MEDIA, README_GERMAN_COMP_NAME, FALSE);
596         ComponentSelectItem(MEDIA, README_SPANISH_COMP_NAME, FALSE);
597         ComponentSelectItem(MEDIA, README_PORTUGUESE_COMP_NAME, FALSE);
598         ComponentSelectItem(MEDIA, DOCS_ENGLISH_COMP_NAME, FALSE);
599         ComponentSelectItem(MEDIA, DOCS_JAPANESE_COMP_NAME, FALSE);
600         ComponentSelectItem(MEDIA, DOCS_KOREAN_COMP_NAME, FALSE);
601         ComponentSelectItem(MEDIA, DOCS_SIMP_CHINESE_COMP_NAME, FALSE);
602         ComponentSelectItem(MEDIA, DOCS_TRAD_CHINESE_COMP_NAME, FALSE);
603         ComponentSelectItem(MEDIA, DOCS_GERMAN_COMP_NAME, FALSE);
604         ComponentSelectItem(MEDIA, DOCS_SPANISH_COMP_NAME, FALSE);
605         ComponentSelectItem(MEDIA, DOCS_PORTUGUESE_COMP_NAME, FALSE);
606 end;
607
608
609 ///////////////////////////////////////////////////////////////////////////////
610 //
611 //  Function: DoesConfigInfoExist
612 //
613 //  Purpose: This function determines if config info exists for an app.
614 //
615 ///////////////////////////////////////////////////////////////////////////////
616 function DoesConfigInfoExist(pApp)
617 begin
618         RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
619
620         if (RegDBKeyExist(CONFIG_INFO_KEY ^ pApp->szProductName) = 1) then
621                 return TRUE;
622         endif;
623         
624         return FALSE;
625 end;
626
627
628 ///////////////////////////////////////////////////////////////////////////////
629 //
630 //  Function: RestorePreviousConfigs
631 //
632 //  Purpose: This function restores config info for the apps we just installed.
633 //
634 ///////////////////////////////////////////////////////////////////////////////
635 function RestorePreviousConfigs()
636 begin
637         if (appServer.bInstallSucceeded && DoesConfigInfoExist(&appServer)) then
638                 RestoreConfigInfo(SERVER);
639         endif;
640
641     if (appFullClient.bInstallSucceeded) then
642         if (appFullClient.iVer.szTitle = "3.4a") then
643             Upgrade34ClientConfigInfo();
644         elseif (DoesConfigInfoExist(&appFullClient) = TRUE) then
645                     RestoreConfigInfo(CLIENT);
646                 endif;
647         endif;
648
649         if (appLightClient.bInstallSucceeded && DoesConfigInfoExist(&appLightClient)) then
650                 RestoreConfigInfo(LCLIENT);
651         endif;
652         
653         // Only restore control center info if client not installed
654         if (appControlCenter.bInstallSucceeded && !bClientInstalled && !appFullClient.bInstallSucceeded
655                 && DoesConfigInfoExist(&appControlCenter))
656         then
657                 RestoreConfigInfo(CC);
658         endif;
659 end;
660
661
662 ///////////////////////////////////////////////////////////////////////////////
663 //
664 //  Function: OnlyInstallingDocs
665 //
666 //  Purpose: This function determines if only the doc files are being installed.
667 //
668 ///////////////////////////////////////////////////////////////////////////////
669 function OnlyInstallingDocs()
670 begin
671         if (!bServerSel && !bFullClientSel && !bLightClientSel && !bCcSel && bDocsSel) then
672                 return TRUE;
673         endif;
674         
675         return FALSE;
676 end;
677
678
679 ///////////////////////////////////////////////////////////////////////////////
680 //
681 //  Function: CreateDirs
682 //
683 //  Purpose: This function creates directories that we don't want IS to make.
684 //
685 ///////////////////////////////////////////////////////////////////////////////
686 function CreateDirs()
687 begin
688         // Turn off logging.  It shouldn't be on when this func is called, but we
689         // turn it off anyway just to make sure.  We turn it off so that IS won't
690         // try to delete the dirs we are about to make during an uninstall.  If
691         // we don't do this, then the first app installed that uses one of these
692         // dirs will think that it owns that dir and won't know that other apps
693         // are sharing it.
694         Disable(LOGGING);
695
696         // Create the target dir and the shared dirs
697         CreateDir(TARGETDIR);
698         CreateDir(TARGETDIR ^ "Documentation");
699         CreateDir(TARGETDIR ^ "Documentation\\Html");
700         CreateDir(TARGETDIR ^ "Documentation\\Html\\InstallGd");
701         CreateDir(TARGETDIR ^ "Documentation\\Html\\ReleaseNotes");
702
703         // We need to manually create the Server dir so that if we have to leave
704         // it behind during an uninstall (so that config info is preserved), IS
705         // won't complain that it can't be deleted.
706         if (bServerSel) then
707                 CreateDir(TARGETDIR ^ "Server\\usr\\afs\\bin");
708         endif;
709
710     // Docs don't use the common dir
711         if (OnlyInstallingDocs() = FALSE) then
712                 CreateDir(TARGETDIR ^ "Common");
713         endif;
714 end;
715
716
717 ///////////////////////////////////////////////////////////////////////////////
718 //
719 //  Function: PrepareForWSPPInstall
720 //
721 //  Purpose: This function decides what to install when doing a WSPP install.
722 //
723 ///////////////////////////////////////////////////////////////////////////////
724 function PrepareForWSPPInstall()
725 begin
726         SHELL_OBJECT_FOLDER = @WSPP_FOLDER_NAME;
727
728         // Never install the Docs during a WSPP install
729         appDocs.nInstallAction = ACTION_NONE;
730
731         // If we have been told to replace any preinstalled software, then set
732         // our reinstall mechanism in motion.
733         if (bPreinstallReplace) then
734                 if (bCcInstalled && bCcSel) then
735                         appControlCenter.nInstallAction = ACTION_REINSTALL;
736                 endif;
737                 if (bClientInstalled && bFullClientSel) then
738                         appFullClient.nInstallAction = ACTION_REINSTALL;
739                 endif;
740                 if (bServerInstalled && bServerSel) then
741                         appServer.nInstallAction = ACTION_REINSTALL;
742                 endif;
743                 if (bLightClientInstalled && bLightClientSel) then
744                         appLightClient.nInstallAction = ACTION_REINSTALL;
745                 endif;
746         else
747                 // If we have been told to not install something that is already
748                 // installed, then do just that.
749                 if (bCcInstalled && bCcSel) then
750                         bCcSel = FALSE;
751                 endif;
752                 if (bClientInstalled && bFullClientSel) then
753                         bFullClientSel = FALSE;
754                 endif;
755                 if (bServerInstalled && bServerSel) then
756                         bServerSel = FALSE;
757                 endif;
758                 if (bLightClientInstalled && bLightClientSel) then
759                         bLightClientSel = FALSE;
760                 endif;
761         endif;
762 end;
763
764
765 ///////////////////////////////////////////////////////////////////////////////
766 //
767 // Function: RemoveCurrentVersion
768 //
769 //  Purpose: This function removes the currently installed version of the app.
770 //                       It provides a message to the user so they know what is going on.
771 //
772 ///////////////////////////////////////////////////////////////////////////////
773 function RemoveCurrentVersion(pApp)
774         string szMsg;
775         string szFormat;
776 begin
777         szFormat = "";
778
779         switch(pApp->nInstallAction)
780                 case ACTION_REINSTALL:  szFormat = @REINSTALL_PREP_MSG;
781                 case ACTION_UPGRADE:    szFormat = @UPGRADE_PREP_MSG;
782                 case ACTION_DOWNGRADE:  szFormat = @DOWNGRADE_PREP_MSG;
783         endswitch;
784
785         if (szFormat == "") then
786                 return;
787         endif;
788         
789         Sprintf(szMsg, szFormat, pApp->szProductName);
790         
791         if (!bWSPPInstall) then
792                 SdShowMsg(szMsg, TRUE);
793         endif;
794
795         RemoveInstalledBits(pApp->szProductName);
796
797         if (!bWSPPInstall) then
798                 SdShowMsg(szMsg, FALSE);
799         endif;
800 end;
801
802
803 ///////////////////////////////////////////////////////////////////////////////
804 //
805 // Function: RemoveAllCurrentVersions
806 //
807 // Purpose: This function removes the current install of all apps that are
808 //          begin reinstalled, upgraded, or downgraded.
809 //
810 ///////////////////////////////////////////////////////////////////////////////
811 function RemoveAllCurrentVersions()
812 begin
813         if (bFullClientSel) then        
814                 RemoveCurrentVersion(&appFullClient);
815         endif;
816         
817         if (bServerSel) then
818                 RemoveCurrentVersion(&appServer);
819         endif;
820         
821         if (bCcSel) then
822                 RemoveCurrentVersion(&appControlCenter);
823         endif;
824         
825         if (bLightClientSel) then
826                 RemoveCurrentVersion(&appLightClient);
827         endif;
828 end;
829
830
831 ///////////////////////////////////////////////////////////////////////////////
832 //
833 // Function: InstallApp
834 //
835 // Purpose: This function installs an application that is part of a suite.
836 //
837 ///////////////////////////////////////////////////////////////////////////////
838 function InstallApp(pApp)
839         NUMBER nResult;
840 begin
841         if (pApp->nInstallAction = ACTION_NONE) then
842                 return 0;
843         endif;
844
845         // Start fresh with nothing selected
846         UnselectComps();
847
848         // Select the comps we want to install.  We will install the passed in app
849         // as well as the comps that are shared by all the apps.  Because of weird
850         // IS stuff, the app comp must be selected last else IS will autoselect
851         // things we don't want.
852         ComponentSelectItem(MEDIA, szReadmeComp, TRUE);
853
854         // Lang comps are shared by all apps except the docs app
855         if (pApp != &appDocs) then
856                 ComponentSelectItem(MEDIA, szLangComp, TRUE);
857         endif;
858
859     // Select the app's component
860     ComponentSelectItem(MEDIA, pApp->szCompName, TRUE);
861
862 //      MessageBox("Install app: " + pApp->szCompName, INFORMATION);
863
864     nResult = ProcessBeforeDataMove(pApp);
865     if (nResult < 0) goto error;
866
867     nResult = MoveFileData();
868     if (nResult < 0) goto error;
869
870     nResult = ProcessAfterDataMove();
871     if (nResult < 0) goto error;
872         
873         nResult = CreateRegistrySets(pApp->szRegistrySets);
874         if (nResult < 0) goto error;
875
876         Disable(LOGGING);
877
878         nResult = CreateRegistrySets(pApp->szNoLogRegistrySets);
879         if (nResult < 0) goto error;
880
881         nResult = ConfigUninstallDLL(pApp);
882         if (nResult < 0) goto error;
883
884         AddPath(pApp->szBinPath);
885
886         // Now unselect it again
887         ComponentSelectItem(MEDIA, pApp->szCompName, FALSE);
888
889         pApp->bInstallSucceeded = TRUE;
890
891         return 0;
892         
893 error:
894         return nResult;
895 end;
896
897
898 ///////////////////////////////////////////////////////////////////////////////
899 //
900 // Function: ProcessBeforeDataMove
901 //
902 //  Purpose: This function performs any necessary operations prior to the
903 //           actual file transfer.
904 //
905 ///////////////////////////////////////////////////////////////////////////////
906 function ProcessBeforeDataMove(pApp)
907     STRING svLogFile;
908     NUMBER nResult;
909 begin
910         // Create app information and App Paths registry keys.
911     InstallationInfo(pApp->szCompanyName, pApp->szProductName, pApp->Ver.szTitle, pApp->szProductKey);
912
913     svLogFile = pApp->szUninstLogfileName;
914
915     // Create the uninstall reg key and open the log file
916     nResult = DeinstallStart(TARGETDIR, svLogFile, pApp->szUninstKey, 0 );
917     if (nResult < 0) then
918         ShowError( @ERROR_UNINSTSETUP, WARNING );
919     endif;
920
921     szAppPath = pApp->szAppPath;
922
923         // Fill in reg values for this apps reg key and uninstall reg key
924     RegDBSetItem( REGDB_APPPATH, szAppPath );
925     RegDBSetItem( REGDB_APPPATH_DEFAULT, szAppPath ^ pApp->szProductKey);
926     RegDBSetItem( REGDB_UNINSTALL_NAME, pApp->szUninstDisplayName);
927
928     return 0;
929 end;
930
931
932 /*
933 function ShowIsSelected(comp)
934         number nSel;
935         string str;
936 begin
937     nSel = ComponentIsItemSelected(MEDIA , comp);
938     if (nSel) then
939         str = comp + " is selected.";
940         MessageBox(str, INFORMATION);
941     else
942         str = comp + " is not selected.";
943     endif;
944 end;
945
946
947 function ShowSelectedComponents()
948 begin
949         // Visible components
950         ShowIsSelected(CLIENT_COMP_NAME);
951         ShowIsSelected(LIGHT_CLIENT_COMP_NAME);
952         ShowIsSelected(SERVER_COMP_NAME);
953         ShowIsSelected(CC_COMP_NAME);
954         ShowIsSelected(DOCS_COMP_NAME);
955
956     // Language components
957         ShowIsSelected(LANG_COMP_NAME);
958     ShowIsSelected(LANG_ENGLISH_COMP_NAME);
959     ShowIsSelected(LANG_SIMP_CHINESE_COMP_NAME);
960     ShowIsSelected(LANG_TRAD_CHINESE_COMP_NAME);
961     ShowIsSelected(LANG_KOREAN_COMP_NAME);
962     ShowIsSelected(LANG_JAPANESE_COMP_NAME);
963     ShowIsSelected(LANG_GERMAN_COMP_NAME);
964     ShowIsSelected(LANG_SPANISH_COMP_NAME);
965     ShowIsSelected(LANG_PORTUGUESE_COMP_NAME);
966
967         // Documentation components
968         ShowIsSelected(DOCS_ENGLISH_COMP_NAME);
969         ShowIsSelected(DOCS_JAPANESE_COMP_NAME);
970         ShowIsSelected(DOCS_KOREAN_COMP_NAME);
971         ShowIsSelected(DOCS_SIMP_CHINESE_COMP_NAME);
972         ShowIsSelected(DOCS_TRAD_CHINESE_COMP_NAME);
973         ShowIsSelected(DOCS_GERMAN_COMP_NAME);
974         ShowIsSelected(DOCS_SPANISH_COMP_NAME);
975         ShowIsSelected(DOCS_PORTUGUESE_COMP_NAME);
976         
977         // Readme files components
978         ShowIsSelected(README_COMP_NAME);
979         ShowIsSelected(README_ENGLISH_COMP_NAME);
980         ShowIsSelected(README_JAPANESE_COMP_NAME);
981         ShowIsSelected(README_KOREAN_COMP_NAME);
982         ShowIsSelected(README_SIMP_CHINESE_COMP_NAME);
983         ShowIsSelected(README_TRAD_CHINESE_COMP_NAME);
984         ShowIsSelected(README_GERMAN_COMP_NAME);
985         ShowIsSelected(README_SPANISH_COMP_NAME);
986         ShowIsSelected(README_PORTUGUESE_COMP_NAME);
987 end;
988 */
989
990
991 ///////////////////////////////////////////////////////////////////////////////
992 //
993 //  Function:  MoveFileData
994 //
995 //  Purpose:  This function handles the file transfer for
996 //            the setup.
997 //
998 ///////////////////////////////////////////////////////////////////////////////
999 function MoveFileData()
1000     NUMBER nResult, nDisk;
1001
1002 begin
1003         if (!bWSPPInstall) then
1004                 Enable( INDVFILESTATUS );
1005         SetStatusWindow( 0, "" );
1006         Disable( DIALOGCACHE );
1007         Enable( STATUS );
1008         StatusUpdate( ON, 100 );
1009         endif;
1010
1011     nResult = ComponentMoveData( MEDIA, nDisk, 0 );
1012         
1013         // Reinit this call so the progress indicator resets
1014         ComponentMoveData("", nDisk, 0);
1015
1016     HandleMoveDataError( nResult );
1017
1018     Disable( STATUS );
1019
1020     return nResult;
1021 end;
1022
1023
1024 ///////////////////////////////////////////////////////////////////////////////
1025 //
1026 // Function: HandleMoveDataError
1027 //
1028 //  Purpose: This function handles the error (if any) during the file transfer
1029 //           operation.
1030 //
1031 ///////////////////////////////////////////////////////////////////////////////
1032 function HandleMoveDataError( nResult )
1033     STRING szErrMsg, svComponent , svFileGroup , svFile;
1034         string szMsg;
1035 begin
1036     svComponent = "";
1037     svFileGroup = "";
1038     svFile = "";
1039
1040     switch (nResult)
1041         case 0:
1042             return 0;
1043         default:
1044             ComponentError ( MEDIA , svComponent , svFileGroup , svFile , nResult );
1045             szErrMsg = @ERROR_MOVEDATA  + "\n\n" +
1046                 @ERROR_COMPONENT + " " + svComponent + "\n" +
1047                 @ERROR_FILEGROUP + " " + svFileGroup + "\n" +
1048                 @ERROR_FILE      + " " + svFile;
1049             Sprintf(szMsg, szErrMsg, nResult);
1050             ShowError(szMsg, SEVERE);
1051             bInstallAborted = TRUE;
1052             return nResult;
1053     endswitch;
1054
1055 end;
1056
1057
1058 ///////////////////////////////////////////////////////////////////////////////
1059 //
1060 // Function: ProcessAfterDataMove
1061 //
1062 //  Purpose: This function performs any necessary operations needed after
1063 //           all files have been transferred.
1064 //
1065 ///////////////////////////////////////////////////////////////////////////////
1066 function ProcessAfterDataMove()
1067     STRING szReferenceFile;
1068
1069 begin
1070
1071     // TO DO : update self-registered files and other processes that
1072     //        should be performed after the files have been transferred.
1073
1074     // DeinstallSetReference specifies a file to be checked before
1075     // uninstallation. If the file is in use, uninstallation will not proceed.
1076
1077 //      szReferenceFile = svDir ^ pApp->szProductKey; // TO DO : If your file is in a
1078                                             // subfolder of svDir add that here
1079
1080 //    DeinstallSetReference( szReferenceFile );
1081
1082     return 0;
1083 end;
1084
1085
1086 ///////////////////////////////////////////////////////////////////////////////
1087 //
1088 // Function: CleanUpInstall
1089 //
1090 //  Purpose: This cleans up the setup.  Anything that should
1091 //           be released or deleted at the end of the setup should
1092 //           be done here.
1093 //
1094 ///////////////////////////////////////////////////////////////////////////////
1095 function CleanUpInstall()
1096
1097 begin
1098     if (bInstallAborted) then
1099         return 0;
1100     endif;
1101
1102     if (!bWSPPInstall) then
1103         DialogShowSdFinishReboot();
1104     endif;
1105
1106     if (BATCH_INSTALL) then // ensure locked files are properly transferred
1107         CommitSharedFiles(0);
1108     endif;
1109
1110     return 0;
1111 end;
1112
1113
1114 ///////////////////////////////////////////////////////////////////////////////
1115 //
1116 // Function: GetLicenseFilename
1117 //
1118 //  Purpose: This will determine the full path to the appropriate-language
1119 //           license on the CD.  Will default to English if the locale cannot
1120 //           be determined.
1121 //
1122 ///////////////////////////////////////////////////////////////////////////////
1123 function GetLicenseFilename(szLicense)
1124         number MajorLanguage;
1125 begin
1126         MajorLanguage = SELECTED_LANGUAGE & 255;
1127
1128         switch(MajorLanguage)
1129         case ISLANG_CHINESE:
1130                 if (SELECTED_LANGUAGE == ISLANG_CHINESE_TAIWAN) then
1131                         szLicense = SRCDIR ^ LICENSE_TRAD_CHINESE_FILENAME;
1132                 else
1133                         szLicense = SRCDIR ^ LICENSE_SIMP_CHINESE_FILENAME;
1134                 endif;
1135
1136         case ISLANG_KOREAN:
1137                 szLicense = SRCDIR ^ LICENSE_KOREAN_FILENAME;
1138
1139         case ISLANG_JAPANESE:
1140                 szLicense = SRCDIR ^ LICENSE_JAPANESE_FILENAME;
1141
1142         case ISLANG_GERMAN:
1143                 szLicense = SRCDIR ^ LICENSE_GERMAN_FILENAME;
1144
1145         case ISLANG_PORTUGUESE:
1146                 szLicense = SRCDIR ^ LICENSE_PORTUGUESE_FILENAME;
1147
1148         case ISLANG_SPANISH:
1149                 szLicense = SRCDIR ^ LICENSE_SPANISH_FILENAME;
1150
1151         default:
1152                 szLicense = SRCDIR ^ LICENSE_ENGLISH_FILENAME;
1153
1154         endswitch;
1155
1156         return 0;
1157 end;
1158
1159
1160 ///////////////////////////////////////////////////////////////////////////////
1161 //
1162 // Function: GetLanguageComp
1163 //
1164 //  Purpose: This will determine which language the locale is set to.  Uses
1165 //           this info to determine which lang, readme, and doc comps to
1166 //           install.  Will default to English if the locale cannot be
1167 //           determined.
1168 //
1169 ///////////////////////////////////////////////////////////////////////////////
1170 function GetNlsComps(szLangComp, szReadmeComp, szDocsComp, szCodePage)
1171         number MajorLanguage;
1172 begin
1173         MajorLanguage = SELECTED_LANGUAGE & 255;
1174
1175         switch(MajorLanguage)
1176                 case ISLANG_CHINESE:
1177                         if (SELECTED_LANGUAGE == ISLANG_CHINESE_TAIWAN) then
1178                szLangComp = LANG_TRAD_CHINESE_COMP_NAME;
1179                szReadmeComp = README_TRAD_CHINESE_COMP_NAME;
1180                szDocsComp = DOCS_TRAD_CHINESE_COMP_NAME;
1181                szCodePage = "1028";
1182                         else
1183                szLangComp = LANG_SIMP_CHINESE_COMP_NAME;
1184                szReadmeComp = README_SIMP_CHINESE_COMP_NAME;
1185                szDocsComp = DOCS_SIMP_CHINESE_COMP_NAME;
1186                szCodePage = "2052";
1187                         endif;
1188
1189                 case ISLANG_KOREAN:
1190                szLangComp = LANG_KOREAN_COMP_NAME;
1191                szReadmeComp = README_KOREAN_COMP_NAME;
1192                szDocsComp = DOCS_KOREAN_COMP_NAME;
1193                szCodePage = "1042";
1194
1195                 case ISLANG_JAPANESE:
1196                szLangComp = LANG_JAPANESE_COMP_NAME;
1197                szReadmeComp = README_JAPANESE_COMP_NAME;
1198                szDocsComp = DOCS_JAPANESE_COMP_NAME;
1199                szCodePage = "1041";
1200
1201         case ISLANG_GERMAN:
1202                szLangComp = LANG_GERMAN_COMP_NAME;
1203                szReadmeComp = README_GERMAN_COMP_NAME;
1204                szDocsComp = DOCS_GERMAN_COMP_NAME;
1205                szCodePage = "1032";
1206
1207         case ISLANG_PORTUGUESE:
1208                szLangComp = LANG_PORTUGUESE_COMP_NAME;
1209                szReadmeComp = README_PORTUGUESE_COMP_NAME;
1210                szDocsComp = DOCS_PORTUGUESE_COMP_NAME;
1211                szCodePage = "1046";
1212
1213         case ISLANG_SPANISH:
1214                szLangComp = LANG_SPANISH_COMP_NAME;
1215                szReadmeComp = README_SPANISH_COMP_NAME;
1216                szDocsComp = DOCS_SPANISH_COMP_NAME;
1217                szCodePage = "1034";
1218
1219                 default:
1220                szLangComp = LANG_ENGLISH_COMP_NAME;
1221                szReadmeComp = README_ENGLISH_COMP_NAME;
1222                szDocsComp = DOCS_ENGLISH_COMP_NAME;
1223                szCodePage = "1033";
1224
1225         endswitch;
1226
1227         return 0;
1228 end;
1229
1230
1231 ///////////////////////////////////////////////////////////////////////////////
1232 //
1233 // Function: SetupVerInfo
1234 //
1235 //  Purpose: This will initialize the VERINFO structures for a product.
1236 //
1237 ///////////////////////////////////////////////////////////////////////////////
1238 function SetupVerInfo(pApp, szMajor, szMinor, szPatchLevel, szBetaLevel, szReleaseType, szTitle, bInstalledVerInfo)
1239         int nMajor;
1240         int nMinor;
1241         int nPatchLevel;
1242         int nBetaLevel;
1243 begin
1244         StrToNum(nMajor, szMajor);
1245         StrToNum(nMinor, szMinor);
1246         StrToNum(nPatchLevel, szPatchLevel);
1247         StrToNum(nBetaLevel, szBetaLevel);
1248
1249         if (bInstalledVerInfo) then
1250                 pApp->iVer.nMajorVersion = nMajor;
1251                 pApp->iVer.nMinorVersion = nMinor;
1252                 pApp->iVer.nPatchLevel = nPatchLevel;
1253                 pApp->iVer.nBetaLevel = nBetaLevel;
1254                 pApp->iVer.szReleaseType = szReleaseType;
1255                 pApp->iVer.szTitle = szTitle;   
1256         else
1257                 pApp->Ver.nMajorVersion = nMajor;
1258                 pApp->Ver.nMinorVersion = nMinor;
1259                 pApp->Ver.nPatchLevel = nPatchLevel;
1260                 pApp->Ver.nBetaLevel = nBetaLevel;
1261                 pApp->Ver.szReleaseType = szReleaseType;
1262                 pApp->Ver.szTitle = szTitle;
1263         endif;
1264 end;
1265
1266
1267         
1268 ///////////////////////////////////////////////////////////////////////////////
1269 //
1270 // Function: FixTargetPaths
1271 //
1272 //  Purpose: This function updates the CommonBinPath and app paths if you
1273 //                       choose to install to a different directory
1274 //
1275 ///////////////////////////////////////////////////////////////////////////////
1276 function FixTargetPaths()
1277 begin
1278         // The AFS path must not contain spaces.  AFS code will break if it does.
1279         LongPathToShortPath(TARGETDIR);
1280
1281         szCommonBinPath = TARGETDIR ^ "Common";
1282         
1283         // Full Client
1284         appFullClient.szAppPath = TARGETDIR ^ "Client";
1285         appFullClient.szBinPath = TARGETDIR ^ "Client\\Program";
1286         
1287         // Light Client
1288         appLightClient.szAppPath = TARGETDIR ^ "Client";
1289         appLightClient.szBinPath = TARGETDIR ^ "Client\\Program";
1290
1291         // Server
1292         appServer.szAppPath = TARGETDIR ^ "Server";
1293         appServer.szBinPath = TARGETDIR ^ "Server\\usr\\afs\\bin";
1294         
1295         // Control Center
1296         appControlCenter.szAppPath = TARGETDIR ^ "Control Center";
1297         appControlCenter.szBinPath = TARGETDIR ^ "Control Center";
1298         
1299     // Docs
1300         appDocs.szAppPath = TARGETDIR ^ "Documentation";
1301         appDocs.szBinPath = TARGETDIR ^ "Documentation";
1302 end;
1303         
1304
1305         
1306 ///////////////////////////////////////////////////////////////////////////////
1307 //
1308 // Function: SetupAppInfo
1309 //
1310 //  Purpose: This will initialize the APPINFO structures for each product
1311 //                       that we can install.
1312 //
1313 ///////////////////////////////////////////////////////////////////////////////
1314 function SetupAppInfo()
1315 int n;
1316 begin
1317         szCommonBinPath = TARGETDIR ^ "Common";
1318         
1319         // Full Client
1320         appFullClient.szCompName = CLIENT_COMP_NAME;            // Component name
1321         appFullClient.szCompanyName = @COMPANY_NAME;
1322         appFullClient.szProductName = @PRODUCT_NAME_CLIENT;
1323         appFullClient.szProductKey = @PRODUCT_KEY_CLIENT;
1324         appFullClient.bUseUninstDLL = TRUE;
1325         appFullClient.szUninstDllName = CLIENT_UNINST_DLL_NAME;
1326         appFullClient.szUninstLogfileName = CLIENT_UNINST_LOGFILE_NAME;
1327         appFullClient.szUninstKey = @UNINST_KEY_CLIENT;
1328         appFullClient.szAppPath = TARGETDIR ^ "Client";
1329         appFullClient.szBinPath = TARGETDIR ^ "Client\\Program";
1330         appFullClient.bAddToPath = TRUE;
1331         appFullClient.szUninstDisplayName = @UNINST_DISPLAY_NAME_CLIENT;
1332         appFullClient.szRegistrySets = "Client,Full_Client";
1333         appFullClient.szNoLogRegistrySets = "Client_NoUninstall,WinNT_Client_NoUninstall";
1334         appFullClient.bInstallSucceeded = FALSE;
1335         SetupVerInfo(&appFullClient, @PRODUCT_VERSION_MAJOR, @PRODUCT_VERSION_MINOR, @PRODUCT_VERSION_PATCH_LEVEL, @PRODUCT_VERSION_BETA_LEVEL, @PRODUCT_VERSION_RELEASE_TYPE, @PRODUCT_VERSION_TITLE, FALSE);
1336         
1337         // Light Client
1338         if (bWin95) then
1339                 appLightClient.szCompName = LIGHT95_CLIENT_COMP_NAME;
1340         elseif (bWin98) then
1341                 appLightClient.szCompName = LIGHT98_CLIENT_COMP_NAME;
1342         endif;
1343         appLightClient.szCompanyName = @COMPANY_NAME;
1344         appLightClient.szProductName = @PRODUCT_NAME_LIGHT_CLIENT;
1345         appLightClient.szProductKey = @PRODUCT_KEY_LIGHT_CLIENT;
1346         appLightClient.bUseUninstDLL = TRUE;
1347         appLightClient.szUninstDllName = LIGHT_CLIENT_UNINST_DLL_NAME;
1348         appLightClient.szUninstLogfileName = LIGHT_CLIENT_UNINST_LOGFILE_NAME;
1349         appLightClient.szUninstKey = @UNINST_KEY_LIGHT_CLIENT;
1350         appLightClient.szAppPath = TARGETDIR ^ "Client";
1351         appLightClient.szBinPath = TARGETDIR ^ "Client\\Program";
1352         appLightClient.bAddToPath = TRUE;
1353         appLightClient.szUninstDisplayName = @UNINST_DISPLAY_NAME_LIGHT_CLIENT;
1354         appLightClient.szRegistrySets = "Client,LightClient";
1355         appLightClient.szNoLogRegistrySets = "Client_NoUninstall";
1356         appLightClient.bInstallSucceeded = FALSE;
1357         SetupVerInfo(&appLightClient, @PRODUCT_VERSION_MAJOR, @PRODUCT_VERSION_MINOR, @PRODUCT_VERSION_PATCH_LEVEL, @PRODUCT_VERSION_BETA_LEVEL, @PRODUCT_VERSION_RELEASE_TYPE, @PRODUCT_VERSION_TITLE, FALSE);
1358
1359         // Server
1360         appServer.szCompName = SERVER_COMP_NAME;
1361         appServer.szCompanyName = @COMPANY_NAME;
1362         appServer.szProductName = @PRODUCT_NAME_SERVER;
1363         appServer.szProductKey = @PRODUCT_KEY_SERVER;
1364         appServer.bUseUninstDLL = TRUE;
1365         appServer.szUninstDllName = SERVER_UNINST_DLL_NAME;
1366         appServer.szUninstLogfileName = SERVER_UNINST_LOGFILE_NAME;
1367         appServer.szUninstKey = @UNINST_KEY_SERVER;
1368         appServer.szAppPath = TARGETDIR ^ "Server";
1369         appServer.szBinPath = TARGETDIR ^ "Server\\usr\\afs\\bin";
1370         appServer.bAddToPath = TRUE;
1371         appServer.szUninstDisplayName = @UNINST_DISPLAY_NAME_SERVER;
1372         appServer.szRegistrySets = "Server";
1373         appServer.szNoLogRegistrySets = "";
1374         appServer.bInstallSucceeded = FALSE;
1375         SetupVerInfo(&appServer, @PRODUCT_VERSION_MAJOR, @PRODUCT_VERSION_MINOR, @PRODUCT_VERSION_PATCH_LEVEL, @PRODUCT_VERSION_BETA_LEVEL, @PRODUCT_VERSION_RELEASE_TYPE, @PRODUCT_VERSION_TITLE, FALSE);
1376         
1377         // Control Center
1378         appControlCenter.szCompName = CC_COMP_NAME;
1379         appControlCenter.szCompanyName = @COMPANY_NAME;
1380         appControlCenter.szProductName = @PRODUCT_NAME_CC;
1381         appControlCenter.szProductKey = @PRODUCT_KEY_CC;
1382         appControlCenter.bUseUninstDLL = TRUE;
1383         appControlCenter.szUninstDllName = CC_UNINST_DLL_NAME;
1384         appControlCenter.szUninstLogfileName = CC_UNINST_LOGFILE_NAME;
1385         appControlCenter.szUninstKey = @UNINST_KEY_CC;
1386         appControlCenter.szAppPath = TARGETDIR ^ "Control Center";
1387         appControlCenter.szBinPath = TARGETDIR ^ "Control Center";
1388         appControlCenter.bAddToPath = TRUE;
1389         appControlCenter.szUninstDisplayName = @UNINST_DISPLAY_NAME_CC;
1390         appControlCenter.szRegistrySets = "Control_Center";
1391         appControlCenter.szNoLogRegistrySets = "";
1392         appControlCenter.bInstallSucceeded = FALSE;
1393         SetupVerInfo(&appControlCenter, @PRODUCT_VERSION_MAJOR, @PRODUCT_VERSION_MINOR, @PRODUCT_VERSION_PATCH_LEVEL, @PRODUCT_VERSION_BETA_LEVEL, @PRODUCT_VERSION_RELEASE_TYPE, @PRODUCT_VERSION_TITLE, FALSE);
1394         
1395     // Docs
1396         appDocs.szCompName = DOCS_COMP_NAME;
1397         appDocs.szCompanyName = @COMPANY_NAME;
1398         appDocs.szProductName = @PRODUCT_NAME_DOCS;
1399         appDocs.szProductKey = @PRODUCT_KEY_DOCS;
1400         appDocs.bUseUninstDLL = TRUE;
1401         appDocs.szUninstDllName = DOCS_UNINST_DLL_NAME;
1402         appDocs.szUninstLogfileName = DOCS_UNINST_LOGFILE_NAME;
1403         appDocs.szUninstKey = @UNINST_KEY_DOCS;
1404         appDocs.szAppPath = TARGETDIR ^ "Documentation";
1405         appDocs.szBinPath = TARGETDIR ^ "Documentation";
1406         appDocs.bAddToPath = FALSE;
1407         appDocs.szUninstDisplayName = @UNINST_DISPLAY_NAME_DOCS;
1408         appDocs.szRegistrySets = "Docs";
1409         appDocs.szNoLogRegistrySets = "";
1410         appDocs.bInstallSucceeded = FALSE;
1411         SetupVerInfo(&appDocs, @PRODUCT_VERSION_MAJOR, @PRODUCT_VERSION_MINOR, @PRODUCT_VERSION_PATCH_LEVEL, @PRODUCT_VERSION_BETA_LEVEL, @PRODUCT_VERSION_RELEASE_TYPE, @PRODUCT_VERSION_TITLE, FALSE);
1412 end;
1413         
1414
1415 ///////////////////////////////////////////////////////////////////////////////
1416 //
1417 // Function: SetupInstall
1418 //
1419 //  Purpose: This will initialize the setup.  Any general initialization
1420 //           needed for the installation should be performed here.
1421 //
1422 ///////////////////////////////////////////////////////////////////////////////
1423 function SetupInstall()
1424 begin
1425     Enable( CORECOMPONENTHANDLING );
1426
1427     bInstallAborted = FALSE;
1428
1429     //  Create list of end user selections to be displayed by DialogShowSdStartCopy()
1430
1431     svDir = PROGRAMFILES ^ @DEFAULT_INSTALL_DIR;
1432
1433     TARGETDIR  = svDir;
1434
1435     SdProductName( @PRODUCT_NAME );
1436
1437     Enable( DIALOGCACHE );
1438
1439     SetDialogTitle(DLG_ASK_YESNO, @TITLE_CAPTIONBAR);
1440         SetDialogTitle(DLG_MSG_INFORMATION, @TITLE_CAPTIONBAR);
1441         SetDialogTitle(DLG_MSG_WARNING, @TITLE_CAPTIONBAR);
1442         SetDialogTitle(DLG_MSG_SEVERE, @TITLE_CAPTIONBAR);
1443         SetDialogTitle(DLG_USER_CAPTION, @TITLE_CAPTIONBAR);
1444 end;
1445
1446 ///////////////////////////////////////////////////////////////////////////////
1447 //
1448 // Function:  SetupScreen
1449 //
1450 //  Purpose:  This function establishes the screen look.  This includes
1451 //            colors, fonts, and text to be displayed.
1452 //
1453 ///////////////////////////////////////////////////////////////////////////////
1454 function SetupScreen()
1455 begin
1456     Enable( FULLWINDOWMODE );
1457     SetTitle( @TITLE_MAIN, 24, WHITE );
1458
1459     SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION ); // Caption bar text.
1460
1461     Enable( BACKGROUND );
1462
1463     Delay( 1 );
1464 end;
1465
1466
1467 ///////////////////////////////////////////////////////////////////////////////
1468 //
1469 // Function:  CheckRequirements
1470 //
1471 //  Purpose:  This function checks all minimum requirements for the
1472 //            application being installed.  If any fail, then the user
1473 //            is informed and the setup is terminated.
1474 //
1475 ///////////////////////////////////////////////////////////////////////////////
1476 function CheckRequirements()
1477     NUMBER  nvDx, nvDy, nvResult;
1478     STRING  svResult;
1479 begin
1480     bWinNT           = FALSE;
1481     bWin95                       = FALSE;
1482     bWin98                       = FALSE;
1483     bIsShellExplorer = FALSE;
1484
1485     // Check screen resolution.
1486     GetExtents( nvDx, nvDy );
1487
1488     if (nvDy < 480) then
1489         ShowError( @ERROR_VGARESOLUTION, WARNING );
1490         abort;
1491     endif;
1492
1493     // set 'setup' operation mode
1494     bIs32BitSetup = TRUE;
1495     GetSystemInfo( ISTYPE, nvResult, svResult );
1496     if (nvResult = 16) then
1497         bIs32BitSetup = FALSE; // running 16-bit setup
1498         return 0; // no additional information required
1499     endif;
1500
1501     // --- 32-bit testing after this point ---
1502
1503     // Determine the target system's operating system.
1504     GetSystemInfo( OS, nvResult, svResult );
1505
1506     if (nvResult =  IS_WINDOWSNT) then
1507         // Running Windows NT.
1508         bWinNT = TRUE;
1509
1510         // If the user is not an admin, then abort
1511         if (CheckIfAdmin() = -1) then
1512             ShowError(@MUST_BE_AN_ADMIN_MSG, SEVERE);
1513             abort;
1514         endif;
1515
1516         // Check to see if the shell being used is EXPLORER shell.
1517         if (GetSystemInfo( OSMAJOR, nvResult, svResult ) = 0) then
1518             if (nvResult >= 4) then
1519                 bIsShellExplorer = TRUE;
1520             endif;
1521         endif;
1522
1523     elseif (nvResult = IS_WINDOWS95) then
1524         // IS puts us here even for Win98
1525         if (IsWin98() = 0) then
1526             bWin98 = TRUE;
1527                 else
1528                     bWin95 = TRUE;
1529                 endif;
1530
1531         bIsShellExplorer = TRUE;
1532     endif;
1533 end;
1534
1535
1536 ///////////////////////////////////////////////////////////////////////////////
1537 //
1538 // Function: DialogShowSdWelcome
1539 //
1540 //  Purpose: This function handles the standard welcome dialog.
1541 //
1542 //
1543 ///////////////////////////////////////////////////////////////////////////////
1544 function DialogShowSdWelcome()
1545     NUMBER nResult;
1546     STRING szTitle, szMsg;
1547
1548 begin
1549
1550     szTitle = "";
1551     szMsg   = "";
1552     nResult = SdWelcome( szTitle, szMsg );
1553
1554     return nResult;
1555 end;
1556
1557
1558 ///////////////////////////////////////////////////////////////////////////////
1559 //
1560 // Function: DialogShowSdAskDestPath
1561 //
1562 //  Purpose: This function asks the user for the destination folder.
1563 //
1564 ///////////////////////////////////////////////////////////////////////////////
1565 function DialogShowSdAskDestPath()
1566     NUMBER nResult;
1567     STRING szTitle, szMsg;
1568
1569 begin
1570
1571     szTitle = "";
1572     szMsg   = "";
1573     nResult = SdAskDestPath( szTitle, szMsg, svDir, 0 );
1574
1575     TARGETDIR = svDir;
1576     FixTargetPaths();
1577
1578     return nResult;
1579 end;
1580
1581
1582 ///////////////////////////////////////////////////////////////////////////////
1583 //
1584 // Function: GetVersionNumber
1585 //
1586 //  Purpose: This function converts a version number string into an integer.
1587 //
1588 ///////////////////////////////////////////////////////////////////////////////
1589 function GetVersionNumber(szVerion)
1590         int nVersion;
1591         int nMajorVersion;
1592         int nMinorVersion;
1593         string szVer[64];
1594 begin
1595         // This code assumes a majorversion.minorversion format.
1596         szVer = szVerion;
1597                 
1598         // This will get everything up to the '.'
1599         StrToNum(nMajorVersion, szVer);
1600         
1601         // Delete the part of the string we just converted
1602         StrSub(szVer, szVer, StrFind(szVer, ".") + 1, 64);
1603         
1604         // Now convert the part after the '.'
1605         StrToNum(nMinorVersion, szVer);
1606         
1607         // Turn in into a single number
1608         nVersion = (nMajorVersion * 10) + nMinorVersion;
1609         
1610         return nVersion;
1611 end;
1612         
1613
1614 ///////////////////////////////////////////////////////////////////////////////
1615 //
1616 // Function: CompareVersions
1617 //
1618 //  Purpose: This function compares an apps two version info structures and
1619 //                       determines if one is greater than the other, or if they are equal.
1620 //
1621 ///////////////////////////////////////////////////////////////////////////////
1622 function CompareVersions(pApp)
1623         int nResult;
1624 begin
1625         // Compare major versions
1626         nResult = pApp->Ver.nMajorVersion - pApp->iVer.nMajorVersion;
1627         if (nResult > 0) then return 1; endif;
1628         if (nResult < 0) then return -1; endif;
1629         
1630         // Major versions are equal, move on to minor versions
1631         nResult = pApp->Ver.nMinorVersion - pApp->iVer.nMinorVersion;
1632         if (nResult > 0) then return 1; endif;
1633         if (nResult < 0) then return -1; endif;
1634
1635         // Minor versions are equal, move on to patch level.
1636         nResult = pApp->Ver.nPatchLevel - pApp->iVer.nPatchLevel;
1637         if (nResult > 0) then return 1; endif;
1638         if (nResult < 0) then return -1; endif;
1639
1640         // Patch levels are equal, move on to release type.
1641         if ((pApp->Ver.szReleaseType = RELEASE_TYPE_GA) && (pApp->iVer.szReleaseType = RELEASE_TYPE_BETA)) then return 1; endif;
1642         if ((pApp->Ver.szReleaseType = RELEASE_TYPE_BETA) && (pApp->iVer.szReleaseType = RELEASE_TYPE_GA)) then return -1; endif;
1643         
1644         // Release types are equal.  Special handling now required:
1645         
1646         // If this is a GA release, then there is no more info to look at, and the versions are equal.
1647         if (pApp->Ver.szReleaseType = RELEASE_TYPE_GA) then return 0; endif;
1648
1649         // We have a Beta release, so we still have some info to check.  Compare the beta release levels.
1650         nResult = pApp->Ver.nBetaLevel - pApp->iVer.nBetaLevel;
1651         if (nResult > 0) then return 1; endif;
1652         if (nResult < 0) then return -1; endif;
1653         
1654         // Beta versions are equal.
1655         return 0;
1656 end;
1657         
1658
1659 ///////////////////////////////////////////////////////////////////////////////
1660 //
1661 // Function: GetInstallAction
1662 //
1663 //  Purpose: This function decides what install action to perform for a
1664 //           component and sets the display name accordingly.
1665 //
1666 ///////////////////////////////////////////////////////////////////////////////
1667 function GetInstallAction(szCompName, bInstalled, szInstallMsg, szUpgradeMsg, szDowngradeMsg, szReinstallMsg, pApp)
1668         string szDisplayName;
1669         string szVerMsg;
1670         int nResult;
1671 begin
1672         szVerMsg = "";
1673
1674         if (bInstalled) then
1675                 nResult = CompareVersions(pApp);
1676
1677                 if (nResult = 0) then
1678                         szDisplayName = szReinstallMsg;
1679                         pApp->nInstallAction = ACTION_REINSTALL;
1680         
1681                 elseif (nResult > 0) then
1682                         szDisplayName = szUpgradeMsg;
1683                         pApp->nInstallAction = ACTION_UPGRADE;
1684                         Sprintf(szVerMsg, " %s", pApp->iVer.szTitle);
1685                         
1686                 else // Trying to install old version on top of new version
1687                         szDisplayName = szDowngradeMsg;
1688                         pApp->nInstallAction = ACTION_DOWNGRADE;
1689                         Sprintf(szVerMsg, " %s", pApp->iVer.szTitle);
1690                 endif;
1691         else
1692                 szDisplayName = szInstallMsg;
1693                 pApp->nInstallAction = ACTION_INSTALL;
1694         endif;
1695
1696         szDisplayName = szDisplayName + szVerMsg;
1697
1698         ComponentSetData(MEDIA, szCompName, COMPONENT_FIELD_DISPLAYNAME, 0, szDisplayName);
1699         
1700         return TRUE;
1701 end;
1702
1703
1704 ///////////////////////////////////////////////////////////////////////////////
1705 //
1706 // Function: GetInstallActions
1707 //
1708 //  Purpose: This function decides what install action to perform for each
1709 //           component and sets the display name accordingly.
1710 //
1711 ///////////////////////////////////////////////////////////////////////////////
1712 function GetInstallActions()
1713 begin
1714         // Decide what to do for each component and then set the display names appropriately
1715         GetInstallAction(CLIENT_COMP_NAME, bClientInstalled, @INSTALL_CLIENT_MSG, @UPGRADE_CLIENT_MSG, @DOWNGRADE_CLIENT_MSG, @REINSTALL_CLIENT_MSG, &appFullClient);
1716         GetInstallAction(SERVER_COMP_NAME, bServerInstalled, @INSTALL_SERVER_MSG, @UPGRADE_SERVER_MSG, @DOWNGRADE_SERVER_MSG, @REINSTALL_SERVER_MSG, &appServer);
1717         GetInstallAction(CC_COMP_NAME, bCcInstalled, @INSTALL_CC_MSG, @UPGRADE_CC_MSG, @DOWNGRADE_CC_MSG, @REINSTALL_CC_MSG, &appControlCenter);
1718         GetInstallAction(LIGHT_CLIENT_COMP_NAME, bLightClientInstalled, @INSTALL_LIGHT_CLIENT_MSG, @UPGRADE_LIGHT_CLIENT_MSG, @DOWNGRADE_LIGHT_CLIENT_MSG, @REINSTALL_LIGHT_CLIENT_MSG, &appLightClient);
1719         GetInstallAction(DOCS_COMP_NAME, bDocsInstalled, @INSTALL_DOCS_MSG, @UPGRADE_DOCS_MSG, @DOWNGRADE_DOCS_MSG, @REINSTALL_DOCS_MSG, &appDocs);
1720 end;
1721
1722 ///////////////////////////////////////////////////////////////////////////////
1723 //
1724 // Function: ClientSelectedOrInstalled
1725 //
1726 //  Purpose: This function checks whether or not the client is selected or if
1727 //           it is already installed.
1728 //
1729 ///////////////////////////////////////////////////////////////////////////////
1730 function ClientSelectedOrInstalled()
1731 begin
1732         if (bFullClientSel || bClientInstalled) then
1733                 return TRUE;
1734         endif;
1735                 
1736         return FALSE;
1737 end;
1738
1739 ///////////////////////////////////////////////////////////////////////////////
1740 //
1741 // Function: AppVersionOk
1742 //
1743 //  Purpose: This function determines if a given app will have the correct
1744 //           version after installation.
1745 //
1746 ///////////////////////////////////////////////////////////////////////////////
1747 function AppVersionOk(bInstalled, bSel, pApp)
1748         BOOL bOk;
1749 begin
1750         // Here's the logic of this:
1751         //
1752         // 1)  If the app is not installed and
1753         //     a) it's not being installed, then this app doesn't affect the version
1754         //        restrictions, so return true
1755         //     b) it will be installed, then it will get the version which this
1756         //        installer installs, so the version will be ok
1757         //
1758         // 2)  If the app is installed and
1759         //     a) the app is selected for reinstall, upgrade, or downgrade, then the
1760         //        newly installed version will be the version this installer installs,
1761         //        and so the version will be ok
1762         //     b) the app is not selected for reinstall, upgrade, or downgrade, then
1763         //        the version is ok only if the app's current version matches the
1764         //        the version of this installer
1765
1766         bOk = !bInstalled || bSel || (CompareVersions(pApp) = 0);
1767
1768         return bOk;
1769 end;
1770         
1771
1772 ///////////////////////////////////////////////////////////////////////////////
1773 //
1774 // Function: DialogShowSdAskComponentDialog
1775 //
1776 //  Purpose: This function asks the user which components to install
1777 //                       and what the destination folder should be.
1778 //
1779 ///////////////////////////////////////////////////////////////////////////////
1780 function DialogShowSdAskComponentDialog()
1781     NUMBER nResult;
1782     STRING szTitle, szMsg, szComponent, szFilename;
1783     BOOL bClient, bServer, bCc, bDocs, bVersionsOK;
1784 begin
1785
1786     szTitle = "";
1787     szMsg   = "";
1788         szComponent = "";
1789
1790         // If running WinNT hide the Light Client component.  If the user wants to only
1791         // allow client installs, then hide all but the Client component as well.  If not
1792         // running on NT, then hide all but the Light Client component.
1793         if (bWinNT) then
1794                 ComponentSetData(MEDIA, LIGHT_CLIENT_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
1795                 ComponentSelectItem(MEDIA, LIGHT_CLIENT_COMP_NAME, FALSE);
1796         
1797                 if (FindFile(SRCDIR, ALLOW_ONLY_CLIENT_FLAG_FILENAME, szFilename) = 0) then
1798                         ComponentSetData(MEDIA, SERVER_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
1799                         ComponentSetData(MEDIA, CC_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
1800                         ComponentSetData(MEDIA, DOCS_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
1801                 
1802                         ComponentSelectItem(MEDIA, SERVER_COMP_NAME, FALSE);
1803                         ComponentSelectItem(MEDIA, CC_COMP_NAME, FALSE);
1804                         ComponentSelectItem(MEDIA, DOCS_COMP_NAME, FALSE);
1805                 endif;
1806         else
1807                 ComponentSetData(MEDIA, CLIENT_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
1808                 ComponentSetData(MEDIA, SERVER_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
1809                 ComponentSetData(MEDIA, CC_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
1810                 ComponentSetData(MEDIA, DOCS_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
1811                 
1812                 ComponentSelectItem(MEDIA, SERVER_COMP_NAME, FALSE);
1813                 ComponentSelectItem(MEDIA, CLIENT_COMP_NAME, FALSE);
1814                 ComponentSelectItem(MEDIA, CC_COMP_NAME, FALSE);
1815                 ComponentSelectItem(MEDIA, DOCS_COMP_NAME, FALSE);
1816         endif;
1817
1818 retry:
1819         nResult = SdComponentDialog(szTitle, szMsg, svDir, szComponent);
1820
1821         // Enforce selection rules - something must be selected and
1822         // the client must be selected if the server is.  However, take into
1823         // account if it is already installed.
1824         bFullClientSel = ComponentIsItemSelected(MEDIA , CLIENT_COMP_NAME);
1825         bLightClientSel = ComponentIsItemSelected(MEDIA , LIGHT_CLIENT_COMP_NAME);
1826         bServerSel = ComponentIsItemSelected(MEDIA , SERVER_COMP_NAME);
1827         bCcSel = ComponentIsItemSelected(MEDIA , CC_COMP_NAME);
1828         bDocsSel = ComponentIsItemSelected(MEDIA , DOCS_COMP_NAME);
1829
1830         if (!bFullClientSel && !bLightClientSel && !bServerSel && !bCcSel && !bDocsSel) then
1831                 ShowError(@NOTHING_SELECTED_MSG, SEVERE);
1832                 goto retry;
1833         endif;
1834
1835         if (bServerSel && !ClientSelectedOrInstalled()) then
1836                 ShowError(@SERVER_NEEDS_CLIENT_MSG, SEVERE);
1837                 goto retry;
1838         endif;  
1839
1840         // Also, if upgrading or downgrading, all apps must be at the same version level.
1841         // We won't upgrade one app to a higer version than another, and we won't downgrade
1842         // one app to a lowel version than another.  All must be at the same level when the
1843         // install program is done.  This is necessary because the apps share some files.
1844         if (!bWinNT) then
1845                 bVersionsOK = TRUE;
1846         else
1847                 bClient = AppVersionOk(bClientInstalled, bFullClientSel, &appFullClient);
1848                 bServer = AppVersionOk(bServerInstalled, bServerSel, &appServer);
1849                 bCc = AppVersionOk(bCcInstalled, bCcSel, &appControlCenter);
1850                 bDocs = AppVersionOk(bDocsInstalled, bDocsSel, &appDocs);
1851                 bVersionsOK = bClient && bServer && bCc && bDocs;
1852         endif;
1853         
1854         if (!bVersionsOK) then
1855                 ShowError(@APPS_NOT_SAME_VERSION, SEVERE);
1856                 goto retry;
1857         endif;
1858
1859     TARGETDIR = svDir;
1860     FixTargetPaths();
1861
1862     return nResult;
1863 end;
1864
1865
1866 ///////////////////////////////////////////////////////////////////////////////
1867 //
1868 // Function: DialogShowSdSetupType
1869 //
1870 //  Purpose: This function displays the standard setup type dialog.
1871 //
1872 ///////////////////////////////////////////////////////////////////////////////
1873 function DialogShowSdSetupType()
1874     NUMBER nResult, nType;
1875     STRING szTitle, szMsg, szReserved;
1876
1877 begin
1878
1879     if (svSetupType == "") then
1880         svSetupType = "AFS Server";
1881         endif;
1882         
1883     szTitle = "";
1884     szMsg   = @SETUP_TYPE_MSG;
1885     szReserved = "";
1886
1887         nResult = SdSetupTypeEx(szTitle, szMsg, szReserved, svSetupType, 0);
1888
1889     return nResult;
1890 end;
1891
1892
1893 ///////////////////////////////////////////////////////////////////////////////
1894 //
1895 //  Function: DialogShowSdSelectFolder
1896 //
1897 //  Purpose: This function displays the standard folder selection dialog.
1898 //
1899 //
1900 ///////////////////////////////////////////////////////////////////////////////
1901 function DialogShowSdSelectFolder()
1902     NUMBER nResult;
1903     STRING szTitle, szMsg;
1904 begin
1905     if (SHELL_OBJECT_FOLDER = "") then
1906         SHELL_OBJECT_FOLDER = @FOLDER_NAME;
1907     endif;
1908
1909         // We are going to force the user to use the default folder name.  This is
1910         // because we create the folder unlogged, and must therefore remove it
1911         // ourselves in our uninstall dll (which we do because IS doesn't handle
1912         // removing them correctly).  Therefore, we must know the name of the
1913         // folder so we can remove it during uninstall.  Also, the user can install
1914         // the AFS components during several executions of the install program,
1915         // and we don't want to allow them to pick a different folder each time.
1916         // We could solve these problems in code but we don't have time, so we
1917         // are going to force them to use our default folder name.
1918         return 0;
1919
1920     szTitle    = "";
1921     szMsg      = "";
1922     nResult    = SdSelectFolder( szTitle, szMsg, SHELL_OBJECT_FOLDER);
1923
1924     return nResult;
1925 end;
1926
1927
1928 ///////////////////////////////////////////////////////////////////////////////
1929 //
1930 //  Function: DialogShowSdFinishReboot
1931 //
1932 //  Purpose: This function will show the last dialog of the product.
1933 //           It will allow the user to reboot and/or show some readme text.
1934 //
1935 ///////////////////////////////////////////////////////////////////////////////
1936 function DialogShowSdFinishReboot()
1937     NUMBER nResult, nDefOptions;
1938     STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;
1939     NUMBER bOpt1, bOpt2;
1940 begin
1941     if (!BATCH_INSTALL) then
1942         bOpt1 = FALSE;
1943         bOpt2 = FALSE;
1944         szMsg1 = @SETUP_FINISHED_MSG;
1945         szMsg2 = "";
1946         szOption1 = "";
1947         szOption2 = "";
1948         szTitle = "";
1949         nResult = SdFinish(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2 );
1950         return 0;
1951     endif;
1952
1953     nDefOptions = SYS_BOOTMACHINE;
1954     szTitle     = "";
1955     szMsg1      = "";
1956     szMsg2      = "";
1957     nResult     = SdFinishReboot( szTitle, szMsg1, nDefOptions, szMsg2, 0 );
1958
1959     return nResult;
1960 end;
1961
1962
1963 ///////////////////////////////////////////////////////////////////////////////
1964 //
1965 //  Function: ConfigServerService
1966 //
1967 //  Purpose: This function will configure the AFS Server bos service via the
1968 //                       SCM.
1969 //
1970 ///////////////////////////////////////////////////////////////////////////////
1971 function ConfigServerService()
1972     STRING szMsg;
1973     BOOL bError;
1974     number nStatus;
1975 begin
1976     bError = TRUE;
1977
1978     if (!bWSPPInstall) then
1979         szMsg = @CONFIGURING_AFS_SERVER_SERVICE;
1980         SdShowMsg(szMsg, TRUE);
1981     endif;
1982
1983     nStatus = RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
1984     if (nStatus < 0) goto error;
1985
1986     nStatus = InstallServerService(TARGETDIR ^ "\\Server\\usr\\afs\\bin\\bosctlsvc.exe");
1987     if (nStatus < 0) goto error;
1988
1989     bError = FALSE;
1990
1991 error:
1992     if (!bWSPPInstall) then
1993             SdShowMsg(szMsg, FALSE);
1994         endif;
1995
1996     if (bError) then
1997         Sprintf(szMsg, @AFS_SERVER_SERVICE_INSTALL_ERROR, nStatus);
1998         ShowError(szMsg, SEVERE);
1999         bInstallAborted = TRUE;
2000         return -1;
2001     endif;
2002
2003     return 0;
2004 end;
2005
2006
2007 ///////////////////////////////////////////////////////////////////////////////
2008 //
2009 //  Function: ConfigClientService
2010 //
2011 //  Purpose: This function will configure the AFS Client service via the SCM.
2012 //
2013 ///////////////////////////////////////////////////////////////////////////////
2014 function ConfigClientService()
2015     STRING szMsg;
2016     BOOL bError;
2017     number nStatus;
2018 begin
2019     bError = TRUE;
2020
2021         if (!bWSPPInstall) then
2022         szMsg = @CONFIGURING_AFS_CLIENT_SERVICE;
2023         SdShowMsg(szMsg, TRUE);
2024     endif;
2025
2026     nStatus = RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
2027     if (nStatus < 0) goto error;
2028
2029     nStatus = InstallClientService(TARGETDIR ^ "\\Client\\Program\\afsd_service.exe");
2030     if (nStatus < 0) goto error;
2031
2032     bError = FALSE;
2033
2034 error:
2035     if (!bWSPPInstall) then
2036             SdShowMsg(szMsg, FALSE);
2037         endif;
2038
2039     if (bError) then
2040         Sprintf(szMsg, @AFS_CLIENT_SERVICE_INSTALL_ERROR, nStatus);
2041         ShowError(szMsg, SEVERE);
2042         bInstallAborted = TRUE;
2043         return -1;
2044     endif;
2045
2046     return 0;
2047 end;
2048
2049 ///////////////////////////////////////////////////////////////////////////////
2050 //
2051 //  Function: AddPath
2052 //
2053 //  Purpose: This function will add the specified path to the system PATH
2054 //                       environment variable.
2055 //
2056 ///////////////////////////////////////////////////////////////////////////////
2057 function AddPath(szPath)
2058 begin
2059     LongPathToShortPath(szPath);
2060
2061     if (AddToPath(szPath) < 0) then
2062         ShowError(@ADD_PATH_ERROR, WARNING);
2063     endif;
2064
2065         return 0;
2066 end;
2067
2068
2069 ///////////////////////////////////////////////////////////////////////////////
2070 //
2071 //  Function: ConfigUninstallDLL
2072 //
2073 //  Purpose: This function will modify the uninstall entry for these products
2074 //                       to use an uninstall dll.
2075 //
2076 ///////////////////////////////////////////////////////////////////////////////
2077 function ConfigUninstallDLL(pApp)
2078     string svValue;
2079     NUMBER nStatus;
2080 begin
2081         if (!pApp->bUseUninstDLL) then
2082                 return 0;
2083         endif;
2084
2085     nStatus = RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
2086     if (nStatus < 0) goto error;
2087
2088     svValue = UNINST + " -c\"" + pApp->szBinPath ^ pApp->szUninstDllName + "\" -f\"" + TARGETDIR ^ pApp->szUninstLogfileName + "\"";
2089
2090     nStatus = RegDBSetKeyValueEx(MSUNINSTALL_KEY ^ pApp->szProductName, "UninstallString", REGDB_STRING, svValue, -1);
2091     if (nStatus < 0) goto error;
2092
2093     return 0;
2094
2095 error:
2096     return nStatus;
2097 end;
2098                 
2099
2100 ///////////////////////////////////////////////////////////////////////////////
2101 //
2102 //  Function: CreateServerDirs
2103 //
2104 //  Purpose: This function will create directories that the server programs
2105 //                       need.  The creation of these is not logged, and so they will be
2106 //                       deleted by the uninstall dll.
2107 //
2108 ///////////////////////////////////////////////////////////////////////////////
2109 function CreateServerDirs()
2110 begin
2111         CreateDir(TARGETDIR ^ "\\Server\\usr\\afs\\logs");
2112         CreateDir(TARGETDIR ^ "\\Server\\usr\\afs\\etc");
2113         CreateDir(TARGETDIR ^ "\\Server\\usr\\afs\\local");
2114 end;
2115
2116
2117 ///////////////////////////////////////////////////////////////////////////////
2118 //
2119 //  Function: GetDateTimeString()
2120 //
2121 //  Purpose: This function will return a string containing the current date
2122 //           and time.
2123 //
2124 ///////////////////////////////////////////////////////////////////////////////
2125 function GetDateTimeString(szDateTime)
2126     STRING szDate, szTime;
2127     NUMBER nDate, nTime;
2128 begin
2129         GetSystemInfo(DATE, nDate, szDate);
2130     GetSystemInfo(TIME, nTime, szTime);
2131
2132     szDateTime = szDate + " " + szTime;
2133 end;
2134
2135
2136 ///////////////////////////////////////////////////////////////////////////////
2137 //
2138 //  Function: SetUserVars()
2139 //
2140 //  Purpose: This function will set at runtime values for user defined variables
2141 //                       we set up in the Registry Entries GUI tool.
2142 //
2143 ///////////////////////////////////////////////////////////////////////////////
2144 function SetUserVars()
2145     number nStatus;
2146     string szInstallDate;
2147     string szDesc;
2148     string szTitle;
2149     string szReleaseType;
2150 begin
2151     // Set the install date variable's value
2152     GetDateTimeString(szInstallDate);
2153
2154         ComponentSetTarget(MEDIA, "<INSTALL_DATE>", szInstallDate);
2155
2156         // Set the proper client logon dll
2157         if (bFullClientSel) then
2158                 ComponentSetTarget(MEDIA, "<LOGON_DLL>", TARGETDIR ^ FULL_CLIENT_LOGON_DLL);
2159         elseif (bLightClientSel) then
2160                 ComponentSetTarget(MEDIA, "<LOGON_DLL>", TARGETDIR ^ LIGHT_CLIENT_LOGON_DLL);
2161         endif;
2162
2163         // Set the client description and title values
2164         if (bFullClientSel || bLightClientSel) then
2165
2166                 if (bFullClientSel) then
2167                         szDesc = @CLIENT_DESC;
2168                         szTitle = @CLIENT_TITLE;
2169                 else
2170                         szDesc = @LIGHT_CLIENT_DESC;
2171                         szTitle = @LIGHT_CLIENT_TITLE;
2172                 endif;
2173
2174                 ComponentSetTarget(MEDIA, "<CLIENT_DESC>", szDesc);
2175                 ComponentSetTarget(MEDIA, "<CLIENT_TITLE>", szTitle);
2176         endif;
2177
2178         if (bServerSel) then
2179                 ComponentSetTarget(MEDIA, "<EVENT_MSG_DLL>", TARGETDIR ^ "Common\\afseventmsg_" + szCodePage + ".dll");
2180         endif;
2181
2182         szReleaseType = @PRODUCT_VERSION_RELEASE_TYPE;
2183         ComponentSetTarget(MEDIA, "<RELEASE_TYPE>", szReleaseType);
2184
2185 done:
2186         return nStatus;
2187 end;
2188
2189
2190 ///////////////////////////////////////////////////////////////////////////////
2191 //
2192 //  Function: SetNetworkProviderOrder()
2193 //
2194 //  Purpose: This function will add the AFS Client service name to the
2195 //                       ProviderOrder value of the
2196 //                       HKLM\SYSTEM\CurrentControlSet\ControlNetworkProvider\Order key.
2197 //                       It makes a call to the setup dll to do this.
2198 ///////////////////////////////////////////////////////////////////////////////
2199 function SetNetworkProviderOrder()
2200         int nStatus;
2201 begin
2202         nStatus = AddToNetworkProviderOrder(CLIENT_SERVICE_NAME);
2203         if (nStatus < 0) then
2204                 ShowError(@SET_NETWORK_PROVIDER_ERROR, SEVERE);
2205         endif;
2206
2207         return nStatus;
2208 end;
2209
2210
2211 ///////////////////////////////////////////////////////////////////////////////
2212 //
2213 //  Function: CreateRegistrySets()
2214 //
2215 //  Purpose: This function will create the registry entries for each resgistry
2216 //                       set in the passed in string.  The string must be a comma separated
2217 //                       list of registry sets created using the IS Registry Entries GUI.
2218 //
2219 ///////////////////////////////////////////////////////////////////////////////
2220 function CreateRegistrySets(szRegistrySets)
2221         int nRegSetListID;
2222         int nResult;
2223         string szRegSet;
2224 begin
2225         nRegSetListID = ListCreate(STRINGLIST);
2226         
2227         StrGetTokens(nRegSetListID, szRegistrySets, ",");
2228
2229         nResult = ListGetFirstString(nRegSetListID, szRegSet);
2230         while (nResult != END_OF_LIST)
2231 //              MessageBox(szRegSet, INFORMATION);
2232                 CreateRegistrySet(szRegSet);
2233                 nResult = ListGetNextString(nRegSetListID, szRegSet);
2234         endwhile;
2235         
2236         ListDestroy(nRegSetListID);
2237 end;
2238
2239
2240 ///////////////////////////////////////////////////////////////////////////////
2241 //
2242 //  Function: ConfigAfsCreds()
2243 //
2244 //  Purpose: This function will config the AFS Client Credentials tool.
2245 //
2246 ///////////////////////////////////////////////////////////////////////////////
2247 function ConfigAfsCreds()
2248 int nResult;
2249 begin
2250         nResult = LaunchAppAndWait(TARGETDIR ^ "Client\\Program\\afscreds.exe", "/install", WAIT);
2251         if (nResult < 0) then
2252                 ShowError(@CONFIGURING_AFS_CREDS_ERROR, INFORMATION);
2253         endif;
2254         
2255         return nResult;
2256 end;
2257
2258
2259 ///////////////////////////////////////////////////////////////////////////////
2260 //
2261 //  Function: IsAppInstalled
2262 //
2263 //  Purpose: This function will determine if an app is installed, and if it is,
2264 //           will set its iVer info.
2265 //
2266 ///////////////////////////////////////////////////////////////////////////////
2267 function IsAppInstalled(pApp)
2268 int nResult;
2269 int nSize;
2270 int nType;
2271 string szKey;
2272 string szMajorVersion, szMinorVersion, szPatchLevel, szBetaLevel, szReleaseType, szTitle;
2273 begin
2274     nResult = RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
2275     if (nResult < 0) goto error;
2276
2277         szKey = COMPANY_REG_KEY ^ pApp->szProductName ^ "CurrentVersion";
2278
2279         nResult = RegDBGetKeyValueEx(szKey, "MajorVersion", nType, szMajorVersion, nSize);
2280         if (nResult < 0) goto error;
2281         
2282         nResult = RegDBGetKeyValueEx(szKey, "MinorVersion", nType, szMinorVersion, nSize);
2283         if (nResult < 0) goto error;
2284         
2285         nResult = RegDBGetKeyValueEx(szKey, "PatchLevel", nType, szPatchLevel, nSize);
2286         if (nResult < 0) goto error;
2287
2288         nResult = RegDBGetKeyValueEx(szKey, "BetaLevel", nType, szBetaLevel, nSize);
2289         // It's ok for this to fail.  Pre-3.5 3.32 releases did not use this.
2290
2291         nResult = RegDBGetKeyValueEx(szKey, "VersionString", nType, szTitle, nSize);
2292         if (nResult < 0) goto error;
2293
2294         nResult = RegDBGetKeyValueEx(szKey, "ReleaseType", nType, szReleaseType, nSize);
2295         if (nResult < 0) then
2296                 if ((pApp->szProductName = "AFS Client") && (szTitle = "3.4a")) then
2297                         // This value won't exist for 3.4a clients
2298                         szReleaseType = RELEASE_TYPE_GA;
2299                 else
2300                         // This value won't exist for any 3.5 beta versions
2301                         szReleaseType = RELEASE_TYPE_BETA;
2302                 endif;
2303         endif;
2304
2305         SetupVerInfo(pApp, szMajorVersion, szMinorVersion, szPatchLevel, szBetaLevel, szReleaseType, szTitle, TRUE);
2306         
2307         return TRUE;
2308
2309 error:
2310         return FALSE;
2311 end;
2312         
2313
2314 ///////////////////////////////////////////////////////////////////////////////
2315 //
2316 //  Function: LocalizeComponents()
2317 //
2318 //  Purpose: This function updates all components to use localized text
2319 //           in their status fields as appropriate
2320 //
2321 ///////////////////////////////////////////////////////////////////////////////
2322 function LocalizeComponents()
2323 begin
2324         LocalizeComponentStatusText ("Client\\Client_Common");
2325         LocalizeComponentStatusText ("Client\\Client_Program\\Client_Headers\\Client_Afs_Headers");
2326         LocalizeComponentStatusText ("Client\\Client_Program\\Client_Headers\\Client_Main_Headers");
2327         LocalizeComponentStatusText ("Client\\Client_Program\\Client_Headers\\Client_Rx_Headers");
2328         LocalizeComponentStatusText ("Client\\Client_Program\\Client_Headers");
2329         LocalizeComponentStatusText ("Client\\Client_Program\\Client_Sample");
2330         LocalizeComponentStatusText ("Client\\Client_Program");
2331         LocalizeComponentStatusText ("Client\\Client_System32");
2332         LocalizeComponentStatusText ("Client\\Client_WinDir");
2333         LocalizeComponentStatusText ("Client");
2334         LocalizeComponentStatusText ("Components");
2335         LocalizeComponentStatusText ("Control_Center\\Control_Center_Common");
2336         LocalizeComponentStatusText ("Control_Center\\Control_Center_Program");
2337         LocalizeComponentStatusText ("Control_Center\\Control_Center_System32");
2338         LocalizeComponentStatusText ("Control_Center\\Control_Center_WinDir");
2339         LocalizeComponentStatusText ("Control_Center");
2340         LocalizeComponentStatusText ("Documentation\\English\\Cmd_Ref");
2341         LocalizeComponentStatusText ("Documentation\\English\\Doc_Misc");
2342         LocalizeComponentStatusText ("Documentation\\English\\Sys_Admin_Guide");
2343         LocalizeComponentStatusText ("Documentation\\English");
2344         LocalizeComponentStatusText ("Documentation\\German\\Cmd_Ref");
2345         LocalizeComponentStatusText ("Documentation\\German\\Doc_Misc");
2346         LocalizeComponentStatusText ("Documentation\\German\\Sys_Admin_Guide");
2347         LocalizeComponentStatusText ("Documentation\\German");
2348         LocalizeComponentStatusText ("Documentation\\Japanese\\Cmd_Ref");
2349         LocalizeComponentStatusText ("Documentation\\Japanese\\Doc_Misc");
2350         LocalizeComponentStatusText ("Documentation\\Japanese\\Sys_Admin_Guide");
2351         LocalizeComponentStatusText ("Documentation\\Japanese");
2352         LocalizeComponentStatusText ("Documentation\\Korean\\Cmd_Ref");
2353         LocalizeComponentStatusText ("Documentation\\Korean\\Doc_Misc");
2354         LocalizeComponentStatusText ("Documentation\\Korean\\Sys_Admin_Guide");
2355         LocalizeComponentStatusText ("Documentation\\Korean");
2356         LocalizeComponentStatusText ("Documentation\\Portuguese\\Cmd_Ref");
2357         LocalizeComponentStatusText ("Documentation\\Portuguese\\Doc_Misc");
2358         LocalizeComponentStatusText ("Documentation\\Portuguese\\Sys_Admin_Guide");
2359         LocalizeComponentStatusText ("Documentation\\Portuguese");
2360         LocalizeComponentStatusText ("Documentation\\Simp_Chinese\\Cmd_Ref");
2361         LocalizeComponentStatusText ("Documentation\\Simp_Chinese\\Doc_Misc");
2362         LocalizeComponentStatusText ("Documentation\\Simp_Chinese\\Sys_Admin_Guide");
2363         LocalizeComponentStatusText ("Documentation\\Simp_Chinese");
2364         LocalizeComponentStatusText ("Documentation\\Spanish\\Cmd_Ref");
2365         LocalizeComponentStatusText ("Documentation\\Spanish\\Doc_Misc");
2366         LocalizeComponentStatusText ("Documentation\\Spanish\\Sys_Admin_Guide");
2367         LocalizeComponentStatusText ("Documentation\\Spanish");
2368         LocalizeComponentStatusText ("Documentation\\Trad_Chinese\\Cmd_Ref");
2369         LocalizeComponentStatusText ("Documentation\\Trad_Chinese\\Doc_Misc");
2370         LocalizeComponentStatusText ("Documentation\\Trad_Chinese\\Sys_Admin_Guide");
2371         LocalizeComponentStatusText ("Documentation\\Trad_Chinese");
2372         LocalizeComponentStatusText ("Documentation");
2373         LocalizeComponentStatusText ("Info");
2374         LocalizeComponentStatusText ("Languages\\Lang_English");
2375         LocalizeComponentStatusText ("Languages\\Lang_German");
2376         LocalizeComponentStatusText ("Languages\\Lang_Japanese");
2377         LocalizeComponentStatusText ("Languages\\Lang_Korean");
2378         LocalizeComponentStatusText ("Languages\\Lang_Portuguese");
2379         LocalizeComponentStatusText ("Languages\\Lang_Simp_Chinese");
2380         LocalizeComponentStatusText ("Languages\\Lang_Spanish");
2381         LocalizeComponentStatusText ("Languages\\Lang_Trad_Chinese");
2382         LocalizeComponentStatusText ("Languages");
2383         LocalizeComponentStatusText ("Light_Client\\Win95\\Light95_Client_Common");
2384         LocalizeComponentStatusText ("Light_Client\\Win95\\Light95_Client_Program");
2385         LocalizeComponentStatusText ("Light_Client\\Win95\\Light95_Client_System32");
2386         LocalizeComponentStatusText ("Light_Client\\Win95\\Light95_Client_WinDir");
2387         LocalizeComponentStatusText ("Light_Client\\Win95");
2388         LocalizeComponentStatusText ("Light_Client\\Win98\\Light_Client_Common");
2389         LocalizeComponentStatusText ("Light_Client\\Win98\\Light_Client_Program");
2390         LocalizeComponentStatusText ("Light_Client\\Win98\\Light_Client_System32");
2391         LocalizeComponentStatusText ("Light_Client\\Win98\\Light_Client_WinDir");
2392         LocalizeComponentStatusText ("Light_Client\\Win98");
2393         LocalizeComponentStatusText ("Light_Client");
2394         LocalizeComponentStatusText ("Readme\\English\\Doc_Misc");
2395         LocalizeComponentStatusText ("Readme\\English\\Install_Guide");
2396         LocalizeComponentStatusText ("Readme\\English\\Release_Notes");
2397         LocalizeComponentStatusText ("Readme\\English");
2398         LocalizeComponentStatusText ("Readme\\German\\Doc_Misc");
2399         LocalizeComponentStatusText ("Readme\\German\\Install_Guide");
2400         LocalizeComponentStatusText ("Readme\\German\\Release_Notes");
2401         LocalizeComponentStatusText ("Readme\\German");
2402         LocalizeComponentStatusText ("Readme\\Japanese\\Doc_Misc");
2403         LocalizeComponentStatusText ("Readme\\Japanese\\Install_Guide");
2404         LocalizeComponentStatusText ("Readme\\Japanese\\Release_Notes");
2405         LocalizeComponentStatusText ("Readme\\Japanese");
2406         LocalizeComponentStatusText ("Readme\\Korean\\Doc_Misc");
2407         LocalizeComponentStatusText ("Readme\\Korean\\Install_Guide");
2408         LocalizeComponentStatusText ("Readme\\Korean\\Release_Notes");
2409         LocalizeComponentStatusText ("Readme\\Korean");
2410         LocalizeComponentStatusText ("Readme\\Portuguese\\Doc_Misc");
2411         LocalizeComponentStatusText ("Readme\\Portuguese\\Install_Guide");
2412         LocalizeComponentStatusText ("Readme\\Portuguese\\Release_Notes");
2413         LocalizeComponentStatusText ("Readme\\Portuguese");
2414         LocalizeComponentStatusText ("Readme\\Simp_Chinese\\Doc_Misc");
2415         LocalizeComponentStatusText ("Readme\\Simp_Chinese\\Install_Guide");
2416         LocalizeComponentStatusText ("Readme\\Simp_Chinese\\Release_Notes");
2417         LocalizeComponentStatusText ("Readme\\Simp_Chinese");
2418         LocalizeComponentStatusText ("Readme\\Spanish\\Doc_Misc");
2419         LocalizeComponentStatusText ("Readme\\Spanish\\Install_Guide");
2420         LocalizeComponentStatusText ("Readme\\Spanish\\Release_Notes");
2421         LocalizeComponentStatusText ("Readme\\Spanish");
2422         LocalizeComponentStatusText ("Readme\\Trad_Chinese\\Doc_Misc");
2423         LocalizeComponentStatusText ("Readme\\Trad_Chinese\\Install_Guide");
2424         LocalizeComponentStatusText ("Readme\\Trad_Chinese\\Release_Notes");
2425         LocalizeComponentStatusText ("Readme\\Trad_Chinese");
2426         LocalizeComponentStatusText ("Readme");
2427         LocalizeComponentStatusText ("Server\\Server_Common");
2428         LocalizeComponentStatusText ("Server\\Server_Program");
2429         LocalizeComponentStatusText ("Server\\Server_System32");
2430         LocalizeComponentStatusText ("Server\\Server_WinDir");
2431         LocalizeComponentStatusText ("Server");
2432 end;
2433
2434
2435 ///////////////////////////////////////////////////////////////////////////////
2436 //
2437 //  Function: LocalizeComponentStatusText()
2438 //
2439 //  Purpose: This function updates one component to use localized text
2440 //           in its status fields as appropriate
2441 //
2442 ///////////////////////////////////////////////////////////////////////////////
2443 function LocalizeComponentStatusText (svComponent)
2444         NUMBER dwResult;
2445         STRING svOriginal;
2446         STRING svLocalized;
2447 begin
2448         ComponentGetData (MEDIA, svComponent, COMPONENT_FIELD_STATUS, dwResult, svOriginal);
2449
2450         if (svOriginal == "CLIENT") then
2451                 svLocalized = @STATUS_INSTALLING_CLIENT;
2452         elseif (svOriginal == "SERVER") then
2453                 svLocalized = @STATUS_INSTALLING_SERVER;
2454         elseif (svOriginal == "CCENTER") then
2455                 svLocalized = @STATUS_INSTALLING_CCENTER;
2456         elseif (svOriginal == "LIGHT") then
2457                 svLocalized = @STATUS_INSTALLING_LIGHT;
2458         elseif (svOriginal == "HEADERS") then
2459                 svLocalized = @STATUS_INSTALLING_HEADERS;
2460         elseif (svOriginal == "DOCS") then
2461                 svLocalized = @STATUS_INSTALLING_DOCS;
2462         elseif (svOriginal == "LANGUAGE") then
2463                 svLocalized = @STATUS_INSTALLING_LANGUAGE;
2464         else
2465                 svLocalized = "";
2466         endif;
2467
2468         ComponentSetData(MEDIA, svComponent, COMPONENT_FIELD_STATUS, 0, svLocalized);
2469 end;
2470
2471
2472 ///////////////////////////////////////////////////////////////////////////////
2473 //
2474 //  Function: DetectInstalledComponents()
2475 //
2476 //  Purpose: This function will detect if any of our components is already
2477 //           installed.
2478 //
2479 ///////////////////////////////////////////////////////////////////////////////
2480 function DetectInstalledComponents()
2481 begin
2482         if (bWinNT) then
2483                 bClientInstalled = IsAppInstalled(&appFullClient);
2484                 bServerInstalled = IsAppInstalled(&appServer);
2485                 bCcInstalled = IsAppInstalled(&appControlCenter);
2486                 bDocsInstalled = IsAppInstalled(&appDocs);
2487         else
2488                 // The light client uses the client's registry entries.  There is a light
2489                 // client entry, but it contains nothing under it.  IS makes it but we
2490                 // don't use it.
2491                 bLightClientInstalled = IsAppInstalled(&appLightClient);
2492         endif;
2493 end;
2494
2495
2496 ///////////////////////////////////////////////////////////////////////////////
2497 //
2498 // Function: ParseCommandLine
2499 //
2500 //  Purpose: This function parses the command line to set up a silent install
2501 //
2502 ///////////////////////////////////////////////////////////////////////////////
2503 function ParseCommandLine()
2504     NUMBER nResult;
2505     STRING szTemp, szResult[MAX_STRING_LEN], szParms;
2506     LIST listParms;
2507 begin
2508     bWSPPInstall = FALSE;
2509         bPreinstallReplace = FALSE;
2510
2511     szParms = CMDLINE;
2512
2513     // Need a list to hold the parms
2514     listParms = ListCreate(STRINGLIST);
2515
2516     // Break parms into semicolon separated tokens and put into list
2517     if (StrGetTokens(listParms, szParms, ";") = 0 ) then
2518        nResult = ListGetFirstString(listParms, szResult);
2519
2520         //  Do until the end of the list
2521         while (nResult != END_OF_LIST)
2522                         if (StrFind(szResult, "DIR=") > -1 ) then
2523                 nResult = StrSub(szTemp, szResult, 4, MAX_STRING_LEN);
2524                 TARGETDIR = szTemp + "\\AFS";
2525                 
2526                 elseif (StrFind(szResult, "P=") > -1 ) then
2527                 nResult = StrSub(szTemp, szResult, StrFind(szResult, "P=") + 2, 1);
2528                 if (StrFind(szTemp, "Y") > -1 ) then
2529                         bPreinstallReplace = TRUE;
2530                 endif;
2531
2532                 elseif (StrFind(szResult, "C=") > -1 ) then
2533                         ProcessCompsOnCmdLn(szResult);
2534                 endif;
2535
2536                         nResult = ListGetNextString(listParms, szResult);
2537                 endwhile;
2538         endif;
2539 end;
2540
2541
2542 ///////////////////////////////////////////////////////////////////////////////
2543 //
2544 // Function: ProcessCompsOnCmdLn
2545 //
2546 //  Purpose: This function puts the components in a list and
2547 //           checks for setup types on the command line.
2548 //
2549 //
2550 ///////////////////////////////////////////////////////////////////////////////
2551 function ProcessCompsOnCmdLn(szParms)
2552      NUMBER nResult, nIndex;
2553      STRING szComp;
2554 begin
2555     bWSPPInstall = TRUE;
2556
2557         // Strip c= off cmdln string
2558         nResult = StrSub(szParms, szParms, StrFind(szParms, "C=") + 2, StrLength(szParms) - 2);
2559
2560         // Get each component from the cmd line
2561     while (StrLength(szParms))
2562         nIndex = StrSub(szComp, szParms, 0, StrFind(szParms, ","));
2563         if (!nIndex) then  // if comma not found then last item in list
2564                 szComp = szParms;
2565                 nIndex = StrLength(szComp); // for extracting this string
2566                 endif;
2567
2568         if (StrFind(szComp, "Client") > -1) then
2569                 bFullClientSel = TRUE;
2570         elseif (StrFind(szComp, "Server") > -1) then
2571                 bServerSel = TRUE;
2572         elseif (StrFind(szComp, "ControlCtr") > -1) then
2573                 bCcSel = TRUE;
2574         endif;
2575
2576        // Delete component from the command line string
2577         StrSub(szParms, szParms, nIndex + 1, StrLength(szParms));
2578      endwhile;
2579 end;
2580
2581
2582 ///////////////////////////////////////////////////////////////////////////////
2583 //
2584 // Function: RemoveInstalledBits
2585 //
2586 //  Purpose: This function silently uninstalls a product.
2587 //
2588 ///////////////////////////////////////////////////////////////////////////////
2589 function RemoveInstalledBits(szProductName)
2590         int nStatus;
2591         int nType;
2592         string szValue[MAX_STRING_LEN];
2593         string szProgram[256];
2594         string szCmdLine[128];
2595         int nSize;
2596         int nIndex;
2597 begin
2598         // Check for a special case - version 3.4a of the AFS Client
2599         if ((szProductName = "AFS Client") && (appFullClient.iVer.szTitle = "3.4a")) then
2600                 return Eradicate34Client();
2601         endif;
2602
2603     nStatus = RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
2604     if (nStatus < 0) goto error;
2605
2606         nStatus = RegDBGetKeyValueEx(MSUNINSTALL_KEY ^ szProductName, "UninstallString", nType, szValue, nSize);
2607     if (nStatus < 0) goto error;
2608
2609         nIndex = StrFind(szValue, " ");
2610         if (nIndex < 0) goto error;
2611         
2612         StrSub(szProgram, szValue, 0, nIndex);
2613         StrSub(szCmdLine, szValue, nIndex + 1, 128);
2614
2615         // Make the uninstall run silently
2616         szCmdLine = szCmdLine + " -a";
2617
2618         nStatus = LaunchAppAndWait(szProgram, szCmdLine, WAIT);
2619         if (nStatus < 0) goto error;
2620
2621         return 0;
2622
2623 error:
2624         return nStatus;
2625 end;
2626
2627
2628 ///////////////////////////////////////////////////////////////////////////////
2629 //
2630 // Function: AddShortCut
2631 //
2632 //  Purpose: Adds a short cut to the start menu.
2633 //
2634 ///////////////////////////////////////////////////////////////////////////////
2635 function AddShortCut(szFolder, szName, szCmdPath, szArgs)
2636         int result;
2637         string szCmd;
2638 begin
2639         szCmdPath = TARGETDIR ^ szCmdPath;
2640         LongPathToQuote(szCmdPath, TRUE);
2641         
2642         szCmd = szCmdPath + " " + szArgs;
2643         
2644         nResult = AddFolderIcon(SHELL_OBJECT_FOLDER ^ szFolder, szName, szCmd, "", "", 0, "", REPLACE);
2645         
2646         return nResult;
2647 end;
2648
2649
2650 ///////////////////////////////////////////////////////////////////////////////
2651 //
2652 // Function: CreateStartMenuEntries
2653 //
2654 //  Purpose: This function creates start menu entries for our apps.
2655 //
2656 ///////////////////////////////////////////////////////////////////////////////
2657 function CreateStartMenuEntries()
2658 begin
2659         if (bServerSel) then
2660                 AddShortCut(@SERVER_GROUP_NAME, @CFG_WIZARD_ITEM_NAME, CFG_WIZARD_CMD_PATH, CFG_WIZARD_ARGS);
2661         endif;
2662         
2663         if (bFullClientSel) then
2664                 AddShortCut(@CLIENT_GROUP_NAME, @CREDS_TOOL_ITEM_NAME, CREDS_TOOL_CMD_PATH, CREDS_TOOL_ARGS);
2665                 AddShortCut(@CLIENT_GROUP_NAME, @CLIENT_HELP_ITEM_NAME, CLIENT_HELP_CMD_PATH, CLIENT_HELP_ARGS);
2666         endif;
2667         
2668         if (bCcSel) then
2669                 AddShortCut(@CCENTER_GROUP_NAME, @SERVER_MANAGER_ITEM_NAME, SERVER_MANAGER_CMD_PATH, SERVER_MANAGER_ARGS);
2670                 AddShortCut(@CCENTER_GROUP_NAME, @ACCT_MANAGER_ITEM_NAME, ACCT_MANAGER_CMD_PATH, ACCT_MANAGER_ARGS);
2671         endif;
2672         
2673         if (bLightClientSel) then
2674                 AddShortCut(@LIGHT_GROUP_NAME, @CREDS_TOOL_ITEM_NAME, CREDS_TOOL_CMD_PATH, CREDS_TOOL_ARGS);
2675                 AddShortCut(@LIGHT_GROUP_NAME, @LIGHT_CLIENT_HELP_ITEM_NAME, LIGHT_CLIENT_HELP_CMD_PATH, LIGHT_CLIENT_HELP_ARGS);
2676         endif;
2677
2678         AddShortCut("", @DOCUMENTATION_ITEM_NAME, DOCUMENTATION_CMD_PATH, DOCUMENTATION_ARGS);
2679 end;
2680
2681
2682 ///////////////////////////////////////////////////////////////////////////////
2683 //
2684 // Function: ShowError
2685 //
2686 //  Purpose: This function shows an error to the user when not in silent mode,
2687 //           and will log an error to a file when in silent mode.
2688 //
2689 ///////////////////////////////////////////////////////////////////////////////
2690 function ShowError(szMsg, nType)
2691     string szType;
2692     int nFileID;
2693 begin
2694     if (!bWSPPInstall) then
2695         MessageBox(szMsg, nType);
2696         return;
2697     endif;
2698
2699     switch (nType)
2700         case WARNING:       szType = "Warning: ";
2701         case SEVERE:        szType = "Error: ";
2702         case INFORMATION:   szType = "Note: ";
2703         default:            szType = "Unknown error type: ";
2704     endswitch;
2705
2706     WriteToInstallErrorLog(szType + szMsg);
2707 end;
2708
2709
2710 ///////////////////////////////////////////////////////////////////////////////
2711 //
2712 // Function: CheckCopyCellServDB
2713 //
2714 //  Purpose: During install the CellServDB file is copied into the Common dir.
2715 //                       If the user does not already have this file, we will copy it for
2716 //           them into the windows directory.  If they already do have the
2717 //           file, then we will do nothing.
2718 ///////////////////////////////////////////////////////////////////////////////
2719 function CheckCopyCellServDB()
2720         int nResult;
2721         string szResult;
2722 begin
2723         nResult = FindFile(WINDIR, CELLSERVDB_FILENAME, szResult);
2724         if (nResult < 0) then
2725                 VarSave(SRCTARGETDIR);
2726                 SRCDIR = TARGETDIR ^ "Common";
2727                 TARGETDIR = WINDIR;
2728                 CopyFile(CELLSERVDB_FILENAME, CELLSERVDB_FILENAME);
2729                 VarRestore(SRCTARGETDIR);
2730         endif;
2731 end;
2732
2733
2734 // --- include script file section ---
2735 #include "sddialog.rul"
2736
2737
2738