fe722129042059fc9eb3fa28017ac59b014cc6ff
[platform/core/csapi/tizenfx.git] / src / Tizen.Location / Interop / Interop.Location.cs
1 // Copyright 2016 by Samsung Electronics, Inc.,
2 //
3 // This software is the confidential and proprietary information
4 // of Samsung Electronics, Inc. ("Confidential Information"). You
5 // shall not disclose such Confidential Information and shall use
6 // it only in accordance with the terms of the license agreement
7 // you entered into with Samsung.
8
9 using System;
10 using System.Runtime.InteropServices;
11 using Tizen.Location;
12
13 internal static partial class Interop
14 {
15     internal static partial class Locator
16     {
17         [DllImport(Libraries.Location, EntryPoint = "location_manager_create")]
18         public static extern int Create(int locationMethod, out IntPtr handle);
19
20         [DllImport(Libraries.Location, EntryPoint = "location_manager_destroy")]
21         public static extern int Destroy(IntPtr handle);
22
23         [DllImport(Libraries.Location, EntryPoint = "location_manager_start")]
24         public static extern int Start(IntPtr handle);
25
26         [DllImport(Libraries.Location, EntryPoint = "location_manager_stop")]
27         public static extern int Stop(IntPtr handle);
28
29         [DllImport(Libraries.Location, EntryPoint = "location_manager_enable_mock_location")]
30         public static extern int EnableMock(bool enable);
31
32         [DllImport(Libraries.Location, EntryPoint = "location_manager_set_mock_location")]
33         public static extern int SetMockLocation(IntPtr handle, double latitude, double longitude, double altitude, double speed, double direction, double accuracy);
34
35         [DllImport(Libraries.Location, EntryPoint = "location_manager_clear_mock_location")]
36         public static extern int ClearMock(IntPtr handle);
37
38         [DllImport(Libraries.Location, EntryPoint = "location_manager_get_method")]
39         public static extern int GetLocationType(IntPtr handle, out LocationType method);
40
41         [DllImport(Libraries.Location, EntryPoint = "location_manager_get_location")]
42         public static extern int GetLocation(IntPtr handle, out double altitude, out double latitude, out double longitude, out double climb, out double direction, out double speed, out LocationAccuracy level, out double horizontal, out double vertical, out int timestamp);
43
44         [DllImport(Libraries.Location, EntryPoint = "location_manager_get_last_location")]
45         public static extern int GetLastLocation(IntPtr handle, out double altitude, out double latitude, out double longitude, out double climb, out double direction, out double speed, out LocationAccuracy level, out double horizontal, out double vertical, out int timestamp);
46
47         [DllImport(Libraries.Location, EntryPoint = "location_manager_add_boundary")]
48         public static extern int AddBoundary(IntPtr managerHandle, IntPtr boundsHandle);
49
50         [DllImport(Libraries.Location, EntryPoint = "location_manager_remove_boundary")]
51         public static extern int RemoveBoundary(IntPtr managerHandle, IntPtr boundsHandle);
52     }
53
54     internal static partial class LocatorHelper\r
55     {\r
56         [DllImport(Libraries.Location, EntryPoint = "location_manager_is_enabled_method")]
57         public static extern int IsEnabled(int locationMethod, out bool status);
58
59         [DllImport(Libraries.Location, EntryPoint = "location_manager_is_supported_method")]
60         public static extern bool IsSupported(int locationMethod);\r
61     }
62
63     internal static partial class Location
64     {
65         [DllImport(Libraries.Location, EntryPoint = "location_manager_get_distance")]
66         public static extern int GetDistanceBetween(double startLatitude, double startLongitude, double endLatitude, double endLongitude, out double distance);
67     }
68
69     internal static partial class LocatorEvent
70     {
71         public delegate void ServiceStatechangedCallback(ServiceState state, IntPtr userData);
72         public delegate void ZonechangedCallback(BoundaryState state, double latitude, double longitude, double altitude, int timesatmp, IntPtr userData);
73         public delegate void SettingchangedCallback(LocationType method, bool enable, IntPtr userData);
74         public delegate void LocationchangedCallback(double latitude, double longitude, double altitude, double speed, double direction, double horizontalAcc, int timeStamp, IntPtr userData);
75         public delegate void LocationUpdatedCallback(LocationError error, double latitude, double longitude, double altitude, int timestamp, double speed, double direction, double climb, IntPtr userData);
76
77         [DllImport(Libraries.Location, EntryPoint = "location_manager_set_service_state_changed_cb")]
78         public static extern int SetServiceStateChangedCallback(IntPtr handle, ServiceStatechangedCallback callback, IntPtr userData);
79
80         [DllImport(Libraries.Location, EntryPoint = "location_manager_unset_service_state_changed_cb")]
81         public static extern int UnSetServiceStateChangedCallback(IntPtr handle);
82
83         [DllImport(Libraries.Location, EntryPoint = "location_manager_set_zone_changed_cb")]
84         public static extern int SetZoneChangedCallback(IntPtr handle, ZonechangedCallback callback, IntPtr userData);
85
86         [DllImport(Libraries.Location, EntryPoint = "location_manager_unset_zone_changed_cb")]
87         public static extern int UnSetZoneChangedCallback(IntPtr handle);
88
89         [DllImport(Libraries.Location, EntryPoint = "location_manager_set_setting_changed_cb")]
90         public static extern int SetSettingChangedCallback(int method, SettingchangedCallback callback, IntPtr userData);
91
92         [DllImport(Libraries.Location, EntryPoint = "location_manager_unset_setting_changed_cb")]
93         public static extern int UnSetSettingChangedCallback(int method);
94
95         [DllImport(Libraries.Location, EntryPoint = "location_manager_set_distance_based_location_changed_cb")]
96         public static extern int SetDistanceBasedLocationChangedCallback(IntPtr handle, LocationchangedCallback callback, int interval, double distance, IntPtr userData);
97
98         [DllImport(Libraries.Location, EntryPoint = "location_manager_unset_distance_based_location_changed_cb")]
99         public static extern int UnSetDistanceBasedLocationChangedCallback(IntPtr handle);
100
101         [DllImport(Libraries.Location, EntryPoint = "location_manager_set_location_changed_cb")]
102         public static extern int SetLocationChangedCallback(IntPtr handle, LocationchangedCallback callback, int interval, IntPtr userData);
103
104         [DllImport(Libraries.Location, EntryPoint = "location_manager_unset_location_changed_cb")]
105         public static extern int UnSetLocationChangedCallback(IntPtr handle);
106
107         [DllImport(Libraries.Location, EntryPoint = "location_manager_request_single_location")]
108         public static extern int GetSingleLocation(IntPtr handle, int timeout, LocationUpdatedCallback callback, IntPtr userData);
109     }
110
111     internal static partial class LocationBoundary
112     {
113         public delegate bool PolygonCoordinatesCallback(Coordinate coordinates, IntPtr userData);
114
115         [DllImport(Libraries.Location, EntryPoint = "location_bounds_create_rect")]
116         public static extern int CreateRectangularBoundary(Coordinate topLeft, Coordinate bottomLeft, out IntPtr boundsHandle);
117
118         [DllImport(Libraries.Location, EntryPoint = "location_bounds_create_circle")]
119         public static extern int CreateCircleBoundary(Coordinate center, double radius, out IntPtr boundsHandle);
120
121         [DllImport(Libraries.Location, EntryPoint = "location_bounds_create_polygon")]
122         public static extern int CreatePolygonBoundary(IntPtr list, int listLength, out IntPtr boundsHandle);
123
124         [DllImport(Libraries.Location, EntryPoint = "location_bounds_get_rect_coords")]
125         public static extern int GetRectangleCoordinates(IntPtr handle, out Coordinate topLeft, out Coordinate bottomRight);
126
127         [DllImport(Libraries.Location, EntryPoint = "location_bounds_get_circle_coords")]
128         public static extern int GetCircleCoordinates(IntPtr handle, out Coordinate center, out double radius);
129
130         [DllImport(Libraries.Location, EntryPoint = "location_bounds_foreach_polygon_coords")]
131         public static extern int GetForEachPolygonCoordinates(IntPtr handle, PolygonCoordinatesCallback callback, IntPtr userData);
132
133         [DllImport(Libraries.Location, EntryPoint = "location_bounds_contains_coordinates")]
134         public static extern bool IsValidCoordinates(IntPtr handle, Coordinate coordinate);
135
136         [DllImport(Libraries.Location, EntryPoint = "location_bounds_destroy")]
137         public static extern bool DestroyBoundary(IntPtr handle);
138     }
139
140     internal static partial class GpsSatellite
141     {
142         public delegate void SatelliteStatuschangedCallback(uint numActive, uint numInView, int timeStamp, IntPtr userData);
143         public delegate bool SatelliteStatusinfomationCallback(uint azimuth, uint elevation, uint prn, uint snr, bool isActive, IntPtr userData);
144
145         [DllImport(Libraries.Location, EntryPoint = "gps_status_get_nmea")]
146         public static extern int GetNMEAData(IntPtr handle, out string nmea);
147
148         [DllImport(Libraries.Location, EntryPoint = "gps_status_get_satellite")]
149         public static extern int GetSatelliteStatus(IntPtr handle, out uint numberOfActive, out uint numberInView, out int timestamp);
150
151         [DllImport(Libraries.Location, EntryPoint = "gps_status_set_satellite_updated_cb")]
152         public static extern int SetSatelliteStatusChangedCallback(IntPtr handle, SatelliteStatuschangedCallback callback, int interval, IntPtr userData);
153
154         [DllImport(Libraries.Location, EntryPoint = "gps_status_unset_satellite_updated_cb")]
155         public static extern int UnSetSatelliteStatusChangedCallback(IntPtr handle);
156
157         [DllImport(Libraries.Location, EntryPoint = "gps_status_foreach_satellites_in_view")]
158         public static extern int GetForEachSatelliteInView(IntPtr handle, SatelliteStatusinfomationCallback callback, IntPtr userData);
159     }
160
161     internal static DateTime ConvertDateTime(int timestamp)
162     {
163         DateTime dateTime = DateTime.Now;
164
165         DateTime start = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(timestamp), DateTimeKind.Utc);
166         dateTime = start.ToLocalTime();
167
168         return dateTime;
169     }
170 }