/* * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ /** * Contains information about a single contact. * @param {DOMString} id unique identifier * @param {DOMString} displayName * @param {ContactName} name * @param {DOMString} nickname * @param {ContactField[]} phoneNumbers array of phone numbers * @param {ContactField[]} emails array of email addresses * @param {ContactAddress[]} addresses array of addresses * @param {ContactField[]} ims instant messaging user ids * @param {ContactOrganization[]} organizations * @param {DOMString} revision date contact was last updated * @param {DOMString} birthday contact's birthday * @param {DOMString} gender contact's gender * @param {DOMString} note user notes about contact * @param {ContactField[]} photos * @param {ContactField[]} urls contact's web sites * @param {DOMString} timezone UTC time zone offset */ var Contact = function(id, displayName, name, nickname, phoneNumbers, emails, addresses, ims, organizations, revision, birthday, gender, note, photos, categories, urls, timezone) { this.id = id || null; this.displayName = displayName || null; this.name = name || null; // ContactName this.nickname = nickname || null; this.phoneNumbers = phoneNumbers || null; // ContactField[] this.emails = emails || null; // ContactField[] this.addresses = addresses || null; // ContactAddress[] this.ims = ims || null; // ContactField[] this.organizations = organizations || null; // ContactOrganization[] this.revision = revision || null; // JS Date this.birthday = birthday || null; // JS Date this.gender = gender || null; this.note = note || null; this.photos = photos || null; // ContactField[] this.categories = categories || null; this.urls = urls || null; // ContactField[] this.timezone = timezone || null; }; /** * Removes contact from device storage. * @param successCB success callback * @param errorCB error callback (optional) */ Contact.prototype.remove = function(successCB, errorCB) { if (this.id == null) { var errorObj = new ContactError(); errorObj.code = ContactError.NOT_FOUND_ERROR; errorCB(errorObj); } else { Cordova.exec(successCB, errorCB, "org.apache.cordova.Contacts", "remove", [this.id]); } }; /** * Bada ONLY * displays contact via Bada Contact UI * * @param errorCB error callback */ Contact.prototype.display = function(successCB, errorCB, options) { if (this.id == null) { var errorObj = new ContactError(); errorObj.code = ContactError.NOT_FOUND_ERROR; errorCB(errorObj); } else { Cordova.exec(successCB, errorCB, "org.apache.cordova.Contacts","displayContact", [this.id, options]); } }; /** * Creates a deep copy of this Contact. * With the contact ID set to null. * @return copy of this Contact */ Contact.prototype.clone = function() { var clonedContact = Cordova.clone(this); clonedContact.id = null; // Loop through and clear out any id's in phones, emails, etc. if (clonedContact.phoneNumbers) { for (i=0; i