X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fsignal-handler.c;h=81a657e3f259499727bbc763e9fed4b610ba4f9b;hb=c25daf55a3f87084d8816b469670404d6ee57549;hp=304234dc5e2736066bc580c1817d02d1c684ba6a;hpb=3f2db10886d26f848dc863eb3f5c29fce4b8b9af;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git diff --git a/src/signal-handler.c b/src/signal-handler.c index 304234d..81a657e 100755 --- a/src/signal-handler.c +++ b/src/signal-handler.c @@ -49,12 +49,17 @@ #define SIGNAL_TDLS_CONNECTED "TDLSConnected" #define SIGNAL_TDLS_DISCONNECTED "TDLSDisconnected" #define SIGNAL_TDLS_PEER_FOUND "TDLSPeerFound" + +#define SIGNAL_WPS_CONNECTED "WPSConnected" +#define SIGNAL_WPS_EVENT "Event" +#define SIGNAL_WPS_CREDENTIALS "Credentials" + #define CONNMAN_SIGNAL_SERVICES_CHANGED "ServicesChanged" #define CONNMAN_SIGNAL_PROPERTY_CHANGED "PropertyChanged" #define CONNMAN_SIGNAL_NAME_CHANGED "NameOwnerChanged" #define MAX_SIG_LEN 64 -#define TOTAL_CONN_SIGNALS 4 +#define TOTAL_CONN_SIGNALS 5 typedef enum { SIG_INTERFACE_REMOVED = 0, @@ -91,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 && strlen(old_ip) > 0) + vconf_set_str(VCONFKEY_NETWORK_IP, ""); + else + vconf_set_str(VCONFKEY_NETWORK_IP, value); + } + 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_IP6); + + 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 + vconf_set_str(VCONFKEY_NETWORK_IP6, value); + } + 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) @@ -303,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); @@ -524,7 +583,7 @@ static void _supplicant_session_overlapped(GDBusConnection *conn, { DBG("Driver session overlapped handling!"); ERR("WPS PBC SESSION OVERLAPPED"); -#if defined TIZEN_WEARABLE +#if defined TIZEN_WEARABLE return; #else netconfig_send_message_to_net_popup("WPS Error", @@ -536,8 +595,8 @@ static void _supplicant_tdls_connected(GDBusConnection *conn, const gchar *name, const gchar *path, const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data) { - ERR("Received TDLS Connected Signal"); - netconfig_wifi_tlds_connected_event(param); + DBG("Received TDLS Connected Signal"); + netconfig_wifi_tdls_connected_event(param); return; } @@ -546,8 +605,8 @@ static void _supplicant_tdls_disconnected(GDBusConnection *conn, const gchar *name, const gchar *path, const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data) { - ERR("Received TDLS Disconnected Signal"); - netconfig_wifi_tlds_disconnected_event(param); + DBG("Received TDLS Disconnected Signal"); + netconfig_wifi_tdls_disconnected_event(param); return; } @@ -556,7 +615,204 @@ static void _supplicant_tdls_peer_found(GDBusConnection *conn, const gchar *name, const gchar *path, const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data) { - ERR("Received TDLS Peer Found Signal"); + DBG("Received TDLS Peer Found Signal"); + netconfig_wifi_tdls_peer_found_event(param); + return; +} + +static void _supplicant_wifi_wps_connected(GVariant *param) +{ + gchar *key; + char ssid[32] = {0, }; + gchar *name; + GVariantIter *iter; + GVariant *variant; + int config_error = 0; + int error_indication = 0; + gsize ssid_len = 0; + + if (param == NULL) { + ERR("Param is NULL"); + return; + } + + g_variant_get(param, "(sa{sv})", &name, &iter); + INFO("wps Result: %s", name); + while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) { + INFO("wps Key is %s", key); + if (g_strcmp0(key, "SSID") == 0) { + const char *t_key = NULL; + t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar)); + INFO("wps ssid_len is %d ", ssid_len); + if (t_key == NULL) { + g_free(key); + g_variant_unref(variant); + ERR("WPS PBC Connection Failed"); + goto error; + } + if (ssid_len > 0 && ssid_len <= 32) { + memcpy(ssid, t_key, ssid_len); + } else { + memset(ssid, 0, sizeof(ssid)); + ssid_len = 0; + } + INFO("WPS PBC Connection completed with AP %s", ssid); + netconfig_wifi_notify_wps_completed(ssid, ssid_len); + } + } + + g_variant_iter_free(iter); + g_free(name); + return; + +error: + g_variant_iter_free(iter); + g_free(name); + error_indication = WPS_EI_OPERATION_FAILED; + config_error = WPS_CFG_NO_ERROR; + ERR("Error Occured! Notifying Fail Event"); + netconfig_wifi_notify_wps_fail_event(config_error, error_indication); + +} + +static void _supplicant_wifi_wps_event(GVariant *param) +{ + gchar *key; + gchar *name; + GVariantIter *iter; + GVariant *variant; + gint32 config_error = 0; + gint32 error_indication = 0; + + if (param == NULL) { + ERR("Param is NULL"); + return; + } + + g_variant_get(param, "(sa{sv})", &name, &iter); + INFO("Event Result: %s", name); + if (g_strcmp0(name, "failed") == 0) { + while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) { + if (key == NULL) + goto error; + INFO("Key is %s", key); + if (g_strcmp0(key, "config_error") == 0) { + config_error = g_variant_get_int32(variant); + ERR("Config Error %d", config_error); + } else if (g_strcmp0(key, "error_indication") == 0) { + error_indication = g_variant_get_int32(variant); + ERR("Error Indication %d", error_indication); + } + } + netconfig_wifi_notify_wps_fail_event(config_error, error_indication); + } + + g_variant_iter_free(iter); + g_free(name); + return; + +error: + g_variant_iter_free(iter); + g_free(name); + error_indication = WPS_EI_OPERATION_FAILED; + config_error = WPS_CFG_NO_ERROR; + ERR("Error Occured! Notifying Fail Event"); + netconfig_wifi_notify_wps_fail_event(config_error, error_indication); +} + +static void _supplicant_wifi_wps_credentials(GVariant *param) +{ + gchar *key; + char ssid[32]; + char wps_key[100]; + GVariantIter *iter; + GVariant *variant; + int config_error = 0; + int error_indication = 0; + gsize ssid_len = 0; + + if (param == NULL) { + ERR("Param is NULL"); + return; + } + + g_variant_get(param, "(a{sv})", &iter); + while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) { + if (key == NULL) + goto error; + INFO("wps Key is %s", key); + if (g_strcmp0(key, "Key") == 0) { + gsize key_len = 0; + const char *t_key = NULL; + key_len = g_variant_get_size(variant); + + INFO("wps password len %d ", key_len); + if (key_len > 0) { + t_key = g_variant_get_fixed_array(variant, &key_len, sizeof(guchar)); + if (!t_key) { + g_free(key); + g_variant_unref(variant); + goto error; + } + strncpy(wps_key, t_key, key_len); + wps_key[key_len] = '\0'; + INFO("WPS Key in process credentials %s", wps_key); + } else + SLOGI("WPS AP Security ->Open"); + } else if (g_strcmp0(key, "SSID") == 0) { + const char *t_key = NULL; + t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar)); + INFO("wps ssid_len is %d ", ssid_len); + if (!t_key) { + g_free(key); + g_variant_unref(variant); + goto error; + } + if (ssid_len > 0 && ssid_len <= 32) { + memcpy(ssid, t_key, ssid_len); + } else { + memset(ssid, 0, sizeof(ssid)); + ssid_len = 0; + } + INFO("SSID in process credentials %s", ssid); + } + } + + g_variant_iter_free(iter); + +#if 0 + /* + * Notify WPS Credentials only when requested through WPS PBC + * In case of WPS PIN connman will take care of notification + */ + if (netconfig_get_wps_field() == TRUE) +#endif + netconfig_wifi_notify_wps_credentials(ssid, ssid_len, wps_key); + return; + +error: + g_variant_iter_free(iter); + error_indication = WPS_EI_OPERATION_FAILED; + config_error = WPS_CFG_NO_ERROR; + ERR("Error Occured! Notifying Fail Event"); + netconfig_wifi_notify_wps_fail_event(config_error, error_indication); +} + +static void __netconfig_wps_signal_filter_handler(GDBusConnection *conn, + const gchar *name, const gchar *path, const gchar *interface, + const gchar *sig, GVariant *param, gpointer user_data) +{ + if (g_strcmp0(sig, SIGNAL_WPS_CREDENTIALS) == 0) { + INFO("Received wps CREDENTIALS Signal from Supplicant"); + _supplicant_wifi_wps_credentials(param); + } else if (g_strcmp0(sig, SIGNAL_WPS_EVENT) == 0) { + INFO("Received wps EVENT Signal from Supplicant"); + _supplicant_wifi_wps_event(param); + } else if (g_strcmp0(sig, SIGNAL_WPS_CONNECTED) == 0) { + INFO("Received WPSConnected Signal from Supplicant"); + _supplicant_wifi_wps_connected(param); + } + return; } @@ -636,6 +892,20 @@ void register_gdbus_signal(void) INFO("Successfully register connman DBus signal filters"); + conn_subscription_ids[4] = g_dbus_connection_signal_subscribe( + connection, + SUPPLICANT_SERVICE, + SUPPLICANT_INTERFACE ".Interface.WPS", + NULL, + NULL, + NULL, + G_DBUS_SIGNAL_FLAGS_NONE, + __netconfig_wps_signal_filter_handler, + NULL, + NULL); + + INFO("Successfully register Supplicant WPS DBus signal filters"); + for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) { /* * For SIG_INTERFACE_REMOVED INTERFACE_ADDED