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_shutdown_f) (maps_plugin_h plugin);
31 typedef int (*maps_plugin_get_info_f) (maps_plugin_info_h *info);
33 /* Maps Provider access key, preference and capabilities */
34 typedef int (*maps_plugin_set_provider_key_f) (const char *provider_key);
35 typedef int (*maps_plugin_get_provider_key_f) (char **provider_key);
36 typedef int (*maps_plugin_set_preference_f) (maps_preference_h preference);
37 typedef int (*maps_plugin_get_preference_f) (maps_preference_h *preference);
38 typedef int (*maps_plugin_is_service_supported_f) (maps_service_e service,
40 typedef int (*maps_plugin_is_data_supported_f) (maps_service_data_e data,
44 typedef int (*maps_plugin_geocode_f) (const char *address,
45 const maps_preference_h preference,
46 maps_service_geocode_cb callback,
47 void *user_data, int *request_id);
48 typedef int (*maps_plugin_geocode_inside_area_f) (const char *address,
49 const maps_area_h bounds,
50 const maps_preference_h
52 maps_service_geocode_cb
56 typedef int (*maps_plugin_geocode_by_structured_address_f) (const maps_address_h
61 maps_service_geocode_cb
65 typedef int (*maps_plugin_reverse_geocode_f) (double latitude, double longitude,
66 const maps_preference_h
68 maps_service_reverse_geocode_cb
70 void *user_data, int *request_id);
73 typedef int (*maps_plugin_search_place_f) (const maps_coordinates_h position,
75 const maps_place_filter_h filter,
76 maps_preference_h preference,
77 maps_service_search_place_cb
79 void *user_data, int *request_id);
80 typedef int (*maps_plugin_search_place_by_area_f) (const maps_area_h boundary,
81 const maps_place_filter_h
83 maps_preference_h preference,
84 maps_service_search_place_cb
88 typedef int (*maps_plugin_search_place_by_address_f) (const char *address,
91 const maps_place_filter_h
95 maps_service_search_place_cb
101 typedef int (*maps_plugin_search_route_f) (const maps_coordinates_h origin,
102 const maps_coordinates_h destination,
103 maps_preference_h preference,
104 maps_service_search_route_cb
106 void *user_data, int *request_id);
107 typedef int (*maps_plugin_search_route_waypoints_f) (const maps_coordinates_h *
112 maps_service_search_route_cb
118 typedef int (*maps_plugin_cancel_request_f) (int request_id);
123 /* Plugin interface */
124 typedef struct _interface_s {
126 /* Plugin dedicated functions */
127 maps_plugin_init_f maps_plugin_init;
128 maps_plugin_shutdown_f maps_plugin_shutdown;
129 maps_plugin_get_info_f maps_plugin_get_info;
131 /* Maps Provider access key, preference and capabilities */
132 maps_plugin_set_provider_key_f maps_plugin_set_provider_key;
133 maps_plugin_get_provider_key_f maps_plugin_get_provider_key;
134 maps_plugin_set_preference_f maps_plugin_set_preference;
135 maps_plugin_get_preference_f maps_plugin_get_preference;
136 maps_plugin_is_service_supported_f
137 maps_plugin_is_service_supported;
138 maps_plugin_is_data_supported_f maps_plugin_is_data_supported;
141 maps_plugin_geocode_f maps_plugin_geocode;
142 maps_plugin_geocode_inside_area_f
143 maps_plugin_geocode_inside_area;
144 maps_plugin_geocode_by_structured_address_f
145 maps_plugin_geocode_by_structured_address;
146 maps_plugin_reverse_geocode_f maps_plugin_reverse_geocode;
149 maps_plugin_search_place_f maps_plugin_search_place;
150 maps_plugin_search_place_by_area_f
151 maps_plugin_search_place_by_area;
152 maps_plugin_search_place_by_address_f
153 maps_plugin_search_place_by_address;
156 maps_plugin_search_route_f maps_plugin_search_route;
157 maps_plugin_search_route_waypoints_f
158 maps_plugin_search_route_waypoints;
161 maps_plugin_cancel_request_f maps_plugin_cancel_request;
165 /* Plugin structure */
166 typedef struct _plugin_s {
167 interface_s interface; /* Plugin interface function pointers */
168 gpointer module; /* Plugin module pointer, GMod */
169 GAsyncQueue *request_queue; /* Queue of asynchronous requests */
170 GThread *thread; /* Request queue thread: there is
171 happening delivery of request from
174 /* Flag: is the plugin in use */
175 volatile bool is_working; /* It is discouraged to use this
177 /* probably, it must be exchanged with event dispite of
178 * performance trade-off */
180 /*maps_string_hashtable_h capabilities; // The table of plugin
183 GMutex pending_request_mutex; /* Mutex for synchronizing the
184 map of pending requests */
185 GHashTable *pending_request_maps; /* Map of pending
189 /* TODO: Refactor to encapsulate everithing in a single calss
191 typedef struct _GMod {
197 /* RAII Class implementing the mutex helper on the base of GLib mutex */
198 /* which automatically locks mutex during its creation and unlocks while
199 * exiting the scope */
203 scope_mutex(GMutex *m);
207 class binary_extractor {
210 virtual ~binary_extractor()
214 provider_info get_plugin_info(const string &file_name) const;
215 maps_plugin_h init(const provider_info &info);
216 void shutdown(maps_plugin_h plugin_h);
218 GMod *gmod_new(const string &module_file,
219 gboolean is_resident) const;
220 void gmod_free(GMod *gmod) const;
221 gpointer gmod_find_sym(GMod *gmod,
222 const gchar *func_name) const;
223 void trace_dbg(const plugin_s *plugin) const;
227 #endif /* __MAPS_SERVICE_PLUGIN_MODULE_H__ */