Legacy add-on for Thunderbird 64 can't override nsIPromptService

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

Legacy add-on for Thunderbird 64 can't override nsIPromptService

Mozilla - Thunderbird mailing list
Hi!
I'm author of the extension for Thunderbird, which allows to autofill the mail accounts credentials automatically with data stored in the external Password Manager application.
The extension works fine until Thunderbird 64.
I updated the extension code according to the requirements https://wiki.mozilla.org/Thunderbird/Add-ons_Guide_63 but got this errors:

SyntaxError: illegal character[Learn More] spIPromptService.js:1:1
NS_ERROR_XPC_GS_RETURNED_FAILURE: Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]

I do have this lines in the chrome.manifest file:
component {83BECBC2-94C7-11DB-B856-728655D89593} components/spIPromptService.js
contract @mozilla.org/embedcomp/prompt-service;1 {83BECBC2-94C7-11DB-B856-728655D89593}

And here is the part of the component JS:
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");

function TspPromptService() {
  // initialization code
  this.RealPromptService = ...
}

TspPromptService.prototype = {
  classID: Components.ID('{83BECBC2-94C7-11DB-B856-728655D89593}'),
   
  // nsIPromptService and nsIPromptService2 implementations
  QueryInterface: function(aIID)
  {
    return this.RealPromptService.QueryInterface(aIID);
  },
 
  alert: function(aParent, aDialogTitle, aText)
  {
    this.RealPromptService.alert(aParent, aDialogTitle, aText);
  },

  // other functions implementation
  ...  
};

var NSGetFactory = XPCOMUtils.generateNSGetFactory([TspPromptService]);

Where this.RealPromptService is obtained directly from the original nsIPromptService2 or nsIPromptService services.

Can I make my extension works under Thunderbird 64? Or starting from Thunderbird 64 such code won't work at all?
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Legacy add-on for Thunderbird 64 can't override nsIPromptService

Philipp Kewisch-2
This sounds like you have an UTF-8 BOM in the file, because of
|SyntaxError: illegal character|. Maybe check if there are other illegal
characters.

With that fixed it should work again, but if not maybe try manually
unregistering the old prompt service in the component manager and then
registering your own.

See
https://searchfox.org/comm-central/source/mail/test/mozmill/shared-modules/test-prompt-helpers.js#184
for how we overwrite the prompt service in tests. Note that
unregistering xpcom components can be a bit flaky.

Philipp


On 12/13/18 3:49 PM, [hidden email] wrote:

> Hi!
> I'm author of the extension for Thunderbird, which allows to autofill the mail accounts credentials automatically with data stored in the external Password Manager application.
> The extension works fine until Thunderbird 64.
> I updated the extension code according to the requirements https://wiki.mozilla.org/Thunderbird/Add-ons_Guide_63 but got this errors:
>
> SyntaxError: illegal character[Learn More] spIPromptService.js:1:1
> NS_ERROR_XPC_GS_RETURNED_FAILURE: Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]
>
> I do have this lines in the chrome.manifest file:
> component {83BECBC2-94C7-11DB-B856-728655D89593} components/spIPromptService.js
> contract @mozilla.org/embedcomp/prompt-service;1 {83BECBC2-94C7-11DB-B856-728655D89593}
>
> And here is the part of the component JS:
> ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
> ChromeUtils.import("resource://gre/modules/Services.jsm");
>
> function TspPromptService() {
>   // initialization code
>   this.RealPromptService = ...
> }
>
> TspPromptService.prototype = {
>   classID: Components.ID('{83BECBC2-94C7-11DB-B856-728655D89593}'),
>    
>   // nsIPromptService and nsIPromptService2 implementations
>   QueryInterface: function(aIID)
>   {
>     return this.RealPromptService.QueryInterface(aIID);
>   },
>  
>   alert: function(aParent, aDialogTitle, aText)
>   {
>     this.RealPromptService.alert(aParent, aDialogTitle, aText);
>   },
>
>   // other functions implementation
>   ...  
> };
>
> var NSGetFactory = XPCOMUtils.generateNSGetFactory([TspPromptService]);
>
> Where this.RealPromptService is obtained directly from the original nsIPromptService2 or nsIPromptService services.
>
> Can I make my extension works under Thunderbird 64? Or starting from Thunderbird 64 such code won't work at all?
>

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

Re: Legacy add-on for Thunderbird 64 can't override nsIPromptService

Mozilla - Thunderbird mailing list
Philipp, thank you so much for your fast reply!
It helped me a lot and now my extension works like before. It looks like it's my text editor changed the JS file encoding to UTF-8 and there was BOM in the file.

Small off-topic - still can't understand what's wrong if JS file has UTF-8 encoding? May be it's a bug in the Mozilla code?
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Legacy add-on for Thunderbird 64 can't override nsIPromptService

Jörg Knobloch
On 14/12/2018 14:24, aleksandr.guk--- via dev-apps-thunderbird wrote:
> Small off-topic - still can't understand what's wrong if JS file has UTF-8 encoding?

Hmm, the BOM would upset it. Do you have non-ASCII characters in your
code? If not, ASCII, windows-1252, ISO-8859-1, UTF-8 and other
ASCII-compatible encoding all produce the same. What is the working
encoding?

Jörg.

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

Re: Legacy add-on for Thunderbird 64 can't override nsIPromptService

Mozilla - Thunderbird mailing list
Jörg, my working encoding is ASCII and no other encoding used.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Legacy add-on for Thunderbird 64 can't override nsIPromptService

Mozilla - Thunderbird mailing list
In reply to this post by Mozilla - Thunderbird mailing list
By the way I read this information here https://thunderbird-webextensions.readthedocs.io/en/latest/legacy.html:
"Legacy extensions will not be around forever, and possibly will not even make it to Thunderbird 68."

Does it mean that after legacy extensions will be completely removed from Thunderbird than I would not be able to override nsIPromptService anymore? And my extension would be non-functional at all?
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Legacy add-on for Thunderbird 64 can't override nsIPromptService

Philipp Kewisch-2
On 12/17/18 3:38 PM, [hidden email] wrote:
> By the way I read this information here https://thunderbird-webextensions.readthedocs.io/en/latest/legacy.html:
> "Legacy extensions will not be around forever, and possibly will not even make it to Thunderbird 68."
>
> Does it mean that after legacy extensions will be completely removed from Thunderbird than I would not be able to override nsIPromptService anymore? And my extension would be non-functional at all?
>

It depends. Try to think of it in a different way. You want to provide
authentication instead of popping up the prompt dialog, correct? So
you'd rather need an API that allows you to provide the authentication
instead of having Thunderbird prompt for it.

This kind of API sounds like something that would make sense for
MailExtensions, and we could certainly use your help in devising it.

An API that specifically overrides nsIPromptService would not, because
it is tied to the technical implementation of the prompt service.

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: Legacy add-on for Thunderbird 64 can't override nsIPromptService

Mozilla - Thunderbird mailing list
Philipp, our extension implements 2 features:
1) Silent authentication for mail accounts without displaying original Thunderbird prompt dialog. This is done via overriding nsIPromptService, in such a way we can return the password for requested mail account from our Password Manager secure database.
2) Possibility to add mail account to Password Manager directly from Thunderbird prompt dialog. We just override original Thunderbird dialog with our own one (which looks almost the same as Thunderbird one) using original texts passed to nsIPromptService methods, using our Context Menu user is able to create Mail Account in Password Manager very fast. It is not a short task to describe how does this feature works.

I would be very appreciated if we can implement the API for feature #1 at least. Let me know if you need my help or any technical details.


On Thursday, December 20, 2018 at 2:26:51 PM UTC+2, Philipp Kewisch wrote:

> On 12/17/18 3:38 PM, [hidden email] wrote:
> > By the way I read this information here https://thunderbird-webextensions.readthedocs.io/en/latest/legacy.html:
> > "Legacy extensions will not be around forever, and possibly will not even make it to Thunderbird 68."
> >
> > Does it mean that after legacy extensions will be completely removed from Thunderbird than I would not be able to override nsIPromptService anymore? And my extension would be non-functional at all?
> >
>
> It depends. Try to think of it in a different way. You want to provide
> authentication instead of popping up the prompt dialog, correct? So
> you'd rather need an API that allows you to provide the authentication
> instead of having Thunderbird prompt for it.
>
> This kind of API sounds like something that would make sense for
> MailExtensions, and we could certainly use your help in devising it.
>
> An API that specifically overrides nsIPromptService would not, because
> it is tied to the technical implementation of the prompt service.
>
> Philipp

_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird