Apply coding rule
[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         if (next)
397                 g_variant_iter_free(next);
398         if (added)
399                 g_variant_iter_free(added);
400         if (removed)
401                 g_variant_iter_free(removed);
402         return;
403 }
404
405 static void _supplicant_interface_removed(GDBusConnection *conn,
406                 const gchar *name, const gchar *path, const gchar *interface,
407                 const gchar *sig, GVariant *param, gpointer user_data)
408 {
409         DBG("Interface removed handling!");
410         if (netconfig_wifi_is_wps_enabled() == TRUE)
411                 netconfig_wifi_wps_signal_scanaborted();
412
413         return;
414 }
415
416 static void _supplicant_properties_changed(GDBusConnection *conn,
417                 const gchar *name, const gchar *path, const gchar *interface,
418                 const gchar *sig, GVariant *param, gpointer user_data)
419 {
420         DBG("Properties changed handling!");
421         gchar *key;
422         GVariantIter *iter;
423         GVariant *variant;
424         gboolean scanning = FALSE;
425
426         if (param == NULL)
427                 return;
428
429         g_variant_get(param, "(a{sv})", &iter);
430         while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
431                 if (g_strcmp0(key, "Scanning") == 0) {
432                         scanning = g_variant_get_boolean(variant);
433                         if (scanning == TRUE)
434                                 netconfig_wifi_set_scanning(TRUE);
435
436                         g_variant_unref(variant);
437                         g_free(key);
438                         break;
439                 }
440         }
441
442         g_variant_iter_free(iter);
443
444         return;
445 }
446
447 static void _supplicant_bss_added(GDBusConnection *conn,
448                 const gchar *name, const gchar *path, const gchar *interface,
449                 const gchar *sig, GVariant *param, gpointer user_data)
450 {
451         DBG("BSS added handling!");
452         if (wifi_ssid_scan_get_state() == TRUE)
453                 wifi_ssid_scan_add_bss(param);
454         else
455                 wifi_state_set_bss_found(TRUE);
456
457         return;
458 }
459
460 static void _supplicant_scan_done(GDBusConnection *conn,
461                 const gchar *name, const gchar *path, const gchar *interface,
462                 const gchar *sig, GVariant *param, gpointer user_data)
463 {
464         DBG("Scan Done handling!");
465         netconfig_wifi_set_scanning(FALSE);
466
467         if (netconfig_wifi_is_wps_enabled() == TRUE) {
468                 netconfig_wifi_wps_signal_scandone();
469                 if (wifi_state_get_technology_state() < NETCONFIG_WIFI_TECH_POWERED)
470                         return;
471         }
472
473         if (netconfig_wifi_get_bgscan_state() != TRUE) {
474                 if (wifi_ssid_scan_get_state() == TRUE)
475                         wifi_ssid_scan_emit_scan_completed();
476                 else
477                         wifi_ssid_scan(NULL);
478         } else {
479                 if (wifi_state_get_technology_state() >=
480                                 NETCONFIG_WIFI_TECH_POWERED)
481                         netconfig_wifi_bgscan_start(FALSE);
482
483                 wifi_start_timer_network_notification();
484         }
485
486         return;
487 }
488
489 static void _supplicant_driver_hanged(GDBusConnection *conn,
490                 const gchar *name, const gchar *path, const gchar *interface,
491                 const gchar *sig, GVariant *param, gpointer user_data)
492 {
493         DBG("Driver Hanged handling!");
494         ERR("Critical. Wi-Fi firmware crashed");
495
496         wifi_power_recover_firmware();
497
498         return;
499 }
500
501 static void _supplicant_session_overlapped(GDBusConnection *conn,
502                 const gchar *name, const gchar *path, const gchar *interface,
503                 const gchar *sig, GVariant *param, gpointer user_data)
504 {
505         DBG("Driver session overlapped handling!");
506         ERR("WPS PBC SESSION OVERLAPPED");
507 #if defined TIZEN_WEARABLE
508         wc_launch_syspopup(WC_POPUP_TYPE_SESSION_OVERLAPPED);
509 #else
510         netconfig_send_message_to_net_popup("WPS Error",
511                                         "wps session overlapped", "popup", NULL);
512 #endif
513 }
514
515 static void _supplicant_tdls_connected(GDBusConnection *conn,
516                 const gchar *name, const gchar *path, const gchar *interface,
517                 const gchar *sig, GVariant *param, gpointer user_data)
518 {
519         ERR("Received TDLS Connected Signal");
520         netconfig_wifi_tlds_connected_event(param);
521
522         return;
523 }
524
525 static void _supplicant_tdls_disconnected(GDBusConnection *conn,
526                 const gchar *name, const gchar *path, const gchar *interface,
527                 const gchar *sig, GVariant *param, gpointer user_data)
528 {
529         ERR("Received TDLS Disconnected Signal");
530         netconfig_wifi_tlds_disconnected_event(param);
531
532         return;
533 }
534
535 static void _supplicant_tdls_peer_found(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 Peer Found Signal");
540         return;
541 }
542
543 static supplicant_signal_cb supplicant_cbs[SIG_MAX] = {
544                 _supplicant_interface_removed,
545                 _supplicant_properties_changed,
546                 _supplicant_bss_added,
547                 _supplicant_scan_done,
548                 _supplicant_driver_hanged,
549                 _supplicant_session_overlapped,
550                 _supplicant_tdls_connected,
551                 _supplicant_tdls_disconnected,
552                 _supplicant_tdls_peer_found
553 };
554
555 #if defined TIZEN_DEBUG_DISABLE
556 static void __netconfig_dumpservice_handler(GDBusConnection *conn,
557                 const gchar *name, const gchar *path, const gchar *interface,
558                 const gchar *sig, GVariant *param, gpointer user_data)
559 {
560         int mode;
561         gchar *signal_path = NULL;
562
563         if (param == NULL)
564                 return;
565
566         g_variant_get(param, "(io)", &mode, &signal_path);
567         DBG("Path: %s and mode: %d", signal_path, mode);
568         netconfig_dump_log(path);
569         if (signal_path)
570                 g_free(signal_path);
571
572         return;
573 }
574 #endif
575
576 void register_gdbus_signal(void)
577 {
578         GDBusConnection *connection = NULL;
579         const char *interface = NULL;
580         SuppSigArrayIndex sig;
581         connection = netdbus_get_connection();
582
583         if (connection == NULL) {
584                 ERR("Failed to get GDbus Connection");
585                 return;
586         }
587
588         /* listening to messages from all objects as no path is specified */
589         /* see signals from the given interface */
590         conn_subscription_ids[0] = g_dbus_connection_signal_subscribe(
591                         connection,
592                         CONNMAN_SERVICE,
593                         CONNMAN_TECHNOLOGY_INTERFACE,
594                         NULL,
595                         NULL,
596                         NULL,
597                         G_DBUS_SIGNAL_FLAGS_NONE,
598                         _technology_signal_cb,
599                         NULL,
600                         NULL);
601
602         conn_subscription_ids[1] = g_dbus_connection_signal_subscribe(
603                         connection,
604                         CONNMAN_SERVICE,
605                         CONNMAN_SERVICE_INTERFACE,
606                         CONNMAN_SIGNAL_PROPERTY_CHANGED,
607                         NULL,
608                         NULL,
609                         G_DBUS_SIGNAL_FLAGS_NONE,
610                         _service_signal_cb,
611                         NULL,
612                         NULL);
613
614         conn_subscription_ids[2] = g_dbus_connection_signal_subscribe(
615                         connection,
616                         DBUS_SERVICE_DBUS,
617                         DBUS_INTERFACE_DBUS,
618                         CONNMAN_SIGNAL_NAME_CHANGED,
619                         NULL,
620                         CONNMAN_SERVICE,
621                         G_DBUS_SIGNAL_FLAGS_NONE,
622                         _dbus_name_changed_cb,
623                         NULL,
624                         NULL);
625
626         conn_subscription_ids[3] = g_dbus_connection_signal_subscribe(
627                         connection,
628                         CONNMAN_SERVICE,
629                         CONNMAN_MANAGER_INTERFACE,
630                         CONNMAN_SIGNAL_SERVICES_CHANGED,
631                         NULL,
632                         NULL,
633                         G_DBUS_SIGNAL_FLAGS_NONE,
634                         _services_changed_cb,
635                         NULL,
636                         NULL);
637
638         INFO("Successfully register connman DBus signal filters");
639
640         for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
641                 /*
642                  * For SIG_INTERFACE_REMOVED INTERFACE_ADDED
643                  */
644                 interface = (sig == SIG_INTERFACE_REMOVED) ?
645                                 SUPPLICANT_INTERFACE : SUPPLICANT_IFACE_INTERFACE;
646
647                 supp_subscription_ids[sig] = g_dbus_connection_signal_subscribe(
648                                 connection,
649                                 SUPPLICANT_SERVICE,
650                                 interface,
651                                 supplicant_signals[sig],
652                                 NULL,
653                                 NULL,
654                                 G_DBUS_SIGNAL_FLAGS_NONE,
655                                 supplicant_cbs[sig],
656                                 NULL,
657                                 NULL);
658         }
659
660         INFO("Successfully register Supplicant DBus signal filters");
661
662 #if defined TIZEN_DEBUG_DISABLE
663         dumpservice_subscription_id = g_dbus_connection_signal_subscribe(
664                         connection,
665                         /*
666                          * Sender => For testing purpose made NULL
667                          *WPA_SUPPLICANT,
668                          */
669                         NULL,
670                         DUMP_SERVICE_INTERFACE,
671                         DUMP_SIGNAL,
672                         NULL,
673                         NULL,
674                         G_DBUS_SIGNAL_FLAGS_NONE,
675                         __netconfig_dumpservice_handler,
676                         NULL,
677                         NULL);
678
679         INFO("Successfully register Dumpservice DBus signal filter");
680 #endif
681         /* In case ConnMan precedes this signal register,
682          * net-config should update the default connected profile.
683          */
684         netconfig_update_default();
685 }
686
687 void deregister_gdbus_signal(void)
688 {
689         GDBusConnection *connection = NULL;
690         int signal;
691         SuppSigArrayIndex sig;
692         connection = netdbus_get_connection();
693         if (!connection) {
694                 ERR("Already de-registered. Nothing to be done");
695                 return;
696         }
697
698         for (signal = 0; signal < TOTAL_CONN_SIGNALS; signal++) {
699                 if (conn_subscription_ids[signal]) {
700                         g_dbus_connection_signal_unsubscribe(connection,
701                                                 conn_subscription_ids[signal]);
702                 }
703         }
704
705         for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
706                 if (supp_subscription_ids[sig]) {
707                         g_dbus_connection_signal_unsubscribe(connection,
708                                                 supp_subscription_ids[sig]);
709                 }
710         }
711
712         g_dbus_connection_signal_unsubscribe(connection,
713                         dumpservice_subscription_id);
714 }