Built-In Namespace _global_
Field Attributes | Field Name and Description |
---|---|
A global pointer to all the identities known for the user.
|
|
The "Collected addresses" address book
|
|
The "Personal addresses" address book
|
Method Summary
Method Attributes | Method Name and Description |
---|---|
citeString(aStr)
A function that properly quotes a plaintext email.
|
|
dateAsInMessageList(aDate)
A stupid formatting function that uses the i18nDateFormatter XPCOM component
to format a date just like in the message list
|
|
escapeHtml(s)
Helper function to escape some XML chars, so they display properly in
innerHTML.
|
|
This function you should call to populate the gIdentities global object.
|
|
getAddressBookFromUri(aUri)
Get one of the predefined address books through their URI.
|
|
getArchiveFolderUriFor(identity, msgDate)
Get the Archive folder URI depending on the given identity and the given Date
object.
|
|
getMail3Pane(aForce)
Get the main Thunderbird window.
|
|
htmlToPlainText(aHtml)
Convert HTML into text/plain suitable for insertion right away in the mail
body.
|
|
MixIn(aConstructor, aMixIn)
MixIn-style helper.
|
|
msgHdrGetTags(aMsgHdr)
Given a msgHdr, return a list of tag objects.
|
|
msgHdrGetUri(aMsg)
Get a given message header's uri.
|
|
msgHdrIsArchive(msgHdr)
Tells if the message is an archived message
|
|
msgHdrIsDraft(msgHdr)
Tells if the message is a draft message
|
|
msgHdrIsInbox(msgHdr)
Tells if the message is in the account's inbox
|
|
msgHdrIsJunk(msgHdr)
Tell if a message has been marked as junk.
|
|
msgHdrIsNntp(msgHdr)
Tell if a message is a NNTP message
|
|
msgHdrIsRss(msgHdr)
Tell if a message is an RSS feed iteme
|
|
msgHdrIsSent(msgHdr)
Tells if the message is a sent message
|
|
msgHdrMarkAsJunk(msgHdr)
|
|
msgHdrsArchive(msgHdrs)
Archive a set of messages
|
|
msgHdrsDelete(msgHdrs)
Delete a set of messages.
|
|
msgHdrsMarkAsRead(msgHdrs, read)
Mark an array of msgHdrs read (or unread)
|
|
msgHdrToMessageBody(aMessageHeader, aStripHtml, aLength)
Get a string containing the body of a messsage.
|
|
msgHdrToNeckoURL(aMsgHdr)
Get a nsIURI from a nsIMsgDBHdr
|
|
msgUriToMsgHdr(aUri)
Get a msgHdr from a message URI (msgHdr.URI).
|
|
NS_FAILED(v)
Low-level XPCOM-style macro.
|
|
NS_SUCCEEDED(v)
Low-level XPCOM-style macro.
|
|
parseMimeLine(aMimeLine)
Wraps the low-level header parser stuff.
|
|
plainTextToHtml(txt)
Just try to convert quoted lines back to HTML markup (<blockquote>s).
|
|
quoteMsgHdr(aMsgHdr, k)
Use the mailnews component to stream a message, and process it in a way
that's suitable for quoting (strip signature, remove images, stuff like
that).
|
|
range(begin, end)
Python-style range function to use in list comprehensions.
|
|
saveEmailInAddressBook(aBook, aEmail, aName)
Just a one-liner to add an email to the given address book, without any extra
properties.
|
|
sendMessage(composeParameters, sendingParameters, aNode, listeners, options)
This is our monstrous Javascript function for sending a message.
|
|
simpleWrap(txt, width)
Wrap some text.
|
Field Detail
gIdentities
A global pointer to all the identities known for the user. Feel free to call
fillIdentities again if you feel that the user has updated them!
The keys are email addresses, the values are nsIMsgIdentity objects.
Defined in: misc.js.
Defined in: misc.js.
kCollectedAddressBookUri
The "Collected addresses" address book
Defined in: addressBookUtils.js.
Defined in: addressBookUtils.js.
kPersonalAddressBookUri
The "Personal addresses" address book
Defined in: addressBookUtils.js.
Defined in: addressBookUtils.js.
Method Detail
-
{String} citeString(aStr)A function that properly quotes a plaintext email.
Defined in: compose.js.- Parameters:
- {String} aStr
- The mail body that we're expected to quote.
- Returns:
- {String} The quoted mail body with >'s properly taken care of.
-
{String} dateAsInMessageList(aDate)A stupid formatting function that uses the i18nDateFormatter XPCOM component to format a date just like in the message list
Defined in: misc.js.- Parameters:
- {Date} aDate
- a javascript Date object
- Returns:
- {String} a string containing the formatted date
-
{String} escapeHtml(s)Helper function to escape some XML chars, so they display properly in innerHTML.
Defined in: misc.js.- Parameters:
- {String} s
- input text
- Returns:
- {String} The string with <, >, and & replaced by the corresponding entities.
-
fillIdentities()This function you should call to populate the gIdentities global object. The recommended time to call this is after the mail-startup-done event, although doing this at overlay load-time seems to be fine as well. Beware, although gIdentities has a "default" key, it is not guaranteed to be non-null.
Defined in: misc.js. -
getAddressBookFromUri(aUri)Get one of the predefined address books through their URI.
Defined in: addressBookUtils.js.- Parameters:
- aUri
- the URI of the address book, use one of the consts above
- Returns:
- nsIAbDirectory the address book
-
{String} getArchiveFolderUriFor(identity, msgDate)Get the Archive folder URI depending on the given identity and the given Date object.
Defined in: send.js.- Parameters:
- {nsIMsgIdentity} identity
- {Date} msgDate
- Returns:
- {String} The URI for the folder. Use MailUtils.getFolderForURI.
-
getMail3Pane(aForce)Get the main Thunderbird window. Used heavily to get a reference to globals that are defined in mail/base/content/. You should call this function with true everytime your overlay on the main Thunderbird window is loaded, so that it invalidates the previous cached reference to the main window (closing the main window doesn't necessarily mean restarting Thunderbird).
Defined in: msgHdrUtils.js.- Parameters:
- {bool} aForce
- The results are cached, should we reset the cache?
- Returns:
- The window object for the main window.
-
{String} htmlToPlainText(aHtml)Convert HTML into text/plain suitable for insertion right away in the mail body. If there is text with >'s at the beginning of lines, these will be space-stuffed, and the same goes for Froms. <blockquote>s will be converted with the suitable >'s at the beginning of the line, and so on... This function also takes care of rewrapping at 72 characters, so your quoted lines will be properly wrapped too. This means that you can add some text of your own, and then pass this to simpleWrap, it should "just work" (unless the user has edited a quoted line and made it longer than 990 characters, of course).
Defined in: compose.js.- Parameters:
- {String} aHtml
- A string containing the HTML that's to be converted.
- Returns:
- {String} A text/plain string suitable for insertion in a mail body.
-
MixIn(aConstructor, aMixIn)MixIn-style helper. Adds aMixIn properties, getters and setters to aConstructor.
Defined in: misc.js.- Parameters:
- {Object} aConstructor
- {Object} aMixIn
-
{nsIMsgTag array} msgHdrGetTags(aMsgHdr)Given a msgHdr, return a list of tag objects. This function just does the messy work of understanding how tags are stored in nsIMsgDBHdrs.
Defined in: msgHdrUtils.js.- Parameters:
- {nsIMsgDbHdr} aMsgHdr
- the msgHdr whose tags we want
- Returns:
- {nsIMsgTag array} a list of tag objects
-
{String} msgHdrGetUri(aMsg)Get a given message header's uri.
Defined in: msgHdrUtils.js.- Parameters:
- {nsIMsgDbHdr} aMsg
- The message
- Returns:
- {String}
-
{bool} msgHdrIsArchive(msgHdr)Tells if the message is an archived message
Defined in: msgHdrUtils.js.- Parameters:
- {nsIMsgDbHdr} msgHdr
- The message header to examine
- Returns:
- {bool}
-
{bool} msgHdrIsDraft(msgHdr)Tells if the message is a draft message
Defined in: msgHdrUtils.js.- Parameters:
- {nsIMsgDbHdr} msgHdr
- The message header to examine
- Returns:
- {bool}
-
{bool} msgHdrIsInbox(msgHdr)Tells if the message is in the account's inbox
Defined in: msgHdrUtils.js.- Parameters:
- {nsIMsgDbHdr} msgHdr
- The message header to examine
- Returns:
- {bool}
-
{Bool} msgHdrIsJunk(msgHdr)Tell if a message has been marked as junk.
Defined in: msgHdrUtils.js.- Parameters:
- {nsIMsgDbHdr} msgHdr
- The message header
- Returns:
- {Bool}
-
{Bool} msgHdrIsNntp(msgHdr)Tell if a message is a NNTP message
Defined in: msgHdrUtils.js.- Parameters:
- {nsIMsgDbHdr} msgHdr
- The message header
- Returns:
- {Bool}
-
{Bool} msgHdrIsRss(msgHdr)Tell if a message is an RSS feed iteme
Defined in: msgHdrUtils.js.- Parameters:
- {nsIMsgDbHdr} msgHdr
- The message header
- Returns:
- {Bool}
-
{bool} msgHdrIsSent(msgHdr)Tells if the message is a sent message
Defined in: msgHdrUtils.js.- Parameters:
- {nsIMsgDbHdr} msgHdr
- The message header to examine
- Returns:
- {bool}
-
msgHdrMarkAsJunk(msgHdr)
Defined in: msgHdrUtils.js.- Parameters:
- msgHdr
-
msgHdrsArchive(msgHdrs)Archive a set of messages
Defined in: msgHdrUtils.js.- Parameters:
- {nsIMsgDbHdr array} msgHdrs
- The message headers
-
msgHdrsDelete(msgHdrs)Delete a set of messages.
Defined in: msgHdrUtils.js.- Parameters:
- {nsIMsgDbHdr array} msgHdrs
- The message headers
-
msgHdrsMarkAsRead(msgHdrs, read)Mark an array of msgHdrs read (or unread)
Defined in: msgHdrUtils.js.- Parameters:
- {nsIMsgDbHdr array} msgHdrs
- The message headers
- {bool} read
- True to mark them read, false to mark them unread
-
{string} msgHdrToMessageBody(aMessageHeader, aStripHtml, aLength)Get a string containing the body of a messsage.
Defined in: msgHdrUtils.js.- Parameters:
- {nsIMsgDbHdr} aMessageHeader
- The message header
- {bool} aStripHtml
- Keep html?
- aLength
- Returns:
- {string}
-
{nsIURI} msgHdrToNeckoURL(aMsgHdr)Get a nsIURI from a nsIMsgDBHdr
Defined in: msgHdrUtils.js.- Parameters:
- {nsIMsgDbHdr} aMsgHdr
- The message header
- Returns:
- {nsIURI}
-
{nsIMsgDbHdr} msgUriToMsgHdr(aUri)Get a msgHdr from a message URI (msgHdr.URI).
Defined in: msgHdrUtils.js.- Parameters:
- {String} aUri
- The URI of the message
- Returns:
- {nsIMsgDbHdr}
-
{Bool} NS_FAILED(v)Low-level XPCOM-style macro. You might need this for the composition and sending listeners which will pass you some status codes.
Defined in: misc.js.- Parameters:
- {Int} v
- The status code
- Returns:
- {Bool}
-
{Bool} NS_SUCCEEDED(v)Low-level XPCOM-style macro. You might need this for the composition and sending listeners which will pass you some status codes.
Defined in: misc.js.- Parameters:
- {Int} v
- The status code
- Returns:
- {Bool}
-
{Array} parseMimeLine(aMimeLine)Wraps the low-level header parser stuff.
Defined in: misc.js.- Parameters:
- {String} aMimeLine
- a line that looks like "John <john@cheese.com>, Jane <jane@wine.com>"
- Returns:
- {Array} a list of { email, name } objects
-
{String} plainTextToHtml(txt)Just try to convert quoted lines back to HTML markup (<blockquote>s).
Defined in: compose.js.- Parameters:
- {String} txt
- Returns:
- {String}
-
quoteMsgHdr(aMsgHdr, k)Use the mailnews component to stream a message, and process it in a way that's suitable for quoting (strip signature, remove images, stuff like that).
Defined in: compose.js.- Parameters:
- {nsIMsgDBHdr} aMsgHdr
- The message header that you want to quote
- {Function} k
- The continuation. This function will be passed quoted text suitable for insertion in a plaintext editor. The text must be appended to the mail body "as is", it shouldn't be run again through htmlToPlainText or whatever.
- Returns:
-
{Iterator} range(begin, end)Python-style range function to use in list comprehensions.
Defined in: misc.js.- Parameters:
- {Number} begin
- {Number} end
- Returns:
- {Iterator} An iterator that yields from begin to end - 1.
-
saveEmailInAddressBook(aBook, aEmail, aName)Just a one-liner to add an email to the given address book, without any extra properties.
Defined in: addressBookUtils.js.- Parameters:
- aBook
- the nsIAbDirectory
- aEmail
- the email
- aName
- (optional) the name
- Returns:
- nsIAbCard
-
sendMessage(composeParameters, sendingParameters, aNode, listeners, options)This is our monstrous Javascript function for sending a message. It hides all the atrocities of nsMsgCompose.cpp and nsMsgSend.cpp for you, and it provides what I hope is a much more understandable interface. You are expected to provide the whole set of listeners. The most interesting one is the stateListener, since it has the ComposeProcessDone notification. This version only does plaintext composition but I hope to enhance it with both HTML and plaintext in the future.
Defined in: send.js.- Parameters:
- composeParameters
- composeParameters.identity
- The identity the user picked to send the message
- composeParameters.to
- The recipients. This is a comma-separated list of valid email addresses that must be escaped already. You probably want to use nsIMsgHeaderParser.MakeFullAddress to deal with names that contain commas.
- composeParameters.cc
- Same remark.
- composeParameters.bcc
- Same remark.
- composeParameters.subject
- The subject, no restrictions on that one.
- sendingParameters
- sendingParameters.deliverType
- See Ci.nsIMsgCompDeliverMode
- sendingParameters.compType
- See Ci.nsIMsgCompType. We use this to determine what kind of headers we should set (Reply-To, References...).
- aNode
- The DOM node that holds the editing session. Right now, it's kinda useless if it's only plaintext, but it's relevant for the HTML composition (because nsMsgSend queries the original DOM node to find out about inline images).
- listeners
- listeners.progressListener
- That one monitors the progress of long operations (like sending a message with attachments), it's notified with the current percentage of completion.
- listeners.sendListener
- That one receives notifications about factual events (sending, copying to Sent, ...). It receives notifications with statuses.
- listeners.stateListener
- This one is a high-level listener that receives notifications about the global composition process.
- options
- options.popOut
- Don't send the message, just transfer it to a new composition window.
- options.archive
- Shall we archive the message right away? This won't even copy it to the Sent folder. Warning: this one assumes that the "right" Archives folder already exists.
-
{String} simpleWrap(txt, width)Wrap some text. Beware, that function doesn't do rewrapping, and only operates on non-quoted lines. This is only useful in our very specific case where the quoted lines have been properly wrapped for format=flowed already, and the non-quoted lines are the only ones that need wrapping for format=flowed. Beware, this function will treat all lines starting with >'s as quotations, even user-inserted ones. We would need support from the editor to proceed otherwise, and the current textarea doesn't provide this. This function, when breaking lines, will do space-stuffing per the RFC if after the break the text starts with From or >.
Defined in: compose.js.- Parameters:
- {String} txt
- The text that should be wrapped.
- {Number} width
- (optional) The width we should wrap to. Default to 72.
- Returns:
- {String} The text with non-quoted lines wrapped. This is suitable for sending as format=flowed.