Confirmed users
74
edits
(→Gmail) |
Mikedeboer (talk | contribs) m (spelling) |
||
(9 intermediate revisions by one other user not shown) | |||
Line 101: | Line 101: | ||
In order to avoid running into cross-origin issues in retrieving contacts, the retrieval will be performed in privileged code. This means that the [http://dxr.mozilla.org/mozilla-central/source/browser/components/loop/MozLoopAPI.jsm window.mozLoop API] will need new functions added to it in order to initiate contact import. | In order to avoid running into cross-origin issues in retrieving contacts, the retrieval will be performed in privileged code. This means that the [http://dxr.mozilla.org/mozilla-central/source/browser/components/loop/MozLoopAPI.jsm window.mozLoop API] will need new functions added to it in order to initiate contact import. | ||
See {{bug|972000}} for further information and a proof-of-concept patch. | |||
The function for starting an import will be of the form: | The function for starting an import will be of the form: | ||
function startImport(importId, serviceParameters, newContactCallback, | function startImport(importId, serviceParameters, newContactCallback, doneCallback) | ||
* '''importId''': A unique ID passed back to the caller in callbacks. This allows the caller to disambiguate between import operations in the case that there are multiple operations going on at the same time. | * '''importId''': A unique ID passed back to the caller in callbacks. This allows the caller to disambiguate between import operations in the case that there are multiple operations going on at the same time. | ||
* '''serviceParameters''': An object defining the service to import from. This must contain a "service" parameter. Certain services may require additional parameters. | * '''serviceParameters''': An object defining the service to import from. This must contain a "service" parameter. Certain services may require additional parameters (e.g., a generic CardDAV importer may require a username and password). | ||
* '''newContactCallback''': A callback of the form <tt>function(importId, contact, progress, total)</tt>, called whenever a new contact is imported. Note that this contact may already exist in the database (that is, it may already have an entry with a matching "id" field), in which case the new contact should ''replace'' the existing entry. | * '''newContactCallback''': A callback of the form <tt>function(importId, contact, progress, total)</tt>, called whenever a new contact is imported. Note that this contact may already exist in the database (that is, it may already have an entry with a matching "id" field), in which case the new contact should ''replace'' the existing entry. | ||
** ''importId'': The import ID passed in when startImport was called. | ** ''importId'': The import ID passed in when startImport was called. | ||
Line 113: | Line 115: | ||
** ''progress'': The number of contacts that have been imported from this operation | ** ''progress'': The number of contacts that have been imported from this operation | ||
** ''total'': The total number of contacts in this current import operation. Set to '-1' if unknown. | ** ''total'': The total number of contacts in this current import operation. Set to '-1' if unknown. | ||
* ''' | * '''doneCallback''': A callback of the form <tt>function(importId, error)</tt> | ||
** ''importId'': The import ID passed in when startImport was called. | ** ''importId'': The import ID passed in when startImport was called. | ||
** ''error'': | ** ''error'': If the import was successful, set to "null"; otherwise, an [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error Error] object with information about the failure. | ||
For example, importing gmail contacts would be initiated using something along the lines of: | For example, importing gmail contacts would be initiated using something along the lines of: | ||
window.mozLoop.startImport({service: "gmail"}, addContactToDatabase, | window.mozLoop.startImport(importId, {service: "gmail"}, addContactToDatabase, handleImportErrorOrCompletion); | ||
=== Local Contacts === | === Local Contacts === | ||
The [https://people.mozilla.org/~dhenein/labs/loop-mvp-spec/#contacts the Loop MVP UX spec] defines the experience for adding a user manually to the address book. This is currently intended to be a minimal set of data, populating only the following fields: | |||
* '''id''': UUID generated at the time the user is added | |||
* '''name[0]''': Text from user-entered "Name" field | |||
* '''email[0].value''': Text from user-entered "Email" field | |||
* '''email[0].type[0]''': set to "other" | |||
* '''email[0].pref''': set to true | |||
* '''phone[0].value''': Text from user-entered "Phone" field | |||
* '''phone[0].type[0]''': set to "other" | |||
* '''phone[0].pref''': set to true | |||
* '''category[0]''': set to "local" | |||
Currently, the plan is to leave the photo field blank for user-entered contacts; this may be revisited in the future (potentially leveraging Gravatar icons where appropriate). | |||
=== Gmail === | === Gmail === | ||
Line 201: | Line 216: | ||
== UX == | == UX == | ||
See [https://people.mozilla.org/~dhenein/labs/loop-mvp-spec/#contacts the Loop MVP UX spec] ''(Note: at the time of writing this, the contact import UX flow is not yet specified)'' | See [https://people.mozilla.org/~dhenein/labs/loop-mvp-spec/#contacts the Loop MVP UX spec] ''(Note: at the time of writing this, the contact import UX flow is not yet specified)'' | ||
The value of category[0] in each user record will be used to determine a couple of different aspects of user experience: | |||
# When set to "gmail", the "gmail" icon shown in the UX mock-ups will be displayed | |||
# When set to "local," the UX will allow selection of the contact for editing and deletion. |