From: jomui Date: Mon, 26 Jun 2017 05:08:12 +0000 (+0900) Subject: add internal APIs for user consent X-Git-Tag: submit/tizen/20170704.105114^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94cfe7f5e5a1345e2e4371da16cf41900f3be4b3;p=platform%2Fcore%2Fapi%2Fmaps-service.git add internal APIs for user consent Signed-off-by: jomui Change-Id: I4c7955558b2084c537d34c34f0e5b313e7eaa84c --- diff --git a/include/maps_plugin.h b/include/maps_plugin.h index 80b92d0..07c49c4 100644 --- a/include/maps_plugin.h +++ b/include/maps_plugin.h @@ -23,6 +23,7 @@ #include #include #include +#include /** * diff --git a/include/maps_service_internal.h b/include/maps_service_internal.h new file mode 100644 index 0000000..018a279 --- /dev/null +++ b/include/maps_service_internal.h @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2014 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. + */ + +#ifndef __MAPS_SERVICE_INTERNAL_H__ +#define __MAPS_SERVICE_INTERNAL_H__ + + +/** + * @file maps_service_internal.h + * @brief This file contains the functions related to Maps API. + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @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] 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_with_handle() + */ +typedef void(*maps_service_request_user_consent_with_handle_cb) (bool consented, 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. + * A Maps Service handle is used to query Maps Provider performing services, such as Geocoding, Searching Places, and Routing. + * @since_tizen 4.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/mapservice \n + * %http://tizen.org/privilege/network.get + * @remarks @a maps service handle must be released using maps_service_destroy().\n + * Use maps_service_foreach_provider() to choose one of available Providers.\n + * Use maps_service_set_provider_key() to set provider's key.\n + * Use maps_service_set_preference() to set various options of Maps Provider.\n + * Use maps_service_provider_is_service_supported() and + * maps_service_provider_is_data_supported() to check the Maps Provider's capabilities. + * @param[in] maps_provider The name of Maps Provider + * @param[out] maps A handle of the new Maps Service on success + * @return @c 0 on success, + * otherwise a negative error value + * @retval #MAPS_ERROR_NONE Successful + * @retval #MAPS_ERROR_OUT_OF_MEMORY Out of memory + * @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 + * @retval #MAPS_ERROR_USER_NOT_CONSENTED The user did not consent + * @pre Call maps_service_foreach_provider() to get a available Maps Providers. + * @see maps_service_destroy() + * @see maps_service_request_user_consent_with_handle() + */ +int maps_service_create_without_user_consent(const char *maps_provider, maps_service_h *maps); + +/** + * @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_with_handle() 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_with_handle_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 4.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/mapservice + * @remarks Available map providers can be obtained with maps_service_foreach_provider(). + * @param[in] maps The Maps Service handle + * @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 @c 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_with_handle_cb() to provide information about user consent. + * @see maps_service_request_user_consent_with_handle_cb() + */ +int maps_service_request_user_consent_with_handle(const maps_service_h maps, maps_service_request_user_consent_with_handle_cb callback, void *user_data); + +/** + * @internal + * @brief Gets the user's consent to use maps service. + * @details This function gets the user's consent. + * @since_tizen 4.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/mapservice + * @param[in] maps The Maps Service handle + * @param[in] consented The value of User Consent + * @return 0 on success, otherwise a negative error value + * @retval #MAPS_ERROR_NONE Successful + * @retval #MAPS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MAPS_ERROR_NOT_SUPPORTED Not supported + * + * @see maps_service_set_user_consent() + */ +int maps_service_get_user_consent(const maps_service_h maps, bool *consent); + +/** + * @internal + * @brief Sets the user's consent to use maps service. + * @details This function sets the user's consent. + * @since_tizen 4.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/mapservice + * @param[in] maps The Maps Service handle + * @param[in] consented The value of User Consent + * @return 0 on success, otherwise a negative error value + * @retval #MAPS_ERROR_NONE Successful + * @retval #MAPS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MAPS_ERROR_NOT_SUPPORTED Not supported + * + * @see maps_service_get_user_consent() + */ +int maps_service_set_user_consent(const maps_service_h maps, bool consent); + +#ifdef __cplusplus +} +#endif +/** + * @} + */ +#endif /* __MAPS_SERVICE_INTERNAL_H__ */ diff --git a/src/api/maps_service.cpp b/src/api/maps_service.cpp index cb79665..c2f874b 100644 --- a/src/api/maps_service.cpp +++ b/src/api/maps_service.cpp @@ -20,6 +20,7 @@ #include "maps_service.h" #include "maps_util.h" #include "maps_condition.h" +#include "maps_service_internal.h" #include "command_queue.h" #include "commands.h" @@ -103,6 +104,61 @@ EXPORT_API int maps_service_request_user_consent(const char *maps_provider, return error; } +EXPORT_API int maps_service_request_user_consent_with_handle(const maps_service_h maps, + maps_service_request_user_consent_with_handle_cb callback, void *user_data) +{ + if (!maps_condition_check_maps_feature()) + return MAPS_ERROR_NOT_SUPPORTED; + /* Check if parameters are valid */ + if (!maps || !callback) + return MAPS_ERROR_INVALID_PARAMETER; + + /* Check if privileges enough */ + if (!maps_condition_check_privilege()) + return MAPS_ERROR_PERMISSION_DENIED; + + const plugin::plugin_s *p = __extract_plugin(maps); + if (!p) + return MAPS_ERROR_INVALID_PARAMETER; + return p->interface.maps_plugin_request_user_consent_with_handle(callback, user_data); +} + +EXPORT_API int maps_service_get_user_consent(const maps_service_h maps, bool *consent) +{ + if (!maps_condition_check_maps_feature()) + return MAPS_ERROR_NOT_SUPPORTED; + /* Check if parameters are valid */ + if (!maps || !consent) + return MAPS_ERROR_INVALID_PARAMETER; + + /* Check if privileges enough */ + if (!maps_condition_check_privilege()) + return MAPS_ERROR_PERMISSION_DENIED; + + const plugin::plugin_s *p = __extract_plugin(maps); + if (!p) + return MAPS_ERROR_INVALID_PARAMETER; + return p->interface.maps_plugin_get_user_consent(consent); +} + +EXPORT_API int maps_service_set_user_consent(const maps_service_h maps, bool consent) +{ + if (!maps_condition_check_maps_feature()) + return MAPS_ERROR_NOT_SUPPORTED; + /* Check if parameters are valid */ + if (!maps) + return MAPS_ERROR_INVALID_PARAMETER; + + /* Check if privileges enough */ + if (!maps_condition_check_privilege()) + return MAPS_ERROR_PERMISSION_DENIED; + + const plugin::plugin_s *p = __extract_plugin(maps); + if (!p) + return MAPS_ERROR_INVALID_PARAMETER; + return p->interface.maps_plugin_set_user_consent(consent); +} + EXPORT_API int maps_service_create(const char *maps_provider, maps_service_h *maps) { if (!maps_condition_check_maps_feature()) @@ -164,6 +220,26 @@ EXPORT_API int maps_service_create(const char *maps_provider, maps_service_h *ma return error; } +EXPORT_API int maps_service_create_without_user_consent(const char *maps_provider, maps_service_h *maps) +{ + if (!maps_condition_check_maps_feature()) + return MAPS_ERROR_NOT_SUPPORTED; + if (!maps || !maps_provider) + return MAPS_ERROR_INVALID_PARAMETER; + if (!maps_condition_check_privilege()) { + MAPS_LOGD("ERROR: privilege is not included"); + return MAPS_ERROR_PERMISSION_DENIED; + } + + char maps_provider_without_uc[MAPS_BASE_NAME_MAX_LEN] = ""; + snprintf(maps_provider_without_uc, MAPS_BASE_NAME_MAX_LEN, "%s/NOUC", maps_provider); + + int error = MAPS_ERROR_NONE; + error = maps_service_create(maps_provider_without_uc, maps); + return error; +} + + EXPORT_API int maps_service_destroy(maps_service_h maps) { if (!maps_condition_check_maps_feature()) diff --git a/src/plugin/discovery.h b/src/plugin/discovery.h index 5e45b8d..290750b 100644 --- a/src/plugin/discovery.h +++ b/src/plugin/discovery.h @@ -60,6 +60,8 @@ namespace plugin 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); + int get_user_consent(const char *maps_provider, bool *consent); + int set_user_consent(const char *maps_provider, bool consent); } #endif /* __MAPS_SERVICE_PLUGIN_DISCOVERY_H__ */ \ No newline at end of file diff --git a/src/plugin/empty_module.cpp b/src/plugin/empty_module.cpp index 1f87a8a..304d4f3 100644 --- a/src/plugin/empty_module.cpp +++ b/src/plugin/empty_module.cpp @@ -48,6 +48,23 @@ int maps_plugin_request_user_consent_empty(const char *provider, return 0; } + +int maps_plugin_request_user_consent_with_handle_empty(maps_service_request_user_consent_with_handle_cb callback, + void *user_data) +{ + return 0; +} + +int maps_plugin_get_user_consent_empty(bool *consent) +{ + return 0; +} + +int maps_plugin_set_user_consent_empty(bool consent) +{ + return 0; +} + /* Maps Provider access key, preference and capabilities */ int maps_plugin_set_provider_key_empty(const char *provider_key) { @@ -289,6 +306,9 @@ plugin::interface_s empty_interface = { maps_plugin_get_info_empty, maps_plugin_init_module_empty, maps_plugin_request_user_consent_empty, + maps_plugin_request_user_consent_with_handle_empty, + maps_plugin_get_user_consent_empty, + maps_plugin_set_user_consent_empty, maps_plugin_set_provider_key_empty, maps_plugin_get_provider_key_empty, diff --git a/src/plugin/module.cpp b/src/plugin/module.cpp index f5a8bf5..3495ba4 100644 --- a/src/plugin/module.cpp +++ b/src/plugin/module.cpp @@ -125,6 +125,15 @@ maps_plugin_h plugin::binary_extractor::init(const provider_info &info, new_plugin->interface.maps_plugin_request_user_consent = (maps_plugin_request_user_consent_f) gmod_find_sym(plugin, "maps_plugin_request_user_consent"); + new_plugin->interface.maps_plugin_request_user_consent_with_handle = + (maps_plugin_request_user_consent_with_handle_f) gmod_find_sym(plugin, + "maps_plugin_request_user_consent_with_handle"); + new_plugin->interface.maps_plugin_get_user_consent = + (maps_plugin_get_user_consent_f) gmod_find_sym(plugin, + "maps_plugin_get_user_consent"); + new_plugin->interface.maps_plugin_set_user_consent = + (maps_plugin_set_user_consent_f) gmod_find_sym(plugin, + "maps_plugin_set_user_consent"); /* Maps Provider access key, preference and capabilities */ new_plugin->interface.maps_plugin_set_provider_key = diff --git a/src/plugin/module.h b/src/plugin/module.h index 5e28f0b..7ddf3ef 100644 --- a/src/plugin/module.h +++ b/src/plugin/module.h @@ -33,6 +33,10 @@ 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); +typedef int (*maps_plugin_request_user_consent_with_handle_f) (maps_service_request_user_consent_with_handle_cb callback, + void *user_data); +typedef int (*maps_plugin_get_user_consent_f) (bool *consent); +typedef int (*maps_plugin_set_user_consent_f) (bool consent); /* Maps Provider access key, preference and capabilities */ typedef int (*maps_plugin_set_provider_key_f) (const char *provider_key); @@ -146,6 +150,9 @@ typedef struct _interface_s { 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_plugin_request_user_consent_with_handle_f maps_plugin_request_user_consent_with_handle; + maps_plugin_get_user_consent_f maps_plugin_get_user_consent; + maps_plugin_set_user_consent_f maps_plugin_set_user_consent; /* Maps Provider access key, preference and capabilities */ maps_plugin_set_provider_key_f maps_plugin_set_provider_key;