Skip to content

Commit

Permalink
Tweaked minor changes to contacts API, lined up JS API to closer to m…
Browse files Browse the repository at this point in the history
…obile spec.
  • Loading branch information
Fil Maj committed Nov 27, 2009
1 parent a51aa5a commit 5c0d306
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.');";

Expand Down
22 changes: 11 additions & 11 deletions blackberry/framework/src/www/phonegap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -203,32 +203,32 @@ 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);
this.search_onSuccess = successCallback;
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;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions blackberry/js/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
124 changes: 62 additions & 62 deletions symbian.wrt/www/js/phonegap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5c0d306

Please sign in to comment.