# HG changeset patch # User Eugene Ostroukhov # Date 1277146247 25200 # Node ID 41fb932132ea00e42a4afd3f9fe57b9d6947d85d # Parent 5a72e60dea8b2c0d0f5510048582a87f351debe2 Battery status snippet and system info code template diff -r 5a72e60dea8b -r 41fb932132ea org.symbian.tools.wrttools/plugin.xml --- a/org.symbian.tools.wrttools/plugin.xml Thu Jun 17 17:36:55 2010 -0700 +++ b/org.symbian.tools.wrttools/plugin.xml Mon Jun 21 11:50:47 2010 -0700 @@ -953,7 +953,7 @@ var phoneNumber = "+6505551214"; @@ -967,10 +967,43 @@ } + + + +function watchBatteryNotifications() { + var sysInfo = device.getServiceObject("Service.SysInfo", "ISysInfo"); + var result = sysInfo.ISysInfo.GetNotification( { + Entity : "Battery", + Key : "BatteryStrength" + }, batteryUpdated); + if (result.ErrorCode == 0) { + var transactionId = result.TransactionID; + // TODO Use this ID to cancel notifications + } else { + var message = result.ErrorMessage; + // TODO Process error + } +} + +function batteryUpdated(tId, code, result) { + if (result.ErrorCode == 0) { + var batteryStatus = result.ReturnValue.Status; + // TODO Process battery charge level + } else { + var message = result.ErrorMessage; + // TODO Process error + } +} + + // Call this function to add a callback that will be notified of orientation changes diff -r 5a72e60dea8b -r 41fb932132ea org.symbian.tools.wrttools/templates/default-templates.xml --- a/org.symbian.tools.wrttools/templates/default-templates.xml Thu Jun 17 17:36:55 2010 -0700 +++ b/org.symbian.tools.wrttools/templates/default-templates.xml Mon Jun 21 11:50:47 2010 -0700 @@ -66,5 +66,10 @@ enabled="true" autoinsert="false"> var ${sensors} = device.getServiceObject("Service.Sensor", "ISensor"); +