Changes

Jump to: navigation, search

Thunderbird:Start Hacking

2,120 bytes removed, 20:02, 5 February 2017
overhauled page
=== 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. ([httphttps://gemaldeveloper.dkmozilla.org/en-US/docs/Mozilla/Developer_guide/mozillaBuild_Instructions/build.html Windows 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:
* [https://bugzilla.mozilla.org/createaccount.cgi A Bugzilla account]
* A program to extract the contents of .jar extractfiles (which are named as .ja files in Thunderbird's case). E.g. [http://7-zip.org/build tool7-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
** 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/mozilla.org/thunderbird/nightly/latest-trunkcomm-central/ 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 are strongly discouraged from using the must not use Windows' Notepad text-editorwhich doesn't show Linux linebreaks properly. Viable A viable freeware alternatives are alternative for Windows is [httphttps://www.flosnotepad-plus-freewareplus.chorg/notepad2.html notepad2] and [http:download//http://www.pspad.com/ PSPadNotepad++]. These editors 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.
'''Windows users''' won't have all of these tools installed by default, but if you have followed the windows [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! ===
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 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 3.) In the front-end of 'omni' folder, delete the applicationfolders 'jsloader' and 'jssubloader'.* <tt>classic.jar</tt> - contains many of the css (style) These have source files cached for the default theme* <tt>comm.jar</tt> - contains some of the core "communicator" files (faster loading and if you usually wondon't worry about these.)* <tt>en-US.jar</tt> - these contain the strings used in the applicationremove them, translated your changes 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 real source files for Thunderbird are.* <tt>newsblog.jar</tt> - contains files specific to blog-reading (rss)* <tt>toolkit.jar</tt> - the common files shared will be ignored by all Mozilla toolkit applications (Firefox, Thunderbird, etc). These define common widgets and other useful tools.
3In 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.) Find * <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.jar file * <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 open it with your jar (zipother useful tools. 4.) toolOpen the folder 'messenger'.
Inside here you will find a <tt>content</tt> folder, with 4 sub-folders
* <tt>branding</tt> - Thunderbird specific branding materials
* <tt>editormessagebody</tt> - files contains a file used for printing the html editor used to compose mailaddress book* <b></tt>messenger</tt></b> - most front-end files for Thunderbird* <tt>messenger-smime</tt> - 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.'
41.) The main Thunderbird window lives in the messengermailWindowOverlay.xul file inside <tt>content/messenger</tt>. Open this file in your text-editor.
52.) Scroll down until you see something that looks like:Search for 'savedFiles.label'
<tt>
<vbox menuitem id="folderPaneBoxappmenu_openSavedFilesWnd" minwidth="100" width="200" persist="collapsed width"> < label id="folderColumnLabel&savedFiles.label;" hidden key="truekey_savedFiles" value oncommand="&folderColumn.labelopenSavedFilesWnd();"/>
</tt>
A <tt>vboxmenuitem</tt> is an element in a box whose items are stacked verticallymenu. And a <tt>label</tt> is exactly what you think it issets its text. For more information on various XUL elements, see [http://developer.mozilla.org/en/docs/XUL_Reference DevMo's MDN XUL Reference].
63.) First, notice that the Change <tt>hiddenlabel="&savedFiles.label;"</tt> to read <tt>value="trueMy Saved Files"</tt> attribute . (The original label has an "&" and a ";" because it is set, meaning that this label isn't shown by defaultan entity. For our purposes, we want it shown, so remove thatMore on this below.)
7.) Change Now these lines should look like this this:<tt>value <menuitem id="&folderColumn.appmenu_openSavedFilesWnd" label;"</tt> to read <tt>value="My Folder ListSaved Files"</tt>. (The original label has an key="&key_savedFiles" and a oncommand="openSavedFilesWnd();" because it is an entity/></tt>Save the mailWindowOverlay. More on this belowxul file.)
Now your line should look like this<tt><label id="folderColumnLabel" value="My Folder List"/></tt>Save 4.) Zip the content in the 'omni' folder (not the messengeromni folder itself) and rename the zip file to 'omni.xul fileja' and use it to replace the old omni.ja you unzipped earlier
85.) Place Start Thunderbird and notice your new messenger.xul back inside <tt>content/messenger</tt> (overwriting the old one) and close label in the jar tool.'Tools' menu!
9Yay! Great work.) Restart 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 and notice your new to make sure you did it correctly. Your label!will now read "Saved Files".
Yay! Great work6. You just made your first changes to ) In the code. There's only one problem... remember how we said earlier that all strings live in folder <tt>en-US.jar</tt>? Well, 'My Folder List' here is living in open the folder <tt>locale/en-US/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".
107.) Unzip Many of the strings for Thunderbird live in <tt>en-USmessenger.jardtd</tt> open here. Open it in your text editor. '''Note:''' Changes to strings are always made first to the folder <tt>lcoale/en-USfile. Other localizers will then update their files to the new strings. Patches involving string changes/messenger<additions/tt>deletions should only change en-US files.
118.) Many of Find the strings for Thunderbird live in ENTITY named <tt>messengersavedFiles.dtdlabel</tt> here. Open it in your text editor. and change its value from 'Saved Files'to 'Note:My Saved Files''' 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 Save the new strings. Patches involving string changes/additions/deletions should only change en-US filesfile.
129.) Find Zip, rename and replace the ENTITY named <tt>folderColumn.label</tt> and change its value from 'Nameomni' to folder/ 'My Folder Listomni.ja'. 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. 1410.) 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-3 and 2 above.
43.) The main Thunderbird front-end loading takes place in <tt>msgMail3PaneWindowOpen the file 'mailCore.js</tt> in ' from the function <tt>OnLoadMessenger()</tt>'messenger' folder. Open that file in your text-editor.
54.) Find the <tt>OnLoadMessengeropenSavedFilesWnd()</tt> function. (You'll need to scroll down somewhat.)
65.) Insert the following (after the '{'):
<tt>alert('Hello World!');</tt>
and save the file.
76.) Place your new msgMail3PaneWindow.js back inside <tt>content/messenger</tt> (overwriting the old one) Zip, rename and close replace the jar tool'omni' folder/ 'omni.ja'.
87.) 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 [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.
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!'''
=== 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 messengeromni.jar ja 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 Read how to work from CVS. 1.) Check out the Mozilla source code. See the [httphttps://developer.mozilla.org/en/docs/Mozilla_Source_Code_Via_CVS DevMo article] for more details on this step. 2.) Open 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/enUS/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. Reviewers can be found on the [[Thunderbird:Dev#Module_Owners_And_Review_Rules|reviewers page]]. 6.) Wait for the review. If you haven't heard anything in 5 days, please 'poke' the review. (Ideally, talk to them on [http:Mozilla/Developer_guide/www.mibbit.com/chat/?server=irc.mozilla.org&channel=%23maildev IRC in #maildev]. At a minimum, post a comment in the bug.) If you haven't heard anything in 10 days, please choose How_to_Submit_a_Patch submit 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 ====
=== 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.
* [httphttps://lxrdxr.mozilla.org/mozillacomm-central/source/ LXRDXR] - Great for searching the mozilla Thunderbird's codebase for examples, particular code lines, etc.* [http://www.xulplanet.com/ XULPlanet] - a great reference on all things XUL.* [httphttps://developer.mozilla.org/ DevMoMDN] - The Mozilla Developer's CenterNetwork. Tons of great links and articles on almost everything Mozilla-hackish imaginable.* [httphttps://wwwdeveloper.geocitiesmozilla.comorg/gekachekade/mozdocs/toolTools/venkmanRemote_Debugging/index.html Venkman Javascript DebuggerThunderbird Remotely Debugging Thunderbird] patched to be usable in Thunderbird* [http://www.geocities.com/gekacheka/moz/tool/extensiondev/index.html Extension Developer] with Javascript Shell. Patched to be installable Check how scripts in Thunderbirdwork by setting breakpoints, modify styles etc.
=== Useful settings ===
* You can receive [[httphttps://developer.mozilla.org/en/docs/Setting_up_extension_development_environment more debug messages]] with some preference settings.
=== Other possibly useful links ===
*[httphttps://developer.mozilla.org/en-US/docs/Hacking_Firefox Mozilla/Developer_guide/Introduction Hacking Firefox Guide]
[[category:Thunderbird|*]]
Confirm
567
edits

Navigation menu