Daniel's Stuff

I write code

Category: Cocoa

PSMTabBarControl and Interface Builder 3.0

For one of the projects I’m working on I needed a nice looking tab bar control.  Under previous versions of Mac OS X I used the PSMTabBarControl.  The control is nicely integrated into Interface Builder 2.0, but I no longer have IB 2.0 installed as I’ve upgraded to more recent versions of XCode.  I’ve done a very quick port of the code for IB 3.0 and made it available here on github.

Enjoy 🙂

Windows Live Mail

Just a quick note to let everybody know that I’m making good progress reverse engineering the Windows Live Mail protocol.  With the help of a couple of other people I’ve managed to determine the nature of the compression used on the message data.  We’ve successfully managed to build the decompression table and I’m now working through the routine to do the actual decompression.  IDA Pro is an amazing piece of software and I highly recommend it if you ever need to do any reverse engineering of compiled programs.

Weird characters in the previous post

Something really strange happened in the previous post.  There were these weird characters appearing in the text.  From what I can see it is WebKit trying to be helpful and create non-breaking spaces.  Unfortunately rather than insert a good old   it is inserting 0xA0 characters.  I’ve just added some code to look for these characters and replace then with  .  It should be interesting to see if it works 😉

WebView woes

I have been working on a little blog posting app for my wife for some time called BlogThing. The first version worked well enough that I released it for download from the Automagic Software site. It used some pretty nasty stuff that iterated over the chunks in an NSAttributedString, and while it worked pretty well I decided I wanted something a little more future proof. To that end I decided to look into using WebView in edit mode. Under 10.4 this worked really nicely. I could drag in imanges, set the fonts and do all sorts of really neat things. Unfortunately under 10.5 dragging and pasting images into the blog posting just stopped working 🙁 and I’ve not had a lot of time to look into it. Tonight I’ve managed to get it working well enough that I think I can finally give it to my wife to play with.

The following is an example of what I’ve had to do to get dragging to work the way I want it do. I really don’t like it though

– (unsigned)webView:(WebView *)sender dragDestinationActionMaskForDraggingInfo:(id <NSDraggingInfo>)draggingInfo {

NSPasteboard* pb = [draggingInfo draggingPasteboard];

if([pb availableTypeFromArray: [NSArray arrayWithObject: NSFilenamesPboardType]]) {

// @TODO: this code assumes that any file dragged in is an image! Bad things will probably happen if they aren’t

NSArray* filenames = [pb propertyListForType: NSFilenamesPboardType];

NSMutableString* html = [NSMutableString string];

for(NSString* filename in filenames) {

[html appendFormat: @”<img src=\”%@\”/>”, [[[NSURL alloc] initFileURLWithPath: filename] absoluteString]];


[pb declareTypes: [NSArray arrayWithObject: NSHTMLPboardType] owner: self];

[pb setString: html forType: NSHTMLPboardType];


return WebDragDestinationActionAny;


Incidentally I’m posting this with BlogThing 2.0

Come and get it

The Leopard version of my HTTPMail plugin for Mail can be downloaded from here. Please note that as with any first release with a new version of OS X things may not be as stable as I would like. It works on my machine 😉

I have updated the documentation to show screen shots from Leopard and overall the installation and setup procedures are a little more streamlined.


Almost there!

Yesterday I got account editing working, and tonight’s effort sees sending working. It is still not possible to create new accounts, but that is something for another time. It’s almost midnight and I’m going to be woken up at some time around 3 or 4 am by the little one for a feed so I’d better go get some sleep while I can 😉

Once I’ve got account creation working then the plugin is pretty much done for Leopard 🙂

HTTPMail Plugin and Leopard

Tonight I’ve had some success with getting the plugin working under Leopard. It still isn’t ready for public consumption, however it is coming along nicely.
Currently if a httpmail account is already configured it will connect to the Hotmail servers and successfully download the messages. Unfortunately sub-folders aren’t quite working yet, nor is creation of new accounts or editing of account settings.
Still, it is progress 🙂 Now it is time to go to bed and get some sleep. With a wife, two kids and a day job, I don’t get as much time to work on these things as I once did 😉

Cocoa WebKit

I’ve been playing with the Cocoa WebKit over the last week or so and have rewritten my blogThing application to use it.  So far I’m quite pleased with the way things are coming along 🙂

It lets me do some very interesting things such as paste in formatted text from XCode


//  DPKeychain.h

//  iSpeak


//  Created by Daniel Parnell on 26/07/04.

//  Copyright 2004 Daniel Parnell. All rights reserved.


#import <Cocoa/Cocoa.h>

#import <CoreFoundation/CoreFoundation.h>

#import <Security/Security.h>

#import <CoreServices/CoreServices.h>

@interface DPKeychain : NSObject {

    SecKeychainRef keychain;


+ (DPKeychain*) defaultKeychain;

+ (DPKeychain*) keychainWithPath: (NSString*) aPath;

– (DPKeychain*) initWithPath: (NSString*) aPath;

– (void) setPassword: (NSString*)aPassword forName: (NSString*) aName andService: (NSString*) aService;

– (NSString*) getPasswordForName: (NSString*) aName andService: (NSString*) aService;

– (bool) containsPasswordForName: (NSString*) aName andService: (NSString*) aService;

– (void) removePasswordForName: (NSString*) aName andService: (NSString*) aService;


Inline image support is also working really nicely 🙂
I still need to get things like automatic link creation working, but that’s pretty straight forward.

To top it all off I’ve also made use of CoreGraphics transitions to make things look a little prettier.  That’s been heaps of fun 🙂

flvThing is released

I’ve released flvThing on the www.automagic-software.com web site. It seems to play every flv file I’ve thrown at it quite nicely 🙂 
The flv files are played using the installed flash player which is hosted inside a WebView control. The application creates a tiny very stupid web server that serves up the flash files as well as the flv file for the flash player to load. It seems to work pretty well 🙂