home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 January / 01_02.iso / software / netscape62win / mail.xpi / bin / chrome / messenger.jar / content / messenger / pref-mailnewsOverlay.js < prev    next >
Text File  |  2001-10-11  |  4KB  |  105 lines

  1. /* 
  2.  * The contents of this file are subject to the Mozilla Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/MPL/
  6.  * 
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  * 
  12.  * The Original Code is mozilla.org code.
  13.  * 
  14.  * The Initial Developer of the Original Code is Netscape
  15.  * Communications Corporation.  Portions created by Netscape are 
  16.  * Copyright (C) 2001 Netscape Communications Corporation.  All
  17.  * Rights Reserved.
  18.  * 
  19.  * Contributor(s): 
  20.  * Srilatha Moturi <srilatha@netscape.com>
  21.  */
  22.  
  23. function mailnewsOverlayStartup() {
  24.     mailnewsOverlayInit();
  25.     parent.hPrefWindow.registerOKCallbackFunc(onOK);
  26.     if (!("mapiPref" in parent)) {
  27.         parent.mapiPref = new Object;
  28.         parent.mapiPref.isDefaultMailClient = 
  29.                document.getElementById("mailnewsEnableMapi").checked;
  30.     }
  31.     else { 
  32.         // when we switch between different panes
  33.         // set the checkbox based on the saved state
  34.         var mailnewsEnableMapi = document.getElementById("mailnewsEnableMapi");
  35.         if (parent.mapiPref.isDefaultMailClient)
  36.             mailnewsEnableMapi.setAttribute("checked", "true");
  37.         else
  38.             mailnewsEnableMapi.setAttribute("checked", "false");
  39.     }
  40. }
  41.  
  42. function mailnewsOverlayInit() {
  43.     try {
  44.         var mapiRegistry = Components.classes[ "@mozilla.org/mapiregistry;1" ].
  45.                    getService( Components.interfaces.nsIMapiRegistry );
  46.     }
  47.     catch(ex){
  48.         mapiRegistry = null;
  49.     }
  50.  
  51.     const prefbase = "system.windows.lock_ui.";
  52.     var mailnewsEnableMapi = document.getElementById("mailnewsEnableMapi");
  53.     if (mapiRegistry) {
  54.     // initialise preference component.
  55.     // While the data is coming from the system registry, we use a set
  56.     // of parallel preferences to indicate if the ui should be locked.
  57.         try { 
  58.             var prefService = Components.classes["@mozilla.org/preferences-service;1"]
  59.                           .getService()
  60.                           .QueryInterface(Components.interfaces.nsIPrefService);
  61.             var prefBranch = prefService.getBranch(prefbase);
  62.             if (prefBranch && prefBranch.prefIsLocked("default_mail_client")) {
  63.                 if (prefBranch.getBoolPref("default_mail_client"))
  64.                     mapiRegistry.setDefaultMailClient();
  65.                 else
  66.                     mapiRegistry.unsetDefaultMailClient();
  67.                 mailnewsEnableMapi.setAttribute("disabled", "true");
  68.            }
  69.         }
  70.         catch(ex) {}
  71.         if (mapiRegistry.isDefaultMailClient)
  72.             mailnewsEnableMapi.setAttribute("checked", "true");
  73.         else
  74.             mailnewsEnableMapi.setAttribute("checked", "false");
  75.     }
  76.     else
  77.         mailnewsEnableMapi.setAttribute("disabled", "true");
  78. }
  79.  
  80. function onEnableMapi() {
  81.     // save the state of the checkbox
  82.     if ("mapiPref" in parent)
  83.         parent.mapiPref.isDefaultMailClient = 
  84.                document.getElementById("mailnewsEnableMapi").checked;
  85. }
  86.  
  87. function onOK()
  88. {
  89.     try {
  90.         var mapiRegistry = Components.classes[ "@mozilla.org/mapiregistry;1" ].
  91.                    getService( Components.interfaces.nsIMapiRegistry );
  92.     }
  93.     catch(ex){
  94.         mapiRegistry = null;
  95.     }
  96.     if (mapiRegistry &&
  97.         ("mapiPref" in parent) && 
  98.         (mapiRegistry.isDefaultMailClient != parent.mapiPref.isDefaultMailClient)) { 
  99.         if (parent.mapiPref.isDefaultMailClient)
  100.             mapiRegistry.setDefaultMailClient();
  101.         else
  102.             mapiRegistry.unsetDefaultMailClient();
  103.     }  
  104. }
  105.