~ubuntu-branches/ubuntu/trusty/happy/trusty-proposed

« back to all changes in this revision

Viewing changes to happy/InstallShield/Script Files/setup.rul

  • Committer: Bazaar Package Importer
  • Author(s): Ian Lynagh (wibble)
  • Date: 2006-10-26 22:52:14 UTC
  • mfrom: (1.2.2 upstream) (3.1.1 dapper)
  • Revision ID: james.westby@ubuntu.com-20061026225214-6jmf0n3ykkc9elyw
Tags: 1.16~rc2-1
* New upstream (release candidate) version.
* Removed happy/ prefixes from various paths in debian/rules and
  debian/docs.
* doc/configure generated by autoconf is in the Debian diff.
* Build using cabal:
  * Various debian/rules changes.
  * Create debian/get_version.hs for extracting the version from the cabal
    file.
  * Requires ghc6 >= 6.4.2.
  * No longer tries to detect platform. Closes: #340325, #332979.
  * Removed autotool-dev build-dep.
* Add 'XSLTPROC_OPTS = --nonet' to doc/config.mk.in.
* Remove src/Parser.ly and src/AttrGrammarParser.ly before cleaning so
  the generated files don't get cleaned.
* Set Standards-Version to 3.7.2 (no changes needed).
* Removed PS and DVI stanzas from debian/doc-base as we don't build
  the documentation those ways.
* Removed content-free postinst and prerm.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
  // Include header file
2
 
#include "ifx.h"
3
 
 
4
 
////////////////////// string defines ////////////////////////////
5
 
 
6
 
#define UNINST_LOGFILE_NAME      "Uninst.isu"
7
 
 
8
 
//////////////////// installation declarations ///////////////////
9
 
 
10
 
  // ---- script prototypes -----
11
 
 
12
 
     // generated
13
 
     prototype ShowDialogs();
14
 
     prototype MoveFileData();
15
 
     prototype HandleMoveDataError( NUMBER );
16
 
     prototype ProcessBeforeDataMove();
17
 
     prototype ProcessAfterDataMove();
18
 
     prototype SetupRegistry();
19
 
     prototype SetupFolders();
20
 
     prototype CleanUpInstall();
21
 
     prototype SetupInstall();
22
 
     prototype SetupScreen();
23
 
     prototype CheckRequirements();
24
 
     prototype DialogShowSdShowInfoList();
25
 
     prototype DialogShowSdAskDestPath();
26
 
     prototype DialogShowSdSetupType();
27
 
     prototype DialogShowSdComponentDialog2();
28
 
     prototype DialogShowSdWelcome();
29
 
     prototype DialogShowSdFinishReboot();
30
 
 
31
 
     // your prototypes
32
 
     prototype ForwardSlashify ( STRING, BYREF STRING );
33
 
     prototype CreateHappyScript ( STRING, STRING );
34
 
     prototype CreateHappyBat ( STRING );
35
 
 
36
 
  // ----- global variables ------
37
 
 
38
 
     // generated
39
 
     BOOL        bWinNT, bIsShellExplorer, bInstallAborted, bIs32BitSetup;
40
 
     STRING      svDir;
41
 
     STRING      svName, svCompany, svSerial;
42
 
     STRING      szAppPath;
43
 
     STRING      svSetupType;
44
 
     LIST        listPath;
45
 
 
46
 
 
47
 
     // your global variables
48
 
     STRING      szBinDir, szBinDirUnslashed,
49
 
                 szLibDir, szLibDirUnslashed,
50
 
                 szLibExecDir;
51
 
 
52
 
 
53
 
///////////////////////////////////////////////////////////////////////////////
54
 
//
55
 
//   MAIN PROGRAM
56
 
//
57
 
//      The setup begins here by hiding the visible setup
58
 
//      window.  This is done to allow all the titles, images, etc. to
59
 
//      be established before showing the main window.  The following
60
 
//      logic then performs the setup in a series of steps.
61
 
//
62
 
///////////////////////////////////////////////////////////////////////////////
63
 
program
64
 
    Disable( BACKGROUND );
65
 
 
66
 
    CheckRequirements();
