/* * PhoneGap is available under *either* the terms of the modified BSD license *or* the * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. * * Copyright (c) 2005-2010, Nitobi Software Inc. * Copyright (c) 2010, IBM Corporation */ /** * 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} published date contact was first created * @param {DOMString} updated date contact was last updated * @param {DOMString} birthday contact's birthday * @param (DOMString} anniversary contact's anniversary * @param {DOMString} gender contact's gender * @param {DOMString} note user notes about contact * @param {DOMString} preferredUsername * @param {ContactField[]} photos * @param {ContactField[]} tags * @param {ContactField[]} relationships * @param {ContactField[]} urls contact's web sites * @param {ContactAccounts[]} accounts contact's online accounts * @param {DOMString} utcOffset UTC time zone offset * @param {DOMString} connected */ var Contact = function(id, displayName, name, nickname, phoneNumbers, emails, addresses, ims, organizations, published, updated, birthday, anniversary, gender, note, preferredUsername, photos, tags, relationships, urls, accounts, utcOffset, connected) { this.id = id || null; this.rawId = 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.published = published || null; this.updated = updated || null; this.birthday = birthday || null; this.anniversary = anniversary || null; this.gender = gender || null; this.note = note || null; this.preferredUsername = preferredUsername || null; this.photos = photos || null; // ContactField[] this.tags = tags || null; // ContactField[] this.relationships = relationships || null; // ContactField[] this.urls = urls || null; // ContactField[] this.accounts = accounts || null; // ContactAccount[] this.utcOffset = utcOffset || null; this.connected = connected || null; }; /** * Removes contact from device storage. * @param successCB success callback * @param errorCB error callback */ Contact.prototype.remove = function(successCB, errorCB) { if (this.id == null) { var errorObj = new ContactError(); errorObj.code = ContactError.NOT_FOUND_ERROR; errorCB(errorObj); } else { PhoneGap.exec(successCB, errorCB, "Contacts", "remove", [this.id]); } }; /** * 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 = PhoneGap.clone(this); clonedContact.id = null; clonedContact.rawId = null; // Loop through and clear out any id's in phones, emails, etc. if (clonedContact.phoneNumbers) { for (i=0; i