From: chanywa Date: Tue, 14 Jun 2016 10:29:54 +0000 (+0900) Subject: Tizen C++ Coding Rules X-Git-Tag: submit/tizen/20160615.105814~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ce2db50446120cd503856c79934f947f85969bcd;p=platform%2Fcore%2Fapi%2Fmaps-service.git Tizen C++ Coding Rules Change-Id: I1f5313d0924731d534b754c49f14a753caa395db --- diff --git a/include/maps_error.h b/include/maps_error.h index 8bb493c..88efcae 100644 --- a/include/maps_error.h +++ b/include/maps_error.h @@ -41,20 +41,19 @@ extern "C" { * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum _maps_error_e { - MAPS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ MAPS_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission Denied */ MAPS_ERROR_OUT_OF_MEMORY = - TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ MAPS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ MAPS_ERROR_NOT_SUPPORTED = - TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ + TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ MAPS_ERROR_CONNECTION_TIME_OUT = TIZEN_ERROR_CONNECTION_TIME_OUT,/**< Timeout error, no answer */ @@ -69,20 +68,19 @@ typedef enum _maps_error_e { TIZEN_ERROR_KEY_NOT_AVAILABLE, /**< Invalid key */ MAPS_ERROR_RESOURCE_BUSY = - TIZEN_ERROR_RESOURCE_BUSY, /**< Maps Service busy */ + TIZEN_ERROR_RESOURCE_BUSY, /**< Maps Service busy */ MAPS_ERROR_CANCELED = - TIZEN_ERROR_CANCELED, /**< Maps Service request aborted */ + TIZEN_ERROR_CANCELED, /**< Maps Service request aborted */ MAPS_ERROR_UNKNOWN = - TIZEN_ERROR_UNKNOWN, /**< Unknown error */ + TIZEN_ERROR_UNKNOWN, /**< Unknown error */ MAPS_ERROR_SERVICE_NOT_AVAILABLE = TIZEN_ERROR_MAPS_SERVICE | 0x01,/**< Service unavailable */ MAPS_ERROR_NOT_FOUND = - TIZEN_ERROR_MAPS_SERVICE | 0x02/**< Result not found */ - + TIZEN_ERROR_MAPS_SERVICE | 0x02 /**< Result not found */ } maps_error_e; #ifdef __cplusplus diff --git a/include/maps_route_maneuver.h b/include/maps_route_maneuver.h index dd1e475..cd06179 100755 --- a/include/maps_route_maneuver.h +++ b/include/maps_route_maneuver.h @@ -53,25 +53,15 @@ typedef void *maps_route_maneuver_h; * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { - - MAPS_ROUTE_DIRECTION_NONE, /**< Indicates unknown direction */ - - MAPS_ROUTE_DIRECTION_NORTH, /**< Indicates north direction */ - - MAPS_ROUTE_DIRECTION_NORTHWEST, /**< Indicates north-west direction */ - - MAPS_ROUTE_DIRECTION_NORTHEAST, /**< Indicates north-east direction */ - - MAPS_ROUTE_DIRECTION_SOUTH, /**< Indicates south direction */ - - MAPS_ROUTE_DIRECTION_SOUTHEAST, /**< Indicates south-east direction */ - - MAPS_ROUTE_DIRECTION_SOUTHWEST, /**< Indicates south-west direction */ - - MAPS_ROUTE_DIRECTION_WEST, /**< Indicates west direction */ - - MAPS_ROUTE_DIRECTION_EAST /**< Indicates east direction */ - + MAPS_ROUTE_DIRECTION_NONE, /**< Indicates unknown direction */ + MAPS_ROUTE_DIRECTION_NORTH, /**< Indicates north direction */ + MAPS_ROUTE_DIRECTION_NORTHWEST, /**< Indicates north-west direction */ + MAPS_ROUTE_DIRECTION_NORTHEAST, /**< Indicates north-east direction */ + MAPS_ROUTE_DIRECTION_SOUTH, /**< Indicates south direction */ + MAPS_ROUTE_DIRECTION_SOUTHEAST, /**< Indicates south-east direction */ + MAPS_ROUTE_DIRECTION_SOUTHWEST, /**< Indicates south-west direction */ + MAPS_ROUTE_DIRECTION_WEST, /**< Indicates west direction */ + MAPS_ROUTE_DIRECTION_EAST /**< Indicates east direction */ } maps_route_direction_e; /** @@ -79,47 +69,21 @@ typedef enum { * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { - - MAPS_ROUTE_TURN_TYPE_NONE, /**< Indicates unknown instruction. */ - - MAPS_ROUTE_TURN_TYPE_STRAIGHT, /**< Indicates instruction to move - straight */ - - MAPS_ROUTE_TURN_TYPE_BEAR_RIGHT, /**< Indicates instruction to bear - right. */ - - MAPS_ROUTE_TURN_TYPE_LIGHT_RIGHT, /**< Indicates instruction slightly to - the right. */ - - MAPS_ROUTE_TURN_TYPE_RIGHT, /**< Indicates instruction to turn right. */ - - MAPS_ROUTE_TURN_TYPE_HARD_RIGHT, /**< Indicates instruction to turn hard - to the right. */ - - MAPS_ROUTE_TURN_TYPE_UTURN_RIGHT, /**< Indicates instruction to u-turn - to the right. */ - - MAPS_ROUTE_TURN_TYPE_UTURN_LEFT, /**< Indicates instruction to u-turn - to the left. */ - - MAPS_ROUTE_TURN_TYPE_HARD_LEFT, /**< Indicates instruction to turn hard - to the left. */ - - MAPS_ROUTE_TURN_TYPE_LEFT, /**< Indicates instruction to turn left. */ - - MAPS_ROUTE_TURN_TYPE_LIGHT_LEFT, /**< Indicates instruction to turn - lightly to the left. */ - - MAPS_ROUTE_TURN_TYPE_BEAR_LEFT, /**< Indicates instruction to bear - left. */ - - MAPS_ROUTE_TURN_TYPE_RIGHT_FORK, /**< Indicates right fork - instruction. */ - - MAPS_ROUTE_TURN_TYPE_LEFT_FORK, /**< Indicates left fork instruction. */ - - MAPS_ROUTE_TURN_TYPE_STRAIGHT_FORK /**< Indicates straight fork - instruction. */ + MAPS_ROUTE_TURN_TYPE_NONE, /**< Indicates unknown instruction. */ + MAPS_ROUTE_TURN_TYPE_STRAIGHT, /**< Indicates instruction to move straight */ + MAPS_ROUTE_TURN_TYPE_BEAR_RIGHT, /**< Indicates instruction to bear right. */ + MAPS_ROUTE_TURN_TYPE_LIGHT_RIGHT, /**< Indicates instruction slightly to the right. */ + MAPS_ROUTE_TURN_TYPE_RIGHT, /**< Indicates instruction to turn right. */ + MAPS_ROUTE_TURN_TYPE_HARD_RIGHT, /**< Indicates instruction to turn hard to the right. */ + MAPS_ROUTE_TURN_TYPE_UTURN_RIGHT, /**< Indicates instruction to u-turn to the right. */ + MAPS_ROUTE_TURN_TYPE_UTURN_LEFT, /**< Indicates instruction to u-turn to the left. */ + MAPS_ROUTE_TURN_TYPE_HARD_LEFT, /**< Indicates instruction to turn hard to the left. */ + MAPS_ROUTE_TURN_TYPE_LEFT, /**< Indicates instruction to turn left. */ + MAPS_ROUTE_TURN_TYPE_LIGHT_LEFT, /**< Indicates instruction to turn lightly to the left. */ + MAPS_ROUTE_TURN_TYPE_BEAR_LEFT, /**< Indicates instruction to bear left. */ + MAPS_ROUTE_TURN_TYPE_RIGHT_FORK, /**< Indicates right fork instruction. */ + MAPS_ROUTE_TURN_TYPE_LEFT_FORK, /**< Indicates left fork instruction. */ + MAPS_ROUTE_TURN_TYPE_STRAIGHT_FORK /**< Indicates straight fork instruction. */ } maps_route_turn_type_e; /*----------------------------------------------------------------------------*/ diff --git a/include/maps_view_object_plugin.h b/include/maps_view_object_plugin.h index 7115e93..1c7de8c 100644 --- a/include/maps_view_object_plugin.h +++ b/include/maps_view_object_plugin.h @@ -46,21 +46,11 @@ extern "C" { * @since_tizen 3.0 */ typedef enum _maps_view_object_operation_e { - - /** Indicates the add object operation */ - MAPS_VIEW_OBJECT_ADD, - - /** Indicates the change object visibility operation */ - MAPS_VIEW_OBJECT_SET_VISIBLE, - - /** Indicates the move object operation */ - MAPS_VIEW_OBJECT_MOVE, - - /** Indicates the operation of changing object specific properties */ - MAPS_VIEW_OBJECT_CHANGE, - - /** Indicates the remove object operation */ - MAPS_VIEW_OBJECT_REMOVE, + MAPS_VIEW_OBJECT_ADD, /**< Indicates the add object operation */ + MAPS_VIEW_OBJECT_SET_VISIBLE, /**< Indicates the change object visibility operation */ + MAPS_VIEW_OBJECT_MOVE, /**< Indicates the move object operation */ + MAPS_VIEW_OBJECT_CHANGE, /**< Indicates the operation of changing object specific properties */ + MAPS_VIEW_OBJECT_REMOVE, /**< Indicates the remove object operation */ } maps_view_object_operation_e; int maps_view_object_marker_set_size(const maps_view_object_h marker, int width, int height); diff --git a/src/api/maps_area.cpp b/src/api/maps_area.cpp index 77d6a14..5de01e5 100755 --- a/src/api/maps_area.cpp +++ b/src/api/maps_area.cpp @@ -43,8 +43,7 @@ EXPORT_API int maps_area_create_rectangle(const maps_coordinates_h top_left, if (lon_interval < 180 && lon_interval > -180) { if (rb_lon <= tf_lon || rb_lat >= tf_lat) return MAPS_ERROR_INVALID_PARAMETER; - } - else { + } else { if (rb_lon >= tf_lon || rb_lat >= tf_lat) return MAPS_ERROR_INVALID_PARAMETER; } @@ -118,14 +117,12 @@ EXPORT_API int maps_area_clone(const maps_area_h origin, maps_area_h *cloned) } else { return MAPS_ERROR_INVALID_PARAMETER; } - } - else if (origin_handle->type == MAPS_AREA_CIRCLE) { + } else if (origin_handle->type == MAPS_AREA_CIRCLE) { maps_area_h new_circle = NULL; maps_area_circle_s cir = origin_handle->circle; maps_coordinates_s center = cir.center; double radius = cir.radius; - maps_area_create_circle((maps_coordinates_h) & center, radius, - &new_circle); + maps_area_create_circle((maps_coordinates_h) & center, radius, &new_circle); if (new_circle) { *cloned = new_circle; } else { @@ -162,8 +159,7 @@ bool __is_valid_rect(maps_coordinates_h top_left, maps_coordinates_h bottom_righ if (lon_interval < 180 && lon_interval > -180) { if (rb_lon <= tf_lon || rb_lat >= tf_lat) ret = false; - } - else { + } else { if (rb_lon >= tf_lon || rb_lat >= tf_lat) ret = false; } @@ -187,8 +183,7 @@ bool maps_area_is_valid(const maps_area_h area) ret = false; break; } - } - else if (handle->type == MAPS_AREA_CIRCLE) { + } else if (handle->type == MAPS_AREA_CIRCLE) { maps_area_circle_s cir = handle->circle; maps_coordinates_s center = cir.center; @@ -200,8 +195,7 @@ bool maps_area_is_valid(const maps_area_h area) ret = false; break; } - } - else { + } else { ret = false; } } while (false); diff --git a/src/api/maps_extra_types.cpp b/src/api/maps_extra_types.cpp index b46fe75..3fdbdeb 100755 --- a/src/api/maps_extra_types.cpp +++ b/src/api/maps_extra_types.cpp @@ -62,8 +62,7 @@ EXPORT_API int maps_item_list_append(maps_item_list_h list, const void *data, const int error = clone_func((void *) data, &p); if (error != MAPS_ERROR_NONE) return error; - } - else { + } else { p = (void*)data; } maps_item_list_s *l = (maps_item_list_s *) list; @@ -93,8 +92,7 @@ EXPORT_API int maps_item_list_foreach(maps_item_list_h list, if (clone_func) { if (clone_func(data, &clone) != MAPS_ERROR_NONE) continue; - } - else { + } else { clone = data; } if (!callback(index++, total, clone, user_data)) @@ -448,7 +446,6 @@ EXPORT_API int maps_int_hashtable_foreach(maps_int_hashtable_h table, int index = 0; g_hash_table_iter_init(&iter, t->t); while (g_hash_table_iter_next(&iter, &key, &value)) { - if(!key || !value) continue; @@ -456,7 +453,6 @@ EXPORT_API int maps_int_hashtable_foreach(maps_int_hashtable_h table, int *value_ptr = (int *)value; if (!callback(index++, total, *key_ptr, *value_ptr, user_data)) break; - } return MAPS_ERROR_NONE; } @@ -469,7 +465,6 @@ EXPORT_API int maps_int_hashtable_clone(const maps_int_hashtable_h origin, int error = MAPS_ERROR_NONE; do { - error = maps_int_hashtable_create(cloned); if (!(*cloned) || (error != MAPS_ERROR_NONE)) break; @@ -496,7 +491,6 @@ EXPORT_API int maps_int_hashtable_clone(const maps_int_hashtable_h origin, } return MAPS_ERROR_NONE; - } while (false); maps_int_hashtable_destroy(*cloned); diff --git a/src/api/maps_place.cpp b/src/api/maps_place.cpp index 84a75ef..c9e9e00 100755 --- a/src/api/maps_place.cpp +++ b/src/api/maps_place.cpp @@ -84,7 +84,6 @@ typedef struct _maps_place_s /* The table of available data features */ maps_int_hashtable_h supported_data; - } maps_place_s; /* TODO: extract all such constants to the dedcated header file */ diff --git a/src/api/maps_place_category.cpp b/src/api/maps_place_category.cpp index e3337ea..3de89c7 100755 --- a/src/api/maps_place_category.cpp +++ b/src/api/maps_place_category.cpp @@ -99,7 +99,6 @@ EXPORT_API int maps_place_category_clone(const maps_place_category_h origin, } return MAPS_ERROR_NONE; - } while (false); maps_place_category_destroy(*cloned); diff --git a/src/api/maps_preference.cpp b/src/api/maps_preference.cpp index b0f2558..674c473 100755 --- a/src/api/maps_preference.cpp +++ b/src/api/maps_preference.cpp @@ -69,8 +69,8 @@ static bool __isnamed_preference(const char *key) } static bool __maps_preference_properties_helper_cb(int index, int total, - char *key, void *value, - void *user_data) + char *key, void *value, + void *user_data) { /* Do not return the "named" preference, which can be obtained, */ /* with other functions from this module. */ @@ -129,7 +129,7 @@ EXPORT_API int maps_preference_destroy(maps_preference_h preference) } EXPORT_API int maps_preference_clone(const maps_preference_h origin, - maps_preference_h *cloned) + maps_preference_h *cloned) { if (!cloned || !origin) return MAPS_ERROR_INVALID_PARAMETER; @@ -138,9 +138,8 @@ EXPORT_API int maps_preference_clone(const maps_preference_h origin, /*----------------------------------------------------------------------------*/ -EXPORT_API int maps_preference_get_distance_unit(const maps_preference_h - preference, - maps_distance_unit_e *unit) +EXPORT_API int maps_preference_get_distance_unit(const maps_preference_h preference, + maps_distance_unit_e *unit) { if (!preference || !unit) return MAPS_ERROR_INVALID_PARAMETER; @@ -149,7 +148,7 @@ EXPORT_API int maps_preference_get_distance_unit(const maps_preference_h } EXPORT_API int maps_preference_get_language(const maps_preference_h preference, - char **language) + char **language) { if (!preference || !language) return MAPS_ERROR_INVALID_PARAMETER; @@ -157,9 +156,8 @@ EXPORT_API int maps_preference_get_language(const maps_preference_h preference, "MAPS_PREFERENCE_LANGUAGE", language); } -EXPORT_API int maps_preference_get_max_results(const maps_preference_h - preference, - int *max_results) +EXPORT_API int maps_preference_get_max_results(const maps_preference_h preference, + int *max_results) { if (!preference || !max_results) return MAPS_ERROR_INVALID_PARAMETER; @@ -167,9 +165,8 @@ EXPORT_API int maps_preference_get_max_results(const maps_preference_h "MAPS_PREFERENCE_MAX_RESULTS", max_results); } -EXPORT_API int maps_preference_get_country_code(const maps_preference_h - preference, - char **country_code) +EXPORT_API int maps_preference_get_country_code(const maps_preference_h preference, + char **country_code) { if (!preference || !country_code) return MAPS_ERROR_INVALID_PARAMETER; @@ -177,10 +174,8 @@ EXPORT_API int maps_preference_get_country_code(const maps_preference_h "MAPS_PREFERENCE_COUNTRY_CODE", country_code); } -EXPORT_API int maps_preference_get_route_optimization(const maps_preference_h - preference, - maps_route_optimization_e* - optimization) +EXPORT_API int maps_preference_get_route_optimization(const maps_preference_h preference, + maps_route_optimization_e *optimization) { if (!preference || !optimization) return MAPS_ERROR_INVALID_PARAMETER; @@ -188,10 +183,8 @@ EXPORT_API int maps_preference_get_route_optimization(const maps_preference_h "MAPS_PREFERENCE_ROUTE_OPTIMIZATION", (int *) optimization); } -EXPORT_API int maps_preference_get_route_transport_mode(const maps_preference_h - preference, - maps_route_transport_mode_e * - transport_mode) +EXPORT_API int maps_preference_get_route_transport_mode(const maps_preference_h preference, + maps_route_transport_mode_e *transport_mode) { if (!preference || !transport_mode) return MAPS_ERROR_INVALID_PARAMETER; @@ -199,10 +192,8 @@ EXPORT_API int maps_preference_get_route_transport_mode(const maps_preference_h "MAPS_PREFERENCE_ROUTE_TRANSPORT_MODE", (int *) transport_mode); } -EXPORT_API int maps_preference_get_route_feature_weight(const maps_preference_h - preference, - maps_route_feature_weight_e * - feature_weight) +EXPORT_API int maps_preference_get_route_feature_weight(const maps_preference_h preference, + maps_route_feature_weight_e *feature_weight) { if (!preference || !feature_weight) return MAPS_ERROR_INVALID_PARAMETER; @@ -210,9 +201,8 @@ EXPORT_API int maps_preference_get_route_feature_weight(const maps_preference_h "MAPS_PREFERENCE_ROUTE_FEATURE_WEIGHT", (int *) feature_weight); } -EXPORT_API int maps_preference_get_route_feature(const maps_preference_h - preference, - maps_route_feature_e * feature) +EXPORT_API int maps_preference_get_route_feature(const maps_preference_h preference, + maps_route_feature_e * feature) { if (!preference || !feature) return MAPS_ERROR_INVALID_PARAMETER; @@ -220,7 +210,8 @@ EXPORT_API int maps_preference_get_route_feature(const maps_preference_h "MAPS_PREFERENCE_ROUTE_FEATURE", (int *) feature); } -EXPORT_API int maps_preference_get_route_alternatives_enabled(const maps_preference_h preference, bool *enable) +EXPORT_API int maps_preference_get_route_alternatives_enabled( + const maps_preference_h preference, bool *enable) { if (!preference) return MAPS_ERROR_INVALID_PARAMETER; @@ -244,10 +235,8 @@ EXPORT_API int maps_preference_get(const maps_preference_h preference, } -EXPORT_API int maps_preference_foreach_property(const maps_preference_h - preference, - maps_preference_properties_cb - callback, void *user_data) +EXPORT_API int maps_preference_foreach_property(const maps_preference_h preference, + maps_preference_properties_cb callback, void *user_data) { if (!preference || !callback) return MAPS_ERROR_INVALID_PARAMETER; @@ -259,8 +248,7 @@ EXPORT_API int maps_preference_foreach_property(const maps_preference_h /*----------------------------------------------------------------------------*/ EXPORT_API int maps_preference_set_distance_unit(maps_preference_h preference, - const maps_distance_unit_e - unit) + const maps_distance_unit_e unit) { if (!preference) return MAPS_ERROR_INVALID_PARAMETER; @@ -271,7 +259,7 @@ EXPORT_API int maps_preference_set_distance_unit(maps_preference_h preference, } EXPORT_API int maps_preference_set_language(maps_preference_h preference, - const char *language) + const char *language) { if (!preference || !language) return MAPS_ERROR_INVALID_PARAMETER; @@ -280,7 +268,7 @@ EXPORT_API int maps_preference_set_language(maps_preference_h preference, } EXPORT_API int maps_preference_set_max_results(maps_preference_h preference, - const int max_results) + const int max_results) { if (!preference || max_results <= 0) return MAPS_ERROR_INVALID_PARAMETER; @@ -289,7 +277,7 @@ EXPORT_API int maps_preference_set_max_results(maps_preference_h preference, } EXPORT_API int maps_preference_set_country_code(maps_preference_h preference, - const char *country_code) + const char *country_code) { if (!preference || !country_code) return MAPS_ERROR_INVALID_PARAMETER; @@ -297,10 +285,8 @@ EXPORT_API int maps_preference_set_country_code(maps_preference_h preference, "MAPS_PREFERENCE_COUNTRY_CODE", country_code); } -EXPORT_API int maps_preference_set_route_optimization(maps_preference_h - preference, - const maps_route_optimization_e - optimization) +EXPORT_API int maps_preference_set_route_optimization(maps_preference_h preference, + const maps_route_optimization_e optimization) { if (!preference) return MAPS_ERROR_INVALID_PARAMETER; @@ -311,10 +297,8 @@ EXPORT_API int maps_preference_set_route_optimization(maps_preference_h "MAPS_PREFERENCE_ROUTE_OPTIMIZATION", optimization); } -EXPORT_API int maps_preference_set_route_transport_mode(maps_preference_h - preference, - const maps_route_transport_mode_e - transport_mode) +EXPORT_API int maps_preference_set_route_transport_mode(maps_preference_h preference, + const maps_route_transport_mode_e transport_mode) { if (!preference) return MAPS_ERROR_INVALID_PARAMETER; @@ -325,10 +309,8 @@ EXPORT_API int maps_preference_set_route_transport_mode(maps_preference_h "MAPS_PREFERENCE_ROUTE_TRANSPORT_MODE", transport_mode); } -EXPORT_API int maps_preference_set_route_feature_weight(maps_preference_h - preference, - const maps_route_feature_weight_e - feature_weight) +EXPORT_API int maps_preference_set_route_feature_weight(maps_preference_h preference, + const maps_route_feature_weight_e feature_weight) { if (!preference) return MAPS_ERROR_INVALID_PARAMETER; @@ -340,8 +322,7 @@ EXPORT_API int maps_preference_set_route_feature_weight(maps_preference_h } EXPORT_API int maps_preference_set_route_feature(maps_preference_h preference, - const maps_route_feature_e - feature) + const maps_route_feature_e feature) { if (!preference) return MAPS_ERROR_INVALID_PARAMETER; @@ -352,7 +333,8 @@ EXPORT_API int maps_preference_set_route_feature(maps_preference_h preference, "MAPS_PREFERENCE_ROUTE_FEATURE", feature); } -EXPORT_API int maps_preference_set_route_alternatives_enabled(maps_preference_h preference, bool enable) +EXPORT_API int maps_preference_set_route_alternatives_enabled(maps_preference_h preference, + bool enable) { if (!preference) return MAPS_ERROR_INVALID_PARAMETER; @@ -379,7 +361,6 @@ EXPORT_API int maps_preference_append_route_feature(maps_preference_h preference, maps_item_list_h feature_list, maps_route_feature_weight_e feature) { - if (!preference || max_result_count <= 0) return MAPS_ERROR_INVALID_PARAMETER; @@ -404,7 +385,6 @@ EXPORT_API int maps_preference_remove_route_feature(maps_preference_h preference, maps_item_list_h feature_list, maps_route_feature_weight_e feature) { - if (!preference || !feature_list) return MAPS_ERROR_INVALID_PARAMETER; diff --git a/src/api/maps_view.cpp b/src/api/maps_view.cpp index fcab15d..3271910 100644 --- a/src/api/maps_view.cpp +++ b/src/api/maps_view.cpp @@ -54,7 +54,6 @@ typedef struct _maps_view_idle_listener_info_s { * The structure of Maps View internal data */ typedef struct _maps_view_s { - /* Map Coordinates and Area */ maps_area_h area; maps_coordinates_h center; @@ -190,7 +189,7 @@ session::command_queue *__maps_view_select_q() bool _maps_view_is_gesture_available(maps_view_h view, maps_view_gesture_e gesture) { - if(!view) + if (!view) return false; maps_view_s *v = (maps_view_s *)view; return v->gesture_available[gesture]; @@ -198,7 +197,7 @@ bool _maps_view_is_gesture_available(maps_view_h view, maps_view_gesture_e gestu maps_view_action_e _maps_view_get_gesture_action(maps_view_h view, maps_view_gesture_e gesture) { - if(!view) + if (!view) return MAPS_VIEW_ACTION_NONE; maps_view_s *v = (maps_view_s *)view; return v->gesture_actions[gesture]; @@ -206,7 +205,7 @@ maps_view_action_e _maps_view_get_gesture_action(maps_view_h view, maps_view_ges void *_maps_view_get_maps_service_ptr(maps_view_h view) { - if(!view) + if (!view) return NULL; maps_view_s *v = (maps_view_s *)view; return v->maps; @@ -214,10 +213,10 @@ void *_maps_view_get_maps_service_ptr(maps_view_h view) int _maps_view_on_object_operation(maps_view_h view, maps_view_object_h object, maps_view_object_operation_e operation) { - if(!view) + if (!view) return MAPS_ERROR_INVALID_PARAMETER; - if(!__get_plugin_interface(view)->maps_plugin_on_object) + if (!__get_plugin_interface(view)->maps_plugin_on_object) return MAPS_ERROR_INVALID_PARAMETER; return __get_plugin_interface(view)->maps_plugin_on_object(view, object, operation); @@ -226,12 +225,12 @@ int _maps_view_on_object_operation(maps_view_h view, maps_view_object_h object, static void __on_canvas_tap(void *data, Evas *e, Evas_Object *obj, void *event_info) { MAPS_LOGI("__on_canvas_tap"); - if(!event_info || !data) + if (!event_info || !data) return; /* Extract the view ptr */ maps_view_s *v = (maps_view_s *)data; - if(!v->finger_stream) + if (!v->finger_stream) return; /* Detect & Process the gesture */ @@ -241,12 +240,12 @@ static void __on_canvas_tap(void *data, Evas *e, Evas_Object *obj, void *event_i static void __on_canvas_up(void *data, Evas *e, Evas_Object *obj, void *event_info) { MAPS_LOGI("__on_canvas_up"); - if(!event_info || !data) + if (!event_info || !data) return; /* Extract the view ptr */ maps_view_s *v = (maps_view_s *)data; - if(!v->finger_stream) + if (!v->finger_stream) return; /* Detect & Process the gesture */ @@ -256,12 +255,12 @@ static void __on_canvas_up(void *data, Evas *e, Evas_Object *obj, void *event_in static void __on_canvas_line(void *data, Evas *e, Evas_Object *obj, void *event_info) { MAPS_LOGI("__on_canvas_line"); - if(!event_info || !data) + if (!event_info || !data) return; /* Extract view ptr */ maps_view_s *v = (maps_view_s *)data; - if(!v->finger_stream) + if (!v->finger_stream) return; /* Detect & Process the gesture */ @@ -271,12 +270,12 @@ static void __on_canvas_line(void *data, Evas *e, Evas_Object *obj, void *event_ static void __on_canvas_multi_tap(void *data, Evas *e, Evas_Object *obj, void *event_info) { MAPS_LOGI("__on_canvas_multi_tap"); - if(!event_info || !data) + if (!event_info || !data) return; /* Extract view ptr */ maps_view_s *v = (maps_view_s *)data; - if(!v->finger_stream) + if (!v->finger_stream) return; /* Detect & Process the gesture */ @@ -287,12 +286,12 @@ static void __on_canvas_multi_tap(void *data, Evas *e, Evas_Object *obj, void *e static void __on_canvas_multi_up(void *data, Evas *e, Evas_Object *obj, void *event_info) { MAPS_LOGI("__on_canvas_multi_up"); - if(!event_info || !data) + if (!event_info || !data) return; /* Extract view ptr */ maps_view_s *v = (maps_view_s *)data; - if(!v->finger_stream) + if (!v->finger_stream) return; /* Detect & Process the gesture */ @@ -307,18 +306,17 @@ static int __maps_plugin_render_map(const maps_view_h view, return __get_plugin_interface(view)->maps_plugin_render_map(view, coordinates, zoom_factor, rotation_angle); - } static void __on_canvas_multi_line(void *data, Evas *e, Evas_Object *obj, void *event_info) { MAPS_LOGI("__on_canvas_multi_line"); - if(!event_info || !data) + if (!event_info || !data) return; /* Extract view ptr */ maps_view_s *v = (maps_view_s *)data; - if(!v->finger_stream) + if (!v->finger_stream) return; /* Detect & Process the gesture */ @@ -328,7 +326,7 @@ static void __on_canvas_multi_line(void *data, Evas *e, Evas_Object *obj, void * void _maps_view_set_idle_listener(const maps_view_h view, void (*callback)(void *user_data), void *user_data) { - if(!view) + if (!view) return; maps_view_s *v = (maps_view_s *)view; v->idle_listener.callback = callback; @@ -338,7 +336,7 @@ void _maps_view_set_idle_listener(const maps_view_h view, void _maps_view_halt_inertial_camera(maps_view_h view) { maps_view_s *v = (maps_view_s *)view; - if(v && v->inertial_camera && v->inertial_camera->is_transiting()) { + if (v && v->inertial_camera && v->inertial_camera->is_transiting()) { v->inertial_camera->set_transiting(false); g_usleep(0); } @@ -355,14 +353,14 @@ static Eina_Bool __maps_view_on_idle_cb(void *data) bool is_continue = false; view::inertial_gesture *ig = v->inertial_gesture; - if(ig && ig->is_transiting()) { + if (ig && ig->is_transiting()) { is_transiting |= true; is_continue |= ig->next_transition_step(); g_usleep(5*1000); } view::inertial_camera *ic = v->inertial_camera; - if(ic && ic->is_transiting()) { + if (ic && ic->is_transiting()) { is_transiting |= true; is_continue |= ic->next_transition_step(); __maps_plugin_render_map(v, @@ -374,7 +372,7 @@ static Eina_Bool __maps_view_on_idle_cb(void *data) if (is_transiting && !is_continue) { maps_view_event_data_h ed = _maps_view_create_event_data(MAPS_VIEW_EVENT_READY); - if(ed) { + if (ed) { _maps_view_invoke_event_callback(v, ed); maps_view_event_data_destroy(ed); } @@ -396,7 +394,7 @@ void __maps_view_ready(const maps_view_h view) /* Invoke user registered event callback */ maps_view_event_data_h ed = _maps_view_create_event_data(MAPS_VIEW_EVENT_READY); - if(ed) { + if (ed) { _maps_view_invoke_event_callback(view, ed); maps_view_event_data_destroy(ed); } @@ -506,9 +504,9 @@ EXPORT_API int maps_view_create(maps_service_h maps, Evas_Image *obj, maps_view_ __get_plugin_interface(v)->maps_plugin_get_min_zoom_level(v, &v->min_zoom_level); __get_plugin_interface(v)->maps_plugin_get_max_zoom_level(v, &v->max_zoom_level); - if(v->min_zoom_level <= 0) + if (v->min_zoom_level <= 0) v->min_zoom_level = 2; - if(v->max_zoom_level <= 0) + if (v->max_zoom_level <= 0) v->max_zoom_level = 2; v->zoom_level = v->min_zoom_level; @@ -534,7 +532,7 @@ EXPORT_API int maps_view_destroy(maps_view_h view) maps_view_s *v = (maps_view_s *) view; /* Unregister gesture processing */ - if(v->finger_stream) + if (v->finger_stream) delete v->finger_stream; v->finger_stream = NULL; @@ -595,7 +593,7 @@ int _maps_view_set_center_directly(const maps_view_h view, return MAPS_ERROR_INVALID_PARAMETER; maps_view_s *v = (maps_view_s *) view; - if(v->center != coordinates) { + if (v->center != coordinates) { if (v->center) maps_coordinates_destroy(v->center); maps_coordinates_clone(coordinates, &v->center); @@ -633,7 +631,7 @@ EXPORT_API int maps_view_set_center(maps_view_h view, maps_coordinates_h coordin maps_view_s *v = (maps_view_s *) view; /* Set up the target for camera inertial movement */ - if(v->inertial_camera) + if (v->inertial_camera) v->inertial_camera->set_targets(coordinates, zoom_factor, rotation_angle); @@ -644,7 +642,7 @@ EXPORT_API int maps_view_set_center(maps_view_h view, maps_coordinates_h coordin zoom_factor, rotation_angle); - if(v->center != coordinates) { + if (v->center != coordinates) { maps_coordinates_destroy(v->center); maps_coordinates_clone(coordinates, &v->center); } @@ -652,7 +650,7 @@ EXPORT_API int maps_view_set_center(maps_view_h view, maps_coordinates_h coordin /* Invoke user registered event callback */ maps_view_event_data_h ed = _maps_view_create_event_data(MAPS_VIEW_EVENT_ACTION); - if(ed) { + if (ed) { _maps_view_event_data_set_action_type(ed, MAPS_VIEW_ACTION_SCROLL); _maps_view_event_data_set_center(ed, v->center); _maps_view_invoke_event_callback(v, ed); @@ -672,7 +670,7 @@ int _maps_view_move_center(maps_view_h view, const int delta_x, const int delta_ /* Invoke user registered event callback */ maps_view_event_data_h ed = _maps_view_create_event_data(MAPS_VIEW_EVENT_ACTION); - if(ed) { + if (ed) { _maps_view_event_data_set_action_type(ed, MAPS_VIEW_ACTION_SCROLL); _maps_view_event_data_set_delta(ed, delta_x, delta_y); _maps_view_invoke_event_callback(view, ed); @@ -717,7 +715,7 @@ EXPORT_API int maps_view_set_zoom_level(maps_view_h view, int level) if (new_level > v->max_zoom_level) new_level = v->max_zoom_level; /* Add inertia to the zoom process */ - if(v->inertial_camera) + if (v->inertial_camera) v->inertial_camera->set_zoom_target(double(new_level)); v->zoom_level = new_level; @@ -728,7 +726,7 @@ EXPORT_API int maps_view_set_zoom_level(maps_view_h view, int level) /* Invoke user registered event callback */ maps_view_event_data_h ed = _maps_view_create_event_data(MAPS_VIEW_EVENT_ACTION); - if(ed) { + if (ed) { _maps_view_event_data_set_action_type(ed, MAPS_VIEW_ACTION_ZOOM); _maps_view_event_data_set_zoom_factor(ed, v->zoom_factor); _maps_view_invoke_event_callback(v, ed); @@ -783,7 +781,7 @@ int _maps_view_set_zoom_rotate(maps_view_h view, if (new_factor > v->max_zoom_level) new_factor = v->max_zoom_level; /* Add inertia to the zoom process */ - if(v->inertial_camera) + if (v->inertial_camera) v->inertial_camera->set_zoom_target(new_factor); /* Update Map View zoom factor */ @@ -795,7 +793,7 @@ int _maps_view_set_zoom_rotate(maps_view_h view, if (rotation_changed) { /* Add inertia to the rotation process */ - if(v->inertial_camera) + if (v->inertial_camera) v->inertial_camera->set_rotation_target(angle); /* Update Map View rotation angle */ @@ -810,7 +808,7 @@ int _maps_view_set_zoom_rotate(maps_view_h view, /* Invoke user registered event callback */ maps_view_event_data_h ed = _maps_view_create_event_data(MAPS_VIEW_EVENT_ACTION); - if(ed) { + if (ed) { _maps_view_event_data_set_action_type(ed, MAPS_VIEW_ACTION_ZOOM); _maps_view_event_data_set_zoom_factor(ed, v->zoom_factor); _maps_view_invoke_event_callback(v, ed); @@ -822,7 +820,7 @@ int _maps_view_set_zoom_rotate(maps_view_h view, /* Invoke user registered event callback */ maps_view_event_data_h ed = _maps_view_create_event_data(MAPS_VIEW_EVENT_ACTION); - if(ed) { + if (ed) { _maps_view_event_data_set_action_type(ed, MAPS_VIEW_ACTION_ROTATE); _maps_view_event_data_set_rotation_angle(ed, v->rotation_angle); _maps_view_invoke_event_callback(v, ed); @@ -863,7 +861,7 @@ EXPORT_API int maps_view_set_orientation(maps_view_h view, double angle) /* Add inertia to the rotation process */ maps_view_s *v = (maps_view_s *)view; - if(v->inertial_camera) + if (v->inertial_camera) v->inertial_camera->set_rotation_target(angle); return _maps_view_set_zoom_rotate(view, false, .0, true, angle); @@ -994,8 +992,8 @@ int _maps_view_set_inertia_enabled(maps_view_h view, bool enabled) return MAPS_ERROR_INVALID_PARAMETER; maps_view_s *v = (maps_view_s *) view; - if(enabled) { - if(!v->inertial_gesture) { + if (enabled) { + if (!v->inertial_gesture) { v->inertial_gesture = new view::inertial_gesture(view); if (!v->inertial_gesture) { MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY); @@ -1003,7 +1001,7 @@ int _maps_view_set_inertia_enabled(maps_view_h view, bool enabled) } } - if(!v->inertial_camera) { + if (!v->inertial_camera) { v->inertial_camera = new view::inertial_camera(view); if (!v->inertial_camera) { MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY); @@ -1015,9 +1013,9 @@ int _maps_view_set_inertia_enabled(maps_view_h view, bool enabled) } else { v->finger_stream->set_gesture_detector(new view::gesture_detector_statemachine(view)); - if(v->inertial_gesture) { + if (v->inertial_gesture) { /* Unset Inertial Camera */ - if(v->inertial_gesture->is_transiting()) { + if (v->inertial_gesture->is_transiting()) { v->inertial_gesture->set_transiting(false); sleep(0); } @@ -1026,9 +1024,9 @@ int _maps_view_set_inertia_enabled(maps_view_h view, bool enabled) delete inertial_gesture; } - if(v->inertial_camera) { + if (v->inertial_camera) { /* Unset Inertial Camera */ - if(v->inertial_camera->is_transiting()) { + if (v->inertial_camera->is_transiting()) { v->inertial_camera->set_transiting(false); sleep(0); } @@ -1074,12 +1072,12 @@ EXPORT_API int maps_view_set_language(maps_view_h view, const char *language) }; bool supported = false; for(unsigned int i = 0; i < (sizeof(lngs) / sizeof(lngs[0])); i ++) { - if(g_strcmp0(language, lngs[i]) == 0) { + if (g_strcmp0(language, lngs[i]) == 0) { supported = true; break; } } - if(!supported) + if (!supported) return MAPS_ERROR_INVALID_PARAMETER; maps_view_s *v = (maps_view_s *) view; @@ -1187,7 +1185,7 @@ EXPORT_API int maps_view_set_event_cb(maps_view_h view, maps_view_event_type_e t { if (!view || !callback) return MAPS_ERROR_INVALID_PARAMETER; - if((type < MAPS_VIEW_EVENT_GESTURE) || (type > MAPS_VIEW_EVENT_READY)) + if ((type < MAPS_VIEW_EVENT_GESTURE) || (type > MAPS_VIEW_EVENT_READY)) return MAPS_ERROR_INVALID_PARAMETER; maps_view_s *v = (maps_view_s *) view; @@ -1201,7 +1199,7 @@ EXPORT_API int maps_view_unset_event_cb(maps_view_h view, maps_view_event_type_e { if (!view) return MAPS_ERROR_INVALID_PARAMETER; - if((type < MAPS_VIEW_EVENT_GESTURE) || (type > MAPS_VIEW_EVENT_READY)) + if ((type < MAPS_VIEW_EVENT_GESTURE) || (type > MAPS_VIEW_EVENT_READY)) return MAPS_ERROR_INVALID_PARAMETER; maps_view_s *v = (maps_view_s *) view; @@ -1215,7 +1213,7 @@ EXPORT_API int maps_view_set_gesture_enabled(maps_view_h view, maps_view_gesture { if (!view) return MAPS_ERROR_INVALID_PARAMETER; - if((gesture < MAPS_VIEW_GESTURE_NONE) || (gesture > MAPS_VIEW_GESTURE_LONG_PRESS)) + if ((gesture < MAPS_VIEW_GESTURE_NONE) || (gesture > MAPS_VIEW_GESTURE_LONG_PRESS)) return MAPS_ERROR_INVALID_PARAMETER; maps_view_s *v = (maps_view_s *) view; v->gesture_available[gesture] = enabled; @@ -1226,7 +1224,7 @@ EXPORT_API int maps_view_get_gesture_enabled(const maps_view_h view, maps_view_g { if (!view || !enabled) return MAPS_ERROR_INVALID_PARAMETER; - if((gesture < MAPS_VIEW_GESTURE_NONE) || (gesture > MAPS_VIEW_GESTURE_LONG_PRESS)) + if ((gesture < MAPS_VIEW_GESTURE_NONE) || (gesture > MAPS_VIEW_GESTURE_LONG_PRESS)) return MAPS_ERROR_INVALID_PARAMETER; maps_view_s *v = (maps_view_s *) view; *enabled = v->gesture_available[gesture]; @@ -1246,26 +1244,26 @@ EXPORT_API int maps_view_add_object(maps_view_h view, maps_view_object_h object) /* Add Visual Object to the list of View Visual Objects */ maps_view_s *v = (maps_view_s *)view; error = maps_item_list_append(v->view_objects, object, NULL); - if(error != MAPS_ERROR_NONE) + if (error != MAPS_ERROR_NONE) break; /* Link the object with the View */ error = _maps_view_object_set_view(object, view); - if(error != MAPS_ERROR_NONE) + if (error != MAPS_ERROR_NONE) break; /* Notify the plugin about added object */ error = _maps_view_on_object_operation(view, object, MAPS_VIEW_OBJECT_ADD); - if(error != MAPS_ERROR_NONE) + if (error != MAPS_ERROR_NONE) break; /* Redraw the view */ error = _maps_view_redraw(v); - if(error != MAPS_ERROR_NONE) + if (error != MAPS_ERROR_NONE) break; return MAPS_ERROR_NONE; - } while(false); + } while (false); return error; } @@ -1280,16 +1278,16 @@ EXPORT_API int maps_view_remove_object(maps_view_h view, maps_view_object_h obje /* Remove Visual Object from the list of View Visual Objects */ maps_view_s *v = (maps_view_s *)view; error = maps_item_list_remove(v->view_objects, object, maps_view_object_destroy); - if(error != MAPS_ERROR_NONE) + if (error != MAPS_ERROR_NONE) return error; /* Redraw the view */ error = _maps_view_redraw(v); - if(error != MAPS_ERROR_NONE) + if (error != MAPS_ERROR_NONE) return error; return MAPS_ERROR_NONE; - } while(false); + } while (false); return error; } @@ -1303,16 +1301,16 @@ EXPORT_API int maps_view_remove_all_objects(maps_view_h view) do { maps_view_s *v = (maps_view_s *)view; error = maps_item_list_remove_all(v->view_objects, maps_view_object_destroy); - if(error != MAPS_ERROR_NONE) + if (error != MAPS_ERROR_NONE) return error; /* Redraw the view */ error = _maps_view_redraw(v); - if(error != MAPS_ERROR_NONE) + if (error != MAPS_ERROR_NONE) return error; return MAPS_ERROR_NONE; - } while(false); + } while (false); return error; } @@ -1334,11 +1332,11 @@ maps_view_event_data_h _maps_view_create_event_data(maps_view_event_type_e type) { maps_view_event_data_h event_data = NULL; const int error = _maps_view_event_data_create(&event_data); - if(error != MAPS_ERROR_NONE) { + if (error != MAPS_ERROR_NONE) { maps_view_event_data_destroy(event_data); return NULL; } - if(!event_data) + if (!event_data) return NULL; _maps_view_event_data_set_type(event_data, type); return event_data; @@ -1346,7 +1344,7 @@ maps_view_event_data_h _maps_view_create_event_data(maps_view_event_type_e type) void _maps_view_invoke_event_callback(maps_view_h view, maps_view_event_data_h event_data) { - if(!view || !event_data) + if (!view || !event_data) return; maps_view_s *v = (maps_view_s *)view; @@ -1377,7 +1375,7 @@ typedef struct _maps_view_collect_poly_object_point_s { static bool __maps_view_object_poly_collect_points_cb(int index, maps_coordinates_h point, void *user_data) { - if(!point || !user_data) + if (!point || !user_data) return false; maps_view_collect_poly_object_point_s *cpop = @@ -1385,7 +1383,7 @@ static bool __maps_view_object_poly_collect_points_cb(int index, maps_coordinate int x = 0; int y = 0; - if(maps_view_geolocation_to_screen(cpop->v, point, &x, &y) == MAPS_ERROR_NONE) + if (maps_view_geolocation_to_screen(cpop->v, point, &x, &y) == MAPS_ERROR_NONE) cpop->pd->add_point(float(x), float(y)); return true; @@ -1393,7 +1391,7 @@ static bool __maps_view_object_poly_collect_points_cb(int index, maps_coordinate static bool __maps_view_hit_test_cb(int index, int total, maps_view_object_h object, void *user_data) { - if(!object || !user_data) + if (!object || !user_data) return false; /* If it is an unvisible object, skip this hit-testing. */ @@ -1411,12 +1409,12 @@ static bool __maps_view_hit_test_cb(int index, int total, maps_view_object_h obj maps_view_collect_poly_object_point_s cpop = {htd->v, &pd}; int error = maps_view_object_polyline_foreach_point(object, __maps_view_object_poly_collect_points_cb, &cpop); - if(error != MAPS_ERROR_NONE) + if (error != MAPS_ERROR_NONE) break; int width = 0; maps_view_object_polyline_get_width(object, &width); - if(pd.hit_test(float(htd->x), float(htd->y), false, width)) + if (pd.hit_test(float(htd->x), float(htd->y), false, width)) htd->object = object; break; @@ -1427,10 +1425,10 @@ static bool __maps_view_hit_test_cb(int index, int total, maps_view_object_h obj maps_view_collect_poly_object_point_s cpop = {htd->v, &pd}; int error = maps_view_object_polygon_foreach_point(object, __maps_view_object_poly_collect_points_cb, &cpop); - if(error != MAPS_ERROR_NONE) + if (error != MAPS_ERROR_NONE) break; - if(pd.hit_test(float(htd->x), float(htd->y), true)) + if (pd.hit_test(float(htd->x), float(htd->y), true)) htd->object = object; break; @@ -1459,7 +1457,7 @@ static bool __maps_view_hit_test_cb(int index, int total, maps_view_object_h obj if (h < 30) h = 30; /* Check hit-area */ - if((x > (htd->x - w)) && (x < (htd->x + w)) + if ((x > (htd->x - w)) && (x < (htd->x + w)) && (y > (htd->y - h)) && (y < (htd->y + h))) { htd->object = object; } @@ -1469,7 +1467,7 @@ static bool __maps_view_hit_test_cb(int index, int total, maps_view_object_h obj break; } - if(htd->object) + if (htd->object) return false; return true; diff --git a/src/api/maps_view_event_data.cpp b/src/api/maps_view_event_data.cpp index 7a86480..7996e76 100644 --- a/src/api/maps_view_event_data.cpp +++ b/src/api/maps_view_event_data.cpp @@ -23,7 +23,6 @@ * This represents visual event object information */ typedef struct _maps_view_event_data_s { - maps_view_event_type_e event_type; /* Applicable for set_center action */ @@ -54,7 +53,6 @@ typedef struct _maps_view_event_data_s { /* Applicable for object event */ maps_view_object_h object; - } maps_view_event_data_s; /*----------------------------------------------------------------------------*/ @@ -108,7 +106,7 @@ EXPORT_API int maps_view_event_data_destroy(maps_view_event_data_h event) maps_view_event_data_s *e = (maps_view_event_data_s *) event; - if(e->center) + if (e->center) maps_coordinates_destroy(e->center); g_slice_free(maps_view_event_data_s, e); @@ -205,7 +203,7 @@ int _maps_view_event_data_set_gesture_type(maps_view_event_data_h event, maps_vi { if (!event) return MAPS_ERROR_INVALID_PARAMETER; - if((gesture_type < MAPS_VIEW_GESTURE_NONE) || (gesture_type > MAPS_VIEW_GESTURE_LONG_PRESS)) + if ((gesture_type < MAPS_VIEW_GESTURE_NONE) || (gesture_type > MAPS_VIEW_GESTURE_LONG_PRESS)) return MAPS_ERROR_INVALID_PARAMETER; maps_view_event_data_s *e = (maps_view_event_data_s *) event; e->gesture_type = gesture_type; @@ -216,7 +214,7 @@ int _maps_view_event_data_set_action_type(maps_view_event_data_h event, maps_vie { if (!event) return MAPS_ERROR_INVALID_PARAMETER; - if((action_type < MAPS_VIEW_ACTION_NONE) || (action_type > MAPS_VIEW_ACTION_ROTATE)) + if ((action_type < MAPS_VIEW_ACTION_NONE) || (action_type > MAPS_VIEW_ACTION_ROTATE)) return MAPS_ERROR_INVALID_PARAMETER; maps_view_event_data_s *e = (maps_view_event_data_s *) event; e->action_type = action_type; @@ -267,7 +265,7 @@ EXPORT_API int maps_view_event_data_get_gesture_type(const maps_view_event_data_ if (!event || !gesture_type) return MAPS_ERROR_INVALID_PARAMETER; maps_view_event_data_s *e = (maps_view_event_data_s *) event; - if((e->event_type != MAPS_VIEW_EVENT_GESTURE) && (e->event_type != MAPS_VIEW_EVENT_OBJECT)) + if ((e->event_type != MAPS_VIEW_EVENT_GESTURE) && (e->event_type != MAPS_VIEW_EVENT_OBJECT)) return MAPS_ERROR_INVALID_PARAMETER; *gesture_type = e->gesture_type; return MAPS_ERROR_NONE; @@ -278,7 +276,7 @@ EXPORT_API int maps_view_event_data_get_action_type(const maps_view_event_data_h if (!event || !action_type) return MAPS_ERROR_INVALID_PARAMETER; maps_view_event_data_s *e = (maps_view_event_data_s *) event; - if(e->event_type != MAPS_VIEW_EVENT_ACTION) + if (e->event_type != MAPS_VIEW_EVENT_ACTION) return MAPS_ERROR_INVALID_PARAMETER; *action_type = e->action_type; return MAPS_ERROR_NONE; @@ -301,7 +299,7 @@ EXPORT_API int maps_view_event_data_get_delta(const maps_view_event_data_h event if (!event || !delta_x || !delta_y) return MAPS_ERROR_INVALID_PARAMETER; maps_view_event_data_s *e = (maps_view_event_data_s *) event; - if(e->event_type != MAPS_VIEW_EVENT_ACTION) + if (e->event_type != MAPS_VIEW_EVENT_ACTION) return MAPS_ERROR_INVALID_PARAMETER; *delta_x = e->delta_x; *delta_y = e->delta_y; @@ -313,7 +311,7 @@ EXPORT_API int maps_view_event_data_get_position(const maps_view_event_data_h ev if (!event || !x || !y) return MAPS_ERROR_INVALID_PARAMETER; maps_view_event_data_s *e = (maps_view_event_data_s *) event; - if(e->event_type != MAPS_VIEW_EVENT_GESTURE && e->event_type != MAPS_VIEW_EVENT_OBJECT) + if (e->event_type != MAPS_VIEW_EVENT_GESTURE && e->event_type != MAPS_VIEW_EVENT_OBJECT) return MAPS_ERROR_INVALID_PARAMETER; *x = e->x; *y = e->y; @@ -325,7 +323,7 @@ EXPORT_API int maps_view_event_data_get_fingers(const maps_view_event_data_h eve if (!event || !fingers) return MAPS_ERROR_INVALID_PARAMETER; maps_view_event_data_s *e = (maps_view_event_data_s *) event; - if(e->event_type != MAPS_VIEW_EVENT_GESTURE) + if (e->event_type != MAPS_VIEW_EVENT_GESTURE) return MAPS_ERROR_INVALID_PARAMETER; *fingers = e->fingers; return MAPS_ERROR_NONE; @@ -336,7 +334,7 @@ EXPORT_API int maps_view_event_data_get_zoom_factor(const maps_view_event_data_h if (!event || !zoom_factor) return MAPS_ERROR_INVALID_PARAMETER; maps_view_event_data_s *e = (maps_view_event_data_s *) event; - if((e->event_type != MAPS_VIEW_EVENT_GESTURE) && (e->event_type != MAPS_VIEW_EVENT_ACTION)) + if ((e->event_type != MAPS_VIEW_EVENT_GESTURE) && (e->event_type != MAPS_VIEW_EVENT_ACTION)) return MAPS_ERROR_INVALID_PARAMETER; *zoom_factor = e->zoom_factor; return MAPS_ERROR_NONE; @@ -347,7 +345,7 @@ EXPORT_API int maps_view_event_data_get_rotation_angle(const maps_view_event_dat if (!event || !rotation_angle) return MAPS_ERROR_INVALID_PARAMETER; maps_view_event_data_s *e = (maps_view_event_data_s *) event; - if((e->event_type != MAPS_VIEW_EVENT_GESTURE) && (e->event_type != MAPS_VIEW_EVENT_ACTION)) + if ((e->event_type != MAPS_VIEW_EVENT_GESTURE) && (e->event_type != MAPS_VIEW_EVENT_ACTION)) return MAPS_ERROR_INVALID_PARAMETER; *rotation_angle = e->rotation_angle; return MAPS_ERROR_NONE; @@ -358,7 +356,7 @@ EXPORT_API int maps_view_event_data_get_object(const maps_view_event_data_h even if (!event || !object) return MAPS_ERROR_INVALID_PARAMETER; maps_view_event_data_s *e = (maps_view_event_data_s *) event; - if(e->event_type != MAPS_VIEW_EVENT_OBJECT) + if (e->event_type != MAPS_VIEW_EVENT_OBJECT) return MAPS_ERROR_INVALID_PARAMETER; *object = e->object; return MAPS_ERROR_NONE; diff --git a/src/api/maps_view_object.cpp b/src/api/maps_view_object.cpp index 7bfca3c..a95fb3e 100644 --- a/src/api/maps_view_object.cpp +++ b/src/api/maps_view_object.cpp @@ -74,21 +74,16 @@ typedef struct _maps_view_polygon_data_s { * This represents visual object information */ typedef struct _maps_view_object_s { - maps_view_object_type_e type; /* marker, polyline, polygon, group */ - - void *shape_data; /* Pointer to the visual object data, such as - maps_view_marker_data_s or - maps_view_polyline_data_s */ - + maps_view_object_type_e type; /* marker, polyline, polygon, group */ + void *shape_data; /* Pointer to the visual object data, such as + maps_view_marker_data_s or maps_view_polyline_data_s */ bool visible; - maps_view_object_h parent_group; /* The group, owning the object */ - maps_view_h view; /* Link with the parent Map View */ - } maps_view_object_s; -int _maps_view_on_object_operation(maps_view_h view, maps_view_object_h object, maps_view_object_operation_e operation); +int _maps_view_on_object_operation(maps_view_h view, maps_view_object_h object, + maps_view_object_operation_e operation); static maps_view_h __get_view(const maps_view_object_h object); static maps_view_polyline_data_s *__get_polyline_data(const maps_view_object_h object); @@ -141,7 +136,7 @@ static int __maps_view_polyline_data_create(void **polyline) *polyline = (maps_view_polyline_data_s *) p; return MAPS_ERROR_NONE; - } while(false); + } while (false); __maps_view_polyline_data_destroy(p); return error; @@ -191,7 +186,7 @@ static int __maps_view_polygon_data_create(void **polygon) *polygon = (maps_view_polygon_data_s *) p; return MAPS_ERROR_NONE; - } while(false); + } while (false); __maps_view_polygon_data_destroy(p); return error; @@ -246,7 +241,7 @@ static int __maps_view_marker_data_create(void **marker) m->z_order = 0; *marker = (maps_view_marker_data_s *) m; return MAPS_ERROR_NONE; - } while(false); + } while (false); __maps_view_marker_data_destroy(m); return error; @@ -317,7 +312,7 @@ int _maps_view_object_create(maps_view_object_type_e type, maps_view_object_h *o *object = (maps_view_object_h) o; return MAPS_ERROR_NONE; - } while(false); + } while (false); maps_view_object_destroy(o); return error; } diff --git a/src/plugin/discovery.cpp b/src/plugin/discovery.cpp index 3c6ce92..457ad73 100755 --- a/src/plugin/discovery.cpp +++ b/src/plugin/discovery.cpp @@ -104,26 +104,20 @@ vector plugin::discovery::get_module_file_list() const MAPS_LOGD("START PLUGIN FILES DISCOVERY:"); dir = g_dir_open(MAPS_PLUGINS_PATH_PREFIX, 0, &error); if (dir) { - GPatternSpec *plugin_name_pattern = g_pattern_spec_new("*?.so"); while ((filename = g_dir_read_name(dir))) { MAPS_LOGD("found plugin binary: %s", filename); - if (g_pattern_match_string(plugin_name_pattern, - filename)) { - MAPS_LOGD("\tadded plugin binary: %s", - filename); + if (g_pattern_match_string(plugin_name_pattern, filename)) { + MAPS_LOGD("\tadded plugin binary: %s", filename); l.push_back(string(filename)); } } g_pattern_spec_free(plugin_name_pattern); - g_dir_close(dir); - } - else if (error) { - MAPS_LOGE("%d: Can not open directory: %s\n", error->code, - error->message); /* g_error */ + } else if (error) { + MAPS_LOGE("%d: Can not open directory: %s\n", error->code, error->message); } return l; diff --git a/src/plugin/module.cpp b/src/plugin/module.cpp index 946a1bb..d8350ef 100755 --- a/src/plugin/module.cpp +++ b/src/plugin/module.cpp @@ -41,7 +41,6 @@ plugin::binary_extractor::binary_extractor() plugin::provider_info plugin::binary_extractor::get_plugin_info(const string &file_name) const { - if (file_name.empty()) return provider_info::empty_instance; @@ -96,7 +95,6 @@ maps_plugin_h plugin::binary_extractor::init(const provider_info &info, /* 2. Perform steps to completely initialize a plugin */ do { - if (!new_plugin) { MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY); @@ -298,7 +296,6 @@ maps_plugin_h plugin::binary_extractor::init(const provider_info &info, /* 2.5 Return newly initialized plugin */ return new_plugin; - } while (FALSE); MAPS_LOGE("Shut down the plugin becuause of error"); @@ -349,7 +346,6 @@ void plugin::binary_extractor::shutdown(maps_plugin_h plugin_h) plugin::GMod *plugin::binary_extractor::gmod_new(const string &module_file, gboolean is_resident) const { - if (!g_module_supported()) { MAPS_LOGE("ERROR! g_module_supported is false\n\n"); return NULL; @@ -432,7 +428,6 @@ gpointer plugin::binary_extractor::gmod_find_sym(GMod *gmod, void plugin::binary_extractor::trace_dbg(const plugin_s *plugin) const { - MAPS_LOGD("*********************************************"); MAPS_LOGD("PLUGIN INFO"); if (!plugin) { @@ -444,8 +439,7 @@ void plugin::binary_extractor::trace_dbg(const plugin_s *plugin) const const GMod *mod = (const GMod *) plugin->module; if (!mod) { MAPS_LOGD("PLUGIN module is NULL"); - } - else { + } else { MAPS_LOGD("module address:\t\t\t%p", mod->module); MAPS_LOGD("module name:\t\t\t%s", mod->name); MAPS_LOGD("module path:\t\t\t%s", mod->path); @@ -453,8 +447,7 @@ void plugin::binary_extractor::trace_dbg(const plugin_s *plugin) const if (!plugin->request_queue) { MAPS_LOGD("PLUGIN request queue is NULL"); - } - else { + } else { MAPS_LOGD("plugin request queue:\t\t\t%p", plugin->request_queue); } diff --git a/src/plugin/module.h b/src/plugin/module.h index 71b0e26..07dbc4e 100644 --- a/src/plugin/module.h +++ b/src/plugin/module.h @@ -133,7 +133,6 @@ namespace plugin { /* Plugin interface */ typedef struct _interface_s { - /* Plugin dedicated functions */ maps_plugin_init_f maps_plugin_init; maps_plugin_shutdown_f maps_plugin_shutdown; diff --git a/src/session/command.cpp b/src/session/command.cpp index 9d6da2a..77e66b2 100644 --- a/src/session/command.cpp +++ b/src/session/command.cpp @@ -62,13 +62,11 @@ void session::command::destroy() plugin::interface_s *session::command::interface() const { if (!m) - return plugin::get_empty_interface_ptr(); /* PROBLEM!!! Why have - no maps service!! Returning default empty interface */ + return plugin::get_empty_interface_ptr(); plugin::plugin_s *p = __extract_plugin(m); if (!p) - return plugin::get_empty_interface_ptr(); /* PROBLEM!!! Why have - no plugin!! Returning default empty interface */ + return plugin::get_empty_interface_ptr(); return &p->interface; } diff --git a/src/session/command_queue.cpp b/src/session/command_queue.cpp index e791f6d..311a243 100644 --- a/src/session/command_queue.cpp +++ b/src/session/command_queue.cpp @@ -28,8 +28,7 @@ session::command_queue *session::command_queue::interface() static command_queue_sync sync_queue; return &sync_queue; #endif /* _MAPS_SERVICE_SUPPORTS_ASYNC_QUEUE_ */ - } - else { + } else { static command_queue_sync sync_queue; return &sync_queue; } @@ -140,11 +139,11 @@ gint session::command_queue_view::iterate(gconstpointer a, /* Attempting to update existing command with freshier data. * It is decided not to store a number of commands of the same type: * one command is enough */ - if(c_new) { - if(ca->get_type() == c_new->get_type()) { + if (c_new) { + if (ca->get_type() == c_new->get_type()) { ca->merge(c_new); //c_new->set_merged(); - } else if(cb->get_type() == c_new->get_type()) { + } else if (cb->get_type() == c_new->get_type()) { cb->merge(c_new); //c_new->set_merged(); } @@ -164,7 +163,7 @@ int session::command_queue_view::push(command *c) { /*g_print("session::command_queue_view::push " "pushed a command: %p\n", c);*/ - if(c == command::empty_ptr()) + if (c == command::empty_ptr()) return MAPS_ERROR_NONE; if (!c || !c->plugin() || !c->plugin()->request_queue) @@ -173,26 +172,23 @@ int session::command_queue_view::push(command *c) queue_autoref(c->plugin()->request_queue); - #if 0 /* ---------------------------------------------- */ /* This is the routine without queue modification */ const bool _dbg_simple_queue = false; - if(_dbg_simple_queue) { - g_async_queue_push (c->plugin()->request_queue, c); + if (_dbg_simple_queue) { + g_async_queue_push(c->plugin()->request_queue, c); return MAPS_ERROR_NONE; } /* ---------------------------------------------- */ #endif - - /* Iterating the queue; sorting it and simultaneously attempting * to update the data of the existing command of the current type. * This approach allows to store only one instance of a command per * given type */ /*__dbg_queue_length = 0;*/ - g_async_queue_sort (c->plugin()->request_queue, + g_async_queue_sort(c->plugin()->request_queue, session::command_queue_view::iterate, c); /*g_print("Queue Length: %d\n", __dbg_queue_length);*/ @@ -205,10 +201,10 @@ int session::command_queue_view::push(command *c) * * https://developer.gnome.org/glib/stable/ * glib-Asynchronous-Queues.html#g-async-queue-push-sorted */ - if(c->merged()) + if (c->merged()) delete c; else - g_async_queue_push_sorted (c->plugin()->request_queue, c, + g_async_queue_push_sorted(c->plugin()->request_queue, c, session::command_queue_view::iterate, NULL); @@ -231,11 +227,11 @@ session::command* session::command_queue_view::pop(plugin::plugin_s *p) * https://developer.gnome.org/glib/stable/glib-Asynchronous-Queues.html#g-async-queue-timeout-pop */ command* c = - (command*) g_async_queue_timeout_pop(p->request_queue, + (command*)g_async_queue_timeout_pop(p->request_queue, /*300 * G_TIME_SPAN_MILLISECOND);*/ /* Small timeout is better for UI */ 10 * G_TIME_SPAN_MILLISECOND); - /*if(c) + /*if (c) g_print("session::command_queue_view::pop " "extracted a command: %p\n", c);*/ return (c) ? c : command::empty_ptr(); diff --git a/src/session/commands.cpp b/src/session/commands.cpp index acdf924..fd3ffa2 100755 --- a/src/session/commands.cpp +++ b/src/session/commands.cpp @@ -24,16 +24,16 @@ extern int _maps_view_move_center(maps_view_h view, const int delta_x, const int delta_y); extern int _maps_view_set_zoom_rotate(maps_view_h view, - const bool zoom_changed, const double zoom_factor, - const bool rotation_changed, const double rotation_angle); + const bool zoom_changed, const double zoom_factor, + const bool rotation_changed, const double rotation_angle); extern bool maps_address_is_valid(const maps_address_h address); extern bool maps_area_is_valid(const maps_area_h area); extern bool maps_coordinates_is_valid(const maps_coordinates_h coordinates); static int __put_to_hashtable(session::command_handler *ch, - maps_service_data_e feature, - maps_int_hashtable_h t) + maps_service_data_e feature, + maps_int_hashtable_h t) { if (!ch || !t) return MAPS_ERROR_INVALID_PARAMETER; @@ -79,9 +79,7 @@ int session::command_geocode::run() /* need to create the handler when the function is NULL */ pr.add(my_req_id); handler = new command_geocode_handler(plugin(), - callback, - user_data, - my_req_id); + callback, user_data, my_req_id); if (handler) { /* Run the plugin interface function */ @@ -92,12 +90,10 @@ int session::command_geocode::run() pr.update(my_req_id, handler); MAPS_LOGD("session::command_geocode::run: %d", my_req_id); - } - else { + } else { error = MAPS_ERROR_OUT_OF_MEMORY; } - } - else { + } else { /* Plugin Function is NULL: use default empty function */ /* func = plugin::get_empty_interface().maps_plugin_geocode; @@ -127,7 +123,6 @@ bool session::command_geocode_handler::foreach_geocode_cb(maps_error_e error, coordinates, void *user_data) { - command_geocode_handler *handler = (command_geocode_handler *) user_data; if (request_id != handler->plg_req_id) { @@ -176,12 +171,10 @@ session::command_geocode_inside_bounds::command_geocode_inside_bounds( if (maps_area_is_valid(b)) { bounds = b; - } - else { + } else { error = MAPS_ERROR_INVALID_PARAMETER; *request_id = -1; } - } session::command_geocode_inside_bounds::~command_geocode_inside_bounds() @@ -215,12 +208,10 @@ int session::command_geocode_inside_bounds::run() pr.update(my_req_id, handler); MAPS_LOGD("session::command_geocode_inside_bounds::run: %d", my_req_id); - } - else { + } else { error = MAPS_ERROR_OUT_OF_MEMORY; } - } - else { + } else { /* Plugin Function is NULL: use default empty function */ /* func = plugin::get_empty_interface(). @@ -257,13 +248,11 @@ session::command_geocode_by_structured_address:: if (maps_address_is_valid(a)) { address = a; - } - else { + } else { error = MAPS_ERROR_INVALID_PARAMETER; *request_id = -1; MAPS_LOGD("Invalid parameter"); } - } session::command_geocode_by_structured_address:: @@ -296,12 +285,10 @@ int session::command_geocode_by_structured_address::run() handler, &handler->plg_req_id); pr.update(my_req_id, handler); - } - else { + } else { error = MAPS_ERROR_OUT_OF_MEMORY; } - } - else { + } else { /* Plugin Function is NULL: use default empty function */ /* func = plugin::get_empty_interface(). @@ -335,7 +322,6 @@ session::command_reverse_geocode::command_reverse_geocode(maps_service_h ms, { *request_id = command::command_request_id++; my_req_id = *request_id; - } session::command_reverse_geocode::~command_reverse_geocode() @@ -368,12 +354,10 @@ int session::command_reverse_geocode::run() pr.update(my_req_id, handler); MAPS_LOGD("session::command_reverse_geocode::run: %d", my_req_id); - } - else { + } else { error = MAPS_ERROR_OUT_OF_MEMORY; } - } - else { + } else { /* Plugin Function is NULL: use default empty function */ /* func = plugin::get_empty_interface(). @@ -404,13 +388,11 @@ void session::command_reverse_geocode_handler::foreach_reverse_geocode_cb( maps_address_h address, void *user_data) { - command_reverse_geocode_handler *handler = (command_reverse_geocode_handler *) user_data; if (request_id != handler->plg_req_id) { - MAPS_LOGE( -"\n\nERROR! Incorrect request id [%d] come from the plugin; expected [%d]\n\n", + MAPS_LOGE("\n\nERROR! Incorrect request id [%d] come from the plugin; expected [%d]\n\n", request_id, handler->plg_req_id); } @@ -485,12 +467,10 @@ int session::command_multi_reverse_geocode::run() pr.update(my_req_id, handler); MAPS_LOGD("session::command_multi_reverse_geocode::run: %d", my_req_id); - } - else { + } else { error = MAPS_ERROR_OUT_OF_MEMORY; } - } - else { + } else { /* Plugin Function is NULL: use default empty function */ /* func = plugin::get_empty_interface(). @@ -563,8 +543,7 @@ session::command_search_place::command_search_place(maps_service_h ms, if (maps_coordinates_is_valid(pos)) { position = pos; - } - else { + } else { error = MAPS_ERROR_INVALID_PARAMETER; *request_id = -1; MAPS_LOGD("Invalid parameter"); @@ -600,12 +579,10 @@ int session::command_search_place::run() pr.update(my_req_id, handler); MAPS_LOGD("session::command_search_place::run: %d", my_req_id); - } - else { + } else { error = MAPS_ERROR_OUT_OF_MEMORY; } - } - else { + } else { /* Plugin Function is NULL: use default empty function */ /* func = plugin::get_empty_interface().maps_plugin_search_place; @@ -657,7 +634,6 @@ bool session::command_search_place_handler::foreach_place_cb(maps_error_e error, maps_place_h place, void *user_data) { - command_search_place_handler *handler = (command_search_place_handler *) user_data; @@ -711,8 +687,7 @@ session::command_search_by_area_place::command_search_by_area_place( if (maps_area_is_valid(b)) { boundary = b; - } - else { + } else { error = MAPS_ERROR_INVALID_PARAMETER; *request_id = -1; } @@ -740,7 +715,6 @@ int session::command_search_by_area_place::run() user_data, my_req_id); if (handler) { - /* Run the plugin interface function */ error = func(boundary, filter, preference, command_search_place_handler::foreach_place_cb, @@ -749,12 +723,10 @@ int session::command_search_by_area_place::run() pr.update(my_req_id, handler); MAPS_LOGD("session::command_search_by_area_place::run: %d", my_req_id); - } - else { + } else { error = MAPS_ERROR_OUT_OF_MEMORY; } - } - else { + } else { /* Plugin Function is NULL: use default empty function */ /* func = plugin::get_empty_interface(). @@ -834,12 +806,10 @@ int session::command_search_by_address_place::run() pr.update(my_req_id, handler); MAPS_LOGD("session::command_search_by_address_place::run: %d", my_req_id); - } - else { + } else { error = MAPS_ERROR_OUT_OF_MEMORY; } - } - else { + } else { /* Plugin Function is NULL: use default empty function */ /* func = plugin::get_empty_interface(). @@ -914,12 +884,10 @@ int session::command_search_place_list::run() pr.update(my_req_id, handler); MAPS_LOGD("session::command_search_place_list::run: %d", my_req_id); - } - else { + } else { error = MAPS_ERROR_OUT_OF_MEMORY; } - } - else { + } else { /* Plugin Function is NULL: use default empty function */ /* func = plugin::get_empty_interface().maps_plugin_search_place_list; @@ -1009,12 +977,10 @@ int session::command_get_place_details::run() MAPS_LOGD("session::command_get_place_details::run: %d", my_req_id); - } - else { + } else { error = MAPS_ERROR_OUT_OF_MEMORY; } - } - else { + } else { /* Plugin Function is NULL: use default empty function */ /* func = plugin::get_empty_interface(). @@ -1041,7 +1007,6 @@ session::command_get_place_details_handler::command_get_place_details_handler( void session::command_get_place_details_handler::foreach_place_details_cb(maps_error_e error, int request_id, maps_place_h place, void *user_data) { - command_get_place_details_handler *handler = (command_get_place_details_handler *) user_data; @@ -1087,15 +1052,13 @@ session::command_search_route::command_search_route(maps_service_h ms, if (maps_coordinates_is_valid(orig)) { origin = orig; - } - else { + } else { error = MAPS_ERROR_INVALID_PARAMETER; } if (maps_coordinates_is_valid(dest)) { destination = dest; - } - else { + } else { error = MAPS_ERROR_INVALID_PARAMETER; } @@ -1122,25 +1085,21 @@ int session::command_search_route::run() /* No need to create the handler when the function is NULL */ pr.add(my_req_id); handler = new command_search_route_handler(plugin(), - callback, - user_data, - my_req_id); + callback, user_data, my_req_id); if (handler) { /* Run the plugin interface function */ error = func(origin, destination, preference, - command_search_route_handler::foreach_route_cb, - handler, &handler->plg_req_id); + command_search_route_handler::foreach_route_cb, + handler, &handler->plg_req_id); pr.update(my_req_id, handler); MAPS_LOGD("session::command_search_route::run: %d", my_req_id); - } - else { + } else { error = MAPS_ERROR_OUT_OF_MEMORY; } - } - else { + } else { /* Plugin Function is NULL: use default empty function */ /* func = plugin::get_empty_interface().maps_plugin_search_route; @@ -1223,12 +1182,10 @@ int session::command_search_route_waypoints::run() pr.update(my_req_id, handler); MAPS_LOGD("session::command_search_place::run: %d", my_req_id); - } - else { + } else { error = MAPS_ERROR_OUT_OF_MEMORY; } - } - else { + } else { /* Plugin Function is NULL: use default empty function */ /* func = plugin::get_empty_interface(). @@ -1350,7 +1307,7 @@ int session::command_view_set_center::run() lat, lon); } - if(!v) + if (!v) return MAPS_ERROR_INVALID_PARAMETER; int error = MAPS_ERROR_NONE; @@ -1358,7 +1315,7 @@ int session::command_view_set_center::run() error = maps_view_set_center(v, c); if(error != MAPS_ERROR_NONE) break; - } while(false); + } while (false); const int ret = error; destroy(); @@ -1421,7 +1378,7 @@ int session::command_view_move_center::run() error = _maps_view_move_center(v, _delta_x, _delta_y); if(error != MAPS_ERROR_NONE) break; - } while(false); + } while (false); const int ret = error; destroy(); @@ -1453,14 +1410,14 @@ void session::command_view_move_center::merge(const command *c) int session::command_view_zoom::run() { - MAPS_LOGD ("session::command_view_zoom::run factor = %f", zoom_factor); + MAPS_LOGD("session::command_view_zoom::run factor = %f", zoom_factor); if (!v) return MAPS_ERROR_INVALID_PARAMETER; - const int ret = maps_view_set_zoom_factor (v, zoom_factor); + const int ret = maps_view_set_zoom_factor(v, zoom_factor); - destroy (); + destroy(); return ret; } @@ -1480,14 +1437,14 @@ void session::command_view_zoom::merge(const command *c) command_view_zoom *cmd = (command_view_zoom *)c; if (v == cmd->v) { zoom_factor = cmd->zoom_factor; - cmd->set_merged (); + cmd->set_merged(); } } /*----------------------------------------------------------------------------*/ int session::command_view_rotate::run() { - MAPS_LOGD ("session::command_view_rotate::run angle = %f", + MAPS_LOGD("session::command_view_rotate::run angle = %f", rotation_angle); if (!v) @@ -1495,7 +1452,7 @@ int session::command_view_rotate::run() const int ret = maps_view_set_orientation(v, rotation_angle); - destroy (); + destroy(); return ret; } @@ -1523,7 +1480,7 @@ void session::command_view_rotate::merge(const command *c) int session::command_view_zoom_rotate::run() { - MAPS_LOGD ("session::command_view_zoom_rotate::run " + MAPS_LOGD("session::command_view_zoom_rotate::run " "factor = %f, angle = %f", zoom_factor, rotation_angle); @@ -1534,7 +1491,7 @@ int session::command_view_zoom_rotate::run() true, zoom_factor, true, rotation_angle); - destroy (); + destroy(); return ret; } diff --git a/src/session/commands.h b/src/session/commands.h index 032d255..aec3512 100644 --- a/src/session/commands.h +++ b/src/session/commands.h @@ -570,7 +570,7 @@ private: command_get_place_details() : command(NULL) { } - command_get_place_details( const command_get_place_details &src) + command_get_place_details(const command_get_place_details &src) : command(NULL) { } diff --git a/src/session/thread.cpp b/src/session/thread.cpp index 5e1c547..208ae40 100755 --- a/src/session/thread.cpp +++ b/src/session/thread.cpp @@ -21,18 +21,15 @@ session::thread::thread() { - } session::thread::~thread() { - } /* Thread function: pops the item from the queue and performs the command */ void *session::thread::queue_thread(void *data) { - sleep(0); /* Just switch the thread to accomplish previous initialization routines */ @@ -49,12 +46,10 @@ void *session::thread::queue_thread(void *data) void session::thread::run(plugin::plugin_s *p) { - if (!p) return; if (p->thread) - return; /* Check whether the thread is already - started, */ + return; /* Check whether the thread is already started, */ /* Start if needed */ p->is_working = true; diff --git a/src/view/gesture_detector.cpp b/src/view/gesture_detector.cpp index 4a55f10..c589250 100644 --- a/src/view/gesture_detector.cpp +++ b/src/view/gesture_detector.cpp @@ -111,7 +111,7 @@ void view::gesture_detector::stop_tap_timer() Eina_Bool view::gesture_detector::__on_tap_timer(void *data) { gesture_detector *d = (gesture_detector *)data; - if(!d) + if (!d) return ECORE_CALLBACK_CANCEL; d->log("------- TAP TIMER EVENT -------", FG_MAGENTA); @@ -146,7 +146,7 @@ void view::gesture_detector::stop_long_press_timer() Eina_Bool view::gesture_detector::__on_long_press_timer(void *data) { gesture_detector *d = (gesture_detector *)data; - if(!d) + if (!d) return ECORE_CALLBACK_CANCEL; d->log("------- LONG PRESS TIMER EVENT -------", FG_MAGENTA); @@ -182,7 +182,7 @@ bool view::gesture_detector::finger_pressed_enough(int finger_no, if(up_time < press_time) return false; /* Not yet unpressed */ unsigned int press_duration = up_time - press_time; - if((press_duration >= duration_min) && (press_duration <= duration_max)) + if ((press_duration >= duration_min) && (press_duration <= duration_max)) return true; return false; } diff --git a/src/view/gesture_detector.h b/src/view/gesture_detector.h index 43c3976..64ca050 100644 --- a/src/view/gesture_detector.h +++ b/src/view/gesture_detector.h @@ -113,7 +113,6 @@ namespace view FG_LITE_MAGENTA = 95, FG_LITE_CYAN = 96, FG_LITE_WHITE = 97 - }; static void log(const char *str, log_colors color = FG_WHITE); void log_map_center(int color = FG_LITE_BLUE); diff --git a/src/view/gesture_detector_statemachine.cpp b/src/view/gesture_detector_statemachine.cpp index 804db20..64a8c8f 100644 --- a/src/view/gesture_detector_statemachine.cpp +++ b/src/view/gesture_detector_statemachine.cpp @@ -36,9 +36,7 @@ view::gesture_detector_statemachine::~gesture_detector_statemachine() void view::gesture_detector_statemachine::tap(int finger_no, const touch_point &tp) { - switch(finger_no) { - case 0: /* Single finger pressed */ _info._finger_down[0] = tp; _info._finger_move[0] = tp; @@ -87,7 +85,6 @@ void view::gesture_detector_statemachine::up(int finger_no, const touch_point &tp) { switch(finger_no) { - case 0: /* Up the single finger */ _info._finger_up[0] = tp; @@ -149,7 +146,6 @@ void view::gesture_detector_statemachine::move(int finger_no, stop_long_press_timer(); switch(finger_no) { - case 0: /* Moving the first (single) finger */ _info._prev_finger_down[0] = _info._finger_move[0]; _info._finger_move[0] = tp; @@ -219,9 +215,7 @@ void view::gesture_detector_statemachine::state_machine_on_event(view_event_e ev detector_states_e old_state = _current_state; switch(_current_state) { - case STATE_NONE: { - _info._start_view_state.capture(_view); log_map_center(FG_WHITE); @@ -248,8 +242,9 @@ void view::gesture_detector_statemachine::state_machine_on_event(view_event_e ev if(finger_pressed_enough(0, 0, __CLICK_DURATION)) { _current_state = STATE_CLICKED; start_tap_timer(); - } else + } else { _current_state = STATE_NONE; + } break; } case LONG_PRESS_TIMER: @@ -320,7 +315,6 @@ void view::gesture_detector_statemachine::state_machine_on_event(view_event_e ev case STATE_SECOND_PRESSED: { switch(event) { case FINGER_UP: { - /* First click position */ const touch_point p1 = _info_history._finger_down[0]; @@ -336,9 +330,7 @@ void view::gesture_detector_statemachine::state_machine_on_event(view_event_e ev * convenience */ - if(get_trajectory_effective_length(p1, p2) - <= (4 * __CLICK_AREA)) { - + if(get_trajectory_effective_length(p1, p2) <= (4 * __CLICK_AREA)) { /* Switching to Double Tap state */ _current_state = STATE_SECOND_CLICKED; @@ -348,15 +340,14 @@ void view::gesture_detector_statemachine::state_machine_on_event(view_event_e ev * No need to expect other events here. * Immediatelly switching to the initial State */ - _current_state = STATE_NONE; + _current_state = STATE_NONE; } else { /* Seems like it is a simple click */ _current_state = STATE_CLICKED; stop_long_press_timer(); start_tap_timer(); } - break; } case TAP_TIMER: @@ -410,7 +401,6 @@ void view::gesture_detector_statemachine::state_machine_on_event(view_event_e ev } case STATE_MOVING: { - if(event != FINGER_MOVE) finish_panning(0); @@ -443,7 +433,6 @@ void view::gesture_detector_statemachine::state_machine_on_event(view_event_e ev } case STATE_FINGER2_MOVING: { - if(event != FINGER2_MOVE) finish_panning(1); @@ -529,7 +518,6 @@ void view::gesture_detector_statemachine::state_machine_on_event(view_event_e ev case STATE_FINGER1_PRESSED: { switch(event) { case FINGER_UP: - if(finger_pressed_enough(0, 0, __CLICK_DURATION) && finger_pressed_enough(1, 0, __CLICK_DURATION)){ _current_state = STATE_2FINGERS_CLICKED; @@ -820,7 +808,6 @@ void view::gesture_detector_statemachine::log_event(view_event_e event) void view::gesture_detector_statemachine::log_state(view_event_e event, detector_states_e state) { - string e = get_event_str(event); string s = get_state_str(state); diff --git a/src/view/gesture_processor.cpp b/src/view/gesture_processor.cpp index 91e0acb..bf92a6e 100644 --- a/src/view/gesture_processor.cpp +++ b/src/view/gesture_processor.cpp @@ -74,7 +74,7 @@ view::zoom_calculator::zoom_calculator(const touch_point &start_tp_f1, const double cur_r = sqrt(cur_dx * cur_dx + cur_dy * cur_dy) / 2; /* Calculating the zoom factor */ - if((start_r != .0) && (cur_r != .0) && (start_r != cur_r)) { + if ((start_r != .0) && (cur_r != .0) && (start_r != cur_r)) { if (cur_r > start_r) _new_zoom_factor = (cur_r / start_r) - 1; else @@ -93,8 +93,7 @@ view::zoom_calculator::zoom_calculator(const touch_point &start_tp_f1, if (curl < 0) { _new_rotation_angle = (angle / M_PI * 180.); _rotation_happend = true; - } - else if (curl > 0) { + } else if (curl > 0) { _new_rotation_angle = 360 - (angle / M_PI * 180.); _rotation_happend = true; } @@ -161,7 +160,7 @@ session::command *view::gesture_processor::construct_gesture_command( case MAPS_VIEW_ACTION_SCROLL: { maps_coordinates_h coords = c; maps_coordinates_h center_clone = NULL; - if(!coords) { + if (!coords) { maps_view_get_center(_gd->_view, ¢er_clone); coords = center_clone; } @@ -195,7 +194,7 @@ session::command *view::gesture_processor::construct_gesture_command( maps_coordinates_h coords = c; maps_coordinates_h center_clone = NULL; - if(!coords) { + if (!coords) { maps_view_get_center(_gd->_view, ¢er_clone); coords = center_clone; } @@ -206,21 +205,21 @@ session::command *view::gesture_processor::construct_gesture_command( } case MAPS_VIEW_ACTION_ZOOM: case MAPS_VIEW_ACTION_ROTATE: { - if(zoom_changed & rotation_changed) { + if (zoom_changed & rotation_changed) { MAPS_LOGD("rotation_angle=%f", rotation_angle); - if(zoom_factor == .0) + if (zoom_factor == .0) maps_view_get_zoom_factor(_gd->_view, &zoom_factor); - if(rotation_angle == .0) + if (rotation_angle == .0) maps_view_get_orientation(_gd->_view, &rotation_angle); rotation_angle -= (int(rotation_angle) / 360) * 360; return new session::command_view_zoom_rotate(get_maps(), _gd->_view, zoom_factor, rotation_angle); - } else if(zoom_changed) { - if(zoom_factor == .0) + } else if (zoom_changed) { + if (zoom_factor == .0) maps_view_get_zoom_factor(_gd->_view, &zoom_factor); MAPS_LOGI("\t set new zoom command: %f\n", zoom_factor); return new session::command_view_zoom(get_maps(), _gd->_view, zoom_factor); - } else if(rotation_changed) { - if(rotation_angle == .0) + } else if (rotation_changed) { + if (rotation_angle == .0) maps_view_get_orientation(_gd->_view, &rotation_angle); rotation_angle -= (int(rotation_angle) / 360) * 360; return new session::command_view_rotate(get_maps(), _gd->_view, rotation_angle); @@ -253,7 +252,7 @@ void view::gesture_processor::on_long_press() /* Invoke user registered event callback */ maps_view_event_data_h ed = _maps_view_create_event_data(MAPS_VIEW_EVENT_GESTURE); - if(ed) { + if (ed) { _maps_view_event_data_set_gesture_type(ed, MAPS_VIEW_GESTURE_LONG_PRESS); _maps_view_event_data_set_position(ed, tp._x, tp._y); _maps_view_event_data_set_fingers(ed, 1); @@ -283,7 +282,7 @@ void view::gesture_processor::on_double_tap() /* Invoke user registered event callback */ maps_view_event_data_h ed = _maps_view_create_event_data(MAPS_VIEW_EVENT_GESTURE); - if(ed) { + if (ed) { _maps_view_event_data_set_gesture_type(ed, MAPS_VIEW_GESTURE_DOUBLE_TAP); _maps_view_event_data_set_position(ed, tp._x, tp._y); _maps_view_event_data_set_fingers(ed, 1); @@ -313,7 +312,7 @@ void view::gesture_processor::on_tap() /* Invoke user registered event callback */ maps_view_event_data_h ed = _maps_view_create_event_data(MAPS_VIEW_EVENT_GESTURE); - if(ed) { + if (ed) { _maps_view_event_data_set_gesture_type(ed, MAPS_VIEW_GESTURE_TAP); _maps_view_event_data_set_position(ed, tp._x, tp._y); _maps_view_event_data_set_fingers(ed, 1); @@ -342,7 +341,7 @@ void view::gesture_processor::on_two_finger_tap() /* Invoke user registered event callback */ maps_view_event_data_h ed = _maps_view_create_event_data(MAPS_VIEW_EVENT_GESTURE); - if(ed) { + if (ed) { _maps_view_event_data_set_gesture_type(ed, MAPS_VIEW_GESTURE_2_FINGER_TAP); _maps_view_event_data_set_position(ed, gesture_center._x, gesture_center._y); _maps_view_event_data_set_fingers(ed, 2); @@ -379,7 +378,7 @@ void view::gesture_processor::on_pan(int finger_no) return; touch_point prev_tp = _gd->_info._prev_finger_down[finger_no]; - if(prev_tp.empty()) + if (prev_tp.empty()) prev_tp = _gd->_info._finger_down[finger_no]; /* a. Calculating the delta of the gesture */ @@ -394,7 +393,7 @@ void view::gesture_processor::on_pan(int finger_no) /* Invoke user registered event callback */ maps_view_event_data_h ed = _maps_view_create_event_data(MAPS_VIEW_EVENT_GESTURE); - if(ed) { + if (ed) { _maps_view_event_data_set_gesture_type(ed, MAPS_VIEW_GESTURE_SCROLL); _maps_view_event_data_set_position(ed, cur_tp._x, cur_tp._y); _maps_view_event_data_set_fingers(ed, 1); @@ -466,7 +465,7 @@ bool view::gesture_processor::on_zoom(bool zoom_changed, double &zoom_factor) double new_zoom_factor = zc.get_zoom_factor(); /* Analyse zoom factor changes */ - if(zc.zoom_happend()) { + if (zc.zoom_happend()) { /* Apply newly calculated zoom factor */ new_zoom_factor += _gd->_info._start_view_state._zoom_factor; @@ -476,25 +475,25 @@ bool view::gesture_processor::on_zoom(bool zoom_changed, double &zoom_factor) int max_zoom_level = 0; maps_view_get_min_zoom_level(_gd->_view, &min_zoom_level); maps_view_get_max_zoom_level(_gd->_view, &max_zoom_level); - if(new_zoom_factor < min_zoom_level) + if (new_zoom_factor < min_zoom_level) new_zoom_factor = min_zoom_level; - if(new_zoom_factor > max_zoom_level) + if (new_zoom_factor > max_zoom_level) new_zoom_factor = max_zoom_level; /* Check if the zoom changed relatively to initial state */ double diff = _gd->_info._start_view_state._prev_zoom_factor - new_zoom_factor; if ((!zoom_changed && (diff > 0.10 || diff < -0.10)) || - ( zoom_changed && (diff > 0.02 || diff < -0.02))) { + (zoom_changed && (diff > 0.02 || diff < -0.02))) { _gd->_info._start_view_state._prev_zoom_factor = new_zoom_factor; zoom_changed = true; MAPS_LOGD("[zoom_changed] %f, %f -> %f", diff, _gd->_info._start_view_state._prev_zoom_factor, new_zoom_factor); - } - else + } else { zoom_changed = false; + } } - if(!zoom_changed) + if (!zoom_changed) return false; zoom_factor = new_zoom_factor; @@ -539,7 +538,7 @@ bool view::gesture_processor::on_rotate(bool rotation_changed, double &rotation_ double new_rotation_angle = zc.get_rotation_angle(); /* Analyze rotation angle changes */ - if(zc.rotation_happend()) { + if (zc.rotation_happend()) { /* Apply newly calculated rotation angle */ new_rotation_angle += _gd->_info._start_view_state._rotation_angle; @@ -551,17 +550,17 @@ bool view::gesture_processor::on_rotate(bool rotation_changed, double &rotation_ /* Check if the zoom changed relatively to initial state */ double diff = calc_angle(_gd->_info._start_view_state._prev_rotation_angle, new_rotation_angle); if ((!rotation_changed && (diff > 4.0 || diff < -4.0)) || - ( rotation_changed && (diff > 0.5 || diff < -0.5))) { + (rotation_changed && (diff > 0.5 || diff < -0.5))) { _gd->_info._start_view_state._prev_rotation_angle = new_rotation_angle; rotation_changed = true; MAPS_LOGD("[rotation_changed] %f, %f -> %f", diff, _gd->_info._start_view_state._prev_rotation_angle, new_rotation_angle); - } - else + } else { rotation_changed = false; + } } - if(!rotation_changed) + if (!rotation_changed) return false; // Seems nothing changed, we can return rotation_angle = new_rotation_angle; @@ -620,7 +619,7 @@ void view::gesture_processor::on_zoom_rotate(bool zoom_changed, double zoom_fact _maps_view_event_data_set_rotation_angle(ed, rotation_angle); _maps_view_invoke_event_callback(_gd->_view, ed); } - maps_view_event_data_destroy(ed); + maps_view_event_data_destroy(ed); } } #else @@ -727,9 +726,9 @@ view::finger_event_stream::finger_event_stream(maps_view_h v) void view::finger_event_stream::set_gesture_detector(gesture_detector *d) { - if(!d) + if (!d) return; - if(d != _d) { + if (d != _d) { _d->halt_gesture(); delete _d; _d = d; @@ -738,7 +737,7 @@ void view::finger_event_stream::set_gesture_detector(gesture_detector *d) view::finger_event_stream::~finger_event_stream() { - if(_d) { + if (_d) { _d->halt_gesture(); delete _d; } @@ -748,7 +747,7 @@ view::finger_event_stream::~finger_event_stream() void view::finger_event_stream::tap(Evas_Event_Mouse_Down *ev) { MAPS_LOGI("finger_event_stream::tap"); - if(!ev) + if (!ev) return; /* @@ -756,7 +755,7 @@ void view::finger_event_stream::tap(Evas_Event_Mouse_Down *ev) * so we have to skip this "late" event "press" for the sake of * detector simplicity */ - if(_finger_pressed[0]) { + if (_finger_pressed[0]) { MAPS_LOGI("finger_event_stream::tap [SKIPED]"); return; } @@ -773,7 +772,7 @@ void view::finger_event_stream::tap(Evas_Event_Mouse_Down *ev) void view::finger_event_stream::move(Evas_Event_Mouse_Move *ev) { - if(!ev) + if (!ev) return; /* Current touch point info */ @@ -786,7 +785,7 @@ void view::finger_event_stream::move(Evas_Event_Mouse_Move *ev) * so we have to emulate the "press" for the sake of * detector simplicity */ - if(!_finger_pressed[0]) { + if (!_finger_pressed[0]) { MAPS_LOGI("finger_event_stream::tap [CORRECTION]"); _finger_pressed[0] = true; _finger_down[0] = tp; @@ -797,7 +796,7 @@ void view::finger_event_stream::move(Evas_Event_Mouse_Move *ev) /* It's needed to correct the touch point, when the finger moved out of * assigned movement threshold */ - if(!_finger_moving[0] && !_finger_moving[1] + if (!_finger_moving[0] && !_finger_moving[1] && finger_dragged_enough(0, tp)) { _d->_info._finger_down[0] = tp; } @@ -806,9 +805,8 @@ void view::finger_event_stream::move(Evas_Event_Mouse_Move *ev) * We think that the movement happend when the finger moved out of * some small area. */ - if(_finger_moving[0] || _finger_moving[1] + if (_finger_moving[0] || _finger_moving[1] || finger_dragged_enough(0, tp)) { - _finger_moving[0] = true; /* Process finger move */ @@ -823,7 +821,7 @@ void view::finger_event_stream::move(Evas_Event_Mouse_Move *ev) void view::finger_event_stream::up(Evas_Event_Mouse_Up *ev) { MAPS_LOGI("finger_event_stream::up"); - if(!ev) + if (!ev) return; /* Process finger up */ @@ -837,11 +835,11 @@ void view::finger_event_stream::up(Evas_Event_Mouse_Up *ev) void view::finger_event_stream::multi_tap(Evas_Event_Multi_Down *ev) { MAPS_LOGI("finger_event_stream::multi_tap"); - if(!ev) + if (!ev) return; const int finger_no = ev->device; - if(finger_no >= MAX_FINGERS) + if (finger_no >= MAX_FINGERS) return; /* Current touch point info */ @@ -852,7 +850,7 @@ void view::finger_event_stream::multi_tap(Evas_Event_Multi_Down *ev) * so we have to skip this "late" event "press" for the sake of * detector simplicity */ - if(_finger_pressed[finger_no]) { + if (_finger_pressed[finger_no]) { MAPS_LOGI("finger_event_stream::multi_tap [SKIPED]"); return; } @@ -866,11 +864,11 @@ void view::finger_event_stream::multi_tap(Evas_Event_Multi_Down *ev) void view::finger_event_stream::multi_move(Evas_Event_Multi_Move *ev) { - if(!ev) + if (!ev) return; const int finger_no = ev->device; - if(finger_no >= MAX_FINGERS) + if (finger_no >= MAX_FINGERS) return; /* Current touch point info */ @@ -883,7 +881,7 @@ void view::finger_event_stream::multi_move(Evas_Event_Multi_Move *ev) * so we have to emulate the "press" for the sake of * detector simplicity */ - if(!_finger_pressed[finger_no]) { + if (!_finger_pressed[finger_no]) { MAPS_LOGI("finger_event_stream::multi_tap [CORRECTION]"); _finger_pressed[finger_no] = true; _finger_down[finger_no] = tp; @@ -894,7 +892,7 @@ void view::finger_event_stream::multi_move(Evas_Event_Multi_Move *ev) /* It's needed to correct the touch point, when the finger moved out of * assigned movement threshold */ - if(!_finger_moving[0] && !_finger_moving[1] + if (!_finger_moving[0] && !_finger_moving[1] && finger_dragged_enough(finger_no, tp)) { _d->_info._finger_down[finger_no] = tp; } @@ -903,7 +901,7 @@ void view::finger_event_stream::multi_move(Evas_Event_Multi_Move *ev) * We think that the movement happend when the finger moved out of * some small area. */ - if(_finger_moving[0] || _finger_moving[1] + if (_finger_moving[0] || _finger_moving[1] || finger_dragged_enough(finger_no, tp)) { _finger_moving[finger_no] = true; @@ -919,11 +917,11 @@ void view::finger_event_stream::multi_move(Evas_Event_Multi_Move *ev) void view::finger_event_stream::multi_up(Evas_Event_Multi_Up *ev) { MAPS_LOGI("finger_event_stream::multi_up"); - if(!ev) + if (!ev) return; const int finger_no = ev->device; - if(finger_no >= MAX_FINGERS) + if (finger_no >= MAX_FINGERS) return; /* Process finger up */ diff --git a/src/view/inertial_camera.cpp b/src/view/inertial_camera.cpp index 4babe4c..14b27c7 100644 --- a/src/view/inertial_camera.cpp +++ b/src/view/inertial_camera.cpp @@ -59,10 +59,10 @@ view::inertial_camera::~inertial_camera() void view::inertial_camera::set_cur_state() { - if(!_view) + if (!_view) return; - if(!cur_center) + if (!cur_center) maps_coordinates_destroy(cur_center); maps_view_get_center(_view, &cur_center); maps_view_get_zoom_factor(_view, &cur_zoom_factor); @@ -73,11 +73,11 @@ void view::inertial_camera::set_targets(const maps_coordinates_h center, const double &zoom_factor, const double &rotation_angle) { - if(!_view) + if (!_view) return; /* Store the targets */ - if(!target_center) + if (!target_center) maps_coordinates_destroy(target_center); maps_coordinates_clone(center, &target_center); @@ -85,7 +85,7 @@ void view::inertial_camera::set_targets(const maps_coordinates_h center, target_rotation_angle = rotation_angle; /* Store current state */ - if(!transiting) + if (!transiting) set_cur_state(); /* Start transition */ @@ -94,16 +94,16 @@ void view::inertial_camera::set_targets(const maps_coordinates_h center, void view::inertial_camera::set_center_target(const maps_coordinates_h center) { - if(!_view) + if (!_view) return; /* Store the target */ - if(!target_center) + if (!target_center) maps_coordinates_destroy(target_center); maps_coordinates_clone(center, &target_center); /* Store current state */ - if(!transiting) + if (!transiting) set_cur_state(); /* Start transition */ @@ -112,14 +112,14 @@ void view::inertial_camera::set_center_target(const maps_coordinates_h center) void view::inertial_camera::set_zoom_target(const double &zoom_factor) { - if(!_view) + if (!_view) return; /* Store the target */ target_zoom_factor = zoom_factor; /* Store current state */ - if(!transiting) + if (!transiting) set_cur_state(); /* Start transition */ @@ -128,14 +128,14 @@ void view::inertial_camera::set_zoom_target(const double &zoom_factor) void view::inertial_camera::set_rotation_target(const double &rotation_angle) { - if(!_view) + if (!_view) return; /* Store the target */ target_rotation_angle = rotation_angle; /* Store current state */ - if(!transiting) + if (!transiting) set_cur_state(); /* Start transition */ @@ -146,13 +146,13 @@ double view::inertial_camera::calc_next_step(const double &start, const double &finish, const double step_ratio) const { - if(start == finish) + if (start == finish) return start; /* Expanential transition */ double step = (finish - start) * step_ratio; double new_pos = start + step; - if(finish > start) { + if (finish > start) { new_pos = MAX(new_pos, start); new_pos = MIN(new_pos, finish); } else { @@ -166,7 +166,7 @@ double view::inertial_camera::calc_next_step_lon(const double &start, const double &finish, const double step_ratio) const { - if(start == finish) + if (start == finish) return start; double _f = finish; @@ -203,7 +203,7 @@ double view::inertial_camera::calc_next_step_lon(const double &start, bool view::inertial_camera::next_transition_step() { - if(!_view) + if (!_view) return false; transiting = false; @@ -239,19 +239,19 @@ bool view::inertial_camera::next_transition_step() /* Transiting zoom */ cur_zoom_factor = calc_next_step(cur_zoom_factor, target_zoom_factor, .2); - if(ABS(cur_zoom_factor - target_zoom_factor) > __ZOOM_ACCURACY) + if (ABS(cur_zoom_factor - target_zoom_factor) > __ZOOM_ACCURACY) transiting = true; else cur_zoom_factor = target_zoom_factor; /* Transizint orientation */ - if(target_rotation_angle - cur_rotation_angle > 180.) + if (target_rotation_angle - cur_rotation_angle > 180.) target_rotation_angle -= 360.; - else if(target_rotation_angle - cur_rotation_angle < -180.) + else if (target_rotation_angle - cur_rotation_angle < -180.) target_rotation_angle += 360.; cur_rotation_angle = calc_next_step(cur_rotation_angle, target_rotation_angle, .5); - if(ABS(cur_rotation_angle - target_rotation_angle) > __ROTATE_ACCURACY) + if (ABS(cur_rotation_angle - target_rotation_angle) > __ROTATE_ACCURACY) transiting = true; else cur_rotation_angle = target_rotation_angle; diff --git a/src/view/inertial_gesture.cpp b/src/view/inertial_gesture.cpp index e7e24db..7f878d9 100644 --- a/src/view/inertial_gesture.cpp +++ b/src/view/inertial_gesture.cpp @@ -44,7 +44,7 @@ view::inertial_gesture::~inertial_gesture() { //_maps_view_set_idle_listener(_view, NULL, NULL); - if(_d) + if (_d) delete _d; _d = NULL; } @@ -69,9 +69,9 @@ void view::inertial_gesture::tap(int finger_no, const touch_point &tp) _maps_view_halt_inertial_camera(_view); - if(transiting) { /* Halt the transition */ - for(int i = 0; i < MAX_FINGERS; i ++) { - if(!transiting_part[i]) + if (transiting) { /* Halt the transition */ + for (int i = 0; i < MAX_FINGERS; i ++) { + if (!transiting_part[i]) continue; unsigned int timestamp = _last[i]._timestamp + get_transition_time(i); @@ -91,7 +91,7 @@ void view::inertial_gesture::tap(int finger_no, const touch_point &tp) _cur_x[finger_no] = tp._x; _cur_y[finger_no] = tp._y; - if(_d) + if (_d) _d->tap(finger_no, tp); } @@ -106,7 +106,7 @@ void view::inertial_gesture::move(int finger_no, const touch_point &tp) _cur_x[finger_no] = tp._x; _cur_y[finger_no] = tp._y; - if(_d) + if (_d) _d->move(finger_no, tp); } @@ -125,7 +125,7 @@ void view::inertial_gesture::up(int finger_no, const touch_point &tp) MAPS_LOGD("trajectory=%d", trajectory); if (trajectory <= 5) dt = 0; - if(dt == 0) { + if (dt == 0) { _derivative_x[finger_no] = .0; _derivative_y[finger_no] = .0; } else { @@ -146,19 +146,19 @@ bool view::inertial_gesture::next_transition_step() transiting = false; //static const double dt = 1.; - for(int i = 0; i < MAX_FINGERS; i ++) { - if(!transiting_part[i]) + for (int i = 0; i < MAX_FINGERS; i ++) { + if (!transiting_part[i]) continue; transiting_part[i] = false; - if(ABS(_derivative_x[i]) > __ACCURACY) { + if (ABS(_derivative_x[i]) > __ACCURACY) { _cur_x[i] = get_next_point(_cur_x[i], _derivative_x[i], _dt[i]); _derivative_x[i] = get_next_derivative(_derivative_x[i], _dt[i]); transiting_part[i] |= ABS(_derivative_x[i]) > __ACCURACY; } - if(ABS(_derivative_y[i]) > __ACCURACY) { + if (ABS(_derivative_y[i]) > __ACCURACY) { _cur_y[i] = get_next_point(_cur_y[i], _derivative_y[i], _dt[i]); _derivative_y[i] = get_next_derivative(_derivative_y[i], _dt[i]); transiting_part[i] |= ABS(_derivative_y[i]) > __ACCURACY; @@ -167,7 +167,7 @@ bool view::inertial_gesture::next_transition_step() unsigned int timestamp = _last[i]._timestamp + get_transition_time(i); const touch_point tp(_cur_x[i], _cur_y[i], timestamp); - if(transiting_part[i]) { + if (transiting_part[i]) { MAPS_LOGI("TRANSITION finger %d move FAKE time: %d", i, tp._timestamp); _d->move(i, tp); } else { @@ -179,7 +179,7 @@ bool view::inertial_gesture::next_transition_step() step in transient is needed */ } - if(!transiting) + if (!transiting) reset(); return transiting; @@ -197,13 +197,13 @@ double view::inertial_gesture::get_next_derivative(const double &derivative, const double &dt) { /* Simple square parabola */ - /*if(derivative > 0) + /*if (derivative > 0) return (derivative + __ACCEL * dt); else return (derivative - __ACCEL * dt);*/ /* Exponential spped down */ - if(_d->_info._fingers_pressed <= 1) + if (_d->_info._fingers_pressed <= 1) return (derivative * .9); else return (derivative * .5); @@ -228,7 +228,7 @@ unsigned int view::inertial_gesture::get_transition_time(int finger_no) const void view::inertial_gesture::on_idle(void *data) { inertial_gesture *ig = (inertial_gesture *)data; - if(ig && ig->transiting) { + if (ig && ig->transiting) { MAPS_LOGI("TRANSITION on idle"); ig->next_transition_step(); g_usleep(5*1000); @@ -239,7 +239,7 @@ void view::inertial_gesture::on_idle(void *data) void view::inertial_gesture::reset() { transiting = false; - for(int i = 0; i < MAX_FINGERS; i ++) { + for (int i = 0; i < MAX_FINGERS; i ++) { transiting_part[i] = false; transiting_start[i] = 0; } diff --git a/src/view/marker_constructor.cpp b/src/view/marker_constructor.cpp index f8383ee..68c2fac 100644 --- a/src/view/marker_constructor.cpp +++ b/src/view/marker_constructor.cpp @@ -60,8 +60,7 @@ maps_view_object_h view::marker_constructor::construct(maps_coordinates_h coordi /* SUCCESS */ return marker; - - } while(false); + } while (false); /* FAILURE: Releasing objects */ maps_view_object_destroy(marker); diff --git a/src/view/poly_shape_hit_test.cpp b/src/view/poly_shape_hit_test.cpp index 2ac00c4..1b3047a 100644 --- a/src/view/poly_shape_hit_test.cpp +++ b/src/view/poly_shape_hit_test.cpp @@ -29,24 +29,24 @@ void view::poly_shape_hit_test::add_point(const float x, const float y) bool view::poly_shape_hit_test::hit_test(const float x, const float y, const bool polygon, const int w) const { - if(__x.empty()) + if (__x.empty()) return false; /* 1. Check if the point in the bounding box of a poly-figure */ - if(!hit_test_bounding_box(x, y)) + if (!hit_test_bounding_box(x, y)) return false; /* 2. Check if the point near the polyline */ - if(hit_test_polyline(x, y, polygon, w)) + if (hit_test_polyline(x, y, polygon, w)) return true; /* 3. Check if the point near the vertices */ - if(hit_test_vertices(x, y)) + if (hit_test_vertices(x, y)) return true; /* 4. Check if the point inside the polygon (for polygon only) */ - if(polygon) - if(pnpoly(x, y)) + if (polygon) + if (pnpoly(x, y)) return true; return false; @@ -58,14 +58,14 @@ bool view::poly_shape_hit_test::hit_test_bounding_box(const float x, const float float x_max = 1. * FLT_MIN; float y_min = 1. * FLT_MAX; float y_max = 1. * FLT_MIN; - for(unsigned int i = 0; i < __x.size(); i ++) { - if(__x[i] < x_min) + for (unsigned int i = 0; i < __x.size(); i ++) { + if (__x[i] < x_min) x_min = __x[i]; - if(__x[i] > x_max) + if (__x[i] > x_max) x_max = __x[i]; - if(__y[i] < y_min) + if (__y[i] < y_min) y_min = __y[i]; - if(__y[i] > y_max) + if (__y[i] > y_max) y_max = __y[i]; } x_min -= accuracy; @@ -83,7 +83,7 @@ bool view::poly_shape_hit_test::hit_test_segment(const float x1, const float y1, float a = x2 - x1; float b = y2 - y1; float c = sqrt(a * a + b * b); - if(c == 0) + if (c == 0) return false; float sina = b / c; float cosa = a / c; @@ -93,7 +93,7 @@ bool view::poly_shape_hit_test::hit_test_segment(const float x1, const float y1, float x_rotated = x_shifted * cosa + y_shifted * sina; float y_rotated = x_shifted * sina - y_shifted * cosa; - if((x_rotated >= 0) && (x_rotated <= c) + if ((x_rotated >= 0) && (x_rotated <= c) && (y_rotated >= (-1. * (accuracy + w / 2))) && (y_rotated <= (accuracy + w / 2))) return true; @@ -103,19 +103,18 @@ bool view::poly_shape_hit_test::hit_test_segment(const float x1, const float y1, bool view::poly_shape_hit_test::hit_test_polyline(const float x, const float y, const bool polygon, const int w) const { - if(__x.size() < 1) + if (__x.size() < 1) return false; - for(unsigned int i = 1; i < __x.size(); i ++) { - - if(hit_test_segment(__x[i - 1], __y[i - 1], + for (unsigned int i = 1; i < __x.size(); i ++) { + if (hit_test_segment(__x[i - 1], __y[i - 1], __x[i], __y[i], x, y, w)) return true; } - if(polygon) { + if (polygon) { /* Final section */ - if(hit_test_segment(__x[__x.size() - 1], __y[__x.size() - 1], + if (hit_test_segment(__x[__x.size() - 1], __y[__x.size() - 1], __x[0], __y[0], x, y)) return true; } @@ -125,12 +124,12 @@ bool view::poly_shape_hit_test::hit_test_polyline(const float x, const float y, bool view::poly_shape_hit_test::hit_test_vertices(const float x, const float y) const { - for(unsigned int i = 0; i < __x.size(); i ++) { + for (unsigned int i = 0; i < __x.size(); i ++) { float cur_x_min = __x[i] - accuracy; float cur_x_max = __x[i] + accuracy; float cur_y_min = __y[i] - accuracy; float cur_y_max = __y[i] + accuracy; - if((x >= cur_x_min) && (x <= cur_x_max) + if ((x >= cur_x_min) && (x <= cur_x_max) && (y >= cur_y_min) && (y <= cur_y_max)) return true; } diff --git a/src/view/polygon_constructor.cpp b/src/view/polygon_constructor.cpp index c4cfd53..056c8b9 100644 --- a/src/view/polygon_constructor.cpp +++ b/src/view/polygon_constructor.cpp @@ -60,8 +60,7 @@ maps_view_object_h view::polygon_constructor::construct(const maps_coordinates_l /* SUCCESS */ return polygon; - - } while(false); + } while (false); /* FAILURE: Releasing objects */ maps_view_object_destroy(polygon); diff --git a/src/view/polyline_constructor.cpp b/src/view/polyline_constructor.cpp index 9364f1c..5ac58ae 100644 --- a/src/view/polyline_constructor.cpp +++ b/src/view/polyline_constructor.cpp @@ -67,8 +67,7 @@ maps_view_object_h view::polyline_constructor::construct(const maps_coordinates_ /* SUCCESS */ return polyline; - - } while(false); + } while (false); /* FAILURE: Releasing objects */ maps_view_object_destroy(polyline); diff --git a/src/view/runtime_data.cpp b/src/view/runtime_data.cpp index b23e918..d48fdf0 100644 --- a/src/view/runtime_data.cpp +++ b/src/view/runtime_data.cpp @@ -242,6 +242,6 @@ int view::runtime_touch_info::calc_finger_pressed() int cnt = 0; for(unsigned int i = 0; i < MAX_FINGERS; i ++) if(_is_finger_pressed[i]) - cnt ++; + cnt++; return cnt; }