67
 
 
68
 
    SetupInstall();
69
 
 
70
 
    SetupScreen();
71
 
 
72
 
    if (ShowDialogs()<0) goto end_install;
73
 
 
74
 
    if (ProcessBeforeDataMove()<0) goto end_install;
75
 
 
76
 
    if (MoveFileData()<0) goto end_install;
77
 
 
78
 
    if (ProcessAfterDataMove()<0) goto end_install;
79
 
 
80
 
    if (SetupRegistry()<0) goto end_install;
81
 
 
82
 
    if (SetupFolders()<0) goto end_install;
83
 
 
84
 
 
85
 
  end_install:
86
 
 
87
 
    CleanUpInstall();
88
 
 
89
 
     // If an unrecoverable error occurred, clean up the partial installation.
90
 
     // Otherwise, exit normally.
91
 
 
92
 
    if (bInstallAborted) then
93
 
        abort;
94
 
    endif;
95
 
 
96
 
endprogram
97
 
 
98
 
///////////////////////////////////////////////////////////////////////////////
99
 
//                                                                           //
100
 
// Function:  ShowDialogs                                                    //
101
 
//                                                                           //
102
 
//  Purpose:  This function manages the display and navigation               //
103
 
//            the standard dialogs that exist in a setup.                    //
104
 
//                                                                           //
105
 
///////////////////////////////////////////////////////////////////////////////
106
 
function ShowDialogs()
107
 
    NUMBER  nResult;
108
 
 begin
109
 
 
110
 
    Dlg_Start:
111
 
        // beginning of dialogs label
112
 
 
113
 
    Dlg_SdWelcome:
114
 
        nResult = DialogShowSdWelcome();
115
 
        if (nResult = BACK) goto Dlg_Start;
116
 
 
117
 
    Dlg_SdShowInfoList:
118
 
        nResult = DialogShowSdShowInfoList();
119
 
        if (nResult = BACK) goto Dlg_SdWelcome;
120
 
 
121
 
    Dlg_SdAskDestPath:
122
 
        nResult = DialogShowSdAskDestPath();
123
 
        if (nResult = BACK) goto Dlg_SdShowInfoList;
124
 
 
125
 
    Dlg_SdSetupType:
126
 
        nResult = DialogShowSdSetupType();
127
 
        if (nResult = BACK) goto Dlg_SdAskDestPath;
128
 
 
129
 
    Dlg_SdComponentDialog2:
130
 
        if ((nResult = BACK) && (svSetupType != "Custom") && (svSetupType != "")) then
131
 
           goto Dlg_SdSetupType;
132
 
        endif;
133
 
        nResult = DialogShowSdComponentDialog2();
134
 
        if (nResult = BACK) goto Dlg_SdSetupType;
135
 
 
136
 
    Dlg_SdSelectFolder:
137
 
        //nResult = DialogShowSdSelectFolder();
138
 
        //if (nResult = BACK) goto Dlg_SdComponentDialog2;
139
 
 
140
 
    return 0;
141
 
 
142
 
 end;
143
 
 
144
 
///////////////////////////////////////////////////////////////////////////////
145
 
//                                                                           //
146
 
// Function: ProcessBeforeDataMove                                           //
147
 
//                                                                           //
148
 
//  Purpose: This function performs any necessary operations prior to the    //
149
 
//           actual data move operation.                                     //
150
 
//                                                                           //
151
 
///////////////////////////////////////////////////////////////////////////////
152
 
function ProcessBeforeDataMove()
153
 
    STRING svLogFile;
154
 
    NUMBER nResult;
155
 
 begin
156
 
 
157
 
  InstallationInfo( @COMPANY_NAME, @PRODUCT_NAME, @PRODUCT_VERSION, @PRODUCT_KEY );
158
 
 
159
 
  svLogFile = UNINST_LOGFILE_NAME;
160
 
 
161
 
  nResult = DeinstallStart( svDir, svLogFile, @UNINST_KEY, 0 );
162
 
  if (nResult < 0) then
163
 
      MessageBox( @ERROR_UNINSTSETUP, WARNING );
164
 
  endif;
