[my-place] Accept locations without accuracy. 00/87500/2
authorMarcin Masternak <m.masternak@samsung.com>
Thu, 8 Sep 2016 08:56:12 +0000 (10:56 +0200)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Tue, 20 Sep 2016 06:01:31 +0000 (23:01 -0700)
Change-Id: I7fcd554ed8613a4b0110a0e21b12ef9f29ab83e9
Signed-off-by: Marcin Masternak <m.masternak@samsung.com>
include/context_places_internal.h
src/context_places.cpp

index cd34c77..0e40c72 100644 (file)
@@ -201,7 +201,7 @@ int context_places_place_get_name(context_places_place_h place, char** name);
  * @param[in]  place           Place handle
  * @param[out] latitude        Place location latitude
  * @param[out] longitude       Place location longitude
- * @param[out] accuracy        Place location accuracy
+ * @param[out] accuracy        Place location accuracy. Value -1.0 if not specified.
  *
  * @return             0 on success, otherwise a negative error value
  * @retval             #CONTEXT_PLACES_ERROR_NONE                              Successful
index a37d991..afef1d6 100644 (file)
@@ -119,16 +119,14 @@ SO_EXPORT int context_places_get_list(context_places_list_h* list)
        IF_FAIL_RETURN_TAG(
                        error == ERR_NONE,
                        error,
-                       _E,
-                       "Getting list failed");
+                       _E, "Getting list failed");
 
        _J("Read response", tmp_list);
 
        IF_FAIL_RETURN_TAG(
                        tmp_list.getSize(NULL, PLACE_DATA_READ) > 0,
                        CONTEXT_PLACES_ERROR_NO_DATA,
-                       _D,
-                       "No data");
+                       _D, "No data");
 
        *list = new(std::nothrow) _context_places_list_handle_s();
        ASSERT_ALLOC(*list);
@@ -160,8 +158,7 @@ SO_EXPORT int context_places_list_get_current(context_places_list_h list, contex
        IF_FAIL_RETURN_TAG(
                        error,
                        CONTEXT_PLACES_ERROR_OPERATION_FAILED,
-                       _E,
-                       "Place record load failed");
+                       _E, "Place record load failed");
 
        *record = new(std::nothrow) _context_places_place_handle_s();
        ASSERT_ALLOC(*record);
@@ -186,8 +183,7 @@ SO_EXPORT int context_places_list_move_next(context_places_list_h list)
        IF_FAIL_RETURN_TAG(
                        list->current+1 < list->jList.getSize(NULL, PLACE_DATA_READ),
                        CONTEXT_PLACES_ERROR_NO_DATA,
-                       _D,
-                       "End of list");
+                       _D, "End of list");
 
        list->current++;
 
@@ -211,15 +207,13 @@ SO_EXPORT int context_places_place_get_category(context_places_place_h place, co
        IF_FAIL_RETURN_TAG(
                        place->jPlace.get(NULL, PLACE_CATEG_ID, &categId),
                        CONTEXT_PLACES_ERROR_NO_DATA,
-                       _E,
-                       "Parameter empty");
+                       _E, "Category parameter empty");
 
        double categConfidence;
        IF_FAIL_RETURN_TAG(
                        place->jPlace.get(NULL, PLACE_CATEG_CONFIDENCE, &categConfidence),
                        CONTEXT_PLACES_ERROR_NO_DATA,
-                       _E,
-                       "Parameter empty");
+                       _E, "Categorization confidence parameter empty");
 
        *value = static_cast<context_places_categ_id_e>(categId);
        *confidence = categConfidence;
@@ -235,8 +229,7 @@ SO_EXPORT int context_places_place_get_name(context_places_place_h place, char**
        IF_FAIL_RETURN_TAG(
                        place->jPlace.get(NULL, PLACE_NAME, &str),
                        CONTEXT_PLACES_ERROR_NO_DATA,
-                       _E,
-                       "Parameter empty");
+                       _E, "Parameter empty");
 
        *name = g_strdup(str.c_str());
        ASSERT_ALLOC(*name);
@@ -252,29 +245,23 @@ SO_EXPORT int context_places_place_get_location(context_places_place_h place, do
        IF_FAIL_RETURN_TAG(
                        place->jPlace.get(NULL, PLACE_LOCATION, &locationJson),
                        CONTEXT_PLACES_ERROR_NO_DATA,
-                       _E,
-                       "Location parameter empty");
+                       _E, "Location parameter empty");
 
        double lat;
        IF_FAIL_RETURN_TAG(
                        locationJson.get(NULL, PLACE_LOCATION_LATITUDE, &lat),
                        CONTEXT_PLACES_ERROR_NO_DATA,
-                       _E,
-                       "Location latitude parameter empty");
+                       _E, "Location latitude parameter empty");
 
        double lon;
        IF_FAIL_RETURN_TAG(
                        locationJson.get(NULL, PLACE_LOCATION_LONGITUDE, &lon),
                        CONTEXT_PLACES_ERROR_NO_DATA,
-                       _E,
-                       "Location longitude parameter empty");
+                       _E, "Location longitude parameter empty");
 
