arlolra / ctypes-otr

js-ctypes wrapper for libotr
Mozilla Public License 2.0
29 stars 7 forks source link

Cannot access add-on defaults preferences #81

Closed vqhuy closed 8 years ago

vqhuy commented 8 years ago

I'm trying to set up some default preferences for the add-on. This is the add-on directory structure:

|chrome
+--|content
+--|skin
+--|defaults 
   +--|preferences
      +--|prefs.js

And this is the content of prefs.js file:

pref('extensions.otr.serverIP', '127.0.0.1');

In the javascript file with the function I have

1. let prefManager = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
2. let url = prefManager.getIntPref("extensions.otr.serverIP");

However, instead of returning the preference value, line 2 throws an exception:

Error: NS_ERROR_UNEXPECTED: Component returned failure code: 0x8000ffff
(NS_ERROR_UNEXPECTED) [nsIPrefBranch.getIntPref]

Any ideas as to where I'm going wrong?

arlolra commented 8 years ago

Yeah, preferences in bootstrapped extensions work a little differently. Please see ui.setPrefs(); in ui.js. Let me know if what's there makes sense to you.

vqhuy commented 8 years ago

Thanks! It worked.