From: jomui Date: Wed, 12 Apr 2017 01:08:11 +0000 (+0900) Subject: fixed for deprecate WIFI API X-Git-Tag: submit/tizen/20170412.045102^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F124575%2F7;p=platform%2Fcore%2Flocation%2Fgeofence-server.git fixed for deprecate WIFI API Signed-off-by: jomui Change-Id: I1a6a7a8d0fd69ec6f84ac85ac0c6303636f32da1 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index a416dfa..6600afd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ SET(BIN_DIR "${PREFIX}/bin") #Dependencies SET(common_dp "glib-2.0 geofence-dbus dlog gio-2.0 capi-appfw-app-manager") -SET(server_dp "${common_dp} network vconf vconf-internal-keys capi-system-info gthread-2.0 gio-unix-2.0 sqlite3 db-util alarm-service deviced capi-location-manager capi-network-bluetooth capi-network-wifi libcore-context-manager capi-system-device libtzplatform-config") +SET(server_dp "${common_dp} network vconf vconf-internal-keys capi-system-info gthread-2.0 gio-unix-2.0 sqlite3 db-util alarm-service deviced capi-location-manager capi-network-bluetooth capi-network-wifi-manager libcore-context-manager capi-system-device libtzplatform-config") SET(module_dp "${common_dp} gmodule-2.0 capi-geofence-manager") # Set required packages diff --git a/geofence-server/src/geofence_server.c b/geofence-server/src/geofence_server.c index 77eba2c..de56328 100644 --- a/geofence-server/src/geofence_server.c +++ b/geofence-server/src/geofence_server.c @@ -35,7 +35,7 @@ #include "geofence_server_alarm.h" #include "geofence_server_internal.h" #include "geofence_server_bluetooth.h" -#include +#include #include #include @@ -81,39 +81,43 @@ static bool __is_support_wps() return is_wps_supported; } -static const char *__convert_wifi_error_to_string(wifi_error_e err_type) +static const char *__convert_wifi_error_to_string(wifi_manager_error_e err_type) { switch (err_type) { - case WIFI_ERROR_NONE: + case WIFI_MANAGER_ERROR_NONE: return "NONE"; - case WIFI_ERROR_INVALID_PARAMETER: + case WIFI_MANAGER_ERROR_INVALID_PARAMETER: return "INVALID_PARAMETER"; - case WIFI_ERROR_OUT_OF_MEMORY: + case WIFI_MANAGER_ERROR_OUT_OF_MEMORY: return "OUT_OF_MEMORY"; - case WIFI_ERROR_INVALID_OPERATION: + case WIFI_MANAGER_ERROR_INVALID_OPERATION: return "INVALID_OPERATION"; - case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED: + case WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED: return "ADDRESS_FAMILY_NOT_SUPPORTED"; - case WIFI_ERROR_OPERATION_FAILED: + case WIFI_MANAGER_ERROR_OPERATION_FAILED: return "OPERATION_FAILED"; - case WIFI_ERROR_NO_CONNECTION: + case WIFI_MANAGER_ERROR_NO_CONNECTION: return "NO_CONNECTION"; - case WIFI_ERROR_NOW_IN_PROGRESS: + case WIFI_MANAGER_ERROR_NOW_IN_PROGRESS: return "NOW_IN_PROGRESS"; - case WIFI_ERROR_ALREADY_EXISTS: + case WIFI_MANAGER_ERROR_ALREADY_EXISTS: return "ALREADY_EXISTS"; - case WIFI_ERROR_OPERATION_ABORTED: + case WIFI_MANAGER_ERROR_OPERATION_ABORTED: return "OPERATION_ABORTED"; - case WIFI_ERROR_DHCP_FAILED: + case WIFI_MANAGER_ERROR_DHCP_FAILED: return "DHCP_FAILED"; - case WIFI_ERROR_INVALID_KEY: + case WIFI_MANAGER_ERROR_INVALID_KEY: return "INVALID_KEY"; - case WIFI_ERROR_NO_REPLY: + case WIFI_MANAGER_ERROR_NO_REPLY: return "NO_REPLY"; - case WIFI_ERROR_SECURITY_RESTRICTED: + case WIFI_MANAGER_ERROR_SECURITY_RESTRICTED: return "SECURITY_RESTRICTED"; - case WIFI_ERROR_PERMISSION_DENIED: + case WIFI_MANAGER_ERROR_ALREADY_INITIALIZED: + return "ALREADY_INITIALIZED"; + case WIFI_MANAGER_ERROR_PERMISSION_DENIED: return "PERMISSION_DENIED"; + case WIFI_MANAGER_ERROR_NOT_SUPPORTED: + return "NOT_SUPPORTED"; default: return "NOT Defined"; } @@ -1281,7 +1285,7 @@ static void __free_geofence_list(gpointer userdata) static int __check_fence_permission(int fence_id, const char *app_id) { access_type_e access_type = ACCESS_TYPE_PUBLIC; - char *appid; + char *appid = NULL; int ret = FENCE_ERR_NONE; ret = geofence_manager_get_access_type(fence_id, -1, &access_type); if (ret != FENCE_ERR_NONE) { @@ -1295,17 +1299,19 @@ static int __check_fence_permission(int fence_id, const char *app_id) return -1; } if (g_strcmp0(appid, app_id)) { - LOGE("Not authorized to access this private fence[%d]", fence_id); + LOGE("Not authorized to access this private fence[%d]", fence_id); + g_free(appid); return 0; } } + g_free(appid); return 1; } static int __check_place_permission(int place_id, const char *app_id) { access_type_e access_type = ACCESS_TYPE_PUBLIC; - char *appid; + char *appid = NULL; int ret = FENCE_ERR_NONE; ret = geofence_manager_get_access_type(-1, place_id, &access_type); if (ret != FENCE_ERR_NONE) { @@ -1319,10 +1325,12 @@ static int __check_place_permission(int place_id, const char *app_id) return -1; } if (g_strcmp0(appid, app_id)) { - LOGE("Not authorized to access this private place[%d]", place_id); + LOGE("Not authorized to access this private place[%d]", place_id); + g_free(appid); return 0; } } + g_free(appid); return 1; } @@ -1572,7 +1580,7 @@ static int dbus_add_fence_cb(const gchar *app_id, g_strlcpy(geocoordinate_info->address, address, ADDRESS_LEN); /*Geopoint information is saved in the DB*/ - ret = geofence_manager_set_geocoordinate_info(fence_id, geocoordinate_info); + ret = geofence_manager_set_geocoordinate_info(fence_id, geocoordinate_info); if (ret != FENCE_ERR_NONE) { LOGI_GEOFENCE("Fail to set geocoordinate_info"); ret = geofence_manager_delete_fence_info(fence_id); @@ -1796,7 +1804,7 @@ static void dbus_remove_fence_cb(gint fence_id, const gchar *app_id, gpointer us g_return_if_fail(geofence_server); int ret = FENCE_ERR_NONE; int place_id = -1; - char *app_id_db; + char *app_id_db = NULL; access_type_e access_type = ACCESS_TYPE_UNKNOWN; /*//////////Required to be sent in the event callback////////////////--*/ @@ -2187,9 +2195,9 @@ static void dbus_start_geofence_cb(gint fence_id, const gchar *app_id, gpointer } } else if (item_data->common_info.type == GEOFENCE_TYPE_WIFI) { LOGI_GEOFENCE("fence_type [GEOFENCE_TYPE_WIFI]"); - wifi_error_e rv = WIFI_ERROR_NONE; + wifi_manager_error_e rv = WIFI_MANAGER_ERROR_NONE; int nWifiState; - wifi_ap_h ap_h; + wifi_manager_ap_h ap_h; char *ap_bssid = NULL; int bssidlen; bssid_info_s *wifi_info = NULL; @@ -2201,16 +2209,16 @@ static void dbus_start_geofence_cb(gint fence_id, const gchar *app_id, gpointer if (item_data->priv != NULL) wifi_info = (bssid_info_s *) item_data->priv; - rv = wifi_get_connected_ap(&ap_h); - if (rv != WIFI_ERROR_NONE) { + rv = wifi_manager_get_connected_ap(geofence_server->wifi_h, &ap_h); + if (rv != WIFI_MANAGER_ERROR_NONE) { LOGI_GEOFENCE("Fail/not connected to get the connected AP: [%s] , geofence will be added to the fence list", __convert_wifi_error_to_string(rv)); - if (rv == WIFI_ERROR_NO_CONNECTION) { + if (rv == WIFI_MANAGER_ERROR_NO_CONNECTION) { LOGI_GEOFENCE("Not connected to any AP"); status_to_be_emitted = GEOFENCE_FENCE_STATE_OUT; } } else { - rv = wifi_ap_get_bssid(ap_h, &ap_bssid); - if (rv != WIFI_ERROR_NONE) { + rv = wifi_manager_ap_get_bssid(ap_h, &ap_bssid); + if (rv != WIFI_MANAGER_ERROR_NONE) { LOGI_GEOFENCE("Fail to get the bssid: [%d]\n", __convert_wifi_error_to_string(rv)); } else { bssidlen = strlen(ap_bssid); @@ -2456,16 +2464,14 @@ static GVariant *dbus_get_geofences_cb(int place_id, const gchar *app_id, int *f if ((place_info != NULL) && (place_info->access_type == ACCESS_TYPE_PRIVATE)) { if (g_strcmp0(app_id, place_info->appid) != 0) { LOGI_GEOFENCE("Not authorized to access this private place[%d]", place_id); - if (place_info) - g_free(place_info); + g_free(place_info); /* Send ZERO data gvariant*/ *errorCode = GEOFENCE_SERVER_ERROR_PLACE_ACCESS_DENIED; *fenceCnt = fence_cnt; g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); return g_variant_builder_end(&b); } - if (place_info) - g_free(place_info); + g_free(place_info); } ret = geofence_manager_get_fence_list_from_db(&count, &fence_list, place_id); } @@ -2654,6 +2660,8 @@ static void __init_geofencemanager(GeofenceServer *geofence_server) geofence_server->activity_run_h = NULL; geofence_server->activity_in_vehicle_h = NULL; + geofence_server->wifi_h = NULL; + /*Initializing the DB to store the fence informations*/ if (geofence_manager_db_init() != FENCE_ERR_NONE) LOGI_GEOFENCE("Error initalizing the DB"); @@ -2716,10 +2724,9 @@ int __copy_geofence_to_item_data(int fence_id, GeofenceItemData *item_data) if (FENCE_ERR_NONE != geofence_manager_get_enable_status(fence_id, &item_data->common_info.enable)) return FENCE_ERR_SQLITE_FAIL; - if (FENCE_ERR_NONE != geofence_manager_get_appid_from_geofence(fence_id, &app_id)) { - g_free(app_id); + if (FENCE_ERR_NONE != geofence_manager_get_appid_from_geofence(fence_id, &app_id)) return FENCE_ERR_SQLITE_FAIL; - } else { + else { g_strlcpy(item_data->common_info.appid, app_id, APP_ID_LEN); g_free(app_id); } @@ -2779,6 +2786,10 @@ static void __add_left_fences(gpointer user_data) * } */ GeofenceItemData *item_data = (GeofenceItemData *)g_malloc0(sizeof(GeofenceItemData)); + if (item_data == NULL) { + LOGI_GEOFENCE("Unable to add the fence because of malloc fail"); + return; + } if (FENCE_ERR_NONE != __copy_geofence_to_item_data(fence_id, item_data)) { g_free(item_data); return; @@ -2871,7 +2882,7 @@ int main(int argc, char **argv) LOGD_GEOFENCE("GEOFENCE_manager deamon Stop...."); /*This call goes to server.c and deregisters all the callbacks w.r.t bt and wifi*/ - _geofence_deinitialize_geofence_server(); + _geofence_deinitialize_geofence_server(geofenceserver); #ifdef TIZEN_ENGINEER_MODE _deinit_log(); diff --git a/geofence-server/src/geofence_server.h b/geofence-server/src/geofence_server.h index 0d5d635..19a3044 100644 --- a/geofence-server/src/geofence_server.h +++ b/geofence-server/src/geofence_server.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include @@ -71,7 +71,7 @@ typedef void (*geofence_device_display_changed_cb)(device_callback_e type, void * @Param[in] user_data The user data to be returned * @see None. */ -typedef void (*geofence_wifi_conn_state_changed_cb)(wifi_connection_state_e state, wifi_ap_h ap, void *user_data); +typedef void (*geofence_wifi_conn_state_changed_cb)(wifi_manager_connection_state_e state, wifi_manager_ap_h ap, void *user_data); /** * @brief Wifi device status change callback @@ -80,7 +80,7 @@ typedef void (*geofence_wifi_conn_state_changed_cb)(wifi_connection_state_e stat * @Param[in] user_data The user data to be returned * @see None. */ -typedef void (*geofence_wifi_device_state_changed_cb)(wifi_device_state_e state, void *user_data); +typedef void (*geofence_wifi_device_state_changed_cb)(wifi_manager_device_state_e state, void *user_data); /** * @brief Network scan status change callback @@ -121,7 +121,7 @@ typedef void (*geofence_gps_setting_changed_cb)(location_method_e method, bool e * @see wifi_set_rssi_level_changed_cb() * @see wifi_unset_rssi_level_changed_cb() */ -typedef void(*geofence_wifi_rssi_level_changed_cb)(wifi_rssi_level_e rssi_level, void *user_data); +typedef void(*geofence_wifi_rssi_level_changed_cb)(wifi_manager_rssi_level_e rssi_level, void *user_data); /** * Geofence callback structure. diff --git a/geofence-server/src/geofence_server_bluetooth.c b/geofence-server/src/geofence_server_bluetooth.c index ccb689a..30dbf51 100644 --- a/geofence-server/src/geofence_server_bluetooth.c +++ b/geofence-server/src/geofence_server_bluetooth.c @@ -107,9 +107,7 @@ static void emit_bt_geofence_proximity_changed(GeofenceServer *geofence_server, } item_data->common_info.proximity_status = fence_proximity_status; } - - if (app_id) - free(app_id); + g_free(app_id); } diff --git a/geofence-server/src/geofence_server_db.c b/geofence-server/src/geofence_server_db.c index 26273be..8c85238 100755 --- a/geofence-server/src/geofence_server_db.c +++ b/geofence-server/src/geofence_server_db.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -618,8 +618,8 @@ void __geofence_manager_generate_password(char *password) if (ret != BT_ERROR_NONE) LOGD_GEOFENCE("bt address get fail %d", ret); - ret = wifi_get_mac_address(&wifi_address); - if (ret != WIFI_ERROR_NONE) + ret = wifi_manager_get_mac_address(&wifi_address); + if (ret != WIFI_MANAGER_ERROR_NONE) LOGD_GEOFENCE("wifi address get fail %d", ret); if (bt_address) { diff --git a/geofence-server/src/geofence_server_private.h b/geofence-server/src/geofence_server_private.h index 729054b..e34b023 100644 --- a/geofence-server/src/geofence_server_private.h +++ b/geofence-server/src/geofence_server_private.h @@ -181,6 +181,8 @@ typedef struct { activity_h activity_walk_h; activity_h activity_run_h; activity_h activity_in_vehicle_h; + + wifi_manager_h wifi_h; } GeofenceServer; #ifdef __cplusplus diff --git a/geofence-server/src/geofence_server_wifi.c b/geofence-server/src/geofence_server_wifi.c index 13fc92f..5001594 100644 --- a/geofence-server/src/geofence_server_wifi.c +++ b/geofence-server/src/geofence_server_wifi.c @@ -54,8 +54,7 @@ static void emit_wifi_geofence_inout_changed(GeofenceServer *geofence_server, in item_data->common_info.status = GEOFENCE_FENCE_STATE_OUT; } } - if (app_id) - free(app_id); + g_free(app_id); } static bool __check_for_match(char *str1, char *str2) @@ -132,34 +131,33 @@ static void emit_wifi_geofence_proximity_changed(GeofenceServer *geofence_server } item_data->common_info.proximity_status = fence_proximity_status; } - if (app_id) - free(app_id); + g_free(app_id); } -void wifi_rssi_level_changed(wifi_rssi_level_e rssi_level, void *user_data) +void wifi_rssi_level_changed(wifi_manager_rssi_level_e rssi_level, void *user_data) { FUNC_ENTRANCE_SERVER GeofenceServer *geofence_server = (GeofenceServer *) user_data; g_return_if_fail(geofence_server); - wifi_ap_h ap_h; + wifi_manager_ap_h ap_h; char *bssid = NULL; geofence_proximity_state_e state = GEOFENCE_PROXIMITY_UNCERTAIN; - wifi_error_e rv = WIFI_ERROR_NONE; + wifi_manager_error_e rv = WIFI_MANAGER_ERROR_NONE; LOGI_GEOFENCE("running cnt: %d, connected id: %d", geofence_server->running_wifi_cnt, geofence_server->connectedTrackingWifiFenceId); if (geofence_server->running_wifi_cnt > 0 && geofence_server->connectedTrackingWifiFenceId != -1) { - rv = wifi_get_connected_ap(&ap_h); - if (rv != WIFI_ERROR_NONE) { + rv = wifi_manager_get_connected_ap(geofence_server->wifi_h, &ap_h); + if (rv != WIFI_MANAGER_ERROR_NONE) { LOGE_GEOFENCE("Fail to get the connected AP: Error - %d", rv); return; } - rv = wifi_ap_get_bssid(ap_h, &bssid); - if (rv != WIFI_ERROR_NONE) { + rv = wifi_manager_ap_get_bssid(ap_h, &bssid); + if (rv != WIFI_MANAGER_ERROR_NONE) { LOGI_GEOFENCE("Fail to get the bssid: [%d]", rv); } else { /*Emit the proximity alert here using mConnectedFenceId*/ - if (rssi_level == WIFI_RSSI_LEVEL_4) + if (rssi_level == WIFI_MANAGER_RSSI_LEVEL_4) state = GEOFENCE_PROXIMITY_IMMEDIATE; - else if (rssi_level == WIFI_RSSI_LEVEL_3) + else if (rssi_level == WIFI_MANAGER_RSSI_LEVEL_3) state = GEOFENCE_PROXIMITY_NEAR; else state = GEOFENCE_PROXIMITY_FAR; @@ -171,7 +169,7 @@ void wifi_rssi_level_changed(wifi_rssi_level_e rssi_level, void *user_data) } } -void wifi_device_state_changed(wifi_device_state_e state, void *user_data) +void wifi_device_state_changed(wifi_manager_device_state_e state, void *user_data) { FUNC_ENTRANCE_SERVER GeofenceServer *geofence_server = (GeofenceServer *) user_data; @@ -196,7 +194,7 @@ void wifi_device_state_changed(wifi_device_state_e state, void *user_data) if (fence_type != GEOFENCE_TYPE_WIFI) continue; - if (state == WIFI_DEVICE_STATE_DEACTIVATED) { + if (state == WIFI_MANAGER_DEVICE_STATE_DEACTIVATED) { LOGD_GEOFENCE("Emitted to fence_id [%d] GEOFENCE_FENCE_STATE_OUT", fence_id); emit_wifi_geofence_inout_changed(geofence_server, fence_id, GEOFENCE_FENCE_STATE_OUT); emit_wifi_geofence_proximity_changed(geofence_server, fence_id, GEOFENCE_PROXIMITY_UNCERTAIN); @@ -206,7 +204,7 @@ void wifi_device_state_changed(wifi_device_state_e state, void *user_data) LOGD_GEOFENCE("exit"); } -void __geofence_check_wifi_matched_bssid(wifi_connection_state_e state, char *bssid, void *user_data) +void __geofence_check_wifi_matched_bssid(wifi_manager_connection_state_e state, char *bssid, void *user_data) { LOGD_GEOFENCE("Comparing the matching bssids"); GeofenceServer *geofence_server = (GeofenceServer *)user_data; @@ -230,10 +228,10 @@ void __geofence_check_wifi_matched_bssid(wifi_connection_state_e state, char *bs } if (!g_ascii_strcasecmp(bssid_info->bssid, bssid) || !g_ascii_strcasecmp(g_strdelimit(bssid_info->bssid, "-", ':'), bssid)) { LOGI_GEOFENCE("Matched wifi fence: fence_id = %d, bssid = %s", tracking_fence_id, bssid_info->bssid); - if (state == WIFI_CONNECTION_STATE_CONNECTED) { + if (state == WIFI_MANAGER_CONNECTION_STATE_CONNECTED) { emit_wifi_geofence_inout_changed(geofence_server, tracking_fence_id, GEOFENCE_FENCE_STATE_IN); geofence_server->connectedTrackingWifiFenceId = tracking_fence_id; - } else if (state == WIFI_CONNECTION_STATE_DISCONNECTED) { + } else if (state == WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED) { emit_wifi_geofence_inout_changed(geofence_server, tracking_fence_id, GEOFENCE_FENCE_STATE_OUT); emit_wifi_geofence_proximity_changed(geofence_server, tracking_fence_id, GEOFENCE_PROXIMITY_UNCERTAIN); geofence_server->connectedTrackingWifiFenceId = -1; @@ -245,24 +243,24 @@ void __geofence_check_wifi_matched_bssid(wifi_connection_state_e state, char *bs } -void wifi_conn_state_changed(wifi_connection_state_e state, wifi_ap_h ap, void *user_data) +void wifi_conn_state_changed(wifi_manager_connection_state_e state, wifi_manager_ap_h ap, void *user_data) { LOGD_GEOFENCE("wifi_conn_state_changed"); GeofenceServer *geofence_server = (GeofenceServer *)user_data; char *ap_bssid = NULL; int rv = 0; g_return_if_fail(geofence_server); - rv = wifi_ap_get_bssid(ap, &ap_bssid); + rv = wifi_manager_ap_get_bssid(ap, &ap_bssid); - if (rv != WIFI_ERROR_NONE) { + if (rv != WIFI_MANAGER_ERROR_NONE) { LOGD_GEOFENCE("Failed to get the bssid"); return; } - if (state == WIFI_CONNECTION_STATE_CONNECTED) { + if (state == WIFI_MANAGER_CONNECTION_STATE_CONNECTED) { LOGD_GEOFENCE("Wifi connected to [%s].", ap_bssid); __geofence_check_wifi_matched_bssid(state, ap_bssid, user_data); - } else if (state == WIFI_CONNECTION_STATE_DISCONNECTED) { + } else if (state == WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED) { LOGD_GEOFENCE("Wifi disconnected with [%s].", ap_bssid); __geofence_check_wifi_matched_bssid(state, ap_bssid, user_data); } diff --git a/geofence-server/src/geofence_server_wifi.h b/geofence-server/src/geofence_server_wifi.h index 3932ab7..3c390d8 100644 --- a/geofence-server/src/geofence_server_wifi.h +++ b/geofence-server/src/geofence_server_wifi.h @@ -54,7 +54,7 @@ gboolean geofence_get_enable_wifi_state(gpointer data); * @Param[in] user_data The user data * @see None. */ -void wifi_conn_state_changed(wifi_connection_state_e state, wifi_ap_h ap, void *user_data); +void wifi_conn_state_changed(wifi_manager_connection_state_e state, wifi_manager_ap_h ap, void *user_data); /** * @brief Wifi device status change @@ -62,7 +62,7 @@ void wifi_conn_state_changed(wifi_connection_state_e state, wifi_ap_h ap, void * * @Param[in] user_data The user data * @see None. */ -void wifi_device_state_changed(wifi_device_state_e state, void *user_data); +void wifi_device_state_changed(wifi_manager_device_state_e state, void *user_data); /** * @brief Wifi AP rssi level change @@ -70,5 +70,5 @@ void wifi_device_state_changed(wifi_device_state_e state, void *user_data); * @Param[in] user_data The user data * @see None. **/ -void wifi_rssi_level_changed(wifi_rssi_level_e rssi_level, void *user_data); +void wifi_rssi_level_changed(wifi_manager_rssi_level_e rssi_level, void *user_data); #endif /* GEOFENCE_MANAGER_WIFI_H_ */ diff --git a/geofence-server/src/server.c b/geofence-server/src/server.c index b114669..66dc4fc 100644 --- a/geofence-server/src/server.c +++ b/geofence-server/src/server.c @@ -58,7 +58,7 @@ #include "geofence_server_private.h" /* for bluetooth-geofence*/ #include -#include +#include #include #define TIZEN_ENGINEER_MODE @@ -162,7 +162,7 @@ static void __geofence_bt_adapter_device_discovery_state_changed_cb(int result, LOGD_GEOFENCE("exit"); } -static void __geofence_wifi_device_connection_state_changed_cb(wifi_connection_state_e state, wifi_ap_h ap, void *user_data) +static void __geofence_wifi_device_connection_state_changed_cb(wifi_manager_connection_state_e state, wifi_manager_ap_h ap, void *user_data) { LOGD_GEOFENCE("__geofence_wifi_device_connection_state_changed_cb()"); @@ -175,7 +175,7 @@ static void __geofence_wifi_device_connection_state_changed_cb(wifi_connection_s } } -static void __geofence_wifi_device_state_changed_cb(wifi_device_state_e state, void *user_data) +static void __geofence_wifi_device_state_changed_cb(wifi_manager_device_state_e state, void *user_data) { LOGD_GEOFENCE("__geofence_wifi_device_state_changed_cb()"); @@ -188,7 +188,7 @@ static void __geofence_wifi_device_state_changed_cb(wifi_device_state_e state, v } } -static void __geofence_wifi_rssi_level_changed_cb(wifi_rssi_level_e rssi_level, void *user_data) +static void __geofence_wifi_rssi_level_changed_cb(wifi_manager_rssi_level_e rssi_level, void *user_data) { LOGD_GEOFENCE("__geofence_wifi_rssi_level_changed_cb()"); GeofenceServer *geofence_server = (GeofenceServer *)user_data; @@ -269,9 +269,9 @@ int _geofence_initialize_geofence_server(GeofenceServer *geofence_server) if (BT_ERROR_NONE != ret) LOGE_GEOFENCE("Failed to set the callback for discovery"); - ret = wifi_initialize(); - if (WIFI_ERROR_NONE != ret) { - LOGD_GEOFENCE("wifi_initialize() failed(%d).", ret); + ret = wifi_manager_initialize(&(geofence_server->wifi_h)); + if (WIFI_MANAGER_ERROR_NONE != ret) { + LOGD_GEOFENCE("wifi_manager_initialize() failed(%d).", ret); return -1; } @@ -282,37 +282,40 @@ int _geofence_initialize_geofence_server(GeofenceServer *geofence_server) LOGD_GEOFENCE("net_register_client() succeeded"); } - ret = wifi_set_connection_state_changed_cb(__geofence_wifi_device_connection_state_changed_cb, geofence_server); - if (WIFI_ERROR_NONE != ret) { - LOGD_GEOFENCE("wifi_set_connection_state_changed_cb() failed(%d).", ret); - ret = wifi_deinitialize(); - if (ret != WIFI_ERROR_NONE) - LOGD_GEOFENCE("wifi_deinitialize() failed(%d).", ret); + ret = wifi_manager_set_connection_state_changed_cb(geofence_server->wifi_h, __geofence_wifi_device_connection_state_changed_cb, geofence_server); + if (WIFI_MANAGER_ERROR_NONE != ret) { + LOGD_GEOFENCE("wifi_manager_set_connection_state_changed_cb() failed(%d).", ret); + ret = wifi_manager_deinitialize(geofence_server->wifi_h); + if (ret != WIFI_MANAGER_ERROR_NONE) + LOGD_GEOFENCE("wifi_manager_deinitialize() failed(%d).", ret); + geofence_server->wifi_h = NULL; return -1; } else { - LOGD_GEOFENCE("wifi_set_connection_state_changed_cb() success.", ret); + LOGD_GEOFENCE("wifi_manager_set_connection_state_changed_cb() success.", ret); } - ret = wifi_set_device_state_changed_cb(__geofence_wifi_device_state_changed_cb, geofence_server); - if (WIFI_ERROR_NONE != ret) { - LOGD_GEOFENCE("wifi_set_device_state_changed_cb() failed(%d).", ret); - ret = wifi_deinitialize(); - if (ret != WIFI_ERROR_NONE) - LOGD_GEOFENCE("wifi_deinitialize() failed(%d).", ret); + ret = wifi_manager_set_device_state_changed_cb(geofence_server->wifi_h, __geofence_wifi_device_state_changed_cb, geofence_server); + if (WIFI_MANAGER_ERROR_NONE != ret) { + LOGD_GEOFENCE("wifi_manager_set_device_state_changed_cb() failed(%d).", ret); + ret = wifi_manager_deinitialize(geofence_server->wifi_h); + if (ret != WIFI_MANAGER_ERROR_NONE) + LOGD_GEOFENCE("wifi_manager_deinitialize() failed(%d).", ret); + geofence_server->wifi_h = NULL; return -1; } else { - LOGD_GEOFENCE("wifi_set_device_state_changed_cb() success.", ret); + LOGD_GEOFENCE("wifi_manager_set_device_state_changed_cb() success.", ret); } - ret = wifi_set_rssi_level_changed_cb(__geofence_wifi_rssi_level_changed_cb, geofence_server); - if (WIFI_ERROR_NONE != ret) { - LOGD_GEOFENCE("wifi_set_rssi_level_changed_cb() failed(%d).", ret); - ret = wifi_deinitialize(); - if (ret != WIFI_ERROR_NONE) - LOGD_GEOFENCE("wifi_deinitialize() failed(%d).", ret); + ret = wifi_manager_set_rssi_level_changed_cb(geofence_server->wifi_h, __geofence_wifi_rssi_level_changed_cb, geofence_server); + if (WIFI_MANAGER_ERROR_NONE != ret) { + LOGD_GEOFENCE("wifi_manager_set_rssi_level_changed_cb() failed(%d).", ret); + ret = wifi_manager_deinitialize(geofence_server->wifi_h); + if (ret != WIFI_MANAGER_ERROR_NONE) + LOGD_GEOFENCE("wifi_manager_deinitialize() failed(%d).", ret); + geofence_server->wifi_h = NULL; return -1; } else { - LOGD_GEOFENCE("wifi_set_rssi_level_changed_cb() success.", ret); + LOGD_GEOFENCE("wifi_manager_set_rssi_level_changed_cb() success.", ret); } /*Set the callback for location*/ @@ -334,7 +337,7 @@ int _geofence_initialize_geofence_server(GeofenceServer *geofence_server) return 0; } -int _geofence_deinitialize_geofence_server() +int _geofence_deinitialize_geofence_server(GeofenceServer *geofence_server) { /* to denit geofence engine staff...*/ @@ -357,15 +360,16 @@ int _geofence_deinitialize_geofence_server() LOGD_GEOFENCE("bt_deinitialize() success.\n"); /*unset the callbacks related to wifi*/ - if (wifi_unset_connection_state_changed_cb() != WIFI_ERROR_NONE) - LOGD_GEOFENCE("wifi_unset_connection_state_changed_cb() failed.\n"); + if (wifi_manager_unset_connection_state_changed_cb(geofence_server->wifi_h) != WIFI_MANAGER_ERROR_NONE) + LOGD_GEOFENCE("wifi_manager_unset_connection_state_changed_cb() failed.\n"); else - LOGD_GEOFENCE("wifi_unset_connection_state_changed_cb() success.\n"); + LOGD_GEOFENCE("wifi_manager_unset_connection_state_changed_cb() success.\n"); - if (wifi_deinitialize() != WIFI_ERROR_NONE) - LOGD_GEOFENCE("wifi_deinitialize() failed.\n"); + if (wifi_manager_deinitialize(geofence_server->wifi_h) != WIFI_MANAGER_ERROR_NONE) + LOGD_GEOFENCE("wifi_manager_deinitialize() failed.\n"); else - LOGD_GEOFENCE("wifi_deinitialize() success.\n"); + LOGD_GEOFENCE("wifi_manager_deinitialize() success.\n"); + geofence_server->wifi_h = NULL; if (location_manager_unset_setting_changed_cb(LOCATIONS_METHOD_GPS) != LOCATIONS_ERROR_NONE) LOGD_GEOFENCE("GPS unsetting failed\n"); diff --git a/geofence-server/src/server.h b/geofence-server/src/server.h index 154db89..8788c7a 100644 --- a/geofence-server/src/server.h +++ b/geofence-server/src/server.h @@ -25,7 +25,7 @@ #include "geofence_server.h" #include "geofence_server_private.h" #include -#include +#include typedef enum { GEOFENCE_STATE_AVAILABLE, @@ -47,7 +47,7 @@ int _geofence_initialize_geofence_server(GeofenceServer *geofence_server); * @retval 0 if success * @see none */ -int _geofence_deinitialize_geofence_server(); +int _geofence_deinitialize_geofence_server(GeofenceServer *geofence_server); /** * @brief Registers the update callbacks diff --git a/packaging/geofence-server.spec b/packaging/geofence-server.spec index ee27058..72309b8 100644 --- a/packaging/geofence-server.spec +++ b/packaging/geofence-server.spec @@ -1,6 +1,6 @@ Name: geofence-server Summary: Geofence Server for Tizen -Version: 0.4.5 +Version: 0.4.6 Release: 1 Group: Location/Service License: Apache-2.0 @@ -27,7 +27,7 @@ BuildRequires: pkgconfig(vconf-internal-keys) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(capi-appfw-app-manager) BuildRequires: pkgconfig(capi-location-manager) -BuildRequires: pkgconfig(capi-network-wifi) +BuildRequires: pkgconfig(capi-network-wifi-manager) BuildRequires: pkgconfig(capi-network-bluetooth) BuildRequires: pkgconfig(libcore-context-manager) BuildRequires: pkgconfig(capi-system-device)