Archive forMarch, 2006

Demystifying Mail.app Plugins – A Tutorial

In the course of writing my email un-attachment plugin for Mail.app, I found that Apple has a capable, but entirely undocumented, plugin API. I’m providing this tutorial in the hopes that it may be useful to anyone else considering implementing a plugin for Apple Mail.

Update 2008-02-16: See my updated version of this tutorial for Leopard.

Update 2006-04-11: Apparently yesterday’s update truncated the entry. I’ve managed to restore it thanks to the Google Gods and Their Glorious Cache.

Update 2006-04-10: Added some cautionary text about using a private API, as suggested by Jens Alfke. It’s all common sense, but definitely deserves a mention. Especially considering how uncommon common sense is! :-)

__(’Read the rest of this entry »’)

Comments (14)

Cool Objective-C tricks

I have this really annoying habit of composing emails that refer to an attachment, only to realize after sending the message that I forgot to include the attachment. So I wrote an attachment scanner plugin for Apple’s Mail.app. The plugin itself is nothing special. It just checks if there’s an attachment, and if there isn’t, makes sure you aren’t using certain words in the message body (basically, attach, attachment, and the like).

What is particularly cool, however, is how the plugin works! It’s written in python (using PyObjC) as a .mailbundle, so when Mail starts up, it will load the plugin. The plugin then creates a subclass of the WebMessageEditor class that Mail uses for, well, the message editor window. It then redefines the send: message to perform its checks, and if they all pass, call its parent’s send: method. On its own, that’s nothing special. What’s cool is how I get Mail to use my WebMessageEditor instead of the one it was compiled to use.

Enter the Objective-C runtime. Objective-C supports a notion of class posing, whereby a subclass can pretend to be (or, to pose as) its parent class. Thus, whenever the code instantiates the parent class, it actually instantiates the subclass. Now, when Mail creates a new WebMessageEditor window, it actually creates my WebMessageEditor window, which adds in my attachment checking hooks. How cool is that?!

Comments (1)

Back from the Abyss

It’s been over two years since I last updated my weblog (my last update was back in November of 2003!). After getting fed up with all the blog spammers, I’ve finally decided to give it another go.

Why another weblog? I’ve come up with a couple of reasons. For starters, I’ve found that my writing has gotten pretty dreadful over the past few years. My thoughts are no longer as coherent as they used to be, and I hope that getting into the habit of putting them down on paper bits will help.

Additionally, I’ve found that I really don’t have a good place to put my more serious thoughts in public. My LJ is all fine and good, but that’s where I put all of my meaningless drivel and the occasional emotional crap that my friends care about, but no one else does. I hope that this space will, instead, be a useful resource for me to share my perspectives as a human-computer interaction (HCI) practitioner[-in-training]… and, of course, other geeky stuff, too.

Comments