iChat File Transfer Analysis
Introduction
This summer I was fortunate enough to be selected as a student for Google Summer of Code 2007 to work on the Adium instant messenger. My specific project focuses on improving support for Bonjour messaging. I have worked on updating libezv which was originally written by my mentor, Andrew Wellington.
Within the past month work progressed towards the point where the last major feature was file transfer. I found a rather insightful post to Apple’s rendezvous-dev mailing list which helped immensely in deciphering iChat’s file transfer process.
As mentioned in the post, iChat adds custom attributes to the Jabber OOB Protocol. Unfortunately, these custom additions are the same portions lacking documentation. After more research, I have deduced what exactly these attributes are and how to use them!
File Transfer Process
The process for a typical transfer from iChat starts with an xml message similar to the following:
<message type="chat" to="erich@computer">
<body>Here is the file you asked for: </body>
<html xmlns="http://www.w3.org/1999/xhtml">
<body ichatballooncolor="#E68CBD" ichattextcolor="#000000">
<font ABSZ="12" face="Lucida Grande">Here is the file you asked for: </font>
</body>
</html>
<x xmlns="jabber:x:event">
<composing/>
</x>
<x xmlns="jabber:x:oob">
<url type="file" size="4" posixflags="000001A0" mimeType="text/plain"
hfsflags="00000008">http://192.168.1.100:40785/B554ECD98129158D/File.txt</url>
</x>
</message>
Most everything in the message is self explanatory except for the posixflags and hfsflags attributes. Both attributes hint at their meaning, however, I didn’t know what exactly was necessary to process the information. After some further documentation reading, the answer came rather easily.
Attribute Values
posixflags proved the easier attribute to decipher. In actuality this attribute merely gives the value for the NSFilePosixPermissions key in the file attribute dictionary converted to hexadecimal. Using this information then becomes as easy as converting the hexadecimal value to an NSNumber and then using NSFileManager to apply the value for the NSFilePosixPermissions key.
The meaning of hfsflags did not come as easily. Actually, the answer didn’t come until I was nearly finished finding another way to get information about the file. It turns out that hfsflags consists of the hexadecimal encoding of the finderFlags member of the FileInfo struct. The Finder Flags describes information about a file or folder such as whether the item has a finder label or whether it is an alias. Although the workaround mentioned before precluded any attempt at using this value, in theory application of the finderFlags would be as simple as recreating the FileInfo struct and then applying that information using a call to Carbon’s FSSetCatalogInfo().
Conclusion
Looking back the process to discover these attributes wasn’t very challenging, however, hopefully no one else will need to do research into what the posixflags and hfsflags attributes describe.

