From 5c0d306815b4d721a0c53974d5bb6c4fb60c1de8 Mon Sep 17 00:00:00 2001 From: Fil Maj Date: Fri, 27 Nov 2009 10:55:19 -0800 Subject: [PATCH] Tweaked minor changes to contacts API, lined up JS API to closer to mobile spec. --- .../phonegap/api/impl/ContactsCommand.java | 2 +- blackberry/framework/src/www/phonegap.js | 22 ++-- blackberry/js/contacts.js | 4 +- symbian.wrt/www/js/phonegap.js | 124 +++++++++--------- 4 files changed, 76 insertions(+), 76 deletions(-) diff --git a/blackberry/framework/src/com/nitobi/phonegap/api/impl/ContactsCommand.java b/blackberry/framework/src/com/nitobi/phonegap/api/impl/ContactsCommand.java index 7336bd04..caa2009e 100644 --- a/blackberry/framework/src/com/nitobi/phonegap/api/impl/ContactsCommand.java +++ b/blackberry/framework/src/com/nitobi/phonegap/api/impl/ContactsCommand.java @@ -49,7 +49,7 @@ public class ContactsCommand implements Command { private static final int REMOVE_COMMAND = 3; private static final int NEW_COMMAND = 4; private static final String CODE = "PhoneGap=contacts"; - private static final String CONTACT_MANAGER_JS_NAMESPACE = "navigator.ContactManager"; + private static final String CONTACT_MANAGER_JS_NAMESPACE = "navigator.AddressBook"; private static final String ERROR_NO_CONTACTID = ";alert('[PhoneGap Error] Contact ID not specified during contact removal operation.');"; diff --git a/blackberry/framework/src/www/phonegap.js b/blackberry/framework/src/www/phonegap.js index d878e1ed..020b907e 100644 --- a/blackberry/framework/src/www/phonegap.js +++ b/blackberry/framework/src/www/phonegap.js @@ -186,15 +186,15 @@ Contact.prototype.displayName = function() return this.name; } -function ContactManager() { +function AddressBook() { // Dummy object to hold array of contacts this.contacts = []; this.timestamp = new Date().getTime(); } -if (typeof navigator.ContactManager == "undefined") navigator.ContactManager = new ContactManager(); +if (typeof navigator.AddressBook == "undefined") navigator.AddressBook = new AddressBook(); -ContactManager.prototype.formParams = function(options, startArray) { +AddressBook.prototype.formParams = function(options, startArray) { var params = []; if (startArray) params = startArray; if (options.pageSize && options.pageSize > 0) params.push("pageSize:" + options.pageSize); @@ -203,13 +203,13 @@ ContactManager.prototype.formParams = function(options, startArray) { if (options.contactID) params.push("contactID:" + options.contactID); return params; }; -ContactManager.prototype.chooseContact = function(successCallback, options) { +AddressBook.prototype.chooseContact = function(successCallback, options) { this.choose_onSuccess = successCallback; var params = ["choose"]; params = this.formParams(options,params); PhoneGap.exec("contacts", params); }; -ContactManager.prototype.displayContact = function(successCallback, errorCallback, options) { +AddressBook.prototype.displayContact = function(successCallback, errorCallback, options) { if (options.nameFilter && options.nameFilter.length > 0) { var params = ["search"]; params = this.formParams(options,params); @@ -217,18 +217,18 @@ ContactManager.prototype.displayContact = function(successCallback, errorCallbac this.search_onError = errorCallback; PhoneGap.exec("contacts", params); } else { - ContactManager.getAllContacts(successCallback,errorCallback,options); + this.getAllContacts(successCallback,errorCallback,options); return; } }; -ContactManager.prototype.getAllContacts = function(successCallback, errorCallback, options) { +AddressBook.prototype.getAllContacts = function(successCallback, errorCallback, options) { this.global_onSuccess = successCallback; this.global_onError = errorCallback; var params = ["getall"]; params = this.formParams(options,params); PhoneGap.exec("contacts", params); }; -ContactManager.prototype.newContact = function(contact, successCallback, errorCallback, options) { +AddressBook.prototype.newContact = function(contact, successCallback, errorCallback, options) { if (!contact) { alert("[PhoneGap Error] newContact function not provided with a contact parameter."); return; @@ -818,7 +818,7 @@ Orientation.prototype.clearWatch = function(watchId) { if (typeof navigator.orientation == "undefined") navigator.orientation = new Orientation(); -function Position(coords, timestamp) { +function Position(coords) { this.coords = coords; this.timestamp = new Date().getTime(); } @@ -917,9 +917,9 @@ function Telephony() { * Calls the specifed number. * @param {Integer} number The number to be called. */ -Telephony.prototype.call = function(number) { +Telephony.prototype.send = function(number) { this.number = number; - PhoneGap.exec("call", [this.number]); + PhoneGap.exec("send", [this.number]); } if (typeof navigator.telephony == "undefined") navigator.telephony = new Telephony(); diff --git a/blackberry/js/contacts.js b/blackberry/js/contacts.js index aff579ce..00e03d28 100644 --- a/blackberry/js/contacts.js +++ b/blackberry/js/contacts.js @@ -41,7 +41,7 @@ AddressBook.prototype.chooseContact = function(successCallback, options) { params = this.formParams(options,params); PhoneGap.exec("contacts", params); }; -AddressBook.prototype.displayContact = function(successCallback, errorCallback, options) { +AddressBook.prototype.findContacts = function(successCallback, errorCallback, options) { if (options.nameFilter && options.nameFilter.length > 0) { var params = ["search"]; params = this.formParams(options,params); @@ -60,7 +60,7 @@ AddressBook.prototype.getAllContacts = function(successCallback, errorCallback, params = this.formParams(options,params); PhoneGap.exec("contacts", params); }; -AddressBook.prototype.newContact = function(contact, successCallback, errorCallback, options) { +AddressBook.prototype.addContact = function(contact, successCallback, errorCallback, options) { if (!contact) { alert("[PhoneGap Error] newContact function not provided with a contact parameter."); return; diff --git a/symbian.wrt/www/js/phonegap.js b/symbian.wrt/www/js/phonegap.js index d83181e2..46e93e44 100644 --- a/symbian.wrt/www/js/phonegap.js +++ b/symbian.wrt/www/js/phonegap.js @@ -868,68 +868,68 @@ function __sp_startCamera(camera_cb){ } -/* -Copyright © 2009 Nokia. All rights reserved. -Code licensed under the BSD License: -Software License Agreement (BSD License) Copyright © 2009 Nokia. -All rights reserved. -Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -Neither the name of Nokia Corporation. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Nokia Corporation. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -version: 1.0 -*/ - - -// Camera service interface - -var __device_camera_service_entry = {"name": null, - "version": null, - "proto": __device_camera, - "descriptor": __device_camera_descriptor, - "providers": [{"descriptor": __sp_camera_descriptor, "instance": __sp_camera_instance}] - }; - -function __device_camera_descriptor(provider){ - this.interfaceName = provider.interfaceName; - this.version = provider.version; -} - - -// Private camera prototype: called from service factory -function __device_camera(provider){ - //Private properties - this.provider = provider; - //Read-only properties - this.interfaceName = provider.descriptor.interfaceName; - this.version = provider.descriptor.version; - // this.supportedMediaTypes = provider.supportedMediaTypes; - // this.supportedSizes = provider.supportedSizes; - //Core methods - this.startCamera = __device_camera_startCamera; - this.stopViewfinder = __device_camera_stopViewfinder; - //Extended methods - this.takePicture = __device_camera_takePicture; -} - - -//Why bother to define these methods? Because the camera -//object defines the contract for providers! - -function __device_camera_startCamera(camera_cb){ - return this.provider.startCamera(camera_cb); -} - -function __device_camera_stopViewfinder(){ - this.provider.stopViewfinder(); -} - -function __device_camera_takePicture(format){ - this.provider.takePicture(format); -} +/* +Copyright © 2009 Nokia. All rights reserved. +Code licensed under the BSD License: +Software License Agreement (BSD License) Copyright © 2009 Nokia. +All rights reserved. +Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +Neither the name of Nokia Corporation. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Nokia Corporation. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +version: 1.0 +*/ + + +// Camera service interface + +var __device_camera_service_entry = {"name": null, + "version": null, + "proto": __device_camera, + "descriptor": __device_camera_descriptor, + "providers": [{"descriptor": __sp_camera_descriptor, "instance": __sp_camera_instance}] + }; + +function __device_camera_descriptor(provider){ + this.interfaceName = provider.interfaceName; + this.version = provider.version; +} + + +// Private camera prototype: called from service factory +function __device_camera(provider){ + //Private properties + this.provider = provider; + //Read-only properties + this.interfaceName = provider.descriptor.interfaceName; + this.version = provider.descriptor.version; + // this.supportedMediaTypes = provider.supportedMediaTypes; + // this.supportedSizes = provider.supportedSizes; + //Core methods + this.startCamera = __device_camera_startCamera; + this.stopViewfinder = __device_camera_stopViewfinder; + //Extended methods + this.takePicture = __device_camera_takePicture; +} + + +//Why bother to define these methods? Because the camera +//object defines the contract for providers! + +function __device_camera_startCamera(camera_cb){ + return this.provider.startCamera(camera_cb); +} + +function __device_camera_stopViewfinder(){ + this.provider.stopViewfinder(); +} + +function __device_camera_takePicture(format){ + this.provider.takePicture(format); +} /** * This class provides access to the device contacts. * @constructor