# Some new toys

There have been a couple of things I’ve noticed myself doing over and over again recently, and because I’m a developer whenever I do something over and over again, I try to find a way to automate it.

So I did some playing around with Mozilla’s Add-on Builder and came up with a couple of Jetpacks that solved my problems. Maybe you’ll find them useful, too.

# More secure!

As someone who works on an email client, I’m interested in making my communications more secure. So, with the assistance of Ludovic and Gozer, I got a client certificate that would allow me to sign and encrypt my messages. (Check out the envelope and lock in the image below.)

Most of the time, I’ll probably just sign my messages – after all, that’s what I’ve set it up to do by default – but it’s nice to know that if there’s something I need to encrypt, that option is now available to me.

# OMG! Zerg Rush!

File this one under stupid Unicode tricks, I think.

♖♘♗♔♕♗♘♖
♙♙♙♙♙♙♙♙
♟♟♟♟♟♟♟♟
♟♟♟♟♟♟♟♟
♟♟♟♟♟♟♟♟
♟♟♟♟♟♟♟♟
♟♟♟♟♟♟♟♟
♟♟♟♟♟♟♟♟

# A handy zsh function (for OS X)

A co-worker of mine was having problems remembering where the makefile puts the binary for Thunderbird when you build it yourself. Now, I type in the path far too often, so I know where it is (on my computer, anyways), but since I type it in far too often, I grabbed someone's zsh function that launched Firefox, and modified it to launch Thunderbird from either the build directory or the source directory, but only on Mac OS X.

Anyways, here it is, I hope some of you find it useful.

  1 2 3 4 5 6 7 8 9 10 11 12 13 thunderbird() { local -a currdir; currdir=$PWD:t; for nm in LanikaiDebug ShredderDebug Lanikai Shredder; do if [ -d "./mozilla/dist/$nm.app" ]; then ./mozilla/dist/$nm.app/Contents/MacOS/thunderbird-bin$* break; elif [ -d "../objdir-$currdir/mozilla/dist/$nm.app" ]; then ../objdir-$currdir/mozilla/dist/$nm.app/Contents/MacOS/thunderbird-bin \$* break; fi done } 

# Cool stuff coming soon.

I’ve been reviewing a patch from Andreas and Standard8 which adds lightweight theme support (aka personas) to Thunderbird. It’s so cool that I couldn’t resist taking a screenshot, and posting it for you all to see!

It looks like there’s a good chance the code will make it in to Thunderbird 3.1 beta 2, so with any luck, soon your Thunderbird will be a pretty as mine.

# Your feedback is needed on our new Migration Assistant!

For the next version of Thunderbird, Bryan Clark, Andreas Nilsson, and I have done a lot of work to make it easier to upgrade your profile from Thunderbird 2, and we would like to hear what you think of it, and how we can make it even better.

There are some things we’re particularly interested in (mostly on the “Disk space” tab), such as:

1. Are your existing settings preserved?
2. If you have no previous settings do we choose “Do not Synchronize” by default?
3. For those of you who choose not to synchronize your messages, does that appear to work correctly?

We also have some more general questions, like:

1. Does it look okay? Do the sizes seem correct?
2. Do the options make sense, and how can we make them clearer?
3. Do the buttons work the way you think they should?

Windows

Mac OS X

Linux

And please leave your feedback on Mozilla Messaging’s GetSatsifaction Topic by the end of day on this coming Wednesday (April 7th), so that we have time to tweak the code and the design before the deadline.

Thanks!

# Programming Thunderbird in Visual Studio.

For your reading pleasure this week, we have a guest post from Wei Xian Woo. Wei is a student working on Thunderbird as part of UCOSP, and has just had his first bug marked as FIXED. Anyways, that’s enough out of me. Here’s Wei’s post:

#### Programming Thunderbird in Visual Studio.

During this term’s Undergraduate Capstone Open Source Projects (UCOSP) Code Sprint held at the University of Toronto in January, I wrote a simple Python script for the Thunderbird team to make setting up a Visual C++ project for Thunderbird slightly easier for those of us working on Windows. Blake suggested making this script public so others could benefit from it, so here it is! The script is generic enough to be used for any project, not just Thunderbird. Feel free to use it and make modifications as you see fit :)

#### Using the script to create a Visual C++ project for Thunderbird

Create an empty Visual C++ project in Visual Studio.

From the command prompt launched by mozilla-build\start-msvc9.bat, do:

python /path/to/refreshvcproj.py
--vcproj=/path/to/thunderbird.vcproj --dir=/path/to/gecko-sdk
--dir=/path/to/mozilla/comm-central/mozilla/xpcom
--dir=/path/to/mozilla/comm-central/mail


All files in the specified directories will be included in the project. I suggest including only the directories you will be working with.

#### Configuring the project for debugging:

Open the VC++ project file in Visual Studio, and then open the project's Properties.

Go to: Configuration Properties -> Debugging.

Set Command to \path\to\objdir\mozilla\dist\bin\thunderbird.exe

Set Environment to XPCOM_DEBUG_BREAK=warn

#### And… you’re done!

For better C++ IntelliSense, you might also want to consider getting Visual Assist X (an add-on for VS).

#### Happy coding!

And you can find the script over here.

Thanks, Wei!

# How to (not quite) fix a bug.

I’ve run into a bug. It’s a really annoying bug, because it prevents me from changing folders when I try to test any of my Thunderbird changes.

