Thunderbird:Start Hacking: Difference between revisions

(initial cut)
 
(link to bug queries wiki page)
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<small>[[Thunderbird:Dev|<< Back to Thunderbird Dev page]]</small>
<small>[[Thunderbird/Development|<< Back to Thunderbird Dev page]]</small>


== Beginner's Guide to Hacking Thunderbird ==
== Beginner's Guide to Hacking Thunderbird ==
Line 6: Line 6:
=== Getting the right tools ===
=== Getting the right tools ===
Before you can begin, you're going to need several tools setup on your computer.
Before you can begin, you're going to need several tools setup on your computer.
'''Note:''' Some hackers have found it useful to simply begin by building Thunderbird from source. ([http://gemal.dk/mozilla/build.html Windows Instructions]) If you can do this, you will (almost) automatically have all the right tools to begin hacking.  However, since building is a rather complicated process, you may wish to come back to it at a later stage.
'''Note:''' Some hackers have found it useful to simply begin by building Thunderbird from source. ([https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Simple_Thunderbird_build Instructions]) If you can do this, you will (almost) automatically have all the right tools to begin hacking.  However, since building is a rather complicated process, you may wish to come back to it at a later stage.


You will need:
You will need:
* [https://bugzilla.mozilla.org/createaccount.cgi A Bugzilla account]
* [https://bugzilla.mozilla.org/createaccount.cgi A Bugzilla account]
* A jar extract/build tool.
* A program to extract the contents of .jar files (which are named as .ja files in Thunderbird's case). E.g. [http://7-zip.org/ 7-zip] on Windows.
** Most zip utilities are capable of working with .jar files as well.  Some may require that you rename .jar files to .zip first
** Most zip utilities are capable of working with .jar files as well.  Some may require that you rename .jar files to .zip first
** Windows XP can handle zip files by default but misses some higher-end functions which are necessary to work effectively on Thunderbird. [http://www.filzip.com/ FilZip] is a viable freeware alternative.
* A [http://ftp.mozilla.org/pub/thunderbird/nightly/latest-comm-central/ current nightly build] of Thunderbird
* A [http://ftp.mozilla.org/pub/mozilla.org/thunderbird/nightly/latest-trunk/ current nightly build] of Thunderbird
* A text-editor, who is capable of working with files created on Windows, Linux or Mac OS X.
* A text-editor, who is capable of working with files created on Windows, Linux or Mac OS X.
** Windows users are strongly discouraged from using the Notepad text-editor. Viable freeware alternatives are [http://www.flos-freeware.ch/notepad2.html notepad2] and [http://http://www.pspad.com/ PSPad]. These editors will get you a better view of the code (i.e you will see which braces close which codeblocks, 'if','var' and so on will be bold, among other stuff).
** Windows users must not use Windows' Notepad text-editor which doesn't show Linux linebreaks properly. A viable freeware alternative for Windows is [https://notepad-plus-plus.org/download/ Notepad++]. This editor will get you a better view of the code (i.e you will see which braces close which codeblocks, 'if','var' and so on will be bold, among other stuff).
* A program capable of creating DIFF files (Most CVS programs are capable of doing this.)
** Windows users who do not want to install the recommended CVS programm might use [http://gnuwin32.sourceforge.net/packages/diffutils.htm diffutils] from the GnuWin32 project.
* A CVS program (kinda optional, but not really)


'''Linux users''' will find most of these programs available by default with their distro.
'''Linux users''' will find most of these programs available by default with their distro.


'''Windows users''' won't have all of these tools installed by default, but if you have followed the windows build instructions above, you have downloaded the required tools.
'''Windows users''' won't have all of these tools installed by default, but if you have followed the [https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Simple_Thunderbird_build build instructions] above, you have downloaded the required tools.


=== Hacking! ===
=== Hacking! ===
Line 29: Line 25:
1.) If you haven't done so already, unzip your current nightly build of Thunderbird and make sure it runs properly.  Then close it.
1.) If you haven't done so already, unzip your current nightly build of Thunderbird and make sure it runs properly.  Then close it.


2.) Open the 'chrome' folder inside the folder where you unzipped Thunderbird.
2.) Inside the folder where you unzipped Thunderbird, open the 'omni.ja' file with the zip program. Rename it to omni.zip if necessary to unzip it. Unzip the contents into a folder, let's say 'omni'.


Here you will find a variety of files that create the front-end of the application.
3.) In the 'omni' folder, delete the folders 'jsloader' and 'jssubloader'. These have source files cached for faster loading and if you don't remove them, your changes to the real source files will be ignored by Thunderbird.
* <tt>classic.jar</tt> - contains many of the css (style) files for the default theme
* <tt>comm.jar</tt> - contains some of the core "communicator" files (you usually won't worry about these.)
* <tt>en-US.jar</tt> - these contain the strings used in the application, translated to English.  When using another locale, you may see a different jar
* <b><tt>messenger.har</tt></b> - this is where most of the XUL and JS files for Thunderbird are.
* <tt>newsblog.jar</tt> - contains files specific to blog-reading (rss)
* <tt>toolkit.jar</tt> - the common files shared by all Mozilla toolkit applications (Firefox, Thunderbird, etc).  These define common widgets and other useful tools.


3.) Find the messenger.jar file and open it with your jar (zip) tool.
In the 'omni' folder, you find a variety of folders that create the front-end of the application.
* <tt>content</tt> - many of the front-end files
* <tt>components</tt> - some often used files (in different contexts).
* <tt>defaults</tt> - default values for preferences
* <tt>hyphenation</tt> - dictionaries used in compose context
* <tt>modules</tt> - often used files which once imported share their properties with all context which have been imported to (set a property to 1 in context A and context B will see that value)
* <tt>res</tt> - resources like graphics, e.g. for the HTML compose editor
 
The 'content' folder has the following subfolders:
* <tt>chat</tt> - contains files for the instant messaging and social media component of Thunderbird
* <tt>classic</tt> - contains many of the css (style) and image files for the default theme
* <tt>comm</tt> - contains some of the core "communicator" files (you usually won't worry about these.)
* <tt>devtools</tt> - contains the developer tools, e.g. the code for the error console
* <tt>en-US</tt> - these contain the strings used in the application, translated to English.  When using another locale, you may see a different folder name.
* <tt>gloda</tt> - the files for the <b>glo</b>bal search <b>da</b>tabase. Used to search across folders
* <b><tt>messenger</tt></b> - this is where most of the XUL and JS files for Thunderbird are.
* <tt>newsblog</tt> - contains files specific to blog-reading (RSS)
* <tt>pippki</tt> - certificate management related files
* <tt>toolkit</tt> - the common files shared by all Mozilla toolkit applications (Firefox, Thunderbird).  These define common widgets and other useful tools.
 
4.) Open the folder 'messenger'.


Inside here you will find a <tt>content</tt> folder, with 4 sub-folders
Inside here you will find a <tt>content</tt> folder, with 4 sub-folders
* <tt>branding</tt> - Thunderbird specific branding materials
* <tt>branding</tt> - Thunderbird specific branding materials
* <tt>editor</tt> - files for the html editor used to compose mail
* <tt>messagebody</tt> - contains a file used for printing the address book
* <b></tt>messenger</tt></b> - most front-end files for Thunderbird
* <b><tt>messenger</tt></b> - most front-end files for Thunderbird
* <tt>smime</tt> - files related to smime processing
* <tt>messenger-smime</tt> - files related to smime processing


==== XUL Hacking ====
==== XUL Hacking ====
Our first hack is going to be to add a bit of personalization to Thunderbird.  We're going to display a label above the list of folders that reads 'My Folder List.'
Our first hack is going to be to add a bit of personalization to Thunderbird.  We're going to display a label above the list of folders that reads 'My Folder List.'


4.) The main Thunderbird window lives in the messenger.xul file inside <tt>content/messenger</tt>.  Open this file in your text-editor.
1.) The main Thunderbird window lives in the mailWindowOverlay.xul file inside <tt>content/messenger</tt>.  Open this file in your text-editor.


5.) Scroll down until you see something that looks like:
2.) Search for 'savedFiles.label'
<tt>
<tt>
    <vbox id="folderPaneBox" minwidth="100" width="200" persist="collapsed width">
            <menuitem id="appmenu_openSavedFilesWnd"
      <label id="folderColumnLabel" hidden="true" value="&folderColumn.label;"/>
                      label="&savedFiles.label;"
                      key="key_savedFiles"
                      oncommand="openSavedFilesWnd();"/>
</tt>
</tt>
A <tt>vbox</tt> is a box whose items are stacked verticallyAnd a <tt>label</tt> is exactly what you think it is. For more information on various XUL elements, see [http://developer.mozilla.org/en/docs/XUL_Reference DevMo's XUL Reference].
A <tt>menuitem</tt> is an element in a menu.  <tt>label</tt> sets its text. For more information on various XUL elements, see [http://developer.mozilla.org/en/docs/XUL_Reference MDN XUL Reference].


6.) First, notice that the <tt>hidden="true"</tt> attribute is set, meaning that this label isn't shown by defaultFor our purposes, we want it shown, so remove that.
3.) Change <tt>label="&savedFiles.label;"</tt> to read <tt>value="My Saved Files"</tt>.  (The original label has an "&" and a ";" because it is an entityMore on this below.)


7.) Change <tt>value="&folderColumn.label;"</tt> to read <tt>value="My Folder List"</tt>.  (The original label has an "&" and a ";" because it is an entity.  More on this below.)
Now these lines should look like this this:
 
<tt>
Now your line should look like this
            <menuitem id="appmenu_openSavedFilesWnd"
<tt><label id="folderColumnLabel" value="My Folder List"/></tt>
                      label="My Saved Files"
Save the messenger.xul file.
                      key="key_savedFiles"
                      oncommand="openSavedFilesWnd();"/>
</tt>
Save the mailWindowOverlay.xul file.


8.) Place your new messenger.xul back inside <tt>content/messenger</tt> (overwriting the old one) and close the jar tool.
4.) Zip the content in the 'omni' folder (not the omni folder itself) and rename the zip file to 'omni.ja' and use it to replace the old omni.ja you unzipped earlier


9.) Restart Thunderbird and notice your new label!
5.) Start Thunderbird and notice your new label in the 'Tools' menu!


Yay! Great work.  You just made your first changes to the code.  There's only one problem... remember how we said earlier that all strings live in <tt>en-US.jar</tt>?  Well, 'My Folder List' here is living in <tt>messenger.jar</tt> which is bad.  Change the line back to <tt>value="&folderColumn.label;"</tt> and restart Thunderbird to make sure you did it correctly.  Your (still visible) label will now read "Name".
Yay! Great work.  You just made your first changes to the code.  There's only one problem... remember how we said earlier that all strings live in the <tt>en-US</tt> folder?  Well, 'My Saved Files' here is living in the <tt>messenger</tt> folder which is bad.  Change the line back to <tt>label="&savedFiles.label;"</tt>, zip, rename and replace and restart Thunderbird to make sure you did it correctly.  Your label will now read "Saved Files".


10.) Unzip <tt>en-US.jar</tt> open the folder <tt>lcoale/en-US/messenger</tt>.
6.) In the folder <tt>en-US</tt> open the folder <tt>locale/en-US/messenger</tt>.


11.) Many of the strings for Thunderbird live in <tt>messenger.dtd</tt> here.  Open it in your text editor.  '''Note:''' Changes to strings are always made first to the en-US file.  Other localizers will then update their files (often only prior to a release) to the new strings.  Patches involving string changes/additions/deletions should only change en-US files.
7.) Many of the strings for Thunderbird live in <tt>messenger.dtd</tt> here.  Open it in your text editor.  '''Note:''' Changes to strings are always made first to the en-US file.  Other localizers will then update their files to the new strings.  Patches involving string changes/additions/deletions should only change en-US files.


