cfbf83a4572bd0fa2235a9314de19b6e7244c67d
[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 <stdlib.h>
22 #include <string.h>
23 #include <vconf.h>
24 #include <vconf-keys.h>
25 #include <sys/wait.h>
26
27 #include "log.h"
28 #include "util.h"
29 #include "netdbus.h"
30 #include "neterror.h"
31 #include "wifi-wps.h"
32 #include "wifi-bssid-scan.h"
33 #include "wifi-agent.h"
34 #include "wifi-power.h"
35 #include "wifi-state.h"
36 #include "netsupplicant.h"
37 #include "network-state.h"
38 #include "cellular-state.h"
39 #include "signal-handler.h"
40 #include "wifi-background-scan.h"
41 #include "wifi-tdls.h"
42 #include "ip-conflict-detect.h"
43 #include "wifi-key-encryption.h"
44 #if defined TIZEN_DEBUG_ENABLE
45 #include "network-dump.h"
46 #define NETWORK_LOG_DUMP_SCRIPT  "/opt/var/lib/net-config/network_log_dump.sh"
47 #define MAX_SIZE_ERROR_BUFFER 256
48 #endif
49
50 #define DBUS_SERVICE_DBUS                       "org.freedesktop.DBus"
51 #define DBUS_INTERFACE_DBUS                     "org.freedesktop.DBus"
52 #define SIGNAL_INTERFACE_REMOVED                "InterfaceRemoved"
53 #define SIGNAL_SCAN_DONE                        "ScanDone"
54 #define SIGNAL_BSS_ADDED                        "BSSAdded"
55 #define SIGNAL_PROPERTIES_CHANGED               "PropertiesChanged"
56 #define SIGNAL_PROPERTIES_DRIVER_HANGED         "DriverHanged"
57 #define SIGNAL_PROPERTIES_SESSION_OVERLAPPED    "SessionOverlapped"
58 #define SIGNAL_TDLS_CONNECTED                           "TDLSConnected"
59 #define SIGNAL_TDLS_DISCONNECTED                        "TDLSDisconnected"
60 #define SIGNAL_TDLS_PEER_FOUND                          "TDLSPeerFound"
61
62 #define SIGNAL_WPS_CONNECTED                            "WPSConnected"
63 #define SIGNAL_WPS_EVENT                                        "Event"
64 #define SIGNAL_WPS_CREDENTIALS                          "Credentials"
65
66 #define CONNMAN_SIGNAL_SERVICES_CHANGED         "ServicesChanged"
67 #define CONNMAN_SIGNAL_PROPERTY_CHANGED         "PropertyChanged"
68 #define CONNMAN_SIGNAL_NAME_CHANGED             "NameOwnerChanged"
69
70 #define MAX_SIG_LEN 64
71 #define TOTAL_CONN_SIGNALS 5
72 #define MAX_SOCKET_OPEN_RETRY 5
73
74 typedef enum {
75         SIG_INTERFACE_REMOVED = 0,
76         SIG_PROPERTIES_CHANGED,
77         SIG_BSS_ADDED,
78         SIG_SCAN_DONE,
79         SIG_DRIVER_HANGED,
80         SIG_SESSION_OVERLAPPED,
81         SIG_TDLS_CONNECTED,
82         SIG_TDLS_DISCONNECTED,
83         SIG_TDLS_PEER_FOUND,
84         SIG_MAX
85 } SuppSigArrayIndex;
86
87 static int conn_subscription_ids[TOTAL_CONN_SIGNALS] = {0};
88 static const char supplicant_signals[SIG_MAX][MAX_SIG_LEN] = {
89                 SIGNAL_INTERFACE_REMOVED,
90                 SIGNAL_PROPERTIES_CHANGED,
91                 SIGNAL_BSS_ADDED,
92                 SIGNAL_SCAN_DONE,
93                 SIGNAL_PROPERTIES_DRIVER_HANGED,
94                 SIGNAL_PROPERTIES_SESSION_OVERLAPPED,
95                 SIGNAL_TDLS_CONNECTED,
96                 SIGNAL_TDLS_DISCONNECTED,
97                 SIGNAL_TDLS_PEER_FOUND,
98 };
99
100 static int supp_subscription_ids[SIG_MAX] = {0};
101 #if defined TIZEN_DEBUG_ENABLE
102 static int dumpservice_subscription_id = 0;
103 #endif
104
105 typedef void (*supplicant_signal_cb)(GDBusConnection *conn,
106                 const gchar *name, const gchar *path, const gchar *interface,
107                 const gchar *sig, GVariant *param, gpointer user_data);
108 typedef void (*connman_signal_cb)(GDBusConnection *conn,
109                 const gchar *name, const gchar *path, const gchar *interface,
110                 const gchar *sig, GVariant *param, gpointer user_data);
111
112 static void __netconfig_extract_ipv4_signal_data(GVariant *dictionary,
113                 const gchar *profile)
114 {
115         gchar *key = NULL;
116         const gchar *value = NULL;
117         GVariant *var = NULL;
118         GVariantIter iter;
119         GVariantBuilder *builder;
120         GVariant *params;
121
122         g_variant_iter_init(&iter, dictionary);
123         while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) {
124                 if (g_strcmp0(key, "Address") == 0)  {
125                         g_variant_get(var, "&s", &value);
126                         char *old_ip = vconf_get_str(VCONFKEY_NETWORK_IP);
127
128                         DBG("Old IPv4.Address [%s] Received new IPv4.Address [%s]", old_ip,
129                                                   value);
130                         if (g_strcmp0(old_ip, value) != 0) {
131                                 builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
132
133                                 if (value != NULL) {
134                                         vconf_set_str(VCONFKEY_NETWORK_IP, value);
135                                         g_variant_builder_add(builder, "{sv}", "IPv4Address",
136                                                                   g_variant_new_string(value));
137                                 } else if (old_ip != NULL && strlen(old_ip) > 0) {
138                                         vconf_set_str(VCONFKEY_NETWORK_IP, "");
139                                         g_variant_builder_add(builder, "{sv}", "IPv4Address",
140                                                                   g_variant_new_string(""));
141                                 }
142
143                                 params = g_variant_new("(@a{sv})",
144                                                                            g_variant_builder_end(builder));
145
146                                 g_variant_builder_unref(builder);
147
148                                 netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
149                                                    NETCONFIG_NETWORK_INTERFACE, "NetworkConfigChanged",
150                                                    params);
151                         }
152                         free(old_ip);
153                 }
154         }
155 }
156
157 static void __netconfig_extract_ipv6_signal_data(GVariant *dictionary,
158                                                                                                  const gchar *profile)
159 {
160         gchar *key = NULL;
161         const gchar *value = NULL;
162         GVariant *var = NULL;
163         GVariantIter iter;
164         GVariantBuilder *builder;
165         GVariant *params;
166
167         g_variant_iter_init(&iter, dictionary);
168         while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) {
169                 if (g_strcmp0(key, "Address") == 0)  {
170                         g_variant_get(var, "&s", &value);
171                         char *old_ip6 = vconf_get_str(VCONFKEY_NETWORK_IP6);
172
173                         DBG("Old IPv6.Address [%s] Received new IPv6.Address [%s]", old_ip6,
174                                                         value);
175                         if (g_strcmp0(old_ip6, value) != 0) {
176                                 builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
177
178                                 if (value != NULL) {
179                                         vconf_set_str(VCONFKEY_NETWORK_IP6, value);
180                                         g_variant_builder_add(builder, "{sv}", "IPv6Address",
181                                                                   g_variant_new_string(value));
182                                 } else if (old_ip6 != NULL && strlen(old_ip6) > 0) {
183                                         vconf_set_str(VCONFKEY_NETWORK_IP6, "");
184                                         g_variant_builder_add(builder, "{sv}", "IPv6Address",
185                                                                   g_variant_new_string(""));
186                                 }
187
188                                 params = g_variant_new("(@a{sv})",
189                                                                            g_variant_builder_end(builder));
190                                 g_variant_builder_unref(builder);
191
192                                 netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
193                                                    NETCONFIG_NETWORK_INTERFACE, "NetworkConfigChanged",
194                                                    params);
195                         }
196                         free(old_ip6);
197                 }
198         }
199 }
200
201 #if defined TIZEN_DEBUG_ENABLE
202 static int __netconfig_handle_execute_file(const char *file_path,
203                 char *const args[], char *const envs[])
204 {
205         pid_t pid = 0;
206         int status = 0;
207         int rv = 0;
208         errno = 0;
209         register unsigned int index = 0;
210         char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
211
212         while (args[index] != NULL) {
213                 DBG("%s", args[index]);
214                 index++;
215         }
216
217         if (!(pid = fork())) {
218                 DBG("pid(%d), ppid (%d)", getpid(), getppid());
219                 DBG("Inside child, exec (%s) command", file_path);
220
221                 errno = 0;
222                 if (execve(file_path, args, envs) == -1) {
223                         strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
224                         DBG("Fail to execute command (%s)", error_buf);
225                         exit(1);
226                 }
227         } else if (pid > 0) {
228                 if (waitpid(pid, &status, 0) == -1)
229                         DBG("wait pid (%u) status (%d)", pid, status);
230
231                 if (WIFEXITED(status)) {
232                         rv = WEXITSTATUS(status);
233                         DBG("exited, status=%d", rv);
234                 } else if (WIFSIGNALED(status)) {
235                         DBG("killed by signal %d", WTERMSIG(status));
236                 } else if (WIFSTOPPED(status)) {
237                         DBG("stopped by signal %d", WSTOPSIG(status));
238                 } else if (WIFCONTINUED(status)) {
239                         DBG("continued");
240                 }
241
242                 return rv;
243         }
244
245         strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER);
246         DBG("failed to fork(%s)", error_buf);
247         return -EIO;
248 }
249
250 static int _start_dump()
251 {
252         int rv = 0;
253         gchar *path = NETWORK_LOG_DUMP_SCRIPT;
254         char *const args[] = { NETWORK_LOG_DUMP_SCRIPT, NULL };
255         char *const envs[] = { NULL };
256
257         rv = __netconfig_handle_execute_file(path, args, envs);
258         if (rv < 0) {
259                 ERR("Fail to execute network log dump shell");
260                 return -EIO;
261         }
262         return 0;
263 }
264 #endif
265
266 static void _technology_signal_cb(GDBusConnection *conn,
267                 const gchar *name, const gchar *path, const gchar *interface,
268                 const gchar *sig, GVariant *param, gpointer user_data)
269 {
270         gchar *key = NULL;
271         gboolean value = FALSE;
272         GVariant *var = NULL;
273
274         if (param == NULL)
275                 return;
276
277         if (g_str_has_prefix(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == TRUE) {
278                 g_variant_get(param, "(sv)", &key, &var);
279                 if (g_strcmp0(key, "Powered") == 0) {
280                         /* Power state */
281                         value = g_variant_get_boolean(var);
282                         if (value == TRUE)
283                                 wifi_state_update_power_state(TRUE);
284                         else
285                                 wifi_state_update_power_state(FALSE);
286                 } else if (g_strcmp0(key, "Connected") == 0) {
287                         /* Connection state */
288                         value = g_variant_get_boolean(var);
289                         if (value == TRUE)
290                                 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_CONNECTED);
291                         else
292                                 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_POWERED);
293                 } else if (g_strcmp0(key, "Tethering") == 0) {
294                         /* Tethering state */
295                         wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_TETHERED);
296                 }
297                 g_free(key);
298                 g_variant_unref(var);
299         }
300 }
301
302 static void _service_signal_cb(GDBusConnection *conn,
303                 const gchar *name, const gchar *path,
304                 const gchar *interface, const gchar *sig,
305                 GVariant *param, gpointer user_data)
306 {
307         gchar *sigvalue = NULL;
308         gchar *property;
309         GVariant *variant = NULL, *var;
310         GVariantIter *iter;
311         const gchar *value = NULL;
312         struct sock_data *sd = NULL;
313         int idx = 0;
314
315         if (path == NULL || param == NULL)
316                 goto done;
317
318         g_variant_get(param, "(sv)", &sigvalue, &variant);
319         if (sigvalue == NULL)
320                 goto done;
321
322         if (g_strcmp0(sig, CONNMAN_SIGNAL_PROPERTY_CHANGED) != 0)
323                 goto done;
324
325         if (g_strcmp0(sigvalue, "State") == 0) {
326                 g_variant_get(variant, "s", &property);
327
328                 DBG("[%s] %s", property, path);
329                 if (netconfig_is_wifi_profile(path) || netconfig_is_ethernet_profile(path)) {
330                         if (g_strcmp0(property, "ready") == 0) {
331                                 for (idx = 0; idx < MAX_SOCKET_OPEN_RETRY; idx++) {
332                                         sd = start_ip_conflict_mon();
333                                         if (sd != NULL)
334                                                 break;
335                                 }
336                         } else if (g_strcmp0(property, "online") == 0) {
337                                 // do nothing
338                         } else {
339                                 stop_ip_conflict_mon();
340                         }
341                 }
342
343                 if (netconfig_is_wifi_profile(path) == TRUE) {
344                         int wifi_state = 0;
345
346                         netconfig_vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
347                         if (wifi_state == VCONFKEY_WIFI_OFF) {
348                                 g_free(property);
349                                 goto done;
350                         }
351
352                         if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
353                                 if (wifi_state >= VCONFKEY_WIFI_CONNECTED) {
354                                         g_free(property);
355                                         goto done;
356                                 }
357
358                                 netconfig_update_default_profile(path);
359
360                                 wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTED);
361
362                         } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
363                                 if (netconfig_get_default_profile() == NULL ||
364                                                 netconfig_is_wifi_profile(netconfig_get_default_profile())
365                                                 != TRUE) {
366                                         if (g_strcmp0(property, "failure") == 0)
367                                                 wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
368                                         else
369                                                 wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
370                                         g_free(property);
371                                         goto done;
372                                 }
373
374                                 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
375                                         g_free(property);
376                                         goto done;
377                                 }
378
379                                 netconfig_update_default_profile(NULL);
380
381                                 if (g_strcmp0(property, "failure") == 0)
382                                         wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
383                                 else
384                                         wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
385
386                         } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
387                                 if (netconfig_get_default_profile() == NULL ||
388                                                 netconfig_is_wifi_profile(netconfig_get_default_profile()) != TRUE) {
389                                         if (g_strcmp0(property, "association") == 0)
390                                                 wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
391                                         else
392                                                 wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
393                                         g_free(property);
394                                         goto done;
395                                 }
396
397                                 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
398                                         g_free(property);
399                                         goto done;
400                                 }
401
402                                 netconfig_update_default_profile(NULL);
403
404                                 if (g_strcmp0(property, "association") == 0)
405                                         wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
406                                 else
407                                         wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
408
409                         }
410                 } else {
411                         if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
412                                 if (netconfig_get_default_profile() == NULL) {
413                                         if (!netconfig_is_cellular_profile(path))
414                                                 netconfig_update_default_profile(path);
415                                         else {
416                                                 if (netconfig_is_cellular_internet_profile(path))
417                                                         netconfig_update_default_profile(path);
418                                         }
419                                 }
420
421                                 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
422                                         cellular_state_set_service_state(NETCONFIG_CELLULAR_ONLINE);
423
424                         } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
425                                 if (netconfig_get_default_profile() == NULL) {
426                                         g_free(property);
427                                         goto done;
428                                 }
429
430                                 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
431                                         cellular_state_set_service_state(NETCONFIG_CELLULAR_IDLE);
432
433                                 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
434                                         g_free(property);
435                                         goto done;
436                                 }
437
438                                 netconfig_update_default_profile(NULL);
439                         } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
440                                 if (netconfig_get_default_profile() == NULL) {
441                                         g_free(property);
442                                         goto done;
443                                 }
444
445                                 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
446                                         cellular_state_set_service_state(NETCONFIG_CELLULAR_CONNECTING);
447
448                                 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
449                                         g_free(property);
450                                         goto done;
451                                 }
452
453                                 netconfig_update_default_profile(NULL);
454                         }
455                 }
456                 g_free(property);
457         } else if (g_strcmp0(sigvalue, "Proxy") == 0) {
458                 if (netconfig_is_wifi_profile(path) != TRUE || g_strcmp0(path, netconfig_get_default_profile()) != 0)
459                         goto done;
460
461                 if (!g_variant_type_equal(variant, G_VARIANT_TYPE_ARRAY))
462                         goto done;
463
464                 g_variant_get(variant, "a{sv}", &iter);
465                 while (g_variant_iter_loop(iter, "{sv}", &property, &var)) {
466                         GVariantBuilder *builder;
467                         GVariant *sig_params;
468                         if (g_strcmp0(property, "Servers") == 0) {
469                                 GVariantIter *iter_sub = NULL;
470
471                                 builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
472
473                                 g_variant_get(var, "as", &iter_sub);
474                                 g_variant_iter_loop(iter_sub, "s", &value);
475                                 g_variant_iter_free(iter_sub);
476
477                                 DBG("Proxy - [%s]", value);
478                                 vconf_set_str(VCONFKEY_NETWORK_PROXY, value);
479
480                                 g_variant_builder_add(builder, "{sv}", "ProxyAddress",
481                                                                 g_variant_new_string(value));
482
483                                 sig_params = g_variant_new("(@a{sv})",
484                                                                 g_variant_builder_end(builder));
485                                 g_variant_builder_unref(builder);
486
487                                 netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
488                                                    NETCONFIG_NETWORK_INTERFACE, "NetworkConfigChanged",
489                                                    sig_params);
490
491                                 g_free(property);
492                                 g_variant_unref(var);
493                                 break;
494                         } else if (g_strcmp0(property, "Method") == 0) {
495                                 value = g_variant_get_string(var, NULL);
496                                 DBG("Method - [%s]", value);
497
498                                 if (g_strcmp0(value, "direct") == 0) {
499                                         builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
500
501                                         vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
502                                         g_variant_builder_add(builder, "{sv}", "ProxyAddress",
503                                                                 g_variant_new_string(""));
504
505                                         sig_params = g_variant_new("(@a{sv})",
506                                                                 g_variant_builder_end(builder));
507                                         g_variant_builder_unref(builder);
508
509                                         netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
510                                                            NETCONFIG_NETWORK_INTERFACE,
511                                                            "NetworkConfigChanged", sig_params);
512                                 }
513
514                                 g_free(property);
515                                 g_variant_unref(var);
516                                 break;
517                         }
518                 }
519
520                 g_variant_iter_free(iter);
521         } else if (g_strcmp0(sigvalue, "IPv4") == 0) {
522                 __netconfig_extract_ipv4_signal_data(variant, path);
523         } else if (g_strcmp0(sigvalue, "IPv6") == 0) {
524                 __netconfig_extract_ipv6_signal_data(variant, path);
525         } else if (g_strcmp0(sigvalue, "Error") == 0) {
526                 g_variant_get(variant, "s", &property);
527                 INFO("[%s] Property : %s", sigvalue, property);
528 #if defined TIZEN_DEBUG_ENABLE
529                 if (g_strcmp0(property, "dhcp-failed") == 0
530                         || g_strcmp0(property, "connect-failed") == 0
531                         || g_strcmp0(property, "login-failed") == 0
532                         || g_strcmp0(property, "auth-failed") == 0
533                         || g_strcmp0(property, "invalid-key") == 0) {
534
535                         INFO("start dump");
536                         _start_dump();
537                 }
538 #endif
539                 g_free(property);
540         }
541 done:
542         g_free(sigvalue);
543
544         if (variant)
545                 g_variant_unref(variant);
546
547         return;
548 }
549
550 static void _dbus_name_changed_cb(GDBusConnection *conn,
551                 const gchar *Name, const gchar *path, const gchar *interface,
552                 const gchar *sig, GVariant *param, gpointer user_data)
553 {
554         gchar *name = NULL;
555         gchar *old = NULL;
556         gchar *new = NULL;
557
558         if (param == NULL)
559                 return;
560
561         g_variant_get(param, "(sss)", &name, &old, &new);
562
563         if (g_strcmp0(name, CONNMAN_SERVICE) == 0 && *new == '\0') {
564                 DBG("ConnMan destroyed: name %s, old %s, new %s", name, old, new);
565
566                 connman_register_agent();
567         }
568         g_free(name);
569         g_free(old);
570         g_free(new);
571
572         return;
573 }
574
575 static void _services_changed_cb(GDBusConnection *conn, const gchar *name,
576                 const gchar *path, const gchar *interface, const gchar *sig,
577                 GVariant *param, gpointer user_data)
578 {
579         gchar *property, *value;
580         gchar *service_path;
581         GVariant *variant = NULL;
582         GVariantIter *added = NULL, *removed = NULL, *next = NULL;
583
584         if (path == NULL || param == NULL)
585                 return;
586
587         if (g_strcmp0(sig, CONNMAN_SIGNAL_SERVICES_CHANGED) != 0)
588                 return;
589
590         if (netconfig_get_default_profile() != NULL)
591                 return;
592
593         g_variant_get(param, "(a(oa{sv})ao)", &added, &removed);
594
595         while (g_variant_iter_loop(added, "(oa{sv})", &service_path, &next)) {
596                 gboolean is_wifi_prof, is_cell_prof, is_cell_internet_prof;
597                 is_wifi_prof = netconfig_is_wifi_profile(service_path);
598                 is_cell_prof = netconfig_is_cellular_profile(service_path);
599                 is_cell_internet_prof = netconfig_is_cellular_internet_profile(
600                                 service_path);
601                 if (service_path != NULL) {
602                         while (next && g_variant_iter_loop(next, "{sv}", &property,
603                                                 &variant)) {
604                                 if (g_strcmp0(property, "State") == 0) {
605                                         g_variant_get(variant, "s", &value);
606                                         DBG("Profile %s State %s", service_path,
607                                                         value);
608                                         if (g_strcmp0(value, "ready") != 0 &&
609                                                         g_strcmp0(value,
610                                                                 "online") != 0) {
611                                                 g_free(property);
612                                                 g_free(value);
613                                                 g_variant_unref(variant);
614                                                 break;
615                                         }
616
617                                         if (!is_cell_prof)
618                                                 netconfig_update_default_profile(
619                                                                 service_path);
620                                         else if (is_cell_internet_prof) {
621                                                 netconfig_update_default_profile(
622                                                                 service_path);
623                                         }
624                                         if (is_wifi_prof)
625                                                 wifi_state_set_service_state(
626                                                         NETCONFIG_WIFI_CONNECTED);
627                                         else if (is_cell_prof &&
628                                                         is_cell_internet_prof)
629                                                 cellular_state_set_service_state(
630                                                         NETCONFIG_CELLULAR_ONLINE);
631                                         g_free(property);
632                                         g_free(value);
633                                         g_variant_unref(variant);
634                                         break;
635                                 }
636                         }
637                 }
638         }
639
640         g_variant_iter_free(added);
641
642         if (next)
643                 g_variant_iter_free(next);
644
645         if (removed)
646                 g_variant_iter_free(removed);
647
648         return;
649 }
650
651 static void _supplicant_interface_removed(GDBusConnection *conn,
652                 const gchar *name, const gchar *path, const gchar *interface,
653                 const gchar *sig, GVariant *param, gpointer user_data)
654 {
655         DBG("Interface removed handling!");
656         if (netconfig_wifi_is_bssid_scan_started() == TRUE)
657                 netconfig_wifi_bssid_signal_scanaborted();
658
659         return;
660 }
661
662 static void _supplicant_properties_changed(GDBusConnection *conn,
663                 const gchar *name, const gchar *path, const gchar *interface,
664                 const gchar *sig, GVariant *param, gpointer user_data)
665 {
666         DBG("Properties changed handling!");
667         gchar *key = NULL;
668         const gchar *state = NULL;
669         GVariantIter *iter = NULL;
670         GVariant *variant = NULL;
671         gboolean scanning = FALSE;
672
673         if (param == NULL)
674                 return;
675
676         g_variant_get(param, "(a{sv})", &iter);
677         while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
678                 if (g_strcmp0(key, "Scanning") == 0) {
679                         scanning = g_variant_get_boolean(variant);
680                         DBG("setting scanning %s", scanning ? "TRUE" : "FALSE");
681                         if (scanning == TRUE)
682                                 netconfig_wifi_set_scanning(TRUE);
683                         else
684                                 netconfig_wifi_set_scanning(FALSE);
685
686                         g_variant_unref(variant);
687                         g_free(key);
688                         variant = NULL;
689                         key = NULL;
690                         break;
691                 } else if (g_strcmp0(key, "State") == 0) {
692                         state = g_variant_get_string(variant, NULL);
693                         if (state != NULL)
694                                 ERR("Supplicant state : %s", state);
695
696                         g_variant_unref(variant);
697                         g_free(key);
698                         variant = NULL;
699                         key = NULL;
700                         break;
701                 } else if (g_strcmp0(key, "DisconnectReason") == 0) {
702                         int reason = g_variant_get_int32(variant);
703                         ERR("Supplicant DisconnReason : %d", reason);
704
705                         g_variant_unref(variant);
706                         g_free(key);
707                         variant = NULL;
708                         key = NULL;
709                         break;
710                 } else {
711                         gchar *value;
712                         value = g_variant_print(variant, TRUE);
713                         DBG("Supplicant %s : %s", key, value);
714
715                         g_free(value);
716                 }
717         }
718
719         g_variant_iter_free(iter);
720
721         return;
722 }
723
724 static void _supplicant_bss_added(GDBusConnection *conn,
725                 const gchar *name, const gchar *path, const gchar *interface,
726                 const gchar *sig, GVariant *param, gpointer user_data)
727 {
728         DBG("BSS added handling!");
729         wifi_state_set_bss_found(TRUE);
730
731         return;
732 }
733
734 static void _supplicant_scan_done(GDBusConnection *conn,
735                 const gchar *name, const gchar *path, const gchar *interface,
736                 const gchar *sig, GVariant *param, gpointer user_data)
737 {
738         DBG("Scan Done handling!");
739         netconfig_wifi_set_scanning(FALSE);
740
741         if (netconfig_wifi_is_bssid_scan_started() == TRUE) {
742                 netconfig_wifi_bssid_signal_scandone();
743                 if (wifi_state_get_technology_state() < NETCONFIG_WIFI_TECH_POWERED)
744                         return;
745         }
746
747         if (netconfig_wifi_get_bgscan_state() == TRUE) {
748                 if (wifi_state_get_technology_state() >=
749                                 NETCONFIG_WIFI_TECH_POWERED)
750                         netconfig_wifi_bgscan_start(FALSE);
751
752                 wifi_start_timer_network_notification();
753         }
754
755         return;
756 }
757
758 static void _supplicant_driver_hanged(GDBusConnection *conn,
759                 const gchar *name, const gchar *path, const gchar *interface,
760                 const gchar *sig, GVariant *param, gpointer user_data)
761 {
762         DBG("Driver Hanged handling!");
763         ERR("Critical. Wi-Fi firmware crashed");
764
765 #if !defined TIZEN_WEARABLE
766         netconfig_send_message_to_net_popup("Wi-Fi Error",
767                 "Wi-Fi Driver Hanged. Please get log dump and report", "popup", NULL);
768 #endif
769         wifi_power_recover_firmware();
770
771         return;
772
773 }
774
775 static void _supplicant_session_overlapped(GDBusConnection *conn,
776                 const gchar *name, const gchar *path, const gchar *interface,
777                 const gchar *sig, GVariant *param, gpointer user_data)
778 {
779         DBG("Driver session overlapped handling!");
780         ERR("WPS PBC SESSION OVERLAPPED");
781 #if defined TIZEN_WEARABLE
782         return;
783 #else
784         netconfig_send_message_to_net_popup("WPS Error",
785                                         "wps session overlapped", "popup", NULL);
786 #endif
787 }
788
789 #if defined TIZEN_DEBUG_ENABLE
790 static void __netconfig_dumpservice_handler(GDBusConnection *conn,
791                 const gchar *name, const gchar *path, const gchar *interface,
792                 const gchar *sig, GVariant *param, gpointer user_data)
793 {
794         int mode;
795         gchar *signal_path = NULL;
796
797         if (param == NULL)
798                 return;
799
800         g_variant_get(param, "(is)", &mode, &signal_path);
801         DBG("Path: %s and mode: %d", signal_path, mode);
802
803         netconfig_dump_log(signal_path);
804         if (signal_path)
805                 g_free(signal_path);
806
807         return;
808 }
809 #endif
810
811 static void _supplicant_tdls_connected(GDBusConnection *conn,
812                 const gchar *name, const gchar *path, const gchar *interface,
813                 const gchar *sig, GVariant *param, gpointer user_data)
814 {
815         DBG("Received TDLS Connected Signal");
816         netconfig_wifi_tdls_connected_event(param);
817
818         return;
819 }
820
821 static void _supplicant_tdls_disconnected(GDBusConnection *conn,
822                 const gchar *name, const gchar *path, const gchar *interface,
823                 const gchar *sig, GVariant *param, gpointer user_data)
824 {
825         DBG("Received TDLS Disconnected Signal");
826         netconfig_wifi_tdls_disconnected_event(param);
827
828         return;
829 }
830
831 static void _supplicant_tdls_peer_found(GDBusConnection *conn,
832                 const gchar *name, const gchar *path, const gchar *interface,
833                 const gchar *sig, GVariant *param, gpointer user_data)
834 {
835         DBG("Received TDLS Peer Found Signal");
836         netconfig_wifi_tdls_peer_found_event(param);
837         return;
838 }
839
840 static void _supplicant_wifi_wps_connected(GVariant *param)
841 {
842         gchar *key;
843         char ssid[32] = {0, };
844         gchar *name;
845         GVariantIter *iter;
846         GVariant *variant;
847         int config_error = 0;
848         int error_indication = 0;
849         gsize ssid_len = 0;
850
851         if (param == NULL) {
852                 ERR("Param is NULL");
853                 return;
854         }
855
856         g_variant_get(param, "(sa{sv})", &name, &iter);
857         INFO("wps Result: %s", name);
858         while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
859                 INFO("wps Key is %s", key);
860                 if (g_strcmp0(key, "SSID") == 0) {
861                         const char *t_key = NULL;
862                         t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar));
863                         INFO("wps ssid_len is %d ", ssid_len);
864                         if (t_key == NULL) {
865                                 g_free(key);
866                                 g_variant_unref(variant);
867                                 ERR("WPS PBC Connection Failed");
868                                 goto error;
869                         }
870                         if (ssid_len > 0 && ssid_len <= 32) {
871                                 memcpy(ssid, t_key, ssid_len);
872                         } else {
873                                 memset(ssid, 0, sizeof(ssid));
874                                 ssid_len = 0;
875                         }
876                         INFO("WPS PBC Connection completed with AP %s", ssid);
877                         netconfig_wifi_notify_wps_completed(ssid, ssid_len);
878                 }
879         }
880
881         g_variant_iter_free(iter);
882         g_free(name);
883         return;
884
885 error:
886         g_variant_iter_free(iter);
887         g_free(name);
888         error_indication = WPS_EI_OPERATION_FAILED;
889         config_error = WPS_CFG_NO_ERROR;
890         ERR("Error Occured! Notifying Fail Event");
891         netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
892
893 }
894
895 static void _supplicant_wifi_wps_event(GVariant *param)
896 {
897         gchar *key;
898         gchar *name;
899         GVariantIter *iter;
900         GVariant *variant;
901         gint32 config_error = 0;
902         gint32 error_indication = 0;
903
904         if (param == NULL) {
905                 ERR("Param is NULL");
906                 return;
907         }
908
909         g_variant_get(param, "(sa{sv})", &name, &iter);
910         INFO("Event Result: %s", name);
911         if (g_strcmp0(name, "fail") == 0) {
912                 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
913                         if (key == NULL)
914                                 goto error;
915                         INFO("Key is %s", key);
916                         if (g_strcmp0(key, "config_error") == 0) {
917                                 config_error = g_variant_get_int32(variant);
918                                 ERR("Config Error %d", config_error);
919                         } else if (g_strcmp0(key, "error_indication") == 0) {
920                                 error_indication = g_variant_get_int32(variant);
921                                 ERR("Error Indication %d", error_indication);
922                         }
923                 }
924                 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
925         }
926
927         g_variant_iter_free(iter);
928         g_free(name);
929         return;
930
931 error:
932         g_variant_iter_free(iter);
933         g_free(name);
934         error_indication = WPS_EI_OPERATION_FAILED;
935         config_error = WPS_CFG_NO_ERROR;
936         ERR("Error Occured! Notifying Fail Event");
937         netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
938 }
939
940 static void _find_service_and_set_passphrase(char *ssid, char *key)
941 {
942         GString *str;
943         GVariant *reply = NULL;
944         int i, j, ssid_len;
945         char *service_path;
946         char *dev_mac_addr;
947         char ident[13];
948         gchar *enc_passphrase;
949
950         ssid_len = strlen(ssid);
951
952         str = g_string_sized_new((ssid_len * 2) + 55);
953         if (!str)
954                 return;
955
956         dev_mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
957         if (!dev_mac_addr) {
958                 ERR("Failed to get mac address from vconf key");
959                 g_string_free(str, TRUE);
960                 return;
961         }
962
963         j = 0;
964         for (i = 0; dev_mac_addr[i]; i++) {
965                 if (dev_mac_addr[i] != ':')
966                         ident[j++] = dev_mac_addr[i];
967         }
968         ident[j] = '\0';
969
970         g_string_append_printf(str, "%s%s_", CONNMAN_WIFI_SERVICE_PROFILE_PREFIX,
971                                                    ident);
972         free(dev_mac_addr);
973
974         for (i = 0; i < ssid_len; i++) {
975                 if (ssid[i] != '"')
976                         g_string_append_printf(str, "%02x", ssid[i]);
977         }
978
979         g_string_append_printf(str, "_managed_psk");
980
981         service_path = g_string_free(str, FALSE);
982
983         enc_passphrase = _netconfig_encrypt_passphrase(key);
984         if (!enc_passphrase) {
985                 ERR("Failed to encrypt passphrase");
986                 g_free(service_path);
987                 return;
988         }
989
990         INFO("wps service_path %s Passphrase %s", service_path, enc_passphrase);
991
992         reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE, service_path,
993                                          CONNMAN_SERVICE_INTERFACE, "SetProperty",
994                                          g_variant_new("(sv)", "Passphrase",
995                                                                    g_variant_new_string(enc_passphrase)));
996         if (reply != NULL)
997                 g_variant_unref(reply);
998         else
999                 ERR("Failed to set passphrase");
1000
1001         g_free(service_path);
1002
1003         return;
1004 }
1005
1006 static void _supplicant_wifi_wps_credentials(GVariant *param)
1007 {
1008         gchar *key;
1009         char ssid[32] = {0, };
1010         char wps_key[100] = {0, };
1011         GVariantIter *iter;
1012         GVariant *variant;
1013         int config_error = 0;
1014         int error_indication = 0;
1015         gsize ssid_len = 0;
1016         char *key_mgmt = NULL;
1017
1018         if (param == NULL) {
1019                 ERR("Param is NULL");
1020                 return;
1021         }
1022
1023         g_variant_get(param, "(a{sv})", &iter);
1024         while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
1025                 if (key == NULL)
1026                         goto error;
1027                 INFO("wps Key is %s", key);
1028                 if (g_strcmp0(key, "Key") == 0) {
1029                         gsize key_len = 0;
1030                         const char *t_key = NULL;
1031                         key_len = g_variant_get_size(variant);
1032
1033                         INFO("wps password len %d ", key_len);
1034                         if (key_len > 0) {
1035                                 t_key = g_variant_get_fixed_array(variant, &key_len,
1036                                                   sizeof(guchar));
1037                                 if (!t_key) {
1038                                         g_free(key);
1039                                         g_variant_unref(variant);
1040                                         goto error;
1041                                 }
1042                                 strncpy(wps_key, t_key, key_len);
1043                                 wps_key[key_len] = '\0';
1044                                 INFO("WPS Key in process credentials %s", wps_key);
1045                         } else
1046                                 SLOGI("WPS AP Security ->Open");
1047                 } else if (g_strcmp0(key, "SSID") == 0) {
1048                         const char *t_key = NULL;
1049                         t_key = g_variant_get_fixed_array(variant, &ssid_len,
1050                                                   sizeof(guchar));
1051                         INFO("wps ssid_len is %d ", ssid_len);
1052                         if (!t_key) {
1053                                 g_free(key);
1054                                 g_variant_unref(variant);
1055                                 goto error;
1056                         }
1057                         if (ssid_len > 0 && ssid_len <= 32) {
1058                                 memcpy(ssid, t_key, ssid_len);
1059                         } else {
1060                                 memset(ssid, 0, sizeof(ssid));
1061                                 ssid_len = 0;
1062                         }
1063                         INFO("SSID in process credentials %s", ssid);
1064                 } else if (g_strcmp0(key, "AuthType") == 0) {
1065                         gchar *auth_type;
1066                         GVariantIter *var_iter;
1067                         g_variant_get(variant, "as", &var_iter);
1068                         while (g_variant_iter_loop(var_iter, "s", &auth_type)) {
1069                                 INFO("wps auth_type %s", auth_type);
1070                                 if (g_strcmp0(auth_type, "wpa-psk") == 0 ||
1071                                         g_strcmp0(auth_type, "wpa2-psk") == 0)
1072                                         key_mgmt = "psk";
1073                                 else if (g_strcmp0(auth_type, "open") == 0)
1074                                         key_mgmt = "none";
1075                         }
1076                         g_variant_iter_free(var_iter);
1077                 } else if (g_strcmp0(key, "EncrType") == 0) {
1078                         gchar *encr_type;
1079                         GVariantIter *var_iter;
1080                         g_variant_get(variant, "as", &var_iter);
1081                         while (g_variant_iter_loop(var_iter, "s", &encr_type))
1082                                 INFO("wps encr_type %s", encr_type);
1083                         g_variant_iter_free(var_iter);
1084                 } else if (g_strcmp0(key, "BSSID") == 0) {
1085                         const guchar *bssid;
1086                         gsize bssid_len;
1087                         bssid = g_variant_get_fixed_array(variant, &bssid_len,
1088                                                                 sizeof(guchar));
1089                         if (bssid && bssid_len == 6)
1090                                 INFO("wps BSSID %2x:%2x:%2x:%2x:%2x:%2x", bssid[0], bssid[1],
1091                                          bssid[2], bssid[3], bssid[4], bssid[5]);
1092                 }
1093         }
1094
1095         g_variant_iter_free(iter);
1096
1097         if (g_strcmp0(key_mgmt, "psk") == 0)
1098                 _find_service_and_set_passphrase(ssid, wps_key);
1099
1100 #if 0
1101         /*
1102          * Notify WPS Credentials only when requested through WPS PBC
1103          * In case of WPS PIN connman will take care of notification
1104          */
1105         if (netconfig_get_wps_field() == TRUE)
1106 #endif
1107         netconfig_wifi_notify_wps_credentials(ssid, ssid_len, wps_key);
1108         return;
1109
1110 error:
1111         g_variant_iter_free(iter);
1112         error_indication = WPS_EI_OPERATION_FAILED;
1113         config_error = WPS_CFG_NO_ERROR;
1114         ERR("Error Occured! Notifying Fail Event");
1115         netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
1116 }
1117
1118 static void __netconfig_wps_signal_filter_handler(GDBusConnection *conn,
1119                 const gchar *name, const gchar *path, const gchar *interface,
1120                 const gchar *sig, GVariant *param, gpointer user_data)
1121 {
1122         if (g_strcmp0(sig, SIGNAL_WPS_CREDENTIALS) == 0) {
1123                 INFO("Received wps CREDENTIALS Signal from Supplicant");
1124                 _supplicant_wifi_wps_credentials(param);
1125         } else if (g_strcmp0(sig, SIGNAL_WPS_EVENT) == 0) {
1126                 INFO("Received wps EVENT Signal from Supplicant");
1127                 _supplicant_wifi_wps_event(param);
1128         } else if (g_strcmp0(sig, SIGNAL_WPS_CONNECTED) == 0) {
1129                 INFO("Received WPSConnected Signal from Supplicant");
1130                 _supplicant_wifi_wps_connected(param);
1131         }
1132
1133         return;
1134 }
1135
1136 static supplicant_signal_cb supplicant_cbs[SIG_MAX] = {
1137                 _supplicant_interface_removed,
1138                 _supplicant_properties_changed,
1139                 _supplicant_bss_added,
1140                 _supplicant_scan_done,
1141                 _supplicant_driver_hanged,
1142                 _supplicant_session_overlapped,
1143                 _supplicant_tdls_connected,
1144                 _supplicant_tdls_disconnected,
1145                 _supplicant_tdls_peer_found
1146 };
1147
1148 void register_gdbus_signal(void)
1149 {
1150         GDBusConnection *connection = NULL;
1151         const char *interface = NULL;
1152         SuppSigArrayIndex sig;
1153         connection = netdbus_get_connection();
1154
1155         if (connection == NULL) {
1156                 ERR("Failed to get GDbus Connection");
1157                 return;
1158         }
1159
1160         /* listening to messages from all objects as no path is specified */
1161         /* see signals from the given interface */
1162         conn_subscription_ids[0] = g_dbus_connection_signal_subscribe(
1163                         connection,
1164                         CONNMAN_SERVICE,
1165                         CONNMAN_TECHNOLOGY_INTERFACE,
1166                         NULL,
1167                         NULL,
1168                         NULL,
1169                         G_DBUS_SIGNAL_FLAGS_NONE,
1170                         _technology_signal_cb,
1171                         NULL,
1172                         NULL);
1173
1174         conn_subscription_ids[1] = g_dbus_connection_signal_subscribe(
1175                         connection,
1176                         CONNMAN_SERVICE,
1177                         CONNMAN_SERVICE_INTERFACE,
1178                         CONNMAN_SIGNAL_PROPERTY_CHANGED,
1179                         NULL,
1180                         NULL,
1181                         G_DBUS_SIGNAL_FLAGS_NONE,
1182                         _service_signal_cb,
1183                         NULL,
1184                         NULL);
1185
1186         conn_subscription_ids[2] = g_dbus_connection_signal_subscribe(
1187                         connection,
1188                         DBUS_SERVICE_DBUS,
1189                         DBUS_INTERFACE_DBUS,
1190                         CONNMAN_SIGNAL_NAME_CHANGED,
1191                         NULL,
1192                         CONNMAN_SERVICE,
1193                         G_DBUS_SIGNAL_FLAGS_NONE,
1194                         _dbus_name_changed_cb,
1195                         NULL,
1196                         NULL);
1197
1198         conn_subscription_ids[3] = g_dbus_connection_signal_subscribe(
1199                         connection,
1200                         CONNMAN_SERVICE,
1201                         CONNMAN_MANAGER_INTERFACE,
1202                         CONNMAN_SIGNAL_SERVICES_CHANGED,
1203                         NULL,
1204                         NULL,
1205                         G_DBUS_SIGNAL_FLAGS_NONE,
1206                         _services_changed_cb,
1207                         NULL,
1208                         NULL);
1209
1210         INFO("Successfully register connman DBus signal filters");
1211
1212         conn_subscription_ids[4] = g_dbus_connection_signal_subscribe(
1213                         connection,
1214                         SUPPLICANT_SERVICE,
1215                         SUPPLICANT_INTERFACE ".Interface.WPS",
1216                         NULL,
1217                         NULL,
1218                         NULL,
1219                         G_DBUS_SIGNAL_FLAGS_NONE,
1220                         __netconfig_wps_signal_filter_handler,
1221                         NULL,
1222                         NULL);
1223
1224         INFO("Successfully register Supplicant WPS DBus signal filters");
1225
1226         for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
1227                 /*
1228                  * For SIG_INTERFACE_REMOVED INTERFACE_ADDED
1229                  */
1230                 interface = (sig == SIG_INTERFACE_REMOVED) ?
1231                                 SUPPLICANT_INTERFACE : SUPPLICANT_IFACE_INTERFACE;
1232
1233                 supp_subscription_ids[sig] = g_dbus_connection_signal_subscribe(
1234                                 connection,
1235                                 SUPPLICANT_SERVICE,
1236                                 interface,
1237                                 supplicant_signals[sig],
1238                                 NULL,
1239                                 NULL,
1240                                 G_DBUS_SIGNAL_FLAGS_NONE,
1241                                 supplicant_cbs[sig],
1242                                 NULL,
1243                                 NULL);
1244         }
1245
1246         INFO("Successfully register Supplicant DBus signal filters");
1247
1248 #if defined TIZEN_DEBUG_ENABLE
1249         dumpservice_subscription_id = g_dbus_connection_signal_subscribe(
1250                         connection,
1251                         NULL,
1252                         DUMP_SERVICE_INTERFACE,
1253                         DUMP_SIGNAL,
1254                         NULL,
1255                         NULL,
1256                         G_DBUS_SIGNAL_FLAGS_NONE,
1257                         __netconfig_dumpservice_handler,
1258                         NULL,
1259                         NULL);
1260
1261         INFO("Successfully registered Dumpservice DBus signal filter");
1262 #endif
1263
1264         /* In case ConnMan precedes this signal register,
1265          * net-config should update the default connected profile.
1266          */
1267         netconfig_update_default();
1268 }
1269
1270 void deregister_gdbus_signal(void)
1271 {
1272         GDBusConnection *connection = NULL;
1273         int signal;
1274         SuppSigArrayIndex sig;
1275         connection = netdbus_get_connection();
1276         if (!connection) {
1277                 ERR("Already de-registered. Nothing to be done");
1278                 return;
1279         }
1280
1281         for (signal = 0; signal < TOTAL_CONN_SIGNALS; signal++) {
1282                 if (conn_subscription_ids[signal]) {
1283                         g_dbus_connection_signal_unsubscribe(connection,
1284                                                 conn_subscription_ids[signal]);
1285                 }
1286         }
1287
1288         for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
1289                 if (supp_subscription_ids[sig]) {
1290                         g_dbus_connection_signal_unsubscribe(connection,
1291                                                 supp_subscription_ids[sig]);
1292                 }
1293         }
1294
1295 #if defined TIZEN_DEBUG_ENABLE
1296         g_dbus_connection_signal_unsubscribe(connection,
1297                         dumpservice_subscription_id);
1298 #endif
1299 }