/// <summary> /// The internal constructor. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="placeId">The place ID.</param> /// <param name="fenceId">The specified geofence ID.</param> /// <param name="error">The error code for the particular action.</param> /// <param name="eventType">The result code for the particular place and geofence management.</param> internal GeofenceResponseEventArgs(int placeId, int fenceId, GeofenceError error, GeofenceEventType eventType) { PlaceId = placeId; FenceId = fenceId; ErrorCode = error; EventType = eventType; }
/// <summary> /// Updates the place name of a given place ID. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="placeId">The specified place ID.</param> /// <param name="name">A new place name of the place ID.</param> /// <privilege>http://tizen.org/privilege/location</privilege> /// <exception cref="ArgumentException">In case of an invalid parameter.</exception> /// <exception cref="InvalidOperationException">In case of any System error.</exception> /// <exception cref="UnauthorizedAccessException">In case privileges are not defined.</exception> /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception> public void UpdatePlace(int placeId, string name) { GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.UpdatePlace(Handle, placeId, name); if (ret != GeofenceError.None) { throw GeofenceErrorFactory.CreateException(ret, "Failed to update place to Geofence Manager for " + placeId); } }
/// <summary> /// Removes the geofence with a given geofence ID. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="fenceId">The specified geofence ID.</param> /// <privilege>http://tizen.org/privilege/location</privilege> /// <exception cref="ArgumentException">In case of an invalid parameter.</exception> /// <exception cref="InvalidOperationException">In case of any system error.</exception> /// <exception cref="UnauthorizedAccessException">In case privileges are not defined.</exception> /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception> public void RemoveGeofence(int fenceId) { GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.RemoveFence(Handle, fenceId); if (ret != GeofenceError.None) { throw GeofenceErrorFactory.CreateException(ret, "Failed to remove geofence from Geofence Manager for " + fenceId); } }
/// <summary> /// Stops the geofenceing service. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="geofenceId">The specified geofence ID.</param> /// <privilege>http://tizen.org/privilege/location</privilege> /// <remarks> /// This function initiates the process of stopping the service. /// You can stop and start the Geofence manager as needed. /// </remarks> /// <exception cref="ArgumentException">In case of an invalid parameter.</exception> /// <exception cref="InvalidOperationException">In case of any system error.</exception> /// <exception cref="UnauthorizedAccessException">In case privileges are not defined.</exception> /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception> public void Stop(int geofenceId) { GeofenceError ret = (GeofenceError)Interop.GeofenceManager.Stop(Handle, geofenceId); if (ret != GeofenceError.None) { throw GeofenceErrorFactory.CreateException(ret, "Failed to stop service for " + geofenceId); } }
internal static Exception CreateException(GeofenceError err, string msg) { Log.Info(LogTag, "Got Error " + err + " throwing Exception with msg " + msg); Exception exp; switch (err) { case GeofenceError.InvalidParameter: { exp = new ArgumentException(msg + " Invalid Parameters Provided"); break; } case GeofenceError.OutOfMemory: { exp = new OutOfMemoryException(msg + " Out Of Memory"); break; } case GeofenceError.NotInitialized: { exp = new InvalidOperationException(msg + " Not initializded"); break; } case GeofenceError.NotSupported: { exp = new NotSupportedException(msg + " Not supported"); break; } case GeofenceError.PermissionDenied: // fall through case GeofenceError.GeofenceAccessDenied: //fall through case GeofenceError.PlaceAccessDenied: { exp = new UnauthorizedAccessException(msg + " Permission Denied"); break; } case GeofenceError.DBFailed: { exp = new InvalidOperationException(msg + " DataBase Failed"); break; } default: { exp = new InvalidOperationException(msg); break; } } return(exp); }
/// <summary> /// Creates a new place for the geofencing service. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="name">A place name to be created.</param> /// <returns>The place ID to be newly created on success.</returns> /// <privilege>http://tizen.org/privilege/location</privilege> /// <exception cref="ArgumentException">In case of an invalid parameter.</exception> /// <exception cref="InvalidOperationException">In case of any system error.</exception> /// <exception cref="UnauthorizedAccessException">In case privileges are not defined.</exception> /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception> public int AddPlaceName(string name) { int placeId = 0; GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.AddPlace(Handle, name, out placeId); if (ret != GeofenceError.None) { throw GeofenceErrorFactory.CreateException(ret, "Failed to add place to Geofence Manager for " + name); } return(placeId); }
/// <summary> /// Gets the name of place. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="placeId">The place ID.</param> /// <returns>The name of the place.</returns> /// <privilege>http://tizen.org/privilege/location</privilege> /// <exception cref="ArgumentException">In case of an invalid parameter.</exception> /// <exception cref="InvalidOperationException">In case of any system error.</exception> /// <exception cref="UnauthorizedAccessException">In case privileges are not defined.</exception> /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception> public string GetPlaceName(int placeId) { string name = ""; GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.GetPlaceName(Handle, placeId, out name); if (ret != GeofenceError.None) { throw GeofenceErrorFactory.CreateException(ret, "Failed to get placenamefrom Geofence Manager for " + placeId); } return(name); }
/// <summary> /// Adds the geofence for a given Geofence manager. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="fence">The geofence instance to be added.</param> /// <returns>The geofence ID to be newly created on success.</returns> /// <remarks> The return value will always be a number greater than zero.</remarks> /// <privilege>http://tizen.org/privilege/location</privilege> /// <exception cref="ArgumentException">In case of an invalid parameter.</exception> /// <exception cref="InvalidOperationException">In case of any system error.</exception> /// <exception cref="UnauthorizedAccessException">In case privileges are not defined.</exception> /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception> public int AddGeofence(Fence fence) { int fenceId = 0; GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.AddFence(Handle, fence.Handle, out fenceId); if (ret != GeofenceError.None) { throw GeofenceErrorFactory.CreateException(ret, "Failed to add fence to Geofence Manager "); } return(fenceId); }
/// <summary> /// Creates a new geofence status. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="fenceId">The geofence ID.</param> /// <exception cref="ArgumentException">In case of an invalid parameter.</exception> /// <exception cref="NotSupportedException">In case of geofence is not supported.</exception> public FenceStatus(int fenceId) { IntPtr handle; GeofenceError ret = (GeofenceError)Interop.GeofenceStatus.Create(fenceId, out handle); if (ret != GeofenceError.None) { throw GeofenceErrorFactory.CreateException(ret, "Failed to create Geofence Status instance"); } Handle = handle; }
/// <summary> /// Creates a new Geofence manager. /// </summary> /// <since_tizen> 3 </since_tizen> /// <exception cref="OutOfMemoryException">In case of out of memory condition.</exception> /// <exception cref="InvalidOperationException">In case of any system error.</exception> /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception> public GeofenceManager() { IntPtr handle; GeofenceError ret = (GeofenceError)Interop.GeofenceManager.Create(out handle); if (ret != GeofenceError.None) { throw GeofenceErrorFactory.CreateException(ret, "Failed to create Geofence Manager instance"); } Handle = handle; }
/// <summary> /// Creates a Bluetooth type of the new geofence. /// </summary> /// <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; GeofenceError ret = (GeofenceError)Interop.Geofence.CreateBTFence(placeId, bssid, ssid, out handle); if (ret != GeofenceError.None) { throw GeofenceErrorFactory.CreateException(ret, "Failed to create Geofence from Bluetooth Data for " + placeId); } return(new Fence(handle)); }
/// <summary> /// Creates a geopoint type of the new geofence. /// </summary> /// <since_tizen> 4 </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, double latitude, double longitude, int radius, string address) { IntPtr handle = IntPtr.Zero; 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); } return(new Fence(handle)); }
/// <summary> /// Retrieves a list of fences registered in the specified place. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="placeId"> The place ID.</param> /// <returns>The list of FenceData instances registered for each geofence for the specified place.</returns> /// <privilege>http://tizen.org/privilege/location</privilege> /// <exception cref="ArgumentException">In case of an invalid parameter.</exception> /// <exception cref="InvalidOperationException">In case of any system error.</exception> /// <exception cref="UnauthorizedAccessException">In case privileges are not defined.</exception> /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception> public IEnumerable <FenceData> GetGeofenceDataListByPlaceId(int placeId) { List <FenceData> fences = new List <FenceData>(); Interop.VirtualPerimeter.ForEachFenceListCallback callback = (int fenceId, IntPtr handle, int index, int count, IntPtr data) => { FenceData fence = new FenceData(fenceId, handle, index, count); fences.Add(fence); return(true); }; GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.GetForEachPlaceFenceList(Handle, placeId, callback, IntPtr.Zero); if (ret != GeofenceError.None) { throw GeofenceErrorFactory.CreateException(ret, "Failed to get Geofence list from Geofence Manager for " + placeId); } return(fences); }
/// <summary> /// Retrieves a list of places registered in the specified Geofence manager. /// </summary> /// <since_tizen> 3 </since_tizen> /// <returns>List of places registered as the PlaceData instance list.</returns> /// <privilege>http://tizen.org/privilege/location</privilege> /// <exception cref="InvalidOperationException">In case of any system error.</exception> /// <exception cref="UnauthorizedAccessException">In case privileges are not defined.</exception> /// <exception cref="NotSupportedException">In case the geofence is not supported.</exception> public IEnumerable <PlaceData> GetPlaceDataList() { List <PlaceData> places = new List <PlaceData>(); Interop.VirtualPerimeter.ForEachPlaceListCallback placeCallback = (int placeId, string name, int index, int count, IntPtr data) => { if (count != 0) { PlaceData place = new PlaceData(placeId, name, index, count); places.Add(place); } return(true); }; GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.GetForEachPlaceList(Handle, placeCallback, IntPtr.Zero); if (ret != GeofenceError.None) { throw GeofenceErrorFactory.CreateException(ret, "Failed to get Places list from Geofence Manager "); } return(places); }