summaryrefslogtreecommitdiff
path: root/src/Tizen.Maps/Interop/Interop.Service.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Tizen.Maps/Interop/Interop.Service.cs')
-rwxr-xr-xsrc/Tizen.Maps/Interop/Interop.Service.cs195
1 files changed, 195 insertions, 0 deletions
diff --git a/src/Tizen.Maps/Interop/Interop.Service.cs b/src/Tizen.Maps/Interop/Interop.Service.cs
new file mode 100755
index 0000000..0cd154f
--- /dev/null
+++ b/src/Tizen.Maps/Interop/Interop.Service.cs
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal enum ServiceType
+ {
+ Geocode, // MAPS_SERVICE_GEOCODE
+ GeocodeInsideArea, // MAPS_SERVICE_GEOCODE_INSIDE_AREA
+ GeocodeByStructuredAddress, // MAPS_SERVICE_GEOCODE_BY_STRUCTURED_ADDRESS
+ ReverseGeocode, // MAPS_SERVICE_REVERSE_GEOCODE
+ SearchPlace, // MAPS_SERVICE_SEARCH_PLACE
+ SearchPlaceByArea, // MAPS_SERVICE_SEARCH_PLACE_BY_AREA
+ SearchPlaceByAddress, // MAPS_SERVICE_SEARCH_PLACE_BY_ADDRESS
+ SearchRoute, // MAPS_SERVICE_SEARCH_ROUTE
+ SearchRouteWaypoints, // MAPS_SERVICE_SEARCH_ROUTE_WAYPOINTS
+ CancelRequest, // MAPS_SERVICE_CANCEL_REQUEST
+ MultiReverseGeocode, // MAPS_SERVICE_MULTI_REVERSE_GEOCODE
+ SearchPlaceList, // MAPS_SERVICE_SEARCH_PLACE_LIST
+ SearchGetPlaceDetails, // MAPS_SERVICE_SEARCH_GET_PLACE_DETAILS
+ View = 0x100, // MAPS_SERVICE_VIEW
+ ViewSnapshot, // MAPS_SERVICE_VIEW_SNAPSHOT
+ }
+
+ internal enum ServiceData
+ {
+ PlaceAddress, // MAPS_PLACE_ADDRESS
+ PlaceRating, // MAPS_PLACE_RATING
+ PlaceCategories, // MAPS_PLACE_CATEGORIES
+ PlaceAttributes, // MAPS_PLACE_ATTRIBUTES
+ PlaceContacts, // MAPS_PLACE_CONTACTS
+ PlaceEditorials, // MAPS_PLACE_EDITORIALS
+ PlaceReviews, // MAPS_PLACE_REVIEWS
+ PlaceImage, // MAPS_PLACE_IMAGE
+ PlaceSupplier, // MAPS_PLACE_SUPPLIER
+ PlaceRelated, // MAPS_PLACE_RELATED
+ RoutePath, // MAPS_ROUTE_PATH
+ RouteSegmentsPath, // MAPS_ROUTE_SEGMENTS_PATH
+ RouteSegmentsManeuvers, // MAPS_ROUTE_SEGMENTS_MANEUVERS
+ ViewTraffic = 0x100, // MAPS_VIEW_TRAFFIC
+ ViewPublicTransit, // MAPS_VIEW_PUBLIC_TRANSIT
+ ViewBuilding, // MAPS_VIEW_BUILDING
+ ViewScaleBar, // MAPS_VIEW_SCALEBAR
+ }
+
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool GeocodeCallback(ErrorCode /* maps_error_e */ result, int requestId, int index, int total, IntPtr /* maps_coordinates_h */ coordinates, IntPtr /* void */ userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ReverseGeocodeCallback(ErrorCode /* maps_error_e */ result, int requestId, int index, int total, IntPtr /* maps_address_h */ address, IntPtr /* void */ userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool MultiReverseGeocodeCallback(ErrorCode /* maps_error_e */ result, int requestId, int total, IntPtr /* maps_address_list_h */ addressList, IntPtr /* void */ userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool SearchPlaceCallback(ErrorCode /* maps_error_e */ error, int requestId, int index, int total, IntPtr /* maps_place_h */ place, IntPtr /* void */ userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void SearchPlaceListCallback(ErrorCode /* maps_error_e */ error, int requestId, int total, IntPtr /* maps_place_list_h */ placeList, IntPtr /* void */ userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void GetPlaceDetailsCallback(ErrorCode /* maps_error_e */ error, int requestId, IntPtr /* maps_place_h */ place, IntPtr /* void */ userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool SearchRouteCallback(ErrorCode /* maps_error_e */ error, int requestId, int index, int total, IntPtr /* maps_route_h */ route, IntPtr /* void */ userData);
+
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_cancel_request")]
+ internal static extern ErrorCode CancelRequest(this ServiceHandle /* maps_service_h */ maps, int requestId);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_geocode")]
+ internal static extern ErrorCode Geocode(this ServiceHandle /* maps_service_h */ maps, string address, PreferenceHandle /* maps_preference_h */ preference, GeocodeCallback callback, IntPtr /* void */ userData, out int requestId);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_geocode_inside_area")]
+ internal static extern ErrorCode GeocodeInsideArea(this ServiceHandle /* maps_service_h */ maps, string address, AreaHandle /* maps_area_h */ bounds, PreferenceHandle /* maps_preference_h */ preference, GeocodeCallback callback, IntPtr /* void */ userData, out int requestId);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_geocode_by_structured_address")]
+ internal static extern ErrorCode GeocodeByStructuredAddress(this ServiceHandle /* maps_service_h */ maps, AddressHandle /* maps_address_h */ address, PreferenceHandle /* maps_preference_h */ preference, GeocodeCallback callback, IntPtr /* void */ userData, out int requestId);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_reverse_geocode")]
+ internal static extern ErrorCode ReverseGeocode(this ServiceHandle /* maps_service_h */ maps, double latitude, double longitude, PreferenceHandle /* maps_preference_h */ preference, ReverseGeocodeCallback callback, IntPtr /* void */ userData, out int requestId);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_multi_reverse_geocode")]
+ internal static extern ErrorCode MultiReverseGeocode(this ServiceHandle /* maps_service_h */ maps, CoordinatesListHandle /* maps_coordinates_list_h */ coordinatesList, PreferenceHandle /* maps_preference_h */ preference, MultiReverseGeocodeCallback callback, IntPtr /* void */ userData, out int requestId);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_search_place")]
+ internal static extern ErrorCode SearchPlace(this ServiceHandle /* maps_service_h */ maps, CoordinatesHandle /* maps_coordinates_h */ position, int distance, PlaceFilterHandle /* maps_place_filter_h */ filter, PreferenceHandle /* maps_preference_h */ preference, SearchPlaceCallback callback, IntPtr /* void */ userData, out int requestId);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_search_place_by_area")]
+ internal static extern ErrorCode SearchPlaceByArea(this ServiceHandle /* maps_service_h */ maps, AreaHandle /* maps_area_h */ boundary, PlaceFilterHandle /* maps_place_filter_h */ filter, PreferenceHandle /* maps_preference_h */ preference, SearchPlaceCallback callback, IntPtr /* void */ userData, out int requestId);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_search_place_by_address")]
+ internal static extern ErrorCode SearchPlaceByAddress(this ServiceHandle /* maps_service_h */ maps, string address, AreaHandle /* maps_area_h */ boundary, PlaceFilterHandle /* maps_place_filter_h */ filter, PreferenceHandle /* maps_preference_h */ preference, SearchPlaceCallback callback, IntPtr /* void */ userData, out int requestId);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_search_place_list")]
+ internal static extern ErrorCode SearchPlaceList(this ServiceHandle /* maps_service_h */ maps, AreaHandle /* maps_area_h */ boundary, PlaceFilterHandle /* maps_place_filter_h */ filter, PreferenceHandle /* maps_preference_h */ preference, SearchPlaceListCallback callback, IntPtr /* void */ userData, out int requestId);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_get_place_details")]
+ internal static extern ErrorCode GetPlaceDetails(this ServiceHandle /* maps_service_h */ maps, string uri, GetPlaceDetailsCallback callback, IntPtr /* void */ userData, out int requestId);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_search_route")]
+ internal static extern ErrorCode SearchRoute(this ServiceHandle /* maps_service_h */ maps, CoordinatesHandle /* maps_coordinates_h */ origin, CoordinatesHandle /* maps_coordinates_h */ destination, PreferenceHandle /* maps_preference_h */ preference, SearchRouteCallback callback, IntPtr /* void */ userData, out int requestId);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_search_route_waypoints")]
+ internal static extern ErrorCode SearchRouteWaypoints(this ServiceHandle /* maps_service_h */ maps, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] [In] IntPtr[] /* maps_coordinates_h */ waypointList, int waypointNum, PreferenceHandle /* maps_preference_h */ preference, SearchRouteCallback callback, IntPtr /* void */ userData, out int requestId);
+
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_set_provider_key")]
+ internal static extern ErrorCode SetProviderKey(this ServiceHandle /* maps_service_h */ maps, string providerKey);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_get_provider_key")]
+ internal static extern ErrorCode GetProviderKey(this ServiceHandle /* maps_service_h */ maps, out string providerKey);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_set_preference")]
+ internal static extern ErrorCode SetPreference(this ServiceHandle /* maps_service_h */ maps, PreferenceHandle /* maps_preference_h */ preference);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_get_preference")]
+ internal static extern ErrorCode GetPreference(this ServiceHandle /* maps_service_h */ maps, out IntPtr /* maps_preference_h */ preference);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_provider_is_service_supported")]
+ internal static extern ErrorCode IsServiceSupported(this ServiceHandle /* maps_service_h */ maps, ServiceType /* maps_service_e */ service, out bool supported);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_provider_is_data_supported")]
+ internal static extern ErrorCode IsDataSupported(this ServiceHandle /* maps_service_h */ maps, ServiceData /* maps_service_data_e */ data, out bool supported);
+
+ internal class ServiceHandle : SafeMapsHandle
+ {
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void RequestUserConsentCallback(bool consented, string provider, IntPtr /* void */ userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool ProviderInfoCallback(string mapsProvider, IntPtr /* void */ userData);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_request_user_consent")]
+ internal static extern ErrorCode RequestUserConsent(string provider, RequestUserConsentCallback callback, IntPtr /* void */ userData);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_foreach_provider")]
+ internal static extern ErrorCode ForeachProvider(ProviderInfoCallback callback, IntPtr /* void */ userData);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_create")]
+ internal static extern ErrorCode Create(string provider, out IntPtr /* maps_service_h */ maps);
+
+ [DllImport(Libraries.MapService, EntryPoint = "maps_service_destroy")]
+ internal static extern ErrorCode Destroy(IntPtr /* maps_service_h */ maps);
+
+ internal string ProviderKey
+ {
+ get { return NativeGet(this.GetProviderKey); }
+ set { NativeSet(this.SetProviderKey, value); }
+ }
+
+ internal PreferenceHandle Preferences
+ {
+ get { return NativeGet(this.GetPreference, PreferenceHandle.Create); }
+ set { NativeSet(this.SetPreference, value); }
+ }
+
+ public ServiceHandle(IntPtr handle, bool needToRelease) : base(handle, needToRelease, Destroy)
+ {
+ }
+
+ public ServiceHandle(string serviceProvider) : this(IntPtr.Zero, true)
+ {
+ Create(serviceProvider, out handle).ThrowIfFailed($"Failed to create native handle for {serviceProvider}");
+ }
+
+ internal static void ForeachProvider(Action<string> action)
+ {
+ ProviderInfoCallback callback = (provider, userData) =>
+ {
+ action(provider);
+ return true;
+ };
+
+ ForeachProvider(callback, IntPtr.Zero).WarnIfFailed("Failed to get provider list from native handle");
+ }
+ }
+}