Showing posts with label open source. Show all posts
Showing posts with label open source. Show all posts

Tuesday, October 18, 2011

Getting Thunderbird to work with distribution.ini

The bug I'm working on is the ability to customize vanilla Thunderbird with a group of settings (through distribution.ini). For those who do not know, Thunderbird is Mozilla's open source mail client. (Mozilla = makers of Firefox). I'm far from done. This entry is a culmination of what I have learned so far.

Checkout the repo

I am working with Fedora, so I use yum. I followed the build and configure instructions from here. In a nutshell, here are the steps to cloning the comm-central
(Thunderbird) repo:

1) yum install mercurial - to get Mercurial, a version control tool.

2) Create a file called ".hgrc" in your home directory and put these in it:


[ui]
username=Firstname Lastname
merge=internal:merge

[diff]
git=1
showfunc=1
unified=8

[defaults]
commit=-v

Note: Obviously, replace Firstname, Lastname, and my.email... with your information.

3) Make sure you're in the directory that you want to put the repo in (for example, your home dir) then checkout the repo:
hg clone
http://hg.mozilla.org/comm-central/ src-thunderbird

So now you should have a "src-thunderbird" folder in your current directory.

Building Thunderbird

1) Go to your src-thunderbird directory (cd src-thunderbird).

2) Create a .mozconfig file. (I use vi, so vi .mozconfig). This file will contain your build configurations for Thunderbird. The contents of mine are:

mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-tbdebug

ac_add_options --enable-application=mail

ac_add_options --enable-debug

ac_add_options --disable-optimize

"obj-tbdebug" is the directory where all my object files will end up (you can change what you call yours). I will refer to this as objdir, from now on. The second line says, build me Thunderbird. The third line is because I need debugging printouts. The fourth line I just threw in for good measure. You can read more about configuration options here.

3) Build Thunderbird! "make -f client.mk build" (while still in src-thunderbird). This step will take a while (more than a half hour in my case).

4) Once the build is done, run Thunderbird with ./objdir/mozilla/dist/bin/thunderbird. Since we configured this build with the debug option, you will see a lot of printouts at your terminal.

Updating the repository

Make sure you're in the src-thunderbird directory. On the terminal, execute python client.py checkout. Re-build again.


Modifying the source files

The source files are everything outside your src-thunderbird file. Everything in it are your object files. When you modify your source files, you need to re-create your object files. You can run make -f client.mk build again (in your src-thunderbird dir), and it won't take as long as the first time.

If you changed files in only one directory, you can re-make only that directory. For example, if you changed files only in ~/src-thunderbird/mail/components, run make -C objdir/mail/components.

Getting distribution.ini working

1) This is a sample distribution.ini. This file must be placed in objdir/mozilla/dist/bin/distribution.

2) Add "distribution.js \" to the EXTRA_JS_MODULES section of Makefile.in (which resides in ~/src-thunderbird/mail/base/modules).

3) distribution.js should be in ~/src-thunderbird/mail/base/modules. I copied and modified the Firefox version. (Code referring to bookmarks and livemarks were ripped out.) I also changed the name of the object it exported to something like TBDistCustomizer.

(Note: JS modules have EXPORTED_SYMBOLS at the start of the file. This is as opposed to components files (which are also JS), which do not.)

4)
cd to objdir/mail/base/modules and type "make".

5) Modify mailGlue.js (in ~/src-thunderbird/mail/components) so that:

(a) It would import distribution.js (Components.utils.import("resource:///modules/distribution.js");); and

(b) it would create an instance of TBDistCustomizer. This intance can now be used to call the code in distribution.js that actually changes prefs (applyPrefDefaults).

Hitting the brick wall

So now I've come to the point where preferences set in distribution.ini are being set in Thunderbird, but there is a catch: some prefs are set properly, while others are duplicated. For example, mail.phishing.detection.enabled is set correctly, but something like network.cookie.lifetimePolicy instead becomes duplicated, with one version having the default and the other having the value that was set in distribution.ini.

I am still trying to figure out why this is so...


Climbing the brick wall

The problem was that distribution.ini doesn't like spaces around the "=" sign. network.cookie.lifetimePolicy = 1 should be network.cookie.lifetimePolicy=1.

Thanks to...

The MailDev team at Mozilla! In particular Standard8 and sid0 for helping me get started.

Thursday, October 7, 2010

Game programming with open source tools

Remember trying to create games with Flash? No? Neither do I. I couldn't be bothered to pay for the tools I needed. But that's okay because it's now possible to code games for the web using free tools like Processing.js and C3DL. You don't have to pay $$$ to be the game programmer you want to be. You just need a bit of patience and dedication.

Level Up: An OpenWeb Game Jam is a tutorial/hack session happening right before the Free Software and Open Source Symposium (FSOSS) 2010 on October 27 at the Seneca@York. Think of it as a one-day sprint of learning new languages. In the morning, you attend the tutorials and the in the afternoon you get to try out what you've learned. Yes, you get to code your own game!

When you really think about it, why learn a new language by yourself when you can have fun, socialize (network, maybe?), and learn with others?

* * *
Some html5 games that you can while away time with:
Chain Reaction - Advanced - http://yvoschaap.com/chainrxnadvanced/
HTML5 Games - http://html5games.com/

Friday, September 10, 2010

Started @ CDOT

This fall, I am a "Student Research Assistant" at CDOT. It's a wikkid title because it sounds like it belongs to a university student. However, as one of the administrators explained it, we are not researching for the sake of knowledge--we are researching for the sake of a final product.

The first thing I did was set up my workstation. Sounds easy enough, but when you throw in a MAC OS (which I'd never worked with before), it's new*2.

Some things I learned:

sudo su

1) I should've set up my account on this computer under the admin account in the first place.

2) I utilized the sudo su command while setting up my github account (as outlined in Anna's blog). (github is a version control system.) sudo is a command that lets you execute commands as a super user.

Since everything was done at the command line, as user donna, I was prompted for a password every now and then and then inevitably told that "donna is not a sudoer" (or something like that). The fix was to beat the cl to the punch and just type in sudo su and then type in the admin password, and off I went.

(Must mention that even while under Admin account, I had to sudo su in order to access other user's accounts).

github

As I already said, github is a version control system. In one of my classes, OOP344, I used Tortoise SVN, and that was fine because it had GUI. Since Anna's instructions were on the command line, that's how I worked, too. It was frustrating =\

After cloning the repos that I was going to be working with, I created a local and a remote branch (again, instructions are in Anna's blog), but I stumbled a bit. Things I learned:

1) When branching, make sure you are in the directory that contains the cloned repo. So when you clone popcorn (one of the repos I will be working with) like this:

git clone git://github.com/mozilla/popcorn-js.git popcornDonna

follow with cd popcornDonna, then create the branch (git branch firstBranch).

2) As Anna says in her blog, some errors that result in creating a remote branch (using the git push command) are fixable by editing the config file. She is referring to the .git/config file.

How to find the file: make sure you are in the folder that contains the repo you cloned (in my example, the folder is popcornDonna). Then type ls -a . One of the results should be .git. Change directory to .git (cd .git). Type ls and you should see the config file. Edit it.

So far so good, tho. Just going to be reading up on Popcorn and learning some JS for the time being.