You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/07/27 02:29:17 UTC

[76/78] [abbrv] [partial] added platform specs and basic work

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/244fae11/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/BaseCommand.cs
----------------------------------------------------------------------
diff --git a/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/BaseCommand.cs b/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/BaseCommand.cs
deleted file mode 100755
index c2af744..0000000
--- a/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/BaseCommand.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-/*  
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-*/
-
-using System;
-using System.Reflection;
-using Microsoft.Phone.Shell;
-using System.Diagnostics;
-
-namespace WP7CordovaClassLib.Cordova.Commands
-{
-    public abstract class BaseCommand : IDisposable
-    {
-        /*
-         *  All commands + plugins must extend BaseCommand, because they are dealt with as BaseCommands in PGView.xaml.cs
-         *  
-         **/
-
-        public event EventHandler<PluginResult> OnCommandResult;
-
-        public event EventHandler<ScriptCallback> OnCustomScript;
-
-        public BaseCommand()
-        {
-                PhoneApplicationService service = PhoneApplicationService.Current;
-                service.Activated += this.OnResume;                
-                service.Deactivated += this.OnPause;                
-        }
-
-        /*
-         *  InvokeMethodNamed will call the named method of a BaseCommand subclass if it exists and pass the variable arguments list along.
-         **/
-
-        public object InvokeMethodNamed(string methodName, params object[] args)
-        {
-            MethodInfo mInfo = this.GetType().GetMethod(methodName);
-
-            if (mInfo != null)
-            {
-                // every function handles DispatchCommandResult by itself
-                return mInfo.Invoke(this, args);
-            }
-
-            // actually methodName could refer to a property
-            if (args == null || args.Length == 0 ||
-               (args.Length == 1 && "undefined".Equals(args[0])))
-            {
-                PropertyInfo pInfo = this.GetType().GetProperty(methodName);
-                if (pInfo != null)
-                {
-                    
-                    object res = pInfo.GetValue(this , null);
-
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.OK, res));
-                    
-                    return res;
-                }
-            }
-
-            throw new MissingMethodException(methodName);            
-
-        }
-
-
-        public void InvokeCustomScript(ScriptCallback script)
-        {
-            if (this.OnCustomScript != null)
-            {
-                this.OnCustomScript(this, script);
-                this.OnCustomScript = null;
-            }
-        }
-
-        public void DispatchCommandResult()
-        {
-            this.DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT));
-        }
-
-        public void DispatchCommandResult(PluginResult result)
-        {
-            if (this.OnCommandResult != null)
-            {
-                this.OnCommandResult(this, result);
-
-                if (!result.KeepCallback)
-                {
-                    this.Dispose();
-                }
-
-            }
-        }
-
-        /// <summary>
-        /// Occurs when the application is being deactivated.
-        /// </summary>        
-        public virtual void OnPause(object sender, DeactivatedEventArgs e)
-        {
-        }
-
-        /// <summary>
-        /// Occurs when the application is being made active after previously being put
-        /// into a dormant state or tombstoned.
-        /// </summary>        
-        public virtual void OnResume(object sender, Microsoft.Phone.Shell.ActivatedEventArgs e)
-        {
-        }
-        
-        public void Dispose()
-        {
-            PhoneApplicationService service = PhoneApplicationService.Current;
-            service.Activated -= this.OnResume;
-            service.Deactivated -= this.OnPause;
-            this.OnCommandResult = null;
-        }
-    }
-
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/244fae11/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Battery.cs
----------------------------------------------------------------------
diff --git a/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Battery.cs b/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Battery.cs
deleted file mode 100755
index f027c0f..0000000
--- a/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Battery.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-/*  
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-*/
-
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-
-using Microsoft.Phone.Info;
-
-namespace WP7CordovaClassLib.Cordova.Commands
-{
-    /// <summary>
-    /// Listens for changes to the state of the battery on the device.
-    /// Currently only the "isPlugged" parameter available via native APIs.
-    /// </summary>
-    public class Battery : BaseCommand
-    {
-        private bool isPlugged = false;
-        private EventHandler powerChanged;
-
-        public Battery()
-        {
-            powerChanged = new EventHandler(DeviceStatus_PowerSourceChanged);
-            isPlugged = DeviceStatus.PowerSource.ToString().CompareTo("External") == 0;
-        }
-
-        public void start(string options)
-        {
-            // Register power changed event handler
-            DeviceStatus.PowerSourceChanged += powerChanged;
-
-            PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
-            result.KeepCallback = true;
-            DispatchCommandResult(result);
-        }
-        public void stop(string options)
-        {
-            // Unregister power changed event handler
-            DeviceStatus.PowerSourceChanged -= powerChanged;
-        }
-
-        private void DeviceStatus_PowerSourceChanged(object sender, EventArgs e)
-        {
-            isPlugged = DeviceStatus.PowerSource.ToString().CompareTo("External") == 0;
-            PluginResult result = new PluginResult(PluginResult.Status.OK, GetCurrentBatteryStateFormatted());
-            result.KeepCallback = true;
-            DispatchCommandResult(result);
-        }
-
-        private string GetCurrentBatteryStateFormatted()
-        {
-            string batteryState = String.Format("\"level\":{0},\"isPlugged\":{1}",
-                                                    "null",
-                                                    isPlugged ? "true" : "false"
-                            );
-            batteryState = "{" + batteryState + "}";
-            return batteryState;
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/244fae11/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Camera.cs
----------------------------------------------------------------------
diff --git a/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Camera.cs b/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Camera.cs
deleted file mode 100755
index 6620dd4..0000000
--- a/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Camera.cs
+++ /dev/null
@@ -1,435 +0,0 @@
-/*  
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-*/
-
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Collections.Generic;
-using Microsoft.Phone.Tasks;
-using System.Runtime.Serialization;
-using System.IO;
-using System.IO.IsolatedStorage;
-using System.Windows.Media.Imaging;
-using Microsoft.Phone;
-using Microsoft.Xna.Framework.Media;
-using System.Diagnostics;
-
-namespace WP7CordovaClassLib.Cordova.Commands
-{
-    public class Camera : BaseCommand
-    {
-
-        /// <summary>
-        /// Return base64 encoded string
-        /// </summary>
-        private const int DATA_URL = 0;
-
-        /// <summary>
-        /// Return file uri
-        /// </summary>
-        private const int FILE_URI = 1;
-
-        /// <summary>
-        /// Choose image from picture library
-        /// </summary>
-        private const int PHOTOLIBRARY = 0;
-
-        /// <summary>
-        /// Take picture from camera
-        /// </summary>
-
-        private const int CAMERA = 1;
-
-        /// <summary>
-        /// Choose image from picture library
-        /// </summary>
-        private const int SAVEDPHOTOALBUM = 2;
-
-        /// <summary>
-        /// Take a picture of type JPEG
-        /// </summary>
-        private const int JPEG = 0;
-
-        /// <summary>
-        /// Take a picture of type PNG
-        /// </summary>
-        private const int PNG = 1;
-
-        /// <summary>
-        /// Folder to store captured images
-        /// </summary>
-        private const string isoFolder = "CapturedImagesCache";
-
-        /// <summary>
-        /// Represents captureImage action options.
-        /// </summary>
-        [DataContract]
-        public class CameraOptions
-        {
-            /// <summary>
-            /// Source to getPicture from.
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "sourceType")]
-            public int PictureSourceType { get; set; }
-
-            /// <summary>
-            /// Format of image that returned from getPicture.
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "destinationType")]
-            public int DestinationType { get; set; }
-
-            /// <summary>
-            /// Quality of saved image
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "quality")]
-            public int Quality { get; set; }
-
-
-            /// <summary>
-            /// Height in pixels to scale image
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "targetHeight")]
-            public int TargetHeight { get; set; }
-
-            /// <summary>
-            /// Width in pixels to scale image
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "targetWidth")]
-            public int TargetWidth { get; set; }
-
-            /// <summary>
-            /// Creates options object with default parameters
-            /// </summary>
-            public CameraOptions()
-            {
-                this.SetDefaultValues(new StreamingContext());
-            }
-
-            /// <summary>
-            /// Initializes default values for class fields.
-            /// Implemented in separate method because default constructor is not invoked during deserialization.
-            /// </summary>
-            /// <param name="context"></param>
-            [OnDeserializing()]
-            public void SetDefaultValues(StreamingContext context)
-            {
-                PictureSourceType = CAMERA;
-                DestinationType = FILE_URI;
-                Quality = 80;
-                TargetHeight = -1;
-                TargetWidth = -1;
-            }
-
-        }
-
-        /// <summary>
-        /// Used to open photo library
-        /// </summary>
-        PhotoChooserTask photoChooserTask;
-
-        /// <summary>
-        /// Used to open camera application
-        /// </summary>
-        CameraCaptureTask cameraTask;
-
-        /// <summary>
-        /// Camera options
-        /// </summary>
-        CameraOptions cameraOptions;
-
-        public void takePicture(string options)
-        {
-            try
-            {
-                this.cameraOptions = String.IsNullOrEmpty(options) ?
-                        new CameraOptions() : JSON.JsonHelper.Deserialize<CameraOptions>(options);
-            }
-            catch (Exception ex)
-            {
-                this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
-                return;
-            }
-
-            //TODO Check if all the options are acceptable
-
-
-            if (cameraOptions.PictureSourceType == CAMERA)
-            {
-                cameraTask = new CameraCaptureTask();
-                cameraTask.Completed += onCameraTaskCompleted;
-                cameraTask.Show();
-            }
-            else
-            {
-                if ((cameraOptions.PictureSourceType == PHOTOLIBRARY) || (cameraOptions.PictureSourceType == SAVEDPHOTOALBUM))
-                {
-                    photoChooserTask = new PhotoChooserTask();
-                    photoChooserTask.Completed += onPickerTaskCompleted;
-                    photoChooserTask.Show();
-                }
-                else
-                {
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT));
-                }
-            }
-
-        }
-
-        public void onCameraTaskCompleted(object sender, PhotoResult e)
-        {
-            if (e.Error != null)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
-                return;
-            }
-
-            switch (e.TaskResult)
-            {
-                case TaskResult.OK:
-                    try
-                    {
-                        string imagePathOrContent = string.Empty;
-
-                        if (cameraOptions.DestinationType == FILE_URI)
-                        {
-                            // Save image in media library
-                            // MediaLibrary library = new MediaLibrary();
-                            // Picture pict = library.SavePicture(e.OriginalFileName, e.ChosenPhoto); // to save to photo-roll ...
-
-                            int orient = ImageExifHelper.getImageOrientationFromStream(e.ChosenPhoto);
-                            int newAngle = 0;
-                            switch (orient)
-                            {
-                                case ImageExifOrientation.LandscapeLeft:
-                                    newAngle = 90;
-                                    break;
-                                case ImageExifOrientation.PortraitUpsideDown:
-                                    newAngle = 180;
-                                    break;
-                                case ImageExifOrientation.LandscapeRight:
-                                    newAngle = 270;
-                                    break;
-                                case ImageExifOrientation.Portrait:
-                                default: break; // 0 default already set
-                            }
-
-                            Stream rotImageStream = ImageExifHelper.RotateStream(e.ChosenPhoto, newAngle);
-
-                            // we should return stream position back after saving stream to media library
-                            rotImageStream.Seek(0, SeekOrigin.Begin);
-
-                            WriteableBitmap image = PictureDecoder.DecodeJpeg(rotImageStream);
-
-                            imagePathOrContent = this.SaveImageToLocalStorage(image, Path.GetFileName(e.OriginalFileName));
-
-
-                        }
-                        else if (cameraOptions.DestinationType == DATA_URL)
-                        {
-                            imagePathOrContent = this.GetImageContent(e.ChosenPhoto);
-                        }
-                        else
-                        {
-                            // TODO: shouldn't this happen before we launch the camera-picker?
-                            DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Incorrect option: destinationType"));
-                            return;
-                        }
-
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, imagePathOrContent));
-
-                    }
-                    catch (Exception)
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error retrieving image."));
-                    }
-                    break;
-
-                case TaskResult.Cancel:
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection cancelled."));
-                    break;
-
-                default:
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection did not complete!"));
-                    break;
-            }
-
-        }
-
-        public void onPickerTaskCompleted(object sender, PhotoResult e)
-        {
-            if (e.Error != null)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
-                return;
-            }
-
-            switch (e.TaskResult)
-            {
-                case TaskResult.OK:
-                    try
-                    {
-                        string imagePathOrContent = string.Empty;
-
-                        if (cameraOptions.DestinationType == FILE_URI)
-                        {
-                            WriteableBitmap image = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
-                            imagePathOrContent = this.SaveImageToLocalStorage(image, Path.GetFileName(e.OriginalFileName));
-                        }
-                        else if (cameraOptions.DestinationType == DATA_URL)
-                        {
-                            imagePathOrContent = this.GetImageContent(e.ChosenPhoto);
-
-                        }
-                        else
-                        {
-                            // TODO: shouldn't this happen before we launch the camera-picker?
-                            DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Incorrect option: destinationType"));
-                            return;
-                        }
-
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, imagePathOrContent));
-
-                    }
-                    catch (Exception)
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error retrieving image."));
-                    }
-                    break;
-
-                case TaskResult.Cancel:
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection cancelled."));
-                    break;
-
-                default:
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection did not complete!"));
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Returns image content in a form of base64 string
-        /// </summary>
-        /// <param name="stream">Image stream</param>
-        /// <returns>Base64 representation of the image</returns>
-        private string GetImageContent(Stream stream)
-        {
-            int streamLength = (int)stream.Length;
-            byte[] fileData = new byte[streamLength + 1];
-            stream.Read(fileData, 0, streamLength);        
-
-            //use photo's actual width & height if user doesn't provide width & height
-            if (cameraOptions.TargetWidth < 0 && cameraOptions.TargetHeight < 0)
-            {
-                stream.Close();
-                return Convert.ToBase64String(fileData);                
-            }
-            else
-            {
-                // resize photo
-                byte[] resizedFile = ResizePhoto(stream, fileData);
-                stream.Close();
-                return Convert.ToBase64String(resizedFile);
-            }
-        }
-
-        /// <summary>
-        /// Resize image
-        /// </summary>
-        /// <param name="stream">Image stream</param>
-        /// <param name="fileData">File data</param>
-        /// <returns>resized image</returns>
-        private byte[] ResizePhoto(Stream stream, byte[] fileData)
-        {
-            int streamLength = (int)stream.Length;
-            int intResult = 0;
-
-            byte[] resizedFile;
-
-            stream.Read(fileData, 0, streamLength);
-
-            BitmapImage objBitmap = new BitmapImage();
-            MemoryStream objBitmapStream = new MemoryStream(fileData);
-            MemoryStream objBitmapStreamResized = new MemoryStream();
-            WriteableBitmap objWB;
-            objBitmap.SetSource(stream);
-            objWB = new WriteableBitmap(objBitmap);
-
-            // resize the photo with user defined TargetWidth & TargetHeight
-            Extensions.SaveJpeg(objWB, objBitmapStreamResized, cameraOptions.TargetWidth, cameraOptions.TargetHeight, 0, cameraOptions.Quality);
-
-            //Convert the resized stream to a byte array. 
-            streamLength = (int)objBitmapStreamResized.Length;
-            resizedFile = new Byte[streamLength]; //-1 
-            objBitmapStreamResized.Position = 0;
-            //for some reason we have to set Position to zero, but we don't have to earlier when we get the bytes from the chosen photo... 
-            intResult = objBitmapStreamResized.Read(resizedFile, 0, streamLength);
-
-            return resizedFile;
-        }
-        
-        /// <summary>
-        /// Saves captured image in isolated storage
-        /// </summary>
-        /// <param name="imageFileName">image file name</param>
-        /// <returns>Image path</returns>
-        private string SaveImageToLocalStorage(WriteableBitmap image, string imageFileName)
-        {
-
-            if (image == null)
-            {
-                throw new ArgumentNullException("imageBytes");
-            }
-            try
-            {
-
-
-                var isoFile = IsolatedStorageFile.GetUserStoreForApplication();
-
-                if (!isoFile.DirectoryExists(isoFolder))
-                {
-                    isoFile.CreateDirectory(isoFolder);
-                }
-
-                string filePath = System.IO.Path.Combine("/" + isoFolder + "/", imageFileName);
-
-                using (var stream = isoFile.CreateFile(filePath))
-                {
-                    // resize image if Height and Width defined via options 
-                    if (cameraOptions.TargetHeight > 0 && cameraOptions.TargetWidth > 0)
-                    {
-                        image.SaveJpeg(stream, cameraOptions.TargetWidth, cameraOptions.TargetHeight, 0, cameraOptions.Quality);
-                    }
-                    else
-                    {
-                        image.SaveJpeg(stream, image.PixelWidth, image.PixelHeight, 0, cameraOptions.Quality);
-                    }
-                }
-
-                return new Uri(filePath, UriKind.Relative).ToString();
-            }
-            catch (Exception)
-            {
-                //TODO: log or do something else
-                throw;
-            }
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/244fae11/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Capture.cs
----------------------------------------------------------------------
diff --git a/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Capture.cs b/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Capture.cs
deleted file mode 100755
index 25d22e3..0000000
--- a/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Capture.cs
+++ /dev/null
@@ -1,737 +0,0 @@
-/*  
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.IO.IsolatedStorage;
-using System.Runtime.Serialization;
-using System.Windows.Media.Imaging;
-using Microsoft.Phone;
-using Microsoft.Phone.Tasks;
-using Microsoft.Xna.Framework.Media;
-using WP7CordovaClassLib.Cordova.UI;
-using AudioResult = WP7CordovaClassLib.Cordova.UI.AudioCaptureTask.AudioResult;
-using VideoResult = WP7CordovaClassLib.Cordova.UI.VideoCaptureTask.VideoResult;
-using System.Windows;
-using System.Diagnostics;
-using Microsoft.Phone.Controls;
-
-namespace WP7CordovaClassLib.Cordova.Commands
-{
-    /// <summary>
-    /// Provides access to the audio, image, and video capture capabilities of the device
-    /// </summary>
-    public class Capture : BaseCommand
-    {
-        #region Internal classes (options and resultant objects)
-
-        /// <summary>
-        /// Represents captureImage action options.
-        /// </summary>
-        [DataContract]
-        public class CaptureImageOptions
-        {
-            /// <summary>
-            /// The maximum number of images the device user can capture in a single capture operation. The value must be greater than or equal to 1 (defaults to 1).
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "limit")]
-            public int Limit { get; set; }
-
-            public static CaptureImageOptions Default
-            {
-                get { return new CaptureImageOptions() { Limit = 1 }; }
-            }
-        }
-
-        /// <summary>
-        /// Represents captureAudio action options.
-        /// </summary>
-        [DataContract]
-        public class CaptureAudioOptions
-        {
-            /// <summary>
-            /// The maximum number of images the device user can capture in a single capture operation. The value must be greater than or equal to 1 (defaults to 1).
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "limit")]
-            public int Limit { get; set; }
-
-            public static CaptureAudioOptions Default
-            {
-                get { return new CaptureAudioOptions() { Limit = 1 }; }
-            }
-        }
-
-        /// <summary>
-        /// Represents captureVideo action options.
-        /// </summary>
-        [DataContract]
-        public class CaptureVideoOptions
-        {
-            /// <summary>
-            /// The maximum number of video files the device user can capture in a single capture operation. The value must be greater than or equal to 1 (defaults to 1).
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "limit")]
-            public int Limit { get; set; }
-
-            public static CaptureVideoOptions Default
-            {
-                get { return new CaptureVideoOptions() { Limit = 1 }; }
-            }
-        }
-
-        /// <summary>
-        /// Represents getFormatData action options.
-        /// </summary>
-        [DataContract]
-        public class MediaFormatOptions
-        {
-            /// <summary>
-            /// File path
-            /// </summary>
-            [DataMember(IsRequired = true, Name = "fullPath")]
-            public string FullPath { get; set; }
-
-            /// <summary>
-            /// File mime type
-            /// </summary>
-            [DataMember(Name = "type")]
-            public string Type { get; set; }
-
-        }
-
-        /// <summary>
-        /// Stores image info
-        /// </summary>
-        [DataContract]
-        public class MediaFile
-        {
-
-            [DataMember(Name = "name")]
-            public string FileName { get; set; }
-
-            [DataMember(Name = "fullPath")]
-            public string FilePath { get; set; }
-
-            [DataMember(Name = "type")]
-            public string Type { get; set; }
-
-            [DataMember(Name = "lastModifiedDate")]
-            public string LastModifiedDate { get; set; }
-
-            [DataMember(Name = "size")]
-            public long Size { get; set; }
-
-            public MediaFile(string filePath, Picture image)
-            {
-                this.FilePath = filePath;
-                this.FileName = System.IO.Path.GetFileName(this.FilePath);
-                this.Type = MimeTypeMapper.GetMimeType(FileName);
-                this.Size = image.GetImage().Length;
-
-                using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
-                {
-                    this.LastModifiedDate = storage.GetLastWriteTime(filePath).DateTime.ToString();
-                }
-
-            }
-
-            public MediaFile(string filePath, Stream stream)
-            {
-                this.FilePath = filePath;
-                this.FileName = System.IO.Path.GetFileName(this.FilePath);
-                this.Type = MimeTypeMapper.GetMimeType(FileName);
-                this.Size = stream.Length;
-
-                using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
-                {
-                    this.LastModifiedDate = storage.GetLastWriteTime(filePath).DateTime.ToString();
-                }
-            }
-        }
-
-        /// <summary>
-        /// Stores additional media file data
-        /// </summary>
-        [DataContract]
-        public class MediaFileData
-        {
-            [DataMember(Name = "height")]
-            public int Height { get; set; }
-
-            [DataMember(Name = "width")]
-            public int Width { get; set; }
-
-            [DataMember(Name = "bitrate")]
-            public int Bitrate { get; set; }
-
-            [DataMember(Name = "duration")]
-            public int Duration { get; set; }
-
-            [DataMember(Name = "codecs")]
-            public string Codecs { get; set; }
-
-            public MediaFileData(WriteableBitmap image)
-            {
-                this.Height = image.PixelHeight;
-                this.Width = image.PixelWidth;
-                this.Bitrate = 0;
-                this.Duration = 0;
-                this.Codecs = "";
-            }
-        }
-
-        #endregion
-
-        /// <summary>
-        /// Folder to store captured images
-        /// </summary>
-        private string isoFolder = "CapturedImagesCache";
-
-        /// <summary>
-        /// Capture Image options
-        /// </summary>
-        protected CaptureImageOptions captureImageOptions;
-
-        /// <summary>
-        /// Capture Audio options
-        /// </summary>
-        protected CaptureAudioOptions captureAudioOptions;
-
-        /// <summary>
-        /// Capture Video options
-        /// </summary>
-        protected CaptureVideoOptions captureVideoOptions;
-
-        /// <summary>
-        /// Used to open camera application
-        /// </summary>
-        private CameraCaptureTask cameraTask;
-
-        /// <summary>
-        /// Used for audio recording
-        /// </summary>
-        private AudioCaptureTask audioCaptureTask;
-
-        /// <summary>
-        /// Used for video recording
-        /// </summary>
-        private VideoCaptureTask videoCaptureTask;
-
-        /// <summary>
-        /// Stores information about captured files
-        /// </summary>
-        List<MediaFile> files = new List<MediaFile>();
-
-        /// <summary>
-        /// Launches default camera application to capture image
-        /// </summary>
-        /// <param name="options">may contains limit or mode parameters</param>
-        public void captureImage(string options)
-        {
-            try
-            {
-                try
-                {
-                    this.captureImageOptions = String.IsNullOrEmpty(options) ?
-                        CaptureImageOptions.Default : JSON.JsonHelper.Deserialize<CaptureImageOptions>(options);
-
-                }
-                catch (Exception ex)
-                {
-                    this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
-                    return;
-                }
-
-
-                cameraTask = new CameraCaptureTask();
-                cameraTask.Completed += this.cameraTask_Completed;
-                cameraTask.Show();
-            }
-            catch (Exception e)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
-            }
-        }
-
-        /// <summary>
-        /// Launches our own audio recording control to capture audio
-        /// </summary>
-        /// <param name="options">may contains additional parameters</param>
-        public void captureAudio(string options)
-        {
-            try
-            {
-                try
-                {
-                    this.captureAudioOptions = String.IsNullOrEmpty(options) ?
-                        CaptureAudioOptions.Default : JSON.JsonHelper.Deserialize<CaptureAudioOptions>(options);
-
-                }
-                catch (Exception ex)
-                {
-                    this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
-                    return;
-                }
-
-                audioCaptureTask = new AudioCaptureTask();
-                audioCaptureTask.Completed += audioRecordingTask_Completed;
-                audioCaptureTask.Show();
-
-            }
-            catch (Exception e)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
-            }
-        }
-
-        /// <summary>
-        /// Launches our own video recording control to capture video
-        /// </summary>
-        /// <param name="options">may contains additional parameters</param>
-        public void captureVideo(string options)
-        {
-            try
-            {
-                try
-                {
-                    this.captureVideoOptions = String.IsNullOrEmpty(options) ?
-                        CaptureVideoOptions.Default : JSON.JsonHelper.Deserialize<CaptureVideoOptions>(options);
-
-                }
-                catch (Exception ex)
-                {
-                    this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
-                    return;
-                }
-
-               videoCaptureTask = new VideoCaptureTask();
-               videoCaptureTask.Completed += videoRecordingTask_Completed;
-               videoCaptureTask.Show();
-
-            }
-            catch (Exception e)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
-            }
-        }
-
-        /// <summary>
-        /// Retrieves the format information of the media file.
-        /// </summary>
-        /// <param name="options"></param>
-        public void getFormatData(string options)
-        {
-            if (String.IsNullOrEmpty(options))
-            {
-                this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
-                return;
-            }
-
-            try
-            {
-                MediaFormatOptions mediaFormatOptions;
-                try
-                {
-                    mediaFormatOptions = JSON.JsonHelper.Deserialize<MediaFormatOptions>(options);
-                }
-                catch (Exception ex)
-                {
-                    this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
-                    return;
-                }
-
-                if (string.IsNullOrEmpty(mediaFormatOptions.FullPath))
-                {
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
-                }
-
-                string mimeType = mediaFormatOptions.Type;
-
-                if (string.IsNullOrEmpty(mimeType))
-                {
-                    mimeType = MimeTypeMapper.GetMimeType(mediaFormatOptions.FullPath);
-                }
-
-                if (mimeType.Equals("image/jpeg"))
-                {
-                    Deployment.Current.Dispatcher.BeginInvoke(() =>
-                    {
-                        WriteableBitmap image = ExtractImageFromLocalStorage(mediaFormatOptions.FullPath);
-
-                        if (image == null)
-                        {
-                            DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "File not found"));
-                            return;
-                        }
-
-                        MediaFileData mediaData = new MediaFileData(image);
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, mediaData));
-                    });
-                }
-                else
-                {
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
-                }
-            }
-            catch (Exception)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
-            }
-        }
-
-        /// <summary>
-        /// Opens specified file in media player
-        /// </summary>
-        /// <param name="options">MediaFile to play</param>
-        public void play(string options)
-        {
-            try
-            {
-                MediaFile file;
-
-                try
-                {
-                   file = String.IsNullOrEmpty(options) ? null : JSON.JsonHelper.Deserialize<MediaFile>(options);
-
-                }
-                catch (Exception ex)
-                {
-                    this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
-                    return;
-                }
-
-                if (file == null || String.IsNullOrEmpty(file.FilePath))
-                {
-                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "File path is missing"));
-                    return;
-                }
-
-                // if url starts with '/' media player throws FileNotFound exception
-                Uri fileUri = new Uri(file.FilePath.TrimStart(new char[] { '/', '\\' }), UriKind.Relative);
-
-                MediaPlayerLauncher player = new MediaPlayerLauncher();
-                player.Media = fileUri;
-                player.Location = MediaLocationType.Data;
-                player.Show();
-
-                this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
-                
-            }
-            catch (Exception e)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
-            }
-        }
-
-
-        /// <summary>
-        /// Handles result of capture to save image information 
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e">stores information about current captured image</param>
-        private void cameraTask_Completed(object sender, PhotoResult e)
-        {
-
-            if (e.Error != null)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
-                return;
-            }
-
-            switch (e.TaskResult)
-            {
-                case TaskResult.OK:
-                    try
-                    {
-                        string fileName = System.IO.Path.GetFileName(e.OriginalFileName);
-
-                        // Save image in media library
-                        MediaLibrary library = new MediaLibrary();
-                        Picture image = library.SavePicture(fileName, e.ChosenPhoto);
-
-                        int orient = ImageExifHelper.getImageOrientationFromStream(e.ChosenPhoto);
-                        int newAngle = 0;
-                        switch (orient)
-                        {
-                            case ImageExifOrientation.LandscapeLeft :
-                                newAngle = 90;
-                                break;
-                            case ImageExifOrientation.PortraitUpsideDown :
-                                newAngle = 180;
-                                break;
-                            case ImageExifOrientation.LandscapeRight :
-                                newAngle = 270;
-                                break;
-                            case ImageExifOrientation.Portrait : default : break; // 0 default already set
-                        }
-
-                        Stream rotImageStream = ImageExifHelper.RotateStream(e.ChosenPhoto, newAngle);
-
-                        // Save image in isolated storage    
-
-                        // we should return stream position back after saving stream to media library
-                        rotImageStream.Seek(0, SeekOrigin.Begin);
-                        
-                        byte[] imageBytes = new byte[rotImageStream.Length];
-                        rotImageStream.Read(imageBytes, 0, imageBytes.Length);
-                        rotImageStream.Dispose();
-                        string pathLocalStorage = this.SaveImageToLocalStorage(fileName, isoFolder, imageBytes);
-                        imageBytes = null;
-                        // Get image data
-                        MediaFile data = new MediaFile(pathLocalStorage, image);
-
-                        this.files.Add(data);
-
-                        if (files.Count < this.captureImageOptions.Limit)
-                        {
-                            cameraTask.Show();
-                        }
-                        else
-                        {
-                            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
-                            files.Clear();
-                        }
-                    }
-                    catch (Exception)
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error capturing image."));
-                    }
-                    break;
-
-                case TaskResult.Cancel:
-                    if (files.Count > 0)
-                    {
-                        // User canceled operation, but some images were made
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
-                        files.Clear();
-                    }
-                    else
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Canceled."));
-                    }
-                    break;
-
-                default:
-                    if (files.Count > 0)
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
-                        files.Clear();
-                    }
-                    else
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Did not complete!"));
-                    }
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Handles result of audio recording tasks 
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e">stores information about current captured audio</param>
-        private void audioRecordingTask_Completed(object sender, AudioResult e)
-        {
-
-            if (e.Error != null)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
-                return;
-            }
-
-            switch (e.TaskResult)
-            {
-                case TaskResult.OK:
-                    try
-                    {
-                        // Get image data
-                        MediaFile data = new MediaFile(e.AudioFileName, e.AudioFile);
-
-                        this.files.Add(data);
-
-                        if (files.Count < this.captureAudioOptions.Limit)
-                        {
-                            audioCaptureTask.Show();
-                        }
-                        else
-                        {
-                            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
-                            files.Clear();
-                        }
-                    }
-                    catch (Exception)
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error capturing audio."));
-                    }
-                    break;
-
-                case TaskResult.Cancel:
-                    if (files.Count > 0)
-                    {
-                        // User canceled operation, but some audio clips were made
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
-                        files.Clear();
-                    }
-                    else
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Canceled."));
-                    }
-                    break;
-
-                default:
-                    if (files.Count > 0)
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
-                        files.Clear();
-                    }
-                    else
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Did not complete!"));
-                    }
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Handles result of video recording tasks 
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e">stores information about current captured video</param>
-        private void videoRecordingTask_Completed(object sender, VideoResult e)
-        {
-
-            if (e.Error != null)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
-                return;
-            }
-
-            switch (e.TaskResult)
-            {
-                case TaskResult.OK:
-                    try
-                    {
-                        // Get image data
-                        MediaFile data = new MediaFile(e.VideoFileName, e.VideoFile);
-
-                        this.files.Add(data);
-
-                        if (files.Count < this.captureVideoOptions.Limit)
-                        {
-                            videoCaptureTask.Show();
-                        }
-                        else
-                        {
-                            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
-                            files.Clear();
-                        }
-                    }
-                    catch (Exception)
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error capturing video."));
-                    }
-                    break;
-
-                case TaskResult.Cancel:
-                    if (files.Count > 0)
-                    {
-                        // User canceled operation, but some video clips were made
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
-                        files.Clear();
-                    }
-                    else
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Canceled."));
-                    }
-                    break;
-
-                default:
-                    if (files.Count > 0)
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
-                        files.Clear();
-                    }
-                    else
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Did not complete!"));
-                    }
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// Extract file from Isolated Storage as WriteableBitmap object
-        /// </summary>
-        /// <param name="filePath"></param>
-        /// <returns></returns>
-        private WriteableBitmap ExtractImageFromLocalStorage(string filePath)
-        {
-            try
-            {
-
-                var isoFile = IsolatedStorageFile.GetUserStoreForApplication();
-
-                using (var imageStream = isoFile.OpenFile(filePath, FileMode.Open, FileAccess.Read))
-                {
-                    var imageSource = PictureDecoder.DecodeJpeg(imageStream);
-                    return imageSource;
-                }
-            }
-            catch (Exception)
-            {
-                return null;
-            }
-        }
-
-
-        /// <summary>
-        /// Saves captured image in isolated storage
-        /// </summary>
-        /// <param name="imageFileName">image file name</param>
-        /// <param name="imageFolder">folder to store images</param>
-        /// <returns>Image path</returns>
-        private string SaveImageToLocalStorage(string imageFileName, string imageFolder, byte[] imageBytes)
-        {
-            if (imageBytes == null)
-            {
-                throw new ArgumentNullException("imageBytes");
-            }
-            try
-            {
-                var isoFile = IsolatedStorageFile.GetUserStoreForApplication();
-
-                if (!isoFile.DirectoryExists(imageFolder))
-                {
-                    isoFile.CreateDirectory(imageFolder);
-                }
-                string filePath = System.IO.Path.Combine("/" + imageFolder + "/", imageFileName);
-
-                using (IsolatedStorageFileStream stream = isoFile.CreateFile(filePath))
-                {
-                    stream.Write(imageBytes, 0, imageBytes.Length);
-                }
-
-                return filePath;
-            }
-            catch (Exception)
-            {
-                //TODO: log or do something else
-                throw;
-            }
-        }
-
-
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/244fae11/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Compass.cs
----------------------------------------------------------------------
diff --git a/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Compass.cs b/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Compass.cs
deleted file mode 100755
index b4058c1..0000000
--- a/lib/cordova-1.9.0/lib/windows-phone/framework/Cordova/Commands/Compass.cs
+++ /dev/null
@@ -1,364 +0,0 @@
-/*  
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-*/
-
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-using DeviceCompass = Microsoft.Devices.Sensors.Compass;
-using System.Windows.Threading;
-using System.Runtime.Serialization;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Globalization;
-using System.Threading;
-using Microsoft.Devices.Sensors;
-
-namespace WP7CordovaClassLib.Cordova.Commands
-{
-
-    public class Compass : BaseCommand
-    {
-        #region Static members
-
-        /// <summary>
-        /// Status of listener
-        /// </summary>
-        private static int currentStatus;
-
-        /// <summary>
-        /// Id for get getCompass method
-        /// </summary>
-        private static string getCompassId = "getCompassId";
-
-        /// <summary>
-        /// Compass
-        /// </summary>
-        private static DeviceCompass compass = new DeviceCompass();
-
-        /// <summary>
-        /// Listeners for callbacks
-        /// </summary>
-        private static Dictionary<string, Compass> watchers = new Dictionary<string, Compass>();
-
-        #endregion
-
-        #region Status codes
-
-        public const int Stopped = 0;
-        public const int Starting = 1;
-        public const int Running = 2;
-        public const int ErrorFailedToStart = 4;
-        public const int Not_Supported = 20;
-
-        /*
-         *   // Capture error codes
-            CompassError.COMPASS_INTERNAL_ERR = 0;
-            CompassError.COMPASS_NOT_SUPPORTED = 20;
-         * */
-
-        #endregion
-
-        #region CompassOptions class
-        /// <summary>
-        /// Represents Accelerometer options.
-        /// </summary>
-        [DataContract]
-        public class CompassOptions
-        {
-            /// <summary>
-            /// How often to retrieve the Acceleration in milliseconds
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "frequency")]
-            public int Frequency { get; set; }
-
-            /// <summary>
-            /// The change in degrees required to initiate a watchHeadingFilter success callback.
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "filter")]
-            public int Filter { get; set; }
-
-            /// <summary>
-            /// Watcher id
-            /// </summary>
-            [DataMember(IsRequired = false, Name = "id")]
-            public string Id { get; set; }
-
-        }
-        #endregion
-
-
-        /// <summary>
-        /// Time the value was last changed
-        /// </summary>
-        //private DateTime lastValueChangedTime;
-
-        /// <summary>
-        /// Accelerometer options
-        /// </summary>
-        private CompassOptions compassOptions;
-
-        //bool isDataValid;
-
-        //bool calibrating = false;
-
-        public Compass()
-        {
-
-        }
-
-        /// <summary>
-        /// Formats current coordinates into JSON format
-        /// </summary>
-        /// <returns>Coordinates in JSON format</returns>
-        private string GetHeadingFormatted(CompassReading reading)
-        {
-            string result = String.Format("\"magneticHeading\":{0},\"headingAccuracy\":{1},\"trueHeading\":{2},\"timestamp\":{3}",
-                            reading.MagneticHeading.ToString("0.0", CultureInfo.InvariantCulture),
-                            reading.HeadingAccuracy.ToString("0.0", CultureInfo.InvariantCulture),
-                            reading.TrueHeading.ToString("0.0", CultureInfo.InvariantCulture),
-                            reading.Timestamp.UtcTicks.ToString());
-            result = "{" + result + "}";
-            return result;
-        }
-
-        public void getHeading(string options)
-        {
-            if (!DeviceCompass.IsSupported)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "{code:" + Not_Supported + "}"));
-            }
-            else
-            {
-                //if (compass == null)
-                //{
-                //    // Instantiate the compass.
-                //    compass = new DeviceCompass();
-                //    compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(40);
-                //    compass.CurrentValueChanged += new EventHandler<Microsoft.Devices.Sensors.SensorReadingEventArgs<Microsoft.Devices.Sensors.CompassReading>>(compass_CurrentValueChanged);
-                //    compass.Calibrate += new EventHandler<Microsoft.Devices.Sensors.CalibrationEventArgs>(compass_Calibrate);
-                //}
-                
-                
-                //compass.Start();
-
-            }
-
-            try
-            {
-                if (currentStatus != Running)
-                {
-
-                    lock (compass)
-                    {
-                        compass.CurrentValueChanged += compass_SingleHeadingValueChanged;
-                        compass.Start();
-                        this.SetStatus(Starting);
-                    }
-
-                    long timeout = 2000;
-                    while ((currentStatus == Starting) && (timeout > 0))
-                    {
-                        timeout = timeout - 100;
-                        Thread.Sleep(100);
-                    }
-
-                    if (currentStatus != Running)
-                    {
-                        DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, ErrorFailedToStart));
-                        return;
-                    }
-                }
-                lock (compass)
-                {
-
-                    compass.CurrentValueChanged -= compass_SingleHeadingValueChanged;
-                    if (watchers.Count < 1)
-                    {
-                        compass.Stop();
-                    }
-                }
-            }
-            catch (UnauthorizedAccessException)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION, ErrorFailedToStart));
-            }
-            catch (Exception)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ErrorFailedToStart));
-            }
-        }
-
-        void compass_SingleHeadingValueChanged(object sender, Microsoft.Devices.Sensors.SensorReadingEventArgs<CompassReading> e)
-        {
-            this.SetStatus(Running);
-            if (compass.IsDataValid)
-            {
-                // trueHeading :: The heading in degrees from 0 - 359.99 at a single moment in time.
-                //  magneticHeading:: The heading relative to the geographic North Pole in degrees 0 - 359.99 at a single moment in time. 
-                //  A negative value indicates that the true heading could not be determined.
-                // headingAccuracy :: The deviation in degrees between the reported heading and the true heading.
-                //rawMagnetometerReading = e.SensorReading.MagnetometerReading;
-
-                //Debug.WriteLine("Compass Result :: " + GetHeadingFormatted(e.SensorReading));
-
-                PluginResult result = new PluginResult(PluginResult.Status.OK, GetHeadingFormatted(e.SensorReading));
-
-                DispatchCommandResult(result);
-            }
-        }
-
-        /// <summary>
-        /// Starts listening for compass sensor
-        /// </summary>
-        /// <returns>status of listener</returns>
-        private int start()
-        {
-            if ((currentStatus == Running) || (currentStatus == Starting))
-            {
-                return currentStatus;
-            }
-            try
-            {
-                lock (compass)
-                {
-                    watchers.Add(getCompassId, this);
-                    compass.CurrentValueChanged += watchers[getCompassId].compass_CurrentValueChanged;
-                    compass.Start();
-                    this.SetStatus(Starting);
-                }
-            }
-            catch (Exception)
-            {
-                this.SetStatus(ErrorFailedToStart);
-            }
-            return currentStatus;
-        }
-
-        public void startWatch(string options)
-        {
-            if (!DeviceCompass.IsSupported)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, Not_Supported));
-            }
-
-            try
-            {
-                compassOptions = JSON.JsonHelper.Deserialize<CompassOptions>(options);
-            }
-            catch (Exception ex)
-            {
-                this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
-                return;
-            }
-
-            if (string.IsNullOrEmpty(compassOptions.Id))
-            {
-                this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
-                return;
-            }
-
-            try
-            {
-                lock (compass)
-                {
-                    watchers.Add(compassOptions.Id, this);
-                    compass.CurrentValueChanged += watchers[compassOptions.Id].compass_CurrentValueChanged;
-                    compass.Start();
-                    this.SetStatus(Starting);
-                }
-            }
-            catch (Exception)
-            {
-                this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ErrorFailedToStart));
-                return;
-            }
-        }
-
-        public void stopWatch(string options)
-        {
-            try
-            {
-                compassOptions = JSON.JsonHelper.Deserialize<CompassOptions>(options);
-            }
-            catch (Exception ex)
-            {
-                this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
-                return;
-            }
-
-            if (string.IsNullOrEmpty(compassOptions.Id))
-            {
-                this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
-                return;
-            }
-
-            if (currentStatus != Stopped)
-            {
-                lock (compass)
-                {
-                    Compass watcher = watchers[compassOptions.Id];
-                    compass.CurrentValueChanged -= watcher.compass_CurrentValueChanged;
-                    watchers.Remove(compassOptions.Id);
-                    watcher.Dispose();
-                }
-            }
-            this.SetStatus(Stopped);
-
-            this.DispatchCommandResult();
-        }
-
-        void compass_Calibrate(object sender, Microsoft.Devices.Sensors.CalibrationEventArgs e)
-        {
-            //throw new NotImplementedException();
-            // TODO: pass calibration error to JS
-        }
-
-        void compass_CurrentValueChanged(object sender, Microsoft.Devices.Sensors.SensorReadingEventArgs<CompassReading> e)
-        {
-            this.SetStatus(Running);
-            if (compass.IsDataValid)
-            {
-                // trueHeading :: The heading in degrees from 0 - 359.99 at a single moment in time.
-                //  magneticHeading:: The heading relative to the geographic North Pole in degrees 0 - 359.99 at a single moment in time. 
-                //  A negative value indicates that the true heading could not be determined.
-                // headingAccuracy :: The deviation in degrees between the reported heading and the true heading.
-                //rawMagnetometerReading = e.SensorReading.MagnetometerReading;
-
-                //Debug.WriteLine("Compass Result :: " + GetHeadingFormatted(e.SensorReading));
-
-                PluginResult result = new PluginResult(PluginResult.Status.OK,GetHeadingFormatted(e.SensorReading));
-                result.KeepCallback = true;
-
-                DispatchCommandResult(result);
-            }
-        }
-
-        /// <summary>
-        /// Sets current status
-        /// </summary>
-        /// <param name="status">current status</param>
-        private void SetStatus(int status)
-        {
-            currentStatus = status;
-        }
-
-    }
-}