From: Saurav Babu Date: Wed, 13 Jan 2016 12:03:02 +0000 (+0530) Subject: [net-config] Add support of connman's ServicesChanged signal X-Git-Tag: submit/tizen/20160211.015108~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1271e68456599cf93009ad539ddfada9e66c6b10;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git [net-config] Add support of connman's ServicesChanged signal Connman doesn't notify PropertyChanged signal if Property chage occurs within 100ms, instead it notifies all the Properties Changed in one signal ServicesChanged. Due to this functionality in connman if ethernet cable was plugged out and then plugged back in then ready state of connman was not sent to net-config as sometimes connman state from configuration to ready is changed in around 50ms. This patch adds support of Connman's ServicesChanged signal in net-config. net-config updates default connection info on receiving ServicesChanged signal if there are no default connection available in net-config at that time. Change-Id: I8bfa03149c7db7ca1b8c0a7f3394b77b68b8b4fe Signed-off-by: Saurav Babu --- diff --git a/src/signal-handler.c b/src/signal-handler.c index b0d7c1b..fee6d0a 100755 --- a/src/signal-handler.c +++ b/src/signal-handler.c @@ -58,7 +58,7 @@ #define CONNMAN_SIGNAL_NAME_CHANGED "NameOwnerChanged" #define MAX_SIG_LEN 64 -#define TOTAL_CONN_SIGNALS 3 +#define TOTAL_CONN_SIGNALS 4 typedef enum { SIG_INTERFACE_REMOVED = 0, @@ -330,6 +330,77 @@ static void _dbus_name_changed_cb(GDBusConnection *conn, return; } +static void _services_changed_cb(GDBusConnection *conn, const gchar *name, + const gchar *path, const gchar *interface, const gchar *sig, + GVariant *param, gpointer user_data) +{ + gchar *property, *value; + gchar *service_path; + GVariant *variant = NULL; + GVariantIter *added = NULL, *removed = NULL, *next = NULL; + + if (path == NULL || param == NULL) + return; + + if (g_strcmp0(sig, CONNMAN_SIGNAL_SERVICES_CHANGED) != 0) + return; + + if (netconfig_get_default_profile() != NULL) + return; + + g_variant_get(param, "(a(oa{sv})ao)", &added, &removed); + + while (g_variant_iter_loop(added, "(oa{sv})", &service_path, &next)) { + gboolean is_wifi_prof, is_cell_prof, is_cell_internet_prof; + is_wifi_prof = netconfig_is_wifi_profile(service_path); + is_cell_prof = netconfig_is_cellular_profile(service_path); + is_cell_internet_prof = netconfig_is_cellular_internet_profile( + service_path); + if (service_path != NULL) { + while (g_variant_iter_loop(next, "{sv}", &property, + &variant)) { + if (g_strcmp0(property, "State") == 0) { + g_variant_get(variant, "s", &value); + DBG("Profile %s State %s", service_path, + value); + if (g_strcmp0(value, "ready") != 0 && + g_strcmp0(value, + "online") != 0) { + g_free(property); + g_variant_unref(variant); + break; + } + + if(!is_cell_prof) + netconfig_update_default_profile( + service_path); + else if (is_cell_internet_prof) { + netconfig_update_default_profile( + service_path); + } + if (is_wifi_prof) + wifi_state_set_service_state( + NETCONFIG_WIFI_CONNECTED); + else if (is_cell_prof && + is_cell_internet_prof) + cellular_state_set_service_state( + NETCONFIG_CELLULAR_ONLINE); + g_free(property); + g_variant_unref(variant); + break; + } + } + } + } + if (next) + g_variant_iter_free(next); + if (added) + g_variant_iter_free(added); + if (removed) + g_variant_iter_free(removed); + return; +} + static void _supplicant_interface_removed(GDBusConnection *conn, const gchar *name, const gchar *path, const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data) @@ -551,6 +622,18 @@ void register_gdbus_signal(void) NULL, NULL); + conn_subscription_ids[3] = g_dbus_connection_signal_subscribe( + connection, + CONNMAN_SERVICE, + CONNMAN_MANAGER_INTERFACE, + CONNMAN_SIGNAL_SERVICES_CHANGED, + NULL, + NULL, + G_DBUS_SIGNAL_FLAGS_NONE, + _services_changed_cb, + NULL, + NULL); + INFO("Successfully register connman DBus signal filters"); for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {