added to check privilege of new public APIs 38/77738/1
authorchanywa <cbible.kim@samsung.com>
Fri, 1 Jul 2016 01:21:36 +0000 (10:21 +0900)
committerchanywa <cbible.kim@samsung.com>
Fri, 1 Jul 2016 01:21:36 +0000 (10:21 +0900)
Change-Id: I4fcbfadb19e5de6b0ceb70d65a02520da7acc7d1

CMakeLists.txt
capi-maps-service.pc.in
packaging/capi-maps-service.spec
src/api/maps_condition.cpp [new file with mode: 0644]
src/api/maps_condition.h [new file with mode: 0644]
src/api/maps_service.cpp
src/api/maps_view.cpp
src/api/maps_view_snapshot.cpp

index 6c56316..43ecd82 100644 (file)
@@ -31,8 +31,19 @@ SET(dependents
        cairo
        elementary
        capi-media-image-util
+)
+
+IF(${TIZEN_VER} LESS 300)
+       SET(dependents
+               ${dependents}
+               # Privilege check
+               capi-appfw-app-manager
+               pkgmgr-info
+               capi-security-privilege-manager
        )
-SET(pc_dependents "capi-base-common")
+ENDIF(${TIZEN_VER} LESS 300)
+
+SET(pc_dependents "capi-base-common evas")
 
 INCLUDE(FindPkgConfig)
 pkg_check_modules(${fw_name} REQUIRED ${dependents})
@@ -40,11 +51,9 @@ FOREACH(flag ${${fw_name}_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -g -fdump-rtl-expand")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fvisibility=hidden -fvisibility-inlines-hidden")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 
-#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -g -fPIC -fdump-rtl-expand -std=c++0x")
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fvisibility=hidden")
 SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
 
@@ -52,6 +61,11 @@ IF("${ARCH}" STREQUAL "arm")
        ADD_DEFINITIONS("-DTARGET")
 ENDIF("${ARCH}" STREQUAL "arm")
 
+IF("${PROFILE}" STREQUAL "wearable")
+       ADD_DEFINITIONS("-DTIZEN_WEARABLE")
+ENDIF("${PROFILE}" STREQUAL "wearable")
+
+ADD_DEFINITIONS("-DTIZEN_VER=${TIZEN_VER}")
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DEXPORT_API=__attribute__((visibility(\"default\")))")
 #ADD_DEFINITIONS("-DTIZEN_DEBUG")
@@ -72,7 +86,7 @@ SET_TARGET_PROPERTIES(${fw_name}
        VERSION ${FULLVER}
        SOVERSION ${MAJORVER}
        CLEAN_DIRECT_OUTPUT 1
-       )
+)
 
 INSTALL(TARGETS ${fw_name} DESTINATION ${LIBDIR})
 INSTALL(
@@ -81,7 +95,7 @@ INSTALL(
        # *_plugin.h" are needed by plugin
        #        PATTERN "*_plugin.h" EXCLUDE
        PATTERN "${INC_DIR}/*.h"
-       )
+)
 
 SET(PC_NAME ${fw_name})
 SET(PC_DESCRIPTION "Tizen Maps Library")
@@ -93,5 +107,5 @@ CONFIGURE_FILE(
        ${fw_name}.pc.in
        ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
        @ONLY
-       )
+)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIBDIR}/pkgconfig)
index 674627c..152508c 100644 (file)
@@ -8,7 +8,7 @@ includedir=@PC_INCLUDE@
 Name: @PC_NAME@
 Description: @PC_DESCRIPTION@
 Version: @VERSION@
-Requires: evas
+Requires: @PC_REQUIRED@
 Libs: -L${libdir} @PC_LDFLAGS@
-Cflags: -I${includedir}
+Cflags: -I${includedir} @PC_CFLAGS@
 
index a1a6b70..3b36de0 100644 (file)
@@ -9,22 +9,22 @@ Source0:    %{name}-%{version}.tar.gz
 BuildRequires:  cmake
 
 # Maps API dependencies
-BuildRequires:  pkgconfig(glib-2.0)
-BuildRequires:  pkgconfig(gmodule-2.0)
-BuildRequires:  pkgconfig(capi-base-common)
-BuildRequires:  pkgconfig(dlog)
-BuildRequires:  pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gmodule-2.0)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(capi-system-info)
 
 # Mapping API dependencies
-BuildRequires:  pkgconfig(eina)
-BuildRequires:  pkgconfig(evas)
-BuildRequires:  pkgconfig(ecore)
-BuildRequires: pkgconfig(cairo)
-BuildRequires: pkgconfig(elementary)
-BuildRequires:  pkgconfig(capi-media-image-util)
-
-Requires(post):  /sbin/ldconfig
-Requires(postun):  /sbin/ldconfig
+BuildRequires: pkgconfig(eina)
+BuildRequires: pkgconfig(evas)
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(cairo)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(capi-media-image-util)
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
 Provides: capi-maps-service-plugin-devel
 
 %ifarch %{arm}
@@ -45,7 +45,8 @@ export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
 export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
 
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DLIBDIR=%{_libdir}
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} \
+       -DLIBDIR=%{_libdir} -DPROFILE=%{?profile} -DTIZEN_VER=300
 make %{?jobs:-j%jobs}
 
 %install
@@ -70,7 +71,7 @@ chsmack -a "*" %{_libdir}/maps/plugins
 %files
 %manifest capi-maps-service.manifest
 %defattr(-,root,root,-)
-/usr/share/license/capi-maps-service
+%{_datadir}/license/%{name}
 %{_libdir}/libcapi-maps-service.so.*
 
 
diff --git a/src/api/maps_condition.cpp b/src/api/maps_condition.cpp
new file mode 100644 (file)
index 0000000..997c641
--- /dev/null
@@ -0,0 +1,106 @@
+/* Copyright (c) 2010-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.
+ */
+
+#include <glib.h>
+#include <unistd.h>
+#if TIZEN_VER < 300
+#include <app_manager.h>
+#include <pkgmgr-info.h>
+#include <privilege_checker.h> /* privilege */
+#endif
+#include <system_info.h>               /* system_info_get_platform_bool */
+#include <maps_util.h>                 /* log */
+#include <maps_error.h>
+
+
+#define MAPSERVICE_PRIVILEGE   "http://tizen.org/privilege/mapservice"
+
+#define INTERNET_FEATURE               "http://tizen.org/feature/network.internet"
+
+
+#if TIZEN_VER < 300
+static char* __maps_condition_get_package_id(char **package_id)
+{
+       int ret = 0;
+       pid_t pid = 0;
+       char *app_id = NULL;
+       char *pkg_id = NULL;
+       pkgmgrinfo_appinfo_h pkgmgrinfo_appinfo;
+
+       do {
+               pid = getpid();
+               ret = app_manager_get_app_id(pid, &app_id);
+               if (ret) {
+                       MAPS_LOGE("Fail to get app_id. Err[%d]", ret);
+                       break;
+               }
+
+               ret = pkgmgrinfo_appinfo_get_appinfo(app_id, &pkgmgrinfo_appinfo);
+               if (ret) {
+                       MAPS_LOGE("Fail to get appinfo for [%s]. Err[%d]", app_id, ret);
+                       break;
+               }
+
+               ret = pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo, &pkg_id);
+               if (ret) {
+                       MAPS_LOGE("Fail to get package_id for [%s]. Err[%d]", app_id, ret);
+                       break;
+               }
+
+               *package_id = g_strdup(pkg_id);
+       } while (0);
+
+       g_free(app_id);
+       pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo);
+
+       return *package_id;
+}
+#endif
+
+bool maps_condition_check_privilege(void)
+{
+       bool is_permitted = true;
+#if TIZEN_VER < 300
+       /* to check for Tizen 2.x privilege */
+       char *package_id = NULL;
+       if (!__maps_condition_get_package_id(&package_id))
+               return is_permitted;
+
+       int ret = privilege_checker_check_package_privilege(package_id, MAPSERVICE_PRIVILEGE);
+       is_permitted = (ret == PRIV_CHECKER_ERR_NONE);
+       g_free(package_id);
+#else
+       /* to check for Tizen 3.x privilege */
+       extern const char *MAPS_PLUGINS_PATH_PREFIX;
+       is_permitted = (access(MAPS_PLUGINS_PATH_PREFIX, F_OK) != 0) || /* not exist */
+                      (access(MAPS_PLUGINS_PATH_PREFIX, R_OK) == 0);   /* readable */
+#endif
+       MAPS_LOGD("mapservice privilege is%sconsented", ( is_permitted ? " " : " not "));
+       return is_permitted;
+}
+
+bool maps_condition_check_feature(void)
+{
+       bool is_supported = true;
+#ifdef TIZEN_WEARABLE
+       int ret = system_info_get_platform_bool(INTERNET_FEATURE, &is_supported);
+       if (ret == SYSTEM_INFO_ERROR_NONE)
+               MAPS_LOGD("internet feature is%ssupported", (is_supported ? " " : " not "));
+       else
+               MAPS_LOGD("system info error (%d)", ret);
+#endif
+       return is_supported;
+}
diff --git a/src/api/maps_condition.h b/src/api/maps_condition.h
new file mode 100644 (file)
index 0000000..9ccbf6b
--- /dev/null
@@ -0,0 +1,30 @@
+/* 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_CHECK_H__
+#define __MAPS_SERVICE_CHECK_H__
+
+/**
+ * @brief      Gets if privilege is consented
+ */
+bool maps_condition_check_privilege(void);
+
+/**
+ * @brief      Gets if network.internet feature is supported
+ * @remarks    If target is not a wearable gear, it returns true always.
+ */
+bool maps_condition_check_feature(void);
+
+#endif /* __MAPS_SERVICE_CHECK_H__ */
index 6742c5a..6d8207b 100755 (executable)
  */
 
 #include <glib.h>
