From: Avichal Date: Mon, 27 May 2019 13:33:04 +0000 (+0530) Subject: Repalcing libnet-client API with connection CAPI X-Git-Tag: accepted/tizen/5.5/unified/20191031.024947^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_5.5_tv;p=platform%2Fcore%2Flocation%2Fgeofence-server.git Repalcing libnet-client API with connection CAPI Change-Id: I06a31652a7e64b66e1c7ee12915465e573c54e32 Signed-off-by: Avichal --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e226f5..88c85b2 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-manager libcore-context-manager capi-system-device libtzplatform-config") +SET(server_dp "${common_dp} vconf vconf-internal-keys capi-system-info gthread-2.0 gio-unix-2.0 sqlite3 db-util alarm-service deviced capi-network-connection 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 d8cff49..5cb8ea8 100644 --- a/geofence-server/src/geofence_server.c +++ b/geofence-server/src/geofence_server.c @@ -35,7 +35,6 @@ #include "geofence_server_internal.h" #include "geofence_server_bluetooth.h" #include -#include #include #define TIZEN_ENGINEER_MODE @@ -1014,7 +1013,7 @@ void bt_adapter_device_discovery_state_cb(int result, bt_adapter_device_discover #endif } -static void geofence_network_evt_cb(net_event_info_t *event_cb, void *user_data) +static void geofence_network_evt_cb(connection_type_e type, void* user_data) { FUNC_ENTRANCE_SERVER; GeofenceServer *geofence_server = (GeofenceServer *) user_data; @@ -1023,8 +1022,8 @@ static void geofence_network_evt_cb(net_event_info_t *event_cb, void *user_data) int wps_state = 0; int gps_state = 0; - switch (event_cb->Event) { - case NET_EVENT_WIFI_POWER_IND: + switch (type) { + case CONNECTION_TYPE_WIFI: LOGI_GEOFENCE("WIFI ON/OFF indication"); vconf_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED, &wps_state); vconf_get_int(VCONFKEY_LOCATION_ENABLED, &gps_state); @@ -1062,7 +1061,7 @@ static void geofence_network_evt_cb(net_event_info_t *event_cb, void *user_data) LOGE_GEOFENCE("WPS is not supported"); } break; - case NET_EVENT_OPEN_IND: + case CONNECTION_TYPE_CELLULAR: LOGI_GEOFENCE("Mobile internet connected"); vconf_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED, &wps_state); if (__is_support_wps() == true && geofence_server->running_geopoint_cnt > 0 && wps_state == 1 && __isWifiOn() == true && __isDataConnected() == true) { @@ -1076,7 +1075,7 @@ static void geofence_network_evt_cb(net_event_info_t *event_cb, void *user_data) LOGE_GEOFENCE("Fail to start wps positioning. Error[%d]", ret); } break; - case NET_EVENT_CLOSE_IND: + case CONNECTION_TYPE_DISCONNECTED: LOGI_GEOFENCE("Mobile internet disconnected"); if (__is_support_wps() == true && geofence_server->running_geopoint_cnt > 0 && geofence_server->loc_wps_started == true) { /***** Start standalone gps as mobile data is disconnected *****/ diff --git a/geofence-server/src/geofence_server.h b/geofence-server/src/geofence_server.h index 19a3044..7a6d811 100644 --- a/geofence-server/src/geofence_server.h +++ b/geofence-server/src/geofence_server.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include "geofence_server_data_types.h" #define PACKAGE_NAME "geofence-server" @@ -89,7 +89,7 @@ typedef void (*geofence_wifi_device_state_changed_cb)(wifi_manager_device_state_ * @Param[in] user_data The user data to be returned * @see None. */ -typedef void (*geofence_network_event_cb)(net_event_info_t *event_cb, void *user_data); +typedef void (*geofence_network_event_cb)(connection_type_e type, void* user_data); /** * @brief BT Discovery status change callback diff --git a/geofence-server/src/geofence_server_private.h b/geofence-server/src/geofence_server_private.h index e34b023..4b05c5b 100644 --- a/geofence-server/src/geofence_server_private.h +++ b/geofence-server/src/geofence_server_private.h @@ -25,7 +25,6 @@ #include #include #include -#include #include "geofence_server_data_types.h" #include "geofence_server.h" #include diff --git a/geofence-server/src/server.c b/geofence-server/src/server.c index b063be9..25ef479 100644 --- a/geofence-server/src/server.c +++ b/geofence-server/src/server.c @@ -46,10 +46,6 @@ #endif /* for scan AP #include */ -#include -#include -#include -#include /* for telephony*/ #if USE_TAPI #include @@ -71,6 +67,7 @@ #endif geofence_callbacks g_fence_update_cb; void *g_fence_user_data; +static connection_h g_connection ; #if USE_TAPI typedef struct { @@ -99,16 +96,16 @@ static void __deinitialize_geofence_data(void) } #endif -static void __geofence_network_evt_cb(net_event_info_t *event_cb, void *user_data) +static void __geofence_network_evt_cb(connection_type_e type, void* user_data) { GeofenceServer *geofence_server = (GeofenceServer *)user_data; g_return_if_fail(geofence_server); - LOGD_GEOFENCE("==CM Event callback==, Event[%d]", event_cb->Event); + LOGD_GEOFENCE("==CM Event callback==, Event[%d]", type); if (g_fence_update_cb.network_evt_cb) { LOGD_GEOFENCE("geofence_network_evt_cb"); - g_fence_update_cb.network_evt_cb(event_cb, user_data); + g_fence_update_cb.network_evt_cb(type, user_data); } } @@ -272,12 +269,14 @@ int _geofence_initialize_geofence_server(GeofenceServer *geofence_server) LOGE_GEOFENCE("wifi_manager_initialize() failed(%d).", ret); return -1; } - - if (net_register_client((net_event_cb_t) __geofence_network_evt_cb, geofence_server) != NET_ERR_NONE) { - LOGD_GEOFENCE("net_register_client() failed"); - return -1; - } else { - LOGD_GEOFENCE("net_register_client() succeeded"); + ret = connection_create(&g_connection); + if(ret == CONNECTION_ERROR_NONE) { + connection_set_type_changed_cb(g_connection, + __geofence_network_evt_cb,geofence_server); + LOGD_GEOFENCE("Create connection() succeeded"); + } + else { + LOGD_GEOFENCE("Create connection failed () failed"); } ret = wifi_manager_set_connection_state_changed_cb(geofence_server->wifi_h, __geofence_wifi_device_connection_state_changed_cb, geofence_server); @@ -373,6 +372,8 @@ int _geofence_deinitialize_geofence_server(GeofenceServer *geofence_server) LOGD_GEOFENCE("GPS unsetting failed\n"); else LOGD_GEOFENCE("GPS unsetting success\n"); + connection_unset_type_changed_cb(g_connection); + connection_destroy(g_connection); #if USE_TAPI __deinitialize_geofence_data(); #endif diff --git a/geofence-server/src/server.h b/geofence-server/src/server.h index 8788c7a..cce4fb2 100644 --- a/geofence-server/src/server.h +++ b/geofence-server/src/server.h @@ -24,6 +24,7 @@ #include "geofence_server.h" #include "geofence_server_private.h" +#include #include #include diff --git a/packaging/geofence-server.spec b/packaging/geofence-server.spec index be86dca..0167bbd 100644 --- a/packaging/geofence-server.spec +++ b/packaging/geofence-server.spec @@ -13,7 +13,6 @@ Requires(post): sqlite Requires(post): lbs-server BuildRequires: cmake BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(network) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(geofence-dbus) @@ -28,6 +27,7 @@ BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(capi-appfw-app-manager) BuildRequires: pkgconfig(capi-location-manager) BuildRequires: pkgconfig(capi-network-wifi-manager) +BuildRequires: pkgconfig(capi-network-connection) BuildRequires: pkgconfig(capi-network-bluetooth) BuildRequires: pkgconfig(libcore-context-manager) BuildRequires: pkgconfig(capi-system-device)