12.) Find the ENTITY named <tt>folderColumn.label</tt> and change its value from 'Name' to 'My Folder List'.  Save the file.
8.) Find the ENTITY named <tt>savedFiles.label</tt> and change its value from 'Saved Files' to 'My Saved Files'.  Save the file.


13.) Put the new <tt>messenger.dtd</tt> file in your en-US.jar (overwriting the old file) and close the jar tool.
9.) Zip, rename and replace the 'omni' folder/ 'omni.ja'.


14.) Restart Thunderbird and observe the changes.
10.) Restart Thunderbird and observe the changes.


Congratulations, this is the proper way to change that string.
Congratulations, this is the proper way to change that string.


==== JS Hacking ====
==== JS Hacking ====
No hacking introduction would be complete without a 'Hello World' example of some sort.  So, here's ours.  Start with steps 1-3 above.
No hacking introduction would be complete without a 'Hello World' example of some sort.  So, here's ours.  Start with steps 1 and 2 above.


4.) The main Thunderbird front-end loading takes place in <tt>msgMail3PaneWindow.js</tt> in the function <tt>OnLoadMessenger()</tt>. Open that file in your text-editor.
3.) Open the file 'mailCore.js' from the 'messenger' folder..


5.) Find the <tt>OnLoadMessenger()</tt> function.  (You'll need to scroll down somewhat.)
4.) Find the <tt>openSavedFilesWnd()</tt> function.  (You'll need to scroll down somewhat.)


6.)  Insert the following (after the '{'):  
5.)  Insert the following (after the '{'):  


