1. Funambol Java™ Platform, Java ME
Technology-Based Open-Source Messaging
Client: Lessons Learned
Edoardo Schepis, Java ME Tech Lead
Session: TS-4992
2. What developers should know about building
open source Java Platform, Micro Edition (Java
ME platform) messaging applications for the
mass market
How to build synchronization clients for Java ME
technology-based devices, starting from the
Funambol Java ME SDK
2008 JavaOneSM Conference | java.sun.com/javaone | 2
3. Agenda
Introduction
Funambol Java ME SDK
Push E-mail Client
Write Once...
Mobile Open Source
On the edge
2008 JavaOneSM Conference | java.sun.com/javaone | 3
4. Agenda
Introduction
Funambol Java ME SDK
Push e-mail Client
Write Once...
Mobile Open Source
On the edge
2008 JavaOneSM Conference | java.sun.com/javaone | 4
5. Synchronization
Data synchronization is the process of making
two sets of data look identical
Which means
• Exchange data modifications
• Conflict resolution
Synchronization Protocol Features
• Define a method for establishing a synchronization session and
communicating modifications
• Record naming and identification
• Define protocol commands
2008 JavaOneSM Conference | java.sun.com/javaone | 5
6. Synchronization
Why do we need it?
• PDA, Handsets, iPod, Outlook, Thunderbird, Skype, Gmail, Yahoo,
Jajah, Facebook, Web...
• Mail, Contacts, Calendar
• But also bookmarks, SMS, MP3, documents, files...
• Mobile field work force
The common usage
• PC Suite, Bluetooth, Active Sync, iSync: wired and PC
Over the Air is the key
• Data plans
• It just works
• Wider support
2008 JavaOneSM Conference | java.sun.com/javaone | 6
7. OTA Synchronization with mobile devices
OMA DS (former SyncML)
• Platform independent
• Open
Uses SyncML to automatically synchronize
• Contacts (address book), including photos
• Calendar
• Tasks and notes
• Additional and custom data types
Server maintains backup of PIM data
Data can be accessed via web
Full capabilities for mobile backup service
2008 JavaOneSM Conference | java.sun.com/javaone | 7
8. Native sync or not?
Native is good, but...
• Not always available (branding phones...)
• Native clients not so easy to configure (even to find...)
Do not reinvent the wheel, just make it better
• For all the handsets
• Java ME Platform, Windows Mobile, Linux, Blackberry, Android, iPhone
• For all the clients
• Outlook, Thunderbird, Evolution
• For all the Mail/PIM servers
• POP, IMAP, Exchange...
2008 JavaOneSM Conference | java.sun.com/javaone | 8
9. Funambol Software Overview
Push
• e-mail, contacts and calendar
Mobile Backup & PIM Sync
Mobile Device Management
Mobilizing Data & Applications
2008 JavaOneSM Conference | java.sun.com/javaone | 9
10. Funambol Software Overview
Funambol Portal
1.5B+ Devices Email/PIM
Nokia POP/IMAP
Motorola Yahoo!
Sony Ericsson Hotmail
Samsung Gmail
LG AOL
SyncML Outlook
Win Mobile Exchange*
Java ME Domino*
iPhone Push PIM OTA Mobile Thunderbird*
Android* Email Sync Config Platform Custom/3rd party
Funambol Server
*Community project
2008 JavaOneSM Conference | java.sun.com/javaone | 10
11. Agenda
Introduction
Funambol Java ME SDK
Push E-mail Client
Write Once...
Mobile Open Source
On the edge
2008 JavaOneSM Conference | java.sun.com/javaone | 11
12. Funambol Java ME SDK
MIDP 2.0, CLDC 1.0, WMA 1.1
SyncML API (∼24kb)
• Transport
• Sync Protocol
• Sync Source Sync Application
Mail API (∼15kb)
• MIME std parser
• Multipart support SyncML Mail
Common (∼30kb)
Common
• Push
• SMS JavaME API
• TCP/IP
• Storage
• FileSystem
• RMS / Blackberry
• Utils
2008 JavaOneSM Conference | java.sun.com/javaone | 12
13. Funambol SyncML API - 1/2 Sync Application
SyncML Mail
SyncManager
Common
• Handles communication and protocol
JavaME API
Sync Source
• Client database:
handles items to send and to store
SyncItem
• Abstracts objects to sync
Sync Modes
• Two way, one way
• Refresh
SyncListener
• Notifies upper layers
Transport
• Http/s, Socket, Bluetooth
2008 JavaOneSM Conference | java.sun.com/javaone | 13
15. Funambol Mail API Sync Application
SyncML Mail
Message
• Multipart Common
Mime Formatter and Parser JavaME API
• RFC 2045, 2046
Folders
Flags
Message Message
Header attributes Header attributes
To: <monty@funambol.com> To: <monty@funambol.com>
Subject: Today's meeting Subject: Today's meeting
Content-Type: text/plain; Content-Type:
... multipart/mixed;...
Body Body
Multipart
BodyPart
Hello, World!
Hello, World!
BodyPart
<br>Hello...
BodyPart
[attachment]
2008 JavaOneSM Conference | java.sun.com/javaone | 15
16. Funambol Common Libraries Sync Application
SyncML Mail
Push
• SMS OTA service Common
• TCP/IP service JavaME API
• Server Alert Notification (SAN)
• OTA Configuration
Storage
• RMS / Blackberry
• File System
Utils
• Logging
• Base64 and QuotedPrintable
• ThreadPool
• Serialization
2008 JavaOneSM Conference | java.sun.com/javaone | 16
17. How to build a sync-based application
Prepare your SyncSource
• Create a configuration for synchronization
• Implement sync Items database
Start the sync with SyncManager
• Mapping and modifications
Optional:
• Create a configuration
• Device capabilities (manufacturer, sw, hw, fw, utc support, ...)
• Connect a SyncListener Sync Application
• Notify upper layers
• Filtering
SyncML Mail
• Size, age and more
Common
JavaME API
2008 JavaOneSM Conference | java.sun.com/javaone | 17
18. Let's sync our contacts
Vcard + JSR75
File format standard for electronic business cards
• RFC 2425 and RFC 2426
• V2.1 Specification from the Internet Mail Consortium
• V3.0 Specification approved by the IETF
Java Specification Request (JSR) 75 (PIM package)
BEGIN:VCARD
VERSION:2.1
N:Schepis;Edoardo
FN:Edoardo Schepis
ORG:Funambol
TITLE:JavaME Tech Lead
TEL;WORK;VOICE:+1 (650) 701 1450
ADR;WORK:;;643 Bair Island Road, Suite 305;Redwood
City;CA;94063;United States of America
URL;WORK:http://www.edschepis.net
EMAIL;PREF;INTERNET:schepis@funambol.com
REV:20080309T150456Z
END:VCARD
2008 JavaOneSM Conference | java.sun.com/javaone | 18
19. Let's sync our contacts
JSR75 – get Contact from a VCard
public Contact getContact(byte[] vCard) {
ByteArrayInputStream bis = new
ByteArrayInputStream(vCard);
PIMItem[] items = pim.fromSerialFormat(bis, “UTF-8”);
return ((Contact) items[0]);
}
2008 JavaOneSM Conference | java.sun.com/javaone | 19
20. Let's sync our contacts
JSR75 – get Vcard from a Contact
...
ContactList contactList = (ContactList)
pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
...
public byte[] getVCard(Contact c) {
ByteArrayOutputStream os = new
ByteArrayOutputStream();
PIM.getInstance().
toSerialFormat(c, os, “UTF-8”,
“VCARD/2.1”);
return os.toByteArray();
}
2008 JavaOneSM Conference | java.sun.com/javaone | 20
23. Agenda
Introduction
Funambol Java ME SDK
Push E-mail Client
Write Once...
Mobile Open Source
On the edge
2008 JavaOneSM Conference | java.sun.com/javaone | 23
24. Push E-mail Client 1/2
E-mail on mass market handsets
• Java ME Platform
• Blackberry too
All standard e-mail functionality
Push
• SMS and TCP based
Advanced features e.g.
• Send Photo
• Call sender
• Integrated address book eliminates typing of e-mail addresses on
phone
Advertising
2008 JavaOneSM Conference | java.sun.com/javaone | 24
26. Push Implementation
Client waits for server push
• The ds-server detects updates on mail server and notifies the
registered client
Using SMS (also with app. off)
• The app is registered with PushRegistry for incoming SMS
Using Socket (only with app. on)
• CTP
• The app manages a socket open with the server (CTP server) that uses it for
sending notifications
• STP
• The app starts a serversocket and waits for server notifications
• IP natting, proxies and gateways
• Socket and PushRegistry
• Specs are always right... but app. closed means no connection on many
devices and therefore no IP address
2008 JavaOneSM Conference | java.sun.com/javaone | 26
27. Agenda
Introduction
Funambol Java ME SDK
Push E-mail Client
Write Once...
Mobile Open Source
On the edge
2008 JavaOneSM Conference | java.sun.com/javaone | 27
28. ObjectOriented vs. Performance and Fragmentation
How much does OO still flows in our veins?
• Fat classes
• “if” vs. polymorphism
• Preprocessing
• Antenna
Provide the best User Experience with
• 800kb of Heap space...
• 512kb of RMS
• 100kb of jar (suggested)
Fragmentation
• Targeting consumers means building many bundles
• Platforms: the latest not always means the best
• Branding phones: same device but with fw variant
2008 JavaOneSM Conference | java.sun.com/javaone | 28
29. Certification process - 1/2
Trusted 3rd party Certification
• to avoid requests for permissions to the user
• network, multimedia, PIM and filesystem access, SMS usage, autostart
• to bypass security restriction of carrier-branded phones
• To access restricted API
Verisign/Thawte
• Developers own private key
• Certificate in chain
• Very popular
• Pay once in a year
Java Platform Verified Program
• GeoTrust
• Pay per device/per release
• Testing house applies UTI general criteria (don't mind if the sync
works)
• The only viable solution for Motorola devices
2008 JavaOneSM Conference | java.sun.com/javaone | 29
30. Certification process - 2/2
Carriers security restrictions
• No “Ask Once” for network connections: client-server apps become
impractical and unrealistic
• No Push Registration
• No JSR 75 access
• ... some carriers avoid also to play a MIDI file (!)
Need an agreement with mobile operators or manufacturers
to enter in operator/manufacturer trusted domain
• Full access to all the API
• No user prompts
2008 JavaOneSM Conference | java.sun.com/javaone | 30
31. Agenda
Introduction
Funambol Java ME SDK
Push E-mail Client
Write Once...
Mobile Open Source
On the edge
2008 JavaOneSM Conference | java.sun.com/javaone | 31
32. Funambol is Mobile Open Source
Community Edition
• AGPLv3 (Affero GPL)
• Fixing the ASP loophole (SaaS):
• “If you change or add to the code and you use the software as the basis of an
Internet or network-based service, you must publish your code or buy a
commercial license”
• http://www.fsf.org/licensing/licenses/agpl-3.0.html
Funambol CommEd Contains:
• A data synchronization (DS) server that works on Linux and Windows
• Mobile device clients e.g. Windows Mobile, Java ME Platform, Outlook,
iPod
• E-mail connector that supports POP and IMAP e-mail systems
• Administrator tool
• Software development kits and interfaces
• Documentation
• Community projects, support for Exchange, Domino, BlackBerry and more
2008 JavaOneSM Conference | java.sun.com/javaone | 32
33. Why Open Source in mobile matters?
Broadest device compatibility
First to market advantage
Largest mobile open source community
Mobile innovation, resources and support
Complete code transparency
Reduced risk
Low cost
2008 JavaOneSM Conference | java.sun.com/javaone | 33
34. Developing open source software
Everybody watches you! (therefore write good code)
You belong to a Company and to a Community
Everyone is in the spotlight
Communities need frameworks - Customers need products
2008 JavaOneSM Conference | java.sun.com/javaone | 34
35. Community Programs
Code Sniper
• Awards bounties of up to several
thousand dollars for the development
of connectors, plug-ins, client and
synclets by Community Members
• Enable the Community to influence
the direction and reach of the
Funambol Project through direct
contribution of open source code
• New: connectors for Social Networking
Phone Sniper
• Awards bounties to Community
Members for testing Funambol on
mobile devices
2008 JavaOneSM Conference | java.sun.com/javaone | 35
36. Funambol Community
Hall of Fame
Carlo Codega (Italy) Mike Taczak, Nguyen Mai
http://sazilla.blogspot.com (USA)
• Mozilla Sync http://www.mailtrust.com
• Android Sync • Blackberry Plugin
• iPhone
Paulo Sergio (Portugal)
• Gmail Sync Plugin Patrick Ohly (Germany)
http://sf.net/projects/funambol-gmail http://www.estamos.de
• Yahoo Sync Plugin • SyncEvolution
http://sf.net/projects/funambolyahoo
• iPhone
2008 JavaOneSM Conference | java.sun.com/javaone | 36
37. Agenda
Introduction
Funambol Java ME SDK
Push E-mail Client
Write Once...
Mobile Open Source
On the edge
2008 JavaOneSM Conference | java.sun.com/javaone | 37
38. The new generation of clients
Android
iPhone
Linux Devices: OpenMoko, Qtopia
Symbian
2008 JavaOneSM Conference | java.sun.com/javaone | 38
39. Android
To make a sync application for Android, you
should have:
• An Activity controlling the main UI (start sync,
choose items)
• Some other activities for Settings, About, etc.
• A Service to actually doing the sync
When the user starts the sync:
• The Activity trigger the service using
startService() with an Intent
• The service is started and the method onStart() is
called
The Service talks back to the app using
Intent to notify the sync progress
http://code.google.com/p/funambol/
2008 JavaOneSM Conference | java.sun.com/javaone | 39
40. iPhone
a Safari browser web app for
all users
a native app for developers
and advanced users that have
"jailbroken" their iPhone
• Based on SyncEvolution
• Compiled for iPhone and
connected to the
(undocumented)
AddressBook interface
• A simple COCOA user interface
and the game is done!
We are designing the new
version of the client, based
on the Apple SDK
http://www.funambol.com/solutions/iphone.php
2008 JavaOneSM Conference | java.sun.com/javaone | 40
41. For More Information
Funambol Open Source
• http://www.funambol.com/opensource
Funambol SDK and Documentation
• http://www.funambol.com/opensource/downloads.php
Code Sniper
• http://www.funambol.com/opensource/codesniper.php
SyncML - Data Synchronization and Device Management
• http://www.openmobilealliance.org/syncml/
2008 JavaOneSM Conference | java.sun.com/javaone | 41
42. my.funambol.com
Simple set-up of phones for mobile e-mail and PIM sync
Supports over 700 device models
Sync, view, edit PIM dataList
2008 JavaOneSM Conference | java.sun.com/javaone | 42
43. Summary
Synchronization
• Work in any environment with any device, efficiently and without
configuration/upgrades hassle
Funambol SDK
• Fast development of your sync-applications
Open Source
• The key to beat fragmentation
We are looking for snipers
2008 JavaOneSM Conference | java.sun.com/javaone | 43