2 * Network Configuration Module
4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
24 #include <vconf-keys.h>
31 #include "wifi-agent.h"
32 #include "wifi-power.h"
33 #include "wifi-state.h"
34 #include "netsupplicant.h"
35 #include "network-state.h"
36 #include "cellular-state.h"
37 #include "signal-handler.h"
38 #include "wifi-ssid-scan.h"
39 #include "wifi-background-scan.h"
40 #include "wifi-tdls.h"
42 #define DBUS_SERVICE_DBUS "org.freedesktop.DBus"
43 #define DBUS_INTERFACE_DBUS "org.freedesktop.DBus"
44 #define SIGNAL_INTERFACE_REMOVED "InterfaceRemoved"
45 #define SIGNAL_SCAN_DONE "ScanDone"
46 #define SIGNAL_BSS_ADDED "BSSAdded"
47 #define SIGNAL_PROPERTIES_CHANGED "PropertiesChanged"
48 #define SIGNAL_PROPERTIES_DRIVER_HANGED "DriverHanged"
49 #define SIGNAL_PROPERTIES_SESSION_OVERLAPPED "SessionOverlapped"
50 #define SIGNAL_TDLS_CONNECTED "TDLSConnected"
51 #define SIGNAL_TDLS_DISCONNECTED "TDLSDisconnected"
52 #define SIGNAL_TDLS_PEER_FOUND "TDLSPeerFound"
54 #define SIGNAL_WPS_CONNECTED "WPSConnected"
55 #define SIGNAL_WPS_EVENT "Event"
56 #define SIGNAL_WPS_CREDENTIALS "Credentials"
58 #define CONNMAN_SIGNAL_SERVICES_CHANGED "ServicesChanged"
59 #define CONNMAN_SIGNAL_PROPERTY_CHANGED "PropertyChanged"
60 #define CONNMAN_SIGNAL_NAME_CHANGED "NameOwnerChanged"
62 #define MAX_SIG_LEN 64
63 #define TOTAL_CONN_SIGNALS 5
66 SIG_INTERFACE_REMOVED = 0,
67 SIG_PROPERTIES_CHANGED,
71 SIG_SESSION_OVERLAPPED,
73 SIG_TDLS_DISCONNECTED,
78 static int conn_subscription_ids[TOTAL_CONN_SIGNALS] = {0};
79 static const char supplicant_signals[SIG_MAX][MAX_SIG_LEN] = {
80 SIGNAL_INTERFACE_REMOVED,
81 SIGNAL_PROPERTIES_CHANGED,
84 SIGNAL_PROPERTIES_DRIVER_HANGED,
85 SIGNAL_PROPERTIES_SESSION_OVERLAPPED,
86 SIGNAL_TDLS_CONNECTED,
87 SIGNAL_TDLS_DISCONNECTED,
88 SIGNAL_TDLS_PEER_FOUND,
91 static int supp_subscription_ids[SIG_MAX] = {0};
93 typedef void (*supplicant_signal_cb)(GDBusConnection *conn,
94 const gchar *name, const gchar *path, const gchar *interface,
95 const gchar *sig, GVariant *param, gpointer user_data);
96 typedef void (*connman_signal_cb)(GDBusConnection *conn,
97 const gchar *name, const gchar *path, const gchar *interface,
98 const gchar *sig, GVariant *param, gpointer user_data);
100 static void __netconfig_extract_ipv4_signal_data(GVariant *dictionary, const gchar *profile)
103 const gchar *value = NULL;
104 GVariant *var = NULL;
107 g_variant_iter_init(&iter, dictionary);
108 while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) {
109 if (g_strcmp0(key, "Address") == 0) {
110 g_variant_get(var, "&s", &value);
111 char *old_ip = vconf_get_str(VCONFKEY_NETWORK_IP);
113 DBG("Old IPv4.Address [%s] Received new IPv4.Address [%s]", old_ip, value);
114 if (g_strcmp0(old_ip, value) != 0) {
116 vconf_set_str(VCONFKEY_NETWORK_IP, value);
117 else if (old_ip != NULL && strlen(old_ip) > 0)
118 vconf_set_str(VCONFKEY_NETWORK_IP, "");
125 static void __netconfig_extract_ipv6_signal_data(GVariant *dictionary, const gchar *profile)
128 const gchar *value = NULL;
129 GVariant *var = NULL;
132 g_variant_iter_init(&iter, dictionary);
133 while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) {
134 if (g_strcmp0(key, "Address") == 0) {
135 g_variant_get(var, "&s", &value);
136 char *old_ip6 = vconf_get_str(VCONFKEY_NETWORK_IP6);
138 DBG("Old IPv6.Address [%s] Received new IPv6.Address [%s]", old_ip6, value);
139 if (g_strcmp0(old_ip6, value) != 0) {
141 vconf_set_str(VCONFKEY_NETWORK_IP6, value);
142 else if (old_ip6 != NULL && strlen(old_ip6) > 0)
143 vconf_set_str(VCONFKEY_NETWORK_IP6, "");
150 static void _technology_signal_cb(GDBusConnection *conn,
151 const gchar *name, const gchar *path, const gchar *interface,
152 const gchar *sig, GVariant *param, gpointer user_data)
155 gboolean value = FALSE;
156 GVariant *var = NULL;
161 if (g_str_has_prefix(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == TRUE) {
162 g_variant_get(param, "(sv)", &key, &var);
163 if (g_strcmp0(key, "Powered") == 0) {
165 value = g_variant_get_boolean(var);
167 wifi_state_update_power_state(TRUE);
169 wifi_state_update_power_state(FALSE);
170 } else if (g_strcmp0(key, "Connected") == 0) {
171 /* Connection state */
172 value = g_variant_get_boolean(var);
174 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_CONNECTED);
176 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_POWERED);
177 } else if (g_strcmp0(key, "Tethering") == 0) {
178 /* Tethering state */
179 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_TETHERED);
184 g_variant_unref(var);
188 static void _service_signal_cb(GDBusConnection *conn,
189 const gchar *name, const gchar *path,
190 const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data)
192 gchar *sigvalue = NULL;
194 GVariant *variant = NULL, *var;
196 const gchar *value = NULL;
198 if (path == NULL || param == NULL)
201 g_variant_get(param, "(sv)", &sigvalue, &variant);
202 if (sigvalue == NULL)
205 if (g_strcmp0(sig, CONNMAN_SIGNAL_PROPERTY_CHANGED) != 0)
208 if (g_strcmp0(sigvalue, "State") == 0) {
209 g_variant_get(variant, "s", &property);
211 DBG("[%s] %s", property, path);
212 if (netconfig_is_wifi_profile(path) == TRUE) {
215 netconfig_vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
216 if (wifi_state == VCONFKEY_WIFI_OFF) {
221 if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
222 if (wifi_state >= VCONFKEY_WIFI_CONNECTED) {
227 netconfig_update_default_profile(path);
229 wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTED);
231 } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
232 if (netconfig_get_default_profile() == NULL ||
233 netconfig_is_wifi_profile(netconfig_get_default_profile())
235 if (g_strcmp0(property, "failure") == 0)
236 wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
238 wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
243 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
248 netconfig_update_default_profile(NULL);
250 if (g_strcmp0(property, "failure") == 0)
251 wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
253 wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
255 } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
256 if (netconfig_get_default_profile() == NULL ||
257 netconfig_is_wifi_profile(netconfig_get_default_profile()) != TRUE) {
258 if (g_strcmp0(property, "association") == 0)
259 wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
261 wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
266 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
271 netconfig_update_default_profile(NULL);
273 if (g_strcmp0(property, "association") == 0)
274 wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
276 wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
280 if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
281 if (netconfig_get_default_profile() == NULL) {
282 if (!netconfig_is_cellular_profile(path))
283 netconfig_update_default_profile(path);
285 if (netconfig_is_cellular_internet_profile(path))
286 netconfig_update_default_profile(path);
290 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
291 cellular_state_set_service_state(NETCONFIG_CELLULAR_ONLINE);
293 } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
294 if (netconfig_get_default_profile() == NULL) {
299 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
300 cellular_state_set_service_state(NETCONFIG_CELLULAR_IDLE);
302 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
307 netconfig_update_default_profile(NULL);
308 } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
309 if (netconfig_get_default_profile() == NULL) {
314 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
315 cellular_state_set_service_state(NETCONFIG_CELLULAR_CONNECTING);
317 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
322 netconfig_update_default_profile(NULL);
326 } else if (g_strcmp0(sigvalue, "Proxy") == 0) {
327 if (netconfig_is_wifi_profile(path) != TRUE || g_strcmp0(path, netconfig_get_default_profile()) != 0)
330 if (!g_variant_type_equal(variant, G_VARIANT_TYPE_ARRAY))
333 g_variant_get(variant, "a{sv}", &iter);
334 while (g_variant_iter_loop(iter, "{sv}", &property, &var)) {
335 if (g_strcmp0(property, "Servers") == 0) {
336 GVariantIter *iter_sub = NULL;
338 g_variant_get(var, "as", &iter_sub);
339 g_variant_iter_loop(iter_sub, "s", &value);
340 g_variant_iter_free(iter_sub);
342 DBG("Proxy - [%s]", value);
343 vconf_set_str(VCONFKEY_NETWORK_PROXY, value);
346 g_variant_unref(var);
348 } else if (g_strcmp0(property, "Method") == 0) {
349 value = g_variant_get_string(var, NULL);
350 DBG("Method - [%s]", value);
352 if (g_strcmp0(value, "direct") == 0)
353 vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
356 g_variant_unref(var);
361 g_variant_iter_free(iter);
362 } else if (g_strcmp0(sigvalue, "IPv4") == 0) {
363 __netconfig_extract_ipv4_signal_data(variant, path);
364 } else if (g_strcmp0(sigvalue, "IPv6") == 0) {
365 __netconfig_extract_ipv6_signal_data(variant, path);
366 } else if (g_strcmp0(sigvalue, "Error") == 0) {
367 g_variant_get(variant, "s", &property);
368 INFO("[%s] Property : %s", sigvalue, property);
376 g_variant_unref(variant);
381 static void _dbus_name_changed_cb(GDBusConnection *conn,
382 const gchar *Name, const gchar *path, const gchar *interface,
383 const gchar *sig, GVariant *param, gpointer user_data)
392 g_variant_get(param, "(sss)", &name, &old, &new);
394 if (g_strcmp0(name, CONNMAN_SERVICE) == 0 && *new == '\0') {
395 DBG("ConnMan destroyed: name %s, old %s, new %s", name, old, new);
397 connman_register_agent();
409 static void _services_changed_cb(GDBusConnection *conn, const gchar *name,
410 const gchar *path, const gchar *interface, const gchar *sig,
411 GVariant *param, gpointer user_data)
413 gchar *property, *value;
415 GVariant *variant = NULL;
416 GVariantIter *added = NULL, *removed = NULL, *next = NULL;
418 if (path == NULL || param == NULL)
421 if (g_strcmp0(sig, CONNMAN_SIGNAL_SERVICES_CHANGED) != 0)
424 if (netconfig_get_default_profile() != NULL)
427 g_variant_get(param, "(a(oa{sv})ao)", &added, &removed);
429 while (g_variant_iter_loop(added, "(oa{sv})", &service_path, &next)) {
430 gboolean is_wifi_prof, is_cell_prof, is_cell_internet_prof;
431 is_wifi_prof = netconfig_is_wifi_profile(service_path);
432 is_cell_prof = netconfig_is_cellular_profile(service_path);
433 is_cell_internet_prof = netconfig_is_cellular_internet_profile(
435 if (service_path != NULL) {
436 while (g_variant_iter_loop(next, "{sv}", &property,
438 if (g_strcmp0(property, "State") == 0) {
439 g_variant_get(variant, "s", &value);
440 DBG("Profile %s State %s", service_path,
442 if (g_strcmp0(value, "ready") != 0 &&
447 g_variant_unref(variant);
452 netconfig_update_default_profile(
454 else if (is_cell_internet_prof) {
455 netconfig_update_default_profile(
459 wifi_state_set_service_state(
460 NETCONFIG_WIFI_CONNECTED);
461 else if (is_cell_prof &&
462 is_cell_internet_prof)
463 cellular_state_set_service_state(
464 NETCONFIG_CELLULAR_ONLINE);
467 g_variant_unref(variant);
474 g_variant_iter_free(added);
477 g_variant_iter_free(next);
480 g_variant_iter_free(removed);
485 static void _supplicant_interface_removed(GDBusConnection *conn,
486 const gchar *name, const gchar *path, const gchar *interface,
487 const gchar *sig, GVariant *param, gpointer user_data)
489 DBG("Interface removed handling!");
490 if (netconfig_wifi_is_wps_enabled() == TRUE)
491 netconfig_wifi_wps_signal_scanaborted();
496 static void _supplicant_properties_changed(GDBusConnection *conn,
497 const gchar *name, const gchar *path, const gchar *interface,
498 const gchar *sig, GVariant *param, gpointer user_data)
500 DBG("Properties changed handling!");
504 gboolean scanning = FALSE;
509 g_variant_get(param, "(a{sv})", &iter);
510 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
511 if (g_strcmp0(key, "Scanning") == 0) {
512 scanning = g_variant_get_boolean(variant);
513 DBG("setting scanning %s", scanning ? "TRUE" : "FALSE");
514 if (scanning == TRUE)
515 netconfig_wifi_set_scanning(TRUE);
517 netconfig_wifi_set_scanning(FALSE);
519 g_variant_unref(variant);
525 g_variant_iter_free(iter);
530 static void _supplicant_bss_added(GDBusConnection *conn,
531 const gchar *name, const gchar *path, const gchar *interface,
532 const gchar *sig, GVariant *param, gpointer user_data)
534 DBG("BSS added handling!");
535 if (wifi_ssid_scan_get_state() == TRUE)
536 wifi_ssid_scan_add_bss(param);
538 wifi_state_set_bss_found(TRUE);
543 static void _supplicant_scan_done(GDBusConnection *conn,
544 const gchar *name, const gchar *path, const gchar *interface,
545 const gchar *sig, GVariant *param, gpointer user_data)
547 DBG("Scan Done handling!");
548 netconfig_wifi_set_scanning(FALSE);
550 if (netconfig_wifi_is_wps_enabled() == TRUE) {
551 netconfig_wifi_wps_signal_scandone();
552 if (wifi_state_get_technology_state() < NETCONFIG_WIFI_TECH_POWERED)
556 if (netconfig_wifi_get_bgscan_state() != TRUE) {
557 if (wifi_ssid_scan_get_state() == TRUE)
558 wifi_ssid_scan_emit_scan_completed();
560 wifi_ssid_scan(NULL);
562 if (wifi_state_get_technology_state() >=
563 NETCONFIG_WIFI_TECH_POWERED)
564 netconfig_wifi_bgscan_start(FALSE);
566 wifi_start_timer_network_notification();
572 static void _supplicant_driver_hanged(GDBusConnection *conn,
573 const gchar *name, const gchar *path, const gchar *interface,
574 const gchar *sig, GVariant *param, gpointer user_data)
576 DBG("Driver Hanged handling!");
577 ERR("Critical. Wi-Fi firmware crashed");
579 wifi_power_recover_firmware();
584 static void _supplicant_session_overlapped(GDBusConnection *conn,
585 const gchar *name, const gchar *path, const gchar *interface,
586 const gchar *sig, GVariant *param, gpointer user_data)
588 DBG("Driver session overlapped handling!");
589 ERR("WPS PBC SESSION OVERLAPPED");
590 #if defined TIZEN_WEARABLE
593 netconfig_send_message_to_net_popup("WPS Error",
594 "wps session overlapped", "popup", NULL);
598 static void _supplicant_tdls_connected(GDBusConnection *conn,
599 const gchar *name, const gchar *path, const gchar *interface,
600 const gchar *sig, GVariant *param, gpointer user_data)
602 DBG("Received TDLS Connected Signal");
603 netconfig_wifi_tdls_connected_event(param);
608 static void _supplicant_tdls_disconnected(GDBusConnection *conn,
609 const gchar *name, const gchar *path, const gchar *interface,
610 const gchar *sig, GVariant *param, gpointer user_data)
612 DBG("Received TDLS Disconnected Signal");
613 netconfig_wifi_tdls_disconnected_event(param);
618 static void _supplicant_tdls_peer_found(GDBusConnection *conn,
619 const gchar *name, const gchar *path, const gchar *interface,
620 const gchar *sig, GVariant *param, gpointer user_data)
622 DBG("Received TDLS Peer Found Signal");
623 netconfig_wifi_tdls_peer_found_event(param);
627 static void _supplicant_wifi_wps_connected(GVariant *param)
630 char ssid[32] = {0, };
634 int config_error = 0;
635 int error_indication = 0;
639 ERR("Param is NULL");
643 g_variant_get(param, "(sa{sv})", &name, &iter);
644 INFO("wps Result: %s", name);
645 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
646 INFO("wps Key is %s", key);
647 if (g_strcmp0(key, "SSID") == 0) {
648 const char *t_key = NULL;
649 t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar));
650 INFO("wps ssid_len is %d ", ssid_len);
653 g_variant_unref(variant);
654 ERR("WPS PBC Connection Failed");
657 if (ssid_len > 0 && ssid_len <= 32) {
658 memcpy(ssid, t_key, ssid_len);
660 memset(ssid, 0, sizeof(ssid));
663 INFO("WPS PBC Connection completed with AP %s", ssid);
664 netconfig_wifi_notify_wps_completed(ssid, ssid_len);
668 g_variant_iter_free(iter);
673 g_variant_iter_free(iter);
675 error_indication = WPS_EI_OPERATION_FAILED;
676 config_error = WPS_CFG_NO_ERROR;
677 ERR("Error Occured! Notifying Fail Event");
678 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
682 static void _supplicant_wifi_wps_event(GVariant *param)
688 gint32 config_error = 0;
689 gint32 error_indication = 0;
692 ERR("Param is NULL");
696 g_variant_get(param, "(sa{sv})", &name, &iter);
697 INFO("Event Result: %s", name);
698 if (g_strcmp0(name, "fail") == 0) {
699 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
702 INFO("Key is %s", key);
703 if (g_strcmp0(key, "config_error") == 0) {
704 config_error = g_variant_get_int32(variant);
705 ERR("Config Error %d", config_error);
706 } else if (g_strcmp0(key, "error_indication") == 0) {
707 error_indication = g_variant_get_int32(variant);
708 ERR("Error Indication %d", error_indication);
711 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
714 g_variant_iter_free(iter);
719 g_variant_iter_free(iter);
721 error_indication = WPS_EI_OPERATION_FAILED;
722 config_error = WPS_CFG_NO_ERROR;
723 ERR("Error Occured! Notifying Fail Event");
724 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
727 static void _supplicant_wifi_wps_credentials(GVariant *param)
734 int config_error = 0;
735 int error_indication = 0;
739 ERR("Param is NULL");
743 g_variant_get(param, "(a{sv})", &iter);
744 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
747 INFO("wps Key is %s", key);
748 if (g_strcmp0(key, "Key") == 0) {
750 const char *t_key = NULL;
751 key_len = g_variant_get_size(variant);
753 INFO("wps password len %d ", key_len);
755 t_key = g_variant_get_fixed_array(variant, &key_len, sizeof(guchar));
758 g_variant_unref(variant);
761 strncpy(wps_key, t_key, key_len);
762 wps_key[key_len] = '\0';
763 INFO("WPS Key in process credentials %s", wps_key);
765 SLOGI("WPS AP Security ->Open");
766 } else if (g_strcmp0(key, "SSID") == 0) {
767 const char *t_key = NULL;
768 t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar));
769 INFO("wps ssid_len is %d ", ssid_len);
772 g_variant_unref(variant);
775 if (ssid_len > 0 && ssid_len <= 32) {
776 memcpy(ssid, t_key, ssid_len);
778 memset(ssid, 0, sizeof(ssid));
781 INFO("SSID in process credentials %s", ssid);
785 g_variant_iter_free(iter);
789 * Notify WPS Credentials only when requested through WPS PBC
790 * In case of WPS PIN connman will take care of notification
792 if (netconfig_get_wps_field() == TRUE)
794 netconfig_wifi_notify_wps_credentials(ssid, ssid_len, wps_key);
798 g_variant_iter_free(iter);
799 error_indication = WPS_EI_OPERATION_FAILED;
800 config_error = WPS_CFG_NO_ERROR;
801 ERR("Error Occured! Notifying Fail Event");
802 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
805 static void __netconfig_wps_signal_filter_handler(GDBusConnection *conn,
806 const gchar *name, const gchar *path, const gchar *interface,
807 const gchar *sig, GVariant *param, gpointer user_data)
809 if (g_strcmp0(sig, SIGNAL_WPS_CREDENTIALS) == 0) {
810 INFO("Received wps CREDENTIALS Signal from Supplicant");
811 _supplicant_wifi_wps_credentials(param);
812 } else if (g_strcmp0(sig, SIGNAL_WPS_EVENT) == 0) {
813 INFO("Received wps EVENT Signal from Supplicant");
814 _supplicant_wifi_wps_event(param);
815 } else if (g_strcmp0(sig, SIGNAL_WPS_CONNECTED) == 0) {
816 INFO("Received WPSConnected Signal from Supplicant");
817 _supplicant_wifi_wps_connected(param);
823 static supplicant_signal_cb supplicant_cbs[SIG_MAX] = {
824 _supplicant_interface_removed,
825 _supplicant_properties_changed,
826 _supplicant_bss_added,
827 _supplicant_scan_done,
828 _supplicant_driver_hanged,
829 _supplicant_session_overlapped,
830 _supplicant_tdls_connected,
831 _supplicant_tdls_disconnected,
832 _supplicant_tdls_peer_found
835 void register_gdbus_signal(void)
837 GDBusConnection *connection = NULL;
838 const char *interface = NULL;
839 SuppSigArrayIndex sig;
840 connection = netdbus_get_connection();
842 if (connection == NULL) {
843 ERR("Failed to get GDbus Connection");
847 /* listening to messages from all objects as no path is specified */
848 /* see signals from the given interface */
849 conn_subscription_ids[0] = g_dbus_connection_signal_subscribe(
852 CONNMAN_TECHNOLOGY_INTERFACE,
856 G_DBUS_SIGNAL_FLAGS_NONE,
857 _technology_signal_cb,
861 conn_subscription_ids[1] = g_dbus_connection_signal_subscribe(
864 CONNMAN_SERVICE_INTERFACE,
865 CONNMAN_SIGNAL_PROPERTY_CHANGED,
868 G_DBUS_SIGNAL_FLAGS_NONE,
873 conn_subscription_ids[2] = g_dbus_connection_signal_subscribe(
877 CONNMAN_SIGNAL_NAME_CHANGED,
880 G_DBUS_SIGNAL_FLAGS_NONE,
881 _dbus_name_changed_cb,
885 conn_subscription_ids[3] = g_dbus_connection_signal_subscribe(
888 CONNMAN_MANAGER_INTERFACE,
889 CONNMAN_SIGNAL_SERVICES_CHANGED,
892 G_DBUS_SIGNAL_FLAGS_NONE,
893 _services_changed_cb,
897 INFO("Successfully register connman DBus signal filters");
899 conn_subscription_ids[4] = g_dbus_connection_signal_subscribe(
902 SUPPLICANT_INTERFACE ".Interface.WPS",
906 G_DBUS_SIGNAL_FLAGS_NONE,
907 __netconfig_wps_signal_filter_handler,
911 INFO("Successfully register Supplicant WPS DBus signal filters");
913 for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
915 * For SIG_INTERFACE_REMOVED INTERFACE_ADDED
917 interface = (sig == SIG_INTERFACE_REMOVED) ?
918 SUPPLICANT_INTERFACE : SUPPLICANT_IFACE_INTERFACE;
920 supp_subscription_ids[sig] = g_dbus_connection_signal_subscribe(
924 supplicant_signals[sig],
927 G_DBUS_SIGNAL_FLAGS_NONE,
933 INFO("Successfully register Supplicant DBus signal filters");
935 /* In case ConnMan precedes this signal register,
936 * net-config should update the default connected profile.
938 netconfig_update_default();
941 void deregister_gdbus_signal(void)
943 GDBusConnection *connection = NULL;
945 SuppSigArrayIndex sig;
946 connection = netdbus_get_connection();
948 ERR("Already de-registered. Nothing to be done");
952 for (signal = 0; signal < TOTAL_CONN_SIGNALS; signal++) {
953 if (conn_subscription_ids[signal]) {
954 g_dbus_connection_signal_unsubscribe(connection,
955 conn_subscription_ids[signal]);
959 for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
960 if (supp_subscription_ids[sig]) {
961 g_dbus_connection_signal_unsubscribe(connection,
962 supp_subscription_ids[sig]);