Configuration .js snippets: where to put them?

26 views
Skip to first unread message

Marco Gaiarin

unread,
Jul 7, 2020, 11:45:21 AM7/7/20
to tb-ent...@mozilla.org

I need to (pre)configure an extension:

https://addons.thunderbird.net/it/thunderbird/addon/tbdialout/

that still use preferences for their configuration; so i've prepared a
'.js' snippet file with parameters and i've put it on:

%ProgramFiles%\Mozilla Thunderbird\defaults\preferences\tbdialout.js

but seems they are not taken into account.


What i'm doing wrong? Thanks.

--
dott. Marco Gaiarin GNUPG Key ID: 240A3D66
Associazione ``La Nostra Famiglia'' http://www.lanostrafamiglia.it/
Polo FVG - Via della Bontà, 7 - 33078 - San Vito al Tagliamento (PN)
marco.gaiarin(at)lanostrafamiglia.it t +39-0434-842711 f +39-0434-842797

Dona il 5 PER MILLE a LA NOSTRA FAMIGLIA!
http://www.lanostrafamiglia.it/index.php/it/sostienici/5x1000
(cf 00307430132, categoria ONLUS oppure RICERCA SANITARIA)
_____________________________________________________________________
Unsubscribe at: https://mail.mozilla.org/listinfo/tb-enterprise#subscribers <<<--- Unsubscribe
Reply to tb-enterprise mailing list at: tb-ent...@mozilla.org
Send questions about the list to: tb-enterp...@mozilla.org

Onno Ekker

unread,
Jul 7, 2020, 11:59:23 AM7/7/20
to tb-ent...@mozilla.org
Op 7-7-2020 om 17:45 schreef Marco Gaiarin:

> I need to (pre)configure an extension:
>
> https://addons.thunderbird.net/it/thunderbird/addon/tbdialout/
>
> that still use preferences for their configuration; so i've prepared a
> '.js' snippet file with parameters and i've put it on:
>
> %ProgramFiles%\Mozilla Thunderbird\defaults\preferences\tbdialout.js
>
> but seems they are not taken into account.
>
>
> What i'm doing wrong? Thanks.
>
This option has been removed, I think with Thunderbird 60 already.

For Thunderbird 68 and below you can add the default value for your
prefs in the code, something like this:

     var prefService =
Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
    var defaultBranch =
prefService.getDefaultBranch("extensions.tbdialout.");
    defaultBranch.setBoolPref("mypref", true);

For Thunderbird 78 (which will be released next week) and up you'll need
to convert your add-on to a MailExtension. Others can tell you how to do
it in there.

Onno

Marco Gaiarin

unread,
Jul 7, 2020, 12:18:05 PM7/7/20
to tb-ent...@mozilla.org
Mandi! Onno Ekker
In chel di` si favelave...

> This option has been removed, I think with Thunderbird 60 already.

Ops...


> For Thunderbird 68 and below you can add the default value for your
> prefs in the code, something like this:

I've tried with:

var prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
var defaultBranch = prefService.getDefaultBranch("extensions.tbdialout.");
defaultBranch.setBoolPref("proto", "asteriskami" );
defaultBranch.setBoolPref("ami.channel", "SIP/XXX" );
defaultBranch.setBoolPref("ami.context", "outcall" );
defaultBranch.setBoolPref("ami.host", "pbx.sv.lnf.it" );
defaultBranch.setBoolPref("ami.port", 5038 );
defaultBranch.setBoolPref("ami.user", "dialer" );
defaultBranch.setBoolPref("ami.pass", "dialer" );
defaultBranch.setBoolPref("ami.callerid", "tb/" );
defaultBranch.setBoolPref("ami.timeout", 15000 );

but seems does not work; still i have to put 'js' file in
'defaults\preferences\' folder?


> For Thunderbird 78 (which will be released next week) and up you'll need
> to convert your add-on to a MailExtension. Others can tell you how to do
> it in there.

I know that...

--
dott. Marco Gaiarin GNUPG Key ID: 240A3D66
Associazione ``La Nostra Famiglia'' http://www.lanostrafamiglia.it/
Polo FVG - Via della Bontà, 7 - 33078 - San Vito al Tagliamento (PN)
marco.gaiarin(at)lanostrafamiglia.it t +39-0434-842711 f +39-0434-842797

Dona il 5 PER MILLE a LA NOSTRA FAMIGLIA!
http://www.lanostrafamiglia.it/index.php/it/sostienici/5x1000
(cf 00307430132, categoria ONLUS oppure RICERCA SANITARIA)

Onno Ekker

unread,
Jul 7, 2020, 12:32:52 PM7/7/20
to tb-ent...@mozilla.org
Op 7-7-2020 om 18:17 schreef Marco Gaiarin:
> Mandi! Onno Ekker
> In chel di` si favelave...
>
>> This option has been removed, I think with Thunderbird 60 already.
> Ops...
>
>
>> For Thunderbird 68 and below you can add the default value for your
>> prefs in the code, something like this:
> I've tried with:
>
> var prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
> var defaultBranch = prefService.getDefaultBranch("extensions.tbdialout.");
> defaultBranch.setBoolPref("proto", "asteriskami" );
> defaultBranch.setBoolPref("ami.channel", "SIP/XXX" );
> defaultBranch.setBoolPref("ami.context", "outcall" );
> defaultBranch.setBoolPref("ami.host", "pbx.sv.lnf.it" );
> defaultBranch.setBoolPref("ami.port", 5038 );
> defaultBranch.setBoolPref("ami.user", "dialer" );
> defaultBranch.setBoolPref("ami.pass", "dialer" );
> defaultBranch.setBoolPref("ami.callerid", "tb/" );
> defaultBranch.setBoolPref("ami.timeout", 15000 );
>
> but seems does not work; still i have to put 'js' file in
> 'defaults\preferences\' folder?

