1. Add dispose of LocationBoundary
authorkj7.sung <kj7.sung@samsung.com>
Tue, 8 Nov 2016 07:36:53 +0000 (16:36 +0900)
committerkj7.sung <kj7.sung@samsung.com>
Tue, 8 Nov 2016 07:37:37 +0000 (16:37 +0900)
2. Remove None method type

Change-Id: Icbd07c12b1dff5d42aaeed01bbc04ef5b97a8559
Signed-off-by: kj7.sung <kj7.sung@samsung.com>
Tizen.Location/Interop/Interop.Location.cs
Tizen.Location/Tizen.Location/Location.cs
Tizen.Location/Tizen.Location/LocationBoundary.cs
Tizen.Location/Tizen.Location/Locator.cs
Tizen.Location/Tizen.Location/LocatorEnumerations.cs

index 44ef576..9998fbf 100755 (executable)
@@ -142,7 +142,7 @@ internal static partial class Interop
         public static extern bool IsValidCoordinates(IntPtr handle, Coordinate coordinate);
 
         [DllImport(Libraries.Location, EntryPoint = "location_bounds_destroy")]
-        public static extern bool DestroyBoundary(IntPtr handle);
+        public static extern int DestroyBoundary(IntPtr handle);
     }
 
     internal static partial class GpsSatellite
@@ -175,4 +175,4 @@ internal static partial class Interop
 
         return dateTime;
     }
-}
\ No newline at end of file
+}
index f57f53d..15604be 100755 (executable)
@@ -25,12 +25,12 @@ namespace Tizen.Location
     /// </summary>
     public class Location
     {
-        private double _altitude;
         private double _latitude;
         private double _longitude;
+        private double _altitude;
+        private double _horizontal;
         private double _direction;
         private double _speed;
-        private double _horizontal;
         internal int _timestamp;
 
         /// <summary>
@@ -62,92 +62,92 @@ namespace Tizen.Location
         }
 
         /// <summary>
-        /// The current altitude (meters).
+        /// The current latitude [-90.0 ~ 90.0] (degrees).
         /// </summary>
-        public double Altitude
+        public double Latitude
         {
             get
             {
-                return _altitude;
+                return _latitude;
             }
             set
             {
-                _altitude = value;
+                _latitude = value;
             }
         }
 
         /// <summary>
-        /// The current latitude [-90.0 ~ 90.0] (degrees).
+        /// The current longitude [-180.0 ~ 180.0] (degrees).
         /// </summary>
-        public double Latitude
+        public double Longitude
         {
             get
             {
-                return _latitude;
+                return _longitude;
             }
             set
             {
-                _latitude = value;
+                _longitude = value;
             }
         }
 
         /// <summary>
-        /// The current longitude [-180.0 ~ 180.0] (degrees).
+        /// The current altitude (meters).
         /// </summary>
-        public double Longitude
+        public double Altitude
         {
             get
             {
-                return _longitude;
+                return _altitude;
             }
             set
             {
-                _longitude = value;
+                _altitude = value;
             }
         }
 
         /// <summary>
-        /// The direction, degrees from the north.
+        /// The horizontal accuracy.
         /// </summary>
-        public double Direction
+        public double HorizontalAccuracy
         {
             get
             {
-                return _direction;
+                return _horizontal;
             }
             set
             {
-                _direction = value;
+                _horizontal = value;
             }
         }
 
         /// <summary>
-        /// The Device Speed (km/h).
+        /// The direction, degrees from the north.
         /// </summary>
-        public double Speed
+        public double Direction
         {
             get
             {
-                return _speed;
+                return _direction;
             }
             set
             {
-                _speed = value;
+                _direction = value;
             }
         }
 
         /// <summary>
-        /// The horizontal accuracy.
+        /// The Device Speed (km/h).
         /// </summary>
-        public double HorizontalAccuracy
+        public double Speed
         {
             get
             {
-                return _horizontal;
+                return _speed;
             }
             set
             {
-                _horizontal = value;
+                _speed = value;
             }
         }
 
index 5e5aca5..d89e886 100755 (executable)
@@ -23,15 +23,25 @@ namespace Tizen.Location
     /// <summary>
     /// Abstract class which provides functions related to geographic bounds information.
     /// </summary>
-    public abstract class LocationBoundary
+    public abstract class LocationBoundary : IDisposable
     {
         internal IntPtr handle;
+        private bool _disposed = false;
 
         /// <summary>
         /// Gets the location boundary type.
         /// </summary>
         public BoundaryType BoundaryType{ get; internal set; }
 
+        /// <summary>
+        /// The destructor of LocationBoundary class.
+        /// </summary>
+        ~LocationBoundary()
+        {
+            Log.Info(Globals.LogTag, "The destructor of LocationBoundary class");
+            Dispose(false);
+        }
+
         internal IntPtr GetHandle()
         {
             return handle;
@@ -47,6 +57,37 @@ namespace Tizen.Location
             Log.Info(Globals.LogTag, "Checking if coordinates are contained within boundary");
             return Interop.LocationBoundary.IsValidCoordinates(handle, coordinate);
         }
+
+        /// <summary>
+        /// The overidden Dispose method of the IDisposable class.
+        /// </summary>
+        public void Dispose()
+        {
+            Log.Info(Globals.LogTag, "Dispose");
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            Log.Info(Globals.LogTag, "Dispose");
+            if (_disposed)
+                return;
+
+            DestroyHandle();
+            _disposed = true;
+        }
+
+        private void DestroyHandle()
+        {
+            Log.Info(Globals.LogTag, "DestroyHandle");
+            int ret = Interop.LocationBoundary.DestroyBoundary(handle);
+            if (((LocationError)ret != LocationError.None))
+            {
+                Log.Error(Globals.LogTag, "Error in DestroyBoundary handle" + (LocationError)ret);
+                throw LocationErrorFactory.ThrowLocationException(ret);
+            }
+        }
     }
 
     /// <summary>
index d95f6e3..0a21100 100755 (executable)
@@ -276,7 +276,7 @@ namespace Tizen.Location
             int ret = Interop.Locator.SetMockLocation(_handle, location.Latitude, location.Longitude, location.Altitude, location.Speed, location.Direction, location.HorizontalAccuracy);
             if (((LocationError)ret == LocationError.None))
             {
-                _location.Altitude = 0;
+                _location.Altitude = location.Altitude;
                 _location.Latitude = location.Latitude;
                 _location.Longitude = location.Longitude;
                 _location.Speed = location.Speed;
index 5ab9e1d..95c6725 100755 (executable)
@@ -33,8 +33,7 @@ namespace Tizen.Location
     /// </summary>
     public enum LocationType
     {
-        None = -1, /**<Undefined method.*/
-        Hybrid, /**<This method selects the best method available at the moment.*/
+        Hybrid = 0, /**<This method selects the best method available at the moment.*/
         Gps, /**<This method uses Global Positioning System.*/
         Wps, /**<This method uses WiFi Positioning System.*/
     }