Questions and answers from the newsgroups 2006 10 20

Return to mozilla-dev-extensions


(ā†‘ top)

How to get a reference to the sidebar window
Assuming you have chrome privileges, this should work:
var Ci = Components.interfaces;
var topLevelWindow = 
var sidebar = topLevelWindow.document.getElementById("sidebar");
Is there anyone successfully using Dojo in a Firefox extension and where to fine sample codes?
The problem with most JS frameworks is that they bootstrap by dynamically appending script elements, which doesn't work in XUL, last I checked. Take a look at the bottom of

see what it's trying to load and write out the script element by hand.

Could someone write an extension that would collapse the current sidebar in Firefox?
These are called "Grippies"

This extension brings grippies back to Firefox (and Thunderbird!)

Would anyone be able to suggest the best way to do source level debugging in a Firefox extension?
In the Debug menu, uncheck Exclude Browser Files.
Use the debugger by typing in a command like this: /break chrome://myextension/content/myfile.js 123
Then I suggest using flat chrome. If you turn off the XUL cache you don't even need to restart to see changes, simply open a new window.
How can I backup some of the files before upgrade an extension and put them back afterward? Do I need to write an installation script to achieve this?
You shouldn't store data there, so there's nothing to backup.
Do not store files within the extension directory.
The Profile directory is meant to do so.
Storing files within the extension directory is a no-no because it might break the multi-user support of those Mozilla products, as it is possible to install extensions directly within the application directory.
Inspector, Talkback and the default theme are nowadays installed like this.
Does Firefox clean up the preferences set by extension? If not, how to proceed?
When user chooses to uninstall an extension, a nsIObserverService notification is sent out. The problem is, while your extension is still active, user can cancel uninstallation, and when it is physically uninstalled, your code can't run.
Right. And if you uninstall Firefox, the profile data is left behind.
It would be nice to give the option of clearing extension's data, but it should be implemented at application level, not by each extension individually.
It might be an option to stick with it and perform stuff when it comes to application shutdown.
The Sanitize stuff does this (clean stuff on exit).
Firefox will clean all those preferences which are still "default", that is not changed by the user or the application/extension.
To provide those default preferences to your extension see:
BTW: Resetting prefences to default will clear them in case no default prefence is (still) available.
Those will be completely removed upon next application launch.
Is it possible to create a sidebar on the top of the page?
Not unless you make it a separate window. There's a bug in bugzilla about stacking other widgets on top of browser/iframe, which hopefully will be fixed for Gecko 1.9.
CustomizeGoogle extension already has support for switching Gmail to HTTPS (and calendar possibly, too).
Does anyone know how write a bounce email extension?
Are you aware of the "mailredirect" extension? It allows bouncing to arbitrary addresses. It seems what you want is a one button access to that extension with a prefilled bounce address, right?
Is each window is essentially a separate JavaScript sandbox?
It's best to define singletons as custom XPCOM services. You'll avoid problems like these.
could someone make an extension for Thunderbird that preview upcoming events and number of new messages?
In our company I write this extension that connects to our GroupWare server (HTTP). What server should search extension work against? Did you mean Exchange?
How to attach information using the StringProperties of an IMAP message with out changing the properties?
String properties are implemented as IMAP user flags. However not all servers support user flags, in which case you get reduced functionality as follows: all flags are stored in your local cache and are lost if your cache gets invalidated, and only "known" properties are copied when messages are copied. The list of "known" properties is: junkscore junkscoreorigin label priority keywords.
Keywords - In the GUI they are called Tags. They replace the old Labels.
Preserved properties source code - nsImapMailFolder::CopyMessages
Why xbl thinks method is not a function?
It's a common oversight when working with JavaScript callbacks. Both setTimeout( fn, ... ) and addEventListener(receiver, fn, .. ) have this problem. In the case of setTimeout fn is called with this equal to the window. In the case of addEventListener fn is called with this equal to the receiver that you added the event listener to. In your case that is also the window.
It is possible to get events and timer notifications in an object-oriented manner. For events it is as simple as passing an object instead of a function. This object's handleEvent method will get called with this equal to the object itself. However you would need to add logic to distinguish multiple events, or create a separate object for each event, which would require you to track event objects to avoid leaking.
If you want an object-oriented timer callback then currently the only way to do this is from an extension where you can use the timer service to register a callback object. This object's notify method will get called with this equal to the object itself. In this case it is even more vital that you track your objects to avoid leaking.


(ā†‘ top)