101 Accelerometer.prototype.getCurrentAcceleration = function(successCallback, errorCallback, options) { |
101 Accelerometer.prototype.getCurrentAcceleration = function(successCallback, errorCallback, options) { |
102 // If the acceleration is available then call success |
102 // If the acceleration is available then call success |
103 // If the acceleration is not available then call error |
103 // If the acceleration is not available then call error |
104 |
104 |
105 try { |
105 try { |
106 alert(1); |
|
107 if (!this.serviceObj) |
106 if (!this.serviceObj) |
108 this.serviceObj = this.getServiceObj(); |
107 this.serviceObj = this.getServiceObj(); |
109 |
108 |
110 if (this.serviceObj == null) |
109 if (this.serviceObj == null) |
111 throw { |
110 throw { |
116 //get the sensor channel |
115 //get the sensor channel |
117 var SensorParams = { |
116 var SensorParams = { |
118 SearchCriterion: "AccelerometerAxis" |
117 SearchCriterion: "AccelerometerAxis" |
119 }; |
118 }; |
120 var returnvalue = this.serviceObj.ISensor.FindSensorChannel(SensorParams); |
119 var returnvalue = this.serviceObj.ISensor.FindSensorChannel(SensorParams); |
121 alert(2); |
|
122 var error = returnvalue["ErrorCode"]; |
120 var error = returnvalue["ErrorCode"]; |
123 var errmsg = returnvalue["ErrorMessage"]; |
121 var errmsg = returnvalue["ErrorMessage"]; |
124 if (!(error == 0 || error == 1012)) { |
122 if (!(error == 0 || error == 1012)) { |
125 var ex = { |
123 var ex = { |
126 name: "Unable to find Sensor Channel: " + error, |
124 name: "Unable to find Sensor Channel: " + error, |
148 |
146 |
149 // TODO: this call crashes WRT, but there is no other way to read the accel sensor |
147 // TODO: this call crashes WRT, but there is no other way to read the accel sensor |
150 // http://discussion.forum.nokia.com/forum/showthread.php?t=182151&highlight=memory+leak |
148 // http://discussion.forum.nokia.com/forum/showthread.php?t=182151&highlight=memory+leak |
151 this.serviceObj.ISensor.RegisterForNotification(criteria, function(transId, eventCode, result){ |
149 this.serviceObj.ISensor.RegisterForNotification(criteria, function(transId, eventCode, result){ |
152 try { |
150 try { |
153 alert(10); |
|
154 var criteria = { |
151 var criteria = { |
155 TransactionID: transId |
152 TransactionID: transId |
156 }; |
153 }; |
157 obj.serviceObj.ISensor.Cancel(criteria); |
154 obj.serviceObj.ISensor.Cancel(criteria); |
158 |
155 |
218 } |
213 } |
219 return so; |
214 return so; |
220 }; |
215 }; |
221 |
216 |
222 if (typeof navigator.accelerometer == "undefined") navigator.accelerometer = new Accelerometer();/** |
217 if (typeof navigator.accelerometer == "undefined") navigator.accelerometer = new Accelerometer();/** |
|
218 * This class provides access to the device media, interfaces to both sound and video |
|
219 * @constructor |
|
220 */ |
|
221 function Audio(src, successCallback, errorCallback) { |
|
222 this.src = src; |
|
223 this.successCallback = successCallback; |
|
224 this.errorCallback = errorCallback; |
|
225 } |
|
226 |
|
227 Audio.prototype.record = function() { |
|
228 }; |
|
229 |
|
230 Audio.prototype.play = function() { |
|
231 try { |
|
232 if (document.getElementById('gapsound')) |
|
233 document.body.removeChild(document.getElementById('gapsound')); |
|
234 var obj; |
|
235 obj = document.createElement("embed"); |
|
236 obj.setAttribute("id", "gapsound"); |
|
237 obj.setAttribute("type", "audio/x-mpeg"); |
|
238 obj.setAttribute("width", "0"); |
|
239 obj.setAttribute("width", "0"); |
|
240 obj.setAttribute("hidden", "true"); |
|
241 obj.setAttribute("autostart", "true"); |
|
242 obj.setAttribute("src", this.src); |
|
243 document.body.appendChild(obj); |
|
244 } catch (ex) { debug.log(ex.name + ": " + ex.message); } |
|
245 }; |
|
246 |
|
247 Audio.prototype.pause = function() { |
|
248 }; |
|
249 |
|
250 Audio.prototype.stop = function() { |
|
251 document.body.removeChild(document.getElementById('gapsound')); |
|
252 }; |
|
253 /** |
223 * This class provides access to the device camera. |
254 * This class provides access to the device camera. |
224 * @constructor |
255 * @constructor |
225 */ |
256 */ |
226 function Camera() { |
257 function Camera() { |
227 this.success_callback = null; |
258 this.success_callback = null; |
1012 try { |
1043 try { |
1013 if (i >= start) { |
1044 if (i >= start) { |
1014 var gapContact = new Contact(); |
1045 var gapContact = new Contact(); |
1015 gapContact.name.givenName = Contacts.GetValue(contact, "FirstName"); |
1046 gapContact.name.givenName = Contacts.GetValue(contact, "FirstName"); |
1016 gapContact.name.familyName = Contacts.GetValue(contact, "LastName"); |
1047 gapContact.name.familyName = Contacts.GetValue(contact, "LastName"); |
1017 gapContact.name.formatted = gapContact.firstName + " " + gapContact.lastName; |
1048 gapContact.name.formatted = gapContact.name.givenName + " " + gapContact.name.familyName; |
1018 gapContact.emails = Contacts.getEmailsList(contact); |
1049 gapContact.emails = Contacts.getEmailsList(contact); |
1019 gapContact.phones = Contacts.getPhonesList(contact); |
1050 gapContact.phones = Contacts.getPhonesList(contact); |
1020 gapContact.address = Contacts.getAddress(contact); |
1051 gapContact.address = Contacts.getAddress(contact); |
1021 gapContact.id = Contacts.GetValue(contact, "id"); |
1052 gapContact.id = Contacts.GetValue(contact, "id"); |
1022 gapContacts.push(gapContact); |
1053 gapContacts.push(gapContact); |
1075 return ""; |
1106 return ""; |
1076 } |
1107 } |
1077 }; |
1108 }; |
1078 |
1109 |
1079 if (typeof navigator.contacts == "undefined") navigator.contacts = new Contacts(); |
1110 if (typeof navigator.contacts == "undefined") navigator.contacts = new Contacts(); |
|
1111 /** |
|
1112 * This class provides access to the debugging console. |
|
1113 * @constructor |
|
1114 */ |
|
1115 function DebugConsole() { |
|
1116 } |
|
1117 |
|
1118 /** |
|
1119 * Print a normal log message to the console |
|
1120 * @param {Object|String} message Message or object to print to the console |
|
1121 */ |
|
1122 DebugConsole.prototype.log = function(message) { |
|
1123 |
|
1124 //This ends up in C:\jslog_widget.log on the device |
|
1125 console.log(message); |
|
1126 }; |
|
1127 |
|
1128 /** |
|
1129 * Print a warning message to the console |
|
1130 * @param {Object|String} message Message or object to print to the console |
|
1131 */ |
|
1132 DebugConsole.prototype.warn = function(message) { |
|
1133 }; |
|
1134 |
|
1135 /** |
|
1136 * Print an error message to the console |
|
1137 * @param {Object|String} message Message or object to print to the console |
|
1138 */ |
|
1139 DebugConsole.prototype.error = function(message) { |
|
1140 }; |
|
1141 |
|
1142 if (typeof window.debug == "undefined") window.debug = new DebugConsole(); |
1080 PhoneGap.ExtendWrtDeviceObj = function(){ |
1143 PhoneGap.ExtendWrtDeviceObj = function(){ |
1081 |
1144 |
1082 if (!window.device) |
1145 if (!window.device) |
1083 window.device = {}; |
1146 window.device = {}; |
1084 navigator.device = window.device; |
1147 navigator.device = window.device; |
1265 |
1328 |
1266 |
1329 |
1267 if (typeof navigator.geolocation == "undefined") navigator.geolocation = new Geolocation(); |
1330 if (typeof navigator.geolocation == "undefined") navigator.geolocation = new Geolocation(); |
1268 |
1331 |
1269 /** |
1332 /** |
1270 * This class provides access to the device media, interfaces to both sound and video |
1333 * This class provides access to native mapping applications on the device. |
1271 * @constructor |
1334 */ |
1272 */ |
1335 function Map() { |
1273 function Media(src, successCallback, errorCallback) { |
1336 |
1274 this.src = src; |
1337 } |
1275 this.successCallback = successCallback; |
1338 |
1276 this.errorCallback = errorCallback; |
1339 /** |
1277 } |
1340 * Shows a native map on the device with pins at the given positions. |
1278 |
1341 * @param {Array} positions |
1279 Media.prototype.record = function() { |
1342 */ |
1280 }; |
1343 Map.prototype.show = function(positions) { |
1281 |
1344 |
1282 Media.prototype.play = function(src) { |
1345 var err = "map api is unimplemented on symbian.wrt"; |
1283 |
1346 debug.log(err); |
1284 if (document.getElementById('gapsound')) |
1347 return { name: "MapError", message: err }; |
1285 document.body.removeChild(document.getElementById('gapsound')); |
1348 |
1286 var obj; |
1349 }; |
1287 obj = document.createElement("embed"); |
1350 |
1288 obj.setAttribute("id", "gapsound"); |
1351 if (typeof navigator.map == "undefined") navigator.map = new Map(); |
1289 obj.setAttribute("type", "audio/x-mpeg"); |
1352 |
1290 obj.setAttribute("width", "0"); |
|
1291 obj.setAttribute("width", "0"); |
|
1292 obj.setAttribute("hidden", "true"); |
|
1293 obj.setAttribute("autostart", "true"); |
|
1294 obj.setAttribute("src", src); |
|
1295 document.body.appendChild(obj); |
|
1296 }; |
|
1297 |
|
1298 Media.prototype.pause = function() { |
|
1299 }; |
|
1300 |
|
1301 Media.prototype.stop = function() { |
|
1302 }; |
|
1303 |
|
1304 if (typeof navigator.media == "undefined") navigator.media = new Media(); |
|
1305 /** |
1353 /** |
1306 * This class provides access to notifications on the device. |
1354 * This class provides access to notifications on the device. |
1307 */ |
1355 */ |
1308 function Notification() { |
1356 function Notification() { |
1309 |
1357 |
1460 this.error_callback = errorCallback; |
1508 this.error_callback = errorCallback; |
1461 |
1509 |
1462 //create a closure to persist this instance of orientation object into the RegisterForNofication callback |
1510 //create a closure to persist this instance of orientation object into the RegisterForNofication callback |
1463 var obj = this; |
1511 var obj = this; |
1464 |
1512 |
|
1513 // TODO: this call crashes WRT, but there is no other way to read the orientation sensor |
|
1514 // http://discussion.forum.nokia.com/forum/showthread.php?t=182151&highlight=memory+leak |
1465 this.serviceObj.ISensor.RegisterForNotification(criteria, function(transId, eventCode, result){ |
1515 this.serviceObj.ISensor.RegisterForNotification(criteria, function(transId, eventCode, result){ |
1466 alert(1); |
|
1467 var criteria = { |
1516 var criteria = { |
1468 TransactionID: transId |
1517 TransactionID: transId |
1469 }; |
1518 }; |
1470 try { |
1519 try { |
1471 var orientation = result.ReturnValue.DeviceOrientation; |
1520 //var orientation = result.ReturnValue.DeviceOrientation; |
1472 obj.serviceObj.ISensor.Cancel(criteria); |
1521 obj.serviceObj.ISensor.Cancel(criteria); |
|
1522 |
|
1523 var orientation = null; |
|
1524 switch (result.ReturnValue.DeviceOrientation) { |
|
1525 case "DisplayUpwards": orientation = DisplayOrientation.FACE_UP; break; |
|
1526 case "DisplayDownwards": orientation = DisplayOrientation.FACE_DOWN; break; |
|
1527 case "DisplayUp": orientation = DisplayOrientation.PORTRAIT; break; |
|
1528 case "DisplayDown": orientation = DisplayOrientation.REVERSE_PORTRAIT; break; |
|
1529 case "DisplayRightUp": orientation = DisplayOrientation.LANDSCAPE_RIGHT_UP; break; |
|
1530 case "DisplayLeftUp": orientation = DisplayOrientation.LANDSCAPE_LEFT_UP; break; |
|
1531 |
|
1532 } |
1473 |
1533 |
1474 obj.setOrientation(orientation); |
1534 obj.setOrientation(orientation); |
1475 |
1535 |
1476 obj.success_callback(orientation); |
1536 obj.success_callback(orientation); |
1477 |
1537 |
1524 message: ex.name + ": " + ex.message |
1584 message: ex.name + ": " + ex.message |
1525 }; |
1585 }; |
1526 } |
1586 } |
1527 return so; |
1587 return so; |
1528 }; |
1588 }; |
|
1589 |
|
1590 |
|
1591 /** |
|
1592 * This class encapsulates the possible orientation values. |
|
1593 * @constructor |
|
1594 */ |
|
1595 function DisplayOrientation() { |
|
1596 this.code = null; |
|
1597 this.message = ""; |
|
1598 } |
|
1599 |
|
1600 DisplayOrientation.PORTRAIT = 0; |
|
1601 DisplayOrientation.REVERSE_PORTRAIT = 1; |
|
1602 DisplayOrientation.LANDSCAPE_LEFT_UP = 2; |
|
1603 DisplayOrientation.LANDSCAPE_RIGHT_UP = 3; |
|
1604 DisplayOrientation.FACE_UP = 4; |
|
1605 DisplayOrientation.FACE_DOWN = 5; |
1529 |
1606 |
1530 if (typeof navigator.orientation == "undefined") navigator.orientation = new Orientation(); |
1607 if (typeof navigator.orientation == "undefined") navigator.orientation = new Orientation(); |
1531 /** |
1608 /** |
1532 * This class contains position information. |
1609 * This class contains position information. |
1533 * @param {Object} lat |
1610 * @param {Object} lat |
1739 |
1816 |
1740 window.widget.setPreferenceForKey( "({" + json + "})", Storage.PREFERENCE_KEY); |
1817 window.widget.setPreferenceForKey( "({" + json + "})", Storage.PREFERENCE_KEY); |
1741 }; |
1818 }; |
1742 |
1819 |
1743 if (typeof navigator.storage == "undefined" ) navigator.storage = new Storage(); |
1820 if (typeof navigator.storage == "undefined" ) navigator.storage = new Storage(); |
|
1821 /** |
|
1822 * This class provides access to the telephony features of the device. |
|
1823 * @constructor |
|
1824 */ |
|
1825 function Telephony() { |
|
1826 this.number = ""; |
|
1827 } |
|
1828 |
|
1829 /** |
|
1830 * Calls the specifed number. |
|
1831 * @param {Integer} number The number to be called. |
|
1832 */ |
|
1833 Telephony.prototype.send = function(number) { |
|
1834 var err = "Telephony API not available for symbian.wrt"; |
|
1835 debug.log(err); |
|
1836 return { name: "TelephonyError", message: err }; |
|
1837 }; |
|
1838 |
|
1839 if (typeof navigator.telephony == "undefined") navigator.telephony = new Telephony(); |