/* Copyright (c) Oracle Corporation 1992.  All Rights Reserved */
/*****************************************************************************
  NAME
    ssf20.ins - V3 installation script for System Support Files for Dev/2000.

  DESCRIPTION
    This script installs System Support Files 2.0 for Oracle Forms/Reports Developer.

  OWNER
    Rajesh Bansal

  MODIFIED   DD/MON/YY   Reason
  pgupta     07/17/97    OCSM win32 bit compliant
  aharriso   05/DEC/95   Added overwrite_mode function.
   rbansal   20/APR/95   Installer 3.1 compliant
   jewillia  09/FEB/95   Added MFC support and re-written
   rbansal   24/OCT/94   Created.
******************************************************************************/
{
      filename_list = explode(current_script,"\/");  /* allow unix and dos/os2 seperators */
      while (not(empty(filename_list)))
    {
        filename = first(filename_list);
        filename_list = rest(filename_list);
    }

    if (doit)
    {
        ui_product(instantiate(display_product_label));

        /*****************************
        Set the VRF-INS script ratchet
        ******************************/
        ins_ratchet = "2.0.1.2.1";
        execute("%installer_home%%dir_separator%%operating_system%.ins");

        permit_retry_operations  = TRUE;
        permit_ignore_operations = TRUE;
        permit_process_operations= TRUE;

        ui_product(instantiate(display_product_label));

        /*******************
        Copy deinstall files
        ********************/

        ui_action(instantiate(install_files));
        copy(deinst);

        overwrite_mode = 'ALWAYS;

        /********************************
        Install MSVCRT2X.DLL - overwrite
        any existing version
        ********************************/
        ui_action(instantiate(install_mfc));
        copy(special);
        copy(special1);

      wininit = "%windir%\wininit.ini";
      rename_group = "rename";
      copy_msft_dlls = true;
      /********************************************
       Install files - if they are newer
       than those already installed
      ********************************************/
      ui_action(instantiate(install_mfc));
      copy(dll);

      /********************************************
       Check if MFC40.DLL is present, if so, check
       if the version installed is lower than the 
       DLL which is being shipped. If yes, copy the
       MFC40.NEW to MFC40.DLL. 
      ********************************************/

      mfc40 = "%win_sys_loc%\mfc40.dll";
      mfc40new = "%win_sys_loc%\mfc40.new";
      mfc40old = "%win_sys_loc%\mfc40.old";
      if (not(exists(mfc40)))
      {
        { move_file(mfc40new, mfc40); }
        [ 'DEFAULT: copy_file(mfc40new, mfc40); ]
      }

      else
      {
        { version_no = windows_file_version(mfc40); }
        [ 'OS_ERROR: version_no = "0.0.0.0.0.0.0"; ]

        { version_new = windows_file_version(mfc40new); }
        [ 'OS_ERROR: version_new = "0.0.0.0.0.0.0"; ]

        if (earlier_version(version_no, version_new))
        {
          {
          move_file(mfc40, mfc40old);
          move_file(mfc40new, mfc40);
          }
          [ 'DEFAULT: { if (platform() == "nt")
                          copy_file(mfc40new, mfc40);
                        else
                        {
                          copy_msft_dlls = false;
                          modify(mfc40old,mfc40,wininit,rename_group);
                          modify(mfc40,mfc40new,wininit,rename_group);
                        }
                      }
          ]
        }
        else
        {
          { remove_file(mfc40new); }
          [ 'DEFAULT: continue(); ]
        }
      }


      /********************************************
       Check if MFC40U.DLL is present, if so, check
       if the version installed is lower than the 
       DLL which is being shipped. If yes, copy the
       MFC40U.NEW to MFC40U.DLL. 
      ********************************************/

      mfc40u = "%win_sys_loc%\mfc40u.dll";
      mfc40unew = "%win_sys_loc%\mfc40u.new";
      mfc40uold = "%win_sys_loc%\mfc40u.old";
      if (not(exists(mfc40u)))
      {
        { move_file(mfc40unew, mfc40u); }
        [ 'DEFAULT: copy_file(mfc40unew, mfc40u); ]
      }

      else
      {
        { version_no = windows_file_version(mfc40u); }
        [ 'OS_ERROR: version_no = "0.0.0.0.0.0.0"; ]

        { version_new = windows_file_version(mfc40unew); }
        [ 'OS_ERROR: version_new = "0.0.0.0.0.0.0"; ]

        if (earlier_version(version_no, version_new))
        {
          {
          move_file(mfc40u, mfc40uold);
          move_file(mfc40unew, mfcu40);
          }
          [ 'DEFAULT: { if (platform() == "nt")
                          copy_file(mfc40unew, mfc40u);
                        else
                        {
                          copy_msft_dlls = false;
                          modify(mfc40uold,mfc40u,wininit,rename_group);
                          modify(mfc40u,mfc40unew,wininit,rename_group);
                        }
                      }
          ]
        }
        else
        {
          { remove_file(mfc40unew); }
          [ 'DEFAULT: continue(); ]
        }
      }

      /********************************************
       Check if MFC42U.DLL is present, if so, check
       if the version installed is lower than the 
       DLL which is being shipped. If yes, copy the
       MFC42U.NEW to MFC4U.DLL. 
      ********************************************/


      mfc42u = "%win_sys_loc%\mfc42u.dll";
      mfc42unew = "%win_sys_loc%\mfc42u.new";
      mfc42uold = "%win_sys_loc%\mfc42u.old";
      if (not(exists(mfc42u)))
      {
        { move_file(mfc42unew, mfc42u); }
        [ 'DEFAULT: copy_file(mfc42unew, mfc42u); ]
      }

      else
      {
        { version_no = windows_file_version(mfc42u); }
        [ 'OS_ERROR: version_no = "0.0.0.0.0.0.0"; ]

        { version_new = windows_file_version(mfc42unew); }
        [ 'OS_ERROR: version_new = "0.0.0.0.0.0.0"; ]

        if (earlier_version(version_no, version_new))
        {
          {
          move_file(mfc42u, mfc42uold);
          move_file(mfc42unew, mfc42u);
          }
          [ 'DEFAULT: { if (platform() == "nt")
                          copy_file(mfc42unew, mfc42u);
                        else
                        {
                          copy_msft_dlls = false;
                          modify(mfc42uold,mfc42u,wininit,rename_group);
                          modify(mfc42u,mfc42unew,wininit,rename_group);
                        }
                      }
          ]
        }
        else
        {
          { remove_file(mfc42unew); }
          [ 'DEFAULT: continue(); ]
        }
      }

        overwrite_mode = 'UPDATE;

        ui_action(instantiate(install_mfc));
        copy(dll_rest);


        /******************
        Install ODBC support
        *******************/
        ui_action(instantiate(install_files));
        copy(odbc1);
        copy(odbc3);
        {copy(odbc2,"%operating_system%");}
        ['WRITE_ERROR: continue();]    /*the current NT installer is using ctl3d32.dll which is in this
                                      odbc2 group.  This is causing write errors in .ins*/
        copy(shrdll,"%operating_system%");

      
        /************************************************************
        Delete the Old Program Group if present and Install the new
        Program Group
        *************************************************************/
/*
        if(exists("%ORACLE_HOME%/bin/ifrun60.exe"))
        {*/
          D2K60_GROUP = D2K60_GROUP_OLD;
          windows_delete_icons(d2l_old);
          D2K60_GROUP = D2K60_GROUP_NEW;
       /* } */
        /************************************************************/

        /***************************************************************
         Registering map variables except Installer_home and oracle_home
        ****************************************************************/
        win32_register_map_variable("WIN_SYS_LOC");
        win32_register_map_variable("OCA60");
        win32_register_map_variable("WINDOWS_SYS_DIR");

        /*********************************
        Register and Reference the product
        **********************************/
        ui_product(instantiate(display_product_label));
        ui_action( instantiate(install_register) );

        register(current_product);
        reference(current_product);
        /*********************************/

        remove(delold);   
        permit_retry_operations = FALSE;
   }
    [
        'UNREGISTERED_PRODUCT: continue();
        'CANCEL: signal('FAILURE, instantiate(halt_installation));
    ]

    overwrite_mode = 'ALWAYS;
}
