Add IPv4/IPv6 signal to update IP address 46/118546/3 accepted/tizen/common/20170314.172902 accepted/tizen/ivi/20170314.075037 accepted/tizen/mobile/20170314.075012 accepted/tizen/tv/20170314.075025 accepted/tizen/unified/20170314.075048 accepted/tizen/wearable/20170314.075031 submit/tizen/20170314.005318
authorSeonah Moon <seonah1.moon@samsung.com>
Mon, 13 Mar 2017 06:38:21 +0000 (15:38 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Mon, 13 Mar 2017 06:50:40 +0000 (15:50 +0900)
Change-Id: I1d26635ec5fc1b166e2eebf40fe65972e15558fa
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
packaging/net-config.spec
src/signal-handler.c

index 00717c1..629915c 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          net-config
 Summary:       TIZEN Network Configuration service
-Version:       1.1.102
+Version:       1.1.103
 Release:       2
 Group:         System/Network
 License:       Apache-2.0
index 9f02dc7..a7a132f 100755 (executable)
@@ -96,6 +96,56 @@ typedef void (*connman_signal_cb)(GDBusConnection *conn,
                const gchar *name, const gchar *path, const gchar *interface,
                const gchar *sig, GVariant *param, gpointer user_data);
 
+static void __netconfig_extract_ipv4_signal_data(GVariant *dictionary, const gchar *profile)
+{
+       gchar *key = NULL;
+       const gchar *value = NULL;
+       GVariant *var = NULL;
+       GVariantIter iter;
+
+       g_variant_iter_init(&iter, dictionary);
+       while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) {
+               if (g_strcmp0(key, "Address") == 0)  {
+                       value = g_variant_get_string(var, NULL);
+                       char *old_ip = vconf_get_str(VCONFKEY_NETWORK_IP);
+
+                       DBG("Old IPv4.Address [%s] Received new IPv4.Address [%s]", old_ip, value);
+                       if (g_strcmp0(old_ip, value) != 0) {
+                               if (value == NULL)
+                                       vconf_set_str(VCONFKEY_NETWORK_IP, "");
+                               else
+                                       vconf_set_str(VCONFKEY_NETWORK_IP, value);
+                       }
+                       g_free(old_ip);
+               }
+       }
+}
+
+static void __netconfig_extract_ipv6_signal_data(GVariant *dictionary, const gchar *profile)
+{
+       gchar *key = NULL;
+       const gchar *value = NULL;
+       GVariant *var = NULL;
+       GVariantIter iter;
+
+       g_variant_iter_init(&iter, dictionary);
+       while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) {
+               if (g_strcmp0(key, "Address") == 0)  {
+                       value = g_variant_get_string(var, NULL);
+                       char *old_ip6 = vconf_get_str(VCONFKEY_NETWORK_IP);
+
+                       DBG("Old IPv6.Address [%s] Received new IPv6.Address [%s]", old_ip6, value);
+                       if (g_strcmp0(old_ip6, value) != 0) {
+                               if (value == NULL)
+                                       vconf_set_str(VCONFKEY_NETWORK_IP6, "");
+                               else
+                                       vconf_set_str(VCONFKEY_NETWORK_IP6, value);
+                       }
+                       g_free(old_ip6);
+               }
+       }
+}
+
 static void _technology_signal_cb(GDBusConnection *conn,
                const gchar *name, const gchar *path, const gchar *interface,
                const gchar *sig, GVariant *param, gpointer user_data)
@@ -308,6 +358,10 @@ static void _service_signal_cb(GDBusConnection *conn,
                }
 
                g_variant_iter_free(iter);
+       } else if (g_strcmp0(sigvalue, "IPv4") == 0) {
+               __netconfig_extract_ipv4_signal_data(variant, path);
+       } else if (g_strcmp0(sigvalue, "IPv6") == 0) {
+               __netconfig_extract_ipv6_signal_data(variant, path);
        } else if (g_strcmp0(sigvalue, "Error") == 0) {
                g_variant_get(variant, "s", &property);
                INFO("[%s] Property : %s", sigvalue, property);