added to check if wearable target (device or emulator) has a network.internet feature... 56/75356/3
authorchanywa <cbible.kim@samsung.com>
Fri, 17 Jun 2016 12:19:32 +0000 (21:19 +0900)
committerchanywa <cbible.kim@samsung.com>
Tue, 21 Jun 2016 05:26:26 +0000 (14:26 +0900)
Change-Id: Ica56ac00188aae73445123ba5f8d751a6b056a59

CMakeLists.txt
packaging/capi-maps-service.spec
src/api/maps_service.cpp
src/api/maps_view.cpp

index ab27171..6c56316 100644 (file)
@@ -22,6 +22,7 @@ SET(dependents
        gmodule-2.0
        capi-base-common
        dlog
+       capi-system-info
 
        # Mapping API dependencies
        eina
index 539a539..b2b71cf 100644 (file)
@@ -13,6 +13,7 @@ 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)
index 47d978d..56fc9ce 100755 (executable)
@@ -16,6 +16,7 @@
 
 #include <glib.h>
 #include <unistd.h>
+#include <system_info.h>
 #include "maps_service.h"
 #include "maps_error.h"
 #include "maps_service.h"
@@ -56,6 +57,32 @@ 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()
 {
        extern const char *MAPS_PLUGINS_PATH_PREFIX;
@@ -270,6 +297,10 @@ EXPORT_API int maps_service_geocode(const maps_service_h maps,
        if (!address || !callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if privileges enough */
        if (!__has_maps_service_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
@@ -302,6 +333,10 @@ EXPORT_API int maps_service_geocode_inside_area(const maps_service_h maps,
        if (!address || !bounds || !callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if privileges enough */
        if (!__has_maps_service_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
@@ -333,6 +368,10 @@ EXPORT_API int maps_service_geocode_by_structured_address(const maps_service_h m
        if (!address || !callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if privileges enough */
        if (!__has_maps_service_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
@@ -363,11 +402,15 @@ EXPORT_API int maps_service_reverse_geocode(const maps_service_h maps,
        /* Check if parameters are valid */
        if (!callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
-       if (latitude <= -90 && latitude >= 90)
+       if (latitude <= -90 || latitude >= 90)
                return MAPS_ERROR_INVALID_PARAMETER;
-       if (longitude <= -180 && longitude >= 180)
+       if (longitude <= -180 || longitude >= 180)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if privileges enough */
        if (!__has_maps_service_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
@@ -401,9 +444,13 @@ EXPORT_API int maps_service_search_place(const maps_service_h maps,
                return MAPS_ERROR_NOT_SUPPORTED;
 
        /* Check if parameters are valid */
-       if (!position || !filter || !callback || !request_id)
+       if (!position || (distance < 0) || !filter || !callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if privileges enough */
        if (!__has_maps_service_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
@@ -437,6 +484,10 @@ EXPORT_API int maps_service_search_place_by_area(const maps_service_h maps,
        if (!boundary || !filter || !callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if privileges enough */
        if (!__has_maps_service_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
@@ -471,6 +522,10 @@ EXPORT_API int maps_service_search_place_by_address(const maps_service_h maps,
        if (!address || !boundary || !filter || !callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if privileges enough */
        if (!__has_maps_service_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
@@ -499,6 +554,10 @@ EXPORT_API int maps_service_search_place_list(const maps_service_h maps,
        if (!boundary || !filter || !callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        if (!__has_maps_service_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
@@ -523,6 +582,10 @@ EXPORT_API int maps_service_get_place_details(const maps_service_h maps,
        if (!url || !callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        if (!__has_maps_service_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
@@ -557,6 +620,10 @@ EXPORT_API int maps_service_search_route(const maps_service_h maps,
        if (!origin || !destination || !callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if privileges enough */
        if (!__has_maps_service_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
@@ -590,6 +657,10 @@ EXPORT_API int maps_service_search_route_waypoints(const maps_service_h maps,
        if (!waypoint_list || (waypoint_num < 2) || !callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if privileges enough */
        if (!__has_maps_service_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
@@ -648,6 +719,10 @@ EXPORT_API int maps_service_multi_reverse_geocode(const maps_service_h maps,
        if (!coordinates_list || !callback || !request_id)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        if (!__has_maps_service_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
index 3f5eb6d..bc91a22 100644 (file)
@@ -123,6 +123,7 @@ 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);
@@ -556,7 +557,7 @@ EXPORT_API int maps_view_create(maps_service_h maps, Evas_Object *obj, maps_view
        v->maps = maps;
 
        /* Set up canvas and Ecore */
-       maps_view_set_language(v, "eng");
+       v->language = g_strdup("eng");
 
        /* Add an idle handler */
        v->idler = ecore_idler_add(__maps_view_on_idle_cb, v);
@@ -743,6 +744,13 @@ 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)
 {
+       if (!view || !coordinates)
+               return MAPS_ERROR_INVALID_PARAMETER;
+
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        return __maps_view_set_center(view, coordinates, FALSE);
 }
 
@@ -774,6 +782,10 @@ EXPORT_API int maps_view_set_scalebar_enabled(const maps_view_h view, bool enabl
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        return __get_plugin_interface(view)->maps_plugin_set_scalebar(view, enable);
 }
 
@@ -798,6 +810,10 @@ EXPORT_API int maps_view_set_zoom_level(maps_view_h view, int level)
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        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;
@@ -982,6 +998,10 @@ EXPORT_API int maps_view_set_orientation(maps_view_h view, double angle)
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Add inertia to the rotation process */
        maps_view_s *v = (maps_view_s *)view;
        if (v->inertial_camera)
@@ -1041,6 +1061,11 @@ EXPORT_API int maps_view_set_type(maps_view_h view, maps_view_type_e type)
                return MAPS_ERROR_INVALID_PARAMETER;
        if ((type < MAPS_VIEW_TYPE_NORMAL) || (type > MAPS_VIEW_TYPE_HYBRID))
                return MAPS_ERROR_INVALID_PARAMETER;
+
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        maps_view_s *v = (maps_view_s *) view;
        v->type = type;
        return maps_view_set_center(view, v->center);
@@ -1059,6 +1084,11 @@ EXPORT_API int maps_view_set_buildings_enabled(maps_view_h view, bool enabled)
 {
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
+
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        maps_view_s *v = (maps_view_s *) view;
        v->buildings_enabled = enabled;
        return maps_view_set_center(view, v->center);
@@ -1077,6 +1107,11 @@ EXPORT_API int maps_view_set_traffic_enabled(maps_view_h view, bool enabled)
 {
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
+
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        maps_view_s *v = (maps_view_s *) view;
        v->traffic_enabled = enabled;
        return maps_view_set_center(view, v->center);
@@ -1095,6 +1130,11 @@ EXPORT_API int maps_view_set_public_transit_enabled(maps_view_h view, bool enabl
 {
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
+
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        maps_view_s *v = (maps_view_s *) view;
        v->public_transit_enabled = enabled;
        return maps_view_set_center(view, v->center);
@@ -1176,6 +1216,10 @@ EXPORT_API int maps_view_set_language(maps_view_h view, const char *language)
        if (!view || !language)
                return MAPS_ERROR_INVALID_PARAMETER;
 
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if language is supported */
        static const char *lngs[] = {
                "ara",
@@ -1252,6 +1296,11 @@ EXPORT_API int maps_view_set_screen_location(maps_view_h view, int x, int y, int
 {
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
+
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        int error = maps_view_move(view, x, y);
        if (error == MAPS_ERROR_NONE)
                error = maps_view_resize(view, width, height);
@@ -1271,6 +1320,11 @@ EXPORT_API int maps_view_move(maps_view_h view, int x, int y)
 {
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
+
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        maps_view_s *v = (maps_view_s *) view;
        evas_object_move(v->panel, x, y);
        evas_object_move(v->clipper, x, y);
@@ -1281,6 +1335,11 @@ EXPORT_API int maps_view_resize(maps_view_h view, int width, int height)
 {
        if (!view || (width <= 0) || (height <= 0))
                return MAPS_ERROR_INVALID_PARAMETER;
+
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        maps_view_s *v = (maps_view_s *) view;
        evas_object_resize(v->panel, width, height);
        evas_object_resize(v->clipper, width, height);