165
 
 
166
 
  szAppPath = TARGETDIR; // TODO : if your application .exe is in a subdir of TARGETDIR then add subdir
167
 
 
168
 
  if ((bIs32BitSetup) && (bIsShellExplorer)) then
169
 
      RegDBSetItem( REGDB_APPPATH, szAppPath );
170
 
      RegDBSetItem( REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY );
171
 
      RegDBSetItem( REGDB_UNINSTALL_NAME, @UNINST_DISPLAY_NAME );
172
 
  endif;
173
 
  // TODO : update any items you want to process before moving the data
174
 
  //
175
 
 
176
 
  ComponentSetTarget( MEDIA, "<DOCDIR>", TARGETDIR ^ "\\doc" );
177
 
 
178
 
  return 0;
179
 
 end;
180
 
 
181
 
///////////////////////////////////////////////////////////////////////////////
182
 
//                                                                           //
183
 
// Function:  MoveFileData                                                   //
184
 
//                                                                           //
185
 
//  Purpose:  This function handles the data movement for                    //
186
 
//            the setup.                                                     //
187
 
//                                                                           //
188
 
///////////////////////////////////////////////////////////////////////////////
189
 
function MoveFileData()
190
 
    NUMBER nResult, nDisk;
191
 
 begin
192
 
 
193
 
  nDisk = 1;
194
 
  SetStatusWindow( 0, "" );
195
 
  Disable( DIALOGCACHE );
196
 
  Enable( STATUS );
197
 
  StatusUpdate( ON, 100 );
198
 
  nResult = ComponentMoveData( MEDIA, nDisk, 0 );
199
 
 
200
 
  HandleMoveDataError( nResult );
201
 
 
202
 
  Disable( STATUS );
203
 
 
204
 
  return nResult;
205
 
 
206
 
 end;
207
 
 
208
 
 
209
 
///////////////////////////////////////////////////////////////////////////////
210
 
//                                                                           //
211
 
// Function: HandleMoveDataError                                             //
212
 
//                                                                           //
213
 
//  Purpose: This function handles the error (if any) during the move data   //
214
 
//           operation.                                                      //
215
 
//                                                                           //
216
 
///////////////////////////////////////////////////////////////////////////////
217
 
function HandleMoveDataError( nResult )
218
 
    STRING szErrMsg, svComponent , svFileGroup , svFile;
219
 
 begin
220
 
 
221
 
  svComponent = "";
222
 
  svFileGroup = "";
223
 
  svFile = "";
224
 
 
225
 
  switch (nResult)
226
 
  case 0:
227
 
       return 0;
228
 
  default:
229
 
       ComponentError ( MEDIA , svComponent , svFileGroup , svFile , nResult );
230
 
       szErrMsg = @ERROR_MOVEDATA  + "\n\n" +
231
 
                  @ERROR_COMPONENT + " " + svComponent + "\n" +
232
 
                  @ERROR_FILEGROUP + " " + svFileGroup + "\n" +
233
 
                  @ERROR_FILE      + " " + svFile;
234
 
       SprintfBox( SEVERE, @TITLE_CAPTIONBAR, szErrMsg, nResult );
235
 
       bInstallAborted = TRUE;
236
 
       return nResult;
237
 
  endswitch;
238
 
 
239
 
 end;
240
 
 
241
 
 
242
 
///////////////////////////////////////////////////////////////////////////////
243
 
//                                                                           //
244
 
// Function: ProcessAfterDataMove                                            //
245
 
//                                                                           //
246
 
//  Purpose: This function performs any necessary operations needed after    //
247
 
//           all data has been moved.                                        //
248
 
//                                                                           //
249
 
///////////////////////////////////////////////////////////////////////////////
250
 
function ProcessAfterDataMove()
251
 
  STRING szPath;
252
 
  STRING szTemp, szRes, szPathEntry, szDrive;
253
 
  NUMBER nvSize,nvType, nResult, nPos, nSuccess;
254
 
  LIST   listDirs;
255
 
 begin
256
 
 
257
 
  return 0;
258
 
 end;
259
 
 
260
 
///////////////////////////////////////////////////////////////////////////////
261
 
//                                                                           //
262
 
