Review geofence API cs files
[platform/core/csapi/geofence.git] / Tizen.Location.Geofence / Tizen.Location.Geofence / Fence.cs
index d2e1ed6..7dbe95b 100755 (executable)
@@ -19,26 +19,28 @@ using System;
 namespace Tizen.Location.Geofence
 {
     /// <summary>
-    /// Geo-fence defines a virtual perimeter for a real-world geographic area.
-    /// If you create a geofence, you can trigger some activities when a device enters(or exits) the geofences defined by you.
-    /// You can create a geofence with the information of Geopoint, Wi-Fi, or BT.
-    /// <list >
-    /// <item>Geopoint: Geofence is specified by coordinates (Latitude and Longitude) and Radius</item>
-    /// <item>WIFI: Geofence is specified by BSSID of Wi-Fi access point</item>
-    /// <item>BT: Geofence is specified by Bluetooth address</item>
+    /// Geofence defines a virtual perimeter for a real-world geographic area.
+    /// If you create a geofence, you can trigger some activities when a device enters (or exits) the geofences defined by you.
+    /// You can create a geofence with the information of the Geopoint, Wi-Fi, or BT.
+    /// <list>
+    /// <item>Geopoint: Geofence is specified by the coordinates (Latitude and Longitude) and radius.</item>
+    /// <item>WIFI: Geofence is specified by the BSSID of the Wi-Fi access point.</item>
+    /// <item>BT: Geofence is specified by the Bluetooth address.</item>
     /// </list>
-    /// Basic service set identification(BSSID) The BSSID is the MAC address of the wireless access point(WAP) generated by combining the 24 bit Organization Unique Identifier(the manufacturer's identity)
+    /// The Basic service set identifier (BSSID) is the MAC address of the wireless access point (WAP) generated by combining the 24-bit Organization Unique Identifier (the manufacturer's identity)
     /// and the manufacturer's assigned 24-bit identifier for the radio chipset in the WAP.
     /// </summary>
+    /// <since_tizen> 3 </since_tizen>
     public class Fence : IDisposable
     {
+        private bool _disposed = false;
+
         internal IntPtr Handle
         {
             get;
             set;
         }
 
-
         internal Fence(IntPtr handle)
         {
             Handle = handle;
@@ -48,9 +50,11 @@ namespace Tizen.Location.Geofence
         {
             Dispose(false);
         }
+
         /// <summary>
-        /// Gets the type of geofence
+        /// Gets the type of geofence.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public FenceType Type
         {
             get
@@ -67,8 +71,9 @@ namespace Tizen.Location.Geofence
         }
 
         /// <summary>
-        /// Gets the id of place.
+        /// Gets the ID of the place.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public int PlaceId
         {
             get
@@ -85,8 +90,9 @@ namespace Tizen.Location.Geofence
         }
 
         /// <summary>
-        ///Gets the longitude of geofence.
+        /// Gets the longitude of geofence.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public double Longitude
         {
             get
@@ -104,8 +110,9 @@ namespace Tizen.Location.Geofence
         }
 
         /// <summary>
-        ///Gets the latitude of geofence.
+        /// Gets the latitude of geofence.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public double Latitude
         {
             get
@@ -124,6 +131,7 @@ namespace Tizen.Location.Geofence
         /// <summary>
         /// Gets the radius of geofence.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public int Radius
         {
             get
@@ -140,44 +148,9 @@ namespace Tizen.Location.Geofence
         }
 
         /// <summary>
-        /// Gets the state of geofence.
-        /// </summary>
-        public GeofenceState FenceState
-        {
-            get
-            {
-                GeofenceState state;
-                GeofenceError ret = (GeofenceError)Interop.Geofence.FenceState(Handle, out state);
-                if (ret != GeofenceError.None)
-                {
-                    Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get GeofenceState");
-                }
-
-                return state;
-            }
-        }
-
-        /// <summary>
-        /// Gets the amount of seconds geofence is in the current state.
-        /// </summary>
-        public int Duration
-        {
-            get
-            {
-                int result = -1;
-                GeofenceError ret = (GeofenceError)Interop.Geofence.FenceDuration(Handle, out result);
-                if (ret != GeofenceError.None)
-                {
-                    Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get Duration");
-                }
-
-                return result;
-            }
-        }
-
-        /// <summary>
         /// Gets the address of geofence.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public string Address
         {
             get
@@ -194,8 +167,9 @@ namespace Tizen.Location.Geofence
         }
 
         /// <summary>
-        /// Gets the bssid of geofence.
+        /// Gets the BSSID of geofence.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public string Bssid
         {
             get
@@ -212,8 +186,9 @@ namespace Tizen.Location.Geofence
         }
 
         /// <summary>
-        ///Gets the ssid of geofence.
+        /// Gets the SSID of geofence.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public string Ssid
         {
             get
@@ -230,22 +205,22 @@ namespace Tizen.Location.Geofence
         }
 
         /// <summary>
-        /// Creates a geopoint type of new geofence.
+        /// Creates a geopoint type of the new geofence.
         /// </summary>
-        /// <param name="placeId">The current place id</param>
-        /// <param name="latitude">Specifies the value of latitude of geofence [-90.0 ~ 90.0] (degrees) </param>
-        /// <param name="longitude">Specifies the value of longitude of geofence [-180.0 ~ 180.0] (degrees) </param>
-        /// <param name="radius">Specifies the value of radius of geofence [100 ~ 500](meter) </param>
-        /// <param name="adsress">Specifies the value of address</param>
-        /// <returns>Newly created geofence instance </returns>
-        /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
-        /// <exception cref="InvalidOperationException">Incase of any System error</exception>
-        /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
-        /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="placeId">The current place ID.</param>
+        /// <param name="latitude">Specifies the value of latitude of the geofence [-90.0 ~ 90.0] (degrees).</param>
+        /// <param name="longitude">Specifies the value of longitude of the geofence [-180.0 ~ 180.0] (degrees).</param>
+        /// <param name="radius">Specifies the value of radius of the geofence [100 ~ 500](meter).</param>
+        /// <param name="address">Specifies the value of the address.</param>
+        /// <returns>The newly created geofence instance.</returns>
+        /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">In case of any system error.</exception>
+        /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception>
         public static Fence CreateGPSFence(int placeId, int latitude, int longitude, int radius, string address)
         {
             IntPtr handle = IntPtr.Zero;
-            GeofenceError ret = (GeofenceError)Interop.Geofence.CreateGPSFence(placeId,latitude, longitude, radius,address,out handle);
+            GeofenceError ret = (GeofenceError)Interop.Geofence.CreateGPSFence(placeId, latitude, longitude, radius,address, out handle);
             if (ret != GeofenceError.None)
             {
                 throw GeofenceErrorFactory.CreateException(ret, "Failed to create Geofence from GPS Data for " + placeId);
@@ -255,16 +230,16 @@ namespace Tizen.Location.Geofence
         }
 
         /// <summary>
-        /// Creates a Wi-Fi type of new geofence.
+        /// Creates a Wi-Fi type of the new geofence.
         /// </summary>
-        /// <param name="placeId">The current place id </param>
-        /// <param name="bssid">Specifies the value of BSSID of Wi-Fi MAC address</param>
-        /// <param name="ssid"> Specifies the value of SSID of Wi-Fi Device </param>
-        /// <returns>Newly created geofence instance </returns>
-        /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
-        /// <exception cref="InvalidOperationException">Incase of any System error</exception>
-        /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
-        /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="placeId">The current place ID.</param>
+        /// <param name="bssid">Specifies the value of BSSID of the Wi-Fi MAC address.</param>
+        /// <param name="ssid"> Specifies the value of SSID of the Wi-Fi device.</param>
+        /// <returns>The newly created geofence instance.</returns>
+        /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">In case of any system error.</exception>
+        /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception>
         public static Fence CreateWifiFence(int placeId, string bssid, string ssid)
         {
             IntPtr handle = IntPtr.Zero;
@@ -278,16 +253,16 @@ namespace Tizen.Location.Geofence
         }
 
         /// <summary>
-        /// Creates a bluetooth type of new geofence.
+        /// Creates a Bluetooth type of the new geofence.
         /// </summary>
-        /// <param name="placeId">The current place id </param>
-        /// <param name="bssid">Specifies the value of BSSID of BT MAC address</param>
-        /// <param name="ssid"> Specifies the value of SSID of BT Device </param>
-        /// <returns>Newly created geofence instance </returns>
-        /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
-        /// <exception cref="InvalidOperationException">Incase of any System error</exception>
-        /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
-        /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="placeId">The current place ID.</param>
+        /// <param name="bssid">Specifies the value of BSSID of BT MAC address.</param>
+        /// <param name="ssid"> Specifies the value of SSID of BT Device.</param>
+        /// <returns>The newly created geofence instance.</returns>
+        /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">In case of any system error.</exception>
+        /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception>
         public static Fence CreateBTFence(int placeId, string bssid, string ssid)
         {
             IntPtr handle = IntPtr.Zero;
@@ -301,8 +276,9 @@ namespace Tizen.Location.Geofence
         }
 
         /// <summary>
-        /// Overloaded Dispose API for destroying the fence Handle.
+        /// The overloaded Dispose API for destroying the fence handle.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public void Dispose()
         {
             Dispose(true);
@@ -311,14 +287,16 @@ namespace Tizen.Location.Geofence
 
         private void Dispose(bool disposing)
         {
-            if (!disposing)
+            if (_disposed)
+                return;
+
+            if (Handle != IntPtr.Zero)
             {
-                if (Handle != IntPtr.Zero)
-                {
-                    Interop.Geofence.Destroy(Handle);
-                    Handle = IntPtr.Zero;
-                }
+                Interop.Geofence.Destroy(Handle);
+                Handle = IntPtr.Zero;
             }
+
+            _disposed = true;
         }
     }
 }