-#include <unistd.h> /* to check for Tizen 3.x privilege */
-#include <system_info.h>
 #include "maps_service.h"
 #include "maps_error.h"
 #include "maps_service.h"
 #include "maps_util.h"
+#include "maps_condition.h"
 
 #include "command_queue.h"
 #include "commands.h"
@@ -57,39 +56,6 @@ static bool __maps_provider_supported(maps_service_h maps, maps_service_e servic
        return supported;
 }
 
-bool _is_internet_feature_supported(void)
-{
-       static bool __is_checked = false;
-       static bool __is_supported = true;
-
-       if (!__is_checked) {
-               char *profile = NULL;
-               int ret = system_info_get_platform_string("http://tizen.org/feature/profile", &profile);
-               if (ret == SYSTEM_INFO_ERROR_NONE && profile && *profile) {
-                       MAPS_LOGD("profile : %s", profile);
-
-                       /* if wearable, check internet feature in addition */
-                       if (!strcmp("wearable", profile)) {
-                               ret = system_info_get_platform_bool("http://tizen.org/feature/network.internet", &__is_supported);
-                               MAPS_LOGD("internet feature supported : %d", __is_supported);
-                       }
-                       g_free(profile);
-
-                       /* set the flag which means feature checked */
-                       __is_checked = (ret == SYSTEM_INFO_ERROR_NONE);
-               }
-       }
-
-       return __is_supported;
-}
-
-static bool __has_maps_service_privilege()
-{
-       /* to check for Tizen 3.x privilege */
-       extern const char *MAPS_PLUGINS_PATH_PREFIX;
-       return (access(MAPS_PLUGINS_PATH_PREFIX, F_OK) != 0) || /* not exist */
-              (access(MAPS_PLUGINS_PATH_PREFIX, R_OK) == 0);   /* readable */
-}
 
 /*----------------------------------------------------------------------------*/
 /* */
@@ -125,7 +91,7 @@ EXPORT_API int maps_service_create(const char *maps_provider, maps_service_h *ma
                return MAPS_ERROR_INVALID_PARAMETER;
 
        /* Check if privileges enough */
-       if (!__has_maps_service_privilege()) {
+       if (!maps_condition_check_privilege()) {
                MAPS_LOGD("ERROR: privilege is not included");
                return MAPS_ERROR_PERMISSION_DENIED;
        }
@@ -187,7 +153,7 @@ EXPORT_API int maps_service_destroy(maps_service_h maps)
                return MAPS_ERROR_INVALID_PARAMETER;
 
        /* Check if privileges enough */
-       if (!__has_maps_service_privilege())
+       if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
        maps_service_s *maps_service = (maps_service_s *) maps;
@@ -287,7 +253,7 @@ EXPORT_API int maps_service_geocode(const maps_service_h maps,
                                    int *request_id)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
        /* Check if the handle of the Maps Service is valid */
@@ -303,7 +269,7 @@ EXPORT_API int maps_service_geocode(const maps_service_h maps,
                return MAPS_ERROR_INVALID_PARAMETER;
 
        /* Check if privileges enough */
-       if (!__has_maps_service_privilege())
+       if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
        session::command *cmd = new session::command_geocode(maps, address, preference,
@@ -322,7 +288,7 @@ EXPORT_API int maps_service_geocode_inside_area(const maps_service_h maps,
                                                void *user_data, int *request_id)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
        /* Check if the handle of the Maps Service is valid */
@@ -339,7 +305,7 @@ EXPORT_API int maps_service_geocode_inside_area(const maps_service_h maps,
                return MAPS_ERROR_INVALID_PARAMETER;
 
        /* Check if privileges enough */
-       if (!__has_maps_service_privilege())
+       if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
        session::command *cmd = new session::command_geocode_inside_bounds(maps,
@@ -357,7 +323,7 @@ EXPORT_API int maps_service_geocode_by_structured_address(const maps_service_h m
                                        void *user_data, int *request_id)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
        /* Check if the handle of the Maps Service is valid */
@@ -374,7 +340,7 @@ EXPORT_API int maps_service_geocode_by_structured_address(const maps_service_h m
                return MAPS_ERROR_INVALID_PARAMETER;
 
        /* Check if privileges enough */
-       if (!__has_maps_service_privilege())
+       if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
        session::command *cmd = new session::command_geocode_by_structured_address(maps,
@@ -393,7 +359,7 @@ EXPORT_API int maps_service_reverse_geocode(const maps_service_h maps,
                                            int *request_id)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
        /* Check if the handle of the Maps Service is valid */
@@ -413,7 +379,7 @@ EXPORT_API int maps_service_reverse_geocode(const maps_service_h maps,
                return MAPS_ERROR_INVALID_PARAMETER;
 
        /* Check if privileges enough */
-       if (!__has_maps_service_privilege())
+       if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
        session::command *cmd = new session::command_reverse_geocode(maps, latitude,
@@ -437,7 +403,7 @@ EXPORT_API int maps_service_search_place(const maps_service_h maps,
                                         void *user_data, int *request_id)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
        /* Check if the handle of the Maps Service is valid */
@@ -453,7 +419,7 @@ EXPORT_API int maps_service_search_place(const maps_service_h maps,
                return MAPS_ERROR_INVALID_PARAMETER;
 
        /* Check if privileges enough */
-       if (!__has_maps_service_privilege())
+       if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
        session::command *cmd = new session::command_search_place(maps, position,
@@ -473,7 +439,7 @@ EXPORT_API int maps_service_search_place_by_area(const maps_service_h maps,
                                                 int *request_id)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
        /* Check if the handle of the Maps Service is valid */
@@ -490,7 +456,7 @@ EXPORT_API int maps_service_search_place_by_area(const maps_service_h maps,
                return MAPS_ERROR_INVALID_PARAMETER;
 
        /* Check if privileges enough */
-       if (!__has_maps_service_privilege())
+       if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
        session::command *cmd = new session::command_search_by_area_place(maps,
@@ -511,7 +477,7 @@ EXPORT_API int maps_service_search_place_by_address(const maps_service_h maps,
                                                        int *request_id)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
        /* Check if the handle of the Maps Service is valid */
@@ -528,7 +494,7 @@ EXPORT_API int maps_service_search_place_by_address(const maps_service_h maps,
                return MAPS_ERROR_INVALID_PARAMETER;
 
        /* Check if privileges enough */
-       if (!__has_maps_service_privilege())
+       if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
        session::command *cmd = new session::command_search_by_address_place(maps,
@@ -547,7 +513,7 @@ EXPORT_API int maps_service_search_place_list(const maps_service_h maps,
                                        void *user_data, int *request_id)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
        if (!maps)
@@ -559,7 +525,7 @@ EXPORT_API int maps_service_search_place_list(const maps_service_h maps,
        if (!boundary || !filter || !callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
 
-       if (!__has_maps_service_privilege())
+       if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
        session::command *cmd = new session::command_search_place_list(maps,
@@ -575,7 +541,7 @@ EXPORT_API int maps_service_get_place_details(const maps_service_h maps,
        void *user_data, int *request_id)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
        if (!maps)
@@ -587,7 +553,7 @@ EXPORT_API int maps_service_get_place_details(const maps_service_h maps,
        if (!url || !callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
 
-       if (!__has_maps_service_privilege())
+       if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
        session::command *cmd = new session::command_get_place_details(maps,
@@ -610,7 +576,7 @@ EXPORT_API int maps_service_search_route(const maps_service_h maps,
                                         void *user_data, int *request_id)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
        /* Check if the handle of the Maps Service is valid */
@@ -626,7 +592,7 @@ EXPORT_API int maps_service_search_route(const maps_service_h maps,
                return MAPS_ERROR_INVALID_PARAMETER;
 
        /* Check if privileges enough */
-       if (!__has_maps_service_privilege())
+       if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
        session::command *cmd = new session::command_search_route(maps, preference,
@@ -646,7 +612,7 @@ EXPORT_API int maps_service_search_route_waypoints(const maps_service_h maps,
                                                   int *request_id)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
        /* Check if the handle of the Maps Service is valid */
@@ -663,7 +629,7 @@ EXPORT_API int maps_service_search_route_waypoints(const maps_service_h maps,
                return MAPS_ERROR_INVALID_PARAMETER;
 
        /* Check if privileges enough */
-       if (!__has_maps_service_privilege())
+       if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
        session::command *cmd = new session::command_search_route_waypoints(maps,
@@ -693,7 +659,7 @@ EXPORT_API int maps_service_cancel_request(const maps_service_h maps, int reques
                return MAPS_ERROR_INVALID_PARAMETER;
 
        /* Check if privileges enough */
-       if (!__has_maps_service_privilege())
+       if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
        session::command *cmd = new session::command_cancel_request(maps, request_id);
@@ -712,7 +678,7 @@ EXPORT_API int maps_service_multi_reverse_geocode(const maps_service_h maps,
        maps_service_multi_reverse_geocode_cb callback, void *user_data, int *request_id)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
        if (!maps)
@@ -724,7 +690,7 @@ EXPORT_API int maps_service_multi_reverse_geocode(const maps_service_h maps,
        if (!coordinates_list || !callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
 
-       if (!__has_maps_service_privilege())
+       if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
        session::command *cmd = new session::command_multi_reverse_geocode(maps,
index 3921721..62ab58d 100644 (file)
@@ -35,6 +35,7 @@
 #include "inertial_gesture.h"
 #include "gesture_detector_statemachine.h"
 #include "maps_view_event_data.h"
+#include "maps_condition.h"
 
 /*
  * The structure of callbacks info, Maps View is invoking during events
@@ -123,7 +124,6 @@ const gsize _MAPS_VIEW_LANGUAGE_MAX_LENGTH = 16;
 /* ---------------------------------------------------------------------------*/
 
 extern plugin::plugin_s *__extract_plugin(maps_service_h maps);
-extern bool _is_internet_feature_supported(void);
 extern int _maps_view_event_data_set_type(const maps_view_event_data_h event, maps_view_event_type_e event_type);
 extern int _maps_view_event_data_set_gesture_type(const maps_view_event_data_h event, maps_view_gesture_e gesture_type);
 extern int _maps_view_event_data_set_action_type(const maps_view_event_data_h event, maps_view_action_e action_type);
@@ -488,9 +488,14 @@ static void __maps_view_create_panel(maps_view_h view, Evas_Object *obj)
 /* Create the panel and link it to the instance of Maps Service */
 EXPORT_API int maps_view_create(maps_service_h maps, Evas_Object *obj, maps_view_h *view)
 {
+       /* Check if parameters are valid */
        if (!maps || !obj || !view)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        maps_view_s *v = g_slice_new0(maps_view_s);
        if (!v) {
                MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
@@ -600,9 +605,14 @@ EXPORT_API int maps_view_create(maps_service_h maps, Evas_Object *obj, maps_view
 /* Destroy the panel and unlink it from the instance of Maps Service */
 EXPORT_API int maps_view_destroy(maps_view_h view)
 {
+       /* Check if parameters are valid */
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        maps_view_s *v = (maps_view_s *) view;
 
        /* Unregister gesture processing */
@@ -745,12 +755,17 @@ static int __maps_view_set_center(maps_view_h view, maps_coordinates_h coordinat
 EXPORT_API int maps_view_set_center(maps_view_h view, maps_coordinates_h coordinates)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       /* Check if parameters are valid */
        if (!view || !coordinates)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        return __maps_view_set_center(view, coordinates, FALSE);
 }
 
@@ -780,12 +795,17 @@ int _maps_view_move_center(maps_view_h view, const int delta_x, const int delta_
 EXPORT_API int maps_view_set_scalebar_enabled(const maps_view_h view, bool enable)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       /* Check if parameters are valid */
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        return __get_plugin_interface(view)->maps_plugin_set_scalebar(view, enable);
 }
 
@@ -808,12 +828,17 @@ EXPORT_API int maps_view_get_center(const maps_view_h view, maps_coordinates_h *
 EXPORT_API int maps_view_set_zoom_level(maps_view_h view, int level)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       /* Check if parameters are valid */
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        maps_view_s *v = (maps_view_s *) view;
        int new_level = level;
        if (new_level < v->min_zoom_level) new_level = v->min_zoom_level;
@@ -852,8 +877,14 @@ EXPORT_API int maps_view_get_zoom_level(const maps_view_h view, int *level)
 
 EXPORT_API int maps_view_set_min_zoom_level(maps_view_h view, int level)
 {
+       /* Check if parameters are valid */
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
+
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        maps_view_s *v = (maps_view_s *) view;
        int min_zoom_level = -1;
        __get_plugin_interface(v)->maps_plugin_get_min_zoom_level(view, &min_zoom_level);
@@ -878,8 +909,14 @@ EXPORT_API int maps_view_get_min_zoom_level(const maps_view_h view, int *min_zoo
 
 EXPORT_API int maps_view_set_max_zoom_level(maps_view_h view, int level)
 {
+       /* Check if parameters are valid */
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
+
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        maps_view_s *v = (maps_view_s *) view;
        int max_zoom_level = -1;
        __get_plugin_interface(v)->maps_plugin_get_max_zoom_level(view, &max_zoom_level);
@@ -996,12 +1033,17 @@ EXPORT_API int maps_view_get_zoom_factor(const maps_view_h view, double *factor)
 EXPORT_API int maps_view_set_orientation(maps_view_h view, double angle)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       /* Check if parameters are valid */
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        /* Add inertia to the rotation process */
        maps_view_s *v = (maps_view_s *)view;
        if (v->inertial_camera)
@@ -1027,8 +1069,14 @@ EXPORT_API int maps_view_get_orientation(const maps_view_h view, double *angle)
 EXPORT_API int maps_view_screen_to_geolocation(maps_view_h view,
        int x, int y, maps_coordinates_h *coordinates)
 {
+       /* Check if parameters are valid */
        if (!view || !coordinates)
                return MAPS_ERROR_INVALID_PARAMETER;
+
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        int posx = 0;
        int posy = 0;
        maps_view_get_screen_location(view, &posx, &posy, NULL, NULL);
@@ -1039,8 +1087,14 @@ EXPORT_API int maps_view_screen_to_geolocation(maps_view_h view,
 EXPORT_API int maps_view_geolocation_to_screen(const maps_view_h view,
        const maps_coordinates_h coordinates, int *x, int *y)
 {
+       /* Check if parameters are valid */
        if (!view || !coordinates || !x || !y)
                return MAPS_ERROR_INVALID_PARAMETER;
+
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        int posx = 0;
        int posy = 0;
        maps_view_get_screen_location(view, &posx, &posy, NULL, NULL);
@@ -1058,14 +1112,19 @@ EXPORT_API int maps_view_geolocation_to_screen(const maps_view_h view,
 EXPORT_API int maps_view_set_type(maps_view_h view, maps_view_type_e type)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       /* Check if parameters are valid */
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
        if ((type < MAPS_VIEW_TYPE_NORMAL) || (type > MAPS_VIEW_TYPE_HYBRID))
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        maps_view_s *v = (maps_view_s *) view;
        v->type = type;
        return maps_view_set_center(view, v->center);
@@ -1083,12 +1142,17 @@ EXPORT_API int maps_view_get_type(const maps_view_h view, maps_view_type_e *type
 EXPORT_API int maps_view_set_buildings_enabled(maps_view_h view, bool enabled)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       /* Check if parameters are valid */
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        maps_view_s *v = (maps_view_s *) view;
        v->buildings_enabled = enabled;
        return maps_view_set_center(view, v->center);
@@ -1106,12 +1170,17 @@ EXPORT_API int maps_view_get_buildings_enabled(const maps_view_h view, bool *ena
 EXPORT_API int maps_view_set_traffic_enabled(maps_view_h view, bool enabled)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       /* Check if parameters are valid */
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        maps_view_s *v = (maps_view_s *) view;
        v->traffic_enabled = enabled;
        return maps_view_set_center(view, v->center);
@@ -1129,12 +1198,17 @@ EXPORT_API int maps_view_get_traffic_enabled(const maps_view_h view, bool *enabl
 EXPORT_API int maps_view_set_public_transit_enabled(maps_view_h view, bool enabled)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       /* Check if parameters are valid */
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        maps_view_s *v = (maps_view_s *) view;
        v->public_transit_enabled = enabled;
        return maps_view_set_center(view, v->center);
@@ -1214,12 +1288,17 @@ EXPORT_API int maps_view_get_inertia_enabled(maps_view_h view, bool *enabled)
 EXPORT_API int maps_view_set_language(maps_view_h view, const char *language)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       /* Check if parameters are valid */
        if (!view || !language)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        /* Check if language is supported */
        static const char *lngs[] = {
                "ara",
@@ -1295,12 +1374,17 @@ int _maps_view_get_clipper(const maps_view_h view, Evas_Object **clipper)
 EXPORT_API int maps_view_set_screen_location(maps_view_h view, int x, int y, int width, int height)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       /* Check if parameters are valid */
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        int error = maps_view_move(view, x, y);
        if (error == MAPS_ERROR_NONE)
                error = maps_view_resize(view, width, height);
@@ -1319,7 +1403,7 @@ EXPORT_API int maps_view_get_screen_location(const maps_view_h view, int *x, int
 EXPORT_API int maps_view_move(maps_view_h view, int x, int y)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
        if (!view)
@@ -1334,12 +1418,17 @@ EXPORT_API int maps_view_move(maps_view_h view, int x, int y)
 EXPORT_API int maps_view_resize(maps_view_h view, int width, int height)
 {
        /* Check if internet feature is supported */
-       if (!_is_internet_feature_supported())
+       if (!maps_condition_check_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       /* Check if parameters are valid */
        if (!view || (width <= 0) || (height <= 0))
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        maps_view_s *v = (maps_view_s *) view;
        evas_object_resize(v->panel, width, height);
        evas_object_resize(v->clipper, width, height);
@@ -1439,9 +1528,14 @@ EXPORT_API int maps_view_get_gesture_enabled(const maps_view_h view, maps_view_g
 
 EXPORT_API int maps_view_add_object(maps_view_h view, maps_view_object_h object)
 {
+       /* Check if parameters are valid */
        if (!view || !object)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        int error = MAPS_ERROR_NONE;
        do {
                /* Add Visual Object to the list of View Visual Objects */
@@ -1473,9 +1567,14 @@ EXPORT_API int maps_view_add_object(maps_view_h view, maps_view_object_h object)
 
 EXPORT_API int maps_view_remove_object(maps_view_h view, maps_view_object_h object)
 {
+       /* Check if parameters are valid */
        if (!view || !object)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        int error = MAPS_ERROR_NONE;
        do {
                /* Remove Visual Object from the list of View Visual Objects */
@@ -1497,9 +1596,14 @@ EXPORT_API int maps_view_remove_object(maps_view_h view, maps_view_object_h obje
 
 EXPORT_API int maps_view_remove_all_objects(maps_view_h view)
 {
+       /* Check if parameters are valid */
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        int error = MAPS_ERROR_NONE;
        do {
                maps_view_s *v = (maps_view_s *)view;
index 7f51c92..09cf269 100755 (executable)
  * limitations under the License.
  */
 
+#include <stdlib.h>
 #include <image_util.h>
 
 #include <maps_view_plugin.h>
+#include <maps_condition.h>
 #include <module.h>
 #include <empty_module.h>
-#include <stdlib.h>
 
 
 const plugin::interface_s *__get_plugin_interface(maps_view_h view);
@@ -106,10 +107,15 @@ EXPORT_API int maps_view_capture_snapshot(maps_view_h view,
                                                                                        int quality,
                                                                                        const char *path)
 {
+       /* Check if parameters are valid */
        if (!view || type < MAPS_VIEW_SNAPSHOT_BMP || type > MAPS_VIEW_SNAPSHOT_JPEG ||
                quality < 0 || quality > 100 || !path || (path && *path == '\0'))
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if privileges enough */
+       if (!maps_condition_check_privilege())
+               return MAPS_ERROR_PERMISSION_DENIED;
+
        int error = MAPS_ERROR_UNKNOWN;
        int w, h;
        unsigned char *image_buffer = NULL;