// Function: SetupRegistry                                                   //
263
 
//                                                                           //
264
 
//  Purpose: This function makes the registry entries for this setup.        //
265
 
//                                                                           //
266
 
///////////////////////////////////////////////////////////////////////////////
267
 
function SetupRegistry()
268
 
 NUMBER nResult;
269
 
 STRING szProjectDir, szProjectVersionDir, szTargetDir;
270
 
 begin
271
 
 
272
 
  // TODO : Add all your registry entry keys here
273
 
  //
274
 
  //
275
 
 
276
 
  nResult = CreateRegistrySet( "" );
277
 
 
278
 
  // By now, we will have had the following Registry
279
 
  // entries generated (see ProcessBeforeDataMove() ):
280
 
  //
281
 
  // HK_L_M\Software\Glasgow University\Happy\<version no.>
282
 
  //
283
 
  // For Happy, we store and use the install info inside
284
 
  //  HK_L_M\Software\Haskell\Happy (== %ROOT%)
285
 
 
286
 
  // So, we perform the following tasks here:
287
 
  //
288
 
  //  * Checks to see if %ROOT% is defined.
289
 
  //    If not, creates it.
290
 
  //  * Checks for %ROOT%\Version is defined.
291
 
  //  * Create %ROOT%\<version>.
292
 
  //  * Create %ROOT%\<version>\libdir
293
 
  //    (This key will be given a value later.)
294
 
  //  * Create %ROOT%\syslib\  and fill it in
295
 
  //    with the syslibs that has been installed.
296
 
  //  * %ROOT%\syslib\name\<way>
297
 
  //    is added for each kind (e.g., seq, conc)
298
 
  //    syslib we're installing.
299
 
 
300
 
  // When we eventually reach the end, the registry
301
 
  // should be ready for use by the installed app.
302
 
 
303
 
  // Check to see if we've already installed
304
 
  // a version of Happy on this box..
305
 
  RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
306
 
 
307
 
  szProjectDir = @HASKELL_REG_ROOT ^ @PRODUCT_NAME;
308
 
 
309
 
  // check whether we've already got the Registry sub-tree we're
310
 
  // about to add to. If not, then we create it
311
 
  // level-by-level, so as to ensure that the uninstaller
312
 
  // can clean up after us.
313
 
  if ( RegDBKeyExist ( @HASKELL_REG_ROOT ) < 0) then
314
 
     RegDBCreateKeyEx (@HASKELL_REG_ROOT, "");
315
 
  endif;
316
 
  if ( RegDBKeyExist  ( szProjectDir ) < 0 ) then
317
 
     RegDBCreateKeyEx ( szProjectDir, "");
318
 
  endif;
319
 
 
320
 
  // Note: we overwrite any existing value.
321
 
  RegDBSetKeyValueEx( szProjectDir, "Version", REGDB_STRING,
322
 
                       @PRODUCT_KEY, -1);
323
 
 
324
 
  szProjectVersionDir = szProjectDir ^ @PRODUCT_KEY;
325
 
 
326
 
  if ( RegDBKeyExist ( szProjectVersionDir ) < 0) then
327
 
     RegDBCreateKeyEx ( szProjectVersionDir, "");
328
 
  endif;
329
 
 
330
 
  // Here starts the Happy specific part
331
 
 
332
 
  ForwardSlashify (TARGETDIR, szTargetDir);
333
 
  // fill in the all-important path to where the binary and templates have been parked.
334
 
  szBinDir = szTargetDir + "/bin";
335
 
  szBinDirUnslashed = TARGETDIR ^ "\\bin";
336
 
  RegDBSetKeyValueEx ( szProjectVersionDir, "bindir", REGDB_STRING,
337
 
                       szBinDir , -1);
338
 
 
339
 
  szLibDir = szTargetDir + "/lib";
340
 
  szLibDirUnslashed = TARGETDIR ^ "\\lib";
341
 
  RegDBSetKeyValueEx ( szProjectVersionDir, "libdir", REGDB_STRING,
342
 
                       szLibDir , -1);
343
 
  // libexecdir
344
 
  szLibExecDir = szTargetDir + "/lib";
345
 
  RegDBSetKeyValueEx ( szProjectVersionDir, "libexecdir", REGDB_STRING,
346
 
                       szLibExecDir , -1);
347
 
 
348
 
  return 0;
349
 
 end;
350
 
 
351
 
 
352
 
///////////////////////////////////////////////////////////////////////////////
353
 
//
354
 
// Function: SetupFolders
355
 
//
356
 
//  Purpose: This function creates all the folders and shortcuts for the
357
 
//           setup.  This includes program groups and items for Windows 3.1.
358
 
//
359
 
///////////////////////////////////////////////////////////////////////////////
360
 
function SetupFolders()
361
 
 NUMBER nResult;
362
 
 STRING svResult, szTemp;
363
 
 begin
364
 
 
365
 
 
366
 
  // TODO : Add all your folder (program group) along with shortcuts (program items)
367
 
  //
368
 
  //
369
 
  //    CreateProgramFolder, AddFolderIcon....
370
 
  //
371
 
 
372
 
  CreateHappyScript(szBinDirUnslashed, "happy");
373
 
  CreateHappyBat(szBinDirUnslashed);
374
 
  
375
 
  nResult = CreateShellObjects( "" );
376
 
 
377
 
  return nResult;
378
 
 end;
379
 
 
380
 
///////////////////////////////////////////////////////////////////////////////
381
 
//                                                                           //
382
 
// Function: CleanUpInstall                                                  //
383
 
//                                                                           //
384
 
//  Purpose: This cleans up the setup.  Anything that should                 //
385
 
//           be released or deleted at the end of the setup should           //
386
 
//           be done here.                                                   //
387
 
//                                                                           //
388
 
///////////////////////////////////////////////////////////////////////////////
389
 
function CleanUpInstall()
390
 
 begin
391
 
 
392
 
  if (bInstallAborted) then
393
 
      return 0;
394
 
  endif;
395
 
 
396
 
  DialogShowSdFinishReboot();
397
 
 
398
 
  if (BATCH_INSTALL) then // ensure locked files are properly written
399
 
      CommitSharedFiles(0);
400
 
  endif;
401
 
 
402
 
  return 0;
403
 
 end;
404
 
 
405
 
///////////////////////////////////////////////////////////////////////////////
406
 
//                                                                           //
407
 
// Function: SetupInstall                                                    //
408
 
//                                                                           //
409
 
//  Purpose: This will setup the installation.  Any general initialization   //
410
 
//           needed for the installation should be performed here.           //
411
 
//                                                                           //
412
 
///////////////////////////////////////////////////////////////////////////////
413
 
function SetupInstall()
414
 
 
415
 
 begin
416
 
 
417
 
  Enable( CORECOMPONENTHANDLING );
418
 
 
419
 
  bInstallAborted = FALSE;
420
 
 
421
 
  GetDisk(WINDIR, svDir);
422
 
 
423
 
  if (bIs32BitSetup) then
424
 
      svDir = svDir + "\\" ^ @PRODUCT_NAME_SHORT ^ @PRODUCT_KEY;
425
 
  else
426
 
      // We're (=>ghc) 32 through and through, but for the sake of
427
 
      // completenes.
428
 
      svDir = svDir + "\\" ^ @PRODUCT_NAME_SHORT ^ @PRODUCT_NAME16;
429
 
  endif;
430
 
 
431
 
  TARGETDIR  = svDir;
432
 
 
433
 
  SdProductName( @PRODUCT_NAME );
434
 
 
435
 
  Enable( DIALOGCACHE );
436
 
 
437
 
  return 0;
438
 
 end;
439
 
 
440
 
///////////////////////////////////////////////////////////////////////////////
441
 
//                                                                           //
442
 
// Function:  SetupScreen                                                    //
443
 
//                                                                           //
444
 
//  Purpose:  This function establishes  the screen look.  This includes     //
445
 
//            colors, fonts, and text to be displayed.                       //
446
 
//                                                                           //
447
 
///////////////////////////////////////////////////////////////////////////////
448
 
function SetupScreen()
449
 
 begin
450
 
 
451
 
  SetColor ( BACKGROUND, BLUE );
452
 
  Enable( FULLWINDOWMODE );
453
 
  Enable( INDVFILESTATUS );
454
 
 
455
 
  SetTitle( @TITLE_MAIN, 24, WHITE );
456
 
 
457
 
  SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION ); // Caption bar text.
458
 
 
459
 
  Enable( BACKGROUND );
460
 
 
461
 
  Delay( 1 );
462
 
 end;
463
 
 
464
 
///////////////////////////////////////////////////////////////////////////////
465
 
//                                                                           //
466
 
// Function:  CheckRequirements                                              //
467
 
//                                                                           //
468
 
//  Purpose:  This function checks all minimum requirements for the          //
469
 
//            application being installed.  If any fail, then the user       //
470
 
//            is informed and the setup is terminated.                       //
471
 
//                                                                           //
472
 
///////////////////////////////////////////////////////////////////////////////
473
 
function CheckRequirements()
474
 
    NUMBER  nvDx, nvDy, nvResult;
475
 
    STRING  svResult;
476
 
 
477
 
 begin
478
 
 
479
 
  bWinNT           = FALSE;
480
 
  bIsShellExplorer = FALSE;
481
 
 
482
 
  // Check screen resolution.
483
 
  GetExtents( nvDx, nvDy );
484
 
 
485
 
  if (nvDy < 480) then
486
 
      MessageBox( @ERROR_VGARESOLUTION, WARNING );
487
 
      abort;
488
 
  endif;
489
 
 
490
 
  // set 'setup' operation mode
491
 
  bIs32BitSetup = TRUE;
492
 
  GetSystemInfo( ISTYPE, nvResult, svResult );
493
 
  if (nvResult = 16) then
494
 
      bIs32BitSetup = FALSE; // running 16-bit setup
495
 
      return 0; // no additional information required
496
 
  endif;
497
 
 
498
 
  // --- 32-bit testing after this point ---
499
 
 
500
 
  // Determine the target system's operating system.
501
 
  GetSystemInfo( OS, nvResult, svResult );
502
 
 
503
 
  if (nvResult =  IS_WINDOWSNT) then
504
 
      // Running Windows NT.
505
 
      bWinNT = TRUE;
506
 
 
507
 
      // Check to see if the shell being used is EXPLORER shell.
508
 
      if (GetSystemInfo( OSMAJOR, nvResult, svResult ) = 0) then
509
 
          if (nvResult >= 4) then
510
 
              bIsShellExplorer = TRUE;
511
 
          endif;
512
 
      endif;
513
 
 
514
 
  elseif (nvResult = IS_WINDOWS95 ) then
515
 
      bIsShellExplorer = TRUE;
516
 
 
517
 
  endif;
518
 
 
519
 
end;
520
 
 
521
 
 
522
 
///////////////////////////////////////////////////////////////////////////////
523
 
//                                                                           //
524
 
// Function: DialogShowSdWelcome                                             //
525
 
//                                                                           //
526
 
//  Purpose: This function handles the standard welcome dialog.              //
527
 
//                                                                           //
528
 
//                                                                           //
529
 
///////////////////////////////////////////////////////////////////////////////
530
 
function DialogShowSdWelcome()
531
 
    NUMBER nResult;
532
 
    STRING szTitle, szMsg;
533
 
 begin
534
 
 
535
 
  szTitle = "";
536
 
  szMsg   = "";
537
 
  nResult = SdWelcome( szTitle, szMsg );
538
 
 
539
 
  return nResult;
540
 
 end;
541
 
 
542
 
 
543
 
///////////////////////////////////////////////////////////////////////////////
544
 
//                                                                           //
545
 
// Function: DialogShowSdShowInfoList                                        //
546
 
//                                                                           //
547
 
//  Purpose: This function displays the general information list dialog.     //
548
 
//                                                                           //
549
 
//                                                                           //
550
 
///////////////////////////////////////////////////////////////////////////////
551
 
function DialogShowSdShowInfoList()
552
 
    NUMBER nResult;
553
 
    LIST   list;
554
 
    STRING szTitle, szMsg, szFile;
555
 
 begin
556
 
 
557
 
  szFile = SUPPORTDIR ^ "announce";
