/* Copyright (c) Oracle Corporation 1992, 1996.  All Rights Reserved */
/***************************************************************************
  NAME
    netc23.ins

  DESCRIPTION
    This script performs the installation tasks for the Win32 SQL*Net
    product.

  OWNER
    Etna Flores

  MODIFIED   DD-MMM-YY  Reason
    mhclau   22-SEP-97  Copy NLS resource.
   dstiefel  22-Feb-96  Merge NT/95
   ljiang        9/95       Modified for Easy Configuration
   dlau      07-AUG-95  Modified for SQLNET 2.2
 **************************************************************************/
{
  if (doit)
  {
    ins_ratchet = "2.3.4.0.0";

    execute("%installer_home%\%operating_system%.ins");


/*--------------------------------------------------------------------------------------------------*/

   ################################
   #                              #
   # Install Product Dependencies #
   #                              #
   ################################



   /* Force install RSF and Trace Server */
   install(w32rsf73);
   install(w32traceSvr);


   /* Force install the Installer.  (Doit will be false if this is not possible) */
   if (not(registered("%prefix%install")))
      install(install_prod);
   else if (earlier_version(registration("%prefix%install"),product_version(instver_prod)))
      install(install_prod);


   /* Force install the appropriate adapters  LU6.2 and DECNet will only be installable through custom */
   if(install_tcp)
      install(tcp_prod);
   if(install_spx)
      install(spx_prod);
   if(install_nmp)          /* For this release, this will always happen */
      install(nmp_prod);


/*--------------------------------------------------------------------------------------------------*/

   ###############################################
   #                                             #
   # Copy and Configure files for SQL*Net Client #
   #                                             #
   ###############################################


      ui_product(product_label);

      ui_action(instantiate(net2_install_tns));


      /* sqlnet_in_use is a boolean which it true until the copy(tns) command is succesful. */
      /* This is how we allow the user to stop services and/or applications using sqlnet and continue installing */
      sqlnet_in_use = TRUE;
      while(sqlnet_in_use)
      {
         write_error_occured = FALSE;
         { copy(tns); }
         [  'WRITE_ERROR:
            {
               /* If in silent mode signal an error to avoid an infinite loop. */
               if(silent_mode)
                  signal('CANCEL, app_prompt);

               information_dialog(instantiate(app_prompt), app_content, app_help);
               write_error_occured = TRUE;
               continue();
            }
         ]
         if(not(write_error_occured))
         {
            sqlnet_in_use = FALSE;
         }
      }

      /* sqlnet_in_use is a boolean which it true until the copy(bequeth) command is succesful. */
      /* This is how we allow the user to stop services and/or applications using sqlnet and continue installing */
      sqlnet_in_use = TRUE;
      while(sqlnet_in_use)
      {
         write_error_occured = FALSE;
         { copy(bequeth, prefix); }
         [  'WRITE_ERROR:
            {
               /* If in silent mode signal an error to avoid an infinite loop. */
               if(silent_mode)
                  signal('CANCEL, app_prompt);

               information_dialog(instantiate(app_prompt), app_content, app_help);
               write_error_occured = TRUE;
               continue();
            }
         ]
         if(not(write_error_occured))
         {
            sqlnet_in_use = FALSE;
         }
      }



    ui_action(instantiate(net2_install_script));
    copy(deinstl, nls_abbreviation);

    ui_action(instantiate(net2_install_message));
    copy(msb, nls_abbreviation);

    ui_action(instantiate(net2_install_sample));
    copy(sample);

    /* create default sqlnet.ora if none exists */
    sqlnet_ora = "%oracle_home%\NETWORK\ADMIN\SQLNET.ORA";
    sqlnet_ora_sample = "%oracle_home%\NETWORK\ADMIN\SAMPLE\SQLNET.ORA";
    if (not(exists(sqlnet_ora)))
    {
         copy_file(sqlnet_ora_sample, sqlnet_ora);
    }
    ['INVALID_FILE_NAME, 'PERMISSION_DENIED, 'WRITE_ERROR, 'FILE_NOT_FOUND, 'OS_ERROR: continue(); ]


/*--------------------------------------------------------------------------------------------------*/

   ##############################
   #                            #
   # Copy files for Easy Config #
   #                            #
   ##############################

    ui_action(instantiate(net2_install_easycfg));
    copy(cfg23);
    copy(cfgico);  /* This group only contains the Easy Config Icon; it is not copied for OCSM installs */

   if (platform() == "win95")
   {
      {
         move_file("%ORACLE_HOME%\NETWORK\CFG\NT.PRD","%ORACLE_HOME%\NETWORK\CFG\WIN95.PRD");
      }
      ['DEFAULT: continue(); ]

      /* set NET20 here in the registry */

      modify("NET20","%oracle_home%\NETWORK", ora_config, (product_filename(current_product)));
   } /* Win 95 */


/*--------------------------------------------------------------------------------------------------*/

   /* Register Product and Dependencies */

   ui_action(instantiate(net2_register));
   register(current_product);
   if(member(selected_products,current_product))
      reference(current_product);

   reference(w32rsf73, current_product);
   reference(w32traceSvr, current_product);
   if(install_tcp)
      reference(tcp_prod, current_product);
   if(install_spx)
      reference(spx_prod, current_product);
   if(install_nmp)
      reference(nmp_prod, current_product);

        /* OCSM Compliance */
        { Win32_register_OCSM_product(); }
        [ 'default: win32_ocsm_register_product(); ]

        /* Register the groups in the map file and specify which should get
           copied over under the three OCSM installation modes. */
        win32_register_ocsm_group(deinstl,   nls_abbreviation,  'MAXMODE);
        win32_register_ocsm_group(tns,                          'MAXMODE);
        win32_register_ocsm_group(cfg23,                        'MAXMODE);
        win32_register_ocsm_group(sample,                       'MAXMODE);
        win32_register_ocsm_group(msb,       nls_abbreviation,  'MAXMODE);

        win32_register_ocsm_group(deinstl,   nls_abbreviation,  'MEDMODE);
        win32_register_ocsm_group(tns,                          'MEDMODE);
        win32_register_ocsm_group(cfg23,                        'MEDMODE);
        win32_register_ocsm_group(sample,                       'MEDMODE);
        win32_register_ocsm_group(msb,       nls_abbreviation,  'MEDMODE);

        win32_register_ocsm_group(deinstl,   nls_abbreviation,  'MINMODE);
        win32_register_ocsm_group(tns,                          'MINMODE);
        win32_register_ocsm_group(cfg23,                        'MINMODE);
        win32_register_ocsm_group(sample,                       'MINMODE);
        win32_register_ocsm_group(msb,       nls_abbreviation,  'MINMODE);

        /* Register variables in the map file that are not Installer variables. */
        win32_register_map_variable("oracle_group_name");

        /* Register product variables or keys created in the Windows registry by   */
        /* this INS script.  Associated with calls to: modify(...) in this script. */

        /* Define the key and subkey. */
        okey    = "HKEY_LOCAL_MACHINE";
        osubkey = "SOFTWARE\ORACLE";

        /* Only in Win95 as in the modify(...) call above. */
        if(platform() == "win95")
                win32_register_key(okey, osubkey, "NET20",   'REPLICATE);

        /* End OCSM Compliance */
  }
}
