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.
23 #include <vconf-keys.h>
30 #include "wifi-agent.h"
31 #include "wifi-power.h"
32 #include "wifi-state.h"
33 #include "netsupplicant.h"
34 #include "network-state.h"
35 #include "cellular-state.h"
36 #include "signal-handler.h"
37 #include "wifi-ssid-scan.h"
38 #include "wifi-background-scan.h"
39 #include "wifi-tdls.h"
41 #define DBUS_SERVICE_DBUS "org.freedesktop.DBus"
42 #define DBUS_INTERFACE_DBUS "org.freedesktop.DBus"
43 #define SIGNAL_INTERFACE_REMOVED "InterfaceRemoved"
44 #define SIGNAL_SCAN_DONE "ScanDone"
45 #define SIGNAL_BSS_ADDED "BSSAdded"
46 #define SIGNAL_PROPERTIES_CHANGED "PropertiesChanged"
47 #define SIGNAL_PROPERTIES_DRIVER_HANGED "DriverHanged"
48 #define SIGNAL_PROPERTIES_SESSION_OVERLAPPED "SessionOverlapped"
49 #define SIGNAL_TDLS_CONNECTED "TDLSConnected"
50 #define SIGNAL_TDLS_DISCONNECTED "TDLSDisconnected"
51 #define SIGNAL_TDLS_PEER_FOUND "TDLSPeerFound"
53 #define SIGNAL_WPS_CONNECTED "WPSConnected"
54 #define SIGNAL_WPS_EVENT "Event"
55 #define SIGNAL_WPS_CREDENTIALS "Credentials"
57 #define CONNMAN_SIGNAL_SERVICES_CHANGED "ServicesChanged"
58 #define CONNMAN_SIGNAL_PROPERTY_CHANGED "PropertyChanged"
59 #define CONNMAN_SIGNAL_NAME_CHANGED "NameOwnerChanged"
61 #define MAX_SIG_LEN 64
62 #define TOTAL_CONN_SIGNALS 5
65 SIG_INTERFACE_REMOVED = 0,
66 SIG_PROPERTIES_CHANGED,
70 SIG_SESSION_OVERLAPPED,
72 SIG_TDLS_DISCONNECTED,
77 static int conn_subscription_ids[TOTAL_CONN_SIGNALS] = {0};
78 static const char supplicant_signals[SIG_MAX][MAX_SIG_LEN] = {
79 SIGNAL_INTERFACE_REMOVED,
80 SIGNAL_PROPERTIES_CHANGED,
83 SIGNAL_PROPERTIES_DRIVER_HANGED,
84 SIGNAL_PROPERTIES_SESSION_OVERLAPPED,
85 SIGNAL_TDLS_CONNECTED,
86 SIGNAL_TDLS_DISCONNECTED,
87 SIGNAL_TDLS_PEER_FOUND,
90 static int supp_subscription_ids[SIG_MAX] = {0};
92 typedef void (*supplicant_signal_cb)(GDBusConnection *conn,
93 const gchar *name, const gchar *path, const gchar *interface,
94 const gchar *sig, GVariant *param, gpointer user_data);
95 typedef void (*connman_signal_cb)(GDBusConnection *conn,
96 const gchar *name, const gchar *path, const gchar *interface,
97 const gchar *sig, GVariant *param, gpointer user_data);
99 static void __netconfig_extract_ipv4_signal_data(GVariant *dictionary, const gchar *profile)
102 const gchar *value = NULL;
103 GVariant *var = NULL;
106 g_variant_iter_init(&iter, dictionary);
107 while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) {
108 if (g_strcmp0(key, "Address") == 0) {
109 value = g_variant_get_string(var, NULL);
110 char *old_ip = vconf_get_str(VCONFKEY_NETWORK_IP);
112 DBG("Old IPv4.Address [%s] Received new IPv4.Address [%s]", old_ip, value);
113 if (g_strcmp0(old_ip, value) != 0) {
114 if (value == NULL && strlen(old_ip) > 0)
115 vconf_set_str(VCONFKEY_NETWORK_IP, "");
117 vconf_set_str(VCONFKEY_NETWORK_IP, value);
124 static void __netconfig_extract_ipv6_signal_data(GVariant *dictionary, const gchar *profile)
127 const gchar *value = NULL;
128 GVariant *var = NULL;
131 g_variant_iter_init(&iter, dictionary);
132 while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) {
133 if (g_strcmp0(key, "Address") == 0) {
134 value = g_variant_get_string(var, NULL);
135 char *old_ip6 = vconf_get_str(VCONFKEY_NETWORK_IP6);
137 DBG("Old IPv6.Address [%s] Received new IPv6.Address [%s]", old_ip6, value);
138 if (g_strcmp0(old_ip6, value) != 0) {
139 if (value == NULL && strlen(old_ip6) > 0)
140 vconf_set_str(VCONFKEY_NETWORK_IP6, "");
142 vconf_set_str(VCONFKEY_NETWORK_IP6, value);
149 static void _technology_signal_cb(GDBusConnection *conn,
150 const gchar *name, const gchar *path, const gchar *interface,
151 const gchar *sig, GVariant *param, gpointer user_data)
154 gboolean value = FALSE;
155 GVariant *var = NULL;
160 if (g_str_has_prefix(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == TRUE) {
161 g_variant_get(param, "(sv)", &key, &var);
162 if (g_strcmp0(key, "Powered") == 0) {
164 value = g_variant_get_boolean(var);
166 wifi_state_update_power_state(TRUE);
168 wifi_state_update_power_state(FALSE);
169 } else if (g_strcmp0(key, "Connected") == 0) {
170 /* Connection state */
171 value = g_variant_get_boolean(var);
173 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_CONNECTED);
175 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_POWERED);
176 } else if (g_strcmp0(key, "Tethering") == 0) {
177 /* Tethering state */
178 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_TETHERED);
183 g_variant_unref(var);
187 static void _service_signal_cb(GDBusConnection *conn,
188 const gchar *name, const gchar *path,
189 const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data)
191 gchar *sigvalue = NULL;
193 GVariant *variant = NULL, *var;
195 const gchar *value = NULL;
197 if (path == NULL || param == NULL)
200 g_variant_get(param, "(sv)", &sigvalue, &variant);
201 if (sigvalue == NULL)
204 if (g_strcmp0(sig, CONNMAN_SIGNAL_PROPERTY_CHANGED) != 0)
207 if (g_strcmp0(sigvalue, "State") == 0) {
208 g_variant_get(variant, "s", &property);
210 DBG("[%s] %s", property, path);
211 if (netconfig_is_wifi_profile(path) == TRUE) {
214 netconfig_vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
215 if (wifi_state == VCONFKEY_WIFI_OFF) {
220 if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
221 if (wifi_state >= VCONFKEY_WIFI_CONNECTED) {
226 netconfig_update_default_profile(path);
228 wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTED);
230 } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
231 if (netconfig_get_default_profile() == NULL ||
232 netconfig_is_wifi_profile(netconfig_get_default_profile())
234 if (g_strcmp0(property, "failure") == 0)
235 wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
237 wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
242 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
247 netconfig_update_default_profile(NULL);
249 if (g_strcmp0(property, "failure") == 0)
250 wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
252 wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
254 } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
255 if (netconfig_get_default_profile() == NULL ||
256 netconfig_is_wifi_profile(netconfig_get_default_profile()) != TRUE) {
257 if (g_strcmp0(property, "association") == 0)
258 wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
260 wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
265 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
270 netconfig_update_default_profile(NULL);
272 if (g_strcmp0(property, "association") == 0)
273 wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
275 wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
279 if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
280 if (netconfig_get_default_profile() == NULL) {
281 if (!netconfig_is_cellular_profile(path))
282 netconfig_update_default_profile(path);
284 if (netconfig_is_cellular_internet_profile(path))
285 netconfig_update_default_profile(path);
289 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
290 cellular_state_set_service_state(NETCONFIG_CELLULAR_ONLINE);
292 } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
293 if (netconfig_get_default_profile() == NULL) {
298 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
299 cellular_state_set_service_state(NETCONFIG_CELLULAR_IDLE);
301 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
306 netconfig_update_default_profile(NULL);
307 } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
308 if (netconfig_get_default_profile() == NULL) {
313 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
314 cellular_state_set_service_state(NETCONFIG_CELLULAR_CONNECTING);
316 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
321 netconfig_update_default_profile(NULL);
325 } else if (g_strcmp0(sigvalue, "Proxy") == 0) {
326 if (netconfig_is_wifi_profile(path) != TRUE || g_strcmp0(path, netconfig_get_default_profile()) != 0)
329 if (!g_variant_type_equal(variant, G_VARIANT_TYPE_ARRAY))
332 g_variant_get(variant, "a{sv}", &iter);
333 while (g_variant_iter_loop(iter, "{sv}", &property, &var)) {
334 if (g_strcmp0(property, "Servers") == 0) {
335 GVariantIter *iter_sub = NULL;
337 g_variant_get(var, "as", &iter_sub);
338 g_variant_iter_loop(iter_sub, "s", &value);
339 g_variant_iter_free(iter_sub);
341 DBG("Proxy - [%s]", value);
342 vconf_set_str(VCONFKEY_NETWORK_PROXY, value);
345 g_variant_unref(var);
347 } else if (g_strcmp0(property, "Method") == 0) {
348 value = g_variant_get_string(var, NULL);
349 DBG("Method - [%s]", value);
351 if (g_strcmp0(value, "direct") == 0)
352 vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
355 g_variant_unref(var);
360 g_variant_iter_free(iter);
361 } else if (g_strcmp0(sigvalue, "IPv4") == 0) {
362 __netconfig_extract_ipv4_signal_data(variant, path);
363 } else if (g_strcmp0(sigvalue, "IPv6") == 0) {
364 __netconfig_extract_ipv6_signal_data(variant, path);
365 } else if (g_strcmp0(sigvalue, "Error") == 0) {
366 g_variant_get(variant, "s", &property);
367 INFO("[%s] Property : %s", sigvalue, property);
375 g_variant_unref(variant);
380 static void _dbus_name_changed_cb(GDBusConnection *conn,
381 const gchar *Name, const gchar *path, const gchar *interface,
382 const gchar *sig, GVariant *param, gpointer user_data)
391 g_variant_get(param, "(sss)", &name, &old, &new);
393 if (g_strcmp0(name, CONNMAN_SERVICE) == 0 && *new == '\0') {
394 DBG("ConnMan destroyed: name %s, old %s, new %s", name, old, new);
396 connman_register_agent();
408 static void _services_changed_cb(GDBusConnection *conn, const gchar *name,
409 const gchar *path, const gchar *interface, const gchar *sig,
410 GVariant *param, gpointer user_data)
412 gchar *property, *value;
414 GVariant *variant = NULL;
415 GVariantIter *added = NULL, *removed = NULL, *next = NULL;
417 if (path == NULL || param == NULL)
420 if (g_strcmp0(sig, CONNMAN_SIGNAL_SERVICES_CHANGED) != 0)
423 if (netconfig_get_default_profile() != NULL)
426 g_variant_get(param, "(a(oa{sv})ao)", &added, &removed);
428 while (g_variant_iter_loop(added, "(oa{sv})", &service_path, &next)) {
429 gboolean is_wifi_prof, is_cell_prof, is_cell_internet_prof;
430 is_wifi_prof = netconfig_is_wifi_profile(service_path);
431 is_cell_prof = netconfig_is_cellular_profile(service_path);
432 is_cell_internet_prof = netconfig_is_cellular_internet_profile(
434 if (service_path != NULL) {
435 while (g_variant_iter_loop(next, "{sv}", &property,
437 if (g_strcmp0(property, "State") == 0) {
438 g_variant_get(variant, "s", &value);
439 DBG("Profile %s State %s", service_path,
441 if (g_strcmp0(value, "ready") != 0 &&
446 g_variant_unref(variant);
451 netconfig_update_default_profile(
453 else if (is_cell_internet_prof) {
454 netconfig_update_default_profile(
458 wifi_state_set_service_state(
459 NETCONFIG_WIFI_CONNECTED);
460 else if (is_cell_prof &&
461 is_cell_internet_prof)
462 cellular_state_set_service_state(
463 NETCONFIG_CELLULAR_ONLINE);
466 g_variant_unref(variant);
473 g_variant_iter_free(added);
476 g_variant_iter_free(next);
479 g_variant_iter_free(removed);
484 static void _supplicant_interface_removed(GDBusConnection *conn,
485 const gchar *name, const gchar *path, const gchar *interface,
486 const gchar *sig, GVariant *param, gpointer user_data)
488 DBG("Interface removed handling!");
489 if (netconfig_wifi_is_wps_enabled() == TRUE)
490 netconfig_wifi_wps_signal_scanaborted();
495 static void _supplicant_properties_changed(GDBusConnection *conn,
496 const gchar *name, const gchar *path, const gchar *interface,
497 const gchar *sig, GVariant *param, gpointer user_data)
499 DBG("Properties changed handling!");
503 gboolean scanning = FALSE;
508 g_variant_get(param, "(a{sv})", &iter);
509 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
510 if (g_strcmp0(key, "Scanning") == 0) {
511 scanning = g_variant_get_boolean(variant);
512 if (scanning == TRUE)
513 netconfig_wifi_set_scanning(TRUE);
515 g_variant_unref(variant);
521 g_variant_iter_free(iter);
526 static void _supplicant_bss_added(GDBusConnection *conn,
527 const gchar *name, const gchar *path, const gchar *interface,
528 const gchar *sig, GVariant *param, gpointer user_data)
530 DBG("BSS added handling!");
531 if (wifi_ssid_scan_get_state() == TRUE)
532 wifi_ssid_scan_add_bss(param);
534 wifi_state_set_bss_found(TRUE);
539 static void _supplicant_scan_done(GDBusConnection *conn,
540 const gchar *name, const gchar *path, const gchar *interface,
541 const gchar *sig, GVariant *param, gpointer user_data)
543 DBG("Scan Done handling!");
544 netconfig_wifi_set_scanning(FALSE);
546 if (netconfig_wifi_is_wps_enabled() == TRUE) {
547 netconfig_wifi_wps_signal_scandone();
548 if (wifi_state_get_technology_state() < NETCONFIG_WIFI_TECH_POWERED)
552 if (netconfig_wifi_get_bgscan_state() != TRUE) {
553 if (wifi_ssid_scan_get_state() == TRUE)
554 wifi_ssid_scan_emit_scan_completed();
556 wifi_ssid_scan(NULL);
558 if (wifi_state_get_technology_state() >=
559 NETCONFIG_WIFI_TECH_POWERED)
560 netconfig_wifi_bgscan_start(FALSE);
562 wifi_start_timer_network_notification();
568 static void _supplicant_driver_hanged(GDBusConnection *conn,
569 const gchar *name, const gchar *path, const gchar *interface,
570 const gchar *sig, GVariant *param, gpointer user_data)
572 DBG("Driver Hanged handling!");
573 ERR("Critical. Wi-Fi firmware crashed");
575 wifi_power_recover_firmware();
580 static void _supplicant_session_overlapped(GDBusConnection *conn,
581 const gchar *name, const gchar *path, const gchar *interface,
582 const gchar *sig, GVariant *param, gpointer user_data)
584 DBG("Driver session overlapped handling!");
585 ERR("WPS PBC SESSION OVERLAPPED");
586 #if defined TIZEN_WEARABLE
589 netconfig_send_message_to_net_popup("WPS Error",
590 "wps session overlapped", "popup", NULL);
594 static void _supplicant_tdls_connected(GDBusConnection *conn,
595 const gchar *name, const gchar *path, const gchar *interface,
596 const gchar *sig, GVariant *param, gpointer user_data)
598 DBG("Received TDLS Connected Signal");
599 netconfig_wifi_tdls_connected_event(param);
604 static void _supplicant_tdls_disconnected(GDBusConnection *conn,
605 const gchar *name, const gchar *path, const gchar *interface,
606 const gchar *sig, GVariant *param, gpointer user_data)
608 DBG("Received TDLS Disconnected Signal");
609 netconfig_wifi_tdls_disconnected_event(param);
614 static void _supplicant_tdls_peer_found(GDBusConnection *conn,
615 const gchar *name, const gchar *path, const gchar *interface,
616 const gchar *sig, GVariant *param, gpointer user_data)
618 DBG("Received TDLS Peer Found Signal");
619 netconfig_wifi_tdls_peer_found_event(param);
623 static void _supplicant_wifi_wps_connected(GVariant *param)
626 char ssid[32] = {0, };
630 int config_error = 0;
631 int error_indication = 0;
635 ERR("Param is NULL");
639 g_variant_get(param, "(sa{sv})", &name, &iter);
640 INFO("wps Result: %s", name);
641 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
642 INFO("wps Key is %s", key);
643 if (g_strcmp0(key, "SSID") == 0) {
644 const char *t_key = NULL;
645 t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar));
646 INFO("wps ssid_len is %d ", ssid_len);
649 g_variant_unref(variant);
650 ERR("WPS PBC Connection Failed");
653 if (ssid_len > 0 && ssid_len <= 32) {
654 memcpy(ssid, t_key, ssid_len);
656 memset(ssid, 0, sizeof(ssid));
659 INFO("WPS PBC Connection completed with AP %s", ssid);
660 netconfig_wifi_notify_wps_completed(ssid, ssid_len);
664 g_variant_iter_free(iter);
669 g_variant_iter_free(iter);
671 error_indication = WPS_EI_OPERATION_FAILED;
672 config_error = WPS_CFG_NO_ERROR;
673 ERR("Error Occured! Notifying Fail Event");
674 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
678 static void _supplicant_wifi_wps_event(GVariant *param)
684 gint32 config_error = 0;
685 gint32 error_indication = 0;
688 ERR("Param is NULL");
692 g_variant_get(param, "(sa{sv})", &name, &iter);
693 INFO("Event Result: %s", name);
694 if (g_strcmp0(name, "failed") == 0) {
695 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
698 INFO("Key is %s", key);
699 if (g_strcmp0(key, "config_error") == 0) {
700 config_error = g_variant_get_int32(variant);
701 ERR("Config Error %d", config_error);
702 } else if (g_strcmp0(key, "error_indication") == 0) {
703 error_indication = g_variant_get_int32(variant);
704 ERR("Error Indication %d", error_indication);
707 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
710 g_variant_iter_free(iter);
715 g_variant_iter_free(iter);
717 error_indication = WPS_EI_OPERATION_FAILED;
718 config_error = WPS_CFG_NO_ERROR;
719 ERR("Error Occured! Notifying Fail Event");
720 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
723 static void _supplicant_wifi_wps_credentials(GVariant *param)
730 int config_error = 0;
731 int error_indication = 0;
735 ERR("Param is NULL");
739 g_variant_get(param, "(a{sv})", &iter);
740 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
743 INFO("wps Key is %s", key);
744 if (g_strcmp0(key, "Key") == 0) {
746 const char *t_key = NULL;
747 key_len = g_variant_get_size(variant);
749 INFO("wps password len %d ", key_len);
751 t_key = g_variant_get_fixed_array(variant, &key_len, sizeof(guchar));
754 g_variant_unref(variant);
757 strncpy(wps_key, t_key, key_len);
758 wps_key[key_len] = '\0';
759 INFO("WPS Key in process credentials %s", wps_key);
761 SLOGI("WPS AP Security ->Open");
762 } else if (g_strcmp0(key, "SSID") == 0) {
763 const char *t_key = NULL;
764 t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar));
765 INFO("wps ssid_len is %d ", ssid_len);
768 g_variant_unref(variant);
771 if (ssid_len > 0 && ssid_len <= 32) {
772 memcpy(ssid, t_key, ssid_len);
774 memset(ssid, 0, sizeof(ssid));
777 INFO("SSID in process credentials %s", ssid);
781 g_variant_iter_free(iter);
785 * Notify WPS Credentials only when requested through WPS PBC
786 * In case of WPS PIN connman will take care of notification
788 if (netconfig_get_wps_field() == TRUE)
790 netconfig_wifi_notify_wps_credentials(ssid, ssid_len, wps_key);
794 g_variant_iter_free(iter);
795 error_indication = WPS_EI_OPERATION_FAILED;
796 config_error = WPS_CFG_NO_ERROR;
797 ERR("Error Occured! Notifying Fail Event");
798 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
801 static void __netconfig_wps_signal_filter_handler(GDBusConnection *conn,
802 const gchar *name, const gchar *path, const gchar *interface,
803 const gchar *sig, GVariant *param, gpointer user_data)
805 if (g_strcmp0(sig, SIGNAL_WPS_CREDENTIALS) == 0) {
806 INFO("Received wps CREDENTIALS Signal from Supplicant");
807 _supplicant_wifi_wps_credentials(param);
808 } else if (g_strcmp0(sig, SIGNAL_WPS_EVENT) == 0) {
809 INFO("Received wps EVENT Signal from Supplicant");
810 _supplicant_wifi_wps_event(param);
811 } else if (g_strcmp0(sig, SIGNAL_WPS_CONNECTED) == 0) {
812 INFO("Received WPSConnected Signal from Supplicant");
813 _supplicant_wifi_wps_connected(param);
819 static supplicant_signal_cb supplicant_cbs[SIG_MAX] = {
820 _supplicant_interface_removed,
821 _supplicant_properties_changed,
822 _supplicant_bss_added,
823 _supplicant_scan_done,
824 _supplicant_driver_hanged,
825 _supplicant_session_overlapped,
826 _supplicant_tdls_connected,
827 _supplicant_tdls_disconnected,
828 _supplicant_tdls_peer_found
831 void register_gdbus_signal(void)
833 GDBusConnection *connection = NULL;
834 const char *interface = NULL;
835 SuppSigArrayIndex sig;
836 connection = netdbus_get_connection();
838 if (connection == NULL) {
839 ERR("Failed to get GDbus Connection");
843 /* listening to messages from all objects as no path is specified */
844 /* see signals from the given interface */
845 conn_subscription_ids[0] = g_dbus_connection_signal_subscribe(
848 CONNMAN_TECHNOLOGY_INTERFACE,
852 G_DBUS_SIGNAL_FLAGS_NONE,
853 _technology_signal_cb,
857 conn_subscription_ids[1] = g_dbus_connection_signal_subscribe(
860 CONNMAN_SERVICE_INTERFACE,
861 CONNMAN_SIGNAL_PROPERTY_CHANGED,
864 G_DBUS_SIGNAL_FLAGS_NONE,
869 conn_subscription_ids[2] = g_dbus_connection_signal_subscribe(
873 CONNMAN_SIGNAL_NAME_CHANGED,
876 G_DBUS_SIGNAL_FLAGS_NONE,
877 _dbus_name_changed_cb,
881 conn_subscription_ids[3] = g_dbus_connection_signal_subscribe(
884 CONNMAN_MANAGER_INTERFACE,
885 CONNMAN_SIGNAL_SERVICES_CHANGED,
888 G_DBUS_SIGNAL_FLAGS_NONE,
889 _services_changed_cb,
893 INFO("Successfully register connman DBus signal filters");
895 conn_subscription_ids[4] = g_dbus_connection_signal_subscribe(
898 SUPPLICANT_INTERFACE ".Interface.WPS",
902 G_DBUS_SIGNAL_FLAGS_NONE,
903 __netconfig_wps_signal_filter_handler,
907 INFO("Successfully register Supplicant WPS DBus signal filters");
909 for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
911 * For SIG_INTERFACE_REMOVED INTERFACE_ADDED
913 interface = (sig == SIG_INTERFACE_REMOVED) ?
914 SUPPLICANT_INTERFACE : SUPPLICANT_IFACE_INTERFACE;
916 supp_subscription_ids[sig] = g_dbus_connection_signal_subscribe(
920 supplicant_signals[sig],
923 G_DBUS_SIGNAL_FLAGS_NONE,
929 INFO("Successfully register Supplicant DBus signal filters");
931 /* In case ConnMan precedes this signal register,
932 * net-config should update the default connected profile.
934 netconfig_update_default();
937 void deregister_gdbus_signal(void)
939 GDBusConnection *connection = NULL;
941 SuppSigArrayIndex sig;
942 connection = netdbus_get_connection();
944 ERR("Already de-registered. Nothing to be done");
948 for (signal = 0; signal < TOTAL_CONN_SIGNALS; signal++) {
949 if (conn_subscription_ids[signal]) {
950 g_dbus_connection_signal_unsubscribe(connection,
951 conn_subscription_ids[signal]);
955 for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
956 if (supp_subscription_ids[sig]) {
957 g_dbus_connection_signal_unsubscribe(connection,
958 supp_subscription_ids[sig]);