Thunderbird: getting messageManager for currently displayed

Talk about add-ons and extension development.
Post Reply
susbox
Posts: 20
Joined: July 9th, 2007, 9:16 am

Thunderbird: getting messageManager for currently displayed

Post by susbox »

Hi friends,

In Firefox we use the gBrowser.selectedBrowser.messageManager to be capable of using the sendAsyncMessage function to communicate to a proper script.

How do we get a messageManager in Thunderbird? The window.messageManager supports only nsIMessageBroadcaster, so there's no way to send a message to specific script using sendAsyncManager.

My solution is:

var emailMessageManager = window.messageManager.getChildAt(0);
emailMessageManager.sendAsyncMessage(...)

I wonder if there is a proper way to obtain this messageManager?
lithopsian
Posts: 3664
Joined: September 15th, 2010, 9:03 am

Re: Thunderbird: getting messageManager for currently displa

Post by lithopsian »

This is a proper way. Is it always child zero that you want?

You can get individual browsers in Thunderbird. Do they not have a messageManager property defined? If not then something like this might work:

Code: Select all

aBrowser.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager;
Sorry, I haven't done this in Thunderbird so I have no idea if that makes sense.
susbox
Posts: 20
Joined: July 9th, 2007, 9:16 am

Re: Thunderbird: getting messageManager for currently displa

Post by susbox »

Thanks, lithopsian

You gave me a hint. That was really easy:

Code: Select all

var msgMgr = window.getBrowser().messageManager;
lithopsian
Posts: 3664
Joined: September 15th, 2010, 9:03 am

Re: Thunderbird: getting messageManager for currently displa

Post by lithopsian »

Ah, so the browser does have a messageManager property in Thunderbird. That's good.
Post Reply