Gaia/Email/ActiveSync

From MozillaWiki
< Gaia‎ | Email
Jump to: navigation, search

Needs

  • Phase 1: A WBXML parser (done)
  • Phase 2: Base activesync support. It's an HTTP protocol, but additional work is required to deal with determining the protocol version, agreeing with the server about the device's capabilities, keepalive pings (when desired), etc.
  • Phase 3: Simple application protocol support (with no real state). Be able to connect to the server and issue simple requests. Our logic should not perform any complicated state tracking; SyncKey management should be handled by the caller.
    • E-mail protocol support (in order of importance)
      • folder list sync (we can be inefficient about this if it's simpler) (done)
      • Ask about messages received in the last few days (done)
      • Retrieve information on a message (envelope, subject, body without attachments, attachment names/info) (done)
      • Receive updated flags for known messages (done)
      • Modify simple message state (read/unread, flagged) (done)
      • Delete messages (done)
      • Send a message (done)
      • Save a draft
      • Simple server-side search
    • Calendar protocol support.
      • Ask James Lal :)
  • Phase 3.5: Autodiscovery/autoconfiguration assistance. From Android's EasSyncService, it looks like there is some special exchange logic for picking a server that it would be beneficial for us to have too.
  • Phase 4: Higher level sync logic. Use the protocol support to hook things up to our backends we have already created for IMAP/CalDAV. Ideally we can use thin adapters or otherwise port the logic.

Prior Art

Android has an Apache-licensed ActiveSync stack (implemented in Java):

 git clone https://android.googlesource.com/platform/packages/apps/Exchange

It seems to have a lot of useful information in it. Given that it is Apache licensed and we are Apache licensed, it makes a lot of sense to learn from the code and/or just port things where appropriate. The exception is that their sync logic is somewhat directly built-in to their protocol logic, and we would like our protocol logic separated.

Notable bits:

  • parser: src/com/android/exchange/adapter/Parser.java
    • code page / tag defs: src/com/android/exchange/adapter/Tags.js
  • core sync/protocol logic: src/com/android/exchange/EasSyncService.java
  • email
    • main sync logic: src/com/android/exchange/adapter/EmailSyncAdapter.java
    • search logic: src/com/android/exchange/adapter/Search.java

Its WBXML parser uses a pull-parser idiom. We can stick with that or build a DOM; either way is probably fine. If building a DOM, we probably just want to build a simple JS representation rather than trying to build an actual XML document using Firefox's underlying XML DOM support.

Documentation

Microsoft provides reasonably extensive protocol documentation. Note that Exchange Web Services is a different thing from ActiveSync and we don't care about it.

Recent changes to support relax XHR origin restrictions which will be relevant: