User:Jminta/Mail XPCOMUtils: Difference between revisions
(initial page) |
No edit summary |
||
| Line 8: | Line 8: | ||
=== How do I write the patch? === | === How do I write the patch? === | ||
# Find a javascript component file (see list below). | # Find a javascript component file (see list below). | ||
# Import the XPCOMUtils module | |||
# Replace any QueryInterface functions with XPCOMUtils.generateQI | # Replace any QueryInterface functions with XPCOMUtils.generateQI | ||
# Remove any nsIFactory and nsIModule implementations | # Remove any nsIFactory and nsIModule implementations | ||
Revision as of 03:16, 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?
- Find a javascript component file (see list below).
- Import the XPCOMUtils module
- Replace any QueryInterface functions with XPCOMUtils.generateQI
- Remove any nsIFactory and nsIModule implementations
- Add in the appropriate fields to the component's prototype. (see this example)
- 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: