# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- # ***** BEGIN LICENSE BLOCK ***** # Version: MPL 1.1/GPL 2.0/LGPL 2.1 # # The contents of this file are subject to the Mozilla 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/MPL/ # # 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 the Initial Developer are Copyright (C) 1998-1999 # the Initial Developer. All Rights Reserved. # # Contributor(s): # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), # in which case the provisions of the GPL or the LGPL are applicable instead # of those above. If you wish to allow use of your version of this file only # under the terms of either the GPL or the LGPL, and not to allow others to # use your version of this file under the terms of the MPL, indicate your # decision by deleting the provisions above and replace them with the notice # and other provisions required by the GPL or the LGPL. If you do not delete # the provisions above, a recipient may use your version of this file under # the terms of any one of the MPL, the GPL or the LGPL. # # ***** END LICENSE BLOCK ***** /** * 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(); msgWindow = msgWindow.QueryInterface(Components.interfaces.nsIMsgWindow); /** * 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 gAttachVCardOptionChanged; var gMailSession; var gAutoSaveInterval; var gAutoSaveTimeout; 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. gLDAPPrefsService = Components.classes["@mozilla.org/ldapprefs-service;1"]; if (gLDAPPrefsService) { try { gLDAPPrefsService = gLDAPPrefsService .getService(Components.interfaces.nsILDAPPrefsService); } catch (ex) {Components.utils.reportError("ERROR: Cannot get the LDAP prefs service\n" + ex + "\n");} if (gLDAPPrefsService) { gLDAPPrefsService.migratePrefsIfNeeded(); } } 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; gAttachVCardOptionChanged = 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