I tried putting dump statements everywhere, to see if I could figure out what was going on, but they were to no avail. Then, I thought about looking for the error code.

So the error lookup page says that the error that’s reported is:

Module          Severity        Number
CONTENT (25)    Failure (1)     6


And DXR says that Content Error 6 is: NS_ERROR_CONTENT_BLOCKED

Which occurs, among other places, here

But when I set a breakpoint there, it didn’t hit it. So instead of trusting mxr or dxr, I did a grep (well, an ack, but same thing), and started setting breakpoints on a few of the hits.

The one that hit my breakpoint ended up being this one which, weirdly enough, isn’t even listed in the mxr results of this search

Now that I’m at the breakpoint, we’re halfway there, I hope. ;)

How I got there was:

(gdb) bt
#1  0x152d9daa in nsDocShell::LoadURI (…) at …/mozilla/docshell/base/nsDocShell.cpp:1369
#2  0x13dc7581 in nsLocation::SetURI (…) at …/mozilla/dom/base/nsLocation.cpp:316
#3  0x13dc8af3 in nsLocation::SetHrefWithBase (…) at …/mozilla/dom/base/nsLocation.cpp:595
#4  0x13dc8cf9 in nsLocation::SetHrefWithContext (…) at …/mozilla/dom/base/nsLocation.cpp:542
#5  0x13dc9120 in nsLocation::SetHref (…) at …/mozilla/dom/base/nsLocation.cpp:510
#6  0x003fa28e in NS_InvokeByIndex_P (…) at …/mozilla/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_unixish_x86.cpp:179
#7  0x120f88bb in XPCWrappedNative::CallMethod (…) at …/mozilla/js/src/xpconnect/src/xpcwrappednative.cpp:2727
#8  0x1210c0c6 in XPCWrappedNative::SetAttribute (…) at xpcprivate.h:2550
#9  0x12105530 in XPC_WN_GetterSetter (…) at …/mozilla/js/src/xpconnect/src/xpcwrappednativejsops.cpp:1792
#10 0x001141a7 in js_Invoke (…) at jsinterp.cpp:1388
[…]


And it looks like we get there because the return value of NS_CheckContentLoadPolicy is 0x80004003, or NS_ERROR_INVALID_POINTER.

Then, after dinner, I tracked it down a little further, and if you place a breakpoint on the “\n\nAAAAAA\nrv5=%x\n” line in this patch, you can see that it’s the folder = do_QueryInterface(subFolder, &rv); line which is causing the failure, because the subFolder’s mRawPtr is null.

But I have no idea why that’s happening, so I posted what I had, and hoped that someone else could take it and run with it. And Bienvenu did, and now it’s much less of a problem for me, and I can go work on other things.

# How folder modes work.

Earlier today, I was asked by Andreas Nilsson to give him a hand with a folder pane header bug he was trying to fix. In the middle of digging around in the code, I thought “I should really write this down, so that I can understand it later.”, and so here it is.

The main place we’ll need to change is in this object.

We start in the load method, which calls registerMode, to add the mode with its localized name. There is also a default list of modes, which will come into play later.

When the user chooses to cycle the mode, it calls the setter for mode, passing it the modename, which comes from the _modeNames list (which contains both the defaults and any newly-registered modes). Then, in the setter, if the mode is a default mode, it will fail the if-test, and get the localized name from the “bundle_messenger” string bundle. If it’s a newly-registered mode, they will have passed in a localized name which we will have stored in this._modeDisplayNames, and so we will use that.

The point of the bug is to switch the label-and-two-buttons to a dropdown menu, so at this point I think we should start with an empty menulist in the XUL, and in the load method add menuitems corresponding to the values in the _modeNames array. Then, in the registerMode and unregisterMode methods, we should add and remove new menuitems, which I’m hoping will just automatically show up in the dropdown. Finally, we need to change the setter for mode to not calculate the new name, but just select the appropriate menuitem set the mode attribute on the _treeElement, and call _rebuild(). At that point, I think we’re done, but only time will tell.

Okay, so this was really posted on Dec 22nd, but I wanted to back-date it so as not to bump Amy’s “Welcome” post off the top a mere day after she posted it.

# Experiments in OpenGL (on the iPhone 3GS).

While I was at the Toronto iPhone Tech Talks, I attended the OpenGL ES sessions by Allan Schaffer. Seeing the “Shock” demo was really inspiring, and caused me to want to try my hand at some simple OpenGL Shader demos.

The base XCode OpenGL ES Application template sets you up pretty nicely for some simple experimentation, the only things that gave me any trouble were:

1. remembering to set the identifier to ca.latte.whatever so that I could build, and

2. remembering that the OpenGL ES 2.0 path only ran on the device, so of course none of the changes I was making were showing up on the simulator1, and finally

3. Figuring out that depth was position.w, and not position.z. (Did I mention that I’m a bit of a newbie at this?)

Anyways, after it was all up and running, I made the x and w co-ordinates vary on a different period than the y co-ordinate, and now the square moves around in 3 dimensions in a pleasing (to me) way.

Since this is intended for me to play around with shaders, I’m not going to bother updating the OpenGL ES 1.0 code path, but if you’ve got an iPhone 3GS, or a 3rd generation iTouch, feel free to grab the code at BitBucket, and play around. I'll be adding branches and tags and keeping it updated as I play with new stuff.

1. Rune let me know that Open GL ES 2.0 is supported in the latest version of the simulator. I guess I must have been testing with an earlier version of the SDK, or XCode, or something.