fix for NOT_SUPPORTED 53/89853/4
authorjomui <jongmun.woo@samsung.com>
Tue, 27 Sep 2016 08:00:20 +0000 (17:00 +0900)
committerchanywa <cbible.kim@samsung.com>
Tue, 27 Sep 2016 08:49:37 +0000 (17:49 +0900)
Signed-off-by: jomui <jongmun.woo@samsung.com>
Change-Id: I7d66d43c9a52ae86aff7f94239b85c6f50e71982

src/api/maps_condition.cpp
src/api/maps_condition.h
src/api/maps_place.cpp
src/api/maps_view.cpp
src/api/maps_view_snapshot.cpp

index 98c3906..0936090 100644 (file)
@@ -19,6 +19,7 @@
 #include <system_info.h>               /* system_info_get_platform_bool */
 #include <maps_util.h>                 /* log */
 #include <maps_error.h>
+#include <maps_condition.h>
 #if (TIZEN_VER < VERSION(3, 0, 0))
 #include <privacy_checker_client.h>
 #include <sys/smack.h>
@@ -30,6 +31,9 @@
 #define INTERNET_FEATURE               "http://tizen.org/feature/network.internet"
 
 
+void *_maps_view_get_maps_service_ptr(maps_view_h view);
+
+
 #if (TIZEN_VER < VERSION(3, 0, 0))
 static int __maps_condition_check_privilege(const char *privilege_name, const char *permission)
 {
@@ -103,3 +107,45 @@ bool maps_condition_check_internet_feature(void)
 #endif
        return is_supported;
 }
+
+bool maps_condition_check_service_supported(maps_service_h maps, maps_service_e service)
+{
+       if (!maps)
+               return false;
+       bool supported = false;
+       if (maps_service_provider_is_service_supported(maps, service, &supported) != MAPS_ERROR_NONE)
+               return false;
+       return supported;
+}
+
+bool maps_condition_check_data_supported(maps_service_h maps, maps_service_data_e data)
+{
+       if (!maps)
+               return false;
+       bool supported = false;
+       if (maps_service_provider_is_data_supported(maps, data, &supported) != MAPS_ERROR_NONE)
+               return false;
+       return supported;
+}
+
+bool maps_condition_check_view_service_supported(maps_view_h view, maps_service_e service)
+{
+       if (!view)
+               return false;
+       maps_service_h maps = _maps_view_get_maps_service_ptr(view);
+       bool supported = false;
+       if (maps_service_provider_is_service_supported(maps, service, &supported) != MAPS_ERROR_NONE)
+               return false;
+       return supported;
+}
+
+bool maps_condition_check_view_data_supported(maps_view_h view, maps_service_data_e data)
+{
+       if (!view)
+               return false;
+       maps_service_h maps = _maps_view_get_maps_service_ptr(view);
+       bool supported = false;
+       if (maps_service_provider_is_data_supported(maps, data, &supported) != MAPS_ERROR_NONE)
+               return false;
+       return supported;
+}
\ No newline at end of file
index 9450c26..6aece43 100644 (file)
  * limitations under the License.
  */
 
-#ifndef __MAPS_SERVICE_CHECK_H__
-#define __MAPS_SERVICE_CHECK_H__
+#ifndef __MAPS_CONDITION_H__
+#define __MAPS_CONDITION_H__
+
+#include <maps_service.h>
+#include <maps_types.h>
 
 /**
  * @brief      Gets if privilege is consented
@@ -23,7 +26,6 @@ bool maps_condition_check_privilege(void);
 
 /**
  * @brief      Gets if maps feature is supported
- * @remarks    If target is not a wearable gear, it returns true always.
  */
 bool maps_condition_check_maps_feature(void);
 
@@ -33,4 +35,24 @@ bool maps_condition_check_maps_feature(void);
  */
 bool maps_condition_check_internet_feature(void);
 