<tt>alert('Hello World!');</tt>  
<tt>alert('Hello World!');</tt>  
Line 98: Line 113:
and save the file.
and save the file.


7.) Place your new msgMail3PaneWindow.js back inside <tt>content/messenger</tt> (overwriting the old one) and close the jar tool.
6.) Zip, rename and replace the 'omni' folder/ 'omni.ja'.


8.) Restart Thunderbird and observe the 'Hello World!' greeting.
7.) Restart Thunderbird, open the 'Tools' menu, click on 'My Saved Files' and observe the 'Hello World!' greeting.


=== Finding a bug to fix===
=== Finding a bug to fix===
So, by now you're (hopefully) eager to actually fix some real bugs!  You may have come here because you already had a bug you wanted to fix.  If so, great!  The best bugs to fix are usually the ones that annoy you personally.  If not, look at the list of [https://bugzilla.mozilla.org/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&product=Thunderbird&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=%5Bgood+first+bug%5D&keywords_type=allwords&keywords=&bug_status=NEW&resolution=DUPLICATE&resolution=---&emailassigned_to1=1&emailtype1=exact&email1=&emailassigned_to2=1&emailreporter2=1&emailqa_contact2=1&emailtype2=exact&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0= good first bugs].  (This is currently a short list, but all bug-triagers have now been told to start adding to this list on a more regular basis, so expect it to grow.Pick one that sounds interesting to you.
So, by now you're (hopefully) eager to actually fix some real bugs!  You may have come here because you already had a bug you wanted to fix.  If so, great!  The best bugs to fix are usually the ones that annoy you personally.  If not, look at the list of [https://bugzilla.mozilla.org/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&product=Thunderbird&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=%5Bgood+first+bug%5D&keywords_type=allwords&keywords=&bug_status=NEW&resolution=DUPLICATE&resolution=---&emailassigned_to1=1&emailtype1=exact&email1=&emailassigned_to2=1&emailreporter2=1&emailqa_contact2=1&emailtype2=exact&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0= good first bugs] or [[Thunderbird:Bug Queries|other common bug queries]]. Pick one that sounds interesting to you.


