MAPS_ERROR_UNKNOWN =
TIZEN_ERROR_UNKNOWN, /**< Unknown error */
+ MAPS_ERROR_USER_NOT_CONSENTED =
+ TIZEN_ERROR_USER_NOT_CONSENTED, /**< Not Consented (Since @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif) */
+
MAPS_ERROR_SERVICE_NOT_AVAILABLE =
TIZEN_ERROR_MAPS_SERVICE | 0x01,/**< Service unavailable */
MAPS_SERVICE_SEARCH_PLACE_BY_AREA, /**< Indicates that maps_service_search_place_by_area() service is allowed */
MAPS_SERVICE_SEARCH_PLACE_BY_ADDRESS, /**< Indicates that maps_service_search_place_by_address() service is allowed */
MAPS_SERVICE_SEARCH_ROUTE, /**< Indicates that maps_service_search_route() service is allowed */
- MAPS_SERVICE_SEARCH_ROUTE_WAYPOINTS, /**< Indicates that maps_service_search_route_waypoints() service is allowed */
+ MAPS_SERVICE_SEARCH_ROUTE_WAYPOINTS, /**< Indicates that maps_service_search_route_waypoints() service is allowed */
MAPS_SERVICE_CANCEL_REQUEST, /**< Indicates that maps_service_cancel_request() service is allowed */
MAPS_SERVICE_MULTI_REVERSE_GEOCODE, /**< Indicates that maps_service_multi_reverse_geocode() service is allowed @if MOBILE (Since 3.0) @endif */
MAPS_SERVICE_SEARCH_PLACE_LIST, /**< Indicates that maps_service_search_place_list() service is allowed @if MOBILE (Since 3.0) @endif */
void *user_data);
/**
+ * @brief Called with the information about user's consent.
+ * @details The Maps Service invokes this callback when the information about user's consent is obtained.
+ * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
+ *
+ * @param[in] consented The value of User Consent
+ * @param[in] maps_provider The name of Maps Provider
+ * @param[in] user_data The user data passed from maps_service_request_user_consent()
+ *
+ * @pre maps_service_request_user_consent() will invoke this callback.
+ *
+ * @see maps_service_request_user_consent()
+ * @see maps_service_create()
+ */
+typedef void(*maps_service_request_user_consent_cb) (bool consented,
+ const char *maps_provider, void *user_data);
+
+/**
+ * @brief Gets the user's consent to use maps data.
+ * @details The function gets information whether the user agreed that the application can use maps data.
+ * If maps_service_request_user_consent() is called when the user didn't agree yet, a popup is shown and
+ * the user can decide whether to agree or not. Then the result is saved and maps_service_request_user_consent_cb()
+ * is called. If the user has already agreed, the popup is not shown and only the callback is called.
+ * The request is asynchronous.
+ * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/mapservice
+ *
+ * @remarks Available map providers can be obtained with maps_service_foreach_provider().
+ *
+ * @param[in] maps_provider The name of Maps Provider
+ * @param[in] callback The callback which receives the user's consent decision
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value
+
+ * @retval #MAPS_ERROR_NONE Successful
+ * @retval #MAPS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MAPS_ERROR_SERVICE_NOT_AVAILABLE Service not available
+ * @retval #MAPS_ERROR_NOT_SUPPORTED Not supported
+ * @retval #MAPS_ERROR_PERMISSION_DENIED Permission Denied
+ *
+ * @post This function invokes maps_service_request_user_consent_cb() to provide information
+ * about user consent.
+ *
+ * @see maps_service_foreach_provider()
+ * @see maps_service_request_user_consent_cb()
+ * @see maps_service_create()
+ */
+int maps_service_request_user_consent(const char *maps_provider,
+ maps_service_request_user_consent_cb callback, void *user_data);
+
+/**
* @brief Creates a new Maps Service and assigns it with a handle.
* @details While Maps Service is being created, a Maps Provider is initialized
* and linked with Maps Service handle.
* @retval #MAPS_ERROR_SERVICE_NOT_AVAILABLE Service not available
* @retval #MAPS_ERROR_NOT_SUPPORTED Not supported
* @retval #MAPS_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #MAPS_ERROR_USER_NOT_CONSENTED The user did not consent
*
* @pre Call maps_service_foreach_provider() to get a available Maps Providers.
*
return MAPS_ERROR_NONE;
}
+EXPORT_API int maps_service_request_user_consent(const char *maps_provider,
+ maps_service_request_user_consent_cb callback, void *user_data)
+{
+ if (!maps_condition_check_maps_feature())
+ return MAPS_ERROR_NOT_SUPPORTED;
+ /* Check if parameters are valid */
+ if (!maps_provider || !callback)
+ return MAPS_ERROR_INVALID_PARAMETER;
+
+ /* Check if privileges enough */
+ if (!maps_condition_check_privilege())
+ return MAPS_ERROR_PERMISSION_DENIED;
+
+ int error = plugin::request_user_consent(maps_provider, (void*)callback, user_data);
+ return error;
+}
+
EXPORT_API int maps_service_create(const char *maps_provider, maps_service_h *maps)
{
if (!maps_condition_check_maps_feature())
evas_object_show(v->panel);
else
evas_object_hide(v->panel);
+
+ /* Equal size of a panel object and a parent object */
+ int x, y, w, h;
+ evas_object_geometry_get(v->parent, &x, &y, &w, &h);
+ evas_object_move(v->panel, x, y);
+ evas_object_resize(v->panel, w, h);
+ evas_object_image_fill_set(v->panel, 0, 0, w, h);
}
evas_object_image_filled_set(v->panel, EINA_FALSE);
}
v->screen_dpi = maps_get_display_dpi();
v->min_hit_area = MAX(20, v->screen_dpi / 5);
+ /* Update map view */
+ __maps_view_set_center(v, v->center, TRUE);
+
return MAPS_ERROR_NONE;
}
void plugin::split_provider_name(const char *original, char **provider, char **module)
{
char *save, *_provider, *_module;
-
+
_provider = strtok_r(g_strdup(original), "/", &save);
_module = g_strdup(strtok_r(NULL, "", &save));
g_free(_provider);
g_free(_module);
}
+
+
+typedef struct
+{
+ maps_service_request_user_consent_cb callback;
+ char *provider;
+ void *user_data;
+ void *plugin;
+} user_consent_s;
+
+gboolean user_consent_shutdown(gpointer data)
+{
+ MAPS_LOGD("data = %p", data);
+ if (!data) return false;
+
+ user_consent_s *uc = (user_consent_s*)data;
+ plugin::user_consent_checker().shutdown(uc->plugin);
+ g_free(uc->provider);
+ g_free(uc);
+ return false;
+}
+
+void plugin::user_consent_cb(bool consented, const char *provider, void *user_data)
+{
+ MAPS_LOGE("user_consent_cb is called");
+ user_consent_s *uc = (user_consent_s*)user_data;
+ if (uc && uc->callback)
+ uc->callback(consented, provider, uc->user_data);
+ g_idle_add(user_consent_shutdown, (void*)uc);
+}
+
+int plugin::request_user_consent(const char *maps_provider, void *callback, void *user_data)
+{
+ if (!maps_provider || !callback)
+ return MAPS_ERROR_INVALID_PARAMETER;
+
+ char *provider = NULL, *module = NULL;
+ plugin::split_provider_name(maps_provider, &provider, &module);
+ const plugin::provider_info info = plugin::find_by_names(provider);
+
+ /* 1. initialize the requested plugin */
+ int error = MAPS_ERROR_SERVICE_NOT_AVAILABLE;
+ int init_error = MAPS_ERROR_NONE; /* Storage for init error code */
+ plugin_s *plugin_handle = (plugin_s*)plugin::user_consent_checker().init(info, module, &init_error);
+ g_free(provider);
+ g_free(module);
+ if (!plugin_handle) {
+ MAPS_LOGE("ERROR! Plugin init failed");
+ return init_error;
+ }
+
+ /* 2. request user consent */
+ user_consent_s *uc = NULL;
+ if (plugin_handle->interface.maps_plugin_request_user_consent) {
+ uc = (user_consent_s*)g_malloc0(sizeof(user_consent_s));
+ if (!uc) {
+ error = MAPS_ERROR_OUT_OF_MEMORY;
+ } else {
+ uc->callback = (maps_service_request_user_consent_cb)callback;
+ uc->provider = g_strdup(maps_provider);
+ uc->user_data = user_data;
+ uc->plugin = plugin_handle;
+ error = plugin_handle->interface.maps_plugin_request_user_consent(
+ (const char*)uc->provider, user_consent_cb, (void*)uc);
+ MAPS_LOGD("maps_plugin_request_user_consent = %d", error);
+ if (error == MAPS_ERROR_USER_NOT_CONSENTED)
+ error = MAPS_ERROR_NONE;
+ }
+ }
+
+ /* 3. shutdown plugin */
+ if (error != MAPS_ERROR_NONE) {
+ plugin::user_consent_checker().shutdown(plugin_handle);
+ if (uc) {
+ g_free(uc->provider);
+ g_free(uc);
+ }
+ }
+
+ return error;
+}
provider_info find_by_names(const string &provider);
void split_provider_name(const char *original, char **provider, char **module);
+
+ void user_consent_cb(bool consented, const char *provider, void *user_data);
+ int request_user_consent(const char *maps_provider, void* callback, void *user_data);
}
#endif /* __MAPS_SERVICE_PLUGIN_DISCOVERY_H__ */
\ No newline at end of file
return 0;
}
+int maps_plugin_request_user_consent_empty(const char *provider,
+ maps_service_request_user_consent_cb callback,
+ void *user_data)
+{
+ return 0;
+}
+
/* Maps Provider access key, preference and capabilities */
int maps_plugin_set_provider_key_empty(const char *provider_key)
{
maps_plugin_shutdown_empty,
maps_plugin_get_info_empty,
maps_plugin_init_module_empty,
+ maps_plugin_request_user_consent_empty,
maps_plugin_set_provider_key_empty,
maps_plugin_get_provider_key_empty,
new_plugin->interface.maps_plugin_get_info =
(maps_plugin_get_info_f) gmod_find_sym(plugin,
"maps_plugin_get_info");
+ new_plugin->interface.maps_plugin_request_user_consent =
+ (maps_plugin_request_user_consent_f) gmod_find_sym(plugin,
+ "maps_plugin_request_user_consent");
/* Maps Provider access key, preference and capabilities */
new_plugin->interface.maps_plugin_set_provider_key =
itf->maps_plugin_capture_snapshot);
MAPS_LOGD("*********************************************");
}
+
+plugin::user_consent_checker::user_consent_checker()
+{
+}
+
+maps_plugin_h plugin::user_consent_checker::init(const provider_info &info,
+ const char *module, int *init_error)
+{
+ /* 1.Initialize plugin */
+ if (info.file.empty() || !init_error) {
+ if (init_error)
+ *init_error = MAPS_ERROR_NOT_SUPPORTED;
+ return NULL;
+ }
+
+ *init_error = MAPS_ERROR_NONE;
+
+ GMod *plugin = gmod_new(info.file, TRUE);
+ if (!plugin) {
+ MAPS_LOGE("Open Module Failed: %s", info.file.c_str());
+ *init_error = MAPS_ERROR_SERVICE_NOT_AVAILABLE;
+ return NULL;
+ }
+
+ /* 2.1 Create new plugin interface */
+ plugin_s* new_plugin = g_slice_new0(plugin_s);
+
+ /* 2. Perform steps to completely initialize a plugin */
+ do {
+ if (!new_plugin) {
+ MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
+ *init_error = MAPS_ERROR_OUT_OF_MEMORY;
+ break;
+ }
+
+ /* 2.1 Set plugin module handle */
+ new_plugin->module = plugin;
+
+ /* 2.2 Set plugin interface */
+ new_plugin->interface = get_empty_interface();
+
+ /* Plugin dedicated functions */
+ new_plugin->interface.maps_plugin_request_user_consent =
+ (maps_plugin_request_user_consent_f) gmod_find_sym(plugin,
+ "maps_plugin_request_user_consent");
+
+ if (!new_plugin->interface.maps_plugin_request_user_consent) {
+ MAPS_LOGE("ERROR! Plugin request_user_consent function is NULL");
+ *init_error = MAPS_ERROR_SERVICE_NOT_AVAILABLE;
+ break;
+ }
+
+ /* 2.5 Return newly initialized plugin */
+ return new_plugin;
+ } while (FALSE);
+
+ MAPS_LOGE("Shut down the plugin becuause of error");
+
+ /* 3. shutdown plugin in case of problem */
+ shutdown(new_plugin);
+ return NULL;
+}
+
+void plugin::user_consent_checker::shutdown(maps_plugin_h plugin_h)
+{
+ if (!plugin_h)
+ return;
+ plugin_s *plugin = (plugin_s *) plugin_h;
+ g_return_if_fail(plugin->module);
+
+ /* 4. Unload plugin from memory */
+ gmod_free((GMod *) plugin->module);
+
+ /* 5. Destroying the table with plugin capabilities */
+ /*maps_int_hashtable_destroy(plugin->capabilities); */
+
+ /* 6. Release memory used by plugin structure */
+ g_slice_free(plugin_s, plugin);
+}
typedef int (*maps_plugin_init_module_f) (maps_plugin_h *plugin, const char *module);
typedef int (*maps_plugin_shutdown_f) (maps_plugin_h plugin);
typedef int (*maps_plugin_get_info_f) (maps_plugin_info_h *info);
+typedef int (*maps_plugin_request_user_consent_f) (const char *provider,
+ maps_service_request_user_consent_cb callback,
+ void *user_data);
/* Maps Provider access key, preference and capabilities */
typedef int (*maps_plugin_set_provider_key_f) (const char *provider_key);
maps_plugin_shutdown_f maps_plugin_shutdown;
maps_plugin_get_info_f maps_plugin_get_info;
maps_plugin_init_module_f maps_plugin_init_module;
+ maps_plugin_request_user_consent_f maps_plugin_request_user_consent;
/* Maps Provider access key, preference and capabilities */
maps_plugin_set_provider_key_f maps_plugin_set_provider_key;
provider_info get_plugin_info(const string &file_name) const;
maps_plugin_h init(const provider_info &info, const char *module, int *init_error);
void shutdown(maps_plugin_h plugin_h);
-private:
+//private:
+protected:
GMod *gmod_new(const string &module_file, gboolean is_resident) const;
void gmod_free(GMod *gmod) const;
gpointer gmod_find_sym(GMod *gmod, const gchar *func_name) const;
void trace_dbg(const plugin_s *plugin) const;
};
+
+class user_consent_checker : public binary_extractor {
+public:
+ user_consent_checker();
+ virtual ~user_consent_checker() {}
+ maps_plugin_h init(const provider_info &info, const char *module, int *init_error);
+ void shutdown(maps_plugin_h plugin_h);
+};
};
#endif /* __MAPS_SERVICE_PLUGIN_MODULE_H__ */