This is an automated email from the ASF dual-hosted git repository.

timbru31 pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/cordova-plugin-device-orientation.git


The following commit(s) were added to refs/heads/master by this push:
     new b34dd2d  fix!: remove deprecated platforms (#57)
b34dd2d is described below

commit b34dd2ddd4e4ac081b0a3e72ac9cb577866d9ef6
Author: Tim Brust <[email protected]>
AuthorDate: Thu Aug 27 08:59:16 2020 +0000

    fix!: remove deprecated platforms (#57)
---
 README.md                 |  36 +----
 package.json              |  18 +--
 plugin.xml                |  99 +------------
 src/blackberry10/index.js |  35 -----
 src/firefoxos/compass.js  |  41 ------
 src/tizen/CompassProxy.js |  56 -------
 src/ubuntu/compass.cpp    |  75 ----------
 src/ubuntu/compass.h      |  58 --------
 src/wp/Compass.cs         | 362 ----------------------------------------------
 9 files changed, 10 insertions(+), 770 deletions(-)

diff --git a/README.md b/README.md
index 1e2afde..d750b98 100644
--- a/README.md
+++ b/README.md
@@ -61,15 +61,10 @@ Report issues on the [Apache Cordova issue 
tracker](https://issues.apache.org/ji
 
 ## Supported Platforms
 
-- Amazon Fire OS
 - Android
-- BlackBerry 10
 - Browser
-- Firefox OS
 - iOS
-- Tizen
-- Windows Phone 7 and 8 (if available in hardware)
-- Windows 8
+- Windows
 
 ## Methods
 
@@ -141,26 +136,10 @@ Only one `watchHeading` can be in effect at one time in 
iOS.  If a
 changes. Watching heading changes with a filter is more efficient than
 with time intervals.
 
-### Amazon Fire OS Quirks
-
-- `filter` is not supported.
-
 ### Android Quirks
 
 - No support for `filter`.
 
-### Firefox OS Quirks
-
-- No support for `filter`.
-
-### Tizen Quirks
-
-- No support for `filter`.
-
-### Windows Phone 7 and 8 Quirks
-
-- No support for `filter`.
-
 ## navigator.compass.clearWatch
 
 Stop watching the compass referenced by the watch ID parameter.
@@ -191,25 +170,12 @@ A `CompassHeading` object is returned to the 
`compassSuccess` callback function.
 
 - __timestamp__: The time at which this heading was determined.  
_(DOMTimeStamp)_
 
-
-### Amazon Fire OS Quirks
-
-- `trueHeading` is not supported, but reports the same value as 
`magneticHeading`
-
-- `headingAccuracy` is always 0 because there is no difference between the 
`magneticHeading` and `trueHeading`
-
 ### Android Quirks
 
 - The `trueHeading` property is not supported, but reports the same value as 
`magneticHeading`.
 
 - The `headingAccuracy` property is always 0 because there is no difference 
between the `magneticHeading` and `trueHeading`.
 
-### Firefox OS Quirks
-
-- The `trueHeading` property is not supported, but reports the same value as 
`magneticHeading`.
-
-- The `headingAccuracy` property is always 0 because there is no difference 
between the `magneticHeading` and `trueHeading`.
-
 ### iOS Quirks
 
 - The `trueHeading` property is only returned for location services enabled 
via `navigator.geolocation.watchLocation()`.
diff --git a/package.json b/package.json
index f4fae3d..d98d277 100644
--- a/package.json
+++ b/package.json
@@ -6,16 +6,9 @@
   "cordova": {
     "id": "cordova-plugin-device-orientation",
     "platforms": [
-      "firefoxos",
       "android",
-      "amazon-fireos",
-      "ubuntu",
-      "blackberry10",
       "ios",
-      "wp7",
-      "wp8",
-      "windows8",
-      "tizen",
+      "windows",
       "browser"
     ]
   },
@@ -31,16 +24,9 @@
     "device",
     "orientation",
     "ecosystem:cordova",
-    "cordova-firefoxos",
     "cordova-android",
-    "cordova-amazon-fireos",
-    "cordova-ubuntu",
-    "cordova-blackberry10",
     "cordova-ios",
-    "cordova-wp7",
-    "cordova-wp8",
-    "cordova-windows8",
-    "cordova-tizen",
+    "cordova-windows",
     "cordova-browser"
   ],
   "scripts": {
diff --git a/plugin.xml b/plugin.xml
index 0d1a980..cdf8a25 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -47,68 +47,20 @@
         With the W3C Device Motion and Orientation API now being supported on 
iOS, Android and Windows devices, this plugin is not needed any more. Read more 
about the API at https://www.w3.org/TR/2016/CR-orientation-event-20160818/ 
     </info>
 
-    <!-- firefoxos -->
-    <platform name="firefoxos">
-        <config-file target="config.xml" parent="/*">
-            <feature name="Compass">
-                <param name="firefoxos-package" value="Compass" />
-            </feature>
-        </config-file>
-
-        <js-module src="src/firefoxos/compass.js" name="compass-impl">
-          <runs />
-        </js-module>
-    </platform>
-
     <!-- android -->
     <platform name="android">
         <config-file target="res/xml/config.xml" parent="/*">
-               <feature name="Compass">
-                   <param name="android-package" 
value="org.apache.cordova.deviceorientation.CompassListener"/>
-               </feature>
-           </config-file>
-
-           <config-file target="AndroidManifest.xml" parent="/*">
-               <uses-permission 
android:name="android.permission.ACCESS_COARSE_LOCATION" />
-            <uses-permission 
android:name="android.permission.ACCESS_FINE_LOCATION" />
+            <feature name="Compass">
+                <param name="android-package" 
value="org.apache.cordova.deviceorientation.CompassListener"/>
+            </feature>
         </config-file>
 
-           <source-file src="src/android/CompassListener.java" 
target-dir="src/org/apache/cordova/deviceorientation" />
-    </platform>
-
-    <!-- amazon-fireos -->
-    <platform name="amazon-fireos">
-        <config-file target="res/xml/config.xml" parent="/*">
-               <feature name="Compass">
-                   <param name="android-package" 
value="org.apache.cordova.deviceorientation.CompassListener"/>
-               </feature>
-           </config-file>
-
-           <config-file target="AndroidManifest.xml" parent="/*">
-               <uses-permission 
android:name="android.permission.ACCESS_COARSE_LOCATION" />
+        <config-file target="AndroidManifest.xml" parent="/*">
+            <uses-permission 
android:name="android.permission.ACCESS_COARSE_LOCATION" />
             <uses-permission 
android:name="android.permission.ACCESS_FINE_LOCATION" />
         </config-file>
 
-           <source-file src="src/android/CompassListener.java" 
target-dir="src/org/apache/cordova/deviceorientation" />
-    </platform>
-
-    <!-- ubuntu -->
-    <platform name="ubuntu">
-        <header-file src="src/ubuntu/compass.h" />
-        <source-file src="src/ubuntu/compass.cpp" />
-        <config-file target="config.xml" parent="/*">
-            <feature name="DeviceOrientation">
-                <param policy_group="sensors" policy_version="1" />
-            </feature>
-        </config-file>
-    </platform>
-
-    <!-- blackberry10 -->
-    <platform name="blackberry10">
-        <config-file target="www/config.xml" parent="/widget">
-            <feature name="Compass" value="Compass" />
-        </config-file>
-        <source-file src="src/blackberry10/index.js" target-dir="Compass" />
+        <source-file src="src/android/CompassListener.java" 
target-dir="src/org/apache/cordova/deviceorientation" />
     </platform>
 
     <!-- ios -->
@@ -125,50 +77,13 @@
         <framework src="CoreLocation.framework" />
     </platform>
 
-    <!-- wp7 -->
-    <platform name="wp7">
-        <config-file target="config.xml" parent="/*">
-            <feature name="Compass">
-                <param name="wp-package" value="Compass"/>
-            </feature>
-        </config-file>
-
-        <config-file target="Properties/WMAppManifest.xml" 
parent="/Deployment/App/Capabilities">
-            <Capability Name="ID_CAP_SENSORS" />
-        </config-file>
-
-        <source-file src="src/wp/Compass.cs" />
-    </platform>
-
-        <!-- wp8 -->
-    <platform name="wp8">
-        <config-file target="config.xml" parent="/*">
-            <feature name="Compass">
-                <param name="wp-package" value="Compass"/>
-            </feature>
-        </config-file>
-
-        <config-file target="Properties/WMAppManifest.xml" 
parent="/Deployment/App/Capabilities">
-            <Capability Name="ID_CAP_SENSORS" />
-        </config-file>
-
-        <source-file src="src/wp/Compass.cs" />
-    </platform>
-
-        <!-- windows -->
+    <!-- windows -->
     <platform name="windows">
         <js-module src="src/windows/CompassProxy.js" name="CompassProxy">
             <runs />
         </js-module>
     </platform>
 
-    <!-- tizen -->
-    <platform name="tizen">
-        <js-module src="src/tizen/CompassProxy.js" name="CompassProxy">
-            <runs/>
-        </js-module>
-    </platform>
-
     <!-- browser -->
     <platform name="browser">
         <js-module src="src/browser/CompassProxy.js" name="CompassProxy">
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
deleted file mode 100644
index cd1bdf5..0000000
--- a/src/blackberry10/index.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2013 Research In Motion Limited.
- *
- * 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.
- */
-
-/* global PluginResult */
-
-module.exports = {
-    getHeading: function (success, fail, args, env) {
-        var result = new PluginResult(args, env),
-            callback = function (orientation) {
-                var info = {
-                    magneticHeading: orientation.alpha,
-                    trueHeading: 360-orientation.alpha,
-                    headingAccuracy: 360-(2*orientation.alpha),
-                    timestamp: new Date().getTime()
-                };
-                window.removeEventListener("deviceorientation", callback);
-                result.callbackOk(info, false);
-            };
-        window.addEventListener("deviceorientation", callback);
-        result.noResult(true);
-    }
-};
diff --git a/src/firefoxos/compass.js b/src/firefoxos/compass.js
deleted file mode 100644
index 95ac02c..0000000
--- a/src/firefoxos/compass.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- *
-*/
-
-var Compass = {
-    getHeading: function(success, error) {
-        var listener = function(ev) {
-            var orient = {
-                trueHeading: ev.alpha,
-                magneticHeading: ev.alpha,
-                headingAccuracy: 0,
-                timestamp: new Date().getTime()
-            };
-            success(orient);
-            // remove listener after first response
-            window.removeEventListener('deviceorientation', listener, false);
-        };
-        return window.addEventListener('deviceorientation', listener, false);
-    }
-};
-
-module.exports = Compass;
-require('cordova/exec/proxy').add('Compass', Compass);
-
diff --git a/src/tizen/CompassProxy.js b/src/tizen/CompassProxy.js
deleted file mode 100644
index 0e03af9..0000000
--- a/src/tizen/CompassProxy.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- *
-*/
-
-var CompassHeading = 
require('cordova-plugin-device-orientation.CompassHeading'),
-    CompassError = require('cordova-plugin-device-orientation.CompassError');
-
-var compassCallback = null,
-    compassReady = false;
-
-
-module.exports = {
-    getHeading: function (successCallback, errorCallback) {
-        if (window.DeviceOrientationEvent !== undefined) {
-            compassCallback = function (orientation) {
-                var heading = 360 - orientation.alpha;
-
-                if (compassReady) {
-                    if (successCallback)
-                        successCallback( new CompassHeading (heading, heading, 
0, 0));
-                    window.removeEventListener("deviceorientation", 
compassCallback, true);
-                }
-                compassReady = true;
-            };
-            compassReady = false; // workaround invalid first event value 
returned by WRT
-            window.addEventListener("deviceorientation", compassCallback, 
true);
-        }
-        else {
-            if (errorCallback)
-                errorCallback(CompassError.COMPASS_NOT_SUPPORTED);
-        }
-    },
-
-    stopHeading: function (successCallback, errorCallback) {
-        console.log("Compass stopHeading: not implemented yet.");
-    }
-};
-
-require("cordova/tizen/commandProxy").add("Compass", module.exports);
diff --git a/src/ubuntu/compass.cpp b/src/ubuntu/compass.cpp
deleted file mode 100644
index a2c3bee..0000000
--- a/src/ubuntu/compass.cpp
+++ /dev/null
@@ -1,75 +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.
- */
-
-#include "compass.h"
-
-DeviceOrientation::DeviceOrientation(Cordova *cordova): CPlugin(cordova), 
_validData(false) {
-    _compass.connectToBackend();
-    connect(&_compass, SIGNAL(readingChanged()), SLOT(updateSensor()));
-    connect(&_compass, SIGNAL(sensorError(int)), SLOT(sensorError(int)));
-}
-
-void DeviceOrientation::getHeading(int scId, int ecId, QVariantMap options) {
-    Q_UNUSED(options);
-    if (_compass.isConnectedToBackend() || !_compass.start()) {
-        this->callback(ecId, "CompassError.COMPASS_NOT_SUPPORTED");
-        return;
-    }
-
-    _successCallbacks << scId;
-    _errorCallbacks << ecId;
-
-    if (_validData) {
-        reportResult();
-        return;
-    }
-}
-
-void DeviceOrientation::sensorError(int error) {
-    Q_UNUSED(error);
-
-    for (int ecId: _errorCallbacks) {
-        this->callback(ecId, "CompassError.COMPASS_INTERNAL_ERR");
-    }
-
-    _errorCallbacks.clear();
-    _successCallbacks.clear();
-    _validData = false;
-}
-
-void DeviceOrientation::reportResult() {
-    QVariantMap obj;
-
-    obj.insert("magneticHeading", _azymuth);
-    obj.insert("trueHeading", _azymuth);
-    obj.insert("headingAccuracy", _accuracy);
-    obj.insert("timestamp", _timestamp);
-
-    for (int scId: _successCallbacks) {
-        this->cb(scId, obj);
-    }
-
-    _errorCallbacks.clear();
-    _successCallbacks.clear();
-}
-
-void DeviceOrientation::updateSensor(){
-    QCompassReading *heading = _compass.reading();
-    _azymuth = heading->azimuth();
-    _accuracy = heading->calibrationLevel();
-    _timestamp = QDateTime::currentDateTime().toMSecsSinceEpoch();
-
-    _validData = true;
-    reportResult();
-}
diff --git a/src/ubuntu/compass.h b/src/ubuntu/compass.h
deleted file mode 100644
index a1f421e..0000000
--- a/src/ubuntu/compass.h
+++ /dev/null
@@ -1,58 +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.
- */
-
-#ifndef COMPASS_H_HKFSAHKDFAS
-#define COMPASS_H_HKFSAHKDFAS
-
-#include <cplugin.h>
-#include <QCompass>
-#include <QtCore>
-
-class DeviceOrientation: public CPlugin {
-    Q_OBJECT
-public:
-    explicit DeviceOrientation(Cordova *cordova);
-
-    virtual const QString fullName() override {
-        return DeviceOrientation::fullID();
-    }
-
-    virtual const QString shortName() override {
-        return "Compass";
-    }
-
-    static const QString fullID() {
-        return "Compass";
-    }
-
-public slots:
-    void getHeading(int scId, int ecId, QVariantMap options);
-
-protected slots:
-    void updateSensor();
-    void sensorError(int error);
-
-private:
-    void reportResult();
-    QCompass _compass;
-    QList<int> _successCallbacks;
-    QList<int> _errorCallbacks;
-
-    double _azymuth;
-    double _accuracy;
-    qtimestamp _timestamp;
-    bool _validData;
-};
-
-#endif
diff --git a/src/wp/Compass.cs b/src/wp/Compass.cs
deleted file mode 100644
index d1ce894..0000000
--- a/src/wp/Compass.cs
+++ /dev/null
@@ -1,362 +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 WPCordovaClassLib.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)
-        {   
-            // NOTE: timestamp is generated on the JS side, to avoid issues 
with format conversions
-            string result = 
String.Format("\"magneticHeading\":{0},\"headingAccuracy\":{1},\"trueHeading\":{2}",
-                            reading.MagneticHeading.ToString("0.0", 
CultureInfo.InvariantCulture),
-                            reading.HeadingAccuracy.ToString("0.0", 
CultureInfo.InvariantCulture),
-                            reading.TrueHeading.ToString("0.0", 
CultureInfo.InvariantCulture));
-            return "{" + result + "}";
-        }
-
-        public void getHeading(string options)
-        {
-            if (!DeviceCompass.IsSupported)
-            {
-                DispatchCommandResult(new 
PluginResult(PluginResult.Status.ERROR, 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();
-                        this.SetStatus(Stopped);
-                    }
-                }
-            }
-            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;
-        }
-
-    }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to