From: Abhishek Sansanwal Date: Tue, 28 Nov 2017 11:09:07 +0000 (+0530) Subject: Show notification in case of IP conflict using net-popup X-Git-Tag: accepted/tizen/unified/20171204.072222~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dbb8aa4d3812fd8826b80cae5e7066ea51f67dc5;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git Show notification in case of IP conflict using net-popup Signed-off-by: Abhishek Sansanwal Change-Id: I45962c2ff92c2c147e484f5b99919f5a6c281587 --- diff --git a/include/plugin.h b/include/plugin.h index e68db58..48cc2b7 100755 --- a/include/plugin.h +++ b/include/plugin.h @@ -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; diff --git a/plugin/headed/headed.c b/plugin/headed/headed.c index 2550fc7..ce3a065 100755 --- a/plugin/headed/headed.c +++ b/plugin/headed/headed.c @@ -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); diff --git a/src/ip-conflict-detect.c b/src/ip-conflict-detect.c index 53c1dd1..7169398 100755 --- a/src/ip-conflict-detect.c +++ b/src/ip-conflict-detect.c @@ -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; } diff --git a/src/wifi-state.c b/src/wifi-state.c index 30c740f..c29ac9d 100755 --- a/src/wifi-state.c +++ b/src/wifi-state.c @@ -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(); }