Merge "Modified to get security info for ssid scan" into tizen_3.0
[platform/core/connectivity/net-config.git] / src / signal-handler.c
1 /*
2  * Network Configuration Module
3  *
4  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  */
19
20 #include <stdio.h>
21 #include <string.h>
22 #include <vconf.h>
23 #include <vconf-keys.h>
24
25 #include "log.h"
26 #include "util.h"
27 #include "netdbus.h"
28 #include "neterror.h"
29 #include "wifi-wps.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"
40
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"
52 #define CONNMAN_SIGNAL_SERVICES_CHANGED         "ServicesChanged"
53 #define CONNMAN_SIGNAL_PROPERTY_CHANGED         "PropertyChanged"
54 #define CONNMAN_SIGNAL_NAME_CHANGED             "NameOwnerChanged"
55
56 #define MAX_SIG_LEN 64
57 #define TOTAL_CONN_SIGNALS 4
58
59 typedef enum {
60         SIG_INTERFACE_REMOVED = 0,
61         SIG_PROPERTIES_CHANGED,
62         SIG_BSS_ADDED,
63         SIG_SCAN_DONE,
64         SIG_DRIVER_HANGED,
65         SIG_SESSION_OVERLAPPED,
66         SIG_TDLS_CONNECTED,
67         SIG_TDLS_DISCONNECTED,
68         SIG_TDLS_PEER_FOUND,
69         SIG_MAX
70 } SuppSigArrayIndex;
71
72 static int conn_subscription_ids[TOTAL_CONN_SIGNALS] = {0};
73 static const char supplicant_signals[SIG_MAX][MAX_SIG_LEN] = {
74                 SIGNAL_INTERFACE_REMOVED,
75                 SIGNAL_PROPERTIES_CHANGED,
76                 SIGNAL_BSS_ADDED,
77                 SIGNAL_SCAN_DONE,
78                 SIGNAL_PROPERTIES_DRIVER_HANGED,
79                 SIGNAL_PROPERTIES_SESSION_OVERLAPPED,
80                 SIGNAL_TDLS_CONNECTED,
81                 SIGNAL_TDLS_DISCONNECTED,
82                 SIGNAL_TDLS_PEER_FOUND,
83 };
84
85 static int supp_subscription_ids[SIG_MAX] = {0};
86
87 typedef void (*supplicant_signal_cb)(GDBusConnection *conn,
88                 const gchar *name, const gchar *path, const gchar *interface,
89                 const gchar *sig, GVariant *param, gpointer user_data);
90 typedef void (*connman_signal_cb)(GDBusConnection *conn,
91                 const gchar *name, const gchar *path, const gchar *interface,
92                 const gchar *sig, GVariant *param, gpointer user_data);
93
94 static void _technology_signal_cb(GDBusConnection *conn,
95                 const gchar *name, const gchar *path, const gchar *interface,
96                 const gchar *sig, GVariant *param, gpointer user_data)
97 {
98         gchar *key = NULL;
99         gboolean value = FALSE;
100         GVariant *var = NULL;
101
102         if (param == NULL)
103                 return;
104
105         if (g_str_has_prefix(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == TRUE) {
106                 g_variant_get(param, "(sv)", &key, &var);
107                 if (g_strcmp0(key, "Powered") == 0) {
108                         /* Power state */
109                         value = g_variant_get_boolean(var);
110                         if (value == TRUE)
111                                 wifi_state_update_power_state(TRUE);
112                         else
113                                 wifi_state_update_power_state(FALSE);
114                 } else if (g_strcmp0(key, "Connected") == 0) {
115                         /* Connection state */
116                         value = g_variant_get_boolean(var);
117                         if (value == TRUE)
118                                 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_CONNECTED);
119                         else
120                                 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_POWERED);
121                 } else if (g_strcmp0(key, "Tethering") == 0) {
122                         /* Tethering state */
123                         wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_TETHERED);
124                 }
125                 if (key)
126                         g_free(key);
127                 if (var)
128                         g_variant_unref(var);
129         }
130 }
131
132 static void _service_signal_cb(GDBusConnection *conn,
133                 const gchar *name, const gchar *path,
134                 const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data)
135 {
136         gchar *sigvalue = NULL;
137         gchar *property;
138         GVariant *variant = NULL, *var;
139         GVariantIter *iter;
140         const gchar *value = NULL;
141
142         if (path == NULL || param == NULL)
143                 goto done;
144
145         g_variant_get(param, "(sv)", &sigvalue, &variant);
146         if (sigvalue == NULL)
147                 goto done;
148
149         if (g_strcmp0(sig, CONNMAN_SIGNAL_PROPERTY_CHANGED) != 0)
150                 goto done;
151
152         if (g_strcmp0(sigvalue, "State") == 0) {
153                 g_variant_get(variant, "s", &property);
154
155                 DBG("[%s] %s", property, path);
156                 if (netconfig_is_wifi_profile(path) == TRUE) {
157                         int wifi_state = 0;
158
159                         netconfig_vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
160                         if (wifi_state == VCONFKEY_WIFI_OFF) {
161                                 g_free(property);
162                                 goto done;
163                         }
164
165                         if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
166                                 if (wifi_state >= VCONFKEY_WIFI_CONNECTED) {
167                                         g_free(property);
168                                         goto done;
169                                 }
170
171                                 netconfig_update_default_profile(path);
172
173                                 wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTED);
174
175                         } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
176                                 if (netconfig_get_default_profile() == NULL ||
177                                                 netconfig_is_wifi_profile(netconfig_get_default_profile())
178                                                 != TRUE) {
179                                         if (g_strcmp0(property, "failure") == 0)
180                                                 wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
181                                         else
182                                                 wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
183                                         g_free(property);
184                                         goto done;
185                                 }
186
187                                 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
188                                         g_free(property);
189                                         goto done;
190                                 }
191
192                                 netconfig_update_default_profile(NULL);
193
194                                 if (g_strcmp0(property, "failure") == 0)
195                                         wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
196                                 else
197                                         wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
198
199                         } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
200                                 if (netconfig_get_default_profile() == NULL ||
201                                                 netconfig_is_wifi_profile(netconfig_get_default_profile()) != TRUE) {
202                                         if (g_strcmp0(property, "association") == 0)
203                                                 wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
204                                         else
205                                                 wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
206                                         g_free(property);
207                                         goto done;
208                                 }
209
210                                 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
211                                         g_free(property);
212                                         goto done;
213                                 }
214
215                                 netconfig_update_default_profile(NULL);
216
217                                 if (g_strcmp0(property, "association") == 0)
218                                         wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
219                                 else
220                                         wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
221
222                         }
223                 } else {
224                         if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
225                                 if (netconfig_get_default_profile() == NULL) {
226                                         if (!netconfig_is_cellular_profile(path))
227                                                 netconfig_update_default_profile(path);
228                                         else {
229                                                 if (netconfig_is_cellular_internet_profile(path))
230                                                         netconfig_update_default_profile(path);
231                                         }
232                                 }
233
234                                 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
235                                         cellular_state_set_service_state(NETCONFIG_CELLULAR_ONLINE);
236
237                         } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
238                                 if (netconfig_get_default_profile() == NULL) {
239                                         g_free(property);
240                                         goto done;
241                                 }
242
243                                 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
244                                         cellular_state_set_service_state(NETCONFIG_CELLULAR_IDLE);
245
246                                 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
247                                         g_free(property);
248                                         goto done;
249                                 }
250
251                                 netconfig_update_default_profile(NULL);
252                         } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
253                                 if (netconfig_get_default_profile() == NULL) {
254                                         g_free(property);
255                                         goto done;
256                                 }
257
258                                 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
259                                         cellular_state_set_service_state(NETCONFIG_CELLULAR_CONNECTING);
260
261                                 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
262                                         g_free(property);
263                                         goto done;
264                                 }
265
266                                 netconfig_update_default_profile(NULL);
267                         }
268                 }
269                 g_free(property);
270         } else if (g_strcmp0(sigvalue, "Proxy") == 0) {
271                 if (netconfig_is_wifi_profile(path) != TRUE || g_strcmp0(path, netconfig_get_default_profile()) != 0)
272                         goto done;
273
274                 if (!g_variant_type_equal(variant, G_VARIANT_TYPE_ARRAY))
275                         goto done;
276
277                 g_variant_get(variant, "a{sv}", &iter);
278                 while (g_variant_iter_loop(iter, "{sv}", &property, &var)) {
279                         if (g_strcmp0(property, "Servers") == 0) {
280                                 GVariantIter *iter_sub = NULL;
281
282                                 g_variant_get(var, "as", &iter_sub);
283                                 g_variant_iter_loop(iter_sub, "s", &value);
284                                 g_variant_iter_free(iter_sub);
285
286                                 DBG("Proxy - [%s]", value);
287                                 vconf_set_str(VCONFKEY_NETWORK_PROXY, value);
288
289                                 g_free(property);
290                                 g_variant_unref(var);
291                                 break;
292                         } else if (g_strcmp0(property, "Method") == 0) {
293                                 value = g_variant_get_string(var, NULL);
294                                 DBG("Method - [%s]", value);
295
296                                 if (g_strcmp0(value, "direct") == 0)
297                                         vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
298
299                                 g_free(property);
300                                 g_variant_unref(var);
301                                 break;
302                         }
303                 }
304
305                 g_variant_iter_free(iter);
306         } else if (g_strcmp0(sigvalue, "Error") == 0) {
307                 g_variant_get(variant, "s", &property);
308                 INFO("[%s] Property : %s", sigvalue, property);
309                 g_free(property);
310         }
311 done:
312         if (sigvalue)
313                 g_free(sigvalue);
314
315         if (variant)
316                 g_variant_unref(variant);
317
318         return;
319 }
320
321 static void _dbus_name_changed_cb(GDBusConnection *conn,
322                 const gchar *Name, const gchar *path, const gchar *interface,
323                 const gchar *sig, GVariant *param, gpointer user_data)
324 {
325         gchar *name = NULL;
326         gchar *old = NULL;
327         gchar *new = NULL;
328
329         if (param == NULL)
330                 return;
331
332         g_variant_get(param, "(sss)", &name, &old, &new);
333
334         if (g_strcmp0(name, CONNMAN_SERVICE) == 0 && *new == '\0') {
335                 DBG("ConnMan destroyed: name %s, old %s, new %s", name, old, new);
336
337                 connman_register_agent();
338         }
339         if (name)
340                 g_free(name);
341         if (old)
342                 g_free(old);
343         if (new)
344                 g_free(new);
345
346         return;
347 }
348
349 static void _services_changed_cb(GDBusConnection *conn, const gchar *name,
350                 const gchar *path, const gchar *interface, const gchar *sig,
351                 GVariant *param, gpointer user_data)
352 {
353         gchar *property, *value;
354         gchar *service_path;
355         GVariant *variant = NULL;
356         GVariantIter *added = NULL, *removed = NULL, *next = NULL;
357
358         if (path == NULL || param == NULL)
359                 return;
360
361         if (g_strcmp0(sig, CONNMAN_SIGNAL_SERVICES_CHANGED) != 0)
362                 return;
363
364         if (netconfig_get_default_profile() != NULL)
365                 return;
366
367         g_variant_get(param, "(a(oa{sv})ao)", &added, &removed);
368
369         while (g_variant_iter_loop(added, "(oa{sv})", &service_path, &next)) {
370                 gboolean is_wifi_prof, is_cell_prof, is_cell_internet_prof;
371                 is_wifi_prof = netconfig_is_wifi_profile(service_path);
372                 is_cell_prof = netconfig_is_cellular_profile(service_path);
373                 is_cell_internet_prof = netconfig_is_cellular_internet_profile(
374                                 service_path);
375                 if (service_path != NULL) {
376                         while (g_variant_iter_loop(next, "{sv}", &property,
377                                                 &variant)) {
378                                 if (g_strcmp0(property, "State") == 0) {
379                                         g_variant_get(variant, "s", &value);
380                                         DBG("Profile %s State %s", service_path,
381                                                         value);
382                                         if (g_strcmp0(value, "ready") != 0 &&
383                                                         g_strcmp0(value,
384                                                                 "online") != 0) {
385                                                 g_free(property);
386                                                 g_free(value);
387                                                 g_variant_unref(variant);
388                                                 break;
389                                         }
390
391                                         if (!is_cell_prof)
392                                                 netconfig_update_default_profile(
393                                                                 service_path);
394                                         else if (is_cell_internet_prof) {
395                                                 netconfig_update_default_profile(
396                                                                 service_path);
397                                         }
398                                         if (is_wifi_prof)
399                                                 wifi_state_set_service_state(
400                                                         NETCONFIG_WIFI_CONNECTED);
401                                         else if (is_cell_prof &&
402                                                         is_cell_internet_prof)
403                                                 cellular_state_set_service_state(
404                                                         NETCONFIG_CELLULAR_ONLINE);
405                                         g_free(property);
406                                         g_free(value);
407                                         g_variant_unref(variant);
408                                         break;
409                                 }
410                         }
411                 }
412         }
413
414         g_variant_iter_free(added);
415
416         if (next)
417                 g_variant_iter_free(next);
418
419         if (removed)
420                 g_variant_iter_free(removed);
421
422         return;
423 }
424
425 static void _supplicant_interface_removed(GDBusConnection *conn,
426                 const gchar *name, const gchar *path, const gchar *interface,
427                 const gchar *sig, GVariant *param, gpointer user_data)
428 {
429         DBG("Interface removed handling!");
430         if (netconfig_wifi_is_wps_enabled() == TRUE)
431                 netconfig_wifi_wps_signal_scanaborted();
432
433         return;
434 }
435
436 static void _supplicant_properties_changed(GDBusConnection *conn,
437                 const gchar *name, const gchar *path, const gchar *interface,
438                 const gchar *sig, GVariant *param, gpointer user_data)
439 {
440         DBG("Properties changed handling!");
441         gchar *key;
442         GVariantIter *iter;
443         GVariant *variant;
444         gboolean scanning = FALSE;
445
446         if (param == NULL)
447                 return;
448
449         g_variant_get(param, "(a{sv})", &iter);
450         while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
451                 if (g_strcmp0(key, "Scanning") == 0) {
452                         scanning = g_variant_get_boolean(variant);
453                         if (scanning == TRUE)
454                                 netconfig_wifi_set_scanning(TRUE);
455
456                         g_variant_unref(variant);
457                         g_free(key);
458                         break;
459                 }
460         }
461
462         g_variant_iter_free(iter);
463
464         return;
465 }
466
467 static void _supplicant_bss_added(GDBusConnection *conn,
468                 const gchar *name, const gchar *path, const gchar *interface,
469                 const gchar *sig, GVariant *param, gpointer user_data)
470 {
471         DBG("BSS added handling!");
472         if (wifi_ssid_scan_get_state() == TRUE)
473                 wifi_ssid_scan_add_bss(param);
474         else
475                 wifi_state_set_bss_found(TRUE);
476
477         return;
478 }
479
480 static void _supplicant_scan_done(GDBusConnection *conn,
481                 const gchar *name, const gchar *path, const gchar *interface,
482                 const gchar *sig, GVariant *param, gpointer user_data)
483 {
484         DBG("Scan Done handling!");
485         netconfig_wifi_set_scanning(FALSE);
486
487         if (netconfig_wifi_is_wps_enabled() == TRUE) {
488                 netconfig_wifi_wps_signal_scandone();
489                 if (wifi_state_get_technology_state() < NETCONFIG_WIFI_TECH_POWERED)
490                         return;
491         }
492
493         if (netconfig_wifi_get_bgscan_state() != TRUE) {
494                 if (wifi_ssid_scan_get_state() == TRUE)
495                         wifi_ssid_scan_emit_scan_completed();
496                 else
497                         wifi_ssid_scan(NULL);
498         } else {
499                 if (wifi_state_get_technology_state() >=
500                                 NETCONFIG_WIFI_TECH_POWERED)
501                         netconfig_wifi_bgscan_start(FALSE);
502
503                 wifi_start_timer_network_notification();
504         }
505
506         return;
507 }
508
509 static void _supplicant_driver_hanged(GDBusConnection *conn,
510                 const gchar *name, const gchar *path, const gchar *interface,
511                 const gchar *sig, GVariant *param, gpointer user_data)
512 {
513         DBG("Driver Hanged handling!");
514         ERR("Critical. Wi-Fi firmware crashed");
515
516         wifi_power_recover_firmware();
517
518         return;
519 }
520
521 static void _supplicant_session_overlapped(GDBusConnection *conn,
522                 const gchar *name, const gchar *path, const gchar *interface,
523                 const gchar *sig, GVariant *param, gpointer user_data)
524 {
525         DBG("Driver session overlapped handling!");
526         ERR("WPS PBC SESSION OVERLAPPED");
527 #if defined TIZEN_WEARABLE
528         return;
529 #else
530         netconfig_send_message_to_net_popup("WPS Error",
531                                         "wps session overlapped", "popup", NULL);
532 #endif
533 }
534
535 static void _supplicant_tdls_connected(GDBusConnection *conn,
536                 const gchar *name, const gchar *path, const gchar *interface,
537                 const gchar *sig, GVariant *param, gpointer user_data)
538 {
539         ERR("Received TDLS Connected Signal");
540         netconfig_wifi_tlds_connected_event(param);
541
542         return;
543 }
544
545 static void _supplicant_tdls_disconnected(GDBusConnection *conn,
546                 const gchar *name, const gchar *path, const gchar *interface,
547                 const gchar *sig, GVariant *param, gpointer user_data)
548 {
549         ERR("Received TDLS Disconnected Signal");
550         netconfig_wifi_tlds_disconnected_event(param);
551
552         return;
553 }
554
555 static void _supplicant_tdls_peer_found(GDBusConnection *conn,
556                 const gchar *name, const gchar *path, const gchar *interface,
557                 const gchar *sig, GVariant *param, gpointer user_data)
558 {
559         ERR("Received TDLS Peer Found Signal");
560         return;
561 }
562
563 static supplicant_signal_cb supplicant_cbs[SIG_MAX] = {
564                 _supplicant_interface_removed,
565                 _supplicant_properties_changed,
566                 _supplicant_bss_added,
567                 _supplicant_scan_done,
568                 _supplicant_driver_hanged,
569                 _supplicant_session_overlapped,
570                 _supplicant_tdls_connected,
571                 _supplicant_tdls_disconnected,
572                 _supplicant_tdls_peer_found
573 };
574
575 void register_gdbus_signal(void)
576 {
577         GDBusConnection *connection = NULL;
578         const char *interface = NULL;
579         SuppSigArrayIndex sig;
580         connection = netdbus_get_connection();
581
582         if (connection == NULL) {
583                 ERR("Failed to get GDbus Connection");
584                 return;
585         }
586
587         /* listening to messages from all objects as no path is specified */
588         /* see signals from the given interface */
589         conn_subscription_ids[0] = g_dbus_connection_signal_subscribe(
590                         connection,
591                         CONNMAN_SERVICE,
592                         CONNMAN_TECHNOLOGY_INTERFACE,
593                         NULL,
594                         NULL,
595                         NULL,
596                         G_DBUS_SIGNAL_FLAGS_NONE,
597                         _technology_signal_cb,
598                         NULL,
599                         NULL);
600
601         conn_subscription_ids[1] = g_dbus_connection_signal_subscribe(
602                         connection,
603                         CONNMAN_SERVICE,
604                         CONNMAN_SERVICE_INTERFACE,
605                         CONNMAN_SIGNAL_PROPERTY_CHANGED,
606                         NULL,
607                         NULL,
608                         G_DBUS_SIGNAL_FLAGS_NONE,
609                         _service_signal_cb,
610                         NULL,
611                         NULL);
612
613         conn_subscription_ids[2] = g_dbus_connection_signal_subscribe(
614                         connection,
615                         DBUS_SERVICE_DBUS,
616                         DBUS_INTERFACE_DBUS,
617                         CONNMAN_SIGNAL_NAME_CHANGED,
618                         NULL,
619                         CONNMAN_SERVICE,
620                         G_DBUS_SIGNAL_FLAGS_NONE,
621                         _dbus_name_changed_cb,
622                         NULL,
623                         NULL);
624
625         conn_subscription_ids[3] = g_dbus_connection_signal_subscribe(
626                         connection,
627                         CONNMAN_SERVICE,
628                         CONNMAN_MANAGER_INTERFACE,
629                         CONNMAN_SIGNAL_SERVICES_CHANGED,
630                         NULL,
631                         NULL,
632                         G_DBUS_SIGNAL_FLAGS_NONE,
633                         _services_changed_cb,
634                         NULL,
635                         NULL);
636
637         INFO("Successfully register connman DBus signal filters");
638
639         for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
640                 /*
641                  * For SIG_INTERFACE_REMOVED INTERFACE_ADDED
642                  */
643                 interface = (sig == SIG_INTERFACE_REMOVED) ?
644                                 SUPPLICANT_INTERFACE : SUPPLICANT_IFACE_INTERFACE;
645
646                 supp_subscription_ids[sig] = g_dbus_connection_signal_subscribe(
647                                 connection,
648                                 SUPPLICANT_SERVICE,
649                                 interface,
650                                 supplicant_signals[sig],
651                                 NULL,
652                                 NULL,
653                                 G_DBUS_SIGNAL_FLAGS_NONE,
654                                 supplicant_cbs[sig],
655                                 NULL,
656                                 NULL);
657         }
658
659         INFO("Successfully register Supplicant DBus signal filters");
660
661         /* In case ConnMan precedes this signal register,
662          * net-config should update the default connected profile.
663          */
664         netconfig_update_default();
665 }
666
667 void deregister_gdbus_signal(void)
668 {
669         GDBusConnection *connection = NULL;
670         int signal;
671         SuppSigArrayIndex sig;
672         connection = netdbus_get_connection();
673         if (!connection) {
674                 ERR("Already de-registered. Nothing to be done");
675                 return;
676         }
677
678         for (signal = 0; signal < TOTAL_CONN_SIGNALS; signal++) {
679                 if (conn_subscription_ids[signal]) {
680                         g_dbus_connection_signal_unsubscribe(connection,
681                                                 conn_subscription_ids[signal]);
682                 }
683         }
684
685         for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
686                 if (supp_subscription_ids[sig]) {
687                         g_dbus_connection_signal_unsubscribe(connection,
688                                                 supp_subscription_ids[sig]);
689                 }
690         }
691
692 }