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