The nsIMessenger interface provides functions for managing the history, undo and redo operations, and for loading, saving, or deleting messages and attachments in mailnews.
Inherits from: nsISupports
Implemented by: @mozilla.org/messenger;1. To create an instance, use:
messenger = Components.classes["@mozilla.org/messenger;1"]
.createInstance(Components.interfaces.nsIMessenger);
In Thunderbird, a global nsIMessenger object is defined as messenger via the createMessenger function in mailWindow.js.
void setDisplayCharset(in ACString aCharset); |
void setWindow(in nsIDOMWindow ptr, in nsIMsgWindow msgWindow); |
void openURL(in ACString aURL); |
void loadURL(in nsIDOMWindow ptr, in ACString aURL); |
void launchExternalURL(in ACString aURL); |
boolean canUndo(); |
boolean canRedo(); |
unsigned long getUndoTransactionType(); |
unsigned long getRedoTransactionType(); |
void undo(in nsIMsgWindow msgWindow); |
void redo(in nsIMsgWindow msgWindow); |
void sendUnsentMessages(in nsIMsgIdentity aIdentity, in nsIMsgWindow aMsgWindow); |
void setDocumentCharset(in ACString characterSet); |
void saveAs(in ACString aURI, in boolean aAsFile, in nsIMsgIdentity aIdentity, in AString aMsgFilename); |
void openAttachment(in ACString contentTpe, in ACString url, in ACString displayName, in ACString messageUri, in boolean isExternalAttachment); |
void saveAttachment(in ACString contentTpe, in ACString url, in ACString displayName, in ACString messageUri, in boolean isExternalAttachment); |
void saveAllAttachments(in unsigned long count, [array, size_is(count)] in string contentTypeArray, [array, size_is(count)] in string urlArray, [array, size_is(count)] in string displayNameArray, [array, size_is(count)] in string messageUriArray); |
void saveAttachmentToFile(in nsIFile aFile, in ACString aUrl, in ACString aMessageUri, in ACString aContentType, in nsIUrlListener aListener); |
void detachAttachment(in string contentTpe, in string url, in string displayName, in string messageUri, in boolean saveFirst, [optional] in boolean withoutWarning); |
void detachAllAttachments(in unsigned long count, [array, size_is(count)] in string contentTypeArray, [array, size_is(count)] in string urlArray, [array, size_is(count)] in string displayNameArray, [array, size_is(count)] in string messageUriArray, in boolean saveFirst, [optional] in boolean withoutWarning); |
nsILocalFile saveAttachmentToFolder(in ACString contentType, in ACString url, in ACString displayName, in ACString messageUri, in nsILocalFile aDestFolder); |
nsIMsgMessageService messageServiceFromURI(in ACString aUri); |
nsIMsgDBHdr msgHdrFromURI(in ACString aUri); |
ACString getMsgUriAtNavigatePos(in long aPos); |
ACString getFolderUriAtNavigatePos(in long aPos); |
void getNavigateHistory(out unsigned long aCurPos, out unsigned long aCount, [array, size_is(aCount)] out string aHistory); |
Note: Prior to Gecko 8.0, all references to nsIDOMWindow used in this interface were nsIDOMWindow.
| Attribute | Type | Description |
transactionManager |
nsITransactionManager |
Readonly: The transaction manager for this nsIMessenger instance. |
sendingUnsentMsgs |
boolean | Indicates if sending messages is in progress. |
lastDisplayedMessageUri |
ACString | Readonly: The URL of the last displayed message. |
navigatePos |
long | The current index in the navigation history. |
| Name | Value | Description |
eUnknown |
0 | Unknown transaction type. |
eDeleteMsg |
1 | Delete transaction type. |
eMoveMsg |
2 | Move transaction type. |
eCopyMsg |
3 | Copy transaction type. |
Sets the character set for the displayed message.
void setDisplayCharset(in ACString aCharset);
aCharsetSets the current window for a messenger session.
void setWindow(in nsIDOMWindow aWin,
in nsIMsgWindow aMsgWindow);
aWinid set to "messagepane"?), then the nsIDocShell will be used for future nsIMessenger operations. If there is no messagepane element, then the root XUL nsIDocShell will be used (so that openURL() will still work). If null is passed in then observers are removed in preparation for shutdown.aMsgWindownsIMsgWindow with the transation manager to be used.Opens a url in the current window (set by setWindow()) and adds it to the current history.
void openURL(in ACString aURL);
aURLLoad a custom message by url. Similar to openURL() except can be used to load things that appear as messages to users (e.g load an attachment as a email).
void loadURL(in nsIDOMWindow aWin,
in ACString aURL);
aWinaURLLaunches the nsIExternalProtocolService and sends it the url.
void launchExternalURL(in ACString aURL);
aURLQueries if there are any undo items in the transaction manager.
boolean canUndo();
Queries if there are any redo items in the transaction manager.
boolean canRedo();
Gets the type of the next undo transaction.
unsigned long getUndoTransactionType();
Gets the type of the next redo transaction. Available types are defined as constants in nsIMessenger.
unsigned long getRedoTransactionType();
Performs the next undo transaction.
void undo(in nsIMsgWindow msgWindow);
msgWindownsIMsgWindow to perform the undo transaction on.Performs the next redo transaction.
void redo(in nsIMsgWindow msgWindow);
msgWindownsIMsgWindow to perform the redo transaction on.Creates a nsIMsgSendLater instance and sends all messages for the given identity.
void sendUnsentMessages(in nsIMsgIdentity aIdentity,
in nsIMsgWindow aMsgWindow);
aIdentitynsIMsgIdentity to send messages for.aMsgWindownsIMsgWindow to get messages from.Redisplay the currently selected message (if any) using the given character set.
void setDocumentCharset(in ACString characterSet);
characterSetSave the URL given.
void saveAs(in ACString aURI,
in boolean aAsFile,
in nsIMsgIdentity aIdentity,
in AString aMsgFilename);
aURIaAsFileaIdentityaMsgFilenameOpen an attachment.
void openAttachment(in ACString contentType,
in ACString url,
in ACString displayName,
in ACString messageUri,
in boolean isExternalAttachment);
contentTypeurldisplayNamemessageUriisExternalAttachmentSave an attachment.
void saveAttachment(in ACString contentType,
in ACString url,
in ACString displayName,
in ACString messageUri,
in boolean isExternalAttachment);
contentTypeurldisplayNamemessageUriisExternalAttachmentLaunches a filepicker and saves all attachments listed in an array.
void saveAllAttachments(in unsigned long count,
[array, size_is(count)] in string contentTypeArray,
[array, size_is(count)] in string urlArray,
[array, size_is(count)] in string displayNameArray,
[array, size_is(count)] in string messageUriArray);
countcontentTypeArrayurlArraydisplayNameArraymessageUriArraySave an attachment to a particular nsIFile.
void saveAttachmentToFile(in nsIFile aFile,
in ACString aUrl,
in ACString aMessageUri,
in ACString aContentType,
in nsIUrlListener aListener);
aFilensIFile to save to.aUrlaMessageUriaContentTypeaListenernsIUrlListener to be notified when the file is saved.Deletes an attachment from a message.
void detachAttachment(in string contentType,
in string url,
in string displayName,
in string messageUri,
in boolean saveFirst,
[optional] in boolean withoutWarning);
contentTypeurldisplayNamemessageUrisaveFirsttrue, the attachment is saved using saveAttachment() before it is deleted.withoutWarningtrue, no warning is shown to the user before the delete.Deletes a set of attachments.
void detachAllAttachments(in unsigned long count,
[array, size_is(count)] in string contentTypeArray,
[array, size_is(count)] in string urlArray,
[array, size_is(count)] in string displayNameArray,
[array, size_is(count)] in string messageUriArray,
in boolean saveFirst,
[optional] in boolean withoutWarning);
countcontentTypeArrayurlArraydisplayNameArraymessageUriArraysaveFirsttrue, the attachments are saved using saveAllAttachments() before being deleted.withoutWarningtrue, no warning is shown to the user before the delete.Saves an attachment in a given folder. saveAttachmentToFolder() is used by the drag and drop code to drop an attachment to a destination folder. Returns the actual file path (including the filename).
nsILocalFile saveAttachmentToFolder(in ACString ,
in ACString url,
in ACString displayName,
in ACString messageUri,
in nsILocalFile aDestFolder);
contentTypeurldisplayNamemessageUriaDestFoldernsILocalFile poiting to the folder where the attachment should be saved.nsILocalFile where the attachment was saved.Gets the nsIMsgMessageService in charge of a particular url. Message services are implemented for different protocols such as IMAP, POP3, or local mail sources.
nsIMsgMessageService messageServiceFromURI(in ACString aUri);
aUrinsIMsgMessageService responsible for the url.nsIMsgDBHdr msgHdrFromURI(in ACString aUri);
Gets the message a particular position in the navigation history. For example, back-forward history needs a list of visited messages, and where it is in the list. Unfortunately, you must call this before navigating to a position, because calling this has the side effect of making us adjust our current history position, and not adding the loaded message to the history queue.
ACString getMsgUriAtNavigatePos(in long aPos);
aPosGets the folder url at a particular position in the navigation history.
ACString getFolderUriAtNavigatePos(in long aPos);
aPosReturns information about the current navigation history. If caller just wants the count and current pos, they can pass in null for aHistory, which will be more efficent. If they want a list suitable for display, they should pass in an aHistory pointer, and they'll get returned an array with strings containing something like subject and sender of the message - other possible info is the folder containing the message, and the preview text, if available.
void getNavigateHistory(out unsigned long aCurPos, out unsigned long aCount, [array, size_is(aCount)] out string aHistory);
aCurPosaCountaHistory