GSoC2010 Status Update: Week 8

July 16, 2010

Ones may take various approach implementing AppleScript support in their Cocoa application. Generally, there are 3 approaches:

  • Subclass NSApplication and implement the functionality there.
  • Create a category of NSApplication and implement the functionality there.
  • Implement the functionality in a NSApplication’s delegate.

Before deciding which approach to take, I started digging through Camino’s source. This is because Camino is written in Mac-native and has a reasonable amount of AppleScript support already implemented. Thanks to Camino’s well organized source tree, I quickly found what I needed:

Camino’s approach to implementing AppleScript support is a mix of the 2nd and 3rd approaches above. One learns from the code that MainController is NSApplication’s delegate. Thus, it has the chance to handle Apple events (AppleScript included – which is mainly Key-Value-Coding, KVC calls). It implements this method to specify which keys it wishes to handle. Then, for keys it does not handle directly, it passes the keys to other classes here. The rest of the file specifies categories (a way of adding functions to a class) of existing classes to handle AppleScript events.

Applying Camino’s approach to Thunderbird is not straightforward because of its cross-platform nature. Initially, ones is interested in finding out which class is NSApplication’s delegate in Thunderbird. A simple [NSApp delegate] (added somewhere it may be called) shows that is the delegate. This must be the right place to start hacking. After making some changes, I was able to expose a simple boolean property through AppleScript. However, there are still some concerns about making changes to because it is compiled into libxulapp_s.a library.

This is the first important step in implementing AppleScript support in Thunderbird. The next step is to design what should be supported through AppleScript. At first, I plan to start with “composing a new email message” use case, but this is impossible now, due to Thunderbird’s different mechanism of handling/sending messages. The only way now to create a new message is through a Compose window. Therefore, I’ll probably be exposing the address book in the next few weeks.

Lastly, I have also integrated QL-Enabler into the source. The repo can be found here. Simon has kindly package a Thunderbird 3.2a1pre (10.6 SDK) with QuickLook enabled here. *Note* the build is not stable yet. It works nicely when you read the email in the message pane. But if you open the mail in the standalone window, then it sometimes crash when you quicklook the attachments. Thanks a lot, Simon 😀



  1. J.D. said,

    September 13, 2010 at 5:20 am

    😀 >:D<

  2. Pete said,

    November 11, 2010 at 1:00 am

    How are you getting on with this?
    I am (and many others by the sounds of things) are pretty desperate to have some kind applescript implementation in Thunderbird.

    How actively are you working on this?

    • libras2909 said,

      December 12, 2010 at 12:50 pm

      This extension is scheduled to be in Thunderbird 3.3. However, because Xmas is coming (and New Year also), I and other developers at Mozilla don’t have a firm schedule yet 🙂 But don’t worry, this feature is of high priority now 😀

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: