windows-updates-including-dont-lose-tokens-20011110
[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,szCellName;
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         DeleteFile("afsdsbmt.ini");
775         VarRestore(SRCTARGETDIR);
776     CreateFile(handle, szPath, "afsdsbmt.ini");
777     WriteLine(handle, "[AFS Submounts]");
778         if (StrLength(szRootDrive)==2) then
779                 WriteLine(handle, "all="+szRootPath);
780         endif;
781     if (StrLength(szHomeDrive)==2) then
782                 WriteLine(handle, "home=" + szHomePath);
783         endif;
784         WriteLine(handle, "[AFS Mappings]");
785         if (StrLength(szRootDrive)>0) then
786                 WriteLine(handle, szRootDrive+"="+szRootPath);
787     endif;
788         if (StrLength(szHomeDrive)>0) then
789                 WriteLine(handle, szHomeDrive+"="+szHomePath);
790     endif;
791         CloseFile(handle);
792 end;
793
794 // Return TRUE if silent mode active
795 prototype BOOL SilentSetHomeRoot(STRING,NUMBER,NUMBER,BYREF STRING,BYREF STRING,BYREF STRING,BYREF STRING);
796 function SilentSetHomeRoot(szDlg,option,nResult,szRootDrive,szRootPath,szHomeDrive,szHomePath)
797 STRING svSection,szTemp,szTPath,szTShare,szTDrive,szLogname;
798 NUMBER nTemp,nCount,I;
799 HWND   handle;
800 begin
801         Logitn("SilentSetHomeRoot option=%i",option);
802         switch (option)
803         case 0:         //READ function
804                 if (MODE!=SILENTMODE) then
805                         return FALSE;
806                 endif;                  // this section is a little more complicated, allowing installation of n mappings
807                 SdMakeName( svSection, szDlg, "", nvSection );
808                 Logit("SdMakeName="+svSection);
809         SilentReadData( svSection, "Result", DATA_NUMBER,szTemp,nResult);
810         Logitn("nResult=%i",nResult);
811         if (nResult!=NEXT) then
812                 return TRUE;
813         endif;
814         Logit("Do count");
815         SilentReadData( svSection, "Count", DATA_NUMBER, szTemp,nCount);
816         Logitn("nCount=%i",nCount);
817         if nCount==0 then
818                 return TRUE;
819         endif;
820                 VarSave(SRCTARGETDIR);
821                 TARGETDIR=WINDIR;
822                 DeleteFile("afsdsbmt.ini");
823                 VarRestore(SRCTARGETDIR);
824             CreateFile(handle, WINDIR, "afsdsbmt.ini");
825         WriteLine(handle, "[AFS Submounts]");
826         for I=0 to nCount-1
827                 Logitn("I=%i",I);               
828                 Sprintf(szTemp,"Path_%i",I);
829                 Logit("Path="+szTemp);                  
830                 SilentReadData( svSection, szTemp, DATA_STRING, szTPath,nTemp);
831                 Logit("TPath="+szTPath);                
832                 if (szTPath % "%LOGINNAME%") then
833                         //Replace loginname with actual loging name
834                                 nTemp=StrFind(szTPath,"%LOGINNAME%");
835                                 StrSub(szTemp,szTPath,nTemp+11,StrLength(szTPath));
836                                 StrSub(szTPath,szTPath,0,nTemp);
837                             if (GetUser(szLogname)) then
838                                         szTPath=szTPath+szLogname+szTemp;
839                                 endif;
840                 endif;
841                 Sprintf(szTemp,"Share_%i",I);
842                 SilentReadData( svSection, szTemp, DATA_STRING, szTShare,nTemp);
843                         WriteLine(handle, szTShare+"="+szTPath);
844         endfor;
845                 WriteLine(handle, "[AFS Mappings]");
846         for I=0 to nCount-1
847                 Sprintf(szTemp,"Drive_%i",I);
848                 SilentReadData( svSection, szTemp, DATA_STRING, szTDrive,nTemp);
849                 Sprintf(szTemp,"Path_%i",I);
850                 SilentReadData( svSection, szTemp, DATA_STRING, szTPath,nTemp);
851                 if (szTPath % "%LOGINNAME%") then
852                         //Replace loginname with actual loging name
853                                 nTemp=StrFind(szTPath,"%LOGINNAME%");
854                                 StrSub(szTemp,szTPath,nTemp+11,StrLength(szTPath));
855                                 StrSub(szTPath,szTPath,0,nTemp);
856                             if (GetUser(szLogname)) then
857                                         szTPath=szTPath+szLogname+szTemp;
858                                 endif;
859                 endif;
860                         WriteLine(handle, szTDrive+"="+szTPath);
861         endfor;
862             CloseFile(handle);
863                 nResult=NEXT;
864                 return TRUE;
865         default:        //write
866                 SdMakeName( svSection, szDlg, "", nvSection );
867                 nCount=0;
868         SilentWriteData( svSection, "Result", DATA_NUMBER,szTemp, nResult );
869         if (StrLength(szRootDrive)==2) then
870                 Sprintf(szTemp,"Drive_%i",nCount);
871                 SilentWriteData( svSection,szTemp, DATA_STRING,szRootDrive, nTemp );//root drive
872                 Sprintf(szTemp,"Path_%i",nCount);
873                 SilentWriteData( svSection,szTemp, DATA_STRING,szRootPath, nTemp );//root drive
874                 Sprintf(szTemp,"Share_%i",nCount);
875                 SilentWriteData( svSection,szTemp, DATA_STRING,"all", nTemp );//root drive
876                 nCount++;
877             endif;
878         if (StrLength(szHomeDrive)==2) then
879                 Sprintf(szTemp,"Drive_%i",nCount);
880                 SilentWriteData( svSection,szTemp, DATA_STRING,szHomeDrive, nTemp );//root drive
881                 Sprintf(szTemp,"Path_%i",nCount);
882                 SilentWriteData( svSection,szTemp, DATA_STRING,szHomePath, nTemp );//root drive
883                 Sprintf(szTemp,"Share_%i",nCount);
884                 SilentWriteData( svSection,szTemp, DATA_STRING,"home", nTemp );//root drive
885                 nCount++;
886         endif;
887         SilentWriteData( svSection, "Count", DATA_NUMBER,szTemp, nCount );      // only two can be defined through Dialog box
888                 SetDriveMaps(WINDIR,szRootDrive,szRootPath,szHomeDrive,szHomePath);
889                 return TRUE;            
890     endswitch;
891 end;
892
893 function SetHomeRoot( szTitle,szRootDrive,szRootPath,szHomeDrive,szHomePath )
894
895 STRING  szDlg, szTemp,svSection;
896 NUMBER  bDone, nId, nMessage, nTemp,AvailableDrives,nResult;
897 INT     hwndDlg,hwndItem,hwndItem2;
898
899 begin
900        szDlg = "DLG_DRIVEPATH";
901
902         // record data produced by this dialog
903                 Logit("SetHomeRoot");
904                 if SilentSetHomeRoot(szDlg,0,nResult,szRootDrive,szRootPath,szHomeDrive,szHomePath ) then
905                         return nResult;
906                 endif;
907
908                 GetDefaultDrive(AvailableDrives);
909          // ensure general initialization is complete
910         if (!bSdInit) then
911            SdInit();
912         endif;
913
914         if (EzDefineDialog( szDlg, "", "",
915                             DLG_DRIVEPATH ) = DLG_ERR) then
916            return -1;
917         endif;
918
919         // Loop in dialog until the user selects a standard button
920         bDone = FALSE;
921
922         while (!bDone)
923
924            nId = WaitOnDialog( szDlg );
925
926            switch(nId)
927
928            case DLG_INIT:
929                 hwndDlg = CmdGetHwndDlg( szDlg );
930                 // Initialize List Control
931                         nResult=CtrlSetList( szDlg, IDC_HOMEDRIVELIST, AvailableDrives );
932                     if (nResult != 0) then
933                        // Handle error from CtrlSetList.
934                        MessageBox ("Unable to create folder name list.", SEVERE);
935                        bDone = TRUE;
936                     endif;
937                                 if (CtrlSetCurSel(szDlg,IDC_HOMEDRIVELIST,szHomeDrive)!=0) then
938                                         szHomeDrive="None:";
939                                         CtrlSetCurSel(szDlg,IDC_HOMEDRIVELIST,szHomeDrive);
940                                 endif;
941
942                         nResult=CtrlSetList( szDlg, IDC_ROOTDRIVELIST, AvailableDrives );
943                     if (nResult != 0) then
944                        // Handle error from CtrlSetList.
945                        MessageBox ("Unable to create folder name list.", SEVERE);
946                        bDone = TRUE;
947                     endif;
948                                 if (CtrlSetCurSel(szDlg,IDC_ROOTDRIVELIST,szRootDrive)!=0) then
949                                         szRootDrive="None:";
950                                         CtrlSetCurSel(szDlg,IDC_ROOTDRIVELIST,szRootDrive);
951                                 endif;
952
953                         nResult=CtrlSetText( szDlg, IDC_ROOTPATH,szRootPath );
954                     if (nResult != 0) then
955                        MessageBox ("Unable to create szRootPath.", SEVERE);
956                        bDone = TRUE;
957                     endif;
958                         nResult=CtrlSetText( szDlg, IDC_HOMEPATH,szHomePath );
959                     if (nResult != 0) then
960                        MessageBox ("Unable to create szHomePath.", SEVERE);
961                        bDone = TRUE;
962                     endif;
963
964                 CtrlSetState (szDlg, IDC_ENABLEHOME,BUTTON_CHECKED);
965                 CtrlSetState (szDlg, IDC_ENABLEROOT,BUTTON_CHECKED);
966                 SdGeneralInit( szDlg, hwndDlg, STYLE_NORMAL, szSdProduct );
967                         
968                 //This function sets the caption for old style dialogs or
969                 //sets the text in the top banner area of win2k style dialogs
970            case OK:
971                         if (szRootDrive!=szHomeDrive) then
972                         nId    = NEXT;
973                         bDone  = TRUE;
974                     else
975                         MessageBox("Home and Root drives cannot be the same",WARNING);
976                 endif;
977
978            case BACK:
979                 nId    = BACK;
980                 bDone  = TRUE;
981
982            case DLG_ERR:
983                 SdError( -1, "DLG_DRIVEPATH" );
984                 nId    = -1;
985                 bDone  = TRUE;
986
987            case DLG_CLOSE:
988                 SdCloseDlg( hwndDlg, nId, bDone );
989
990                    case IDC_ENABLEROOT:
991                         
992                                 hwndItem = GetDlgItem( hwndDlg, IDC_ROOTDRIVELIST );//get handle of control in custom dialog box
993                                 hwndItem2 = GetDlgItem( hwndDlg, IDC_ROOTPATH );//get handle of control in custom dialog box
994                                 if (CtrlGetState (szDlg, nId)==BUTTON_CHECKED) then
995                                         EnableWindow( hwndItem2, TRUE);
996                                         EnableWindow( hwndItem, TRUE);
997                                 else
998                                         EnableWindow( hwndItem2, FALSE);
999                                         EnableWindow( hwndItem, FALSE);
1000                                 endif;
1001                    case IDC_ENABLEHOME:
1002                                 hwndItem = GetDlgItem( hwndDlg, IDC_HOMEDRIVELIST );//get handle of control in custom dialog box
1003                                 hwndItem2 = GetDlgItem( hwndDlg, IDC_HOMEPATH );//get handle of control in custom dialog box
1004                                 if (CtrlGetState (szDlg, nId)==BUTTON_CHECKED) then
1005                                         EnableWindow( hwndItem2, TRUE);
1006                                         EnableWindow( hwndItem, TRUE);
1007                                 else
1008                                         EnableWindow( hwndItem2, FALSE);
1009                                         EnableWindow( hwndItem, FALSE);
1010                                 endif;
1011
1012            case IDC_HOMEDRIVELIST:
1013                                 ;
1014            case IDC_ROOTDRIVELIST:
1015                                 ;
1016            case IDC_HOMEPATH:
1017                         CtrlGetText (szDlg, nId,szHomePath);
1018
1019            case IDC_ROOTPATH:
1020                         CtrlGetText (szDlg, nId,szRootPath);
1021
1022            default:
1023                 // check standard handling
1024                  if (SdIsStdButton( nId ) && SdDoStdButton( nId )) then
1025                     bDone = TRUE;
1026                 endif;
1027            endswitch;
1028
1029         endwhile;
1030
1031                 CtrlGetCurSel (szDlg, nId, szRootDrive);
1032                 if (CtrlGetState (szDlg, IDC_ENABLEROOT)==BUTTON_UNCHECKED) then
1033                 szRootDrive="None:";
1034                 endif;
1035                 CtrlGetCurSel (szDlg, nId, szHomeDrive);
1036                 if (CtrlGetState (szDlg, IDC_ENABLEHOME)==BUTTON_UNCHECKED) then
1037                 szHomeDrive="None:";
1038                 endif;
1039         EndDialog( szDlg );
1040         ReleaseDialog( szDlg );
1041
1042         SdUnInit( );
1043
1044         // record data produced by this dialog
1045         if (nId==NEXT) then
1046                         SilentSetHomeRoot(szDlg,1,nId,szRootDrive,szRootPath,szHomeDrive,szHomePath );
1047                 endif;
1048         ListDestroy (AvailableDrives);
1049         return nId;
1050
1051 end;
1052
1053
1054 // ---- script function prototypes -----
1055
1056
1057     // your script function prototypes
1058
1059
1060
1061 ///////////////////////////////////////////////////////////////////////////////
1062 //
1063 //   MAIN PROGRAM
1064 //
1065 //      The setup begins here by hiding the visible setup
1066 //      window.  This is done to allow all the titles, images, etc. to
1067 //      be established before showing the main window.  The setup is
1068 //      then performed in a series of calls to script defined functions,
1069 //      with error checking at each step.
1070 //
1071 ///////////////////////////////////////////////////////////////////////////////
1072 program
1073         Logit("Begin");
1074         nvSection=0;
1075     Disable( BACKGROUND );
1076         if (UseDLL(SUPPORTDIR ^ SETUP_UTILS_DLL_PATH) < 0) then
1077         ShowError(@SETUPUTILS_NOT_FOUND, SEVERE);
1078         bInstallAborted = TRUE;
1079         goto end_install;
1080     endif;
1081         Logit("UseDLL1");
1082         ChangeDirectory (SUPPORTDIR);
1083         if (UseDLL("GetWebDLL.dll") != 0) then
1084                 MessageBox ("DLL failed.\n\nCouldn't load"+SUPPORTDIR^"GetWebDLL.dll", INFORMATION);
1085                 abort;
1086         endif;
1087         Logit("UseDLL2");
1088                 
1089         SetupInstall();
1090         Logit("SetupInstall");
1091         
1092     CheckRequirements();
1093         Logit("CheckRequirements");
1094         
1095         ParseCommandLine();
1096         Logit("ParseCommandLine");
1097                 
1098         SetupAppInfo();
1099         Logit("SetupAppInfo");
1100         
1101         LocalizeComponents();
1102         Logit("LocalizeComponents");
1103         
1104         DetectInstalledComponents();
1105         Logit("DetectInstalledComponents");
1106         
1107         // Can't upgrade, downgrade, or reinstall the light client, so if it is
1108         // already installed, we must abort.  This is because on Win9x, we can't
1109         // move in-use files, and so we can't silently uninstall the light client,
1110         // which upgrade, downgrade, and reinstall require.
1111         if (bLightClientInstalled && !bWinNT) then
1112                 ShowError(@LIGHT_CLIENT_ALREADY_INSTALLED_MSG, SEVERE);
1113                 bInstallAborted = TRUE;
1114                 goto end_install;
1115         endif;
1116
1117         if (AnyNonUpgradableSoftwareInstalled()) then
1118                 ShowError(@NON_UPGRADABLE_SOFTWARE_INSTALLED_ERROR_MSG, SEVERE);
1119                 bInstallAborted = TRUE;
1120                 goto end_install;
1121         endif;
1122
1123         GetInstallActions();
1124
1125         if (bWSPPInstall) then
1126                 SetSilentMode();        // Tells the InstallUtils dll to run silently
1127                 PrepareForWSPPInstall();
1128         else
1129                 // Ask user what to install
1130                 SetupScreen();
1131         if (ShowDialogs()<0) goto end_install;
1132     endif;
1133
1134         // The AFS path must not contain spaces.  AFS code will break if it does.
1135         LongPathToShortPath(TARGETDIR);
1136
1137         // Determine which comps to install to get the proper NLS files.
1138     GetNlsComps(szLangComp, szReadmeComp, szDocsComp, szCodePage);
1139
1140         SetUserVars();
1141
1142         CreateDirs();
1143
1144         // Uninstall current versions before we install
1145         RemoveAllCurrentVersions();
1146
1147         // Install the Client
1148         if (bFullClientSel) then
1149                 RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
1150                 Enable(LOGGING);
1151                 if RegDBSetKeyValueEx ("SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters" 
1152                         ,"SmbDeviceEnabled", REGDB_NUMBER, "0", 8) < 0 then
1153                         MessageBox ("RegDBCreateKeyEx failed.", SEVERE);
1154                     abort;
1155                 endif;
1156                 pApp = &appFullClient;
1157                 if (InstallApp(pApp) < 0) goto end_install;
1158         endif;
1159         if RegDBSetKeyValueEx("SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters","Cell", REGDB_STRING, szCellName, -1) < 0 then
1160              MessageBox ("RegDBCreateKeyEx failed.", SEVERE);
1161              abort;
1162         endif;
1163         // Install the Light Client
1164         if (bLightClientSel) then
1165                 pApp = &appLightClient;
1166                 if (InstallApp(pApp) < 0) goto end_install;
1167                 if (bWin95) then
1168                         EzBatchAddString(LIGHT95_CLIENT_PROTSEQ, "", AFTER | REPLACE);
1169                 endif;
1170         endif;
1171
1172         // Install the Server
1173         if (bServerSel) then
1174                 pApp = &appServer;
1175                 if (InstallApp(pApp) < 0) goto end_install;
1176                 CreateServerDirs();
1177         endif;
1178
1179         // Install the Control Center
1180         if (bCcSel) then
1181                 pApp = &appControlCenter;
1182                 if (InstallApp(pApp) < 0) goto end_install;
1183         endif;
1184
1185         // Install the Docs
1186         if (bDocsSel) then
1187                 appDocs.szCompName = szDocsComp;
1188                 pApp = &appDocs;
1189                 if (InstallApp(pApp) < 0) goto end_install;
1190         endif;
1191
1192         // If we installed the server, then configure the bos service
1193         if (bServerSel) then
1194                 if (ConfigServerService() < 0) goto end_install;
1195         endif;
1196
1197         // If we installed the full client, then configure the client service
1198         // and add the NetworkProviderOrder value.
1199         if (bFullClientSel) then
1200                 if (ConfigClientService() < 0) goto end_install;
1201         // I'm commenting out the line below.  This will result in integrated
1202         // login being off after an install.  If you want it to be on after an
1203         // install, then uncomment the line.
1204                 // if (SetNetworkProviderOrder() < 0) goto end_install;
1205         endif;
1206
1207         if (bFullClientSel || bLightClientSel) then
1208                 ConfigAfsCreds();
1209         endif;
1210
1211         RestorePreviousConfigs();
1212
1213         AddPath(szCommonBinPath);
1214
1215     // If not only installing docs, then set BATCH_INSTALL to true,
1216     // which will cause setup to want to reboot the computer.
1217         if (OnlyInstallingDocs() == FALSE) then
1218                 BATCH_INSTALL = TRUE;
1219         endif;
1220
1221         CreateStartMenuEntries();
1222
1223 //      if (bFullClientSel || bLightClientSel || bCcSel) then
1224 //              CheckCopyCellServDB();
1225 //      endif;
1226
1227         end_install:
1228
1229         UnUseDLL(SUPPORTDIR^"GetWebDLL.dll");
1230         UnUseDLL(SUPPORTDIR ^ SETUP_UTILS_DLL_PATH);
1231
1232     CleanUpInstall();
1233
1234     // If an unrecoverable error occurred, clean up
1235     // the partial installation. Otherwise, exit normally.
1236     if (bInstallAborted) then
1237         abort;
1238     endif;
1239
1240 endprogram
1241
1242 ///////////////////////////////////////////////////////////////////////////////
1243 //
1244 // Function:  ShowDialogs
1245 //
1246 //  Purpose:  This function manages the display and navigation of
1247 //            the standard dialogs that exist in a setup.
1248 //
1249 ///////////////////////////////////////////////////////////////////////////////
1250 function ShowDialogs()
1251     NUMBER  nResult,handle;
1252     STRING      szTargetLicense;
1253     STRING      szSourceLicense;
1254         STRING sRootDrive,sHomeDrive,userID,rootPath,homePath;
1255         NUMBER  DefaultItem;
1256         STRING  szDefaultWeb,szDefaultBrowse,szDefaultInstall,szPreviousInstall;
1257         STRING  szResult[256],svResult;
1258 begin
1259     Dlg_Start:
1260     // beginning of dialogs label
1261     Dlg_SdWelcome:
1262     nResult = DialogShowSdWelcome();
1263     if (nResult = BACK) goto Dlg_Start;
1264
1265     Dlg_License:
1266 //    szTargetLicense = DOCUMENTATION_LICENSE_PATH;
1267 //    GetLicenseFilename (szSourceLicense);
1268 //      Logit("ShowLicense");
1269 //      Disable( DIALOGCACHE );
1270 //      if (MODE!=SILENTMODE) then
1271 //          nResult = ShowLicense(szTargetLicense,szSourceLicense);
1272 //          if (nResult = 0) then
1273 //              abort;
1274 //          endif;
1275 //          Enable( DIALOGCACHE );
1276 //      endif;
1277     if (nResult = BACK) goto Dlg_Start;
1278         Dlg_SdCompDlg:
1279         nResult = DialogShowSdAskComponentDialog();
1280         Logit("DialogShowSdAskComponentDialog");
1281         if (nResult = BACK) goto Dlg_License;
1282
1283     Dlg_SdSelectFolder:
1284     nResult = DialogShowSdSelectFolder();
1285         Logit("DialogShowSdSelectFolder");
1286         if (nResult = BACK) goto Dlg_SdCompDlg;
1287         if (bFullClientSel || bLightClientSel) then
1288                 szDefaultWeb=@CELLSERVDB_WEB;
1289                 szDefaultBrowse=TARGETDIR^"*";
1290                 szDefaultInstall=@CELLSERVDB_INSTALL;
1291                 szPreviousInstall=WINDIR^@CELLSERVDB_CONFIGNAME;
1292             if (Is(FILE_EXISTS,szPreviousInstall)) then
1293                         DefaultItem=IDC_CHECK_PREVIOUSFILE;
1294                 else
1295                         DefaultItem=IDC_CHECK_INSTALL;
1296                 endif;
1297                 Dlg_SdSelectCellServDB:
1298                         Logit("SetCellServDB-next");
1299                         nResult =SetCellServDB("Select AFS Cell Data base (afsdcell.ini)"
1300                         ,DefaultItem
1301                         ,szPreviousInstall
1302                         ,szDefaultWeb
1303                         ,szDefaultBrowse
1304                         ,szDefaultInstall);
1305                 Logit("SetCellServDB");
1306             if (nResult=BACK) goto Dlg_SdSelectFolder;
1307             Dlg_SdSelectCellName:
1308             nResult=SdShowDlgEdit1 ("Select AFS Cell Name","A valid cell name should be entered here.\nIf you don't know your cell name, you may enter one after installation using the AFS Control Center.","Enter Cell Name:", szCellName);
1309             if (nResult = BACK) goto Dlg_SdSelectCellName;
1310                 if (Is(FILE_EXISTS, WINDIR^"afsdsbmt.ini")) then
1311                         Logit("AskYesNo next");
1312                         if (AskYesNo("Previous Drive Mapping Configuration already exist.\n\nPress Yes to keep previous configuration\nPress No to change previous configuration.",YES)=YES) then
1313                                 return 0;
1314                         endif;
1315                 endif;
1316                 userID="                   ";
1317             GetUser(userID);
1318                 sRootDrive="Z:";
1319                 sHomeDrive="U:";
1320                 rootPath="/";
1321             homePath = "/afs/" + szCellName + "/u/" + userID;
1322             nResult=SetHomeRoot( "Home and Root Drive Assignment\nThese drives will be mapped each time AFS is connected!",sRootDrive,rootPath,sHomeDrive,homePath );
1323                 Logit("SetHomeRoot");
1324                 if (nResult = BACK) goto Dlg_SdSelectCellServDB;
1325         endif;
1326         Logit("ShowDialogs-done");
1327         return 0;
1328 end;
1329
1330
1331 ///////////////////////////////////////////////////////////////////////////////
1332 //
1333 //  Function: NotUpgradable
1334 //
1335 //  Purpose: This function will return TRUE if the passed in version is not
1336 //           upgradable.
1337 //
1338 ///////////////////////////////////////////////////////////////////////////////
1339 function NotUpgradable(pApp)
1340 begin
1341         // The 3.5 beta is not upgradable
1342 //      if ((pApp->iVer.nMajorVersion = 3) && (pApp->iVer.nMinorVersion = 5) && (pApp->iVer.nPatchLevel = 0) && (pApp->iVer.szReleaseType = RELEASE_TYPE_BETA)) then
1343 //              return TRUE;
1344 //      endif;
1345         
1346         return FALSE;
1347 end;
1348
1349
1350 ///////////////////////////////////////////////////////////////////////////////
1351 //
1352 //  Function: AnyNonUpgradableSoftwareInstalled
1353 //
1354 //  Purpose: This function will return TRUE if any non-upgradable software is
1355 //           installed.
1356 //
1357 ///////////////////////////////////////////////////////////////////////////////
1358 function AnyNonUpgradableSoftwareInstalled()
1359 begin
1360         if (NotUpgradable(&appFullClient) ||
1361             NotUpgradable(&appServer) ||
1362                 NotUpgradable(&appControlCenter) ||
1363                 NotUpgradable(&appLightClient) ||
1364                 NotUpgradable(&appDocs))
1365         then
1366                 return TRUE;
1367         endif;
1368         
1369         return FALSE;
1370 end;
1371
1372
1373 ///////////////////////////////////////////////////////////////////////////////
1374 //
1375 //  Function: UnselectComps
1376 //
1377 //  Purpose: This function unselects all of the componenets so that we can
1378 //           completely control what gets installed.  We will select each
1379 //           component at the time when we want to install it.
1380 //
1381 ///////////////////////////////////////////////////////////////////////////////
1382 function UnselectComps()
1383 begin
1384         ComponentSelectItem(MEDIA, SERVER_COMP_NAME, FALSE);
1385         ComponentSelectItem(MEDIA, CLIENT_COMP_NAME, FALSE);
1386         ComponentSelectItem(MEDIA, LIGHT_CLIENT_COMP_NAME, FALSE);
1387         ComponentSelectItem(MEDIA, CC_COMP_NAME, FALSE);
1388         ComponentSelectItem(MEDIA, DOCS_COMP_NAME, FALSE);
1389         ComponentSelectItem(MEDIA, LANG_COMP_NAME, FALSE);
1390         ComponentSelectItem(MEDIA, LANG_ENGLISH_COMP_NAME, FALSE);
1391         ComponentSelectItem(MEDIA, LANG_SIMP_CHINESE_COMP_NAME, FALSE);
1392         ComponentSelectItem(MEDIA, LANG_TRAD_CHINESE_COMP_NAME, FALSE);
1393         ComponentSelectItem(MEDIA, LANG_KOREAN_COMP_NAME, FALSE);
1394         ComponentSelectItem(MEDIA, LANG_JAPANESE_COMP_NAME, FALSE);
1395         ComponentSelectItem(MEDIA, LANG_GERMAN_COMP_NAME, FALSE);
1396         ComponentSelectItem(MEDIA, LANG_SPANISH_COMP_NAME, FALSE);
1397         ComponentSelectItem(MEDIA, LANG_PORTUGUESE_COMP_NAME, FALSE);
1398         ComponentSelectItem(MEDIA, README_COMP_NAME, FALSE);
1399         ComponentSelectItem(MEDIA, README_ENGLISH_COMP_NAME, FALSE);
1400         ComponentSelectItem(MEDIA, README_JAPANESE_COMP_NAME, FALSE);
1401         ComponentSelectItem(MEDIA, README_KOREAN_COMP_NAME, FALSE);
1402         ComponentSelectItem(MEDIA, README_SIMP_CHINESE_COMP_NAME, FALSE);
1403         ComponentSelectItem(MEDIA, README_TRAD_CHINESE_COMP_NAME, FALSE);
1404         ComponentSelectItem(MEDIA, README_GERMAN_COMP_NAME, FALSE);
1405         ComponentSelectItem(MEDIA, README_SPANISH_COMP_NAME, FALSE);
1406         ComponentSelectItem(MEDIA, README_PORTUGUESE_COMP_NAME, FALSE);
1407         ComponentSelectItem(MEDIA, DOCS_ENGLISH_COMP_NAME, FALSE);
1408         ComponentSelectItem(MEDIA, DOCS_JAPANESE_COMP_NAME, FALSE);
1409         ComponentSelectItem(MEDIA, DOCS_KOREAN_COMP_NAME, FALSE);
1410         ComponentSelectItem(MEDIA, DOCS_SIMP_CHINESE_COMP_NAME, FALSE);
1411         ComponentSelectItem(MEDIA, DOCS_TRAD_CHINESE_COMP_NAME, FALSE);
1412         ComponentSelectItem(MEDIA, DOCS_GERMAN_COMP_NAME, FALSE);
1413         ComponentSelectItem(MEDIA, DOCS_SPANISH_COMP_NAME, FALSE);
1414         ComponentSelectItem(MEDIA, DOCS_PORTUGUESE_COMP_NAME, FALSE);
1415 end;
1416
1417
1418 ///////////////////////////////////////////////////////////////////////////////
1419 //
1420 //  Function: DoesConfigInfoExist
1421 //
1422 //  Purpose: This function determines if config info exists for an app.
1423 //
1424 ///////////////////////////////////////////////////////////////////////////////
1425 function DoesConfigInfoExist(pApp)
1426 begin
1427         RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
1428
1429         if (RegDBKeyExist(CONFIG_INFO_KEY ^ pApp->szProductName) = 1) then
1430                 return TRUE;
1431         endif;
1432         
1433         return FALSE;
1434 end;
1435
1436
1437 ///////////////////////////////////////////////////////////////////////////////
1438 //
1439 //  Function: RestorePreviousConfigs
1440 //
1441 //  Purpose: This function restores config info for the apps we just installed.
1442 //
1443 ///////////////////////////////////////////////////////////////////////////////
1444 function RestorePreviousConfigs()
1445 begin
1446         if (appServer.bInstallSucceeded && DoesConfigInfoExist(&appServer)) then
1447                 RestoreConfigInfo(SERVER);
1448         endif;
1449
1450     if (appFullClient.bInstallSucceeded) then
1451         if (appFullClient.iVer.szTitle = "3.4a") then
1452             Upgrade34ClientConfigInfo();
1453         elseif (DoesConfigInfoExist(&appFullClient) = TRUE) then
1454                     RestoreConfigInfo(CLIENT);
1455                 endif;
1456         endif;
1457
1458         if (appLightClient.bInstallSucceeded && DoesConfigInfoExist(&appLightClient)) then
1459                 RestoreConfigInfo(LCLIENT);
1460         endif;
1461         
1462         // Only restore control center info if client not installed
1463         if (appControlCenter.bInstallSucceeded && !bClientInstalled && !appFullClient.bInstallSucceeded
1464                 && DoesConfigInfoExist(&appControlCenter))
1465         then
1466                 RestoreConfigInfo(CC);
1467         endif;
1468 end;
1469
1470
1471 ///////////////////////////////////////////////////////////////////////////////
1472 //
1473 //  Function: OnlyInstallingDocs
1474 //
1475 //  Purpose: This function determines if only the doc files are being installed.
1476 //
1477 ///////////////////////////////////////////////////////////////////////////////
1478 function OnlyInstallingDocs()
1479 begin
1480         if (!bServerSel && !bFullClientSel && !bLightClientSel && !bCcSel && bDocsSel) then
1481                 return TRUE;
1482         endif;
1483         
1484         return FALSE;
1485 end;
1486
1487
1488 ///////////////////////////////////////////////////////////////////////////////
1489 //
1490 //  Function: CreateDirs
1491 //
1492 //  Purpose: This function creates directories that we don't want IS to make.
1493 //
1494 ///////////////////////////////////////////////////////////////////////////////
1495 function CreateDirs()
1496 begin
1497         // Turn off logging.  It shouldn't be on when this func is called, but we
1498         // turn it off anyway just to make sure.  We turn it off so that IS won't
1499         // try to delete the dirs we are about to make during an uninstall.  If
1500         // we don't do this, then the first app installed that uses one of these
1501         // dirs will think that it owns that dir and won't know that other apps
1502         // are sharing it.
1503         Disable(LOGGING);
1504
1505         // Create the target dir and the shared dirs
1506         CreateDir(TARGETDIR);
1507         CreateDir(TARGETDIR ^ "Documentation");
1508         CreateDir(TARGETDIR ^ "Documentation\\Html");
1509         CreateDir(TARGETDIR ^ "Documentation\\Html\\InstallGd");
1510         CreateDir(TARGETDIR ^ "Documentation\\Html\\ReleaseNotes");
1511
1512         // We need to manually create the Server dir so that if we have to leave
1513         // it behind during an uninstall (so that config info is preserved), IS
1514         // won't complain that it can't be deleted.
1515         if (bServerSel) then
1516                 CreateDir(TARGETDIR ^ "Server\\usr\\afs\\bin");
1517         endif;
1518
1519     // Docs don't use the common dir
1520         if (OnlyInstallingDocs() = FALSE) then
1521                 CreateDir(TARGETDIR ^ "Common");
1522         endif;
1523 end;
1524
1525
1526 ///////////////////////////////////////////////////////////////////////////////
1527 //
1528 //  Function: PrepareForWSPPInstall
1529 //
1530 //  Purpose: This function decides what to install when doing a WSPP install.
1531 //
1532 ///////////////////////////////////////////////////////////////////////////////
1533 function PrepareForWSPPInstall()
1534 begin
1535         SHELL_OBJECT_FOLDER = @WSPP_FOLDER_NAME;
1536
1537         // Never install the Docs during a WSPP install
1538         appDocs.nInstallAction = ACTION_NONE;
1539
1540         // If we have been told to replace any preinstalled software, then set
1541         // our reinstall mechanism in motion.
1542         if (bPreinstallReplace) then
1543                 if (bCcInstalled && bCcSel) then
1544                         appControlCenter.nInstallAction = ACTION_REINSTALL;
1545                 endif;
1546                 if (bClientInstalled && bFullClientSel) then
1547                         appFullClient.nInstallAction = ACTION_REINSTALL;
1548                 endif;
1549                 if (bServerInstalled && bServerSel) then
1550                         appServer.nInstallAction = ACTION_REINSTALL;
1551                 endif;
1552                 if (bLightClientInstalled && bLightClientSel) then
1553                         appLightClient.nInstallAction = ACTION_REINSTALL;
1554                 endif;
1555         else
1556                 // If we have been told to not install something that is already
1557                 // installed, then do just that.
1558                 if (bCcInstalled && bCcSel) then
1559                         bCcSel = FALSE;
1560                 endif;
1561                 if (bClientInstalled && bFullClientSel) then
1562                         bFullClientSel = FALSE;
1563                 endif;
1564                 if (bServerInstalled && bServerSel) then
1565                         bServerSel = FALSE;
1566                 endif;
1567                 if (bLightClientInstalled && bLightClientSel) then
1568                         bLightClientSel = FALSE;
1569                 endif;
1570         endif;
1571 end;
1572
1573
1574 ///////////////////////////////////////////////////////////////////////////////
1575 //
1576 // Function: RemoveCurrentVersion
1577 //
1578 //  Purpose: This function removes the currently installed version of the app.
1579 //                       It provides a message to the user so they know what is going on.
1580 //
1581 ///////////////////////////////////////////////////////////////////////////////
1582 function RemoveCurrentVersion(pApp)
1583         string szMsg;
1584         string szFormat;
1585 begin
1586         szFormat = "";
1587
1588         switch(pApp->nInstallAction)
1589                 case ACTION_REINSTALL:  szFormat = @REINSTALL_PREP_MSG;
1590                 case ACTION_UPGRADE:    szFormat = @UPGRADE_PREP_MSG;
1591                 case ACTION_DOWNGRADE:  szFormat = @DOWNGRADE_PREP_MSG;
1592         endswitch;
1593
1594         if (szFormat == "") then
1595                 return;
1596         endif;
1597         
1598         Sprintf(szMsg, szFormat, pApp->szProductName);
1599         
1600         if (!bWSPPInstall) then
1601                 SdShowMsg(szMsg, TRUE);
1602         endif;
1603
1604         RemoveInstalledBits(pApp->szProductName);
1605
1606         if (!bWSPPInstall) then
1607                 SdShowMsg(szMsg, FALSE);
1608         endif;
1609 end;
1610
1611
1612 ///////////////////////////////////////////////////////////////////////////////
1613 //
1614 // Function: RemoveAllCurrentVersions
1615 //
1616 // Purpose: This function removes the current install of all apps that are
1617 //          begin reinstalled, upgraded, or downgraded.
1618 //
1619 ///////////////////////////////////////////////////////////////////////////////
1620 function RemoveAllCurrentVersions()
1621 begin
1622         if (bFullClientSel) then        
1623                 RemoveCurrentVersion(&appFullClient);
1624         endif;
1625         
1626         if (bServerSel) then
1627                 RemoveCurrentVersion(&appServer);
1628         endif;
1629         
1630         if (bCcSel) then
1631                 RemoveCurrentVersion(&appControlCenter);
1632         endif;
1633         
1634         if (bLightClientSel) then
1635                 RemoveCurrentVersion(&appLightClient);
1636         endif;
1637 end;
1638
1639
1640 ///////////////////////////////////////////////////////////////////////////////
1641 //
1642 // Function: InstallApp
1643 //
1644 // Purpose: This function installs an application that is part of a suite.
1645 //
1646 ///////////////////////////////////////////////////////////////////////////////
1647 function InstallApp(pApp)
1648         NUMBER nResult;
1649 begin
1650         if (pApp->nInstallAction = ACTION_NONE) then
1651                 return 0;
1652         endif;
1653
1654         // Start fresh with nothing selected
1655         UnselectComps();
1656
1657         // Select the comps we want to install.  We will install the passed in app
1658         // as well as the comps that are shared by all the apps.  Because of weird
1659         // IS stuff, the app comp must be selected last else IS will autoselect
1660         // things we don't want.
1661         ComponentSelectItem(MEDIA, szReadmeComp, TRUE);
1662
1663         // Lang comps are shared by all apps except the docs app
1664         if (pApp != &appDocs) then
1665                 ComponentSelectItem(MEDIA, szLangComp, TRUE);
1666         endif;
1667
1668     // Select the app's component
1669     ComponentSelectItem(MEDIA, pApp->szCompName, TRUE);
1670
1671 //      MessageBox("Install app: " + pApp->szCompName, INFORMATION);
1672
1673     nResult = ProcessBeforeDataMove(pApp);
1674     if (nResult < 0) goto error;
1675
1676     nResult = MoveFileData();
1677     if (nResult < 0) goto error;
1678
1679     nResult = ProcessAfterDataMove();
1680     if (nResult < 0) goto error;
1681         
1682         nResult = CreateRegistrySets(pApp->szRegistrySets);
1683         if (nResult < 0) goto error;
1684
1685         Disable(LOGGING);
1686
1687         nResult = CreateRegistrySets(pApp->szNoLogRegistrySets);
1688         if (nResult < 0) goto error;
1689
1690         nResult = ConfigUninstallDLL(pApp);
1691         if (nResult < 0) goto error;
1692
1693         AddPath(pApp->szBinPath);
1694
1695         // Now unselect it again
1696         ComponentSelectItem(MEDIA, pApp->szCompName, FALSE);
1697
1698         pApp->bInstallSucceeded = TRUE;
1699
1700         return 0;
1701         
1702 error:
1703         return nResult;
1704 end;
1705
1706
1707 ///////////////////////////////////////////////////////////////////////////////
1708 //
1709 // Function: ProcessBeforeDataMove
1710 //
1711 //  Purpose: This function performs any necessary operations prior to the
1712 //           actual file transfer.
1713 //
1714 ///////////////////////////////////////////////////////////////////////////////
1715 function ProcessBeforeDataMove(pApp)
1716     STRING svLogFile;
1717     NUMBER nResult;
1718 begin
1719         // Create app information and App Paths registry keys.
1720     InstallationInfo(pApp->szCompanyName, pApp->szProductName, pApp->Ver.szTitle, pApp->szProductKey);
1721
1722     svLogFile = pApp->szUninstLogfileName;
1723
1724     // Create the uninstall reg key and open the log file
1725     nResult = DeinstallStart(TARGETDIR, svLogFile, pApp->szUninstKey, 0 );
1726     if (nResult < 0) then
1727         ShowError( @ERROR_UNINSTSETUP, WARNING );
1728     endif;
1729
1730     szAppPath = pApp->szAppPath;
1731
1732         // Fill in reg values for this apps reg key and uninstall reg key
1733     RegDBSetItem( REGDB_APPPATH, szAppPath );
1734     RegDBSetItem( REGDB_APPPATH_DEFAULT, szAppPath ^ pApp->szProductKey);
1735     RegDBSetItem( REGDB_UNINSTALL_NAME, pApp->szUninstDisplayName);
1736
1737     return 0;
1738 end;
1739
1740
1741 /*
1742 function ShowIsSelected(comp)
1743         number nSel;
1744         string str;
1745 begin
1746     nSel = ComponentIsItemSelected(MEDIA , comp);
1747     if (nSel) then
1748         str = comp + " is selected.";
1749         MessageBox(str, INFORMATION);
1750     else
1751         str = comp + " is not selected.";
1752     endif;
1753 end;
1754
1755
1756 function ShowSelectedComponents()
1757 begin
1758         // Visible components
1759         ShowIsSelected(CLIENT_COMP_NAME);
1760         ShowIsSelected(LIGHT_CLIENT_COMP_NAME);
1761         ShowIsSelected(SERVER_COMP_NAME);
1762         ShowIsSelected(CC_COMP_NAME);
1763         ShowIsSelected(DOCS_COMP_NAME);
1764
1765     // Language components
1766         ShowIsSelected(LANG_COMP_NAME);
1767     ShowIsSelected(LANG_ENGLISH_COMP_NAME);
1768     ShowIsSelected(LANG_SIMP_CHINESE_COMP_NAME);
1769     ShowIsSelected(LANG_TRAD_CHINESE_COMP_NAME);
1770     ShowIsSelected(LANG_KOREAN_COMP_NAME);
1771     ShowIsSelected(LANG_JAPANESE_COMP_NAME);
1772     ShowIsSelected(LANG_GERMAN_COMP_NAME);
1773     ShowIsSelected(LANG_SPANISH_COMP_NAME);
1774     ShowIsSelected(LANG_PORTUGUESE_COMP_NAME);
1775
1776         // Documentation components
1777         ShowIsSelected(DOCS_ENGLISH_COMP_NAME);
1778         ShowIsSelected(DOCS_JAPANESE_COMP_NAME);
1779         ShowIsSelected(DOCS_KOREAN_COMP_NAME);
1780         ShowIsSelected(DOCS_SIMP_CHINESE_COMP_NAME);
1781         ShowIsSelected(DOCS_TRAD_CHINESE_COMP_NAME);
1782         ShowIsSelected(DOCS_GERMAN_COMP_NAME);
1783         ShowIsSelected(DOCS_SPANISH_COMP_NAME);
1784         ShowIsSelected(DOCS_PORTUGUESE_COMP_NAME);
1785         
1786         // Readme files components
1787         ShowIsSelected(README_COMP_NAME);
1788         ShowIsSelected(README_ENGLISH_COMP_NAME);
1789         ShowIsSelected(README_JAPANESE_COMP_NAME);
1790         ShowIsSelected(README_KOREAN_COMP_NAME);
1791         ShowIsSelected(README_SIMP_CHINESE_COMP_NAME);
1792         ShowIsSelected(README_TRAD_CHINESE_COMP_NAME);
1793         ShowIsSelected(README_GERMAN_COMP_NAME);
1794         ShowIsSelected(README_SPANISH_COMP_NAME);
1795         ShowIsSelected(README_PORTUGUESE_COMP_NAME);
1796 end;
1797 */
1798
1799
1800 ///////////////////////////////////////////////////////////////////////////////
1801 //
1802 //  Function:  MoveFileData
1803 //
1804 //  Purpose:  This function handles the file transfer for
1805 //            the setup.
1806 //
1807 ///////////////////////////////////////////////////////////////////////////////
1808 function MoveFileData()
1809     NUMBER nResult, nDisk;
1810
1811 begin
1812         if (!bWSPPInstall) then
1813                 Enable( INDVFILESTATUS );
1814         SetStatusWindow( 0, "" );
1815         Disable( DIALOGCACHE );
1816         Enable( STATUS );
1817         StatusUpdate( ON, 100 );
1818         endif;
1819
1820     nResult = ComponentMoveData( MEDIA, nDisk, 0 );
1821         
1822         // Reinit this call so the progress indicator resets
1823         ComponentMoveData("", nDisk, 0);
1824
1825     HandleMoveDataError( nResult );
1826
1827     Disable( STATUS );
1828
1829     return nResult;
1830 end;
1831
1832
1833 ///////////////////////////////////////////////////////////////////////////////
1834 //
1835 // Function: HandleMoveDataError
1836 //
1837 //  Purpose: This function handles the error (if any) during the file transfer
1838 //           operation.
1839 //
1840 ///////////////////////////////////////////////////////////////////////////////
1841 function HandleMoveDataError( nResult )
1842     STRING szErrMsg, svComponent , svFileGroup , svFile;
1843         string szMsg;
1844 begin
1845     svComponent = "";
1846     svFileGroup = "";
1847     svFile = "";
1848
1849     switch (nResult)
1850         case 0:
1851             return 0;
1852         default:
1853             ComponentError ( MEDIA , svComponent , svFileGroup , svFile , nResult );
1854             szErrMsg = @ERROR_MOVEDATA  + "\n\n" +
1855                 @ERROR_COMPONENT + " " + svComponent + "\n" +
1856                 @ERROR_FILEGROUP + " " + svFileGroup + "\n" +
1857                 @ERROR_FILE      + " " + svFile;
1858             Sprintf(szMsg, szErrMsg, nResult);
1859             ShowError(szMsg, SEVERE);
1860             bInstallAborted = TRUE;
1861             return nResult;
1862     endswitch;
1863
1864 end;
1865
1866
1867 ///////////////////////////////////////////////////////////////////////////////
1868 //
1869 // Function: ProcessAfterDataMove
1870 //
1871 //  Purpose: This function performs any necessary operations needed after
1872 //           all files have been transferred.
1873 //
1874 ///////////////////////////////////////////////////////////////////////////////
1875 function ProcessAfterDataMove()
1876     STRING szReferenceFile;
1877
1878 begin
1879
1880     // TO DO : update self-registered files and other processes that
1881     //        should be performed after the files have been transferred.
1882
1883     // DeinstallSetReference specifies a file to be checked before
1884     // uninstallation. If the file is in use, uninstallation will not proceed.
1885
1886 //      szReferenceFile = svDir ^ pApp->szProductKey; // TO DO : If your file is in a
1887                                             // subfolder of svDir add that here
1888
1889 //    DeinstallSetReference( szReferenceFile );
1890
1891     return 0;
1892 end;
1893
1894
1895 ///////////////////////////////////////////////////////////////////////////////
1896 //
1897 // Function: CleanUpInstall
1898 //
1899 //  Purpose: This cleans up the setup.  Anything that should
1900 //           be released or deleted at the end of the setup should
1901 //           be done here.
1902 //
1903 ///////////////////////////////////////////////////////////////////////////////
1904 function CleanUpInstall()
1905
1906 begin
1907     if (bInstallAborted) then
1908         return 0;
1909     endif;
1910
1911     if (!bWSPPInstall) then
1912         DialogShowSdFinishReboot();
1913     endif;
1914
1915     if (BATCH_INSTALL) then // ensure locked files are properly transferred
1916         CommitSharedFiles(0);
1917     endif;
1918
1919     return 0;
1920 end;
1921
1922
1923 ///////////////////////////////////////////////////////////////////////////////
1924 //
1925 // Function: GetLicenseFilename
1926 //
1927 //  Purpose: This will determine the full path to the appropriate-language
1928 //           license on the CD.  Will default to English if the locale cannot
1929 //           be determined.
1930 //
1931 ///////////////////////////////////////////////////////////////////////////////
1932 function GetLicenseFilename(szLicense)
1933         number MajorLanguage;
1934 begin
1935         MajorLanguage = SELECTED_LANGUAGE & 255;
1936
1937         switch(MajorLanguage)
1938         case ISLANG_CHINESE:
1939                 if (SELECTED_LANGUAGE == ISLANG_CHINESE_TAIWAN) then
1940                         szLicense = SRCDIR ^ LICENSE_TRAD_CHINESE_FILENAME;
1941                 else
1942                         szLicense = SRCDIR ^ LICENSE_SIMP_CHINESE_FILENAME;
1943                 endif;
1944
1945         case ISLANG_KOREAN:
1946                 szLicense = SRCDIR ^ LICENSE_KOREAN_FILENAME;
1947
1948         case ISLANG_JAPANESE:
1949                 szLicense = SRCDIR ^ LICENSE_JAPANESE_FILENAME;
1950
1951         case ISLANG_GERMAN:
1952                 szLicense = SRCDIR ^ LICENSE_GERMAN_FILENAME;
1953
1954         case ISLANG_PORTUGUESE:
1955                 szLicense = SRCDIR ^ LICENSE_PORTUGUESE_FILENAME;
1956
1957         case ISLANG_SPANISH:
1958                 szLicense = SRCDIR ^ LICENSE_SPANISH_FILENAME;
1959
1960         default:
1961                 szLicense = SRCDIR ^ LICENSE_ENGLISH_FILENAME;
1962
1963         endswitch;
1964
1965         return 0;
1966 end;
1967
1968
1969 ///////////////////////////////////////////////////////////////////////////////
1970 //
1971 // Function: GetLanguageComp
1972 //
1973 //  Purpose: This will determine which language the locale is set to.  Uses
1974 //           this info to determine which lang, readme, and doc comps to
1975 //           install.  Will default to English if the locale cannot be
1976 //           determined.
1977 //
1978 ///////////////////////////////////////////////////////////////////////////////
1979 function GetNlsComps(szLangComp, szReadmeComp, szDocsComp, szCodePage)
1980         number MajorLanguage;
1981 begin
1982         MajorLanguage = SELECTED_LANGUAGE & 255;
1983
1984         switch(MajorLanguage)
1985                 case ISLANG_CHINESE:
1986                         if (SELECTED_LANGUAGE == ISLANG_CHINESE_TAIWAN) then
1987                szLangComp = LANG_TRAD_CHINESE_COMP_NAME;
1988                szReadmeComp = README_TRAD_CHINESE_COMP_NAME;
1989                szDocsComp = DOCS_TRAD_CHINESE_COMP_NAME;
1990                szCodePage = "1028";
1991                         else
1992                szLangComp = LANG_SIMP_CHINESE_COMP_NAME;
1993                szReadmeComp = README_SIMP_CHINESE_COMP_NAME;
1994                szDocsComp = DOCS_SIMP_CHINESE_COMP_NAME;
1995                szCodePage = "2052";
1996                         endif;
1997
1998                 case ISLANG_KOREAN:
1999                szLangComp = LANG_KOREAN_COMP_NAME;
2000                szReadmeComp = README_KOREAN_COMP_NAME;
2001                szDocsComp = DOCS_KOREAN_COMP_NAME;
2002                szCodePage = "1042";
2003
2004                 case ISLANG_JAPANESE:
2005                szLangComp = LANG_JAPANESE_COMP_NAME;
2006                szReadmeComp = README_JAPANESE_COMP_NAME;
2007                szDocsComp = DOCS_JAPANESE_COMP_NAME;
2008                szCodePage = "1041";
2009
2010         case ISLANG_GERMAN:
2011                szLangComp = LANG_GERMAN_COMP_NAME;
2012                szReadmeComp = README_GERMAN_COMP_NAME;
2013                szDocsComp = DOCS_GERMAN_COMP_NAME;
2014                szCodePage = "1032";
2015
2016         case ISLANG_PORTUGUESE:
2017                szLangComp = LANG_PORTUGUESE_COMP_NAME;
2018                szReadmeComp = README_PORTUGUESE_COMP_NAME;
2019                szDocsComp = DOCS_PORTUGUESE_COMP_NAME;
2020                szCodePage = "1046";
2021
2022         case ISLANG_SPANISH:
2023                szLangComp = LANG_SPANISH_COMP_NAME;
2024                szReadmeComp = README_SPANISH_COMP_NAME;
2025                szDocsComp = DOCS_SPANISH_COMP_NAME;
2026                szCodePage = "1034";
2027
2028                 default:
2029                szLangComp = LANG_ENGLISH_COMP_NAME;
2030                szReadmeComp = README_ENGLISH_COMP_NAME;
2031                szDocsComp = DOCS_ENGLISH_COMP_NAME;
2032                szCodePage = "1033";
2033
2034         endswitch;
2035
2036         return 0;
2037 end;
2038
2039
2040 ///////////////////////////////////////////////////////////////////////////////
2041 //
2042 // Function: SetupVerInfo
2043 //
2044 //  Purpose: This will initialize the VERINFO structures for a product.
2045 //
2046 ///////////////////////////////////////////////////////////////////////////////
2047 function SetupVerInfo(pApp, szMajor, szMinor, szPatchLevel, szBetaLevel, szReleaseType, szTitle, bInstalledVerInfo)
2048         int nMajor;
2049         int nMinor;
2050         int nPatchLevel;
2051         int nBetaLevel;
2052 begin
2053         StrToNum(nMajor, szMajor);
2054         StrToNum(nMinor, szMinor);
2055         StrToNum(nPatchLevel, szPatchLevel);
2056         StrToNum(nBetaLevel, szBetaLevel);
2057
2058         if (bInstalledVerInfo) then
2059                 pApp->iVer.nMajorVersion = nMajor;
2060                 pApp->iVer.nMinorVersion = nMinor;
2061                 pApp->iVer.nPatchLevel = nPatchLevel;
2062                 pApp->iVer.nBetaLevel = nBetaLevel;
2063                 pApp->iVer.szReleaseType = szReleaseType;
2064                 pApp->iVer.szTitle = szTitle;   
2065         else
2066                 pApp->Ver.nMajorVersion = nMajor;
2067                 pApp->Ver.nMinorVersion = nMinor;
2068                 pApp->Ver.nPatchLevel = nPatchLevel;
2069                 pApp->Ver.nBetaLevel = nBetaLevel;
2070                 pApp->Ver.szReleaseType = szReleaseType;
2071                 pApp->Ver.szTitle = szTitle;
2072         endif;
2073 end;
2074
2075
2076         
2077 ///////////////////////////////////////////////////////////////////////////////
2078 //
2079 // Function: FixTargetPaths
2080 //
2081 //  Purpose: This function updates the CommonBinPath and app paths if you
2082 //                       choose to install to a different directory
2083 //
2084 ///////////////////////////////////////////////////////////////////////////////
2085 function FixTargetPaths()
2086 begin
2087         // The AFS path must not contain spaces.  AFS code will break if it does.
2088         LongPathToShortPath(TARGETDIR);
2089
2090         szCommonBinPath = TARGETDIR ^ "Common";
2091         
2092         // Full Client
2093         appFullClient.szAppPath = TARGETDIR ^ "Client";
2094         appFullClient.szBinPath = TARGETDIR ^ "Client\\Program";
2095         
2096         // Light Client
2097         appLightClient.szAppPath = TARGETDIR ^ "Client";
2098         appLightClient.szBinPath = TARGETDIR ^ "Client\\Program";
2099
2100         // Server
2101         appServer.szAppPath = TARGETDIR ^ "Server";
2102         appServer.szBinPath = TARGETDIR ^ "Server\\usr\\afs\\bin";
2103         
2104         // Control Center
2105         appControlCenter.szAppPath = TARGETDIR ^ "Control Center";
2106         appControlCenter.szBinPath = TARGETDIR ^ "Control Center";
2107         
2108     // Docs
2109         appDocs.szAppPath = TARGETDIR ^ "Documentation";
2110         appDocs.szBinPath = TARGETDIR ^ "Documentation";
2111 end;
2112         
2113
2114         
2115 ///////////////////////////////////////////////////////////////////////////////
2116 //
2117 // Function: SetupAppInfo
2118 //
2119 //  Purpose: This will initialize the APPINFO structures for each product
2120 //                       that we can install.
2121 //
2122 ///////////////////////////////////////////////////////////////////////////////
2123 function SetupAppInfo()
2124 int n;
2125 begin
2126         szCommonBinPath = TARGETDIR ^ "Common";
2127         
2128         // Full Client
2129         appFullClient.szCompName = CLIENT_COMP_NAME;            // Component name
2130         appFullClient.szCompanyName = @COMPANY_NAME;
2131         appFullClient.szProductName = @PRODUCT_NAME_CLIENT;
2132         appFullClient.szProductKey = @PRODUCT_KEY_CLIENT;
2133         appFullClient.bUseUninstDLL = TRUE;
2134         appFullClient.szUninstDllName = CLIENT_UNINST_DLL_NAME;
2135         appFullClient.szUninstLogfileName = CLIENT_UNINST_LOGFILE_NAME;
2136         appFullClient.szUninstKey = @UNINST_KEY_CLIENT;
2137         appFullClient.szAppPath = TARGETDIR ^ "Client";
2138         appFullClient.szBinPath = TARGETDIR ^ "Client\\Program";
2139         appFullClient.bAddToPath = TRUE;
2140         appFullClient.szUninstDisplayName = @UNINST_DISPLAY_NAME_CLIENT;
2141         appFullClient.szRegistrySets = "Client,Full_Client";
2142         appFullClient.szNoLogRegistrySets = "Client_NoUninstall,WinNT_Client_NoUninstall";
2143         appFullClient.bInstallSucceeded = FALSE;
2144         SetupVerInfo(&appFullClient, @PRODUCT_VERSION_MAJOR, @PRODUCT_VERSION_MINOR, @PRODUCT_VERSION_PATCH_LEVEL, @PRODUCT_VERSION_BETA_LEVEL, @PRODUCT_VERSION_RELEASE_TYPE, @PRODUCT_VERSION_TITLE, FALSE);
2145         
2146         // Light Client
2147         if (bWin95) then
2148                 appLightClient.szCompName = LIGHT95_CLIENT_COMP_NAME;
2149         elseif (bWin98) then
2150                 appLightClient.szCompName = LIGHT98_CLIENT_COMP_NAME;
2151         endif;
2152         appLightClient.szCompanyName = @COMPANY_NAME;
2153         appLightClient.szProductName = @PRODUCT_NAME_LIGHT_CLIENT;
2154         appLightClient.szProductKey = @PRODUCT_KEY_LIGHT_CLIENT;
2155         appLightClient.bUseUninstDLL = TRUE;
2156         appLightClient.szUninstDllName = LIGHT_CLIENT_UNINST_DLL_NAME;
2157         appLightClient.szUninstLogfileName = LIGHT_CLIENT_UNINST_LOGFILE_NAME;
2158         appLightClient.szUninstKey = @UNINST_KEY_LIGHT_CLIENT;
2159         appLightClient.szAppPath = TARGETDIR ^ "Client";
2160         appLightClient.szBinPath = TARGETDIR ^ "Client\\Program";
2161         appLightClient.bAddToPath = TRUE;
2162         appLightClient.szUninstDisplayName = @UNINST_DISPLAY_NAME_LIGHT_CLIENT;
2163         appLightClient.szRegistrySets = "Client,LightClient";
2164         appLightClient.szNoLogRegistrySets = "Client_NoUninstall";
2165         appLightClient.bInstallSucceeded = FALSE;
2166         SetupVerInfo(&appLightClient, @PRODUCT_VERSION_MAJOR, @PRODUCT_VERSION_MINOR, @PRODUCT_VERSION_PATCH_LEVEL, @PRODUCT_VERSION_BETA_LEVEL, @PRODUCT_VERSION_RELEASE_TYPE, @PRODUCT_VERSION_TITLE, FALSE);
2167
2168         // Server
2169         appServer.szCompName = SERVER_COMP_NAME;
2170         appServer.szCompanyName = @COMPANY_NAME;
2171         appServer.szProductName = @PRODUCT_NAME_SERVER;
2172         appServer.szProductKey = @PRODUCT_KEY_SERVER;
2173         appServer.bUseUninstDLL = TRUE;
2174         appServer.szUninstDllName = SERVER_UNINST_DLL_NAME;
2175         appServer.szUninstLogfileName = SERVER_UNINST_LOGFILE_NAME;
2176         appServer.szUninstKey = @UNINST_KEY_SERVER;
2177         appServer.szAppPath = TARGETDIR ^ "Server";
2178         appServer.szBinPath = TARGETDIR ^ "Server\\usr\\afs\\bin";
2179         appServer.bAddToPath = TRUE;
2180         appServer.szUninstDisplayName = @UNINST_DISPLAY_NAME_SERVER;
2181         appServer.szRegistrySets = "Server";
2182         appServer.szNoLogRegistrySets = "";
2183         appServer.bInstallSucceeded = FALSE;
2184         SetupVerInfo(&appServer, @PRODUCT_VERSION_MAJOR, @PRODUCT_VERSION_MINOR, @PRODUCT_VERSION_PATCH_LEVEL, @PRODUCT_VERSION_BETA_LEVEL, @PRODUCT_VERSION_RELEASE_TYPE, @PRODUCT_VERSION_TITLE, FALSE);
2185         
2186         // Control Center
2187         appControlCenter.szCompName = CC_COMP_NAME;
2188         appControlCenter.szCompanyName = @COMPANY_NAME;
2189         appControlCenter.szProductName = @PRODUCT_NAME_CC;
2190         appControlCenter.szProductKey = @PRODUCT_KEY_CC;
2191         appControlCenter.bUseUninstDLL = TRUE;
2192         appControlCenter.szUninstDllName = CC_UNINST_DLL_NAME;
2193         appControlCenter.szUninstLogfileName = CC_UNINST_LOGFILE_NAME;
2194         appControlCenter.szUninstKey = @UNINST_KEY_CC;
2195         appControlCenter.szAppPath = TARGETDIR ^ "Control Center";
2196         appControlCenter.szBinPath = TARGETDIR ^ "Control Center";
2197         appControlCenter.bAddToPath = TRUE;
2198         appControlCenter.szUninstDisplayName = @UNINST_DISPLAY_NAME_CC;
2199         appControlCenter.szRegistrySets = "Control_Center";
2200         appControlCenter.szNoLogRegistrySets = "";
2201         appControlCenter.bInstallSucceeded = FALSE;
2202         SetupVerInfo(&appControlCenter, @PRODUCT_VERSION_MAJOR, @PRODUCT_VERSION_MINOR, @PRODUCT_VERSION_PATCH_LEVEL, @PRODUCT_VERSION_BETA_LEVEL, @PRODUCT_VERSION_RELEASE_TYPE, @PRODUCT_VERSION_TITLE, FALSE);
2203         
2204     // Docs
2205         appDocs.szCompName = DOCS_COMP_NAME;
2206         appDocs.szCompanyName = @COMPANY_NAME;
2207         appDocs.szProductName = @PRODUCT_NAME_DOCS;
2208         appDocs.szProductKey = @PRODUCT_KEY_DOCS;
2209         appDocs.bUseUninstDLL = TRUE;
2210         appDocs.szUninstDllName = DOCS_UNINST_DLL_NAME;
2211         appDocs.szUninstLogfileName = DOCS_UNINST_LOGFILE_NAME;
2212         appDocs.szUninstKey = @UNINST_KEY_DOCS;
2213         appDocs.szAppPath = TARGETDIR ^ "Documentation";
2214         appDocs.szBinPath = TARGETDIR ^ "Documentation";
2215         appDocs.bAddToPath = FALSE;
2216         appDocs.szUninstDisplayName = @UNINST_DISPLAY_NAME_DOCS;
2217         appDocs.szRegistrySets = "Docs";
2218         appDocs.szNoLogRegistrySets = "";
2219         appDocs.bInstallSucceeded = FALSE;
2220         SetupVerInfo(&appDocs, @PRODUCT_VERSION_MAJOR, @PRODUCT_VERSION_MINOR, @PRODUCT_VERSION_PATCH_LEVEL, @PRODUCT_VERSION_BETA_LEVEL, @PRODUCT_VERSION_RELEASE_TYPE, @PRODUCT_VERSION_TITLE, FALSE);
2221 end;
2222         
2223
2224 ///////////////////////////////////////////////////////////////////////////////
2225 //
2226 // Function: SetupInstall
2227 //
2228 //  Purpose: This will initialize the setup.  Any general initialization
2229 //           needed for the installation should be performed here.
2230 //
2231 ///////////////////////////////////////////////////////////////////////////////
2232 function SetupInstall()
2233 begin
2234     Enable( CORECOMPONENTHANDLING );
2235
2236     szCellName=@CELLNAME_DEFAULT;
2237     bInstallAborted = FALSE;
2238
2239     //  Create list of end user selections to be displayed by DialogShowSdStartCopy()
2240
2241     svDir = PROGRAMFILES ^ @DEFAULT_INSTALL_DIR;
2242
2243     TARGETDIR  = svDir;
2244
2245     SdProductName( @PRODUCT_NAME );
2246
2247     Enable( DIALOGCACHE );
2248
2249     SetDialogTitle(DLG_ASK_YESNO, @TITLE_CAPTIONBAR);
2250         SetDialogTitle(DLG_MSG_INFORMATION, @TITLE_CAPTIONBAR);
2251         SetDialogTitle(DLG_MSG_WARNING, @TITLE_CAPTIONBAR);
2252         SetDialogTitle(DLG_MSG_SEVERE, @TITLE_CAPTIONBAR);
2253         SetDialogTitle(DLG_USER_CAPTION, @TITLE_CAPTIONBAR);
2254 end;
2255
2256 ///////////////////////////////////////////////////////////////////////////////
2257 //
2258 // Function:  SetupScreen
2259 //
2260 //  Purpose:  This function establishes the screen look.  This includes
2261 //            colors, fonts, and text to be displayed.
2262 //
2263 ///////////////////////////////////////////////////////////////////////////////
2264 function SetupScreen()
2265 begin
2266     Enable( FULLWINDOWMODE );
2267     SetTitle( @TITLE_MAIN, 24, WHITE );
2268
2269     SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION ); // Caption bar text.
2270
2271     Enable( BACKGROUND );
2272
2273     Delay( 1 );
2274 end;
2275
2276
2277 ///////////////////////////////////////////////////////////////////////////////
2278 //
2279 // Function:  CheckRequirements
2280 //
2281 //  Purpose:  This function checks all minimum requirements for the
2282 //            application being installed.  If any fail, then the user
2283 //            is informed and the setup is terminated.
2284 //
2285 ///////////////////////////////////////////////////////////////////////////////
2286 function CheckRequirements()
2287     NUMBER  nvDx, nvDy, nvResult;
2288     STRING  svResult;
2289 begin
2290     bWinNT           = FALSE;
2291     bWin95                       = FALSE;
2292     bWin98                       = FALSE;
2293     bIsShellExplorer = FALSE;
2294
2295     // Check screen resolution.
2296     GetExtents( nvDx, nvDy );
2297
2298     if (nvDy < 480) then
2299         ShowError( @ERROR_VGARESOLUTION, WARNING );
2300         abort;
2301     endif;
2302
2303     // set 'setup' operation mode
2304     bIs32BitSetup = TRUE;
2305     GetSystemInfo( ISTYPE, nvResult, svResult );
2306     if (nvResult = 16) then
2307         bIs32BitSetup = FALSE; // running 16-bit setup
2308         return 0; // no additional information required
2309     endif;
2310
2311     // --- 32-bit testing after this point ---
2312
2313     // Determine the target system's operating system.
2314     GetSystemInfo( OS, nvResult, svResult );
2315
2316     if (nvResult =  IS_WINDOWSNT) then
2317         // Running Windows NT.
2318         bWinNT = TRUE;
2319
2320         // If the user is not an admin, then abort
2321         if (CheckIfAdmin() = -1) then
2322             ShowError(@MUST_BE_AN_ADMIN_MSG, SEVERE);
2323             abort;
2324         endif;
2325
2326         // Check to see if the shell being used is EXPLORER shell.
2327         if (GetSystemInfo( OSMAJOR, nvResult, svResult ) = 0) then
2328             if (nvResult >= 4) then
2329                 bIsShellExplorer = TRUE;
2330             endif;
2331         endif;
2332
2333     elseif (nvResult = IS_WINDOWS95) then
2334         // IS puts us here even for Win98
2335         if (IsWin98() = 0) then
2336             bWin98 = TRUE;
2337                 else
2338                     bWin95 = TRUE;
2339                 endif;
2340
2341         bIsShellExplorer = TRUE;
2342     endif;
2343 end;
2344
2345
2346 ///////////////////////////////////////////////////////////////////////////////
2347 //
2348 // Function: DialogShowSdWelcome
2349 //
2350 //  Purpose: This function handles the standard welcome dialog.
2351 //
2352 //
2353 ///////////////////////////////////////////////////////////////////////////////
2354 function DialogShowSdWelcome()
2355     NUMBER nResult;
2356     STRING szTitle, szMsg;
2357
2358 begin
2359
2360     szTitle = "";
2361     szMsg   = @WELCOME_MESSAGE;
2362     nResult = SdWelcome( szTitle, szMsg );
2363
2364     return nResult;
2365 end;
2366
2367
2368 ///////////////////////////////////////////////////////////////////////////////
2369 //
2370 // Function: DialogShowSdAskDestPath
2371 //
2372 //  Purpose: This function asks the user for the destination folder.
2373 //
2374 ///////////////////////////////////////////////////////////////////////////////
2375 function DialogShowSdAskDestPath()
2376     NUMBER nResult;
2377     STRING szTitle, szMsg;
2378
2379 begin
2380
2381     szTitle = "";
2382     szMsg   = "";
2383     nResult = SdAskDestPath( szTitle, szMsg, svDir, 0 );
2384
2385     TARGETDIR = svDir;
2386     FixTargetPaths();
2387
2388     return nResult;
2389 end;
2390
2391
2392 ///////////////////////////////////////////////////////////////////////////////
2393 //
2394 // Function: GetVersionNumber
2395 //
2396 //  Purpose: This function converts a version number string into an integer.
2397 //
2398 ///////////////////////////////////////////////////////////////////////////////
2399 function GetVersionNumber(szVerion)
2400         int nVersion;
2401         int nMajorVersion;
2402         int nMinorVersion;
2403         string szVer[64];
2404 begin
2405         // This code assumes a majorversion.minorversion format.
2406         szVer = szVerion;
2407                 
2408         // This will get everything up to the '.'
2409         StrToNum(nMajorVersion, szVer);
2410         
2411         // Delete the part of the string we just converted
2412         StrSub(szVer, szVer, StrFind(szVer, ".") + 1, 64);
2413         
2414         // Now convert the part after the '.'
2415         StrToNum(nMinorVersion, szVer);
2416         
2417         // Turn in into a single number
2418         nVersion = (nMajorVersion * 10) + nMinorVersion;
2419         
2420         return nVersion;
2421 end;
2422         
2423
2424 ///////////////////////////////////////////////////////////////////////////////
2425 //
2426 // Function: CompareVersions
2427 //
2428 //  Purpose: This function compares an apps two version info structures and
2429 //                       determines if one is greater than the other, or if they are equal.
2430 //
2431 ///////////////////////////////////////////////////////////////////////////////
2432 function CompareVersions(pApp)
2433         int nResult;
2434 begin
2435         // Compare major versions
2436         nResult = pApp->Ver.nMajorVersion - pApp->iVer.nMajorVersion;
2437         if (nResult > 0) then return 1; endif;
2438         if (nResult < 0) then return -1; endif;
2439         
2440         // Major versions are equal, move on to minor versions
2441         nResult = pApp->Ver.nMinorVersion - pApp->iVer.nMinorVersion;
2442         if (nResult > 0) then return 1; endif;
2443         if (nResult < 0) then return -1; endif;
2444
2445         // Minor versions are equal, move on to patch level.
2446         nResult = pApp->Ver.nPatchLevel - pApp->iVer.nPatchLevel;
2447         if (nResult > 0) then return 1; endif;
2448         if (nResult < 0) then return -1; endif;
2449
2450         // Patch levels are equal, move on to release type.
2451         if ((pApp->Ver.szReleaseType = RELEASE_TYPE_GA) && (pApp->iVer.szReleaseType = RELEASE_TYPE_BETA)) then return 1; endif;
2452         if ((pApp->Ver.szReleaseType = RELEASE_TYPE_BETA) && (pApp->iVer.szReleaseType = RELEASE_TYPE_GA)) then return -1; endif;
2453         
2454         // Release types are equal.  Special handling now required:
2455         
2456         // If this is a GA release, then there is no more info to look at, and the versions are equal.
2457         if (pApp->Ver.szReleaseType = RELEASE_TYPE_GA) then return 0; endif;
2458
2459         // We have a Beta release, so we still have some info to check.  Compare the beta release levels.
2460         nResult = pApp->Ver.nBetaLevel - pApp->iVer.nBetaLevel;
2461         if (nResult > 0) then return 1; endif;
2462         if (nResult < 0) then return -1; endif;
2463         
2464         // Beta versions are equal.
2465         return 0;
2466 end;
2467         
2468
2469 ///////////////////////////////////////////////////////////////////////////////
2470 //
2471 // Function: GetInstallAction
2472 //
2473 //  Purpose: This function decides what install action to perform for a
2474 //           component and sets the display name accordingly.
2475 //
2476 ///////////////////////////////////////////////////////////////////////////////
2477 function GetInstallAction(szCompName, bInstalled, szInstallMsg, szUpgradeMsg, szDowngradeMsg, szReinstallMsg, pApp)
2478         string szDisplayName;
2479         string szVerMsg;
2480         int nResult;
2481 begin
2482         szVerMsg = "";
2483
2484         if (bInstalled) then
2485                 nResult = CompareVersions(pApp);
2486
2487                 if (nResult = 0) then
2488                         szDisplayName = szReinstallMsg;
2489                         pApp->nInstallAction = ACTION_REINSTALL;
2490         
2491                 elseif (nResult > 0) then
2492                         szDisplayName = szUpgradeMsg;
2493                         pApp->nInstallAction = ACTION_UPGRADE;
2494                         Sprintf(szVerMsg, " %s", pApp->iVer.szTitle);
2495                         
2496                 else // Trying to install old version on top of new version
2497                         szDisplayName = szDowngradeMsg;
2498                         pApp->nInstallAction = ACTION_DOWNGRADE;
2499                         Sprintf(szVerMsg, " %s", pApp->iVer.szTitle);
2500                 endif;
2501         else
2502                 szDisplayName = szInstallMsg;
2503                 pApp->nInstallAction = ACTION_INSTALL;
2504         endif;
2505
2506         szDisplayName = szDisplayName + szVerMsg;
2507
2508         ComponentSetData(MEDIA, szCompName, COMPONENT_FIELD_DISPLAYNAME, 0, szDisplayName);
2509         
2510         return TRUE;
2511 end;
2512
2513
2514 ///////////////////////////////////////////////////////////////////////////////
2515 //
2516 // Function: GetInstallActions
2517 //
2518 //  Purpose: This function decides what install action to perform for each
2519 //           component and sets the display name accordingly.
2520 //
2521 ///////////////////////////////////////////////////////////////////////////////
2522 function GetInstallActions()
2523 begin
2524         // Decide what to do for each component and then set the display names appropriately
2525         GetInstallAction(CLIENT_COMP_NAME, bClientInstalled, @INSTALL_CLIENT_MSG, @UPGRADE_CLIENT_MSG, @DOWNGRADE_CLIENT_MSG, @REINSTALL_CLIENT_MSG, &appFullClient);
2526         GetInstallAction(SERVER_COMP_NAME, bServerInstalled, @INSTALL_SERVER_MSG, @UPGRADE_SERVER_MSG, @DOWNGRADE_SERVER_MSG, @REINSTALL_SERVER_MSG, &appServer);
2527         GetInstallAction(CC_COMP_NAME, bCcInstalled, @INSTALL_CC_MSG, @UPGRADE_CC_MSG, @DOWNGRADE_CC_MSG, @REINSTALL_CC_MSG, &appControlCenter);
2528         GetInstallAction(LIGHT_CLIENT_COMP_NAME, bLightClientInstalled, @INSTALL_LIGHT_CLIENT_MSG, @UPGRADE_LIGHT_CLIENT_MSG, @DOWNGRADE_LIGHT_CLIENT_MSG, @REINSTALL_LIGHT_CLIENT_MSG, &appLightClient);
2529         GetInstallAction(DOCS_COMP_NAME, bDocsInstalled, @INSTALL_DOCS_MSG, @UPGRADE_DOCS_MSG, @DOWNGRADE_DOCS_MSG, @REINSTALL_DOCS_MSG, &appDocs);
2530 end;
2531
2532 ///////////////////////////////////////////////////////////////////////////////
2533 //
2534 // Function: ClientSelectedOrInstalled
2535 //
2536 //  Purpose: This function checks whether or not the client is selected or if
2537 //           it is already installed.
2538 //
2539 ///////////////////////////////////////////////////////////////////////////////
2540 function ClientSelectedOrInstalled()
2541 begin
2542         if (bFullClientSel || bClientInstalled) then
2543                 return TRUE;
2544         endif;
2545                 
2546         return FALSE;
2547 end;
2548
2549 ///////////////////////////////////////////////////////////////////////////////
2550 //
2551 // Function: AppVersionOk
2552 //
2553 //  Purpose: This function determines if a given app will have the correct
2554 //           version after installation.
2555 //
2556 ///////////////////////////////////////////////////////////////////////////////
2557 function AppVersionOk(bInstalled, bSel, pApp)
2558         BOOL bOk;
2559 begin
2560         // Here's the logic of this:
2561         //
2562         // 1)  If the app is not installed and
2563         //     a) it's not being installed, then this app doesn't affect the version
2564         //        restrictions, so return true
2565         //     b) it will be installed, then it will get the version which this
2566         //        installer installs, so the version will be ok
2567         //
2568         // 2)  If the app is installed and
2569         //     a) the app is selected for reinstall, upgrade, or downgrade, then the
2570         //        newly installed version will be the version this installer installs,
2571         //        and so the version will be ok
2572         //     b) the app is not selected for reinstall, upgrade, or downgrade, then
2573         //        the version is ok only if the app's current version matches the
2574         //        the version of this installer
2575
2576         bOk = !bInstalled || bSel || (CompareVersions(pApp) = 0);
2577
2578         return bOk;
2579 end;
2580         
2581
2582 ///////////////////////////////////////////////////////////////////////////////
2583 //
2584 // Function: DialogShowSdAskComponentDialog
2585 //
2586 //  Purpose: This function asks the user which components to install
2587 //                       and what the destination folder should be.
2588 //
2589 ///////////////////////////////////////////////////////////////////////////////
2590 function DialogShowSdAskComponentDialog()
2591     NUMBER nResult;
2592     STRING szTitle, szMsg, szComponent, szFilename;
2593     BOOL bClient, bServer, bCc, bDocs, bVersionsOK;
2594 begin
2595
2596     szTitle = "";
2597     szMsg   = "";
2598         szComponent = "";
2599
2600         // If running WinNT hide the Light Client component.  If the user wants to only
2601         // allow client installs, then hide all but the Client component as well.  If not
2602         // running on NT, then hide all but the Light Client component.
2603         if (bWinNT) then
2604                 ComponentSetData(MEDIA, LIGHT_CLIENT_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
2605                 ComponentSelectItem(MEDIA, LIGHT_CLIENT_COMP_NAME, FALSE);
2606         
2607                 if (FindFile(SRCDIR, ALLOW_ONLY_CLIENT_FLAG_FILENAME, szFilename) = 0) then
2608                         ComponentSetData(MEDIA, SERVER_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
2609                         ComponentSetData(MEDIA, CC_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
2610                         ComponentSetData(MEDIA, DOCS_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
2611                         ComponentSelectItem(MEDIA, DOCS_COMP_NAME, FALSE);
2612                         endif;
2613                 ComponentSelectItem(MEDIA, SERVER_COMP_NAME, FALSE);
2614                 if (@CELLNAME_DEFAULT % ".") then
2615                         ComponentSelectItem(MEDIA, CC_COMP_NAME, FALSE);
2616                 else
2617                         ComponentSelectItem(MEDIA, CC_COMP_NAME, TRUE);
2618                 endif;
2619 else
2620                 ComponentSetData(MEDIA, CLIENT_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
2621                 ComponentSetData(MEDIA, SERVER_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
2622                 ComponentSetData(MEDIA, CC_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
2623                 ComponentSetData(MEDIA, DOCS_COMP_NAME, COMPONENT_FIELD_VISIBLE, FALSE, "");
2624                 
2625                 ComponentSelectItem(MEDIA, SERVER_COMP_NAME, FALSE);
2626                 ComponentSelectItem(MEDIA, CLIENT_COMP_NAME, FALSE);
2627                 ComponentSelectItem(MEDIA, CC_COMP_NAME, FALSE);
2628                 ComponentSelectItem(MEDIA, DOCS_COMP_NAME, FALSE);
2629         endif;
2630
2631 retry:
2632         nResult = SdComponentDialog(szTitle, szMsg, svDir, szComponent);
2633
2634         // Enforce selection rules - something must be selected and
2635         // the client must be selected if the server is.  However, take into
2636         // account if it is already installed.
2637         bFullClientSel = ComponentIsItemSelected(MEDIA , CLIENT_COMP_NAME);
2638         bLightClientSel = ComponentIsItemSelected(MEDIA , LIGHT_CLIENT_COMP_NAME);
2639         bServerSel = ComponentIsItemSelected(MEDIA , SERVER_COMP_NAME);
2640         bCcSel = ComponentIsItemSelected(MEDIA , CC_COMP_NAME);
2641         bDocsSel = ComponentIsItemSelected(MEDIA , DOCS_COMP_NAME);
2642
2643         if (!bFullClientSel && !bLightClientSel && !bServerSel && !bCcSel && !bDocsSel) then
2644                 ShowError(@NOTHING_SELECTED_MSG, SEVERE);
2645                 goto retry;
2646         endif;
2647
2648         if (bServerSel && !ClientSelectedOrInstalled()) then
2649                 ShowError(@SERVER_NEEDS_CLIENT_MSG, SEVERE);
2650                 goto retry;
2651         endif;  
2652
2653         // Also, if upgrading or downgrading, all apps must be at the same version level.
2654         // We won't upgrade one app to a higer version than another, and we won't downgrade
2655         // one app to a lowel version than another.  All must be at the same level when the
2656         // install program is done.  This is necessary because the apps share some files.
2657         if (!bWinNT) then
2658                 bVersionsOK = TRUE;
2659         else
2660                 bClient = AppVersionOk(bClientInstalled, bFullClientSel, &appFullClient);
2661                 bServer = AppVersionOk(bServerInstalled, bServerSel, &appServer);
2662                 bCc = AppVersionOk(bCcInstalled, bCcSel, &appControlCenter);
2663                 bDocs = AppVersionOk(bDocsInstalled, bDocsSel, &appDocs);
2664                 bVersionsOK = bClient && bServer && bCc && bDocs;
2665         endif;
2666         
2667         if (!bVersionsOK) then
2668                 ShowError(@APPS_NOT_SAME_VERSION, SEVERE);
2669                 goto retry;
2670         endif;
2671
2672     TARGETDIR = svDir;
2673     FixTargetPaths();
2674
2675     return nResult;
2676 end;
2677
2678
2679 ///////////////////////////////////////////////////////////////////////////////
2680 //
2681 // Function: DialogShowSdSetupType
2682 //
2683 //  Purpose: This function displays the standard setup type dialog.
2684 //
2685 ///////////////////////////////////////////////////////////////////////////////
2686 function DialogShowSdSetupType()
2687     NUMBER nResult, nType;
2688     STRING szTitle, szMsg, szReserved;
2689
2690 begin
2691
2692     if (svSetupType == "") then
2693         svSetupType = "AFS Server";
2694         endif;
2695         
2696     szTitle = "";
2697     szMsg   = @SETUP_TYPE_MSG;
2698     szReserved = "";
2699
2700         nResult = SdSetupTypeEx(szTitle, szMsg, szReserved, svSetupType, 0);
2701
2702     return nResult;
2703 end;
2704
2705
2706 ///////////////////////////////////////////////////////////////////////////////
2707 //
2708 //  Function: DialogShowSdSelectFolder
2709 //
2710 //  Purpose: This function displays the standard folder selection dialog.
2711 //
2712 //
2713 ///////////////////////////////////////////////////////////////////////////////
2714 function DialogShowSdSelectFolder()
2715     NUMBER nResult;
2716     STRING szTitle, szMsg;
2717 begin
2718     if (SHELL_OBJECT_FOLDER = "") then
2719         SHELL_OBJECT_FOLDER = @FOLDER_NAME;
2720     endif;
2721
2722         // We are going to force the user to use the default folder name.  This is
2723         // because we create the folder unlogged, and must therefore remove it
2724         // ourselves in our uninstall dll (which we do because IS doesn't handle
2725         // removing them correctly).  Therefore, we must know the name of the
2726         // folder so we can remove it during uninstall.  Also, the user can install
2727         // the AFS components during several executions of the install program,
2728         // and we don't want to allow them to pick a different folder each time.
2729         // We could solve these problems in code but we don't have time, so we
2730         // are going to force them to use our default folder name.
2731         return 0;
2732
2733     szTitle    = "";
2734     szMsg      = "";
2735     nResult    = SdSelectFolder( szTitle, szMsg, SHELL_OBJECT_FOLDER);
2736
2737     return nResult;
2738 end;
2739
2740
2741 ///////////////////////////////////////////////////////////////////////////////
2742 //
2743 //  Function: DialogShowSdFinishReboot
2744 //
2745 //  Purpose: This function will show the last dialog of the product.
2746 //           It will allow the user to reboot and/or show some readme text.
2747 //
2748 ///////////////////////////////////////////////////////////////////////////////
2749 function DialogShowSdFinishReboot()
2750     NUMBER nResult, nDefOptions;
2751     STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;
2752     NUMBER bOpt1, bOpt2;
2753 begin
2754     if (!BATCH_INSTALL) then
2755         bOpt1 = FALSE;
2756         bOpt2 = FALSE;
2757         szMsg1 = @SETUP_FINISHED_MSG;
2758         szMsg2 = "";
2759         szOption1 = "";
2760         szOption2 = "";
2761         szTitle = "";
2762         nResult = SdFinish(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2 );
2763         return 0;
2764     endif;
2765
2766     nDefOptions = SYS_BOOTMACHINE;
2767     szTitle     = "";
2768     szMsg1      = "";
2769     szMsg2      = "";
2770     nResult     = SdFinishReboot( szTitle, szMsg1, nDefOptions, szMsg2, 0 );
2771
2772     return nResult;
2773 end;
2774
2775
2776 ///////////////////////////////////////////////////////////////////////////////
2777 //
2778 //  Function: ConfigServerService
2779 //
2780 //  Purpose: This function will configure the AFS Server bos service via the
2781 //                       SCM.
2782 //
2783 ///////////////////////////////////////////////////////////////////////////////
2784 function ConfigServerService()
2785     STRING szMsg;
2786     BOOL bError;
2787     number nStatus;
2788 begin
2789     bError = TRUE;
2790
2791     if (!bWSPPInstall) then
2792         szMsg = @CONFIGURING_AFS_SERVER_SERVICE;
2793         SdShowMsg(szMsg, TRUE);
2794     endif;
2795
2796     nStatus = RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
2797     if (nStatus < 0) goto error;
2798
2799     nStatus = InstallServerService(TARGETDIR ^ "\\Server\\usr\\afs\\bin\\bosctlsvc.exe");
2800     if (nStatus < 0) goto error;
2801
2802     bError = FALSE;
2803
2804 error:
2805     if (!bWSPPInstall) then
2806             SdShowMsg(szMsg, FALSE);
2807         endif;
2808
2809     if (bError) then
2810         Sprintf(szMsg, @AFS_SERVER_SERVICE_INSTALL_ERROR, nStatus);
2811         ShowError(szMsg, SEVERE);
2812         bInstallAborted = TRUE;
2813         return -1;
2814     endif;
2815
2816     return 0;
2817 end;
2818
2819
2820 ///////////////////////////////////////////////////////////////////////////////
2821 //
2822 //  Function: ConfigClientService
2823 //
2824 //  Purpose: This function will configure the AFS Client service via the SCM.
2825 //
2826 ///////////////////////////////////////////////////////////////////////////////
2827 function ConfigClientService()
2828     STRING szMsg;
2829     BOOL bError;
2830     number nStatus;
2831 begin
2832     bError = TRUE;
2833
2834         if (!bWSPPInstall) then
2835         szMsg = @CONFIGURING_AFS_CLIENT_SERVICE;
2836         SdShowMsg(szMsg, TRUE);
2837     endif;
2838
2839     nStatus = RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
2840     if (nStatus < 0) goto error;
2841
2842     nStatus = InstallClientService(TARGETDIR ^ "\\Client\\Program\\afsd_service.exe");
2843     if (nStatus < 0) goto error;
2844
2845     bError = FALSE;
2846
2847 error:
2848     if (!bWSPPInstall) then
2849             SdShowMsg(szMsg, FALSE);
2850         endif;
2851
2852     if (bError) then
2853         Sprintf(szMsg, @AFS_CLIENT_SERVICE_INSTALL_ERROR, nStatus);
2854         ShowError(szMsg, SEVERE);
2855         bInstallAborted = TRUE;
2856         return -1;
2857     endif;
2858
2859     return 0;
2860 end;
2861
2862 ///////////////////////////////////////////////////////////////////////////////
2863 //
2864 //  Function: AddPath
2865 //
2866 //  Purpose: This function will add the specified path to the system PATH
2867 //                       environment variable.
2868 //
2869 ///////////////////////////////////////////////////////////////////////////////
2870 function AddPath(szPath)
2871 begin
2872    LongPathToShortPath(szPath);
2873    if (bWin98 || bWin95) then
2874            if (EzBatchAddPath ("Path", szPath, "", AFTER) < 0) then
2875          ShowError(@ADD_PATH_ERROR, WARNING);
2876             endif;
2877     else
2878            if (AddToPath(szPath) < 0) then
2879          ShowError(@ADD_PATH_ERROR, WARNING);
2880             endif;
2881     endif;
2882         return 0;
2883 end;
2884
2885
2886 ///////////////////////////////////////////////////////////////////////////////
2887 //
2888 //  Function: ConfigUninstallDLL
2889 //
2890 //  Purpose: This function will modify the uninstall entry for these products
2891 //                       to use an uninstall dll.
2892 //
2893 ///////////////////////////////////////////////////////////////////////////////
2894 function ConfigUninstallDLL(pApp)
2895     string svValue;
2896     NUMBER nStatus;
2897 begin
2898         if (!pApp->bUseUninstDLL) then
2899                 return 0;
2900         endif;
2901
2902     nStatus = RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
2903     if (nStatus < 0) goto error;
2904
2905     svValue = UNINST + " -c\"" + pApp->szBinPath ^ pApp->szUninstDllName + "\" -f\"" + TARGETDIR ^ pApp->szUninstLogfileName + "\"";
2906
2907     nStatus = RegDBSetKeyValueEx(MSUNINSTALL_KEY ^ pApp->szProductName, "UninstallString", REGDB_STRING, svValue, -1);
2908     if (nStatus < 0) goto error;
2909
2910     return 0;
2911
2912 error:
2913     return nStatus;
2914 end;
2915                 
2916
2917 ///////////////////////////////////////////////////////////////////////////////
2918 //
2919 //  Function: CreateServerDirs
2920 //
2921 //  Purpose: This function will create directories that the server programs
2922 //                       need.  The creation of these is not logged, and so they will be
2923 //                       deleted by the uninstall dll.
2924 //
2925 ///////////////////////////////////////////////////////////////////////////////
2926 function CreateServerDirs()
2927 begin
2928         CreateDir(TARGETDIR ^ "\\Server\\usr\\afs\\logs");
2929         CreateDir(TARGETDIR ^ "\\Server\\usr\\afs\\etc");
2930         CreateDir(TARGETDIR ^ "\\Server\\usr\\afs\\local");
2931 end;
2932
2933
2934 ///////////////////////////////////////////////////////////////////////////////
2935 //
2936 //  Function: GetDateTimeString()
2937 //
2938 //  Purpose: This function will return a string containing the current date
2939 //           and time.
2940 //
2941 ///////////////////////////////////////////////////////////////////////////////
2942 function GetDateTimeString(szDateTime)
2943     STRING szDate, szTime;
2944     NUMBER nDate, nTime;
2945 begin
2946         GetSystemInfo(DATE, nDate, szDate);
2947     GetSystemInfo(TIME, nTime, szTime);
2948
2949     szDateTime = szDate + " " + szTime;
2950 end;
2951
2952
2953 ///////////////////////////////////////////////////////////////////////////////
2954 //
2955 //  Function: SetUserVars()
2956 //
2957 //  Purpose: This function will set at runtime values for user defined variables
2958 //                       we set up in the Registry Entries GUI tool.
2959 //
2960 ///////////////////////////////////////////////////////////////////////////////
2961 function SetUserVars()
2962     number nStatus;
2963     string szInstallDate;
2964     string szDesc;
2965     string szTitle;
2966     string szReleaseType;
2967 begin
2968     // Set the install date variable's value
2969     GetDateTimeString(szInstallDate);
2970
2971         ComponentSetTarget(MEDIA, "<INSTALL_DATE>", szInstallDate);
2972
2973         // Set the proper client logon dll
2974         if (bFullClientSel) then
2975                 ComponentSetTarget(MEDIA, "<LOGON_DLL>", TARGETDIR ^ FULL_CLIENT_LOGON_DLL);
2976         elseif (bLightClientSel) then
2977                 ComponentSetTarget(MEDIA, "<LOGON_DLL>", TARGETDIR ^ LIGHT_CLIENT_LOGON_DLL);
2978         endif;
2979
2980         // Set the client description and title values
2981         if (bFullClientSel || bLightClientSel) then
2982
2983                 if (bFullClientSel) then
2984                         szDesc = @CLIENT_DESC;
2985                         szTitle = @CLIENT_TITLE;
2986                 else
2987                         szDesc = @LIGHT_CLIENT_DESC;
2988                         szTitle = @LIGHT_CLIENT_TITLE;
2989                 endif;
2990
2991                 ComponentSetTarget(MEDIA, "<CLIENT_DESC>", szDesc);
2992                 ComponentSetTarget(MEDIA, "<CLIENT_TITLE>", szTitle);
2993         endif;
2994
2995         if (bServerSel) then
2996                 ComponentSetTarget(MEDIA, "<EVENT_MSG_DLL>", TARGETDIR ^ "Common\\afseventmsg_" + szCodePage + ".dll");
2997         endif;
2998
2999         szReleaseType = @PRODUCT_VERSION_RELEASE_TYPE;
3000         ComponentSetTarget(MEDIA, "<RELEASE_TYPE>", szReleaseType);
3001
3002 done:
3003         return nStatus;
3004 end;
3005
3006
3007 ///////////////////////////////////////////////////////////////////////////////
3008 //
3009 //  Function: SetNetworkProviderOrder()
3010 //
3011 //  Purpose: This function will add the AFS Client service name to the
3012 //                       ProviderOrder value of the
3013 //                       HKLM\SYSTEM\CurrentControlSet\ControlNetworkProvider\Order key.
3014 //                       It makes a call to the setup dll to do this.
3015 ///////////////////////////////////////////////////////////////////////////////
3016 function SetNetworkProviderOrder()
3017         int nStatus;
3018 begin
3019         nStatus = AddToNetworkProviderOrder(CLIENT_SERVICE_NAME);
3020         if (nStatus < 0) then
3021                 ShowError(@SET_NETWORK_PROVIDER_ERROR, SEVERE);
3022         endif;
3023
3024         return nStatus;
3025 end;
3026
3027
3028 ///////////////////////////////////////////////////////////////////////////////
3029 //
3030 //  Function: CreateRegistrySets()
3031 //
3032 //  Purpose: This function will create the registry entries for each resgistry
3033 //                       set in the passed in string.  The string must be a comma separated
3034 //                       list of registry sets created using the IS Registry Entries GUI.
3035 //
3036 ///////////////////////////////////////////////////////////////////////////////
3037 function CreateRegistrySets(szRegistrySets)
3038         int nRegSetListID;
3039         int nResult;
3040         string szRegSet;
3041 begin
3042         nRegSetListID = ListCreate(STRINGLIST);
3043         
3044         StrGetTokens(nRegSetListID, szRegistrySets, ",");
3045
3046         nResult = ListGetFirstString(nRegSetListID, szRegSet);
3047         while (nResult != END_OF_LIST)
3048 //              MessageBox(szRegSet, INFORMATION);
3049                 CreateRegistrySet(szRegSet);
3050                 nResult = ListGetNextString(nRegSetListID, szRegSet);
3051         endwhile;
3052         
3053         ListDestroy(nRegSetListID);
3054 end;
3055
3056
3057 ///////////////////////////////////////////////////////////////////////////////
3058 //
3059 //  Function: ConfigAfsCreds()
3060 //
3061 //  Purpose: This function will config the AFS Client Credentials tool.
3062 //
3063 ///////////////////////////////////////////////////////////////////////////////
3064 function ConfigAfsCreds()
3065 int nResult;
3066 begin
3067         nResult = LaunchAppAndWait(TARGETDIR ^ "Client\\Program\\afscreds.exe", "/install", WAIT);
3068         if (nResult < 0) then
3069                 ShowError(@CONFIGURING_AFS_CREDS_ERROR, INFORMATION);
3070         endif;
3071         
3072         return nResult;
3073 end;
3074
3075
3076 ///////////////////////////////////////////////////////////////////////////////
3077 //
3078 //  Function: IsAppInstalled
3079 //
3080 //  Purpose: This function will determine if an app is installed, and if it is,
3081 //           will set its iVer info.
3082 //
3083 ///////////////////////////////////////////////////////////////////////////////
3084 function IsAppInstalled(pApp)
3085 int nResult;
3086 int nSize;
3087 int nType;
3088 string szKey;
3089 string szMajorVersion, szMinorVersion, szPatchLevel, szBetaLevel, szReleaseType, szTitle;
3090 begin
3091     nResult = RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
3092     if (nResult < 0) goto error;
3093
3094         szKey = COMPANY_REG_KEY ^ pApp->szProductName ^ "CurrentVersion";
3095
3096         nResult = RegDBGetKeyValueEx(szKey, "MajorVersion", nType, szMajorVersion, nSize);
3097         if (nResult < 0) goto error;
3098         
3099         nResult = RegDBGetKeyValueEx(szKey, "MinorVersion", nType, szMinorVersion, nSize);
3100         if (nResult < 0) goto error;
3101         
3102         nResult = RegDBGetKeyValueEx(szKey, "PatchLevel", nType, szPatchLevel, nSize);
3103         if (nResult < 0) goto error;
3104
3105         nResult = RegDBGetKeyValueEx(szKey, "BetaLevel", nType, szBetaLevel, nSize);
3106         // It's ok for this to fail.  Pre-3.5 3.32 releases did not use this.
3107
3108         nResult = RegDBGetKeyValueEx(szKey, "VersionString", nType, szTitle, nSize);
3109         if (nResult < 0) goto error;
3110
3111         nResult = RegDBGetKeyValueEx(szKey, "ReleaseType", nType, szReleaseType, nSize);
3112         if (nResult < 0) then
3113                 if ((pApp->szProductName = "AFS Client") && (szTitle = "3.4a")) then
3114                         // This value won't exist for 3.4a clients
3115                         szReleaseType = RELEASE_TYPE_GA;
3116                 else
3117                         // This value won't exist for any 3.5 beta versions
3118                         szReleaseType = RELEASE_TYPE_BETA;
3119                 endif;
3120         endif;
3121
3122         SetupVerInfo(pApp, szMajorVersion, szMinorVersion, szPatchLevel, szBetaLevel, szReleaseType, szTitle, TRUE);
3123         
3124         return TRUE;
3125
3126 error:
3127         return FALSE;
3128 end;
3129         
3130
3131 ///////////////////////////////////////////////////////////////////////////////
3132 //
3133 //  Function: LocalizeComponents()
3134 //
3135 //  Purpose: This function updates all components to use localized text
3136 //           in their status fields as appropriate
3137 //
3138 ///////////////////////////////////////////////////////////////////////////////
3139 function LocalizeComponents()
3140 begin
3141         LocalizeComponentStatusText ("Client\\Client_Common");
3142         LocalizeComponentStatusText ("Client\\Client_Program\\Client_Headers\\Client_Afs_Headers");
3143         LocalizeComponentStatusText ("Client\\Client_Program\\Client_Headers\\Client_Main_Headers");
3144         LocalizeComponentStatusText ("Client\\Client_Program\\Client_Headers\\Client_Rx_Headers");
3145         LocalizeComponentStatusText ("Client\\Client_Program\\Client_Headers");
3146         LocalizeComponentStatusText ("Client\\Client_Program\\Client_Sample");
3147         LocalizeComponentStatusText ("Client\\Client_Program");
3148         LocalizeComponentStatusText ("Client\\Client_System32");
3149         LocalizeComponentStatusText ("Client\\Client_WinDir");
3150         LocalizeComponentStatusText ("Client");
3151         LocalizeComponentStatusText ("Components");
3152         LocalizeComponentStatusText ("Control_Center\\Control_Center_Common");
3153         LocalizeComponentStatusText ("Control_Center\\Control_Center_Program");
3154         LocalizeComponentStatusText ("Control_Center\\Control_Center_System32");
3155         LocalizeComponentStatusText ("Control_Center\\Control_Center_WinDir");
3156         LocalizeComponentStatusText ("Control_Center");
3157         LocalizeComponentStatusText ("Documentation\\English\\Cmd_Ref");
3158         LocalizeComponentStatusText ("Documentation\\English\\Doc_Misc");
3159         LocalizeComponentStatusText ("Documentation\\English\\Sys_Admin_Guide");
3160         LocalizeComponentStatusText ("Documentation\\English");
3161         LocalizeComponentStatusText ("Documentation\\German\\Cmd_Ref");
3162         LocalizeComponentStatusText ("Documentation\\German\\Doc_Misc");
3163         LocalizeComponentStatusText ("Documentation\\German\\Sys_Admin_Guide");
3164         LocalizeComponentStatusText ("Documentation\\German");
3165         LocalizeComponentStatusText ("Documentation\\Japanese\\Cmd_Ref");
3166         LocalizeComponentStatusText ("Documentation\\Japanese\\Doc_Misc");
3167         LocalizeComponentStatusText ("Documentation\\Japanese\\Sys_Admin_Guide");
3168         LocalizeComponentStatusText ("Documentation\\Japanese");
3169         LocalizeComponentStatusText ("Documentation\\Korean\\Cmd_Ref");
3170         LocalizeComponentStatusText ("Documentation\\Korean\\Doc_Misc");
3171         LocalizeComponentStatusText ("Documentation\\Korean\\Sys_Admin_Guide");
3172         LocalizeComponentStatusText ("Documentation\\Korean");
3173         LocalizeComponentStatusText ("Documentation\\Portuguese\\Cmd_Ref");
3174         LocalizeComponentStatusText ("Documentation\\Portuguese\\Doc_Misc");
3175         LocalizeComponentStatusText ("Documentation\\Portuguese\\Sys_Admin_Guide");
3176         LocalizeComponentStatusText ("Documentation\\Portuguese");
3177         LocalizeComponentStatusText ("Documentation\\Simp_Chinese\\Cmd_Ref");
3178         LocalizeComponentStatusText ("Documentation\\Simp_Chinese\\Doc_Misc");
3179         LocalizeComponentStatusText ("Documentation\\Simp_Chinese\\Sys_Admin_Guide");
3180         LocalizeComponentStatusText ("Documentation\\Simp_Chinese");
3181         LocalizeComponentStatusText ("Documentation\\Spanish\\Cmd_Ref");
3182         LocalizeComponentStatusText ("Documentation\\Spanish\\Doc_Misc");
3183         LocalizeComponentStatusText ("Documentation\\Spanish\\Sys_Admin_Guide");
3184         LocalizeComponentStatusText ("Documentation\\Spanish");
3185         LocalizeComponentStatusText ("Documentation\\Trad_Chinese\\Cmd_Ref");
3186         LocalizeComponentStatusText ("Documentation\\Trad_Chinese\\Doc_Misc");
3187         LocalizeComponentStatusText ("Documentation\\Trad_Chinese\\Sys_Admin_Guide");
3188         LocalizeComponentStatusText ("Documentation\\Trad_Chinese");
3189         LocalizeComponentStatusText ("Documentation");
3190         LocalizeComponentStatusText ("Info");
3191         LocalizeComponentStatusText ("Languages\\Lang_English");
3192         LocalizeComponentStatusText ("Languages\\Lang_German");
3193         LocalizeComponentStatusText ("Languages\\Lang_Japanese");
3194         LocalizeComponentStatusText ("Languages\\Lang_Korean");
3195         LocalizeComponentStatusText ("Languages\\Lang_Portuguese");
3196         LocalizeComponentStatusText ("Languages\\Lang_Simp_Chinese");
3197         LocalizeComponentStatusText ("Languages\\Lang_Spanish");
3198         LocalizeComponentStatusText ("Languages\\Lang_Trad_Chinese");
3199         LocalizeComponentStatusText ("Languages");
3200         LocalizeComponentStatusText ("Light_Client\\Win95\\Light95_Client_Common");
3201         LocalizeComponentStatusText ("Light_Client\\Win95\\Light95_Client_Program");
3202         LocalizeComponentStatusText ("Light_Client\\Win95\\Light95_Client_System32");
3203         LocalizeComponentStatusText ("Light_Client\\Win95\\Light95_Client_WinDir");
3204         LocalizeComponentStatusText ("Light_Client\\Win95");
3205         LocalizeComponentStatusText ("Light_Client\\Win98\\Light_Client_Common");
3206         LocalizeComponentStatusText ("Light_Client\\Win98\\Light_Client_Program");
3207         LocalizeComponentStatusText ("Light_Client\\Win98\\Light_Client_System32");
3208         LocalizeComponentStatusText ("Light_Client\\Win98\\Light_Client_WinDir");
3209         LocalizeComponentStatusText ("Light_Client\\Win98");
3210         LocalizeComponentStatusText ("Light_Client");
3211         LocalizeComponentStatusText ("Readme\\English\\Doc_Misc");
3212         LocalizeComponentStatusText ("Readme\\English\\Install_Guide");
3213         LocalizeComponentStatusText ("Readme\\English\\Release_Notes");
3214         LocalizeComponentStatusText ("Readme\\English");
3215         LocalizeComponentStatusText ("Readme\\German\\Doc_Misc");
3216         LocalizeComponentStatusText ("Readme\\German\\Install_Guide");
3217         LocalizeComponentStatusText ("Readme\\German\\Release_Notes");
3218         LocalizeComponentStatusText ("Readme\\German");
3219         LocalizeComponentStatusText ("Readme\\Japanese\\Doc_Misc");
3220         LocalizeComponentStatusText ("Readme\\Japanese\\Install_Guide");
3221         LocalizeComponentStatusText ("Readme\\Japanese\\Release_Notes");
3222         LocalizeComponentStatusText ("Readme\\Japanese");
3223         LocalizeComponentStatusText ("Readme\\Korean\\Doc_Misc");
3224         LocalizeComponentStatusText ("Readme\\Korean\\Install_Guide");
3225         LocalizeComponentStatusText ("Readme\\Korean\\Release_Notes");
3226         LocalizeComponentStatusText ("Readme\\Korean");
3227         LocalizeComponentStatusText ("Readme\\Portuguese\\Doc_Misc");
3228         LocalizeComponentStatusText ("Readme\\Portuguese\\Install_Guide");
3229         LocalizeComponentStatusText ("Readme\\Portuguese\\Release_Notes");
3230         LocalizeComponentStatusText ("Readme\\Portuguese");
3231         LocalizeComponentStatusText ("Readme\\Simp_Chinese\\Doc_Misc");
3232         LocalizeComponentStatusText ("Readme\\Simp_Chinese\\Install_Guide");
3233         LocalizeComponentStatusText ("Readme\\Simp_Chinese\\Release_Notes");
3234         LocalizeComponentStatusText ("Readme\\Simp_Chinese");
3235         LocalizeComponentStatusText ("Readme\\Spanish\\Doc_Misc");
3236         LocalizeComponentStatusText ("Readme\\Spanish\\Install_Guide");
3237         LocalizeComponentStatusText ("Readme\\Spanish\\Release_Notes");
3238         LocalizeComponentStatusText ("Readme\\Spanish");
3239         LocalizeComponentStatusText ("Readme\\Trad_Chinese\\Doc_Misc");
3240         LocalizeComponentStatusText ("Readme\\Trad_Chinese\\Install_Guide");
3241         LocalizeComponentStatusText ("Readme\\Trad_Chinese\\Release_Notes");
3242         LocalizeComponentStatusText ("Readme\\Trad_Chinese");
3243         LocalizeComponentStatusText ("Readme");
3244         LocalizeComponentStatusText ("Server\\Server_Common");
3245         LocalizeComponentStatusText ("Server\\Server_Program");
3246         LocalizeComponentStatusText ("Server\\Server_System32");
3247         LocalizeComponentStatusText ("Server\\Server_WinDir");
3248         LocalizeComponentStatusText ("Server");
3249 end;
3250
3251
3252 ///////////////////////////////////////////////////////////////////////////////
3253 //
3254 //  Function: LocalizeComponentStatusText()
3255 //
3256 //  Purpose: This function updates one component to use localized text
3257 //           in its status fields as appropriate
3258 //
3259 ///////////////////////////////////////////////////////////////////////////////
3260 function LocalizeComponentStatusText (svComponent)
3261         NUMBER dwResult;
3262         STRING svOriginal;
3263         STRING svLocalized;
3264 begin
3265         ComponentGetData (MEDIA, svComponent, COMPONENT_FIELD_STATUS, dwResult, svOriginal);
3266
3267         if (svOriginal == "CLIENT") then
3268                 svLocalized = @STATUS_INSTALLING_CLIENT;
3269         elseif (svOriginal == "SERVER") then
3270                 svLocalized = @STATUS_INSTALLING_SERVER;
3271         elseif (svOriginal == "CCENTER") then
3272                 svLocalized = @STATUS_INSTALLING_CCENTER;
3273         elseif (svOriginal == "LIGHT") then
3274                 svLocalized = @STATUS_INSTALLING_LIGHT;
3275         elseif (svOriginal == "HEADERS") then
3276                 svLocalized = @STATUS_INSTALLING_HEADERS;
3277         elseif (svOriginal == "DOCS") then
3278                 svLocalized = @STATUS_INSTALLING_DOCS;
3279         elseif (svOriginal == "LANGUAGE") then
3280                 svLocalized = @STATUS_INSTALLING_LANGUAGE;
3281         else
3282                 svLocalized = "";
3283         endif;
3284
3285         ComponentSetData(MEDIA, svComponent, COMPONENT_FIELD_STATUS, 0, svLocalized);
3286 end;
3287
3288
3289 ///////////////////////////////////////////////////////////////////////////////
3290 //
3291 //  Function: DetectInstalledComponents()
3292 //
3293 //  Purpose: This function will detect if any of our components is already
3294 //           installed.
3295 //
3296 ///////////////////////////////////////////////////////////////////////////////
3297 function DetectInstalledComponents()
3298 begin
3299         if (bWinNT) then
3300                 bClientInstalled = IsAppInstalled(&appFullClient);
3301                 bServerInstalled = IsAppInstalled(&appServer);
3302                 bCcInstalled = IsAppInstalled(&appControlCenter);
3303                 bDocsInstalled = IsAppInstalled(&appDocs);
3304         else
3305                 // The light client uses the client's registry entries.  There is a light
3306                 // client entry, but it contains nothing under it.  IS makes it but we
3307                 // don't use it.
3308                 bLightClientInstalled = IsAppInstalled(&appLightClient);
3309         endif;
3310 end;
3311
3312
3313 ///////////////////////////////////////////////////////////////////////////////
3314 //
3315 // Function: ParseCommandLine
3316 //
3317 //  Purpose: This function parses the command line to set up a silent install
3318 //
3319 ///////////////////////////////////////////////////////////////////////////////
3320 function ParseCommandLine()
3321     NUMBER nResult;
3322     STRING szTemp, szResult[MAX_STRING_LEN], szParms;
3323     LIST listParms;
3324 begin
3325     bWSPPInstall = FALSE;
3326         bPreinstallReplace = FALSE;
3327
3328     szParms = CMDLINE;
3329
3330     // Need a list to hold the parms
3331     listParms = ListCreate(STRINGLIST);
3332
3333     // Break parms into semicolon separated tokens and put into list
3334     if (StrGetTokens(listParms, szParms, ";") = 0 ) then
3335        nResult = ListGetFirstString(listParms, szResult);
3336
3337         //  Do until the end of the list
3338         while (nResult != END_OF_LIST)
3339                         if (StrFind(szResult, "DIR=") > -1 ) then
3340                 nResult = StrSub(szTemp, szResult, 4, MAX_STRING_LEN);
3341                 TARGETDIR = szTemp + "\\AFS";
3342                 
3343                 elseif (StrFind(szResult, "P=") > -1 ) then
3344                 nResult = StrSub(szTemp, szResult, StrFind(szResult, "P=") + 2, 1);
3345                 if (StrFind(szTemp, "Y") > -1 ) then
3346                         bPreinstallReplace = TRUE;
3347                 endif;
3348
3349                 elseif (StrFind(szResult, "C=") > -1 ) then
3350                         ProcessCompsOnCmdLn(szResult);
3351                 endif;
3352
3353                         nResult = ListGetNextString(listParms, szResult);
3354                 endwhile;
3355         endif;
3356 end;
3357
3358
3359 ///////////////////////////////////////////////////////////////////////////////
3360 //
3361 // Function: ProcessCompsOnCmdLn
3362 //
3363 //  Purpose: This function puts the components in a list and
3364 //           checks for setup types on the command line.
3365 //
3366 //
3367 ///////////////////////////////////////////////////////////////////////////////
3368 function ProcessCompsOnCmdLn(szParms)
3369      NUMBER nResult, nIndex;
3370      STRING szComp;
3371 begin
3372     bWSPPInstall = TRUE;
3373
3374         // Strip c= off cmdln string
3375         nResult = StrSub(szParms, szParms, StrFind(szParms, "C=") + 2, StrLength(szParms) - 2);
3376
3377         // Get each component from the cmd line
3378     while (StrLength(szParms))
3379         nIndex = StrSub(szComp, szParms, 0, StrFind(szParms, ","));
3380         if (!nIndex) then  // if comma not found then last item in list
3381                 szComp = szParms;
3382                 nIndex = StrLength(szComp); // for extracting this string
3383                 endif;
3384
3385         if (StrFind(szComp, "Client") > -1) then
3386                 bFullClientSel = TRUE;
3387         elseif (StrFind(szComp, "Server") > -1) then
3388                 bServerSel = TRUE;
3389         elseif (StrFind(szComp, "ControlCtr") > -1) then
3390                 bCcSel = TRUE;
3391         endif;
3392
3393        // Delete component from the command line string
3394         StrSub(szParms, szParms, nIndex + 1, StrLength(szParms));
3395      endwhile;
3396 end;
3397
3398
3399 ///////////////////////////////////////////////////////////////////////////////
3400 //
3401 // Function: RemoveInstalledBits
3402 //
3403 //  Purpose: This function silently uninstalls a product.
3404 //
3405 ///////////////////////////////////////////////////////////////////////////////
3406 function RemoveInstalledBits(szProductName)
3407         int nStatus;
3408         int nType;
3409         string szValue[MAX_STRING_LEN];
3410         string szProgram[256];
3411         string szCmdLine[128];
3412         int nSize;
3413         int nIndex;
3414 begin
3415         // Check for a special case - version 3.4a of the AFS Client
3416         if ((szProductName = "AFS Client") && (appFullClient.iVer.szTitle = "3.4a")) then
3417                 return Eradicate34Client();
3418         endif;
3419
3420     nStatus = RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
3421     if (nStatus < 0) goto error;
3422
3423         nStatus = RegDBGetKeyValueEx(MSUNINSTALL_KEY ^ szProductName, "UninstallString", nType, szValue, nSize);
3424     if (nStatus < 0) goto error;
3425
3426         nIndex = StrFind(szValue, " ");
3427         if (nIndex < 0) goto error;
3428         
3429         StrSub(szProgram, szValue, 0, nIndex);
3430         StrSub(szCmdLine, szValue, nIndex + 1, 128);
3431
3432         // Make the uninstall run silently
3433         szCmdLine = szCmdLine + " -a";
3434
3435         nStatus = LaunchAppAndWait(szProgram, szCmdLine, WAIT);
3436         if (nStatus < 0) goto error;
3437
3438         return 0;
3439
3440 error:
3441         return nStatus;
3442 end;
3443
3444
3445 ///////////////////////////////////////////////////////////////////////////////
3446 //
3447 // Function: AddShortCut
3448 //
3449 //  Purpose: Adds a short cut to the start menu.
3450 //
3451 ///////////////////////////////////////////////////////////////////////////////
3452 function AddShortCut(szFolder, szName, szCmdPath, szArgs)
3453         int result;
3454         string szCmd;
3455 begin
3456         szCmdPath = TARGETDIR ^ szCmdPath;
3457         LongPathToQuote(szCmdPath, TRUE);
3458         
3459         szCmd = szCmdPath + " " + szArgs;
3460         
3461         nResult = AddFolderIcon(SHELL_OBJECT_FOLDER ^ szFolder, szName, szCmd, "", "", 0, "", REPLACE);
3462         
3463         return nResult;
3464 end;
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492 ///////////////////////////////////////////////////////////////////////////////
3493 //
3494 // Function: CreateStartMenuEntries
3495 //
3496 //  Purpose: This function creates start menu entries for our apps.
3497 //
3498 ///////////////////////////////////////////////////////////////////////////////
3499 function CreateStartMenuEntries()
3500 begin
3501         if (bServerSel) then
3502                 AddShortCut(@SERVER_GROUP_NAME, @CFG_WIZARD_ITEM_NAME, CFG_WIZARD_CMD_PATH, CFG_WIZARD_ARGS);
3503         endif;
3504         
3505         if (bFullClientSel) then
3506                 AddShortCut(@CLIENT_GROUP_NAME, @CREDS_TOOL_ITEM_NAME, CREDS_TOOL_CMD_PATH, CREDS_TOOL_ARGS);
3507                 AddShortCut(@CLIENT_GROUP_NAME, @CLIENT_HELP_ITEM_NAME, CLIENT_HELP_CMD_PATH, CLIENT_HELP_ARGS);
3508         endif;
3509         
3510         if (bCcSel) then
3511                 AddShortCut(@CCENTER_GROUP_NAME, @SERVER_MANAGER_ITEM_NAME, SERVER_MANAGER_CMD_PATH, SERVER_MANAGER_ARGS);
3512                 AddShortCut(@CCENTER_GROUP_NAME, @ACCT_MANAGER_ITEM_NAME, ACCT_MANAGER_CMD_PATH, ACCT_MANAGER_ARGS);
3513         endif;
3514         
3515         if (bLightClientSel) then
3516                 AddShortCut(@LIGHT_GROUP_NAME, @CREDS_TOOL_ITEM_NAME, CREDS_TOOL_CMD_PATH, CREDS_TOOL_ARGS);
3517                 AddShortCut(@LIGHT_GROUP_NAME, @LIGHT_CLIENT_HELP_ITEM_NAME, LIGHT_CLIENT_HELP_CMD_PATH, LIGHT_CLIENT_HELP_ARGS);
3518         endif;
3519
3520         AddShortCut("", @DOCUMENTATION_ITEM_NAME, DOCUMENTATION_CMD_PATH, DOCUMENTATION_ARGS);
3521 end;
3522
3523
3524 ///////////////////////////////////////////////////////////////////////////////
3525 //
3526 // Function: ShowError
3527 //
3528 //  Purpose: This function shows an error to the user when not in silent mode,
3529 //           and will log an error to a file when in silent mode.
3530 //
3531 ///////////////////////////////////////////////////////////////////////////////
3532 function ShowError(szMsg, nType)
3533     string szType;
3534     int nFileID;
3535 begin
3536     if (!bWSPPInstall) then
3537         MessageBox(szMsg, nType);
3538         return;
3539     endif;
3540
3541     switch (nType)
3542         case WARNING:       szType = "Warning: ";
3543         case SEVERE:        szType = "Error: ";
3544         case INFORMATION:   szType = "Note: ";
3545         default:            szType = "Unknown error type: ";
3546     endswitch;
3547
3548     WriteToInstallErrorLog(szType + szMsg);
3549 end;
3550
3551
3552 ///////////////////////////////////////////////////////////////////////////////
3553 //
3554 // Function: CheckCopyCellServDB
3555 //
3556 //  Purpose: During install the CellServDB file is copied into the Common dir.
3557 //                       If the user does not already have this file, we will copy it for
3558 //           them into the windows directory.  If they already do have the
3559 //           file, then we will do nothing.
3560 ///////////////////////////////////////////////////////////////////////////////
3561 function CheckCopyCellServDB()
3562         int nResult;
3563         string szResult;
3564 begin
3565         nResult = FindFile(WINDIR, CELLSERVDB_FILENAME, szResult);
3566         if (nResult < 0) then
3567                 VarSave(SRCTARGETDIR);
3568                 SRCDIR = TARGETDIR ^ "Common";
3569                 TARGETDIR = WINDIR;
3570                 CopyFile(CELLSERVDB_FILENAME, CELLSERVDB_FILENAME);
3571                 VarRestore(SRCTARGETDIR);
3572         endif;
3573 end;
3574
3575
3576 // --- include script file section ---
3577 #include "sddialog.rul"