User:Jminta/Mail XPCOMUtils: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
 
Line 20: Line 20:
=== Which files need to be fixed? ===
=== Which files need to be fixed? ===
Any javascript component file. Tentative list:
Any javascript component file. Tentative list:
*[http://mxr.mozilla.org/seamonkey/source/mail/components/shell/nsSetDefaultMail.js nsSetDefaultMail.js] Fixed in [https://bugzilla.mozilla.org/show_bug.cgi?id=410727 bug 410727]
*[http://mxr.mozilla.org/seamonkey/source/mail/extensions/newsblog/js/newsblog.js newsblog.js]
*[http://mxr.mozilla.org/seamonkey/source/mail/extensions/newsblog/js/newsblog.js newsblog.js]
*[http://mxr.mozilla.org/seamonkey/source/mail/components/search/nsSpotlightIntegration.js nsSpotlightIntegration.js]
*[http://mxr.mozilla.org/seamonkey/source/mail/components/search/nsSpotlightIntegration.js nsSpotlightIntegration.js]

Latest revision as of 20:25, 4 January 2008

Writing XPCOMUtils patches for Thunderbird is a great way to get beginning exposure to a specific area of the codebase. This page provides a brief tutorial on how to go about writing one of these patches.

What is XPCOMUtils?

XPCOMUtils is a javascript module that can be included in any javascript file via Components.utils.import. The module is only compiled once, meaning that putting repetitive code in a module can result in startup improvements.

Specifically, XPCOMUtils provides functions that simplify the registration process for XPCOM components.

How do I write the patch?

  1. Find a javascript component file (see list below).
  2. Import the XPCOMUtils module
  3. Replace any QueryInterface functions with XPCOMUtils.generateQI
  4. Remove any nsIFactory and nsIModule implementations
  5. Add in the appropriate fields to the component's prototype. (see this example)
  6. Replace the NSGetModule implementation

Then test your patch (rebuild Thunderbird and watch your console during startup to see that your component is registered), file a bug, attach it, and request a review.

Here is an example patch.

Which files need to be fixed?

Any javascript component file. Tentative list: