org.symbian.tools.wrttools/plugin.xml
changeset 386 7d0a718a6346
parent 385 9bf326e3aeb9
child 387 53123b7b800d
equal deleted inserted replaced
385:9bf326e3aeb9 386:7d0a718a6346
   917 	}
   917 	}
   918           </content>
   918           </content>
   919        </item>
   919        </item>
   920        <item
   920        <item
   921              class="org.symbian.tools.wrttools.util.SnippetInsertion"
   921              class="org.symbian.tools.wrttools.util.SnippetInsertion"
   922              description="Sends SMS message"
       
   923              id="org.symbian.tools.wrttools.contacts"
       
   924              label="Send SMS message">
       
   925           <content>
       
   926 var phoneNumber = "+6505551214";
       
   927 	var text = "Sent from WRT application";
       
   928 	var messaging = device.getServiceObject("Service.Messaging", "IMessaging");
       
   929 	var result = messaging.IMessaging.Send({ MessageType : "SMS", To : phoneNumber, BodyText : text });
       
   930 	if (result.ErrorCode != null) {
       
   931 		var errorCode = result.ErrorCode;
       
   932 		var errorMessage = result.ErrorMessage;
       
   933 		// TODO Cannot send SMS message
       
   934 	}
       
   935           </content>
       
   936        </item>
       
   937        <item
       
   938              class="org.symbian.tools.wrttools.util.SnippetInsertion"
       
   939              description="Adds callback that will be notified of orientation chnages"
       
   940              id="org.symbian.tools.wrttools.contacts"
       
   941              label="Register orientation callback">
       
   942           <content>
       
   943 var sensors = device.getServiceObject("Service.Sensor", "ISensor");
       
   944 	var SensorParams = {
       
   945 		SearchCriterion : "Orientation"
       
   946 	};
       
   947 	var result = sensors.ISensor.FindSensorChannel(SensorParams);
       
   948 
       
   949 	if (result.ErrorCode == 0) {
       
   950 	    // TODO Function named "orientationCallback" will be called when device orientation changes. This function should be created. 
       
   951 		var result2 = sensors.ISensor.RegisterForNotification({ ChannelInfoMap : result.ReturnValue[0], ListeningType : "ChannelData" }, orientationCallback);
       
   952 		if (result.ErrorCode == 0) {
       
   953 			var transactionId = result.TransactionID;
       
   954 			// TODO Use this transaction ID to cancel notifications when watching orientation is no longer needed
       
   955 		} else {
       
   956 			var errorCode = result.ErrorCode;
       
   957 			var errorMessage = result.ErrorMessage;
       
   958 			// TODO Handle error
       
   959 		}
       
   960 	} else {
       
   961 		var errorCode = result.ErrorCode;
       
   962 		var errorMessage = result.ErrorMessage;
       
   963 		// TODO Handle error
       
   964 	}
       
   965          </content>
       
   966        </item>
       
   967        <item
       
   968              class="org.symbian.tools.wrttools.util.SnippetInsertion"
       
   969              description="This function can be used as a callback in GetLocation and Trace calls to location service."
   922              description="This function can be used as a callback in GetLocation and Trace calls to location service."
   970              id="org.symbian.tools.wrttools.location"
   923              id="org.symbian.tools.wrttools.location"
   971              label="Location callback">
   924              label="Location callback">
   972           <content>
   925           <content>
   973 // This function can be passed as a callback to locationService.ILocation
   926 // This function can be passed as a callback to locationService.ILocation
   997 	}
   950 	}
   998 }          </content>
   951 }          </content>
   999        </item>
   952        </item>
  1000        <item
   953        <item
  1001              class="org.symbian.tools.wrttools.util.SnippetInsertion"
   954              class="org.symbian.tools.wrttools.util.SnippetInsertion"
  1002              description="Function that processes notifications from the orientation sensor"
   955              description="Sends SMS message"
  1003              id="org.symbian.tools.wrttools.contacts"
   956              id="org.symbian.tools.wrttools.contacts"
  1004              label="Orientation callback">
   957              label="Send SMS message">
  1005           <content>
   958           <content>
  1006 // This function can be passed as callback to locationService.ILocation.GetLocation 
   959 var phoneNumber = "+6505551214";
  1007 // or locationService.ILocation.Trace method
   960 	var text = "Sent from WRT application";
  1008 function orientationCallback(transactionId, code, result) {
   961 	var messaging = device.getServiceObject("Service.Messaging", "IMessaging");
       
   962 	var result = messaging.IMessaging.Send({ MessageType : "SMS", To : phoneNumber, BodyText : text });
       
   963 	if (result.ErrorCode != null) {
       
   964 		var errorCode = result.ErrorCode;
       
   965 		var errorMessage = result.ErrorMessage;
       
   966 		// TODO Cannot send SMS message
       
   967 	}
       
   968           </content>
       
   969        </item>
       
   970        <item
       
   971              class="org.symbian.tools.wrttools.util.SnippetInsertion"
       
   972              description="Function that processes notifications from the sensors"
       
   973              id="org.symbian.tools.wrttools.contacts"
       
   974              label="Sensor callback">
       
   975           <content>
       
   976 // This function can be passed as callback to 
       
   977 // sensors.ISensor.RegisterForNotification method
       
   978 function sensorCallback(transactionId, code, result) {
  1009 	if (result.ErrorCode == 0) {
   979 	if (result.ErrorCode == 0) {
  1010 		var orientation = result.ReturnValue.DeviceOrientation;
   980 		// TODO Process notification
  1011 		// TODO Possible values:
   981 		var dataType = result.ReturnValue.DataType; // One of: "AxisData", "DoubleTappingData", "OrientationData" or "RotationData"
  1012 		// "Undefined"
   982 		// var xAxis = result.ReturnValue.XAxisData; // Accelerometer
  1013 		// "DisplayUp"
   983 		// var yAxis = result.ReturnValue.YAxisData; // Accelerometer
  1014 		// "DisplayDown"
   984 		// var zAxis = result.ReturnValue.ZAxisData; // Accelerometer
  1015 		// "DisplayLeftUp"
   985 		// var direction = result.ReturnValue.DeviceDirection; // Accelerometer double tapping
  1016 		// "DisplayRightUp"
   986 		// var orientation = result.ReturnValue.DeviceOrientation; // Orientation
  1017 		// "DisplayUpwards"
   987 		// var xRotation = result.ReturnValue.XRotation; // Rotation
  1018 		// "DisplayDownwards"
   988 		// var yRotation = result.ReturnValue.YRotation; // Rotation
       
   989 		// var zRotation = result.ReturnValue.ZRotation; // Rotation
  1019 	} else {
   990 	} else {
  1020 		var errorCode = result.ErrorCode;
   991 		var errorCode = result.ErrorCode;
  1021 		var errorMessage = result.ErrorMessage;
   992 		var errorMessage = result.ErrorMessage;
  1022 		// TODO Handle error
   993 		// TODO Handle error
       
   994 	}
       
   995 }
       
   996          </content>
       
   997        </item>
       
   998        <item
       
   999              class="org.symbian.tools.wrttools.util.SnippetInsertion"
       
  1000              description="Use this method to track acceleration, orientation or rotation changes"
       
  1001              id="org.symbian.tools.wrttools.contacts"
       
  1002              label="Watch sensor notifications">
       
  1003           <content>
       
  1004 // Call this function to add a callback that will be notified of orientation changes
       
  1005 function watchSensorNotifications(sensorCallback) {
       
  1006 	var sensors = device.getServiceObject("Service.Sensor", "ISensor");
       
  1007 	var SensorParams = {
       
  1008 		SearchCriterion : "Orientation" // TODO Possible values (one of):
       
  1009 			// SearchCriterion : "All"
       
  1010 			// SearchCriterion : "AccelerometerAxis"
       
  1011 			// SearchCriterion : "AccelerometerDoubleTapping"
       
  1012 			// SearchCriterion : "Rotation"
       
  1013 	};
       
  1014 	var result = sensors.ISensor.FindSensorChannel(SensorParams);
       
  1015 
       
  1016 	if (result.ErrorCode != 0) {
       
  1017 		var errorCode = result.ErrorCode;
       
  1018 		var errorMessage = result.ErrorMessage;
       
  1019 		// TODO Handle error
       
  1020 		return null;
       
  1021 	}
       
  1022     // TODO Function named "orientationCallback" will be called when device orientation changes. This function should be created. 
       
  1023 	var result2 = sensors.ISensor.RegisterForNotification(
       
  1024 			{ ChannelInfoMap : result.ReturnValue[0], 
       
  1025 				ListeningType : "ChannelData" }, sensorCallback);
       
  1026 	if (result.ErrorCode == 0) {
       
  1027 		var transactionId = result.TransactionID;
       
  1028 		// TODO Use this transaction ID to cancel notifications when watching orientation is no longer needed
       
  1029 		return transactionId;
       
  1030 	} else {
       
  1031 		var errorCode = result.ErrorCode;
       
  1032 		var errorMessage = result.ErrorMessage;
       
  1033 		// TODO Handle error
       
  1034 		return null;
  1023 	}
  1035 	}
  1024 }
  1036 }
  1025          </content>
  1037          </content>
  1026        </item>
  1038        </item>
  1027     </category>
  1039     </category>