diff options
Diffstat (limited to 'module/module_geofence_server.c')
-rw-r--r-- | module/module_geofence_server.c | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/module/module_geofence_server.c b/module/module_geofence_server.c index 0011ec9..fc1783f 100644 --- a/module/module_geofence_server.c +++ b/module/module_geofence_server.c @@ -33,9 +33,9 @@ #define MYPLACES_APP_ID "org.tizen.myplace" typedef enum { - ACCESS_TYPE_PRIVATE = 1, - ACCESS_TYPE_PUBLIC, - ACCESS_TYPE_UNKNOWN, + ACCESS_TYPE_PRIVATE = 1, + ACCESS_TYPE_PUBLIC, + ACCESS_TYPE_UNKNOWN, } access_type_e; typedef struct { @@ -53,11 +53,14 @@ EXPORT_API int add_geopoint(void *handle, int place_id, double latitude, double GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle; g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER); int new_fence_id = -1; + int error_code = GEOFENCE_MANAGER_ERROR_NONE; - new_fence_id = geo_client_add_geofence(geofence_manager->geofence_client, geofence_manager->app_id, place_id, GEOFENCE_TYPE_GEOPOINT, latitude, longitude, radius, address, "", ""); + new_fence_id = geo_client_add_geofence(geofence_manager->geofence_client, geofence_manager->app_id, place_id, GEOFENCE_TYPE_GEOPOINT, latitude, longitude, radius, address, "", "", &error_code); *fence_id = new_fence_id; - if (new_fence_id == -1) + if (error_code != GEOFENCE_MANAGER_ERROR_NONE) + return error_code; + else if (new_fence_id == -1) return GEOFENCE_CLIENT_ERROR_DBUS_CALL; return GEOFENCE_MANAGER_ERROR_NONE; @@ -69,11 +72,14 @@ EXPORT_API int add_bssid(void *handle, int place_id, const char *bssid, const ch GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle; g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER); int new_fence_id = -1; + int error_code = GEOFENCE_MANAGER_ERROR_NONE; - new_fence_id = geo_client_add_geofence(geofence_manager->geofence_client, geofence_manager->app_id, place_id, type, -1, -1, -1, "", bssid, ssid); + new_fence_id = geo_client_add_geofence(geofence_manager->geofence_client, geofence_manager->app_id, place_id, type, -1, -1, -1, "", bssid, ssid, &error_code); *fence_id = new_fence_id; - if (new_fence_id == -1) + if (error_code != GEOFENCE_MANAGER_ERROR_NONE) + return error_code; + else if (new_fence_id == -1) return GEOFENCE_CLIENT_ERROR_DBUS_CALL; return GEOFENCE_MANAGER_ERROR_NONE; @@ -85,11 +91,14 @@ EXPORT_API int add_place(void *handle, const char *place_name, int *place_id) GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle; g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER); int new_place_id = -1; + int error_code = GEOFENCE_MANAGER_ERROR_NONE; - new_place_id = geo_client_add_place(geofence_manager->geofence_client, geofence_manager->app_id, place_name); + new_place_id = geo_client_add_place(geofence_manager->geofence_client, geofence_manager->app_id, place_name, &error_code); *place_id = new_place_id; - if (new_place_id == -1) + if (error_code != GEOFENCE_MANAGER_ERROR_NONE) + return error_code; + else if (new_place_id == -1) return GEOFENCE_CLIENT_ERROR_DBUS_CALL; return GEOFENCE_MANAGER_ERROR_NONE; @@ -103,7 +112,7 @@ EXPORT_API int update_place(void *handle, int place_id, const char *place_name) int ret = geo_client_update_place(geofence_manager->geofence_client, geofence_manager->app_id, place_id, place_name); if (ret != GEOFENCE_CLIENT_ERROR_NONE) - return GEOFENCE_CLIENT_ERROR_DBUS_CALL; + return ret; return GEOFENCE_MANAGER_ERROR_NONE; } @@ -116,7 +125,7 @@ EXPORT_API int remove_geofence(void *handle, int fence_id) int ret = geo_client_delete_geofence(geofence_manager->geofence_client, geofence_manager->app_id, fence_id); if (ret != GEOFENCE_CLIENT_ERROR_NONE) - return GEOFENCE_CLIENT_ERROR_DBUS_CALL; + return ret; return GEOFENCE_MANAGER_ERROR_NONE; } @@ -129,7 +138,7 @@ EXPORT_API int remove_place(void *handle, int place_id) int ret = geo_client_delete_place(geofence_manager->geofence_client, geofence_manager->app_id, place_id); if (ret != GEOFENCE_CLIENT_ERROR_NONE) - return GEOFENCE_CLIENT_ERROR_DBUS_CALL; + return ret; return GEOFENCE_MANAGER_ERROR_NONE; } @@ -222,7 +231,7 @@ EXPORT_API int get_place_name(void *handle, int place_id, char **place_name) int error_code = GEOFENCE_MANAGER_ERROR_NONE; int ret = geo_client_get_place_name(geofence_manager->geofence_client, geofence_manager->app_id, place_id, place_name, &error_code); if (ret != GEOFENCE_CLIENT_ERROR_NONE) - return GEOFENCE_CLIENT_ERROR_DBUS_CALL; + return ret; return error_code; } @@ -247,15 +256,15 @@ EXPORT_API int get_geofences(void *handle, int place_id, int *fence_amount, int int error_code = GEOFENCE_MANAGER_ERROR_NONE; int ret = geo_client_get_geofences(geofence_manager->geofence_client, geofence_manager->app_id, place_id, &iter, &fence_cnt, &error_code); - if (error_code != GEOFENCE_MANAGER_ERROR_NONE) + if (ret != GEOFENCE_MANAGER_ERROR_NONE) + return ret; + else if (error_code != GEOFENCE_MANAGER_ERROR_NONE) return error_code; - else if (ret != GEOFENCE_MANAGER_ERROR_NONE) - return GEOFENCE_CLIENT_ERROR_DBUS_CALL; *fence_amount = fence_cnt; MOD_LOGD("Total fence count : %d", *fence_amount); - int *fence_id_array = (int *) g_slice_alloc0(sizeof(int) * fence_cnt); - geofence_s *p = (geofence_s *) g_slice_alloc0(sizeof(geofence_s) * fence_cnt); + int *fence_id_array = (int *) g_slice_alloc0(sizeof(int) *fence_cnt); + geofence_s *p = (geofence_s *) g_slice_alloc0(sizeof(geofence_s) *fence_cnt); while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { while (g_variant_iter_loop(iter_row, "{sv}", &key, &value)) { @@ -310,28 +319,29 @@ EXPORT_API int get_places(void *handle, int *place_amount, int **place_ids, plac gchar *key; GVariant *value; int place_cnt = 0; - int error_code = -1; + int error_code = GEOFENCE_MANAGER_ERROR_NONE; /*Call the geofence_client api here....*/ - geo_client_get_places(geofence_manager->geofence_client, geofence_manager->app_id, &iter, &place_cnt, &error_code); + int ret = geo_client_get_places(geofence_manager->geofence_client, geofence_manager->app_id, &iter, &place_cnt, &error_code); + if (ret != GEOFENCE_MANAGER_ERROR_NONE) + return ret; if (error_code != GEOFENCE_MANAGER_ERROR_NONE) return error_code; *place_amount = place_cnt; MOD_LOGI("Total place count : %d", *place_amount); - int *place_id_array = (int *)g_slice_alloc0(sizeof(int) * place_cnt); - place_s *p = (place_s *)g_slice_alloc0(sizeof(place_s) * place_cnt); + int *place_id_array = (int *)g_slice_alloc0(sizeof(int) *place_cnt); + place_s *p = (place_s *)g_slice_alloc0(sizeof(place_s) *place_cnt); if (iter == NULL) MOD_LOGI("Iterator is null"); while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { while (g_variant_iter_loop(iter_row, "{sv}", &key, &value)) { - if (!g_strcmp0(key, "place_id")) { + if (!g_strcmp0(key, "place_id")) place_id_array[index] = g_variant_get_int32(value); - } else if (!g_strcmp0(key, "place_name")) { + else if (!g_strcmp0(key, "place_name")) g_strlcpy(p[index].place_name, g_variant_get_string(value, NULL), PLACE_NAME_LEN); - } } MOD_LOGI("place_id: %d, place_name: %s", place_id_array[index], p[index].place_name); index++; @@ -374,7 +384,7 @@ EXPORT_API int start_geofence(void *handle, int fence_id) ret = geo_client_start_geofence(geofence_manager->geofence_client, geofence_manager->app_id, fence_id); if (ret != GEOFENCE_MANAGER_ERROR_NONE) { MOD_LOGE("Fail to start geofence_client_h. Error[%d]", ret); - return GEOFENCE_CLIENT_ERROR_DBUS_CALL; + return ret; } return GEOFENCE_MANAGER_ERROR_NONE; @@ -392,7 +402,7 @@ EXPORT_API int stop_geofence(void *handle, int fence_id) ret = geo_client_stop_geofence(geofence_manager->geofence_client, geofence_manager->app_id, fence_id); if (ret != GEOFENCE_MANAGER_ERROR_NONE) { MOD_LOGE("Fail to stop. Error[%d]", ret); - return GEOFENCE_CLIENT_ERROR_DBUS_CALL; + return ret; } return GEOFENCE_MANAGER_ERROR_NONE; |