return local_handle->type_changed_user_data;
}
-static gboolean __connection_cb_type_changed_cb_idle(gpointer user_data)
-{
- int state, status;
- void *data;
- connection_type_changed_cb callback;
- connection_handle_s *local_handle = (connection_handle_s *)user_data;
-
- if (__connection_check_handle_validity((connection_h)local_handle) != true)
- return FALSE;
-
- if (vconf_get_int(VCONFKEY_NETWORK_STATUS, &status) != 0)
- return FALSE;
-
- state = __connection_convert_net_state(status);
-
- callback = __connection_get_type_changed_callback(local_handle);
- data = __connection_get_type_changed_userdata(local_handle);
- if (callback)
- callback(state, data);
-
- return FALSE;
-}
-
-static void __connection_cb_type_change_cb(keynode_t *node, void *user_data)
+static void __connection_cb_type_change_cb(int type)
{
GSList *list;
connection_h handle;
+ void *data;
+ connection_type_changed_cb callback;
+ int state;
if (_connection_is_created() != true) {
CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
return;
}
+ state = __connection_convert_net_state(type);
+
for (list = conn_handle_list; list; list = list->next) {
handle = (connection_h)list->data;
- _connection_callback_add(__connection_cb_type_changed_cb_idle, (gpointer)handle);
+
+ callback = __connection_get_type_changed_callback(handle);
+ data = __connection_get_type_changed_userdata(handle);
+ if (callback)
+ callback(state, data);
}
}
if (callback) {
if (refcount == 0)
- vconf_notify_key_changed(VCONFKEY_NETWORK_STATUS,
- __connection_cb_type_change_cb, NULL);
+ _connection_libnet_set_type_changed_cb(
+ __connection_cb_type_change_cb);
refcount++;
- CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount);
+ CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)",
+ refcount);
} else {
if (refcount > 0 &&
__connection_get_type_changed_callback(local_handle) != NULL) {
if (--refcount == 0) {
- if (vconf_ignore_key_changed(VCONFKEY_NETWORK_STATUS,
- __connection_cb_type_change_cb) < 0) {
- CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
- "Error to de-register vconf callback(%d)", refcount);
- } else {
- CONNECTION_LOG(CONNECTION_INFO,
- "Successfully de-registered(%d)", refcount);
- }
+ _connection_libnet_set_type_changed_cb(NULL);
+ CONNECTION_LOG(CONNECTION_INFO,
+ "Successfully de-registered(%d)", refcount);
}
}
}
return local_handle->ip_changed_user_data;
}
-static gboolean __connection_cb_ip_changed_cb_idle(gpointer user_data)
-{
- char *ip_addr;
- char *ip6_addr;
- void *data;
- connection_address_changed_cb callback;
- connection_handle_s *local_handle = (connection_handle_s *)user_data;
-
- if (__connection_check_handle_validity((connection_h)local_handle) != true)
- return FALSE;
-
- ip_addr = vconf_get_str(VCONFKEY_NETWORK_IP);
- if (ip_addr == NULL)
- CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
- "vconf_get_str(VCONFKEY_NETWORK_IP) is Failed");
-
- ip6_addr = vconf_get_str(VCONFKEY_NETWORK_IP6);
- if (ip6_addr == NULL)
- CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
- "vconf_get_str(VCONFKEY_NETWORK_IP6) is Failed");
-
- callback = __connection_get_ip_changed_callback(local_handle);
- data = __connection_get_ip_changed_userdata(local_handle);
-
- if (callback)
- callback(ip_addr, ip6_addr, data);
-
- free(ip_addr);
- free(ip6_addr);
-
- return FALSE;
-}
-
-static void __connection_cb_ip_change_cb(keynode_t *node, void *user_data)
+static void __connection_cb_ip_change_cb(
+ connection_address_family_e addr_family, char *ip_addr)
{
GSList *list;
connection_h handle;
+ char *ip4_addr = NULL;
+ char *ip6_addr = NULL;
+ void *data;
+ connection_address_changed_cb callback;
if (_connection_is_created() != true) {
CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
return;
}
+ switch (addr_family) {
+ case CONNECTION_ADDRESS_FAMILY_IPV4:
+ ip4_addr = g_strdup(ip_addr);
+
+ ip6_addr = vconf_get_str(VCONFKEY_NETWORK_IP6);
+ if (ip6_addr == NULL)
+ CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
+ "vconf_get_str(VCONFKEY_NETWORK_IP6) failed");
+ break;
+ case CONNECTION_ADDRESS_FAMILY_IPV6:
+ ip6_addr = g_strdup(ip_addr);
+
+ ip4_addr = vconf_get_str(VCONFKEY_NETWORK_IP);
+ if (ip4_addr == NULL)
+ CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
+ "vconf_get_str(VCONFKEY_NETWORK_IP) failed");
+ break;
+ default:
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid Address Type");
+ return;
+ }
+
for (list = conn_handle_list; list; list = list->next) {
handle = (connection_h)list->data;
- _connection_callback_add(__connection_cb_ip_changed_cb_idle, (gpointer)handle);
+
+ callback = __connection_get_ip_changed_callback(handle);
+ data = __connection_get_ip_changed_userdata(handle);
+
+ if (callback)
+ callback(ip4_addr, ip6_addr, data);
}
+
+ g_free(ip4_addr);
+ g_free(ip6_addr);
}
static int __connection_set_ip_changed_callback(connection_h connection,
local_handle = (connection_handle_s *)connection;
if (callback) {
- if (refcount == 0) {
- vconf_notify_key_changed(VCONFKEY_NETWORK_IP,
- __connection_cb_ip_change_cb, NULL);
- vconf_notify_key_changed(VCONFKEY_NETWORK_IP6,
- __connection_cb_ip_change_cb, NULL);
- }
+ if (refcount == 0)
+ _connection_libnet_set_ip_changed_cb(
+ __connection_cb_ip_change_cb);
refcount++;
- CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount);
+ CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)",
+ refcount);
} else {
if (refcount > 0 &&
__connection_get_ip_changed_callback(local_handle) != NULL) {
if (--refcount == 0) {
- if (vconf_ignore_key_changed(VCONFKEY_NETWORK_IP,
- __connection_cb_ip_change_cb) < 0) {
- CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
- "Error to de-register vconf callback(%d)", refcount);
- } else {
- CONNECTION_LOG(CONNECTION_INFO,
- "Successfully de-registered(%d)", refcount);
- }
- if (vconf_ignore_key_changed(VCONFKEY_NETWORK_IP6,
- __connection_cb_ip_change_cb) < 0) {
- CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
- "Error to de-register vconf callback(%d)", refcount);
- } else {
- CONNECTION_LOG(CONNECTION_INFO,
- "Successfully de-registered(%d)", refcount);
- }
+ _connection_libnet_set_ip_changed_cb(NULL);
+ CONNECTION_LOG(CONNECTION_INFO,
+ "Successfully de-registered(%d)", refcount);
}
}
}
return local_handle->proxy_changed_user_data;
}
-static gboolean __connection_cb_proxy_changed_cb_idle(gpointer user_data)
-{
- char *proxy;
- void *data;
- connection_address_changed_cb callback;
- connection_handle_s *local_handle = (connection_handle_s *)user_data;
-
- if (__connection_check_handle_validity((connection_h)local_handle) != true)
- return FALSE;
-
- proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
- if (proxy == NULL)
- CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
- "vconf_get_str(VCONFKEY_NETWORK_PROXY) is Failed");
-
- callback = __connection_get_proxy_changed_callback(local_handle);
- data = __connection_get_proxy_changed_userdata(local_handle);
- /* TODO: IPv6 should be supported */
- if (callback)
- callback(proxy, NULL, data);
-
- free(proxy);
-
- return FALSE;
-}
-
-static void __connection_cb_proxy_change_cb(keynode_t *node, void *user_data)
+static void __connection_cb_proxy_change_cb(char *proxy_addr)
{
GSList *list;
connection_h handle;
+ void *data;
+ connection_address_changed_cb callback;
if (_connection_is_created() != true) {
CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
for (list = conn_handle_list; list; list = list->next) {
handle = (connection_h)list->data;
- _connection_callback_add(__connection_cb_proxy_changed_cb_idle, (gpointer)handle);
+
+ callback = __connection_get_proxy_changed_callback(handle);
+ data = __connection_get_proxy_changed_userdata(handle);
+ /* TODO: IPv6 should be supported */
+ if (callback)
+ callback(proxy_addr, NULL, data);
}
}
if (callback) {
if (refcount == 0)
- vconf_notify_key_changed(VCONFKEY_NETWORK_PROXY,
- __connection_cb_proxy_change_cb, NULL);
+ _connection_libnet_set_proxy_changed_cb(
+ __connection_cb_proxy_change_cb);
refcount++;
- CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount);
+ CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)",
+ refcount);
} else {
if (refcount > 0 &&
__connection_get_proxy_changed_callback(local_handle) != NULL) {
if (--refcount == 0) {
- if (vconf_ignore_key_changed(VCONFKEY_NETWORK_PROXY,
- __connection_cb_proxy_change_cb) < 0) {
- CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
- "Error to de-register vconf callback(%d)", refcount);
- } else {
- CONNECTION_LOG(CONNECTION_INFO,
- "Successfully de-registered(%d)", refcount);
- }
+ _connection_libnet_set_proxy_changed_cb(NULL);
+ CONNECTION_LOG(CONNECTION_INFO,
+ "Successfully de-registered(%d)", refcount);
}
}
}
connection_set_default_cb set_default_cb;
connection_reset_cb reset_profile_cb;
libnet_ethernet_cable_state_changed_cb ethernet_cable_state_changed_cb;
+ libnet_type_changed_cb type_changed_cb;
+ libnet_ip_changed_cb ip_changed_cb;
+ libnet_proxy_changed_cb proxy_changed_cb;
void *opened_user_data;
void *closed_user_data;
void *set_default_user_data;
};
static __thread struct _profile_list_s profile_iterator = {0, 0, NULL};
-static __thread struct _libnet_s libnet = {NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, false};
+static __thread struct _libnet_s libnet = {NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, false};
static __thread GSList *managed_idler_list = NULL;
static __thread bool connection_is_feature_checked[CONNECTION_SUPPORTED_FEATURE_MAX] = {0, };
static __thread bool connection_feature_supported[CONNECTION_SUPPORTED_FEATURE_MAX] = {0, };
libnet.ethernet_cable_state_changed_cb(state);
}
+static void __libnet_type_changed_cb(int type)
+{
+ if (libnet.type_changed_cb)
+ libnet.type_changed_cb(type);
+}
+
+static void __libnet_ip_changed_cb(connection_address_family_e addr_family,
+ char *ip_addr)
+{
+ if (libnet.ip_changed_cb)
+ libnet.ip_changed_cb(addr_family, ip_addr);
+}
+
+static void __libnet_proxy_changed_cb(char *proxy_addr)
+{
+ if (libnet.proxy_changed_cb)
+ libnet.proxy_changed_cb(proxy_addr);
+}
+
static gboolean __libnet_state_changed_cb_idle(gpointer data)
{
struct _state_notify *notify = (struct _state_notify *)data;
CONNECTION_LOG(CONNECTION_INFO, "Got Ethernet cable detached Indication\n");
__libnet_ethernet_cable_state_changed_cb(CONNECTION_ETHERNET_CABLE_DETACHED);
break;
+ case NET_EVENT_NETWORK_TYPE_CHANGED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got Network Type Changed Indication");
+ int *state = (int *) event_cb->Data;
+ __libnet_type_changed_cb(*state);
+ break;
+ case NET_EVENT_IPV4_ADDRESS_CHANGED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got IPv4 Address Changed Indication");
+ char *ipv4_addr = (char *)event_cb->Data;
+ __libnet_ip_changed_cb(CONNECTION_ADDRESS_FAMILY_IPV4, ipv4_addr);
+ break;
+ case NET_EVENT_IPV6_ADDRESS_CHANGED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got IPv6 Address Changed Indication");
+ char *ipv6_addr = (char *)event_cb->Data;
+ __libnet_ip_changed_cb(CONNECTION_ADDRESS_FAMILY_IPV6, ipv6_addr);
+ break;
+ case NET_EVENT_PROXY_ADDRESS_CHANGED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got Proxy Changed Indication");
+ char *proxy_addr = (char *)event_cb->Data;
+ __libnet_proxy_changed_cb(proxy_addr);
+ break;
default:
break;
return CONNECTION_ERROR_NONE;
}
+void _connection_libnet_set_type_changed_cb(libnet_type_changed_cb callback)
+{
+ libnet.type_changed_cb = callback;
+}
+
+void _connection_libnet_set_ip_changed_cb(libnet_ip_changed_cb callback)
+{
+ libnet.ip_changed_cb = callback;
+}
+
+void _connection_libnet_set_proxy_changed_cb(libnet_proxy_changed_cb callback)
+{
+ libnet.proxy_changed_cb = callback;
+}
+
//LCOV_EXCL_START
int _connection_libnet_get_ethernet_state(connection_ethernet_state_e *state)
{