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