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