-#endif /* __MAPS_SERVICE_CHECK_H__ */
+/**
+ * @brief      Gets if maps service is supported
+ */
+bool maps_condition_check_service_supported(maps_service_h maps, maps_service_e service);
+
+/**
+ * @brief      Gets if maps service data is supported
+ */
+bool maps_condition_check_data_supported(maps_service_h maps, maps_service_data_e data);
+
+/**
+ * @brief      Gets if maps service is supported
+ */
+bool maps_condition_check_view_service_supported(maps_view_h maps, maps_service_e service);
+
+/**
+ * @brief      Gets if maps service data is supported
+ */
+bool maps_condition_check_view_data_supported(maps_view_h view, maps_service_data_e data);
+
+#endif /* __MAPS_CONDITION_H__ */
index 203d02f..c29e3ab 100644 (file)
@@ -375,10 +375,12 @@ EXPORT_API int maps_place_get_address(const maps_place_h place,
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!place || !address)
+       if (!place)
                return MAPS_ERROR_INVALID_PARAMETER;
        if (!__is_supported(place, MAPS_PLACE_ADDRESS))
                return MAPS_ERROR_NOT_SUPPORTED;
+       if (!address)
+               return MAPS_ERROR_INVALID_PARAMETER;
        if (!((maps_place_s *) place)->address)
                return MAPS_ERROR_NOT_FOUND;
        return maps_address_clone(((maps_place_s *) place)->address, address);
@@ -389,10 +391,12 @@ EXPORT_API int maps_place_get_rating(const maps_place_h place,
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!place || !rating)
+       if (!place)
                return MAPS_ERROR_INVALID_PARAMETER;
        if (!__is_supported(place, MAPS_PLACE_RATING))
                return MAPS_ERROR_NOT_SUPPORTED;
+       if (!rating)
+               return MAPS_ERROR_INVALID_PARAMETER;
        if (!((maps_place_s *) place)->rating)
                return MAPS_ERROR_NOT_FOUND;
        return maps_place_rating_clone(((maps_place_s *) place)->rating, rating);
@@ -418,10 +422,12 @@ EXPORT_API int maps_place_foreach_category(const maps_place_h place,
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!place || !callback)
+       if (!place)
                return MAPS_ERROR_INVALID_PARAMETER;
        if (!__is_supported(place, MAPS_PLACE_CATEGORIES))
                return MAPS_ERROR_NOT_SUPPORTED;
