# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- # The contents of this file are subject to the Netscape Public # License Version 1.1 (the "License"); you may not use this file # except in compliance with the License. You may obtain a copy of # the License at http://www.mozilla.org/NPL/ # # Software distributed under the License is distributed on an "AS # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or # implied. See the License for the specific language governing # rights and limitations under the License. # # The Original Code is Mozilla Communicator client code, released # March 31, 1998. # # The Initial Developer of the Original Code is Netscape # Communications Corporation. Portions created by Netscape are # Copyright (C) 1998-1999 Netscape Communications Corporation. All # Rights Reserved. /** * interfaces */ var nsIMsgCompDeliverMode = Components.interfaces.nsIMsgCompDeliverMode; var nsIMsgCompSendFormat = Components.interfaces.nsIMsgCompSendFormat; var nsIMsgCompConvertible = Components.interfaces.nsIMsgCompConvertible; var nsIMsgCompType = Components.interfaces.nsIMsgCompType; var nsIMsgCompFormat = Components.interfaces.nsIMsgCompFormat; var nsIAbPreferMailFormat = Components.interfaces.nsIAbPreferMailFormat; var nsIPlaintextEditorMail = Components.interfaces.nsIPlaintextEditor; /** * In order to distinguish clearly globals that are initialized once when js load (static globals) and those that need to be * initialize every time a compose window open (globals), I (ducarroz) have decided to prefix by s... the static one and * by g... the other one. Please try to continue and repect this rule in the future. Thanks. */ /** * static globals, need to be initialized only once */ var sMsgComposeService = Components.classes["@mozilla.org/messengercompose;1"].getService(Components.interfaces.nsIMsgComposeService); var sComposeMsgsBundle = document.getElementById("bundle_composeMsgs"); var sPrefs = null; var sPrefBranchInternal = null; var sOther_headers = ""; var sAccountManagerDataSource = null; var sRDF = null; var sNameProperty = null; /* Create message window object. This is use by mail-offline.js and therefore should not be renamed. We need to avoid doing this kind of cross file global stuff in the future and instead pass this object as parameter when needed by function in the other js file. */ var msgWindow = Components.classes["@mozilla.org/messenger/msgwindow;1"].createInstance(); /** * Global variables, need to be re-initialized every time mostly because we need to release them when the window close */ var gHideMenus; var gMsgCompose; var gAccountManager; var gIOService; var gPromptService; var gLDAPPrefsService; var gWindowLocked; var gContentChanged; var gCurrentIdentity; var defaultSaveOperation; var gSendOrSaveOperationInProgress; var gCloseWindowAfterSave; var gIsOffline; var gSessionAdded; var gCurrentAutocompleteDirectory; var gAutocompleteSession; var gSetupLdapAutocomplete; var gLDAPSession; var gSavedSendNowKey; var gSendFormat; var gLogComposePerformance; var gMsgIdentityElement; var gMsgAddressingWidgetTreeElement; var gMsgSubjectElement; var gMsgAttachmentElement; var gMsgHeadersToolbarElement; // i18n globals var gCurrentMailSendCharset; var gSendDefaultCharset; var gCharsetTitle; var gCharsetConvertManager; var gLastWindowToHaveFocus; var gReceiptOptionChanged; var gMailSession; const kComposeAttachDirPrefName = "mail.compose.attach.dir"; function InitializeGlobalVariables() { gAccountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager); gIOService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); //This migrates the LDAPServer Preferences from 4.x to mozilla format. try { gLDAPPrefsService = Components.classes["@mozilla.org/ldapprefs-service;1"].getService(); gLDAPPrefsService = gLDAPPrefsService.QueryInterface( Components.interfaces.nsILDAPPrefsService); } catch (ex) {dump ("ERROR: Cannot get the LDAP service\n" + ex + "\n");} gMsgCompose = null; gWindowLocked = false; gContentChanged = false; gCurrentIdentity = null; defaultSaveOperation = "draft"; gSendOrSaveOperationInProgress = false; gCloseWindowAfterSave = false; gIsOffline = gIOService.offline; gSessionAdded = false; gCurrentAutocompleteDirectory = null; gAutocompleteSession = null; gSetupLdapAutocomplete = false; gLDAPSession = null; gSavedSendNowKey = null; gSendFormat = nsIMsgCompSendFormat.AskUser; gCurrentMailSendCharset = null; gSendDefaultCharset = null; gCharsetTitle = null; gCharsetConvertManager = Components.classes['@mozilla.org/charset-converter-manager;1'].getService(Components.interfaces.nsICharsetConverterManager); gMailSession = Components.classes["@mozilla.org/messenger/services/session;1"].getService(Components.interfaces.nsIMsgMailSession); gHideMenus = false; // We are storing the value of the bool logComposePerformance inorder to avoid logging unnecessarily. if (sMsgComposeService) gLogComposePerformance = sMsgComposeService.logComposePerformance; gLastWindowToHaveFocus = null; gReceiptOptionChanged = false; } InitializeGlobalVariables(); function ReleaseGlobalVariables() { gAccountManager = null; gIOService = null; gPromptService = null; gLDAPPrefsService = null; gCurrentIdentity = null; gCurrentAutocompleteDirectory = null; gAutocompleteSession = null; gLDAPSession = null; gCharsetConvertManager = null; gMsgCompose = null; gMailSession = null; } function disableEditableFields() { gMsgCompose.editor.flags |= nsIPlaintextEditorMail.eEditorReadonlyMask; var disableElements = document.getElementsByAttribute("disableonsend", "true"); for (i=0;i