moved checking features to the first line of each APIs 61/76161/1
authorchanywa <cbible.kim@samsung.com>
Thu, 23 Jun 2016 04:09:42 +0000 (13:09 +0900)
committerchanywa <cbible.kim@samsung.com>
Thu, 23 Jun 2016 04:19:40 +0000 (13:19 +0900)
Change-Id: I488aa77fd1dafedb4bc283943d560e9ea052a50b

src/api/maps_service.cpp
src/api/maps_view.cpp
src/api/maps_view_object.cpp
src/maps_util.cpp
src/maps_util.h

index 56fc9ce..6742c5a 100755 (executable)
@@ -15,7 +15,7 @@
  */
 
 #include <glib.h>
-#include <unistd.h>
+#include <unistd.h> /* to check for Tizen 3.x privilege */
 #include <system_info.h>
 #include "maps_service.h"
 #include "maps_error.h"
@@ -85,6 +85,7 @@ bool _is_internet_feature_supported(void)
 
 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 */
@@ -285,6 +286,10 @@ EXPORT_API int maps_service_geocode(const maps_service_h maps,
                                    void *user_data,
                                    int *request_id)
 {
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if the handle of the Maps Service is valid */
        if (!maps)
                return MAPS_ERROR_INVALID_PARAMETER;
@@ -297,10 +302,6 @@ 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;
@@ -320,6 +321,10 @@ EXPORT_API int maps_service_geocode_inside_area(const maps_service_h maps,
                                                maps_service_geocode_cb callback,
                                                void *user_data, int *request_id)
 {
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if the handle of the Maps Service is valid */
        if (!maps)
                return MAPS_ERROR_INVALID_PARAMETER;
@@ -333,10 +338,6 @@ 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;
@@ -355,6 +356,10 @@ EXPORT_API int maps_service_geocode_by_structured_address(const maps_service_h m
                                        maps_service_geocode_cb callback,
                                        void *user_data, int *request_id)
 {
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if the handle of the Maps Service is valid */
        if (!maps)
                return MAPS_ERROR_INVALID_PARAMETER;
@@ -368,10 +373,6 @@ 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;
@@ -391,6 +392,10 @@ EXPORT_API int maps_service_reverse_geocode(const maps_service_h maps,
                                            callback, void * user_data,
                                            int *request_id)
 {
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if the handle of the Maps Service is valid */
        if (!maps)
                return MAPS_ERROR_INVALID_PARAMETER;
@@ -407,10 +412,6 @@ EXPORT_API int maps_service_reverse_geocode(const maps_service_h maps,
        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;
@@ -435,6 +436,10 @@ EXPORT_API int maps_service_search_place(const maps_service_h maps,
                                         maps_service_search_place_cb callback,
                                         void *user_data, int *request_id)
 {
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if the handle of the Maps Service is valid */
        if (!maps)
                return MAPS_ERROR_INVALID_PARAMETER;
@@ -447,10 +452,6 @@ EXPORT_API int maps_service_search_place(const maps_service_h maps,
        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;
@@ -471,6 +472,10 @@ EXPORT_API int maps_service_search_place_by_area(const maps_service_h maps,
                                                 void *user_data,
                                                 int *request_id)
 {
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if the handle of the Maps Service is valid */
        if (!maps)
                return MAPS_ERROR_INVALID_PARAMETER;
@@ -484,10 +489,6 @@ 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;
@@ -509,6 +510,10 @@ EXPORT_API int maps_service_search_place_by_address(const maps_service_h maps,
                                                        void *user_data,
                                                        int *request_id)
 {
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if the handle of the Maps Service is valid */
        if (!maps)
                return MAPS_ERROR_INVALID_PARAMETER;
@@ -522,10 +527,6 @@ 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;
@@ -545,6 +546,10 @@ EXPORT_API int maps_service_search_place_list(const maps_service_h maps,
                                        maps_service_search_place_list_cb callback,
                                        void *user_data, int *request_id)
 {
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        if (!maps)
                return MAPS_ERROR_INVALID_PARAMETER;
 
@@ -554,10 +559,6 @@ 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;
 
@@ -573,6 +574,10 @@ EXPORT_API int maps_service_get_place_details(const maps_service_h maps,
        const char *url, maps_service_get_place_details_cb callback,
        void *user_data, int *request_id)
 {
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        if (!maps)
                return MAPS_ERROR_INVALID_PARAMETER;
 
@@ -582,10 +587,6 @@ 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;
 
@@ -608,6 +609,10 @@ EXPORT_API int maps_service_search_route(const maps_service_h maps,
                                         maps_service_search_route_cb callback,
                                         void *user_data, int *request_id)
 {
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if the handle of the Maps Service is valid */
        if (!maps)
                return MAPS_ERROR_INVALID_PARAMETER;
@@ -620,10 +625,6 @@ 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;
@@ -644,6 +645,10 @@ EXPORT_API int maps_service_search_route_waypoints(const maps_service_h maps,
                                                   void *user_data,
                                                   int *request_id)
 {
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        /* Check if the handle of the Maps Service is valid */
        if (!maps)
                return MAPS_ERROR_INVALID_PARAMETER;
@@ -657,10 +662,6 @@ 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;
@@ -710,6 +711,10 @@ EXPORT_API int maps_service_multi_reverse_geocode(const maps_service_h maps,
        const maps_coordinates_list_h coordinates_list, const maps_preference_h preference,
        maps_service_multi_reverse_geocode_cb callback, void *user_data, int *request_id)
 {
+       /* Check if internet feature is supported */
+       if (!_is_internet_feature_supported())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        if (!maps)
                return MAPS_ERROR_INVALID_PARAMETER;
 
@@ -719,10 +724,6 @@ 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 bc91a22..3921721 100644 (file)
@@ -744,13 +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;
 
+       if (!view || !coordinates)
+               return MAPS_ERROR_INVALID_PARAMETER;
+
        return __maps_view_set_center(view, coordinates, FALSE);
 }
 
@@ -779,13 +779,13 @@ 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)
 {
-       if (!view)
-               return MAPS_ERROR_INVALID_PARAMETER;
-
        /* Check if internet feature is supported */
        if (!_is_internet_feature_supported())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       if (!view)
+               return MAPS_ERROR_INVALID_PARAMETER;
+
        return __get_plugin_interface(view)->maps_plugin_set_scalebar(view, enable);
 }
 
@@ -807,13 +807,13 @@ 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)
 {
-       if (!view)
-               return MAPS_ERROR_INVALID_PARAMETER;
-
        /* Check if internet feature is supported */
        if (!_is_internet_feature_supported())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       if (!view)
+               return MAPS_ERROR_INVALID_PARAMETER;
+
        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;
@@ -995,13 +995,13 @@ 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)
 {
-       if (!view)
-               return MAPS_ERROR_INVALID_PARAMETER;
-
        /* Check if internet feature is supported */
        if (!_is_internet_feature_supported())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       if (!view)
+               return MAPS_ERROR_INVALID_PARAMETER;
+
        /* Add inertia to the rotation process */
        maps_view_s *v = (maps_view_s *)view;
        if (v->inertial_camera)
@@ -1057,15 +1057,15 @@ 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())
+               return MAPS_ERROR_NOT_SUPPORTED;
+
        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 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);
@@ -1082,13 +1082,13 @@ 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)
 {
-       if (!view)
-               return MAPS_ERROR_INVALID_PARAMETER;
-
        /* Check if internet feature is supported */
        if (!_is_internet_feature_supported())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       if (!view)
+               return MAPS_ERROR_INVALID_PARAMETER;
+
        maps_view_s *v = (maps_view_s *) view;
        v->buildings_enabled = enabled;
        return maps_view_set_center(view, v->center);
@@ -1105,13 +1105,13 @@ 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)
 {
-       if (!view)
-               return MAPS_ERROR_INVALID_PARAMETER;
-
        /* Check if internet feature is supported */
        if (!_is_internet_feature_supported())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       if (!view)
+               return MAPS_ERROR_INVALID_PARAMETER;
+
        maps_view_s *v = (maps_view_s *) view;
        v->traffic_enabled = enabled;
        return maps_view_set_center(view, v->center);
@@ -1128,13 +1128,13 @@ 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)
 {
-       if (!view)
-               return MAPS_ERROR_INVALID_PARAMETER;
-
        /* Check if internet feature is supported */
        if (!_is_internet_feature_supported())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       if (!view)
+               return MAPS_ERROR_INVALID_PARAMETER;
+
        maps_view_s *v = (maps_view_s *) view;
        v->public_transit_enabled = enabled;
        return maps_view_set_center(view, v->center);
@@ -1213,13 +1213,13 @@ 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)
 {
-       if (!view || !language)
-               return MAPS_ERROR_INVALID_PARAMETER;
-
        /* Check if internet feature is supported */
        if (!_is_internet_feature_supported())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       if (!view || !language)
+               return MAPS_ERROR_INVALID_PARAMETER;
+
        /* Check if language is supported */
        static const char *lngs[] = {
                "ara",
@@ -1294,13 +1294,13 @@ 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)
 {
-       if (!view)
-               return MAPS_ERROR_INVALID_PARAMETER;
-
        /* Check if internet feature is supported */
        if (!_is_internet_feature_supported())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       if (!view)
+               return MAPS_ERROR_INVALID_PARAMETER;
+
        int error = maps_view_move(view, x, y);
        if (error == MAPS_ERROR_NONE)
                error = maps_view_resize(view, width, height);
@@ -1318,13 +1318,13 @@ 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)
 {
-       if (!view)
-               return MAPS_ERROR_INVALID_PARAMETER;
-
        /* Check if internet feature is supported */
        if (!_is_internet_feature_supported())
                return MAPS_ERROR_NOT_SUPPORTED;
 
+       if (!view)
+               return MAPS_ERROR_INVALID_PARAMETER;
+
        maps_view_s *v = (maps_view_s *) view;
        evas_object_move(v->panel, x, y);
        evas_object_move(v->clipper, x, y);
@@ -1333,13 +1333,13 @@ 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)
 {
-       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;
 
+       if (!view || (width <= 0) || (height <= 0))
+               return MAPS_ERROR_INVALID_PARAMETER;
+
        maps_view_s *v = (maps_view_s *) view;
        evas_object_resize(v->panel, width, height);
        evas_object_resize(v->clipper, width, height);
index aaeef84..638c02b 100644 (file)
 #include "overlay_constructor.h"
 #include <cairo.h>
 
+#ifndef M_PI
+#define M_PI   3.14159265358979323846
+#endif
+
 /*
 * This represents marker visual object information
  */
index d9faf3f..b7738eb 100644 (file)
@@ -34,4 +34,4 @@ int maps_get_string(const char *src, const int max_length, char **dst)
                return MAPS_ERROR_INVALID_PARAMETER;
        *dst = g_strndup(src, max_length);
        return MAPS_ERROR_NONE;
-}
\ No newline at end of file
+}
index 6fea677..92634cc 100755 (executable)
@@ -127,13 +127,15 @@ public:
        void push_back(const T &value)
        {
                T *clone = new T(value);
-               g_array_append_val(parray, clone);
-               current_size++;
+               if (clone) {
+                       g_array_append_val(parray, clone);
+                       current_size++;
+               }
        }
        T &operator[](size_t idx) const
        {
                T *item = g_array_index(parray, T *, idx);
-                return *item;
+               return *item;
        }
        unsigned int size() const
        {