Remove syspopup
[platform/core/connectivity/net-config.git] / src / network-state.c
1 /*
2  * Network Configuration Module
3  *
4  * Copyright (c) 2012-2013 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 <vconf.h>
21 #include <vconf-keys.h>
22 #include <notification.h>
23
24 #include "wifi.h"
25 #include "log.h"
26 #include "util.h"
27 #include "netdbus.h"
28 #include "neterror.h"
29 #include "emulator.h"
30 #include "wifi-state.h"
31 #include "network-state.h"
32
33 #define NETCONFIG_NETWORK_STATE_PATH    "/net/netconfig/network"
34 #define ROUTE_EXEC_PATH                 "/sbin/route"
35
36 #define PROP_DEFAULT            FALSE
37 #define PROP_DEFAULT_STR   NULL
38
39
40 gboolean netconfig_iface_network_state_add_route(
41                 NetconfigNetworkState *master,
42                 gchar *ip_addr, gchar *netmask,
43                 gchar *interface, gboolean *result, GError **error);
44
45 gboolean netconfig_iface_network_state_remove_route(
46                 NetconfigNetworkState *master,
47                 gchar *ip_addr, gchar *netmask,
48                 gchar *interface, gboolean *result, GError **error);
49
50 #include "netconfig-iface-network-state-glue.h"
51
52 enum {
53         PROP_O,
54         PROP_NETWORK_STATE_CONN,
55         PROP_NETWORK_STATE_PATH,
56 };
57
58 struct NetconfigNetworkStateClass {
59         GObjectClass parent;
60 };
61
62 struct NetconfigNetworkState {
63         GObject parent;
64
65         DBusGConnection *conn;
66         gchar *path;
67 };
68
69 G_DEFINE_TYPE(NetconfigNetworkState, netconfig_network_state, G_TYPE_OBJECT);
70
71
72 static void __netconfig_network_state_gobject_get_property(GObject *object,
73                 guint prop_id, GValue *value, GParamSpec *pspec)
74 {
75         return;
76 }
77
78 static void __netconfig_network_state_gobject_set_property(GObject *object,
79                 guint prop_id, const GValue *value, GParamSpec *pspec)
80 {
81         NetconfigNetworkState *network_state = NETCONFIG_NETWORK_STATE(object);
82
83         switch (prop_id) {
84         case PROP_NETWORK_STATE_CONN:
85         {
86                 network_state->conn = g_value_get_boxed(value);
87                 INFO("network_state(%p) set conn(%p)", network_state, network_state->conn);
88                 break;
89         }
90
91         case PROP_NETWORK_STATE_PATH:
92         {
93                 if (network_state->path)
94                         g_free(network_state->path);
95
96                 network_state->path = g_value_dup_string(value);
97                 INFO("network_state(%p) path(%s)", network_state, network_state->path);
98
99                 break;
100         }
101
102         default:
103                 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
104         }
105 }
106
107 static void netconfig_network_state_init(NetconfigNetworkState *network_state)
108 {
109         DBG("network_state initialize");
110
111         network_state->conn = NULL;
112         network_state->path = g_strdup(PROP_DEFAULT_STR);
113 }
114
115 static void netconfig_network_state_class_init(NetconfigNetworkStateClass *klass)
116 {
117         GObjectClass *object_class = G_OBJECT_CLASS(klass);
118
119         DBG("class initialize");
120
121         object_class->get_property = __netconfig_network_state_gobject_get_property;
122         object_class->set_property = __netconfig_network_state_gobject_set_property;
123
124         /* DBus register */
125         dbus_g_object_type_install_info(NETCONFIG_TYPE_NETWORK_STATE,
126                         &dbus_glib_netconfig_iface_network_state_object_info);
127
128         /* property */
129         g_object_class_install_property(object_class, PROP_NETWORK_STATE_CONN,
130                         g_param_spec_boxed("conn", "CONNECTION", "DBus connection",
131                                         DBUS_TYPE_G_CONNECTION,
132                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
133
134         g_object_class_install_property(object_class, PROP_NETWORK_STATE_PATH,
135                         g_param_spec_string("path", "Path", "Object path",
136                                         PROP_DEFAULT_STR,
137                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
138 }
139
140 struct netconfig_default_connection {
141         char *profile;
142         char *ifname;
143         char *ipaddress;
144         char *proxy;
145         char *essid;
146 };
147
148 static struct netconfig_default_connection
149                                 netconfig_default_connection_info;
150
151 static void __netconfig_pop_3g_alert_syspoppup(void)
152 {
153         int rv = 0;
154         int wifi_ug_state = 0;
155         notification_error_e err = NOTIFICATION_ERROR_NONE;
156
157         vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &wifi_ug_state);
158         if (wifi_ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND)
159                 return;
160
161         DBG("Launch 3G alert network popup");
162         // TODO : display a popup
163
164         notification_h noti = NULL;
165
166         noti = notification_create(NOTIFICATION_TYPE_NOTI);
167         if (noti == NULL) {
168                 ERR("Failed to create notification \n");
169                 return;
170         }
171
172         err = notification_set_pkgname(noti, NET_CONFIG_APP_NAME);
173         if (err != NOTIFICATION_ERROR_NONE) {
174                 ERR("Unable to set pkgname \n");
175                 return;
176         }
177
178         err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Cellular connection popup", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
179         if (err != NOTIFICATION_ERROR_NONE) {
180                 ERR("Unable to set notification title \n");
181                 return;
182         }
183
184         err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Connected" , NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
185         if (err != NOTIFICATION_ERROR_NONE) {
186                 ERR("Unable to set notification content \n");
187                 return;
188         }
189
190         err = notification_insert(noti, NULL);
191         if (err != NOTIFICATION_ERROR_NONE) {
192                 ERR("Unable to insert notification \n");
193                 return;
194         }
195
196 }
197
198 static gboolean __netconfig_is_connected(const char *profile)
199 {
200         gboolean is_connected = FALSE;
201         DBusMessage *message = NULL;
202         DBusMessageIter iter, array;
203
204         if (profile == NULL)
205                 return FALSE;
206
207         message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, profile,
208                         CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL);
209         if (message == NULL) {
210                 ERR("Failed to get service properties");
211                 return is_connected;
212         }
213
214         if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
215                 const char *ptr = dbus_message_get_error_name(message);
216                 ERR("Error!!! Error message received [%s]", ptr);
217                 goto done;
218         }
219
220         dbus_message_iter_init(message, &iter);
221         dbus_message_iter_recurse(&iter, &array);
222
223         while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
224                 DBusMessageIter entry, string;
225                 const char *key = NULL;
226
227                 dbus_message_iter_recurse(&array, &entry);
228                 dbus_message_iter_get_basic(&entry, &key);
229
230                 if (g_str_equal(key, "State") == TRUE) {
231                         dbus_message_iter_next(&entry);
232                         dbus_message_iter_recurse(&entry, &string);
233
234                         if (dbus_message_iter_get_arg_type(&string) == DBUS_TYPE_STRING) {
235                                 dbus_message_iter_get_basic(&string, &key);
236
237                                 if (g_str_equal(key, "ready") == TRUE ||
238                                                 g_str_equal(key, "online") == TRUE) {
239                                         is_connected = TRUE;
240
241                                         break;
242                                 }
243                         }
244                 }
245
246                 dbus_message_iter_next(&array);
247         }
248
249 done:
250         if (message != NULL)
251                 dbus_message_unref(message);
252
253         return is_connected;
254 }
255
256 static char *__netconfig_get_default_profile(void)
257 {
258         DBusMessage *message = NULL;
259         GSList *service_profiles = NULL;
260         GSList *list = NULL;
261         DBusMessageIter iter, dict;
262         char *default_profile = NULL;
263
264         message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
265                         CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
266                         "GetServices", NULL);
267         if (message == NULL) {
268                 ERR("Failed to get profiles");
269                 return NULL;
270         }
271
272         dbus_message_iter_init(message, &iter);
273         dbus_message_iter_recurse(&iter, &dict);
274
275         while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_STRUCT) {
276                 DBusMessageIter entry;
277                 const char *object_path = NULL;
278
279                 dbus_message_iter_recurse(&dict, &entry);
280                 dbus_message_iter_get_basic(&entry, &object_path);
281
282                 if (object_path)
283                         service_profiles = g_slist_append(
284                                                 service_profiles,
285                                                 g_strdup(object_path));
286
287                 dbus_message_iter_next(&dict);
288         }
289
290         for (list = service_profiles; list != NULL; list = list->next) {
291                 char *profile_path = list->data;
292
293                 if (__netconfig_is_connected((const char *)profile_path) == TRUE) {
294                         default_profile = g_strdup(profile_path);
295                         break;
296                 }
297         }
298
299         g_slist_free(service_profiles);
300
301         dbus_message_unref(message);
302
303         return default_profile;
304 }
305
306 static void __netconfig_get_default_connection_info(const char *profile)
307 {
308         DBusMessage *message = NULL;
309         DBusMessageIter iter, array;
310
311         message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, profile,
312                         CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL);
313         if (message == NULL) {
314                 ERR("Failed to get service properties");
315                 return;
316         }
317
318         if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
319                 const char *ptr = dbus_message_get_error_name(message);
320                 ERR("Error!!! Error message received [%s]", ptr);
321                 goto done;
322         }
323
324         dbus_message_iter_init(message, &iter);
325         dbus_message_iter_recurse(&iter, &array);
326
327         while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
328                 DBusMessageIter entry, variant, string, iter1, iter2, iter3;
329                 const char *key = NULL, *value = NULL;
330
331                 dbus_message_iter_recurse(&array, &entry);
332                 dbus_message_iter_get_basic(&entry, &key);
333
334                 if (g_str_equal(key, "Name") == TRUE &&
335                                 netconfig_is_wifi_profile(profile) == TRUE) {
336                         dbus_message_iter_next(&entry);
337                         dbus_message_iter_recurse(&entry, &string);
338
339                         if (dbus_message_iter_get_arg_type(&string) == DBUS_TYPE_STRING) {
340                                 dbus_message_iter_get_basic(&string, &value);
341
342                                 netconfig_default_connection_info.essid = g_strdup(value);
343                         }
344                 } else if (g_str_equal(key, "Ethernet") == TRUE) {
345                         dbus_message_iter_next(&entry);
346                         dbus_message_iter_recurse(&entry, &variant);
347                         dbus_message_iter_recurse(&variant, &iter1);
348
349                         while (dbus_message_iter_get_arg_type(&iter1)
350                                         == DBUS_TYPE_DICT_ENTRY) {
351                                 dbus_message_iter_recurse(&iter1, &iter2);
352                                 dbus_message_iter_get_basic(&iter2, &key);
353
354                                 if (g_str_equal(key, "Interface") == TRUE) {
355                                         dbus_message_iter_next(&iter2);
356                                         dbus_message_iter_recurse(&iter2, &iter3);
357                                         dbus_message_iter_get_basic(&iter3, &value);
358
359                                         netconfig_default_connection_info.ifname = g_strdup(value);
360                                 }
361
362                                 dbus_message_iter_next(&iter1);
363                         }
364                 } else if (g_str_equal(key, "IPv4") == TRUE) {
365                         dbus_message_iter_next(&entry);
366                         dbus_message_iter_recurse(&entry, &variant);
367                         dbus_message_iter_recurse(&variant, &iter1);
368
369                         while (dbus_message_iter_get_arg_type(&iter1)
370                                         == DBUS_TYPE_DICT_ENTRY) {
371                                 dbus_message_iter_recurse(&iter1, &iter2);
372                                 dbus_message_iter_get_basic(&iter2, &key);
373
374                                 if (g_str_equal(key, "Address") == TRUE) {
375                                         dbus_message_iter_next(&iter2);
376                                         dbus_message_iter_recurse(&iter2, &iter3);
377                                         dbus_message_iter_get_basic(&iter3, &value);
378
379                                         netconfig_default_connection_info.ipaddress = g_strdup(value);
380                                 }
381
382                                 dbus_message_iter_next(&iter1);
383                         }
384                 } else if (g_str_equal(key, "IPv6") == TRUE) {
385                         dbus_message_iter_next(&entry);
386                         dbus_message_iter_recurse(&entry, &variant);
387                         dbus_message_iter_recurse(&variant, &iter1);
388
389                         while (dbus_message_iter_get_arg_type(&iter1)
390                                         == DBUS_TYPE_DICT_ENTRY) {
391                                 dbus_message_iter_recurse(&iter1, &iter2);
392                                 dbus_message_iter_get_basic(&iter2, &key);
393
394                                 if (g_str_equal(key, "Address") == TRUE) {
395                                         dbus_message_iter_next(&iter2);
396                                         dbus_message_iter_recurse(&iter2, &iter3);
397                                         dbus_message_iter_get_basic(&iter3, &value);
398
399                                         netconfig_default_connection_info.ipaddress = g_strdup(value);
400                                 }
401
402                                 dbus_message_iter_next(&iter1);
403                         }
404                 } else if (g_str_equal(key, "Proxy") == TRUE) {
405                         dbus_message_iter_next(&entry);
406                         dbus_message_iter_recurse(&entry, &variant);
407                         dbus_message_iter_recurse(&variant, &iter1);
408
409                         while (dbus_message_iter_get_arg_type(&iter1)
410                                         == DBUS_TYPE_DICT_ENTRY) {
411                                 DBusMessageIter iter4;
412
413                                 dbus_message_iter_recurse(&iter1, &iter2);
414                                 dbus_message_iter_get_basic(&iter2, &key);
415
416                                 if (g_str_equal(key, "Servers") == TRUE) {
417                                         dbus_message_iter_next(&iter2);
418                                         dbus_message_iter_recurse(&iter2, &iter3);
419                                         if (dbus_message_iter_get_arg_type(&iter3)
420                                                         != DBUS_TYPE_ARRAY)
421                                                 break;
422
423                                         dbus_message_iter_recurse(&iter3, &iter4);
424                                         if (dbus_message_iter_get_arg_type(&iter4)
425                                                         != DBUS_TYPE_STRING)
426                                                 break;
427
428                                         dbus_message_iter_get_basic(&iter4, &value);
429                                         if (value != NULL && (strlen(value) > 0))
430                                                 netconfig_default_connection_info.proxy = g_strdup(value);
431
432                                 } else if (g_str_equal(key, "Method") == TRUE) {
433                                         dbus_message_iter_next(&iter2);
434                                         dbus_message_iter_recurse(&iter2, &iter3);
435                                         if (dbus_message_iter_get_arg_type(&iter3)
436                                                         != DBUS_TYPE_STRING)
437                                                 break;
438
439                                         dbus_message_iter_get_basic(&iter3, &value);
440                                         if (g_strcmp0(value, "direct") == 0) {
441                                                 g_free(netconfig_default_connection_info.proxy);
442                                                 netconfig_default_connection_info.proxy = NULL;
443
444                                                 break;
445                                         }
446                                 }
447
448                                 dbus_message_iter_next(&iter1);
449                         }
450                 }
451
452                 dbus_message_iter_next(&array);
453         }
454
455 done:
456         if (message != NULL)
457                 dbus_message_unref(message);
458 }
459
460 static void __netconfig_update_default_connection_info(void)
461 {
462         int old_network_status = 0;
463         const char *profile = netconfig_get_default_profile();
464         const char *ip_addr = netconfig_get_default_ipaddress();
465         const char *proxy_addr = netconfig_get_default_proxy();
466
467         if (netconfig_emulator_is_emulated() == TRUE)
468                 return;
469
470         if (profile == NULL)
471                 DBG("Reset network state configuration");
472         else
473                 DBG("%s: ip(%s) proxy(%s)", profile, ip_addr, proxy_addr);
474
475         vconf_get_int(VCONFKEY_NETWORK_STATUS, &old_network_status);
476
477         if (profile == NULL && old_network_status != VCONFKEY_NETWORK_OFF) {
478                 vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_OFF);
479
480                 vconf_set_str(VCONFKEY_NETWORK_IP, "");
481                 vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
482
483                 vconf_set_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 0);
484
485                 DBG("Successfully clear IP and PROXY up");
486         } else if (profile != NULL) {
487                 char *old_ip = vconf_get_str(VCONFKEY_NETWORK_IP);
488                 char *old_proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
489
490                 if (netconfig_is_wifi_profile(profile) == TRUE) {
491                         vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_WIFI);
492                 } else if (netconfig_is_cellular_profile(profile) == TRUE) {
493                         vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_CELLULAR);
494
495                         if (old_network_status != VCONFKEY_NETWORK_CELLULAR)
496                                 __netconfig_pop_3g_alert_syspoppup();
497                 } else if (netconfig_is_ethernet_profile(profile) == TRUE) {
498                         vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_ETHERNET);
499                 } else if (netconfig_is_bluetooth_profile(profile) == TRUE) {
500                         vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_BLUETOOTH);
501                 } else {
502                         vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_OFF);
503                 }
504
505                 if (g_strcmp0(old_ip, ip_addr) != 0) {
506                         if (ip_addr == NULL)
507                                 vconf_set_str(VCONFKEY_NETWORK_IP, "");
508                         else
509                                 vconf_set_str(VCONFKEY_NETWORK_IP, ip_addr);
510                 }
511
512                 if (g_strcmp0(old_proxy, proxy_addr) != 0) {
513                         if (proxy_addr == NULL)
514                                 vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
515                         else
516                                 vconf_set_str(VCONFKEY_NETWORK_PROXY, proxy_addr);
517                 }
518
519                 vconf_set_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 1);
520
521                 DBG("Successfully update default network configuration");
522         }
523 }
524
525 const char *netconfig_get_default_profile(void)
526 {
527         return netconfig_default_connection_info.profile;
528 }
529
530 const char *netconfig_get_default_ipaddress(void)
531 {
532         return netconfig_default_connection_info.ipaddress;
533 }
534
535 const char *netconfig_get_default_proxy(void)
536 {
537         return netconfig_default_connection_info.proxy;
538 }
539
540 const char *netconfig_wifi_get_connected_essid(const char *default_profile)
541 {
542         if (default_profile == NULL)
543                 return NULL;
544
545         if (netconfig_is_wifi_profile(default_profile) != TRUE)
546                 return NULL;
547
548         if (g_str_equal(default_profile, netconfig_default_connection_info.profile)
549                         != TRUE)
550                 return NULL;
551
552         return netconfig_default_connection_info.essid;
553 }
554
555 void netconfig_set_default_profile(const char *profile)
556 {
557         char *default_profile = NULL;
558
559         /* It's automatically updated by signal-handler
560          * DO NOT update manually
561          *
562          * It is going to update default connection information
563          */
564         if (netconfig_default_connection_info.profile != NULL) {
565                 g_free(netconfig_default_connection_info.profile);
566                 netconfig_default_connection_info.profile = NULL;
567
568                 g_free(netconfig_default_connection_info.ifname);
569                 netconfig_default_connection_info.ifname = NULL;
570
571                 g_free(netconfig_default_connection_info.ipaddress);
572                 netconfig_default_connection_info.ipaddress = NULL;
573
574                 g_free(netconfig_default_connection_info.proxy);
575                 netconfig_default_connection_info.proxy = NULL;
576
577                 if (netconfig_wifi_state_get_service_state()
578                                 != NETCONFIG_WIFI_CONNECTED) {
579                         g_free(netconfig_default_connection_info.essid);
580                         netconfig_default_connection_info.essid = NULL;
581                 }
582         }
583
584         if (profile == NULL) {
585                 default_profile = __netconfig_get_default_profile();
586                 if (default_profile == NULL) {
587                         __netconfig_update_default_connection_info();
588                         return;
589                 }
590         }
591
592         if (profile != NULL)
593                 netconfig_default_connection_info.profile = g_strdup(profile);
594         else
595                 netconfig_default_connection_info.profile = default_profile;
596
597         __netconfig_get_default_connection_info(
598                         netconfig_default_connection_info.profile);
599
600         __netconfig_update_default_connection_info();
601 }
602
603 gboolean netconfig_iface_network_state_add_route(
604                 NetconfigNetworkState *master,
605                 gchar *ip_addr, gchar *netmask,
606                 gchar *interface, gboolean *result, GError **error)
607 {
608         gboolean ret = FALSE;
609         gboolean rv = FALSE;
610         const char *path = ROUTE_EXEC_PATH;
611         char *const args[] = {"route", "add",
612                                 "-net", ip_addr,
613                                 "netmask", netmask,
614                                 "dev", interface,
615                                 0};
616         char *const envs[] = { NULL };
617
618         DBG("ip_addr(%s), netmask(%s), interface(%s)", ip_addr, netmask, interface);
619
620         if (ip_addr == NULL || netmask == NULL || interface == NULL) {
621                 DBG("Invalid parameter!");
622                 goto done;
623         }
624
625         rv = netconfig_execute_file(path, args, envs);
626         if (rv != TRUE) {
627                 DBG("Failed to add a new route");
628                 goto done;
629         }
630
631         DBG("Successfully added a new route");
632         ret = TRUE;
633
634 done:
635         *result = ret;
636         return ret;
637 }
638
639 gboolean netconfig_iface_network_state_remove_route(
640                 NetconfigNetworkState *master,
641                 gchar *ip_addr, gchar *netmask,
642                 gchar *interface, gboolean *result, GError **error)
643 {
644         gboolean ret = FALSE;
645         gboolean rv = FALSE;
646         const char *path = ROUTE_EXEC_PATH;
647         char *const args[] = {"route", "del",
648                                 "-net", ip_addr,
649                                 "netmask", netmask,
650                                 "dev", interface,
651                                 0};
652         char *const envs[] = { NULL };
653
654         DBG("ip_addr(%s), netmask(%s), interface(%s)", ip_addr, netmask, interface);
655
656         if (ip_addr == NULL || netmask == NULL || interface == NULL) {
657                 DBG("Invalid parameter!");
658                 goto done;
659         }
660
661         rv = netconfig_execute_file(path, args, envs);
662         if (rv != TRUE) {
663                 DBG("Failed to remove a new route");
664                 goto done;
665         }
666
667         DBG("Successfully remove a new route");
668         ret = TRUE;
669
670 done:
671         *result = ret;
672         return ret;
673 }
674
675 gpointer netconfig_network_state_create_and_init(DBusGConnection *conn)
676 {
677         GObject *object;
678
679         g_return_val_if_fail(conn != NULL, NULL);
680
681         object = g_object_new(NETCONFIG_TYPE_NETWORK_STATE, "conn", conn, "path",
682                         NETCONFIG_NETWORK_STATE_PATH, NULL);
683
684         INFO("create network_state(%p)", object);
685
686         dbus_g_connection_register_g_object(conn, NETCONFIG_NETWORK_STATE_PATH, object);
687
688         INFO("network_state(%p) register DBus path(%s)", object, NETCONFIG_NETWORK_STATE_PATH);
689
690         return object;
691 }