Goal: Give users a way to access and manage their contacts from FXOS devices
and WebRTC-enabled FX clients through a rich set of identity-attached services
(picl).
Other experimental identity-attached services that include:
A FirefoxOS add-on that listens for updates to contacts
A simple server for receiving published updates
An indexer for providing fast autocompletion of partial contact names
When the add-on detects a change to your contacts, it tries to POST the changes
to the local server.
The indexer and completer in its simplest form can be used from any web page
using IndexedDB-completer
The implementation of the completer here runs in chrome, and will message
asynchronously back to clients looking for lists of completions, as in this
example use case by Crystal
Beasley.
navigator.mozContacts provides an asynchronous interface for working with
contacts, which are stored in the browser using IndexDB. The
FxOS Contacts
app uses this API. The API includes:
save(contact)
find(options)
remove(record)
clear()
getSimContacts(contactType)
Each of these function returns a request object. The caller should register
onsuccess and onerror callbacks on this object; these will be called with
results when the request succeeds or fails.
A successful find request will point to a list of json result objects with
request.result. So you can query request.result.length, etc. For example:
// Find all the contacts named Juanita.
// Queries can use options like these:
var options = {
filterBy: ['givenName'],
filterLimit: FILTER_LIMIT,
filterOp: 'equals',
filterValue: 'Juanita'
sortBy: 'familyName',
sortOrder: 'ascending'
}
request = navigator.mozContacts.find(options);
request.onsuccess = function() {
if (request.result.length) {
// found a record with id=contactId
}
}
request.onerror = function(message) {
console.log("error:", message);
}
The
ContactManager
messages with the
ContactService
(using cpmm and ppmm message managers respectively); the
ContactService interacts with the
ContactDB,
which is an IndexedDBHelper.
The ContactManager uses the PermissionPromptHelper to request permission to perform any
of these actions.
These modules are all to be found in gecko dom/contacts.
picl Contacts
Goal: Give users a way to access and manage their contacts from FXOS devices and WebRTC-enabled FX clients through a rich set of identity-attached services (picl).
Other experimental identity-attached services that include:
Overview
There are two pieces to this project:
When the add-on detects a change to your contacts, it tries to POST the changes to the local server.
The indexer and completer in its simplest form can be used from any web page using IndexedDB-completer
The implementation of the completer here runs in chrome, and will message asynchronously back to clients looking for lists of completions, as in this example use case by Crystal Beasley.
Demo
Next Steps and Questions
Installation
This can be installed as an add-on for FirefoxOS.
Now run b2g with this profile.
To run the server to receive contacts updates:
Contacts Data Structure and API Notes
mozContactsAPI Overviewnavigator.mozContactsprovides an asynchronous interface for working with contacts, which are stored in the browser using IndexDB. The FxOS Contacts app uses this API. The API includes:save(contact)find(options)remove(record)clear()getSimContacts(contactType)Each of these function returns a
requestobject. The caller should registeronsuccessandonerrorcallbacks on this object; these will be called with results when the request succeeds or fails.A successful
findrequest will point to a list of json result objects withrequest.result. So you can queryrequest.result.length, etc. For example:The ContactManager messages with the ContactService (using cpmm and ppmm message managers respectively); the ContactService interacts with the ContactDB, which is an IndexedDBHelper.
The ContactManager uses the PermissionPromptHelper to request permission to perform any of these actions. These modules are all to be found in gecko
dom/contacts.MDN has documentation for IndexedDB.