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