558
 
 
559
 
  list = ListCreate( STRINGLIST );
560
 
  ListReadFromFile( list, szFile );
561
 
  szTitle  = "";
562
 
  szMsg    = " ";
563
 
  nResult  = SdShowInfoList( szTitle, szMsg, list );
564
 
 
565
 
  ListDestroy( list );
566
 
 
567
 
  return nResult;
568
 
 end;
569
 
 
570
 
 
571
 
///////////////////////////////////////////////////////////////////////////////
572
 
//                                                                           //
573
 
// Function: DialogShowSdAskDestPath                                         //
574
 
//                                                                           //
575
 
//  Purpose: This function asks the user for the destination directory.      //
576
 
//                                                                           //
577
 
///////////////////////////////////////////////////////////////////////////////
578
 
function DialogShowSdAskDestPath()
579
 
    NUMBER nResult;
580
 
    STRING szTitle, szMsg;
581
 
 begin
582
 
 
583
 
  szTitle = "";
584
 
  szMsg   = "";
585
 
  nResult = SdAskDestPath( szTitle, szMsg, svDir, 0 );
586
 
 
587
 
  TARGETDIR = svDir;
588
 
 
589
 
  return nResult;
590
 
 end;
591
 
 
592
 
 
593
 
///////////////////////////////////////////////////////////////////////////////
594
 
//                                                                           //
595
 
// Function: DialogShowSdSetupType                                           //
596
 
//                                                                           //
597
 
//  Purpose: This function displays the standard setup type dialog.          //
598
 
//                                                                           //
599
 
///////////////////////////////////////////////////////////////////////////////
600
 
function DialogShowSdSetupType()
601
 
    NUMBER nResult, nType;
602
 
    STRING szTitle, szMsg;
603
 
 begin
604
 
 
605
 
  switch (svSetupType)
606
 
  case "Typical":
607
 
       nType = TYPICAL;
608
 
  case "Custom":
609
 
       nType = CUSTOM;
610
 
  case "Compact":
611
 
       nType = COMPACT;
612
 
  case "":
613
 
       svSetupType = "Typical";
614
 
       nType = TYPICAL;
615
 
  endswitch;
616
 
 
617
 
  szTitle = "";
618
 
  szMsg   = "";
619
 
  nResult = SetupType( szTitle, szMsg, "", nType, 0 );
620
 
 
621
 
  switch (nResult)
622
 
  case COMPACT:
623
 
       svSetupType = "Compact";
624
 
  case TYPICAL:
625
 
       svSetupType = "Typical";
626
 
  case CUSTOM:
627
 
       svSetupType = "Custom";
628
 
  endswitch;
629
 
 
630
 
  return nResult;
631
 
 end;
632
 
 
633
 
 
634
 
///////////////////////////////////////////////////////////////////////////////
635
 
//                                                                           //
636
 
// Function: DialogShowSdComponentDialog2                                    //
637
 
//                                                                           //
638
 
//  Purpose: This function displays the custom component dialog.             //
639
 
//                                                                           //
640
 
//                                                                           //
641
 
///////////////////////////////////////////////////////////////////////////////
642
 
function DialogShowSdComponentDialog2()
643
 
    NUMBER nResult;
644
 
    STRING szTitle, szMsg;
645
 
 begin
646
 
 
647
 
  if ((svSetupType != "Custom") && (svSetupType != "")) then
648
 
      return 0;
649
 
  endif;
650
 
 
651
 
  szTitle  = "";
652
 
  szMsg    = "";
653
 
  nResult  = SdComponentDialog2( szTitle, szMsg, svDir, "" );
654
 
 
655
 
  return nResult;
656
 
 end;
657
 
 
658
 
 
659
 
///////////////////////////////////////////////////////////////////////////////
660
 
//                                                                           //
661
 
// Function: DialogShowSdFinishReboot                                        //
662
 
//                                                                           //
663
 
//  Purpose: This function will show the last dialog of the product.         //
664
 
//           It will allow the user to reboot and/or show some readme text.  //
665
 
//                                                                           //
666
 
///////////////////////////////////////////////////////////////////////////////
667
 
function DialogShowSdFinishReboot()
668
 
    NUMBER nResult, nDefOptions;
669
 
    STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;
670
 
    NUMBER bOpt1, bOpt2;
671
 
 begin
672
 
 
673
 
  if (!BATCH_INSTALL) then
674
 
      bOpt1 = FALSE;
675
 
      bOpt2 = FALSE;
676
 
      szMsg1 = "";
677
 
      szMsg2 = "";
678
 
      szOption1 = "";
679
 
      szOption2 = "";
680
 
      szTitle = "Installation is now complete.";
681
 
      nResult = SdFinish( szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2 );
682
 
      return 0;
683
 
  else
684
 
      nDefOptions = SYS_BOOTMACHINE;
685
 
      szTitle     = "";
686
 
      szMsg1      = "";
687
 
      szMsg2      = "";
688
 
      nResult     = SdFinishReboot( szTitle, szMsg1, nDefOptions, szMsg2, 0 );
689
 
      return nResult;
690
 
  endif;
691
 
 end;
692
 
 
693
 
function ForwardSlashify ( szStr , theRes )
694
 
   NUMBER nPos;
695
 
   STRING szTemp, szRes;
696
 
 begin
697
 
  // Tortuous piece of code to convert backslashes into
698
 
  // forward ones.
699
 
  nPos = StrFind ( szStr, "\\");
700
 
  szRes="";
701
 
  while ( nPos >= 0 )
702
 
    StrSub ( szTemp, szStr, 0, nPos);
703
 
    szRes = szRes + szTemp + "/";
704
 
    StrSub ( szTemp, szStr, nPos + 1, StrLength ( szStr) - nPos );
705
 
    szStr = szTemp;
706
 
    nPos = StrFind ( szStr, "\\" );
707
 
  endwhile;
708
 
  StrSub ( szTemp, szStr, 0, StrLength (szStr));
709
 
  szRes = szRes + szTemp;
710
 
  theRes = szRes;
711
 
  return 0;
712
 
 end;
713
 
 
714
 
 function CreateHappyScript ( szPath, szFileName )
715
 
    NUMBER writeHandle;
716
 
 begin
717
 
   OpenFileMode (FILE_MODE_APPEND);
718
 
   if ( CreateFile ( writeHandle, szPath, szFileName ) < 0 ) then
719
 
      MessageBox ("CreateFile " + szPath ^ szFileName + " failed", INFORMATION);
720
 
   endif;
721
 
   WriteLine (writeHandle, "#! /bin/sh" );
722
 
   WriteLine (writeHandle, "happy.bat $*" );
723
 
 
724
 
   // There's no way to set the 'x' bit using SetFileInfo(), but, luckily,
725
 
   // it is not needed to run #! scripts under cygwin
726
 
   SetFileInfo ( szPath ^ "\\" + szFileName, FILE_ATTRIBUTE, FILE_ATTR_NORMAL, "");
727
 
   return 0;
728
 
 end;
729
 
 
730
 
 function CreateHappyBat ( szPath )
731
 
    NUMBER writeHandle;
732
 
    STRING szFileName;
733
 
 begin            
734
 
   szFileName = "happy.bat";
735
 
   OpenFileMode (FILE_MODE_APPEND);
736
 
   if ( CreateFile ( writeHandle, szPath, szFileName ) < 0 ) then
737
 
      MessageBox ("CreateFile " + szPath ^ szFileName + " failed", INFORMATION);
738
 
   endif;
739
 
   WriteLine (writeHandle, "@echo off" );
740
 
   WriteLine (writeHandle, "set HAPPYLIB=" + szLibDir + "/happy" );
741
 
   WriteLine (writeHandle, "set HAPPYBIN=" + szLibDirUnslashed ^ "happy.exe" );
742
 
   WriteLine (writeHandle, "%HAPPYBIN% --template %HAPPYLIB% %*" );
743
 
 
744
 
   SetFileInfo ( szPath ^ szFileName, FILE_ATTRIBUTE, FILE_ATTR_NORMAL, "");
745
 
   return 0;
746
 
 end;
 
 
b'\\ No newline at end of file'