net-config: Fix WPS sync-up issue with wpa_supplicant
[platform/core/connectivity/net-config.git] / src / signal-handler.c
index f06136a..9190dfc 100755 (executable)
@@ -18,6 +18,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <vconf.h>
 #include <vconf-keys.h>
@@ -111,12 +112,12 @@ static void __netconfig_extract_ipv4_signal_data(GVariant *dictionary, const gch
 
                        DBG("Old IPv4.Address [%s] Received new IPv4.Address [%s]", old_ip, value);
                        if (g_strcmp0(old_ip, value) != 0) {
-                               if (value == NULL && strlen(old_ip) > 0)
-                                       vconf_set_str(VCONFKEY_NETWORK_IP, "");
-                               else
+                               if (value != NULL)
                                        vconf_set_str(VCONFKEY_NETWORK_IP, value);
+                               else if (old_ip != NULL && strlen(old_ip) > 0)
+                                       vconf_set_str(VCONFKEY_NETWORK_IP, "");
                        }
-                       g_free(old_ip);
+                       free(old_ip);
                }
        }
 }
@@ -136,12 +137,12 @@ static void __netconfig_extract_ipv6_signal_data(GVariant *dictionary, const gch
 
                        DBG("Old IPv6.Address [%s] Received new IPv6.Address [%s]", old_ip6, value);
                        if (g_strcmp0(old_ip6, value) != 0) {
-                               if (value == NULL && strlen(old_ip6) > 0)
-                                       vconf_set_str(VCONFKEY_NETWORK_IP6, "");
-                               else
+                               if (value != NULL)
                                        vconf_set_str(VCONFKEY_NETWORK_IP6, value);
+                               else if (old_ip6 != NULL && strlen(old_ip6) > 0)
+                                       vconf_set_str(VCONFKEY_NETWORK_IP6, "");
                        }
-                       g_free(old_ip6);
+                       free(old_ip6);
                }
        }
 }
@@ -691,7 +692,7 @@ static void _supplicant_wifi_wps_event(GVariant *param)
 
        g_variant_get(param, "(sa{sv})", &name, &iter);
        INFO("Event Result: %s", name);
-       if (g_strcmp0(name, "failed") == 0) {
+       if (g_strcmp0(name, "fail") == 0) {
                while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
                        if (key == NULL)
                                goto error;