Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

Zimbra on Mac OS X: An 'Elegant' Solution with Sync Services

As the year 2006 approached, Zimbra faced a challenge: how to integrate the Zimbra Collaboration Suite (ZCS)—their open source enterprise messaging and collaboration solution—into the Mac OS X environment and synchronize it with Apple’s built-in applications, such as Safari, iCal, Address Book, and Mail. Zimbra wanted its Mac customers—administrators and users—to be able to integrate their systems into ZCS and effortlessly sync data and applications.

Fortunately, Sync Services, introduced in Mac OS X v10.4 Tiger, is designed specifically to address such synchronization challenges. With the power provided by Sync Services, Zimbra’s Mac users can easily and transparently move data among multiple computers and devices so that their data is always available.

From the developer point of view, Sync Services provides an engine that logically handles the sync operations and conflict resolution. Zimbra developer Scott Herscher faced multiple challenges when he was tasked with developing a ZCS synchronization engine for the Mac platform.

When it comes to data synchronization, “there are a lot of things you have to pay attention to,” Herscher says. “Merging the data is a nontrivial task.”

But he was able to successfully leverage Apple’s library of development tools—and Sync Services in particular—to quickly deliver software that exceeded the expectations of Zimbra’s customers.

Challenges of Synchronization

Herscher had used synchronization software for his own data-driven devices, so he was familiar with the challenges they present.

“I used to have a PDA, and it didn’t work all the time. Invariably, things got messed up, and data got garbled. It was difficult to figure out which data had changed and how to deal with conflicts." To make matters worse, calendaring data can be complex, Scott explains. “When you’re dealing with recurring events and exceptions, the data and synchronization tasks become complicated.”

ZCS-a scalable solution that provides multiplatform support for enterprise, service provider, academic, and government environments-integrates email, contacts, shared calendar, VoIP, and online document authoring and sharing. Zimbra’s Mac users often synchronize data to .Mac, a PDA, Microsoft Entourage, and other software and devices. This type of complex synchronization requires an indeterminate amount of data.

“Sync Services does a lot of the heavy lifting, conflict management, and data merging,” says Herscher. “And, as far as synching with .Mac, a PDA, or anything else users can synch with on a Mac, it’s taken care of for me. I merely sync Zimbra to the Sync Services framework, and then each device syncs to the Sync Services framework. No additional work is necessary. It’s a big win to have a centralized sync repository that everyone can use.”

The iSync Connector

Of all the projects Scott has worked on recently, he’s most proud of the Mac-based Zimbra iSync Connector, which earned him the moniker iSync Guy.

“The connector is basically a way to synchronize the calendaring and contact information that resides on the Zimbra server with the data in iCal and Address Book on the Mac and, if I did my job correctly, keep them in sync,” Herscher explains.

What appeared to be a challenging task turned out to be to be fun for Scott, who’s used to working on multiple platforms. “The Mac has all the tools that allow me to focus on solving the problem instead of writing a lot of code before I can begin,” he says.

When it comes to common data structure persistence, for instance, Herscher says that, “programming on the Mac is easy. You can create lists, dictionaries, and all kinds of complicated data structures, persist them to disk, and easily read them from disk. On other platforms, you have to use a third-party class library that’s typically kind of onerous; on the Mac, the process is elegant.”

Herscher appreciates that Apple provides a lot of developer application programming interfaces (APIs) to write to. “I found that, in the best Apple tradition, the APIs are straightforward, clear, and about as simple as you need them to be," he says. "It didn’t take me long to get up to speed. The combination of the available APIs and their quality is powerful.”

Exploiting Zimbra’s natural client and server separation, the connector consists of two pieces. The first is the user interface (UI), which Scott built using Cocoa and Interface Builder. Compared to other interface builders, he found Apple’s environment useful from two perspectives:

“You can use the standard widgets that already look great—things like buttons, list views, tab panes, and all the preference pane design choices,” Scott explains. But he also enjoyed using Interface Builder to wire up the interface and describe the functionality of buttons.

The second piece of the Zimbra iSync Connector is the underlying console executable, which does all the synching and the heavy lifting. This element uses SOAP to translate requests between Sync Services and Zimbra’s server databases and is defined by the user in Zimbra’s system preferences.

The connector maintains caches of object IDs on the Zimbra servers. The challenge is that the object IDs must persist to disk so that Sync Services can read and write them. “It was so easy on the Mac using the Cocoa framework,” Herscher explains. He used the NSCoding protocol to persist the instances of classes such as NSDictionary, NSString, and NSArray.

“You get caching almost for free,” he says, “because with one method call, you can store data to disk, and using another, you can read the data from disk. It’s more or less done for you—easy as pie.”

Herscher also wrote a Cocoa application to overcome the connector project’s biggest obstacle. The Zimbra server uses Java time zone specifications, but the Mac uses UNIX time zone specifications. He used his Cocoa application to create the relationships between the two time zone data sets, thereby automating the translation between the schemas.

Exceeding Expectations

Before Scott started the project, he and Zimbra thought it might take six months or more to complete the work they envisioned for the connector. The Sync Services framework was new for Mac OS X Tiger, and Herscher expected challenges “because it was not clear whether Sync Services had been battle tested.” Even so, he was able to complete the specified work in less than half the expected time-and working only part time. “We were all pleasantly surprised at how relatively quickly the whole thing came together.”

Zimbra’s iSync Connector is currently in public beta. Herscher looks forward to the additional work required to make the product, “more powerful and capable. One thing I love about the Mac is how easy it is to write good-looking software,” Scott explains. “The connector does powerful work, and it’s really pleasing to the eye.”

Zimbra’s customers agree. Alonzo Turner, lead developer at Apple Professional Services company OnDeckTech, says, “ZCS allows us to replace Microsoft Exchange Server for our customers with a cross-platform enterprise system that plays well with others. And the possibilities are limitless. For example, we can see integrating the Joomla! Content Management System (CMS) into the Zimbra environment, integrating it with iCal and Address Book, too.”

Unanticipated Benefits

Members of the open source community are busy extending Zimbra with Zimlets™, mechanisms that integrate ZCS with third-party information systems and content. Since the successful introduction of the Zimbra iSync Connector, Zimbra has become a bridge between third-party extensions and the Apple desktop. Highly anticipated examples include the SugarCRM and Asterisk PBX Zimlets, which enable these applications to access both Zimbra and—through the connector—Apple’s desktop applications.

The OnDeckTech team is also working on a Zimlet that will synchronize the company’s FileMaker-based business management system with Zimbra. “Because of Zimbra’s iSync Connector, this will further synchronize our system with Apple’s desktop suite, increasing the value of the time we spend coding and extending the usefulness of our effort,” Turner explains.

Contributing to Zimbra

ZCS is available under an open source license, and the developer community helps test and program the software. If you’re interested in contributing to the project, you can get involved by downloading the source code at the Zimbra site. You can also check out the Zimbra developer forums.

For more information on the Zimbra Collaboration Suite, and on getting involved with the open source project, see the see Zimbra website.