If you have the proper Bugzilla permissions, please assign the bug to yourself. If not, please post a comment in the bug saying that you are working on it.  '''If you stop working on the bug, please say so as well!'''
If you have the proper Bugzilla permissions, please assign the bug to yourself. If not, please post a comment in the bug saying that you are working on it.  '''If you stop working on the bug, please say so as well!'''
Line 112: Line 127:


=== Creating and submitting a patch ===
=== Creating and submitting a patch ===
Wow!  You've fixed the bug you were working on?  Fantastic!  Time to submit a patch so that everyone can enjoy the fruits of your labor.  The first thing to recognize is that the files inside messenger.jar are slightly different from the actual source files. In an ideal world, you'll check out the source code and create your patch based on that.  If your changes are small however, your reviewer may be willing to accept a chrome patch for the short term.  If you plan on submitting several patches, you really need to work from CVS.
Wow!  You've fixed the bug you were working on?  Fantastic!  Time to submit a patch so that everyone can enjoy the fruits of your labor.  The first thing to recognize is that the files inside omni.ja are slightly different from the actual source files.
 
Read how to [https://developer.thunderbird.net/thunderbird-development/fixing-a-bug/landing-a-patch land a patch].
1.) Check out the Mozilla source code.  See the [http://developer.mozilla.org/en/docs/Mozilla_Source_Code_Via_CVS DevMo article] for more details on this step.
 
2.) Open up the relevant files and make the same changes to them that you made to your messenger.jar files.
 
3.) Use your CVS program's diff utility to create a file that contains information about the files you changed.  This is usually done with a command something like
<tt>cvs diff -prU 8 mozilla/mail/ > myPatch.diff</tt>
 
See the [http://developer.mozilla.org/en/docs/Creating_a_patch DevMo article] for more details on this step.
 
4.) Go to the bug you've been working on and choose 'Create an Attachment'.  Put the path to the file that CVS diff created in the proper box, and give your patch a short title describing your changes.  Describe in detail the changes that you've made in the Description box.  Check the 'Patch' checkbox under content type.
 
5.) '''Important:''' Ask for a review!  In the dropdown menu next to 'review', choose the '?', since you're asking for the review.  In the textbox next to the '?' place the email address of one of the thunderbird developers.
 
Adequate reviewers can be found on the xxx page.
 
6.) Wait for the review.  If you haven't heard anything in 5 days, please 'poke' the review.  (Ideally, talk to them on IRC.  At a minimum, post a comment in the bug.)  If you haven't heard anything in 10 days, please choose a different reviewer.
 
7a.) If your review request is '''granted:''' Your reviewer will 'check in' your patch and (in most cases) mark the bug as FIXED.  You can use [http://bonsai.mozilla.org/cvsquery.cgi?treeid=default&module=ThunderbirdTinderbox&branch=HEAD&branchtype=match&dir=&file=&filetype=match&who=&whotype=match&sortby=Date&hours=2&date=week&mindate=&maxdate=&cvsroot=%2Fcvsroot Bonsai] to confirm this.  (If he doesn't check it in, add the <code>checkin-needed</code> keyword to the bug, and the checkin monkeys will commit it for you, usually within the next week or two.)  Congratulations!  You've just fixed your first bug.
 
7b.) If your review request is '''denied:''' Don't lose heart!  This happens more often than not.  Your reviewer will tell you changes that need to be made to the patch in order for it to be acceptable for checkin.  Repeat this process with those changes in mind, submit another patch, and ask for another review.


==== Tips for making good patches ====
==== Tips for making good patches ====
Line 145: Line 140:


=== Useful tools ===
=== Useful tools ===
* [irc://irc.mozilla.org IRC] - Thunderbird hackers and reviewers like to hang out in the #maildev channel on irc.mozilla.org.  They're usually more than happy to answer your questions if you get stuck on a part of a patch.  '''Be patient''' when asking questions, though.  Hackers have to sleep, eat, and work too, so it may take several hours before someone sees your question and responds.
* [https://chat.mozilla.org Matrix] - Thunderbird hackers and reviewers like to hang out in the #maildev [[Matrix]] channel on chat.mozilla.org.  They're usually more than happy to answer your questions if you get stuck on a part of a patch.  '''Be patient''' when asking questions, though.  Hackers have to sleep, eat, and work too, so it may take several hours before someone sees your question and responds.
* [http://lxr.mozilla.org/mozilla/ LXR] - Great for searching the mozilla codebase for examples, particular code lines, etc.
* [https://dxr.mozilla.org/comm-central/source/ DXR] - Great for searching Thunderbird's codebase for examples, particular code lines, etc.
* [http://www.xulplanet.com/ XULPlanet] - a great reference on all things XUL.
* [https://developer.mozilla.org/ MDN] - The Mozilla Developer Network. Tons of great links and articles on almost everything Mozilla-hackish imaginable.
* [http://developer.mozilla.org/ DevMo] - The Mozilla Developer's Center. Tons of great links and articles on almost everything Mozilla-hackish imaginable.
* [https://developer.thunderbird.net/ Thunderbird developer website] - Has most everything that you need to get started.
* [http://www.geocities.com/gekacheka/moz/tool/venkman/index.html Venkman Javascript Debugger] patched to be usable in Thunderbird
* [https://www.thunderbird.net/en-US/get-involved/ Getting involved] - More links to communities and resources.
* [http://www.geocities.com/gekacheka/moz/tool/extensiondev/index.html Extension Developer] with Javascript Shell.  Patched to be installable in Thunderbird.


=== Useful settings ===
=== Useful settings ===
* You can receive [[http://developer.mozilla.org/en/docs/Setting_up_extension_development_environment more debug messages]] with some preference settings.
* You can receive [https://developer.mozilla.org/en/docs/Setting_up_extension_development_environment more debug messages] with some preference settings.


=== Other possibly useful links ===
=== Other possibly useful links ===
*[http://developer.mozilla.org/en/docs/Hacking_Firefox Hacking Firefox Guide]
*[https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Introduction Hacking Firefox Guide]
 
[[category:Thunderbird|*]]

Latest revision as of 02:19, 16 September 2022

<< Back to Thunderbird Dev page

Beginner's Guide to Hacking Thunderbird

So, you think you might want to help out with Thunderbird? Great! What's that? You don't have any idea where to begin? Hopefully this document can help. It's designed to be an introduction to submitting your first patch(es) to the Thunderbird codebase.

Getting the right tools

Before you can begin, you're going to need several tools setup on your computer. Note: Some hackers have found it useful to simply begin by building Thunderbird from source. (Instructions) If you can do this, you will (almost) automatically have all the right tools to begin hacking. However, since building is a rather complicated process, you may wish to come back to it at a later stage.

You will need:

  • A Bugzilla account
  • A program to extract the contents of .jar files (which are named as .ja files in Thunderbird's case). E.g. 7-zip on Windows.
    • Most zip utilities are capable of working with .jar files as well. Some may require that you rename .jar files to .zip first
  • A current nightly build of Thunderbird
  • A text-editor, who is capable of working with files created on Windows, Linux or Mac OS X.
    • Windows users must not use Windows' Notepad text-editor which doesn't show Linux linebreaks properly. A viable freeware alternative for Windows is Notepad++. This editor will get you a better view of the code (i.e you will see which braces close which codeblocks, 'if','var' and so on will be bold, among other stuff).

Linux users will find most of these programs available by default with their distro.

Windows users won't have all of these tools installed by default, but if you have followed the build instructions above, you have downloaded the required tools.

Hacking!

Time to make your first changes to the code.

1.) If you haven't done so already, unzip your current nightly build of Thunderbird and make sure it runs properly. Then close it.

2.) Inside the folder where you unzipped Thunderbird, open the 'omni.ja' file with the zip program. Rename it to omni.zip if necessary to unzip it. Unzip the contents into a folder, let's say 'omni'.

3.) In the 'omni' folder, delete the folders 'jsloader' and 'jssubloader'. These have source files cached for faster loading and if you don't remove them, your changes to the real source files will be ignored by Thunderbird.

In the 'omni' folder, you find a variety of folders that create the front-end of the application.

  • content - many of the front-end files
  • components - some often used files (in different contexts).
  • defaults - default values for preferences
  • hyphenation - dictionaries used in compose context
  • modules - often used files which once imported share their properties with all context which have been imported to (set a property to 1 in context A and context B will see that value)
  • res - resources like graphics, e.g. for the HTML compose editor

The 'content' folder has the following subfolders:

  • chat - contains files for the instant messaging and social media component of Thunderbird
  • classic - contains many of the css (style) and image files for the default theme
  • comm - contains some of the core "communicator" files (you usually won't worry about these.)
  • devtools - contains the developer tools, e.g. the code for the error console
  • en-US - these contain the strings used in the application, translated to English. When using another locale, you may see a different folder name.
  • gloda - the files for the global search database. Used to search across folders
  • messenger - this is where most of the XUL and JS files for Thunderbird are.
  • newsblog - contains files specific to blog-reading (RSS)
  • pippki - certificate management related files
  • toolkit - the common files shared by all Mozilla toolkit applications (Firefox, Thunderbird). These define common widgets and other useful tools.

4.) Open the folder 'messenger'.

Inside here you will find a content folder, with 4 sub-folders

  • branding - Thunderbird specific branding materials
  • messagebody - contains a file used for printing the address book
  • messenger - most front-end files for Thunderbird
  • messenger-smime - files related to smime processing

XUL Hacking

Our first hack is going to be to add a bit of personalization to Thunderbird. We're going to display a label above the list of folders that reads 'My Folder List.'

1.) The main Thunderbird window lives in the mailWindowOverlay.xul file inside content/messenger. Open this file in your text-editor.

2.) Search for 'savedFiles.label'

           <menuitem id="appmenu_openSavedFilesWnd"
                     label="&savedFiles.label;"
                     key="key_savedFiles"
                     oncommand="openSavedFilesWnd();"/>

A menuitem is an element in a menu. label sets its text. For more information on various XUL elements, see MDN XUL Reference.

3.) Change label="&savedFiles.label;" to read value="My Saved Files". (The original label has an "&" and a ";" because it is an entity. More on this below.)

Now these lines should look like this this:

           <menuitem id="appmenu_openSavedFilesWnd"
                     label="My Saved Files"
                     key="key_savedFiles"
                     oncommand="openSavedFilesWnd();"/>

Save the mailWindowOverlay.xul file.

4.) Zip the content in the 'omni' folder (not the omni folder itself) and rename the zip file to 'omni.ja' and use it to replace the old omni.ja you unzipped earlier

5.) Start Thunderbird and notice your new label in the 'Tools' menu!

Yay! Great work. You just made your first changes to the code. There's only one problem... remember how we said earlier that all strings live in the en-US folder? Well, 'My Saved Files' here is living in the messenger folder which is bad. Change the line back to label="&savedFiles.label;", zip, rename and replace and restart Thunderbird to make sure you did it correctly. Your label will now read "Saved Files".

6.) In the folder en-US open the folder locale/en-US/messenger.

7.) Many of the strings for Thunderbird live in messenger.dtd here. Open it in your text editor. Note: Changes to strings are always made first to the en-US file. Other localizers will then update their files to the new strings. Patches involving string changes/additions/deletions should only change en-US files.

8.) Find the ENTITY named savedFiles.label and change its value from 'Saved Files' to 'My Saved Files'. Save the file.

9.) Zip, rename and replace the 'omni' folder/ 'omni.ja'.

10.) Restart Thunderbird and observe the changes.

Congratulations, this is the proper way to change that string.

JS Hacking

No hacking introduction would be complete without a 'Hello World' example of some sort. So, here's ours. Start with steps 1 and 2 above.

3.) Open the file 'mailCore.js' from the 'messenger' folder..

4.) Find the openSavedFilesWnd() function. (You'll need to scroll down somewhat.)

5.) Insert the following (after the '{'):

alert('Hello World!');

and save the file.

6.) Zip, rename and replace the 'omni' folder/ 'omni.ja'.

7.) Restart Thunderbird, open the 'Tools' menu, click on 'My Saved Files' and observe the 'Hello World!' greeting.

Finding a bug to fix

So, by now you're (hopefully) eager to actually fix some real bugs! You may have come here because you already had a bug you wanted to fix. If so, great! The best bugs to fix are usually the ones that annoy you personally. If not, look at the list of good first bugs or other common bug queries. Pick one that sounds interesting to you.

If you have the proper Bugzilla permissions, please assign the bug to yourself. If not, please post a comment in the bug saying that you are working on it. If you stop working on the bug, please say so as well!

Submit a comment with the basic outline of how you plan to fix the bug. (Or if you have IRC access, talk about the proposal there.) There is nothing more frustrating than working hard on a patch, only to be told that the reviewer wanted the patch solved in a different way. Make sure that your proposed changes (ESPECIALLY changes to the User Interface) are acceptable before investing your valuable time.

Now, for the hard-work part: Fix the bug. Continue to make changes to your messenger.jar file and test them by restarting Thunderbird. Repeat until the bug is solved.

Creating and submitting a patch

Wow! You've fixed the bug you were working on? Fantastic! Time to submit a patch so that everyone can enjoy the fruits of your labor. The first thing to recognize is that the files inside omni.ja are slightly different from the actual source files. Read how to land a patch.

Tips for making good patches

  • Comments inside the code are encouraged! Remember, someone else is going to have to go back and read your code later without any clue of what you were thinking when you were doing it. Make sure that this can be done with as little pain as possible
  • Don't just fix things, fix them correctly. If you find yourself adding lots of special cases for what seems like a simple task, the patch probably won't be approved without a very good reason. Mozilla code is complicated enough as it is; don't make it more so.
  • Be careful about random whitespace changes. Don't add newlines to irrelevant areas, and make sure you remove extra newlines you added while experimenting.
  • While alert() (and it's cousin dump()) are useful for debugging, they should not remain in code that will be checked in. Remove any alert()s you may have used for testing.
  • Use spaces, NOT tabs.
  • Follow the existing style of the document you're working on. If default indenting is 4 spaces, use 4 spaces. If it's 2, use 2. If braces are placed on the same line as for and if (ie if (a == b) {) keep it this way. If they're on the next line, keep it that way.
  • Don't be afraid to ask for help!

Useful tools

  • Matrix - Thunderbird hackers and reviewers like to hang out in the #maildev Matrix channel on chat.mozilla.org. They're usually more than happy to answer your questions if you get stuck on a part of a patch. Be patient when asking questions, though. Hackers have to sleep, eat, and work too, so it may take several hours before someone sees your question and responds.
  • DXR - Great for searching Thunderbird's codebase for examples, particular code lines, etc.
  • MDN - The Mozilla Developer Network. Tons of great links and articles on almost everything Mozilla-hackish imaginable.
  • Thunderbird developer website - Has most everything that you need to get started.
  • Getting involved - More links to communities and resources.

Useful settings

Other possibly useful links