Loop/Architecture/Address Book
Introduction
The main means by which users are expected to initiate Loop calls on desktop is via the "Address Book" sidebar, which will contain a list of the user's contacts. For the initial versions of Loop, contacts will can be populated from several sources, via a one-way synchronization (that is, the data will be imported from a remote authority and updated from that remote authority, but cannot be changed by the Loop client). A necessary implication of this setup is that all contacts will need to track which data source they belong to, and be updated only from those sources.
Format
To allow for future integration with the Contacts API and/or potential integration with contact synchronization across devices (including Firefox OS devices), we will use objects with properties having the same structure as those used by mozContact. In theory, to store these in the Contacts API database, all that would be required would be passing in the object as the argument to the mozContact constructor, and then storing it via navigator.mozContacts.save().
An example of this format is as follows; note that many of the fields are arrays of values rather than single values. Even though our importation will typically only populate these with a single value, we will be maintaining them as arrays to retain the properties described above.
{ "id": "23598", "published": "2014-07-02T15:25:32.000Z", "updated": "2014-07-09T19:46:28.000Z", "bday": "1972-07-19T05:00:00.000Z", "adr": [ { "countryName": "USA", "locality": "Dallas", "postalCode": "75201", "pref": true, "region": "TX", "streetAddress": "1234 Main St.", "type": [ "home" ] } ], "email": [ { "pref": true, "type": [ "work" ], "value": "adam@example.com" } ], "tel": [ { "pref": true, "type": [ "work" ], "value": "+12145551234" } ], "name": [ "Adam Roach" ], "honorificPrefix": [ "Mr." ], "givenName": [ "Adam" ], "additionalName": [ "Boyd" ], "familyName": [ "Roach" ], "honorificSuffix": [ "Jr." ], "category": [ "gmail" ], "org": [ "Mozilla" ], "jobTitle": [ "Principal Engineer" ], "note": [ "Likes Mexican food" ] }
We will be using the "category" field to keep track of the source from which the contact was imported. The remaining fields are derived from information retrieved during the importation process.
For the time being, we will not be using the following mozContacts fields:
- anniversary
- sex
- genderIdentity
- url
- impp
- phoneticGivenName
- phoneticGamilyName
- nickname
- key
Importing
Gmail
The current plan is to use the Google Contacts API, v3 to retrieve contacts from users' gmail accounts. Ideally, we can re-use some, most, or all of the Gaia Gmail Connector code to expedite this importation.