+       if (!callback)
+               return MAPS_ERROR_INVALID_PARAMETER;
        if (!((maps_place_s *) place)->categories)
                return MAPS_ERROR_NOT_FOUND;
        return maps_item_list_foreach(((maps_place_s *) place)->categories,
@@ -434,10 +440,12 @@ EXPORT_API int maps_place_foreach_attribute(const maps_place_h place,
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!place || !callback)
+       if (!place)
                return MAPS_ERROR_INVALID_PARAMETER;
        if (!__is_supported(place, MAPS_PLACE_ATTRIBUTES))
                return MAPS_ERROR_NOT_SUPPORTED;
+       if (!callback)
+               return MAPS_ERROR_INVALID_PARAMETER;
        if (!((maps_place_s *) place)->attribute)
                return MAPS_ERROR_NOT_FOUND;
        return maps_item_list_foreach(((maps_place_s *) place)->attribute,
@@ -450,10 +458,12 @@ EXPORT_API int maps_place_foreach_contact(const maps_place_h place,
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!place || !callback)
+       if (!place)
                return MAPS_ERROR_INVALID_PARAMETER;
        if (!__is_supported(place, MAPS_PLACE_CONTACTS))
                return MAPS_ERROR_NOT_SUPPORTED;
+       if (!callback)
+               return MAPS_ERROR_INVALID_PARAMETER;
        if (!((maps_place_s *) place)->contacts)
                return MAPS_ERROR_NOT_FOUND;
        return maps_item_list_foreach(((maps_place_s *) place)->contacts,
@@ -466,10 +476,12 @@ EXPORT_API int maps_place_foreach_editorial(const maps_place_h place,
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!place || !callback)
+       if (!place)
                return MAPS_ERROR_INVALID_PARAMETER;
        if (!__is_supported(place, MAPS_PLACE_EDITORIALS))
                return MAPS_ERROR_NOT_SUPPORTED;
+       if (!callback)
+               return MAPS_ERROR_INVALID_PARAMETER;
        if (!((maps_place_s *) place)->editorials)
                return MAPS_ERROR_NOT_FOUND;
        return maps_item_list_foreach(((maps_place_s *) place)->editorials,
@@ -482,10 +494,12 @@ EXPORT_API int maps_place_foreach_image(const maps_place_h place,
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!place || !callback)
+       if (!place)
                return MAPS_ERROR_INVALID_PARAMETER;
        if (!__is_supported(place, MAPS_PLACE_IMAGE))
                return MAPS_ERROR_NOT_SUPPORTED;
+       if (!callback)
+               return MAPS_ERROR_INVALID_PARAMETER;
        if (!((maps_place_s *) place)->images)
                return MAPS_ERROR_NOT_FOUND;
        return maps_item_list_foreach(((maps_place_s *) place)->images,
@@ -498,10 +512,12 @@ EXPORT_API int maps_place_foreach_review(const maps_place_h place,
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!place || !callback)
+       if (!place)
                return MAPS_ERROR_INVALID_PARAMETER;
        if (!__is_supported(place, MAPS_PLACE_REVIEWS))
                return MAPS_ERROR_NOT_SUPPORTED;
+       if (!callback)
+               return MAPS_ERROR_INVALID_PARAMETER;
        if (!((maps_place_s *) place)->reviews)
                return MAPS_ERROR_NOT_FOUND;
        return maps_item_list_foreach(((maps_place_s *) place)->reviews,
@@ -513,10 +529,12 @@ EXPORT_API int maps_place_get_supplier_link(const maps_place_image_h place,
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!place || !supplier)
+       if (!place)
                return MAPS_ERROR_INVALID_PARAMETER;
        if (!__is_supported(place, MAPS_PLACE_SUPPLIER))
                return MAPS_ERROR_NOT_SUPPORTED;
+       if (!supplier)
+               return MAPS_ERROR_INVALID_PARAMETER;
        if (!((maps_place_s *) place)->supplier)
                return MAPS_ERROR_NOT_FOUND;
        return maps_place_link_object_clone(((maps_place_s *) place)->supplier, supplier);
@@ -527,10 +545,12 @@ EXPORT_API int maps_place_get_related_link(const maps_place_image_h place,
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!place || !related)
+       if (!place)
                return MAPS_ERROR_INVALID_PARAMETER;
        if (!__is_supported(place, MAPS_PLACE_RELATED))
                return MAPS_ERROR_NOT_SUPPORTED;
+       if (!related)
+               return MAPS_ERROR_INVALID_PARAMETER;
        if (!((maps_place_s *) place)->related)
                return MAPS_ERROR_NOT_FOUND;
        return maps_place_link_object_clone(((maps_place_s *) place)->related, related);
index 73ccb66..69efd26 100644 (file)
@@ -517,7 +517,11 @@ EXPORT_API int maps_view_create(maps_service_h maps, Evas_Object *obj, maps_view
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!maps || !obj || !view)
+       if (!maps)
+               return MAPS_ERROR_INVALID_PARAMETER;
+       if (!maps_condition_check_service_supported(maps, MAPS_SERVICE_VIEW))
+               return MAPS_ERROR_NOT_SUPPORTED;
+       if (!obj || !view)
                return MAPS_ERROR_INVALID_PARAMETER;
        if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
@@ -825,6 +829,8 @@ EXPORT_API int maps_view_set_scalebar_enabled(const maps_view_h view, bool enabl
                return MAPS_ERROR_NOT_SUPPORTED;
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
+       if (!maps_condition_check_view_data_supported(view, MAPS_VIEW_SCALEBAR))
+               return MAPS_ERROR_NOT_SUPPORTED;
        if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
@@ -835,7 +841,11 @@ EXPORT_API int maps_view_get_scalebar_enabled(const maps_view_h view, bool *enab
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!view || !enabled)
+       if (!view)
+               return MAPS_ERROR_INVALID_PARAMETER;
+       if (!maps_condition_check_view_data_supported(view, MAPS_VIEW_SCALEBAR))
+               return MAPS_ERROR_NOT_SUPPORTED;
+       if (!enabled)
                return MAPS_ERROR_INVALID_PARAMETER;
 
        return __get_plugin_interface(view)->maps_plugin_get_scalebar(view, enabled);
@@ -1166,6 +1176,8 @@ EXPORT_API int maps_view_set_buildings_enabled(maps_view_h view, bool enabled)
                return MAPS_ERROR_NOT_SUPPORTED;
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
+       if (!maps_condition_check_view_data_supported(view, MAPS_VIEW_BUILDING))
+               return MAPS_ERROR_NOT_SUPPORTED;
        if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
@@ -1178,7 +1190,11 @@ EXPORT_API int maps_view_get_buildings_enabled(const maps_view_h view, bool *ena
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!view || !enabled)
+       if (!view)
+               return MAPS_ERROR_INVALID_PARAMETER;
+       if (!maps_condition_check_view_data_supported(view, MAPS_VIEW_BUILDING))
+               return MAPS_ERROR_NOT_SUPPORTED;
+       if (!enabled)
                return MAPS_ERROR_INVALID_PARAMETER;
        maps_view_s *v = (maps_view_s *) view;
        *enabled = v->buildings_enabled;
@@ -1191,6 +1207,8 @@ EXPORT_API int maps_view_set_traffic_enabled(maps_view_h view, bool enabled)
                return MAPS_ERROR_NOT_SUPPORTED;
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
+       if (!maps_condition_check_view_data_supported(view, MAPS_VIEW_TRAFFIC))
+               return MAPS_ERROR_NOT_SUPPORTED;
        if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
@@ -1203,7 +1221,11 @@ EXPORT_API int maps_view_get_traffic_enabled(const maps_view_h view, bool *enabl
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!view || !enabled)
+       if (!view)
+               return MAPS_ERROR_INVALID_PARAMETER;
+       if (!maps_condition_check_view_data_supported(view, MAPS_VIEW_TRAFFIC))
+               return MAPS_ERROR_NOT_SUPPORTED;
+       if (!enabled)
                return MAPS_ERROR_INVALID_PARAMETER;
        maps_view_s *v = (maps_view_s *) view;
        *enabled = v->traffic_enabled;
@@ -1216,6 +1238,8 @@ EXPORT_API int maps_view_set_public_transit_enabled(maps_view_h view, bool enabl
                return MAPS_ERROR_NOT_SUPPORTED;
        if (!view)
                return MAPS_ERROR_INVALID_PARAMETER;
+       if (!maps_condition_check_view_data_supported(view, MAPS_VIEW_PUBLIC_TRANSIT))
+               return MAPS_ERROR_NOT_SUPPORTED;
        if (!maps_condition_check_privilege())
                return MAPS_ERROR_PERMISSION_DENIED;
 
@@ -1228,7 +1252,11 @@ EXPORT_API int maps_view_get_public_transit_enabled(const maps_view_h view, bool
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!view || !enabled)
+       if (!view)
+               return MAPS_ERROR_INVALID_PARAMETER;
+       if (!maps_condition_check_view_data_supported(view, MAPS_VIEW_PUBLIC_TRANSIT))
+               return MAPS_ERROR_NOT_SUPPORTED;
+       if (!enabled)
                return MAPS_ERROR_INVALID_PARAMETER;
        maps_view_s *v = (maps_view_s *) view;
        *enabled = v->public_transit_enabled;
index 1c8c3f3..ce98697 100644 (file)
@@ -110,7 +110,11 @@ EXPORT_API int maps_view_capture_snapshot(maps_view_h view,
 {
        if (!maps_condition_check_maps_feature())
                return MAPS_ERROR_NOT_SUPPORTED;
-       if (!view || type < MAPS_VIEW_SNAPSHOT_BMP || type > MAPS_VIEW_SNAPSHOT_JPEG ||
+       if (!view)
+               return MAPS_ERROR_INVALID_PARAMETER;
+       if (!maps_condition_check_view_service_supported(view, MAPS_SERVICE_VIEW_SNAPSHOT))
+               return MAPS_ERROR_NOT_SUPPORTED;
+       if (type < MAPS_VIEW_SNAPSHOT_BMP || type > MAPS_VIEW_SNAPSHOT_JPEG ||
                quality < 0 || quality > 100 || !path || (path && *path == '\0'))
                return MAPS_ERROR_INVALID_PARAMETER;
        if (!maps_condition_check_privilege())