2 * Copyright (c) 2014 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.
17 #ifndef __MAPS_SERVICE_PLUGIN_MODULE_H__
18 #define __MAPS_SERVICE_PLUGIN_MODULE_H__
20 #include "maps_plugin.h"
21 #include "discovery.h"
25 /* ------------------------------------------------------------------------- */
27 * Plugin dedicated functions
29 typedef int (*maps_plugin_init_f) (maps_plugin_h *plugin);
30 typedef int (*maps_plugin_init_module_f) (maps_plugin_h *plugin, const char *module);
31 typedef int (*maps_plugin_shutdown_f) (maps_plugin_h plugin);
32 typedef int (*maps_plugin_get_info_f) (maps_plugin_info_h *info);
33 typedef int (*maps_plugin_request_user_consent_f) (const char *provider,
34 maps_service_request_user_consent_cb callback,
37 /* Maps Provider access key, preference and capabilities */
38 typedef int (*maps_plugin_set_provider_key_f) (const char *provider_key);
39 typedef int (*maps_plugin_get_provider_key_f) (char **provider_key);
40 typedef int (*maps_plugin_set_preference_f) (maps_preference_h preference);
41 typedef int (*maps_plugin_get_preference_f) (maps_preference_h *preference);
42 typedef int (*maps_plugin_is_service_supported_f) (maps_service_e service, bool *supported);
43 typedef int (*maps_plugin_is_data_supported_f) (maps_service_data_e data, bool *supported);
46 typedef int (*maps_plugin_geocode_f) (const char *address,
47 const maps_preference_h preference,
48 maps_service_geocode_cb callback,
49 void *user_data, int *request_id);
50 typedef int (*maps_plugin_geocode_inside_area_f) (const char *address,
51 const maps_area_h bounds,
52 const maps_preference_h preference,
53 maps_service_geocode_cb callback,
56 typedef int (*maps_plugin_geocode_by_structured_address_f) (const maps_address_h address,
57 const maps_preference_h preference,
58 maps_service_geocode_cb callback,
61 typedef int (*maps_plugin_reverse_geocode_f) (double latitude, double longitude,
62 const maps_preference_h preference,
63 maps_service_reverse_geocode_cb callback,
64 void *user_data, int *request_id);
65 typedef int (*maps_plugin_multi_reverse_geocode_f) (const maps_coordinates_list_h maps_list,
66 const maps_preference_h preference,
67 maps_service_multi_reverse_geocode_cb callback,
68 void *user_data, int *request_id);
71 typedef int (*maps_plugin_search_place_f) (const maps_coordinates_h position,
73 const maps_place_filter_h filter,
74 maps_preference_h preference,
75 maps_service_search_place_cb callback,
76 void *user_data, int *request_id);
77 typedef int (*maps_plugin_search_place_by_area_f) (const maps_area_h boundary,
78 const maps_place_filter_h filter,
79 maps_preference_h preference,
80 maps_service_search_place_cb callback,
83 typedef int (*maps_plugin_search_place_by_address_f) (const char *address,
84 const maps_area_h boundary,
85 const maps_place_filter_h filter,
86 maps_preference_h preference,
87 maps_service_search_place_cb callback,
90 typedef int (*maps_plugin_search_place_list_f) (const maps_area_h boundary,
91 const maps_place_filter_h filter,
92 maps_preference_h preference,
93 maps_service_search_place_list_cb callback,
94 void *user_data, int *request_id);
95 typedef int (*maps_plugin_get_place_details_f) (const char *url,
96 maps_service_get_place_details_cb callback,
97 void *user_data, int *request_id);
100 typedef int (*maps_plugin_search_route_f) (const maps_coordinates_h origin,
101 const maps_coordinates_h destination,
102 maps_preference_h preference,
103 maps_service_search_route_cb callback,
104 void *user_data, int *request_id);
105 typedef int (*maps_plugin_search_route_waypoints_f) (const maps_coordinates_h * waypoint_list,
107 maps_preference_h preference,
108 maps_service_search_route_cb callback,
113 typedef int (*maps_plugin_cancel_request_f) (int request_id);
116 typedef int (*maps_plugin_create_map_view_f) (maps_view_h view,
117 maps_plugin_map_view_ready_cb callback);
118 typedef int (*maps_plugin_destroy_map_view_f) (maps_view_h view);
119 typedef int (*maps_plugin_render_map_f) (maps_view_h view,
120 const maps_coordinates_h coordinates,
121 double zoom_factor, double rotation_angle);
122 typedef int (*maps_plugin_move_center_f) (maps_view_h view, int delta_x, int delta_y);
123 typedef int (*maps_plugin_set_scalebar_f) (maps_view_h view, bool enable);
124 typedef int (*maps_plugin_get_scalebar_f) (maps_view_h view, bool *enabled);
125 typedef int (*maps_plugin_on_object_f) (maps_view_h view, const maps_view_object_h object,
126 maps_view_object_operation_e operation);
127 typedef int (*maps_plugin_screen_to_geography_f) (maps_view_h view, int x, int y,
128 maps_coordinates_h* coordinates);
129 typedef int (*maps_plugin_geography_to_screen_f) (maps_view_h view,
130 const maps_coordinates_h coordinates, int* x, int* y);
131 typedef int (*maps_plugin_get_min_zoom_level_f) (maps_view_h view, int *min_zoom_level);
132 typedef int (*maps_plugin_get_max_zoom_level_f) (maps_view_h view, int *max_zoom_level);
133 typedef int (*maps_plugin_get_center_f) (maps_view_h view, maps_coordinates_h *coordinates);
134 typedef int (*maps_plugin_capture_snapshot_f) (maps_view_h view, void **data,
135 int *width, int *height, maps_view_colorspace_type_e *cs);
136 typedef int (*maps_plugin_get_view_scale_factor_f) (maps_view_h view, double *scale_factor);
137 typedef int (*maps_plugin_set_view_scale_factor_f) (maps_view_h view, double scale_factor);
141 /* Plugin interface */
142 typedef struct _interface_s {
143 /* Plugin dedicated functions */
144 maps_plugin_init_f maps_plugin_init;
145 maps_plugin_shutdown_f maps_plugin_shutdown;
146 maps_plugin_get_info_f maps_plugin_get_info;
147 maps_plugin_init_module_f maps_plugin_init_module;
148 maps_plugin_request_user_consent_f maps_plugin_request_user_consent;
150 /* Maps Provider access key, preference and capabilities */
151 maps_plugin_set_provider_key_f maps_plugin_set_provider_key;
152 maps_plugin_get_provider_key_f maps_plugin_get_provider_key;
153 maps_plugin_set_preference_f maps_plugin_set_preference;
154 maps_plugin_get_preference_f maps_plugin_get_preference;
155 maps_plugin_is_service_supported_f maps_plugin_is_service_supported;
156 maps_plugin_is_data_supported_f maps_plugin_is_data_supported;
159 maps_plugin_geocode_f maps_plugin_geocode;
160 maps_plugin_geocode_inside_area_f maps_plugin_geocode_inside_area;
161 maps_plugin_geocode_by_structured_address_f maps_plugin_geocode_by_structured_address;
162 maps_plugin_reverse_geocode_f maps_plugin_reverse_geocode;
163 maps_plugin_multi_reverse_geocode_f maps_plugin_multi_reverse_geocode;
166 maps_plugin_search_place_f maps_plugin_search_place;
167 maps_plugin_search_place_by_area_f maps_plugin_search_place_by_area;
168 maps_plugin_search_place_by_address_f maps_plugin_search_place_by_address;
169 maps_plugin_search_place_list_f maps_plugin_search_place_list;
170 maps_plugin_get_place_details_f maps_plugin_get_place_details;
173 maps_plugin_search_route_f maps_plugin_search_route;
174 maps_plugin_search_route_waypoints_f maps_plugin_search_route_waypoints;
177 maps_plugin_cancel_request_f maps_plugin_cancel_request;
180 maps_plugin_create_map_view_f maps_plugin_create_map_view;
181 maps_plugin_destroy_map_view_f maps_plugin_destroy_map_view;
182 maps_plugin_render_map_f maps_plugin_render_map;
183 maps_plugin_move_center_f maps_plugin_move_center;
184 maps_plugin_set_scalebar_f maps_plugin_set_scalebar;
185 maps_plugin_get_scalebar_f maps_plugin_get_scalebar;
186 maps_plugin_on_object_f maps_plugin_on_object;
187 maps_plugin_screen_to_geography_f maps_plugin_screen_to_geography;
188 maps_plugin_geography_to_screen_f maps_plugin_geography_to_screen;
189 maps_plugin_get_min_zoom_level_f maps_plugin_get_min_zoom_level;
190 maps_plugin_get_max_zoom_level_f maps_plugin_get_max_zoom_level;
191 maps_plugin_get_center_f maps_plugin_get_center;
192 maps_plugin_capture_snapshot_f maps_plugin_capture_snapshot;
193 maps_plugin_get_view_scale_factor_f maps_plugin_get_view_scale_factor;
194 maps_plugin_set_view_scale_factor_f maps_plugin_set_view_scale_factor;
197 /* Plugin structure */
198 typedef struct _plugin_s {
199 interface_s interface; /* Plugin interface function pointers */
200 gpointer module; /* Plugin module pointer, GMod */
201 GAsyncQueue *request_queue; /* Queue of asynchronous requests */
202 GThread *thread; /* Request queue thread: there is
203 happening delivery of request from app to plugin */
205 /* Flag: is the plugin in use */
206 volatile bool is_working; /* It is discouraged to use this approach */
207 /* probably, it must be exchanged with event dispite of performance trade-off */
209 /*maps_int_hashtable_h capabilities; */ /* The table of plugin capabilities */
211 GMutex pending_request_mutex; /* Mutex for synchronizing the
212 map of pending requests */
213 GHashTable *pending_request_maps; /* Map of pending requests */
216 /* TODO: Refactor to encapsulate everything in a single calss
218 typedef struct _GMod {
224 /* RAII Class implementing the mutex helper on the base of GLib mutex */
225 /* which automatically locks mutex during its creation and unlocks while
226 * exiting the scope */
231 scope_mutex(GMutex *m);
235 class binary_extractor {
238 virtual ~binary_extractor() {}
240 provider_info get_plugin_info(const string &file_name) const;
241 maps_plugin_h init(const provider_info &info, const char *module, int *init_error);
242 void shutdown(maps_plugin_h plugin_h);
245 GMod *gmod_new(const string &module_file, gboolean is_resident) const;
246 void gmod_free(GMod *gmod) const;
247 gpointer gmod_find_sym(GMod *gmod, const gchar *func_name) const;
248 void trace_dbg(const plugin_s *plugin) const;
251 class user_consent_checker : public binary_extractor {
253 user_consent_checker();
254 virtual ~user_consent_checker() {}
255 maps_plugin_h init(const provider_info &info, const char *module, int *init_error);
256 void shutdown(maps_plugin_h plugin_h);
261 #endif /* __MAPS_SERVICE_PLUGIN_MODULE_H__ */