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