How to translate a (Webextension) MessageHeader.id to nsIMsgDBHdr?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to translate a (Webextension) MessageHeader.id to nsIMsgDBHdr?

brummolixtest
In the new Webextension APIs there are messages (https://thunderbird-webextensions.readthedocs.io/en/latest/messages.html).

Also there is the possibility to include a WebExtension experiment into the addon  to create functions which are not possible with Webextension API (https://thunderbird-webextensions.readthedocs.io/en/latest/how-to/experiments.html).

I managed to work with messages and to create an WebExtension experiment.

Is there a way to get a nsIMsgDBHdr (https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMsgDBHdr) from an MessageHeader.id?

(And same for folders: MailFolder to nsIMsgFolder
(https://thunderbird-webextensions.readthedocs.io/en/latest/accounts.html#mailfolder / https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMsgFolder)
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: How to translate a (Webextension) MessageHeader.id to nsIMsgDBHdr?

brummolixtest
In https://hg.mozilla.org/comm-central/file/tip/mail/components/extensions/parent/ext-mail.js there is a messageTracker.getMessage(id)

Is this something I can use? How can I get access to it?
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: How to translate a (Webextension) MessageHeader.id to nsIMsgDBHdr?

Philipp Kewisch-2



On 2/23/19 12:13 AM, [hidden email] wrote:
> In https://hg.mozilla.org/comm-central/file/tip/mail/components/extensions/parent/ext-mail.js there is a messageTracker.getMessage(id)
>
> Is this something I can use? How can I get access to it?
>

Just to make sure I got this correctly. You cannot get a nsIMsgDBHdr
from within a WebExtension, this goes against the principle of
WebExtension APIs.

You can however user nsIMsgDBHdr's internally in WebExtension
Experiments code. When one of your API method returns or takes a message
or message id, you need to make sure to wrap it in a Message object.

You can access anything in ext-mail.js that is on the global object. You
should also be interested in
https://hg.mozilla.org/comm-central/file/tip/mail/components/extensions/parent/ext-messages.js#l34
which actually gets the msgdbhdr from a message id.

Philipp
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: How to translate a (Webextension) MessageHeader.id to nsIMsgDBHdr?

brummolixtest
My idea was to use the webextension api to get messages and then to pass the message id to webextension experiment code to do things with messages that are not possible with webextension api (yet).

I saw, that https://hg.mozilla.org/comm-central/file/tip/mail/components/extensions/parent/ext-messages.js#l34 gets the msgdbhdr from a message id via messagetracker.

But how can I access the messagetracker? It is not on the global object?
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: How to translate a (Webextension) MessageHeader.id to nsIMsgDBHdr?

Geoff Lankow-3
On 24/02/19 06:37, [hidden email] wrote:
> My idea was to use the webextension api to get messages and then to pass the message id to webextension experiment code to do things with messages that are not possible with webextension api (yet).
>
> I saw, that https://hg.mozilla.org/comm-central/file/tip/mail/components/extensions/parent/ext-messages.js#l34 gets the msgdbhdr from a message id via messagetracker.
>
> But how can I access the messagetracker? It is not on the global object?
>

Your webextension experiment isn't on the global object either, but they
are both in the same scope.

GL
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: How to translate a (Webextension) MessageHeader.id to nsIMsgDBHdr?

brummolixtest
I seem to miss something or do not understand:
If I call messageTracker in webextension experiment I only get "messageTracker is not defined"?
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: How to translate a (Webextension) MessageHeader.id to nsIMsgDBHdr?

Geoff Lankow-3
Okay, I'm sorry, my understanding of how things work was wrong. It's
been some time since I looked at experiments. From the context object
passed to getAPI, you should be able to access
context.extension.windowManager, correct? We need to add similar
"managers" that you can access that way. I'll get on to that this week,
as it's quite important.

GL

On 26/02/19 12:36, [hidden email] wrote:
> I seem to miss something or do not understand:
> If I call messageTracker in webextension experiment I only get "messageTracker is not defined"?
>
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: How to translate a (Webextension) MessageHeader.id to nsIMsgDBHdr?

brummolixtest
I can access context.extension.windowManager
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird