I have worked on Mozilla Add-on Development in the past (beginner level). But on encountering XPCOM, I got really scared and left it in the middle.
Recently only I encountered Add-on SDK and found it to be really cool, and it was really fascinating to see that the work that took months before was not more than 2 days work with the SDK. Now again I am stuck on the XPCOM module.
Now I really want to exploit the power of XPCOM but it will take me at least a week to get familiar with XPCOM in the context of SDK. What code do I need to obtain the functionality that I desire?
-
For each user session, I want to log something. I am able to differentiate sessions. What I want now is the code to create a file in the user’s machine, open it from the add-on and write something onto it.
-
Code to access the bookmarks and downloads and to read them.
It would really be a heart-breaking moment if I would have to switch back from SDK.
The
chromepackage gives you full XPCOM access. For file access it is best to use theFileUtilsmodule:The somewhat unusual syntax to import the module is due to bug 683217. Note that
FileUtils.openFileOutputStream()is only available starting with Firefox 7 andFileUtils.openSafeFileOutputStream()isn’t usable if you want to append to a file.For bookmark access you use the usual code snippets, starting with: