From 9fd7754967b851b8068a961467f9f500336bbd39 Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Wed, 29 Mar 2017 13:20:52 +0900 Subject: [PATCH] Fixed to get IPv6 address in address changed callback Change-Id: Ib6c9d6e1f9778d176b1006f5e4bc4e95ff474a34 Signed-off-by: Seonah Moon --- packaging/capi-network-connection.spec | 2 +- src/connection.c | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packaging/capi-network-connection.spec b/packaging/capi-network-connection.spec index 001bb57..73a55fa 100755 --- a/packaging/capi-network-connection.spec +++ b/packaging/capi-network-connection.spec @@ -1,6 +1,6 @@ Name: capi-network-connection Summary: Network Connection library in TIZEN C API -Version: 1.0.99 +Version: 1.0.100 Release: 1 Group: System/Network License: Apache-2.0 diff --git a/src/connection.c b/src/connection.c index 0cf5532..348a3a2 100755 --- a/src/connection.c +++ b/src/connection.c @@ -205,6 +205,7 @@ static void *__connection_get_ip_changed_userdata( 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; @@ -217,13 +218,19 @@ static gboolean __connection_cb_ip_changed_cb_idle(gpointer user_data) 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); - /* TODO: IPv6 should be supported */ + if (callback) - callback(ip_addr, NULL, data); + callback(ip_addr, ip6_addr, data); free(ip_addr); + free(ip6_addr); return FALSE; } @@ -254,9 +261,12 @@ static int __connection_set_ip_changed_callback(connection_h connection, local_handle = (connection_handle_s *)connection; if (callback) { - if (refcount == 0) + 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); + } refcount++; CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount); @@ -272,6 +282,14 @@ static int __connection_set_ip_changed_callback(connection_h connection, 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); + } } } } -- 2.7.4