I’ve been using the LookupCIDName command to re-write incoming caller ID names for people that I know. This way, instead of ‘VOICESTREAM’, I get names like ‘Laird, Rusty - cell’.
Using LookupCIDName is easy, but populating the database it uses isn’t. So, here’s a tool: asterisk-vcard-cid. It extracts names and numbers for a directory full of vCards and inserts them into Asterisk’s cidname database. This, combined with ab2vcard and Subversion makes it easy to export your Mac OS X Address Book into Asterisk, although nothing here is really limited to Mac OS X; vCards are the dominant standard for exchanging address book information, so almost everything supports them.
There are two things to be aware of for this release. First, the code is written in Ruby, so you’re going to need a Ruby interpreter installed. Most Linux distributions have one prepackaged; use ‘ruby1.8’ on Debian.
Second, this release can only handle 1 vCard per vCard file. That’s the format that I’m using with ab2vcard, but most tools would rather do bulk exports by bundling lots of vCards together into a single file. If anyone is interested, then I can add support for multiple-vCard files in the next release.
I had a weird thought a couple hours ago. Suppose you set up two Macs with ab2vcard, both syncing to the same Subversion repository, and then added a bit of extra magic to handle conflicts and deletes. Then hand conflicts and remote updates off to Address Book and let it handle it on its own (that was one of the improvements in Panther--the Address Book has a merge dialog).
Wham, instant version-controlled shared address book. Have a nice day.
Of course there are a few little details that need to be handled. Most of them involve tracking deletions and doing the Right Thing. ab2vcard's current deletion tracking is hokey, but it works when it owns the vCard repository. In a shared environment, you need better logic. It's not rocket science, though.
As mentioned yesterday, I'm now exporting all of the entries in my OS X Address Book into Subversion. In order to do this, I needed to hack up a conversion tool. Since I have it working for me, I figured I'd share it. So, I'd like to announce ab2vcard version 1.0. You can download an OS X installer package plus the source.
The whole thing is pretty trivial to use. Just run /usr/local/bin/ab2vcard directory, and it'll create a vCard for everyone in your Address Book in the directory directory. If you add the -d flag, then it'll erase files that aren't currently in your address book. If you add the -s flag, then it'll try to check changes into Subversion. The README that's included gives more detail, as does the manpage.
It's written in Objective C and derived from 'contacts' by Shane Celis. Since I now have a whopping 4 hours of experience with Objective C, don't expect the code to be spotless, but it shouldn't be too bad. Objective C is a surprisingly easy language, if you already know C and are somewhat familiar with other Smalltalk-influenced languages. The hard part is getting the hang of all of the framework code, but Apple's documentation helped with that.
Let me know if you find any bugs, or if you find this useful for anything.
Continuing the theme of backing up my PIM data via Subversion, I'm now exporting the contents of the OS X address book into a subversion tree, and then syncing that from my laptop onto a box at home.
This was a bigger pain then I anticipated; I couldn't find a tutorial that showed how to use AppleScript to export data from the Address Book, but I could find an Objective C program that extracts data from it. I've never used AppleScript or Objective C, so either choice involves learning a new language. At least with Objective C, I have working source to start from. It took most of an hour to rip out the text printing code from 'contacts' and substitute in code to save vCards to individual files, but the result seems to work quite nicely. I'll clean it up and release it eventually; if anyone is interested, send me mail and I'll speed it up.
Update: I've released this as ab2vcard. Let me know if you have any problems.