home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09962.iso / vrml / scout110.exe / disk1 / _setup.lib / setup.rul < prev    next >
Text File  |  1995-08-04  |  18KB  |  571 lines

  1. /*----------------------------------------------------------------------------
  2.  
  3.             .###.  ###     ###       ,#,          .###.    ,#######,
  4.          ,####""   ###    .###     ,##'##,     ,####""   .##'    `##.
  5.         ###        ###########    ,##' `##,   ###       ####      ####
  6.         ###..      ###'    ###  ,###########, ####..    `###,    ,##'
  7.           `######  ###     ###  `##'     `##'   `######   `########'
  8.  
  9.  
  10.     Copyright 1995, Chaco Communications, Inc. All rights reserved.
  11.     Unpublished -- Rights reserved under the copyright laws of the United
  12.     States.  Use of a copyright notice is precautionary only and does no
  13.     imply publication or disclosure.
  14.  
  15.     This software contains confidential information and trade secrets of
  16.     Chaco Communications, Inc.  Use, disclosure, or reproduction is
  17.     prohibited without the prior express written permission of Chaco
  18.     Communications, Inc.
  19.  
  20.     RESTRICTED RIGHTS LEGEND
  21.  
  22.     Use, duplication, or disclosure by the Government is subject to
  23.     restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  24.     Technical Data and Computer Software clause at DFARS 252.227-7013.
  25.  
  26.     Chaco Communications, Inc.
  27.     10164 Parkwood Drive, Suite 8, Cupertino, CA, 95014-1533
  28.  
  29. ------------------------------------------------------------------------------
  30.  
  31.     InstallSHIELD 32-bit Pueblo32 install script.
  32.  
  33. ----------------------------------------------------------------------------*/
  34.  
  35. // $Header: /home/cvs/chaco/modules/client/msw/ChGraphx/ChMaze.cpp,v 2.42 1995/08/03 16:00:46 jimd Exp $
  36.  
  37.  
  38. /*----------------------------------------------------------------------------
  39.     Constants
  40. ----------------------------------------------------------------------------*/
  41.  
  42. #define APP_NAME                "Pueblo"
  43. #define PROGRAM_FOLDER_NAME        "Pueblo"
  44. #define APPBASE_PATH            "\\Program Files\\Chaco\\Pueblo\\"
  45. #define APPBASE_PATH_WIN32S        "\\Programf\\Chaco\\Pueblo\\"
  46.  
  47. #define SPACE_REQUIRED            100000        // Disk space in bytes.
  48.  
  49. #define COMPANY_NAME            "Chaco Communications, Inc."
  50. #define PRODUCT_NAME            "Pueblo"
  51. #define PRODUCT_VERSION            "0.9"
  52.                                             // Deinstall keys
  53. #define PRODUCT_KEY                "pueblo.exe"
  54. #define DEINSTALL_KEY            "Pueblo32DeinstallKey"
  55. #define UNINSTALL_NAME            "Pueblo32 version 0.9"
  56.  
  57. #define INSTALL_BACKGROUND        RGB( 128, 0, 0 )
  58.  
  59. #define STR_DEFTAB                "    "
  60.  
  61. #define CH_CONNECTION_GROUP        "Connection"
  62. #define CH_CONNECTION_HOST            "Host"
  63. #define CH_CONNECTION_HOST_DEF            "zuni.chaco.com"
  64. #define CH_CONNECTION_PORT            "Port"
  65. #define CH_CONNECTION_PORT_DEF            "3141"
  66.  
  67. /*----------------------------------------------------------------------------
  68.     Declaration block
  69. ----------------------------------------------------------------------------*/
  70.  
  71. declare
  72.  
  73. #include "sddialog.h"   // Include script dialog definitions.
  74.  
  75.  
  76. /*----------------------------------------------------------------------------
  77.     Global variables
  78. ----------------------------------------------------------------------------*/
  79.  
  80. STRING  svFolder, szMsg, szFileSet, szTitle;
  81. STRING  svTarget, szProgram, szTemp, svName, svCompany, szComponentList;
  82. STRING  svUninstLogFile, szAppPath, szRegKey, szAppSharedDir;
  83. BOOL    bSpaceOk;
  84. NUMBER  nResult, nType, nOSVersion;
  85. LIST    listInfo;
  86.  
  87.  
  88. /*----------------------------------------------------------------------------
  89.     Function declarations
  90. ----------------------------------------------------------------------------*/
  91.  
  92. prototype SetupScreen();
  93. prototype CheckRequirements();
  94. prototype ConstructInfoList( LIST );
  95. prototype CreateRegDBEntries();
  96. prototype SetupFileTransfer( STRING, STRING );
  97. prototype Install3DR();
  98. prototype PerformFileTransfer( STRING );
  99. prototype SetupFinish();
  100.  
  101.  
  102. /*----------------------------------------------------------------------------
  103.     Program block
  104. ----------------------------------------------------------------------------*/
  105.  
  106. program
  107.  
  108.  
  109. /*----------------------------------------------------------------------------
  110.     Script entrypoint
  111. ----------------------------------------------------------------------------*/
  112.  
  113. StartHere:
  114.         Disable( BACKGROUND );
  115.                                             /* Set installation info, which is
  116.                                                 required for registry
  117.                                                 entries */
  118.  
  119.         InstallationInfo( COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION,
  120.                                PRODUCT_KEY );
  121.  
  122.                                             // Set up the installation screen
  123.         SetupScreen();
  124.         Enable( DIALOGCACHE );
  125.  
  126.                                             // Create a Welcome dialog
  127.     WelcomeDlg:
  128.         Disable( BACKBUTTON );
  129.         SdProductName( PRODUCT_NAME );
  130.         SdWelcome( "", "" );
  131.         Enable( BACKBUTTON );
  132.                                             /* Test target system for proper
  133.                                                 configuration */
  134.         CheckRequirements();
  135.  
  136.         if ((IS_WINDOWSNT = nOSVersion) || (IS_WINDOWS95 = nOSVersion)) then
  137.             svTarget = TARGETDISK ^ APPBASE_PATH;
  138.         else
  139.             svTarget = TARGETDISK ^ APPBASE_PATH_WIN32S;
  140.         endif;
  141.  
  142.         szAppSharedDir  = svTarget ^ "System";
  143.  
  144.     GetTargetDirectory:
  145.                                             // Get the destination directory
  146.         szMsg = "";
  147.         nType = AskDestPath( "", szMsg, svTarget, 0 );
  148.  
  149.         szAppSharedDir  = svTarget ^ "System";
  150.  
  151.                                             /* Perform space check of target
  152.                                                 drive */
  153.         bSpaceOk = TRUE;
  154.         if (GetDiskSpace( svTarget ) < SPACE_REQUIRED) then
  155.             szMsg = "There is not enough space available on the disk\n" +
  156.                     "'" + svTarget + "' \n" +
  157.                     "Please free up some space or change the target location\n" +
  158.                     "to a different disk";
  159.  
  160.             MessageBox( szMsg, WARNING );
  161.             bSpaceOk = FALSE;
  162.         endif;
  163.                                             /* If not enough space, ask user
  164.                                                 to try again */
  165.  
  166.         if (bSpaceOk = FALSE) goto GetTargetDirectory;
  167.  
  168.     GetProgramFolderInfo:
  169.         svFolder = PROGRAM_FOLDER_NAME;
  170.         nResult = SdSelectFolder( "", "", svFolder );
  171.         if ( nResult = BACK ) then
  172.             goto GetTargetDirectory;
  173.         endif;
  174.  
  175.     ConfirmCopy:
  176.                                             /* Show SdStartCopy dialog to
  177.                                                 confirm file transfer
  178.                                                 operation */
  179.         listInfo = ListCreate( STRINGLIST );
  180.         ConstructInfoList( listInfo );
  181.  
  182.         szMsg = "Setup has enough information to start copying Pueblo " +
  183.                 "files.  If you want to review or change any settings, " +
  184.                 "click Back.  If you are satisfied with the settings, " +
  185.                 "click Next to begin copying files.";
  186.         if (SdStartCopy( "", szMsg, listInfo ) = BACK) then
  187.             ListDestroy( listInfo );
  188.             goto GetProgramFolderInfo;
  189.         endif;
  190.  
  191.         ListDestroy( listInfo );
  192.  
  193.     SetupRegAndUninstall:
  194.                                             /* Prepare InstallSHIELD to record
  195.                                                 deinstallation information */
  196.  
  197.         DeinstallStart( svTarget, svUninstLogFile, DEINSTALL_KEY, 0 );
  198.         RegDBSetItem( REGDB_UNINSTALL_NAME, UNINSTALL_NAME );
  199.  
  200.                                             /* Set the App Paths key for the
  201.                                                 main program */
  202.  
  203.         szAppPath = svTarget ^ "PROGRAM" + ";" + szAppSharedDir;
  204.         RegDBSetItem( REGDB_APPPATH, szAppPath );
  205.         szProgram = svTarget ^ "PROGRAM\\designer.exe";
  206.         RegDBSetItem( REGDB_APPPATH_DEFAULT, szProgram );
  207.  
  208.     SetupAndDecompFiles:
  209.         szFileSet = "Pueblo";
  210.         SetupFileTransfer( szComponentList, szFileSet );
  211.  
  212.                                             /* Set up progress indicator and
  213.                                                 information gauge */
  214.         Enable( STATUS );
  215.         Disable( DIALOGCACHE );
  216.                                             /* Transfer files to the target
  217.                                                 system */
  218.         PerformFileTransfer( szFileSet );
  219.  
  220.     DoInstall3DR:
  221.         if (BACK = SdShowAnyDialog( "3DR Installation", "3dr", 0, 0  ))
  222.             goto ConfirmCopy;
  223.  
  224.         Install3DR();
  225.  
  226.     SetRegistryEntries:
  227.         CreateRegDBEntries( );
  228.                                             /* Set up progress indicator and
  229.                                                 information gauge */
  230.         Delay( 2 );
  231.         Disable( FEEDBACK_FULL );
  232.         Disable( STATUS );
  233.  
  234.                                             // Create program folder and icons
  235.     CreateProgramIcons:
  236.         SetStatusWindow( 95, "Creating Program Folder and Icons...." );
  237.  
  238.         if (IS_WIN32S = nOSVersion) then
  239.             AppCommand( PROGMAN, CMD_RESTORE );
  240.             CreateProgramFolder( svFolder );
  241.             ShowProgramFolder( svFolder, 0 );
  242.             LongPathToShortPath( svTarget );
  243.             Delay( 1 );
  244.         endif;
  245.  
  246.         TARGETDIR = svTarget;
  247.  
  248.         szProgram = TARGETDIR ^ "Pueblo.exe";
  249.  
  250.         if ((IS_WINDOWSNT = nOSVersion) || (IS_WINDOWS95 = nOSVersion)) then
  251.             AddFolderIcon( svFolder, APP_NAME, szProgram,
  252.                             TARGETDIR, "", 0, "", REPLACE );
  253.         else
  254.             LongPathToQuote( szProgram, TRUE );
  255.             AddFolderIcon( "", APP_NAME, szProgram, TARGETDIR,
  256.                             "", 0, "", REPLACE );
  257.         endif;
  258.  
  259.         Delay( 1 );
  260.  
  261.         if ((IS_WINDOWSNT = nOSVersion) || (IS_WINDOWS95 = nOSVersion)) then
  262.             AddFolderIcon( svFolder, "Pueblo Help",
  263.                             "WinHelp.exe " + TARGETDIR ^ "Pueblo.hlp",
  264.                             TARGETDIR, "", 0, "", REPLACE );
  265.         
  266.             Delay( 1 );
  267.  
  268.             AddFolderIcon( svFolder, "Pueblo release notes",
  269.                             "NotePad.exe " + TARGETDIR ^ "ReadMe.txt",
  270.                             TARGETDIR, "", 0, "", REPLACE );
  271.         
  272.             Delay( 1 );
  273.  
  274.             szProgram = WINDIR ^ "UnInst.exe";
  275.             LongPathToShortPath( szProgram );
  276.             LongPathToShortPath( svUninstLogFile );
  277.             szProgram = szProgram + " -f" + svUninstLogFile;
  278.             AddFolderIcon( svFolder, "Uninstall Pueblo", szProgram,
  279.                             WINDIR, "", 0, "", REPLACE );
  280.             Delay( 1 );
  281.         endif;
  282.  
  283.                                             /* Announce setup complete and
  284.                                                 offer to read README file */
  285.     CloseOfInstall:
  286.         SetStatusWindow( 100, "Installation complete." );
  287.  
  288.         SetupFinish();
  289.  
  290.         exit;
  291.  
  292.  
  293. /*----------------------------------------------------------------------------
  294.     SetupScreen
  295.  
  296.     This function will set up the screen look.  This includes colors, fonts,
  297.     text to be displayed, etc.
  298. ----------------------------------------------------------------------------*/
  299.  
  300. function SetupScreen()
  301.         string szBitmap;
  302.         number nvDx, nvDy, nDxBillboard, nDyBillboard;
  303. begin
  304.     GetExtents( nvDx, nvDy );
  305.  
  306.     Enable( FULLWINDOWMODE );
  307.     Enable( INDVFILESTATUS );
  308.     Enable( BITMAP256COLORS );
  309.  
  310.     SetColor( BACKGROUND, INSTALL_BACKGROUND );    // Dark red background
  311.     SetTitle( "Setup", 0, BACKGROUNDCAPTION );    // Caption bar text
  312.  
  313.     Enable( BACKGROUND );
  314.  
  315.                                             // Show the bitmap.
  316.     Enable( BITMAPFADE );
  317.     PlaceBitmap( SUPPORTDIR ^ "TITLE.BMP;128,0,0",
  318.                     1, 10, 10, UPPER_LEFT | BITMAPICON );
  319.     Disable( BITMAPFADE );
  320. end;
  321.  
  322.  
  323. /*----------------------------------------------------------------------------
  324.     CheckRequirements
  325.  
  326.     This function will check all minimum requirements for the application
  327.     being installed.  If any fail, then the user is informed and the
  328.     installation is terminated.
  329. ----------------------------------------------------------------------------*/
  330.  
  331. function CheckRequirements()
  332.         number  nvDx, nvDy;
  333.         number  nvResult;
  334.         string  svResult;
  335. begin
  336.                                             /* Determine target system's
  337.                                                 operating system */
  338.     GetSystemInfo( OS, nOSVersion, svResult );
  339.  
  340.     if (nOSVersion = IS_WINDOWS) then
  341.         MessageBox( "This version of Pueblo must be installed on either " +
  342.                     "Windows NT or Windows95.  You can get a separate " +
  343.                     "installer for Windows 3.", WARNING );
  344.         exit;
  345.     endif;
  346.  
  347.     if (nOSVersion = IS_WIN32S) then
  348.         MessageBox( "This version of Pueblo must be installed on either " +
  349.                     "Windows NT or Windows95.  We are currently not Win32s " +
  350.                     "compatible.  You can get a separate installer for " +
  351.                     "Windows 3.", WARNING );
  352.         exit;
  353.     endif;
  354.                                             // Check screen resolution
  355.     GetExtents( nvDx, nvDy );
  356.  
  357.     if (nvDy < 480) then
  358.         MessageBox( "This program requires VGA or better resolution.",
  359.                     WARNING );
  360.         exit;
  361.     endif;
  362. end;
  363.  
  364.  
  365. /*----------------------------------------------------------------------------
  366.     SetupFileTransfer
  367.  
  368.     This function defines the file set based on the user's choices of
  369.     components, then it performs the file set.
  370. ----------------------------------------------------------------------------*/
  371.  
  372. function SetupFileTransfer( szComponentList, szFileSet )
  373. begin
  374.                                             // Define the file set
  375.     TARGETDIR = svTarget;
  376.  
  377.     FileSetBeginDefine( szFileSet );
  378.                                             /* Always include README files,
  379.                                                 located at the root of the
  380.                                                 DATA.Z library file */
  381.  
  382.     SetStatusWindow( -1, "Copying readme files..." );
  383.     TARGETDIR = svTarget;
  384.     CompressGet( "data.z", "*.*", COMP_NORMAL );
  385.  
  386.     SetStatusWindow( -1, "Copying program files..." );
  387.  
  388.     CompressGet( "data.z", "program\\*.*", INCLUDE_SUBDIR );
  389.  
  390.     SetStatusWindow( -1, "Copying help files..." );
  391.  
  392.     CompressGet( "data.z", "help\\*.*", INCLUDE_SUBDIR );
  393.  
  394.                                             // Copy 3DR install to support dir
  395.  
  396.     SetStatusWindow( -1, "Copying 3DR files..." );
  397.  
  398.     TARGETDIR = SUPPORTDIR;
  399.     CompressGet( "data.z", "3dr\\*.*", COMP_NORMAL );
  400.  
  401.                                             /* Copy shared file to shared
  402.                                                 directory */
  403.  
  404.     SetStatusWindow( -1, "Copying shared files..." );
  405.  
  406.     TARGETDIR = WINSYSDIR;
  407.     CompressGet( "data.z", "shared\\*.*", COMP_UPDATE_DATE | SHAREDFILE );
  408.  
  409.     if (nOSVersion = IS_WINDOWSNT) then
  410.         CompressGet( "data.z", "shared\\winnt\\*.*",
  411.                         COMP_UPDATE_DATE | SHAREDFILE );
  412.     elseif (nOSVersion = IS_WINDOWSNT) then
  413.         CompressGet( "data.z", "shared\\win95\\*.*",
  414.                         COMP_UPDATE_DATE | SHAREDFILE );
  415.     endif;
  416.  
  417.     FileSetEndDefine( szFileSet );
  418. end;
  419.  
  420.  
  421. /*----------------------------------------------------------------------------
  422.     ConstructInfoList
  423.  
  424.     This function will construct a info list for showing the SdStartCopy
  425.     dialog to confirm the file transfer operation.
  426. ----------------------------------------------------------------------------*/
  427.  
  428. function ConstructInfoList( listInfo )
  429.         STRING szItem;
  430. begin
  431.     ListAddString( listInfo, "Target Directory", AFTER );
  432.     ListAddString( listInfo, STR_DEFTAB + svTarget, AFTER );
  433.  
  434.     ListAddString( listInfo, "", AFTER );
  435.     ListAddString( listInfo, "Program Folder", AFTER );
  436.     ListAddString( listInfo, STR_DEFTAB + svFolder, AFTER );
  437. end;
  438.  
  439.  
  440. /*----------------------------------------------------------------------------
  441.     CreateRegDBEntries
  442.  
  443.     This function will create necessary keys and values for the sample
  444.     program.
  445. ----------------------------------------------------------------------------*/
  446.  
  447. function CreateRegDBEntries()
  448.     string szKey[255], szValue, szDemo, szProgram;
  449. begin
  450.     RegDBSetDefaultRoot( HKEY_CURRENT_USER );
  451.  
  452.                                             // Create CH_CONNECTION_GROUP key
  453.  
  454.     szKey = "SOFTWARE\\" + COMPANY_NAME + "\\" + PRODUCT_NAME +
  455.                 CH_CONNECTION_GROUP;
  456.     RegDBCreateKeyEx( szKey, "" );
  457.  
  458.     RegDBSetKeyValueEx( szKey, CH_CONNECTION_HOST, REGDB_STRING,
  459.                         CH_CONNECTION_HOST_DEF, -1 );
  460.     RegDBSetKeyValueEx( szKey, CH_CONNECTION_PORT,  REGDB_NUMBER,
  461.                         CH_CONNECTION_PORT_DEF, -1 );
  462. end;
  463.  
  464.  
  465. /*----------------------------------------------------------------------------
  466.     Install3DR
  467.  
  468.     This function will install 3DR.
  469. ----------------------------------------------------------------------------*/
  470.  
  471. function Install3DR()
  472. begin
  473. end;
  474.  
  475.  
  476. /*----------------------------------------------------------------------------
  477.     PerformFileTransfer
  478.  
  479.     This function will perform the file transfer and handle any error that
  480.     may occur during the file transfer.
  481. ----------------------------------------------------------------------------*/
  482.  
  483. function PerformFileTransfer( szFileSet )
  484. begin
  485.     StatusUpdate( ON, 90 );
  486.                                             // Perform the file set
  487.  
  488.     nResult = FileSetPerformEz( szFileSet, 0 );
  489.  
  490.     switch (nResult)
  491.         case FS_DONE:                        // Successful completion
  492.  
  493.         case FS_CREATEDIR:                    // Create directory error
  494.  
  495.             MessageBox( "Unable to create a directory under " +
  496.                             TARGETDIR + ".\n" +
  497.                             "Please check write access to this directory.",
  498.                             SEVERE );
  499.             exit;
  500.  
  501.         default:                            /* Group all other errors under
  502.                                                 default label */
  503.             NumToStr( szTemp, nResult );
  504.             MessageBox( "General file transfer error.  Please check " +
  505.                         "your target location and try again.\n\n" +
  506.                         "Error Number: " + szTemp, SEVERE );
  507.             exit;
  508.     endswitch;
  509. end;
  510.  
  511.  
  512. /*----------------------------------------------------------------------------
  513.     SetupFinish
  514.  
  515.     This function will construct messages and info for showing SdFinish
  516. ----------------------------------------------------------------------------*/
  517.  
  518. function SetupFinish()
  519.     string szMsg1, szMsg2;
  520.     string szReadme, szApp, szProgram, szParam;
  521.     BOOL   bReadme, bApp;
  522. begin
  523.     if (BATCH_INSTALL = TRUE) then
  524.         szMsg = "Some files could not be installed because they are " +
  525.                 "currently in use by other programs in the system.  " +
  526.                 "To allow for proper operation of the new program you " +
  527.                 "should restart your system at this time.";
  528.         CommitSharedFiles( 0 );
  529.         RebootDialog( "Restart Windows", szMsg, SYS_BOOTMACHINE );
  530.     else
  531.         bReadme = FALSE;
  532.         bApp    = FALSE;
  533.  
  534.         szMsg1 = "Setup is complete.  You may run the installed program " +
  535.                     "by double-clicking on the program icon installed.\n\n" +
  536.                     "Please view the contents of the README icon before " +
  537.                     "starting the program";
  538.  
  539.         szMsg2 = "Click Finish to complete Setup.";
  540.  
  541.         bReadme = TRUE;
  542.         szReadme = "Yes, I want to view the ReadMe file now.";
  543.  
  544.         szApp = "Yes, I want to run Pueblo now.";
  545.  
  546.         MessageBeep( 0 );
  547.         SdFinish( "", szMsg1, szMsg2, szReadme, szApp, bReadme, bApp );
  548.  
  549.         if ( bReadme ) then
  550.             szProgram = "NotePad.exe";
  551.             szParam   = svTarget ^ "ReadMe.txt";
  552.             LongPathToShortPath( szParam );
  553.             LaunchAppAndWait( szProgram + " " + szParam, "", NOWAIT );
  554.             Delay(2);
  555.         endif;
  556.  
  557.         if ( bApp ) then
  558.             szProgram = TARGETDIR ^ "Pueblo.exe";
  559.             LaunchAppAndWait( szProgram, "", NOWAIT );
  560.         endif;
  561.     endif;
  562. end;
  563.  
  564.  
  565. /*----------------------------------------------------------------------------
  566.     Standard dialogs include
  567. ----------------------------------------------------------------------------*/
  568.  
  569. #include "sddialog.rul"
  570.  
  571.