2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Runtime.InteropServices;
19 using Tizen.Location.Geofence;
21 internal static partial class Interop
23 internal static partial class Geofence
25 [DllImport(Libraries.Geofence, EntryPoint = "geofence_create_geopoint")]
26 internal static extern int CreateGPSFence(int placeId, double latitude, double longitude, int radius, string address, out IntPtr handle);
28 [DllImport(Libraries.Geofence, EntryPoint = "geofence_create_bluetooth")]
29 internal static extern int CreateBTFence(int placeId, string bssid, string ssid, out IntPtr handle);
31 [DllImport(Libraries.Geofence, EntryPoint = "geofence_create_wifi")]
32 internal static extern int CreateWiFiFence(int placeId, string bssid, string ssid, out IntPtr handle);
34 [DllImport(Libraries.Geofence, EntryPoint = "geofence_destroy")]
35 internal static extern int Destroy(IntPtr handle);
37 [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_type")]
38 internal static extern int FenceType(IntPtr handle, out FenceType type);
40 [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_place_id")]
41 internal static extern int FencePlaceID(IntPtr handle, out int placeId);
43 [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_latitude")]
44 internal static extern int FenceLatitude(IntPtr handle, out double latitude);
46 [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_longitude")]
47 internal static extern int FenceLongitude(IntPtr handle, out double longitude);
49 [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_radius")]
50 internal static extern int FenceRadius(IntPtr handle, out int radius);
52 [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_address")]
53 internal static extern int FenceAddress(IntPtr handle, out string address);
55 [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_bssid")]
56 internal static extern int FenceBSSID(IntPtr handle, out string bssid);
58 [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_ssid")]
59 internal static extern int FenceSSID(IntPtr handle, out string ssid);
62 internal static partial class GeofenceStatus
64 [DllImport(Libraries.Geofence, EntryPoint = "geofence_status_create")]
65 internal static extern int Create(int fenceId, out IntPtr statusHandle);
67 [DllImport(Libraries.Geofence, EntryPoint = "geofence_status_destroy")]
68 internal static extern int Destroy(IntPtr statusHandle);
70 [DllImport(Libraries.Geofence, EntryPoint = "geofence_status_get_state")]
71 internal static extern int State(IntPtr statusHandle, out GeofenceState state);
73 [DllImport(Libraries.Geofence, EntryPoint = "geofence_status_get_duration")]
74 internal static extern int Duration(IntPtr statusHandle, out int seconds);
77 internal static partial class GeofenceManager
79 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
80 internal delegate bool StateChangedCallback(int fenceId, GeofenceState state, IntPtr userData);
82 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
83 internal delegate bool ProximityStateChangedCallback(int fenceId, ProximityState state, ProximityProvider provider, IntPtr userData);
85 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
86 internal delegate bool GeofenceEventCallback(int placeId, int fenceId, GeofenceError error, GeofenceEventType eventType, IntPtr userData);
88 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_is_supported")]
89 internal static extern int IsSupported(out bool supported);
91 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_create")]
92 internal static extern int Create(out IntPtr handle);
94 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_destroy")]
95 internal static extern int Destroy(IntPtr handle);
97 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_start")]
98 internal static extern int Start(IntPtr handle, int fenceId);
100 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_stop")]
101 internal static extern int Stop(IntPtr handle, int fenceId);
103 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_set_geofence_state_changed_cb")]
104 internal static extern int SetStateChangedCB(IntPtr handle, StateChangedCallback callback, IntPtr userData);
106 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_unset_geofence_state_changed_cb")]
107 internal static extern int UnsetStateChangedCB(IntPtr handle);
109 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_set_geofence_proximity_state_changed_cb")]
110 internal static extern int SetProximityStateCB(IntPtr handle, ProximityStateChangedCallback callback, IntPtr userData);
112 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_unset_geofence_proximity_state_changed_cb")]
113 internal static extern int UnsetProximityStateCB(IntPtr handle);
115 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_set_geofence_event_cb")]
116 internal static extern int SetGeofenceEventCB(IntPtr handle, GeofenceEventCallback callback, IntPtr userData);
118 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_unset_geofence_event_cb")]
119 internal static extern int UnsetGeofenceEventCB(IntPtr handle);
122 internal static partial class VirtualPerimeter
124 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
125 internal delegate bool ForEachPlaceListCallback(int placeId, string placeName, int placeIndex, int placeCount, IntPtr userData);
127 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
128 internal delegate bool ForEachFenceListCallback(int fenceId, IntPtr fenceHandle, int placeIndex, int placeCount, IntPtr userData);
130 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_add_place")]
131 internal static extern int AddPlace(IntPtr handle, string placeName, out int placeId);
133 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_update_place")]
134 internal static extern int UpdatePlace(IntPtr handle, int placeId, string placeName);
136 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_remove_place")]
137 internal static extern int RemovePlace(IntPtr handle, int placeId);
139 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_add_fence")]
140 internal static extern int AddFence(IntPtr handle, IntPtr fenceHandle, out int fenceId);
142 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_remove_fence")]
143 internal static extern int RemoveFence(IntPtr handle, int fenceId);
145 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_foreach_geofence_list")]
146 internal static extern int GetForEachFenceList(IntPtr handle, ForEachFenceListCallback callback, IntPtr userData);
148 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_foreach_place_geofence_list")]
149 internal static extern int GetForEachPlaceFenceList(IntPtr handle, int placeId, ForEachFenceListCallback callback, IntPtr userData);
151 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_foreach_place_list")]
152 internal static extern int GetForEachPlaceList(IntPtr handle, ForEachPlaceListCallback callback, IntPtr userData);
154 [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_get_place_name")]
155 internal static extern int GetPlaceName(IntPtr handle, int placeId, out string placeName);