No, the defaults/preferences folder is no longer used. You can keep it
maybe for backwards compatibility, but you don't need it, as the
function getDefaultBranch is also backwards compatible.

You have to change setBoolPref to setIntPref and setCharPref respectively.

And have you defined the constants?

const Cc = Components.classes, Ci = Components.interfaces;

HTH,

Onno

Marco Gaiarin

unread,
Jul 7, 2020, 12:58:02 PM7/7/20
to tb-ent...@mozilla.org
Mandi! Onno Ekker
In chel di` si favelave...

> No, the defaults/preferences folder is no longer used. You can keep it
> maybe for backwards compatibility, but you don't need it, as the
> function getDefaultBranch is also backwards compatible.
>
> You have to change setBoolPref to setIntPref and setCharPref respectively.
>
> And have you defined the constants?
>
> const Cc = Components.classes, Ci = Components.interfaces;

Ok, now my code is:

const Cc = Components.classes, Ci = Components.interfaces;
var prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
var defaultBranch = prefService.getDefaultBranch("extensions.tbdialout.");
defaultBranch.setCharPref("proto", "asteriskami" );
defaultBranch.setCharPref("ami.channel", "SIP/XXX" );
defaultBranch.setCharPref("ami.context", "outcall" );
defaultBranch.setCharPref("ami.host", "pbx.sv.lnf.it" );
defaultBranch.setIntPref("ami.port", 5038 );
defaultBranch.setCharPref("ami.user", "dialer" );
defaultBranch.setCharPref("ami.pass", "dialer" );
defaultBranch.setCharPref("ami.callerid", "tb/" );
defaultBranch.setIntPref("ami.timeout", 15000 );

but still i don't now where to put it; a .js in defaults/preferences
folder seems not suffices...

Thanks.

--
dott. Marco Gaiarin GNUPG Key ID: 240A3D66
Associazione ``La Nostra Famiglia'' http://www.lanostrafamiglia.it/
Polo FVG - Via della Bontà, 7 - 33078 - San Vito al Tagliamento (PN)
marco.gaiarin(at)lanostrafamiglia.it t +39-0434-842711 f +39-0434-842797

Dona il 5 PER MILLE a LA NOSTRA FAMIGLIA!
http://www.lanostrafamiglia.it/index.php/it/sostienici/5x1000
(cf 00307430132, categoria ONLUS oppure RICERCA SANITARIA)

Onno Ekker

unread,
Jul 7, 2020, 1:06:39 PM7/7/20
to tb-ent...@mozilla.org
Op 7-7-2020 om 18:57 schreef Marco Gaiarin:
> Mandi! Onno Ekker
> In chel di` si favelave...
>
>> No, the defaults/preferences folder is no longer used. You can keep it
>> maybe for backwards compatibility, but you don't need it, as the
>> function getDefaultBranch is also backwards compatible.
>>
>> You have to change setBoolPref to setIntPref and setCharPref respectively.
>>
>> And have you defined the constants?
>>
>> const Cc = Components.classes, Ci = Components.interfaces;
> Ok, now my code is:
>
> const Cc = Components.classes, Ci = Components.interfaces;
> var prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
> var defaultBranch = prefService.getDefaultBranch("extensions.tbdialout.");
> defaultBranch.setCharPref("proto", "asteriskami" );
> defaultBranch.setCharPref("ami.channel", "SIP/XXX" );
> defaultBranch.setCharPref("ami.context", "outcall" );
> defaultBranch.setCharPref("ami.host", "pbx.sv.lnf.it" );
> defaultBranch.setIntPref("ami.port", 5038 );
> defaultBranch.setCharPref("ami.user", "dialer" );
> defaultBranch.setCharPref("ami.pass", "dialer" );
> defaultBranch.setCharPref("ami.callerid", "tb/" );
> defaultBranch.setIntPref("ami.timeout", 15000 );
>
> but still i don't now where to put it; a .js in defaults/preferences
> folder seems not suffices...
>
> Thanks.
>
This shouldn't be in a .js file in default/preferences, but somewhere in
the initialization stage of your add-on, maybe in a separate init
function that gets called at startup.

Onno

Marco Gaiarin

unread,
Jul 8, 2020, 7:09:03 AM7/8/20
to tb-ent...@mozilla.org
Mandi! Onno Ekker
In chel di` si favelave...

> This shouldn't be in a .js file in default/preferences, but somewhere in
> the initialization stage of your add-on, maybe in a separate init
> function that gets called at startup.

So, it is every addon that need to have some 'mechanism' to load
preferences?

Thhere's no some 'central places' for this stuff?


Thanks.

--
dott. Marco Gaiarin GNUPG Key ID: 240A3D66
Associazione ``La Nostra Famiglia'' http://www.lanostrafamiglia.it/
Polo FVG - Via della Bontà, 7 - 33078 - San Vito al Tagliamento (PN)
marco.gaiarin(at)lanostrafamiglia.it t +39-0434-842711 f +39-0434-842797

Dona il 5 PER MILLE a LA NOSTRA FAMIGLIA!
http://www.lanostrafamiglia.it/index.php/it/sostienici/5x1000
(cf 00307430132, categoria ONLUS oppure RICERCA SANITARIA)
Reply all
Reply to author
Forward
0 new messages