?? msgcomposecommands.js
字號:
// catch the exception and ignore it, so that if LDAP setup // fails, the entire compose window doesn't get horked } }}function AddDirectoryServerObserver(flag) { if (flag) { sPrefBranchInternal.addObserver("ldap_2.autoComplete.useDirectory", directoryServerObserver, false); sPrefBranchInternal.addObserver("ldap_2.autoComplete.directoryServer", directoryServerObserver, false); } else { var prefstring = "mail.identity." + gCurrentIdentity.key + ".overrideGlobal_Pref"; sPrefBranchInternal.addObserver(prefstring, directoryServerObserver, false); prefstring = "mail.identity." + gCurrentIdentity.key + ".directoryServer"; sPrefBranchInternal.addObserver(prefstring, directoryServerObserver, false); }}function RemoveDirectoryServerObserver(prefstring){ if (!prefstring) { sPrefBranchInternal.removeObserver("ldap_2.autoComplete.useDirectory", directoryServerObserver); sPrefBranchInternal.removeObserver("ldap_2.autoComplete.directoryServer", directoryServerObserver); } else { var str = prefstring + ".overrideGlobal_Pref"; sPrefBranchInternal.removeObserver(str, directoryServerObserver); str = prefstring + ".directoryServer"; sPrefBranchInternal.removeObserver(str, directoryServerObserver); }}function AddDirectorySettingsObserver(){ sPrefBranchInternal.addObserver(gCurrentAutocompleteDirectory, directoryServerObserver, false);}function RemoveDirectorySettingsObserver(prefstring){ sPrefBranchInternal.removeObserver(prefstring, directoryServerObserver);}function setupLdapAutocompleteSession(){ var autocompleteLdap = false; var autocompleteDirectory = null; var prevAutocompleteDirectory = gCurrentAutocompleteDirectory; var i; autocompleteLdap = sPrefs.getBoolPref("ldap_2.autoComplete.useDirectory"); if (autocompleteLdap) autocompleteDirectory = sPrefs.getCharPref( "ldap_2.autoComplete.directoryServer"); if(gCurrentIdentity.overrideGlobalPref) { autocompleteDirectory = gCurrentIdentity.directoryServer; } // use a temporary to do the setup so that we don't overwrite the // global, then have some problem and throw an exception, and leave the // global with a partially setup session. we'll assign the temp // into the global after we're done setting up the session // var LDAPSession; if (gLDAPSession) { LDAPSession = gLDAPSession; } else { LDAPSession = Components .classes["@mozilla.org/autocompleteSession;1?type=ldap"]; if (LDAPSession) { try { LDAPSession = LDAPSession.createInstance() .QueryInterface(Components.interfaces.nsILDAPAutoCompleteSession); } catch (ex) {dump ("ERROR: Cannot get the LDAP autocomplete session\n" + ex + "\n");} } } if (autocompleteDirectory && !gIsOffline) { // Add observer on the directory server we are autocompleting against // only if current server is different from previous. // Remove observer if current server is different from previous gCurrentAutocompleteDirectory = autocompleteDirectory; if (prevAutocompleteDirectory) { if (prevAutocompleteDirectory != gCurrentAutocompleteDirectory) { RemoveDirectorySettingsObserver(prevAutocompleteDirectory); AddDirectorySettingsObserver(); } } else AddDirectorySettingsObserver(); // fill in the session params if there is a session // if (LDAPSession) { var serverURL = Components.classes[ "@mozilla.org/network/ldap-url;1"]. createInstance().QueryInterface( Components.interfaces.nsILDAPURL); try { serverURL.spec = sPrefs.getComplexValue(autocompleteDirectory +".uri", Components.interfaces.nsISupportsString).data; } catch (ex) { dump("ERROR: " + ex + "\n"); } LDAPSession.serverURL = serverURL; // get the login to authenticate as, if there is one // var login = ""; try { login = sPrefs.getComplexValue( autocompleteDirectory + ".auth.dn", Components.interfaces.nsISupportsString).data; } catch (ex) { // if we don't have this pref, no big deal } // set the LDAP protocol version correctly var protocolVersion; try { protocolVersion = sPrefs.getCharPref(autocompleteDirectory + ".protocolVersion"); } catch (ex) { // if we don't have this pref, no big deal } if (protocolVersion == "2") { LDAPSession.version = Components.interfaces.nsILDAPConnection.VERSION2; } // find out if we need to authenticate, and if so, tell the LDAP // autocomplete session how to prompt for a password. This window // (the compose window) is being used to parent the authprompter. // LDAPSession.login = login; if (login != "") { var windowWatcherSvc = Components.classes[ "@mozilla.org/embedcomp/window-watcher;1"] .getService(Components.interfaces.nsIWindowWatcher); var domWin = window.QueryInterface(Components.interfaces.nsIDOMWindow); var authPrompter = windowWatcherSvc.getNewAuthPrompter(domWin); LDAPSession.authPrompter = authPrompter; } // don't search on non-CJK strings shorter than this // try { LDAPSession.minStringLength = sPrefs.getIntPref( autocompleteDirectory + ".autoComplete.minStringLength"); } catch (ex) { // if this pref isn't there, no big deal. just let // nsLDAPAutoCompleteSession use its default. } // don't search on CJK strings shorter than this // try { LDAPSession.cjkMinStringLength = sPrefs.getIntPref( autocompleteDirectory + ".autoComplete.cjkMinStringLength"); } catch (ex) { // if this pref isn't there, no big deal. just let // nsLDAPAutoCompleteSession use its default. } // we don't try/catch here, because if this fails, we're outta luck // var ldapFormatter = Components.classes[ "@mozilla.org/ldap-autocomplete-formatter;1?type=addrbook"] .createInstance().QueryInterface( Components.interfaces.nsIAbLDAPAutoCompFormatter); // override autocomplete name format? // try { ldapFormatter.nameFormat = sPrefs.getComplexValue(autocompleteDirectory + ".autoComplete.nameFormat", Components.interfaces.nsISupportsString).data; } catch (ex) { // if this pref isn't there, no big deal. just let // nsAbLDAPAutoCompFormatter use its default. } // override autocomplete mail address format? // try { ldapFormatter.addressFormat = sPrefs.getComplexValue(autocompleteDirectory + ".autoComplete.addressFormat", Components.interfaces.nsISupportsString).data; } catch (ex) { // if this pref isn't there, no big deal. just let // nsAbLDAPAutoCompFormatter use its default. } try { // figure out what goes in the comment column, if anything // // 0 = none // 1 = name of addressbook this card came from // 2 = other per-addressbook format // var showComments = 0; showComments = sPrefs.getIntPref( "mail.autoComplete.commentColumn"); switch (showComments) { case 1: // use the name of this directory // ldapFormatter.commentFormat = sPrefs.getComplexValue( autocompleteDirectory + ".description", Components.interfaces.nsISupportsString).data; break; case 2: // override ldap-specific autocomplete entry? // try { ldapFormatter.commentFormat = sPrefs.getComplexValue(autocompleteDirectory + ".autoComplete.commentFormat", Components.interfaces.nsISupportsString).data; } catch (innerException) { // if nothing has been specified, use the ldap // organization field ldapFormatter.commentFormat = "[o]"; } break; case 0: default: // do nothing } } catch (ex) { // if something went wrong while setting up comments, try and // proceed anyway } // set the session's formatter, which also happens to // force a call to the formatter's getAttributes() method // -- which is why this needs to happen after we've set the // various formats // LDAPSession.formatter = ldapFormatter; // override autocomplete entry formatting? // try { LDAPSession.outputFormat = sPrefs.getComplexValue(autocompleteDirectory + ".autoComplete.outputFormat", Components.interfaces.nsISupportsString).data; } catch (ex) { // if this pref isn't there, no big deal. just let // nsLDAPAutoCompleteSession use its default. } // override default search filter template? // try { LDAPSession.filterTemplate = sPrefs.getComplexValue( autocompleteDirectory + ".autoComplete.filterTemplate", Components.interfaces.nsISupportsString).data; } catch (ex) { // if this pref isn't there, no big deal. just let // nsLDAPAutoCompleteSession use its default } // override default maxHits (currently 100) // try { // XXXdmose should really use .autocomplete.maxHits, // but there's no UI for that yet // LDAPSession.maxHits = sPrefs.getIntPref(autocompleteDirectory + ".maxHits"); } catch (ex) { // if this pref isn't there, or is out of range, no big deal. // just let nsLDAPAutoCompleteSession use its default. } if (!gSessionAdded) { // if we make it here, we know that session initialization has // succeeded; add the session for all recipients, and // remember that we've done so var autoCompleteWidget; for (i=1; i <= awGetMaxRecipients(); i++) { autoCompleteWidget = document.getElementById("addressCol2#" + i); if (autoCompleteWidget) { autoCompleteWidget.addSession(LDAPSession); // ldap searches don't insert a default entry with the default domain appended to it // so reduce the minimum results for a popup to 2 in this case. autoCompleteWidget.minResultsForPopup = 2; } } gSessionAdded = true; } } } else { if (gCurrentAutocompleteDirectory) { // Remove observer on the directory server since we are not doing Ldap // autocompletion. RemoveDirectorySettingsObserver(gCurrentAutocompleteDirectory); gCurrentAutocompleteDirectory = null; } if (gLDAPSession && gSessionAdded) { for (i=1; i <= awGetMaxRecipients(); i++) document.getElementById("addressCol2#" + i). removeSession(gLDAPSession); gSessionAdded = false; } } gLDAPSession = LDAPSession; gSetupLdapAutocomplete = true;}function DoCommandClose(){ var retVal; if ((retVal = ComposeCanClose())) { // Notify the SendListener that Send has been aborted and Stopped if (gMsgCompose) { var externalListener = gMsgCompose.getExternalSendListener(); if (externalListener) { externalListener.onSendNotPerformed(null, Components.results.NS_ERROR_ABORT); } } MsgComposeCloseWindow(true); // at this point, we might be caching this window. // in which case, we don't want to close it if (sMsgComposeService.isCachedWindow(window)) { retVal = false; } } return retVal;}function DoCommandPrint(){ try { NSPrint(); } catch(ex) {dump("#PRINT ERROR: " + ex + "\n");}}function ToggleWindowLock(){ gWindowLocked = !gWindowLocked; updateComposeItems();}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -