Written: June 14th, 2007, 20:23 (UTC) By: omer
As an update to this post on working with the Mac OS X Address Book, I now have another deliverable: a program that prints all of the properties available on the address book. It's still only printing ASCII, and it's not in the correct format to be imported into OOo as a text file, but these issues are hopefully not hard to fix, and since they don't actually involve the Mac OS X Address Book API, I'm not sure that I'll actually take those final steps. I'm also not yet handling groups (the Mac OS X Address Book is split into two databases: groups and people), which is a more important lack and one that I will likely spend some time exploring soon. Anyway, the tarball for the program is available here. A brief description follows.
Basically: the the most important parts of the program are two method, one called printInformationForRecord and the other called getStringRepresentationOfPropertyValue. The former (by using the latter) can print any property in the address book (at least any one that I've been able to create so far). It doesn't assume that it is working with people, though I haven't tested it with groups yet. The latter can turn any type of value into a string (with the exception of "data" values, which are basically byte arrays and thus could be storing any kind of data), where the types are any of the ones listed in Apple's list of possible types. Although these methods only print a property to STDOUT, they are general enough that only a few manipulations would be enough to get them to do more complex things. This might even become the skeleton for handling the Mac OS X Address Book in OOo, though the complexity of OOo code will likely prevent that.
P.S. Thanks to Florian Heckl for correcting errors in the original program that helped me make this new one!