Battery status snippet and system info code template
authorEugene Ostroukhov <eugeneo@symbian.org>
Mon, 21 Jun 2010 11:50:47 -0700
changeset 390 41fb932132ea
parent 389 5a72e60dea8b
child 391 62472296236e
Battery status snippet and system info code template
org.symbian.tools.wrttools/plugin.xml
org.symbian.tools.wrttools/templates/default-templates.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 @@
        <item
              class="org.symbian.tools.wrttools.util.SnippetInsertion"
              description="Sends SMS message"
-             id="org.symbian.tools.wrttools.contacts"
+             id="org.symbian.tools.wrttools.dial"
              label="Send SMS message">
           <content>
 var phoneNumber = "+6505551214";
@@ -967,10 +967,43 @@
 	}
           </content>
        </item>
+       
+       <item
+             class="org.symbian.tools.wrttools.util.SnippetInsertion"
+             description="Use this code to track battery status"
+             id="org.symbian.tools.wrttools.battery"
+             label="Watch battery status">
+          <content>
+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
+	}
+}
+          </content>
+       </item>
        <item
              class="org.symbian.tools.wrttools.util.SnippetInsertion"
              description="Use this code to track acceleration, orientation or rotation changes"
-             id="org.symbian.tools.wrttools.contacts"
+             id="org.symbian.tools.wrttools.sensor"
              label="Watch sensor notifications">
           <content>
 // Call this function to add a callback that will be notified of orientation changes
--- 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");
 	</template>
+	<template name="sensor" description="Access WRT 1.1 system information API. This API allows widgets to access system data like battery, connectivity, device, display, features, general, memory, network"
+		id="org.symbian.tools.wrttools.templates.sysinfo" context="javaScript"
+		enabled="true" autoinsert="false">
+		var ${sysInfo} = device.getServiceObject("Service.SysInfo", "ISysInfo");
+	</template>
 
 </templates>