static void __connection_cb_ip_change_cb(keynode_t *node, void *user_data);
static void __connection_cb_proxy_change_cb(keynode_t *node, void *user_data);
-static int __connection_convert_net_state(int status)
+static int __connection_convert_net_type(net_device_t net_type)
{
- switch (status) {
- case VCONFKEY_NETWORK_CELLULAR:
+ switch (net_type) {
+ case NET_DEVICE_CELLULAR:
return CONNECTION_TYPE_CELLULAR;
- case VCONFKEY_NETWORK_WIFI:
+ case NET_DEVICE_WIFI:
return CONNECTION_TYPE_WIFI;
- case VCONFKEY_NETWORK_ETHERNET:
+ case NET_DEVICE_ETHERNET:
return CONNECTION_TYPE_ETHERNET;
- case VCONFKEY_NETWORK_BLUETOOTH:
+ case NET_DEVICE_BLUETOOTH:
return CONNECTION_TYPE_BT;
default:
return CONNECTION_TYPE_DISCONNECTED;
connection_handle_s *local_handle = (connection_handle_s *)list->data;
if (local_handle->type_changed_callback)
local_handle->type_changed_callback(
- __connection_convert_net_state(state),
+ __connection_convert_net_type(state),
local_handle->state_changed_user_data);
}
}
EXPORT_API int connection_get_type(connection_h connection, connection_type_e* type)
{
- int status = 0;
+ net_device_t device_type;
if (type == NULL || !(__connection_check_handle_validity(connection))) {
CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- if (vconf_get_int(VCONFKEY_NETWORK_STATUS, &status)) {
- CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d\n", status);
- return CONNECTION_ERROR_OPERATION_FAILED;
- }
-
- CONNECTION_LOG(CONNECTION_INFO, "Connected Network = %d\n", status);
+ if (_connection_libnet_get_default_device_type(&device_type) ==
+ CONNECTION_ERROR_NO_CONNECTION)
+ *type = CONNECTION_TYPE_DISCONNECTED;
+ else
+ *type = __connection_convert_net_type(device_type);
- *type = __connection_convert_net_state(status);
+ CONNECTION_LOG(CONNECTION_INFO, "Connected Network = %d\n",
+ device_type);
return CONNECTION_ERROR_NONE;
}
return CONNECTION_ERROR_NONE;
}
+static int __libnet_get_default_service(
+ struct connman_service **default_service)
+{
+ GList *services_list;
+ struct connman_service *service;
+ net_state_type_t profile_state;
+
+ services_list = connman_get_services();
+ if (services_list == NULL)
+ return CONNECTION_ERROR_NO_CONNECTION;
+
+ service = (struct connman_service *)services_list->data;
+ profile_state = __libnet_service_state_string2type(
+ connman_service_get_state(service));
+
+ if ((profile_state == NET_STATE_TYPE_READY ||
+ profile_state == NET_STATE_TYPE_ONLINE)) {
+ *default_service = service;
+
+ return CONNECTION_ERROR_NONE;
+ }
+
+ return CONNECTION_ERROR_NO_CONNECTION;
+}
+
int __libnet_get_connected_count(struct _profile_list_s *profile_list)
{
int count = 0;
return service;
}
+
+int _connection_libnet_get_default_device_type(net_device_t *device_type)
+{
+ int rv;
+ struct connman_service *default_service;
+
+ rv = __libnet_get_default_service(&default_service);
+ if (rv == CONNECTION_ERROR_NO_CONNECTION)
+ return CONNECTION_ERROR_NO_CONNECTION;
+
+ *device_type = __libnet_service_type_string2type(
+ connman_service_get_type(default_service));
+
+ return CONNECTION_ERROR_NONE;
+}