# HG changeset patch # User Eugene Ostroukhov # Date 1272367477 -3600 # Node ID b99b8311285cfd6abbd64b6b2b9f8f93cb42ac6e # Parent 147e1da954194ceabe5450686fce4157e5c6948e PhoneGap library was updated diff -r 147e1da95419 -r b99b8311285c org.symbian.tools.wrttools.product/launch/WRT IDE Product (Mac OS X).launch --- a/org.symbian.tools.wrttools.product/launch/WRT IDE Product (Mac OS X).launch Fri Apr 23 17:08:33 2010 -0700 +++ b/org.symbian.tools.wrttools.product/launch/WRT IDE Product (Mac OS X).launch Tue Apr 27 12:24:37 2010 +0100 @@ -21,8 +21,8 @@ - - + + diff -r 147e1da95419 -r b99b8311285c org.symbian.tools.wrttools/libraries/phonegap.js --- a/org.symbian.tools.wrttools/libraries/phonegap.js Fri Apr 23 17:08:33 2010 -0700 +++ b/org.symbian.tools.wrttools/libraries/phonegap.js Tue Apr 27 12:24:37 2010 +0100 @@ -103,7 +103,6 @@ // If the acceleration is not available then call error try { - alert(1); if (!this.serviceObj) this.serviceObj = this.getServiceObj(); @@ -118,7 +117,6 @@ SearchCriterion: "AccelerometerAxis" }; var returnvalue = this.serviceObj.ISensor.FindSensorChannel(SensorParams); - alert(2); var error = returnvalue["ErrorCode"]; var errmsg = returnvalue["ErrorMessage"]; if (!(error == 0 || error == 1012)) { @@ -150,7 +148,6 @@ // http://discussion.forum.nokia.com/forum/showthread.php?t=182151&highlight=memory+leak this.serviceObj.ISensor.RegisterForNotification(criteria, function(transId, eventCode, result){ try { - alert(10); var criteria = { TransactionID: transId }; @@ -168,9 +165,7 @@ } }); - alert(4); } catch (ex) { - alert(5); errorCallback(ex); } @@ -220,6 +215,42 @@ }; if (typeof navigator.accelerometer == "undefined") navigator.accelerometer = new Accelerometer();/** + * This class provides access to the device media, interfaces to both sound and video + * @constructor + */ +function Audio(src, successCallback, errorCallback) { + this.src = src; + this.successCallback = successCallback; + this.errorCallback = errorCallback; +} + +Audio.prototype.record = function() { +}; + +Audio.prototype.play = function() { +try { + if (document.getElementById('gapsound')) + document.body.removeChild(document.getElementById('gapsound')); + var obj; + obj = document.createElement("embed"); + obj.setAttribute("id", "gapsound"); + obj.setAttribute("type", "audio/x-mpeg"); + obj.setAttribute("width", "0"); + obj.setAttribute("width", "0"); + obj.setAttribute("hidden", "true"); + obj.setAttribute("autostart", "true"); + obj.setAttribute("src", this.src); + document.body.appendChild(obj); +} catch (ex) { debug.log(ex.name + ": " + ex.message); } +}; + +Audio.prototype.pause = function() { +}; + +Audio.prototype.stop = function() { + document.body.removeChild(document.getElementById('gapsound')); +}; +/** * This class provides access to the device camera. * @constructor */ @@ -1014,7 +1045,7 @@ var gapContact = new Contact(); gapContact.name.givenName = Contacts.GetValue(contact, "FirstName"); gapContact.name.familyName = Contacts.GetValue(contact, "LastName"); - gapContact.name.formatted = gapContact.firstName + " " + gapContact.lastName; + gapContact.name.formatted = gapContact.name.givenName + " " + gapContact.name.familyName; gapContact.emails = Contacts.getEmailsList(contact); gapContact.phones = Contacts.getPhonesList(contact); gapContact.address = Contacts.getAddress(contact); @@ -1077,6 +1108,38 @@ }; if (typeof navigator.contacts == "undefined") navigator.contacts = new Contacts(); +/** + * This class provides access to the debugging console. + * @constructor + */ +function DebugConsole() { +} + +/** + * Print a normal log message to the console + * @param {Object|String} message Message or object to print to the console + */ +DebugConsole.prototype.log = function(message) { + + //This ends up in C:\jslog_widget.log on the device + console.log(message); +}; + +/** + * Print a warning message to the console + * @param {Object|String} message Message or object to print to the console + */ +DebugConsole.prototype.warn = function(message) { +}; + +/** + * Print an error message to the console + * @param {Object|String} message Message or object to print to the console + */ +DebugConsole.prototype.error = function(message) { +}; + +if (typeof window.debug == "undefined") window.debug = new DebugConsole(); PhoneGap.ExtendWrtDeviceObj = function(){ if (!window.device) @@ -1267,41 +1330,26 @@ if (typeof navigator.geolocation == "undefined") navigator.geolocation = new Geolocation(); /** - * This class provides access to the device media, interfaces to both sound and video - * @constructor + * This class provides access to native mapping applications on the device. */ -function Media(src, successCallback, errorCallback) { - this.src = src; - this.successCallback = successCallback; - this.errorCallback = errorCallback; +function Map() { + } -Media.prototype.record = function() { +/** + * Shows a native map on the device with pins at the given positions. + * @param {Array} positions + */ +Map.prototype.show = function(positions) { + + var err = "map api is unimplemented on symbian.wrt"; + debug.log(err); + return { name: "MapError", message: err }; + }; -Media.prototype.play = function(src) { +if (typeof navigator.map == "undefined") navigator.map = new Map(); - if (document.getElementById('gapsound')) - document.body.removeChild(document.getElementById('gapsound')); - var obj; - obj = document.createElement("embed"); - obj.setAttribute("id", "gapsound"); - obj.setAttribute("type", "audio/x-mpeg"); - obj.setAttribute("width", "0"); - obj.setAttribute("width", "0"); - obj.setAttribute("hidden", "true"); - obj.setAttribute("autostart", "true"); - obj.setAttribute("src", src); - document.body.appendChild(obj); -}; - -Media.prototype.pause = function() { -}; - -Media.prototype.stop = function() { -}; - -if (typeof navigator.media == "undefined") navigator.media = new Media(); /** * This class provides access to notifications on the device. */ @@ -1462,15 +1510,27 @@ //create a closure to persist this instance of orientation object into the RegisterForNofication callback var obj = this; + // TODO: this call crashes WRT, but there is no other way to read the orientation sensor + // http://discussion.forum.nokia.com/forum/showthread.php?t=182151&highlight=memory+leak this.serviceObj.ISensor.RegisterForNotification(criteria, function(transId, eventCode, result){ - alert(1); var criteria = { TransactionID: transId }; try { - var orientation = result.ReturnValue.DeviceOrientation; + //var orientation = result.ReturnValue.DeviceOrientation; obj.serviceObj.ISensor.Cancel(criteria); + var orientation = null; + switch (result.ReturnValue.DeviceOrientation) { + case "DisplayUpwards": orientation = DisplayOrientation.FACE_UP; break; + case "DisplayDownwards": orientation = DisplayOrientation.FACE_DOWN; break; + case "DisplayUp": orientation = DisplayOrientation.PORTRAIT; break; + case "DisplayDown": orientation = DisplayOrientation.REVERSE_PORTRAIT; break; + case "DisplayRightUp": orientation = DisplayOrientation.LANDSCAPE_RIGHT_UP; break; + case "DisplayLeftUp": orientation = DisplayOrientation.LANDSCAPE_LEFT_UP; break; + + } + obj.setOrientation(orientation); obj.success_callback(orientation); @@ -1527,6 +1587,23 @@ return so; }; + +/** + * This class encapsulates the possible orientation values. + * @constructor + */ +function DisplayOrientation() { + this.code = null; + this.message = ""; +} + +DisplayOrientation.PORTRAIT = 0; +DisplayOrientation.REVERSE_PORTRAIT = 1; +DisplayOrientation.LANDSCAPE_LEFT_UP = 2; +DisplayOrientation.LANDSCAPE_RIGHT_UP = 3; +DisplayOrientation.FACE_UP = 4; +DisplayOrientation.FACE_DOWN = 5; + if (typeof navigator.orientation == "undefined") navigator.orientation = new Orientation(); /** * This class contains position information. @@ -1741,3 +1818,22 @@ }; if (typeof navigator.storage == "undefined" ) navigator.storage = new Storage(); +/** + * This class provides access to the telephony features of the device. + * @constructor + */ +function Telephony() { + this.number = ""; +} + +/** + * Calls the specifed number. + * @param {Integer} number The number to be called. + */ +Telephony.prototype.send = function(number) { + var err = "Telephony API not available for symbian.wrt"; + debug.log(err); + return { name: "TelephonyError", message: err }; +}; + +if (typeof navigator.telephony == "undefined") navigator.telephony = new Telephony(); \ No newline at end of file