-       double acc;
-       IF_FAIL_RETURN_TAG(
-                       locationJson.get(NULL, PLACE_LOCATION_ACCURACY, &acc),
-                       CONTEXT_PLACES_ERROR_NO_DATA,
-                       _E,
-                       "Location accuracy parameter empty");
+       double acc = -1.0;
+       if (!(locationJson.get(NULL, PLACE_LOCATION_ACCURACY, &acc)))
+               _D("Location accuracy parameter empty");
 
        *latitude = lat;
        *longitude = lon;
@@ -291,8 +278,7 @@ SO_EXPORT int context_places_place_get_creation_date(context_places_place_h plac
        IF_FAIL_RETURN_TAG(
                        place->jPlace.get(NULL, PLACE_CREATE_DATE, &tmp_timestamp),
                        CONTEXT_PLACES_ERROR_NO_DATA,
-                       _E,
-                       "Parameter empty");
+                       _D, "Parameter empty");
 
        *timestamp = static_cast<time_t>(tmp_timestamp);
 
@@ -317,14 +303,12 @@ SO_EXPORT int context_places_place_get_wifi_ap_list(context_places_place_h place
        IF_FAIL_RETURN_TAG(
                        place->jPlace.get(NULL, PLACE_WIFI_APS, &tmp_list),
                        CONTEXT_PLACES_ERROR_NO_DATA,
-                       _E,
-                       "No data");
+                       _E, "No data");
 
        IF_FAIL_RETURN_TAG(
                        tmp_list.getSize(NULL, PLACE_WIFI_APS) > 0,
                        CONTEXT_PLACES_ERROR_NO_DATA,
-                       _D,
-                       "No data");
+                       _D, "No data");
 
        *list = new(std::nothrow) _context_places_wifi_ap_list_handle_s();
        ASSERT_ALLOC(*list);
@@ -355,22 +339,19 @@ SO_EXPORT int context_places_wifi_ap_list_get_current(context_places_wifi_ap_lis
        IF_FAIL_RETURN_TAG(
                        list->jList.getAt(NULL, PLACE_WIFI_APS, list->current, &wifiAPJson),
                        CONTEXT_PLACES_ERROR_OPERATION_FAILED,
-                       _E,
-                       "Place Wifi AP load failed");
+                       _E, "Place Wifi AP load failed");
 
        std::string bssid_str;
        IF_FAIL_RETURN_TAG(
                        wifiAPJson.get(NULL, PLACE_WIFI_AP_MAC, &bssid_str),
                        CONTEXT_PLACES_ERROR_NO_DATA,
-                       _E,
-                       "Parameter empty");
+                       _E, "Parameter empty");
 
        std::string essid_str;
        IF_FAIL_RETURN_TAG(
                        wifiAPJson.get(NULL, PLACE_WIFI_AP_NETWORK_NAME, &essid_str),
                        CONTEXT_PLACES_ERROR_NO_DATA,
-                       _E,
-                       "Parameter empty");
+                       _E, "Parameter empty");
 
        *bssid = g_strdup(bssid_str.c_str());
        ASSERT_ALLOC(*bssid);
@@ -397,8 +378,7 @@ SO_EXPORT int context_places_wifi_ap_list_move_next(context_places_wifi_ap_list_
        IF_FAIL_RETURN_TAG(
                        list->current+1 < list->jList.getSize(NULL, PLACE_WIFI_APS),
                        CONTEXT_PLACES_ERROR_NO_DATA,
-                       _D,
-                       "End of list");
+                       _D, "End of list");
 
        list->current++;
 
@@ -441,8 +421,7 @@ SO_EXPORT int context_places_consent(bool consent)
        IF_FAIL_RETURN_TAG(
                        error == ERR_NONE,
                        CONTEXT_PLACES_ERROR_OPERATION_FAILED,
-                       _E,
-                       "Setting consent value failed");
+                       _E, "Setting consent value failed");
 
        return CONTEXT_PLACES_ERROR_NONE;
 }
@@ -459,15 +438,13 @@ SO_EXPORT int context_places_is_consented(bool *consented)
        IF_FAIL_RETURN_TAG(
                        ret == ERR_NONE,
                        CONTEXT_PLACES_ERROR_OPERATION_FAILED,
-                       _E,
-                       "Getting consent value failed");
+                       _E, "Getting consent value failed");
 
        std::string value;
        IF_FAIL_RETURN_TAG(
                        tmp_cons.get(NULL, PLACE_DETECTION_REQUEST_CONSENT, &value),
                        CONTEXT_PLACES_ERROR_OPERATION_FAILED,
-                       _E,
-                       "Getting consent value failed");
+                       _E, "Getting consent value failed");
        if (value == MYPLACE_SETTING_VALUE_TRUE) {
                *consented = true;
        } else if (value == MYPLACE_SETTING_VALUE_FALSE) {