I had been furiously working on a project for a client the last couple of weeks. However, I managed to squeeze in some time to play with my new iPhone. Ok the price dropped and my Nano is old... that's my story and I am sticking to it. I did poke around the Internet and found out about iTunesMobileDevice API. Then I got real lucky since I am a .Net and VS2008 user. I found a C# Wrapper in Google Code. So what can you do with the API - read on.
Manaza consists of a class library and simple example. The class library is made up
- API file - has the p/invokes for the library although it does not look 100% complete
- iPhone class - this represents a API that allows access to a device.
- iPhoneFile class - this represents a file stream
- ConnectEventHandler - a delegate for connection events
- ConnectEventArgs - event argument for the connection event
- DeviceNotificationEventArgs - event argument for device notifications which are callbacks from the API
I started by building a simple form to explorer the API. The library was easy to use and VS2008 compatible (OK I am a VS2008 fan it has a lot of useful tools in it). The first step was to setup to listen for an iPhone connection
- create a Manzana.iPhone
- setup event handlers for Connect and Disconnect events
iPhone = new iPhone ();
iPhone.Connect += new ConnectEventHandler (iPhone_ConnectionEvent);
iPhone.Disconnect += new ConnectEventHandler(iPhone_ConnectionEvent);
The API automatically handles if the phone is already connected by firing the Connect event. In addition Manaza sends a ConnectEventArgs with an enumeration of Connected, Disconnected, or Unknown. It was simple to create a single event handler and use the enumeration to display the state in the label of a StatusStrip.
connectStatus.Text = args.Message.ToString();
The API is large and it appears that iTunesMobileDevice API deals mainly with getting notifications of the connection status and files. There are 23 other DLLs in the same directory (c:\Program Files\Common Files\Apple\Mobile Device Support\bin).
Next up is reading what is on a connected iPhone. Stay tuned.