home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 November / Chip_2003-11_cd2.bin / nav2004 / download / NAV / External / NORTON / APP / NAVOpts.dll / HTML / OPTIONSBTM.JS < prev    next >
Text File  |  2003-08-17  |  8KB  |  314 lines

  1. // optionsbtm.js
  2.  
  3. g_ModuleID = 3023; // From ccModuleID.h
  4.  
  5. // Called by options.js::Load()
  6. function Load ()
  7. {
  8.     try
  9.     {
  10.         parent.g_btnDefaultPage = options_btnDefault;
  11.     }
  12.     catch(err)
  13.     {
  14.         parent.g_ErrorHandler.DisplayException (err);
  15.     }
  16.  
  17. }
  18.  
  19. function Save()
  20. {
  21.     try
  22.     {
  23.       try
  24.       {
  25.           var bConfigure = parent.IsTrialValid
  26.                         && (parent.InitialLoadVxD != parent.NAVOptions.STARTUP.LoadVxD
  27.                             || (!parent.Is9x && parent.InitialDelayLoad != parent.NAVOptions.AUTOPROTECT.DelayLoad) );
  28.       }
  29.       catch(err)
  30.       {
  31.          // Don't configure AP if an error occurs
  32.          bConfigure = false;
  33.          parent.NAVOptions.NAVError.LogAndDisplay(parent.g_HWND);
  34.       }
  35.       try
  36.       {
  37.           var bSwitchAP = parent.IsTrialValid
  38.                        && parent.NAVAutoProtect.Enabled != parent.CurAPRunning;
  39.       }
  40.       catch(err)
  41.       {
  42.           // Don't switch AP if the state cannot be retrieved
  43.           bSwitchAP = false;
  44.           parent.NAVAutoProtect.NAVError.LogAndDisplay(parent.g_HWND);
  45.       }
  46.      
  47.       var bSwitchProduct = false;
  48.       var bSwitchVirusdefs = false;
  49.  
  50.       // Only switch the modes for ALU if the product reg catalog was available
  51.       // during this session of options and ALU was not hosed
  52.       try
  53.       {
  54.           if( !parent.NAVOptions.ALURunning && !parent.ALUhosed )
  55.           {
  56.              bSwitchProduct = parent.IsTrialValid
  57.                            && parent.InitialALUProduct != parent.NAVOptions.ALU.Product;
  58.              bSwitchVirusdefs = parent.IsTrialValid
  59.                            && parent.InitialALUVirusdefs != parent.NAVOptions.ALU.Virusdefs;
  60.           }
  61.        }
  62.        catch(err)
  63.        {
  64.           parent.NAVOptions.NAVError.LogAndDisplay(parent.g_HWND);
  65.        }
  66.  
  67.       // Flush changes to disk
  68.       try
  69.       {
  70.         parent.NAVOptions.Save();
  71.       }
  72.       catch (NAVErr)
  73.       {
  74.         parent.NAVOptions.NAVError.LogAndDisplay(parent.g_HWND);
  75.         return;
  76.       }
  77.  
  78.       // Set the satrtup configuration
  79.       if (bConfigure)
  80.       {
  81.         var APstartup = 0;
  82.         try
  83.         {
  84.             APstartup = parent.NAVOptions.STARTUP.LoadVxD;
  85.  
  86.             try
  87.             {
  88.                 parent.NAVAutoProtect.Configure(APstartup);
  89.             }
  90.             catch(err)
  91.             {
  92.                 parent.NAVAutoProtect.NAVError.LogAndDisplay(parent.g_HWND);
  93.             }
  94.     
  95.             try 
  96.             {
  97.                 var sww = new ActiveXObject('CcWebWnd.ccWebWindow');
  98.             }
  99.             catch (NAVErr)
  100.             {
  101.                 parent.g_ErrorHandler.DisplayNAVError (document.frames("Errors").ERROR_CREATING_NAVWEBWINDOW_OBJECT.innerText,  
  102.                                                 document.frames("Errors").ERROR_CREATING_NAVWEBWINDOW_OBJECT_ID.innerText);
  103.                 return;
  104.             }
  105.  
  106.             // Display the message only if the option to Load at startup was changed, not if
  107.             // the delay load was changed
  108.             if( parent.InitialLoadVxD != parent.NAVOptions.STARTUP.LoadVxD )
  109.             {
  110.                 sww.MsgBox(parent.NAVOptions.STARTUP.LoadVxD ? document.all.APWillStart.innerText : document.all.APWillStop.innerText, document.all.APMsgBoxTitle.innerText, 0);
  111.                 delete sww;
  112.             }
  113.         }
  114.         catch(err)
  115.         {
  116.             parent.NAVOptions.NAVError.LogAndDisplay(parent.g_HWND);
  117.         }
  118.       }
  119.  
  120.       // Set AP service if the state of AP is changed
  121.       if (bSwitchAP)
  122.       {
  123.         try
  124.         {
  125.             parent.NAVAutoProtect.Enabled = parent.CurAPRunning;
  126.         }
  127.         catch(err)
  128.         {
  129.             parent.NAVAutoProtect.NAVError.LogAndDisplay(parent.g_HWND);
  130.         }
  131.       }
  132.  
  133.       try
  134.       {
  135.         // Change ALU Update modes for product patches if it changed
  136.         if (bSwitchProduct)
  137.         {
  138.             parent.NAVOptions.EnableALU(parent.NAVOptions.ALU.Product, true);
  139.         }
  140.  
  141.         // Change ALU Update modes for Virus Def patches if it changed
  142.         if (bSwitchVirusdefs)
  143.         {
  144.             parent.NAVOptions.EnableALU(parent.NAVOptions.ALU.Virusdefs, false);
  145.         }
  146.       }
  147.       catch (NAVErr)
  148.       {
  149.         parent.NAVOptions.NAVError.LogAndDisplay(parent.g_HWND);
  150.       }
  151.  
  152.       // Clear the password if necessary
  153.       if( parent.ClearPass )
  154.       {
  155.         try    
  156.         {
  157.             var ccpass = new ActiveXObject("Symantec.CommonClient.ccPassword");
  158.  
  159.             // Reset the ccPassword enabled flag to it's old state
  160.             try
  161.             {
  162.                 ccpass.ProductID = parent.NAV_CONSUMER_PASSWORD_ID;
  163.                 ccpass.Clear();
  164.             }
  165.             catch(err)
  166.             {
  167.                 // Swallow error during save
  168.             }
  169.         }
  170.         catch(err)
  171.         {        
  172.             // Swallow error during save
  173.         }
  174.       }
  175.  
  176.     }
  177.     catch (err)
  178.     {
  179.         parent.g_ErrorHandler.DisplayException (err);
  180.         return;
  181.     }
  182. }
  183.  
  184. // Save and close
  185. function OK()
  186. {
  187.   try
  188.   {
  189.       parent.bClosedWithX = false;
  190.  
  191.       if (parent.CurrentPage.Validate())
  192.       {
  193.         // Update objects from previous page first.
  194.         parent.CurrentPage.Terminate();
  195.         Save();
  196.         parent.location.href = 'closeme.xyz';
  197.       }
  198.   }
  199.   catch (err)
  200.   {
  201.     parent.g_ErrorHandler.DisplayException (err);
  202.     return;
  203.   }
  204. }
  205.  
  206. // Cancel and close
  207. function Cancel()
  208. {
  209.   /*
  210.    * Update objects from page first.
  211.    * This is done to set the IsDirty flag if the user made any changes.
  212.    * The IsDirty flag is checked when options.htm is closed and the user is
  213.    * prompted to save pending changes.
  214.    */
  215.   try
  216.   {
  217.     parent.bClosedWithX = false;
  218.     if (parent.CurrentPage.Validate())
  219.     {        
  220.         parent.CurrentPage.Terminate();
  221.  
  222.         // Get the current state of AP
  223.         var APEnabled;
  224.         try
  225.         {
  226.             APEnabled = parent.NAVAutoProtect.Enabled;
  227.         }
  228.         catch(err)
  229.         {
  230.             APEnabled = false;
  231.             parent.NAVAutoProtect.NAVError.LogAndDisplay(parent.g_HWND);
  232.         }
  233.         
  234.         if (parent.NAVOptions.IsDirty
  235.             || parent.NAVOptions.IsPasswordDirty
  236.             || (parent.IsTrialValid
  237.             && APEnabled != parent.CurAPRunning))
  238.         {
  239.           try
  240.           {
  241.             var sww = new ActiveXObject('CcWebWnd.ccWebWindow');                
  242.           }
  243.           catch (NAVErr)
  244.           {            
  245.             parent.g_ErrorHandler.DisplayNAVError (document.frames("Errors").ERROR_CREATING_NAVWEBWINDOW_OBJECT.innerText,
  246.                                             document.frames("Errors").ERROR_CREATING_NAVWEBWINDOW_OBJECT_ID.innerText);
  247.             return;
  248.           }
  249.           
  250.           if (6 == sww.MsgBox(document.all.CancelPromptLine1.innerText+ '\n' + document.all.CancelPromptLine2.innerText, parent.document.title, 36))
  251.           {
  252.             Save();
  253.           }
  254.           else if( parent.NAVOptions.IsPasswordDirty )
  255.           {
  256.             // If the password is dirty we need to undirty it on a cancel
  257.             try    
  258.             {
  259.                 var ccpass = new ActiveXObject("Symantec.CommonClient.ccPassword");
  260.  
  261.                 // Reset the ccPassword enabled flag to it's old state
  262.                 try
  263.                 {
  264.                     ccpass.ProductID = parent.NAV_CONSUMER_PASSWORD_ID;
  265.                     ccpass.Enabled = parent.InitialPassword;
  266.  
  267.                     // Remove the password set on cancel if it was not previously set
  268.                     if( !ccpass.Enabled && parent.InitialPasswordSet != ccpass.UserPasswordSet )
  269.                         ccpass.Clear();
  270.                 }
  271.                 catch(err)
  272.                 {
  273.                     // Swallow error during close
  274.                 }
  275.             }
  276.             catch(err)
  277.             {        
  278.                 // Swallow error during close
  279.             }
  280.           }
  281.           delete sww;
  282.         }
  283.         parent.location.href = 'closeme.xyz';
  284.     }
  285.   }
  286.   catch (err)
  287.   {
  288.     parent.g_ErrorHandler.DisplayException (err);
  289.     return;
  290.   }
  291. }
  292.  
  293. function ResetPage()
  294. {
  295.   try
  296.   {
  297.     // Reset page defaults
  298.     parent.CurrentPage.Default();
  299.   }
  300.   catch(NAVerr)
  301.   {
  302.     parent.NAVOptions.NAVError.LogAndDisplay(parent.g_HWND);
  303.   }
  304.   try
  305.   {
  306.     parent.CurrentPage.Initialize();
  307.   }
  308.   catch (err)
  309.   {
  310.     parent.g_ErrorHandler.DisplayException (err);
  311.     return;
  312.   }
  313. }
  314.