Show notification in case of IP conflict using net-popup 91/161991/1
authorAbhishek Sansanwal <abhishek.s94@samsung.com>
Tue, 28 Nov 2017 11:09:07 +0000 (16:39 +0530)
committerAbhishek Sansanwal <abhishek.s94@samsung.com>
Tue, 28 Nov 2017 11:11:12 +0000 (16:41 +0530)
Signed-off-by: Abhishek Sansanwal <abhishek.s94@samsung.com>
Change-Id: I45962c2ff92c2c147e484f5b99919f5a6c281587

include/plugin.h
plugin/headed/headed.c
src/ip-conflict-detect.c
src/wifi-state.c

index e68db58..48cc2b7 100755 (executable)
@@ -34,6 +34,8 @@ extern "C" {
 #define NETCONFIG_DEL_FOUND_AP_NOTI            "del_found_ap_noti"
 #define NETCONFIG_ADD_PORTAL_NOTI              "add_portal_noti"
 #define NETCONFIG_DEL_PORTAL_NOTI              "del_portal_noti"
+#define NETCONFIG_ADD_IP_CONFLICT_NOTI         "add_ip_conflict_noti"
+#define NETCONFIG_DEL_IP_CONFLICT_NOTI         "del_ip_conflict_noti"
 
 struct wifi_authentication_data {
        int auth_result;
index 2550fc7..ce3a065 100755 (executable)
@@ -131,12 +131,13 @@ void headed_pop_device_picker(void)
 }
 
 
-gboolean headed_send_notification_to_net_popup(const char * noti, const char * ssid)
+gboolean headed_send_notification_to_net_popup(const char * noti, const char * message)
 {
        int ret = 0;
        bundle *b;
        static gboolean is_found_noti_exists = FALSE;
        static gboolean is_portal_noti_exists = FALSE;
+       static gboolean is_conflict_noti_exists = FALSE;
 
        if (noti == NULL) {
                ERR("Invalid notification");
@@ -163,14 +164,27 @@ gboolean headed_send_notification_to_net_popup(const char * noti, const char * s
                        return TRUE;
 
                is_portal_noti_exists = FALSE;
+       } else if (g_strcmp0(noti, NETCONFIG_DEL_IP_CONFLICT_NOTI) == 0) {
+               if (is_conflict_noti_exists == FALSE)
+                       return TRUE;
+
+               is_conflict_noti_exists = FALSE;
+       } else if (g_strcmp0(noti, NETCONFIG_ADD_IP_CONFLICT_NOTI) == 0) {
+               if (is_conflict_noti_exists == TRUE)
+                       return TRUE;
+
+               is_conflict_noti_exists = TRUE;
        }
 
        b = bundle_create();
        bundle_add(b, "_SYSPOPUP_TYPE_", noti);
 
-       if (ssid != NULL) {
-               DBG("ssid (%s)", ssid);
-               bundle_add(b, "_AP_NAME_", ssid);
+       if (message != NULL) {
+               DBG("message (%s)", message);
+               if (g_strcmp0(noti, NETCONFIG_ADD_IP_CONFLICT_NOTI) == 0)
+                       bundle_add(b, "_MAC_ADDRESS_", message);
+               else
+                       bundle_add(b, "_AP_NAME_", message);
        }
 
        ret = syspopup_launch("net-popup", b);
index 53c1dd1..7169398 100755 (executable)
@@ -38,6 +38,7 @@
 #include "network-state.h"
 #include "log.h"
 #include "neterror.h"
+#include "util.h"
 
 #define ARP_PACKET_SIZE 60
 #define MAX_SIZE_ERROR_BUFFER 256
@@ -407,6 +408,12 @@ static void __netconfig_wifi_notify_ip_conflict(char *state, char *mac)
        wifi_emit_ip_conflict_event((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
        g_variant_builder_unref(builder);
 
+       /* send notification using net-popup */
+       if (!strcmp(state, "conflict"))
+               netconfig_send_notification_to_net_popup(NETCONFIG_ADD_IP_CONFLICT_NOTI, mac);
+       else
+               netconfig_send_notification_to_net_popup(NETCONFIG_DEL_IP_CONFLICT_NOTI, mac);
+
        return;
 }
 
index 30c740f..c29ac9d 100755 (executable)
@@ -480,6 +480,7 @@ void wifi_state_update_power_state(gboolean powered)
                /* Inform net-popup to remove the wifi found notification */
                netconfig_send_notification_to_net_popup(NETCONFIG_DEL_FOUND_AP_NOTI, NULL);
                netconfig_send_notification_to_net_popup(NETCONFIG_DEL_PORTAL_NOTI, NULL);
+               netconfig_send_notification_to_net_popup(NETCONFIG_DEL_IP_CONFLICT_NOTI, NULL);
 
                _deregister_network_notification();
        }