From: Daniel Wagner <[email protected]>

---
 Makefile.am        |    4 +-
 include/driver.h   |    3 -
 include/element.h  |  120 -------
 plugins/ofono.c    |    1 -
 src/6to4.c         |    1 +
 src/config.c       |    1 +
 src/connman.h      |   25 +--
 src/counter.c      |    2 +
 src/element.c      |  897 ----------------------------------------------------
 src/ipconfig.c     |    1 +
 src/location.c     |    2 +
 src/main.c         |   32 ++-
 src/manager.c      |    2 +
 src/profile.c      |    1 +
 src/provider.c     |    1 +
 src/rtnl.c         |    1 +
 src/service.c      |    1 +
 src/session.c      |    2 +
 src/stats.c        |    1 +
 src/storage.c      |    1 +
 src/task.c         |    1 +
 src/technology.c   |    1 +
 src/tethering.c    |    1 +
 src/timeserver.c   |    2 +
 src/timezone.c     |    1 +
 src/wpad.c         |    1 +
 unit/session-api.c |    2 +
 27 files changed, 58 insertions(+), 1050 deletions(-)
 delete mode 100644 include/element.h
 delete mode 100644 src/element.c

diff --git a/Makefile.am b/Makefile.am
index 76a75ab..d0bef44 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,7 +11,7 @@ include_HEADERS = include/types.h include/log.h 
include/plugin.h \
 
 nodist_include_HEADERS = include/version.h
 
-noinst_HEADERS = include/driver.h include/element.h include/property.h \
+noinst_HEADERS = include/driver.h include/property.h \
                        include/rtnl.h include/wifi.h include/task.h \
                        include/dbus.h include/rfkill.h include/option.h \
                        include/profile.h include/provider.h \
@@ -70,7 +70,7 @@ src_connmand_SOURCES = $(gdbus_sources) $(gdhcp_sources) \
                        gweb/giognutls.h gweb/gionotls.c \
                        $(builtin_sources) src/connman.ver \
                        src/main.c src/connman.h src/log.c \
-                       src/error.c src/plugin.c src/task.c src/element.c \
+                       src/error.c src/plugin.c src/task.c \
                        src/device.c src/network.c src/connection.c \
                        src/manager.c src/profile.c src/service.c \
                        src/clock.c src/timezone.c \
diff --git a/include/driver.h b/include/driver.h
index 7c4f405..ae1e9a7 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -26,8 +26,6 @@
 extern "C" {
 #endif
 
-#include <connman/element.h>
-
 /**
  * SECTION:driver
  * @title: Driver premitives
@@ -40,7 +38,6 @@ extern "C" {
 
 struct connman_driver {
        const char *name;
-       enum connman_element_type type;
        int priority;
        int (*probe) (struct connman_element *element);
        void (*remove) (struct connman_element *element);
diff --git a/include/element.h b/include/element.h
deleted file mode 100644
index 3499cdf..0000000
--- a/include/element.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- *
- *  Connection Manager
- *
- *  Copyright (C) 2007-2010  Intel Corporation. All rights reserved.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 2 as
- *  published by the Free Software Foundation.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#ifndef __CONNMAN_ELEMENT_H
-#define __CONNMAN_ELEMENT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <errno.h>
-#include <glib.h>
-
-#include <connman/property.h>
-#include <connman/types.h>
-#include <connman/ipconfig.h>
-
-/**
- * SECTION:element
- * @title: Element premitives
- * @short_description: Functions for handling elements
- */
-
-enum connman_element_type {
-       CONNMAN_ELEMENT_TYPE_UNKNOWN    = 0,
-       CONNMAN_ELEMENT_TYPE_ROOT       = 1,
-};
-
-enum connman_element_state {
-       CONNMAN_ELEMENT_STATE_UNKNOWN = 0,
-       CONNMAN_ELEMENT_STATE_ERROR   = 1,
-       CONNMAN_ELEMENT_STATE_IDLE    = 2,
-       CONNMAN_ELEMENT_STATE_DONE    = 3,
-};
-
-enum connman_element_error {
-       CONNMAN_ELEMENT_ERROR_UNKNOWN        = 0,
-       CONNMAN_ELEMENT_ERROR_FAILED         = 1,
-};
-
-struct connman_driver;
-
-struct connman_element {
-       gint refcount;
-       gint index;
-       gchar *name;
-       gchar *path;
-       enum connman_element_type type;
-       enum connman_element_state state;
-       enum connman_element_error error;
-       gboolean enabled;
-       gchar *devname;
-
-       GHashTable *children;
-       struct connman_element *parent;
-
-       struct connman_driver *driver;
-       void *driver_data;
-
-       void (*destruct) (struct connman_element *element);
-
-       union {
-               void *private;
-       };
-
-       GHashTable *properties;
-};
-
-struct connman_element *connman_element_create(const char *name);
-struct connman_element *connman_element_ref(struct connman_element *element);
-void connman_element_unref(struct connman_element *element);
-
-int connman_element_get_value(struct connman_element *element,
-                               enum connman_property_id id, void *value);
-
-int connman_element_set_string(struct connman_element *element,
-                                       const char *key, const char *value);
-const char *connman_element_get_string(struct connman_element *element,
-                                                       const char *key);
-int connman_element_set_bool(struct connman_element *element,
-                               const char *key, connman_bool_t value);
-connman_bool_t connman_element_get_bool(struct connman_element *element,
-                                                       const char *key);
-int connman_element_set_uint8(struct connman_element *element,
-                               const char *key, connman_uint8_t value);
-connman_uint8_t connman_element_get_uint8(struct connman_element *element,
-                                                       const char *key);
-int connman_element_set_blob(struct connman_element *element,
-                       const char *key, const void *data, unsigned int size);
-const void *connman_element_get_blob(struct connman_element *element,
-                                       const char *key, unsigned int *size);
-
-int connman_element_register(struct connman_element *element,
-                                       struct connman_element *parent);
-void connman_element_unregister(struct connman_element *element);
-void connman_element_unregister_children(struct connman_element *element);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CONNMAN_ELEMENT_H */
diff --git a/plugins/ofono.c b/plugins/ofono.c
index 01b2b8b..a8482e7 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -32,7 +32,6 @@
 
 #define CONNMAN_API_SUBJECT_TO_CHANGE
 #include <connman/plugin.h>
-#include <connman/element.h>
 #include <connman/device.h>
 #include <connman/network.h>
 #include <connman/ipconfig.h>
diff --git a/src/6to4.c b/src/6to4.c
index 5e75223..b66ef5c 100644
--- a/src/6to4.c
+++ b/src/6to4.c
@@ -24,6 +24,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/socket.h>
diff --git a/src/config.c b/src/config.c
index 7700db2..bb6027f 100644
--- a/src/config.c
+++ b/src/config.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
diff --git a/src/connman.h b/src/connman.h
index 198b1f7..446ce17 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -175,32 +175,13 @@ int __connman_storage_save_service(struct connman_service 
*service);
 int __connman_storage_load_device(struct connman_device *device);
 int __connman_storage_save_device(struct connman_device *device);
 
+int __connman_detect_init(void);
+void __connman_detect_cleanup(void);
+
 #include <connman/driver.h>
 
 void __connman_driver_rescan(struct connman_driver *driver);
 
-#include <connman/element.h>
-
-int __connman_element_init(void);
-void __connman_element_start(void);
-void __connman_element_stop(void);
-void __connman_element_cleanup(void);
-
-void __connman_element_initialize(struct connman_element *element);
-
-typedef void (* element_cb_t) (struct connman_element *element,
-                                                       gpointer user_data);
-
-void __connman_element_foreach(struct connman_element *element,
-                               enum connman_element_type type,
-                               element_cb_t callback, gpointer user_data);
-void __connman_element_list(struct connman_element *element,
-                                       enum connman_element_type type,
-                                                       DBusMessageIter *iter);
-
-int __connman_detect_init(void);
-void __connman_detect_cleanup(void);
-
 #include <connman/proxy.h>
 
 int __connman_proxy_init(void);
diff --git a/src/counter.c b/src/counter.c
index 4fc4748..7f1c014 100644
--- a/src/counter.c
+++ b/src/counter.c
@@ -23,6 +23,8 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
+
 #include <gdbus.h>
 
 #include "connman.h"
diff --git a/src/element.c b/src/element.c
deleted file mode 100644
index 75d5126..0000000
--- a/src/element.c
+++ /dev/null
@@ -1,897 +0,0 @@
-/*
- *
- *  Connection Manager
- *
- *  Copyright (C) 2007-2010  Intel Corporation. All rights reserved.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 2 as
- *  published by the Free Software Foundation.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <errno.h>
-#include <stdarg.h>
-#include <string.h>
-
-#include <glib.h>
-#include <gdbus.h>
-
-#include "connman.h"
-
-static DBusConnection *connection;
-
-static GNode *element_root = NULL;
-static GSList *driver_list = NULL;
-
-static gboolean started = FALSE;
-
-static const char *type2string(enum connman_element_type type)
-{
-       switch (type) {
-       case CONNMAN_ELEMENT_TYPE_UNKNOWN:
-               return "unknown";
-       case CONNMAN_ELEMENT_TYPE_ROOT:
-               return "root";
-       }
-
-       return NULL;
-}
-
-struct foreach_data {
-       enum connman_element_type type;
-       element_cb_t callback;
-       gpointer user_data;
-};
-
-static gboolean foreach_callback(GNode *node, gpointer user_data)
-{
-       struct connman_element *element = node->data;
-       struct foreach_data *data = user_data;
-
-       DBG("element %p name %s", element, element->name);
-
-       if (element->type == CONNMAN_ELEMENT_TYPE_ROOT)
-               return FALSE;
-
-       if (data->type != CONNMAN_ELEMENT_TYPE_UNKNOWN &&
-                                       data->type != element->type)
-               return FALSE;
-
-       if (data->callback)
-               data->callback(element, data->user_data);
-
-       return FALSE;
-}
-
-void __connman_element_foreach(struct connman_element *element,
-                               enum connman_element_type type,
-                               element_cb_t callback, gpointer user_data)
-{
-       struct foreach_data data = { type, callback, user_data };
-       GNode *node;
-
-       DBG("");
-
-       if (element != NULL) {
-               node = g_node_find(element_root, G_PRE_ORDER,
-                                               G_TRAVERSE_ALL, element);
-               if (node == NULL)
-                       return;
-       } else
-               node = element_root;
-
-       g_node_traverse(node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
-                                               foreach_callback, &data);
-}
-
-struct append_filter {
-       enum connman_element_type type;
-       DBusMessageIter *iter;
-};
-
-static gboolean append_path(GNode *node, gpointer user_data)
-{
-       struct connman_element *element = node->data;
-       struct append_filter *filter = user_data;
-
-       DBG("element %p name %s", element, element->name);
-
-       if (element->type == CONNMAN_ELEMENT_TYPE_ROOT)
-               return FALSE;
-
-       if (filter->type != CONNMAN_ELEMENT_TYPE_UNKNOWN &&
-                                       filter->type != element->type)
-               return FALSE;
-
-       dbus_message_iter_append_basic(filter->iter,
-                               DBUS_TYPE_OBJECT_PATH, &element->path);
-
-       return FALSE;
-}
-
-void __connman_element_list(struct connman_element *element,
-                                       enum connman_element_type type,
-                                                       DBusMessageIter *iter)
-{
-       struct append_filter filter = { type, iter };
-       GNode *node;
-
-       DBG("");
-
-       if (element != NULL) {
-               node = g_node_find(element_root, G_PRE_ORDER,
-                                               G_TRAVERSE_ALL, element);
-               if (node == NULL)
-                       return;
-       } else
-               node = element_root;
-
-       g_node_traverse(node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
-                                               append_path, &filter);
-}
-
-static gint compare_priority(gconstpointer a, gconstpointer b)
-{
-       const struct connman_driver *driver1 = a;
-       const struct connman_driver *driver2 = b;
-
-       return driver2->priority - driver1->priority;
-}
-
-static gboolean match_driver(struct connman_element *element,
-                                       struct connman_driver *driver)
-{
-       if (element->type == CONNMAN_ELEMENT_TYPE_ROOT)
-               return FALSE;
-
-       if (element->type == driver->type ||
-                       driver->type == CONNMAN_ELEMENT_TYPE_UNKNOWN)
-               return TRUE;
-
-       return FALSE;
-}
-
-static gboolean probe_driver(GNode *node, gpointer data)
-{
-       struct connman_element *element = node->data;
-       struct connman_driver *driver = data;
-
-       DBG("element %p name %s", element, element->name);
-
-       if (!element->driver && match_driver(element, driver) == TRUE) {
-               if (driver->probe(element) < 0)
-                       return FALSE;
-
-               element->driver = driver;
-       }
-
-       return FALSE;
-}
-
-void __connman_driver_rescan(struct connman_driver *driver)
-{
-       DBG("driver %p name %s", driver, driver->name);
-
-       if (!driver->probe)
-               return;
-
-       if (element_root != NULL)
-               g_node_traverse(element_root, G_PRE_ORDER,
-                               G_TRAVERSE_ALL, -1, probe_driver, driver);
-}
-
-/**
- * connman_driver_register:
- * @driver: driver definition
- *
- * Register a new driver
- *
- * Returns: %0 on success
- */
-int connman_driver_register(struct connman_driver *driver)
-{
-       DBG("driver %p name %s", driver, driver->name);
-
-       if (driver->type == CONNMAN_ELEMENT_TYPE_ROOT)
-               return -EINVAL;
-
-       if (!driver->probe)
-               return -EINVAL;
-
-       driver_list = g_slist_insert_sorted(driver_list, driver,
-                                                       compare_priority);
-
-       if (started == FALSE)
-               return 0;
-
-       if (element_root != NULL)
-               g_node_traverse(element_root, G_PRE_ORDER,
-                               G_TRAVERSE_ALL, -1, probe_driver, driver);
-
-       return 0;
-}
-
-static gboolean remove_driver(GNode *node, gpointer data)
-{
-       struct connman_element *element = node->data;
-       struct connman_driver *driver = data;
-
-       DBG("element %p name %s", element, element->name);
-
-       if (element->driver == driver) {
-               if (driver->remove)
-                       driver->remove(element);
-
-               element->driver = NULL;
-       }
-
-       return FALSE;
-}
-
-/**
- * connman_driver_unregister:
- * @driver: driver definition
- *
- * Remove a previously registered driver
- */
-void connman_driver_unregister(struct connman_driver *driver)
-{
-       DBG("driver %p name %s", driver, driver->name);
-
-       driver_list = g_slist_remove(driver_list, driver);
-
-       if (element_root != NULL)
-               g_node_traverse(element_root, G_POST_ORDER,
-                               G_TRAVERSE_ALL, -1, remove_driver, driver);
-}
-
-static void unregister_property(gpointer data)
-{
-       struct connman_property *property = data;
-
-       DBG("property %p", property);
-
-       g_free(property->value);
-       g_free(property);
-}
-
-static void unregister_child(gpointer data)
-{
-       struct connman_element *element = data;
-
-       DBG("element %p", element);
-
-       connman_element_unref(element);
-}
-
-void __connman_element_initialize(struct connman_element *element)
-{
-       DBG("element %p", element);
-
-       element->refcount = 1;
-
-       element->name    = NULL;
-       element->type    = CONNMAN_ELEMENT_TYPE_UNKNOWN;
-       element->state   = CONNMAN_ELEMENT_STATE_UNKNOWN;
-       element->error   = CONNMAN_ELEMENT_ERROR_UNKNOWN;
-       element->index   = -1;
-       element->enabled = FALSE;
-
-       element->children = g_hash_table_new_full(g_str_hash, g_str_equal,
-                                               NULL, unregister_child);
-
-       element->properties = g_hash_table_new_full(g_str_hash, g_str_equal,
-                                               g_free, unregister_property);
-}
-
-/**
- * connman_element_create:
- * @name: element name
- *
- * Allocate a new element and assign the given #name to it. If the name
- * is #NULL, it will be later on created based on the element type.
- *
- * Returns: a newly-allocated #connman_element structure
- */
-struct connman_element *connman_element_create(const char *name)
-{
-       struct connman_element *element;
-
-       element = g_try_new0(struct connman_element, 1);
-       if (element == NULL)
-               return NULL;
-
-       DBG("element %p", element);
-
-       __connman_element_initialize(element);
-
-       element->name = g_strdup(name);
-
-       return element;
-}
-
-struct connman_element *connman_element_ref(struct connman_element *element)
-{
-       DBG("element %p name %s refcount %d", element, element->name,
-                               g_atomic_int_get(&element->refcount) + 1);
-
-       g_atomic_int_inc(&element->refcount);
-
-       return element;
-}
-
-static void free_properties(struct connman_element *element)
-{
-       DBG("element %p name %s", element, element->name);
-
-       g_hash_table_destroy(element->properties);
-       element->properties = NULL;
-}
-
-static void free_children(struct connman_element *element)
-{
-       DBG("element %p name %s", element, element->name);
-
-       g_hash_table_destroy(element->children);
-       element->children = NULL;
-}
-
-void connman_element_unref(struct connman_element *element)
-{
-       DBG("element %p name %s refcount %d", element, element->name,
-                               g_atomic_int_get(&element->refcount) - 1);
-
-       if (g_atomic_int_dec_and_test(&element->refcount) == TRUE) {
-               if (element->destruct)
-                       element->destruct(element);
-               free_children(element);
-               free_properties(element);
-               g_free(element->devname);
-               g_free(element->path);
-               g_free(element->name);
-               g_free(element);
-       }
-}
-
-static int set_static_property(struct connman_element *element,
-                               const char *name, int type, const void *value)
-{
-       struct connman_property *property;
-
-       DBG("element %p name %s", element, element->name);
-
-       if (type != DBUS_TYPE_STRING && type != DBUS_TYPE_BYTE)
-               return -EINVAL;
-
-       property = g_try_new0(struct connman_property, 1);
-       if (property == NULL)
-               return -ENOMEM;
-
-       property->id   = CONNMAN_PROPERTY_ID_INVALID;
-       property->type = type;
-
-       DBG("name %s type %d value %p", name, type, value);
-
-       switch (type) {
-       case DBUS_TYPE_STRING:
-               property->value = g_strdup(*((const char **) value));
-               break;
-       case DBUS_TYPE_BOOLEAN:
-       case DBUS_TYPE_BYTE:
-               property->value = g_try_malloc(1);
-               if (property->value != NULL)
-                       memcpy(property->value, value, 1);
-               break;
-       }
-
-       g_hash_table_replace(element->properties, g_strdup(name), property);
-
-       return 0;
-}
-
-static int set_static_array_property(struct connman_element *element,
-                       const char *name, int type, const void *value, int len)
-{
-       struct connman_property *property;
-
-       DBG("element %p name %s", element, element->name);
-
-       if (type != DBUS_TYPE_BYTE)
-               return -EINVAL;
-
-       property = g_try_new0(struct connman_property, 1);
-       if (property == NULL)
-               return -ENOMEM;
-
-       property->id      = CONNMAN_PROPERTY_ID_INVALID;
-       property->type    = DBUS_TYPE_ARRAY;
-       property->subtype = type;
-
-       DBG("name %s type %d value %p", name, type, value);
-
-       switch (type) {
-       case DBUS_TYPE_BYTE:
-               property->value = g_try_malloc(len);
-               if (property->value != NULL) {
-                       memcpy(property->value,
-                               *((const unsigned char **) value), len);
-                       property->size = len;
-               }
-               break;
-       }
-
-       g_hash_table_replace(element->properties, g_strdup(name), property);
-
-       return 0;
-}
-
-int connman_element_get_value(struct connman_element *element,
-                               enum connman_property_id id, void *value)
-{
-       return -EINVAL;
-}
-
-static gboolean get_static_property(struct connman_element *element,
-                                               const char *name, void *value)
-{
-       struct connman_property *property;
-       gboolean found = FALSE;
-
-       DBG("element %p name %s", element, element->name);
-
-       property = g_hash_table_lookup(element->properties, name);
-       if (property != NULL) {
-               switch (property->type) {
-               case DBUS_TYPE_STRING:
-                       *((char **) value) = property->value;
-                       found = TRUE;
-                       break;
-               case DBUS_TYPE_BOOLEAN:
-               case DBUS_TYPE_BYTE:
-                       memcpy(value, property->value, 1);
-                       found = TRUE;
-                       break;
-               }
-       }
-
-       if (found == FALSE && element->parent != NULL)
-               return get_static_property(element->parent, name, value);
-
-       return found;
-}
-
-static gboolean get_static_array_property(struct connman_element *element,
-                       const char *name, void *value, unsigned int *len)
-{
-       struct connman_property *property;
-       gboolean found = FALSE;
-
-       DBG("element %p name %s", element, element->name);
-
-       property = g_hash_table_lookup(element->properties, name);
-       if (property != NULL) {
-               *((void **) value) = property->value;
-               *len = property->size;
-               found = TRUE;
-       }
-
-       return found;
-}
-
-/**
- * connman_element_set_string:
- * @element: element structure
- * @key: unique identifier
- * @value: string value
- *
- * Set string value for specific key
- */
-int connman_element_set_string(struct connman_element *element,
-                                       const char *key, const char *value)
-{
-       return set_static_property(element, key, DBUS_TYPE_STRING, &value);
-}
-
-/**
- * connman_element_get_string:
- * @element: element structure
- * @key: unique identifier
- *
- * Get string value for specific key
- */
-const char *connman_element_get_string(struct connman_element *element,
-                                                       const char *key)
-{
-       const char *value;
-
-       if (get_static_property(element, key, &value) == FALSE)
-               return NULL;
-
-       return value;
-}
-
-/**
- * connman_element_set_bool:
- * @element: element structure
- * @key: unique identifier
- * @value: boolean value
- *
- * Set boolean value for specific key
- */
-int connman_element_set_bool(struct connman_element *element,
-                                       const char *key, connman_bool_t value)
-{
-       return set_static_property(element, key, DBUS_TYPE_BOOLEAN, &value);
-}
-
-/**
- * connman_element_get_bool:
- * @element: element structure
- * @key: unique identifier
- *
- * Get boolean value for specific key
- */
-connman_bool_t connman_element_get_bool(struct connman_element *element,
-                                                       const char *key)
-{
-       connman_bool_t value;
-
-       if (get_static_property(element, key, &value) == FALSE)
-               return FALSE;
-
-       return value;
-}
-
-/**
- * connman_element_set_uint8:
- * @element: element structure
- * @key: unique identifier
- * @value: integer value
- *
- * Set integer value for specific key
- */
-int connman_element_set_uint8(struct connman_element *element,
-                                       const char *key, connman_uint8_t value)
-{
-       return set_static_property(element, key, DBUS_TYPE_BYTE, &value);
-}
-
-/**
- * connman_element_get_uint8:
- * @element: element structure
- * @key: unique identifier
- *
- * Get integer value for specific key
- */
-connman_uint8_t connman_element_get_uint8(struct connman_element *element,
-                                                       const char *key)
-{
-       connman_uint8_t value;
-
-       if (get_static_property(element, key, &value) == FALSE)
-               return 0;
-
-       return value;
-}
-
-/**
- * connman_element_set_blob:
- * @element: element structure
- * @key: unique identifier
- * @data: blob data
- * @size: blob size
- *
- * Set binary blob value for specific key
- */
-int connman_element_set_blob(struct connman_element *element,
-                       const char *key, const void *data, unsigned int size)
-{
-       return set_static_array_property(element, key,
-                                               DBUS_TYPE_BYTE, &data, size);
-}
-
-/**
- * connman_element_get_blob:
- * @element: element structure
- * @key: unique identifier
- * @size: pointer to blob size
- *
- * Get binary blob value for specific key
- */
-const void *connman_element_get_blob(struct connman_element *element,
-                                       const char *key, unsigned int *size)
-{
-       void *value;
-
-       if (get_static_array_property(element, key, &value, size) == FALSE)
-               return NULL;
-
-       return value;
-}
-
-static void probe_element(struct connman_element *element)
-{
-       GSList *list;
-
-       DBG("element %p name %s", element, element->name);
-
-       for (list = driver_list; list; list = list->next) {
-               struct connman_driver *driver = list->data;
-
-               if (match_driver(element, driver) == FALSE)
-                       continue;
-
-               DBG("driver %p name %s", driver, driver->name);
-
-               if (driver->probe(element) == 0) {
-                       element->driver = driver;
-                       break;
-               }
-       }
-}
-
-static void register_element(gpointer data, gpointer user_data)
-{
-       struct connman_element *element = data;
-       const gchar *basepath;
-       GNode *node;
-
-       if (element->parent) {
-               node = g_node_find(element_root, G_PRE_ORDER,
-                                       G_TRAVERSE_ALL, element->parent);
-               basepath = element->parent->path;
-       } else {
-               element->parent = element_root->data;
-
-               node = element_root;
-               basepath = CONNMAN_PATH "/device";
-       }
-
-       element->path = g_strdup_printf("%s/%s", basepath, element->name);
-
-       if (node == NULL) {
-               connman_error("Element registration for %s failed",
-                                                       element->path);
-               return;
-       }
-
-       DBG("element %p path %s", element, element->path);
-
-       g_node_append_data(node, element);
-
-       if (started == FALSE)
-               return;
-
-       probe_element(element);
-}
-
-/**
- * connman_element_register:
- * @element: the element to register
- * @parent: the parent to register the element with
- *
- * Register an element with the core. It will be register under the given
- * parent of if %NULL is provided under the root element.
- *
- * Returns: %0 on success
- */
-int connman_element_register(struct connman_element *element,
-                                       struct connman_element *parent)
-{
-       DBG("element %p name %s parent %p", element, element->name, parent);
-
-       if (element->devname == NULL)
-               element->devname = g_strdup(element->name);
-
-       if (connman_element_ref(element) == NULL)
-               return -EINVAL;
-
-       if (element->name == NULL) {
-               element->name = g_strdup(type2string(element->type));
-               if (element->name == NULL) {
-                       return -EINVAL;
-               }
-       }
-
-       element->parent = parent;
-
-       register_element(element, NULL);
-
-       return 0;
-}
-
-static gboolean remove_element(GNode *node, gpointer user_data)
-{
-       struct connman_element *element = node->data;
-       struct connman_element *root = user_data;
-
-       DBG("element %p name %s", element, element->name);
-
-       if (element == root)
-               return FALSE;
-
-       g_node_unlink(node);
-
-       if (element->driver) {
-               if (element->driver->remove)
-                       element->driver->remove(element);
-
-               element->driver = NULL;
-       }
-
-       g_node_destroy(node);
-
-       connman_element_unref(element);
-
-       return FALSE;
-}
-
-void connman_element_unregister(struct connman_element *element)
-{
-       GNode *node;
-
-       DBG("element %p name %s", element, element->name);
-
-       node = g_node_find(element_root, G_PRE_ORDER, G_TRAVERSE_ALL, element);
-
-       if (node != NULL)
-               g_node_traverse(node, G_POST_ORDER,
-                               G_TRAVERSE_ALL, -1, remove_element, NULL);
-}
-
-void connman_element_unregister_children(struct connman_element *element)
-{
-       GNode *node;
-
-       DBG("element %p name %s", element, element->name);
-
-       node = g_node_find(element_root, G_PRE_ORDER, G_TRAVERSE_ALL, element);
-
-       if (node != NULL)
-               g_node_traverse(node, G_POST_ORDER,
-                               G_TRAVERSE_ALL, -1, remove_element, element);
-}
-
-int __connman_element_init()
-{
-       struct connman_element *element;
-
-       DBG("");
-
-       connection = connman_dbus_get_connection();
-       if (connection == NULL)
-               return -EIO;
-       element = connman_element_create("root");
-
-       element->path = g_strdup("/");
-       element->type = CONNMAN_ELEMENT_TYPE_ROOT;
-
-       element_root = g_node_new(element);
-
-       __connman_technology_init();
-       __connman_notifier_init();
-       __connman_location_init();
-       __connman_service_init();
-       __connman_provider_init();
-       __connman_network_init();
-
-       return 0;
-}
-
-static gboolean probe_node(GNode *node, gpointer data)
-{
-       struct connman_element *element = node->data;
-
-       DBG("element %p name %s", element, element->name);
-
-       if (element->type == CONNMAN_ELEMENT_TYPE_ROOT)
-               return FALSE;
-
-       if (element->driver)
-               return FALSE;
-
-       probe_element(element);
-
-       return FALSE;
-}
-
-void __connman_element_start(void)
-{
-       DBG("");
-
-       __connman_storage_init_profile();
-
-       g_node_traverse(element_root, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
-                                                       probe_node, NULL);
-
-       started = TRUE;
-
-       __connman_rtnl_start();
-
-       __connman_dhcp_init();
-       __connman_wpad_init();
-       __connman_wispr_init();
-
-       __connman_rfkill_init();
-}
-
-void __connman_element_stop(void)
-{
-       DBG("");
-
-       __connman_rfkill_cleanup();
-
-       __connman_wispr_cleanup();
-       __connman_wpad_cleanup();
-       __connman_dhcp_cleanup();
-       __connman_provider_cleanup();
-}
-
-static gboolean free_driver(GNode *node, gpointer data)
-{
-       struct connman_element *element = node->data;
-
-       DBG("element %p name %s", element, element->name);
-
-       if (element->driver) {
-               if (element->driver->remove)
-                       element->driver->remove(element);
-
-               element->driver = NULL;
-       }
-
-       return FALSE;
-}
-
-static gboolean free_node(GNode *node, gpointer data)
-{
-       struct connman_element *element = node->data;
-
-       DBG("element %p name %s", element, element->name);
-
-       if (g_node_depth(node) > 1)
-               connman_element_unregister(element);
-
-       return FALSE;
-}
-
-void __connman_element_cleanup(void)
-{
-       DBG("");
-
-       __connman_network_cleanup();
-       __connman_service_cleanup();
-       __connman_location_cleanup();
-       __connman_notifier_cleanup();
-       __connman_technology_cleanup();
-
-       g_node_traverse(element_root, G_POST_ORDER, G_TRAVERSE_ALL, -1,
-                                                       free_driver, NULL);
-
-       g_node_traverse(element_root, G_POST_ORDER, G_TRAVERSE_ALL, -1,
-                                                       free_node, NULL);
-
-       connman_element_unref(element_root->data);
-
-       g_node_destroy(element_root);
-       element_root = NULL;
-
-       if (connection == NULL)
-               return;
-
-       dbus_connection_unref(connection);
-}
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 986943f..700f4a6 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <stdio.h>
 #include <net/if.h>
 #include <net/if_arp.h>
diff --git a/src/location.c b/src/location.c
index ccfb2ed..dece833 100644
--- a/src/location.c
+++ b/src/location.c
@@ -23,6 +23,8 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
+
 #include "connman.h"
 
 struct connman_location {
diff --git a/src/main.c b/src/main.c
index 0de8cd1..d020a58 100644
--- a/src/main.c
+++ b/src/main.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -264,7 +265,12 @@ int main(int argc, char *argv[])
        parse_config(config);
 
        __connman_storage_init();
-       __connman_element_init();
+       __connman_technology_init();
+       __connman_notifier_init();
+       __connman_location_init();
+       __connman_service_init();
+       __connman_provider_init();
+       __connman_network_init();
        __connman_device_init(option_device, option_nodevice);
 
        __connman_agent_init();
@@ -289,7 +295,16 @@ int main(int argc, char *argv[])
 
        __connman_plugin_init(option_plugin, option_noplugin);
 
-       __connman_element_start();
+       __connman_storage_init_profile();
+
+       __connman_rtnl_start();
+
+       __connman_dhcp_init();
+       __connman_wpad_init();
+       __connman_wispr_init();
+       __connman_plugin_cleanup();
+
+       __connman_rfkill_init();
 
        g_free(option_device);
        g_free(option_plugin);
@@ -303,9 +318,12 @@ int main(int argc, char *argv[])
 
        g_main_loop_run(main_loop);
 
-       __connman_element_stop();
+       __connman_rfkill_cleanup();
 
-       __connman_plugin_cleanup();
+       __connman_wispr_cleanup();
+       __connman_wpad_cleanup();
+       __connman_dhcp_cleanup();
+       __connman_provider_cleanup();
 
        __connman_connection_cleanup();
        __connman_timeserver_cleanup();
@@ -328,7 +346,11 @@ int main(int argc, char *argv[])
        __connman_iptables_cleanup();
 
        __connman_device_cleanup();
-       __connman_element_cleanup();
+       __connman_network_cleanup();
+       __connman_service_cleanup();
+       __connman_location_cleanup();
+       __connman_notifier_cleanup();
+       __connman_technology_cleanup();
        __connman_storage_cleanup();
 
        __connman_dbus_cleanup();
diff --git a/src/manager.c b/src/manager.c
index 40736af..e883364 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -23,6 +23,8 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
+
 #include <gdbus.h>
 
 #include "connman.h"
diff --git a/src/profile.c b/src/profile.c
index a16336e..0df255a 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <string.h>
 
 #include <glib.h>
diff --git a/src/provider.c b/src/provider.c
index fb236e8..01e8ffc 100644
--- a/src/provider.c
+++ b/src/provider.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
diff --git a/src/rtnl.c b/src/rtnl.c
index 6002b5b..d605917 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
diff --git a/src/service.c b/src/service.c
index b95d567..19b45ee 100644
--- a/src/service.c
+++ b/src/service.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <stdio.h>
 #include <string.h>
 #include <gdbus.h>
diff --git a/src/session.c b/src/session.c
index d068087..91758e2 100644
--- a/src/session.c
+++ b/src/session.c
@@ -24,6 +24,8 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
+
 #include <gdbus.h>
 
 #include "connman.h"
diff --git a/src/stats.c b/src/stats.c
index 1a6b3e5..743b795 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -24,6 +24,7 @@
 #endif
 
 #define _GNU_SOURCE
+#include <errno.h>
 #include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/src/storage.c b/src/storage.c
index 800acfa..81f9ecd 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <unistd.h>
 
 #include "connman.h"
diff --git a/src/task.c b/src/task.c
index 37bbe71..b5b9ef7 100644
--- a/src/task.c
+++ b/src/task.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <unistd.h>
 #include <stdarg.h>
 #include <sys/wait.h>
diff --git a/src/technology.c b/src/technology.c
index dc8b845..c68a649 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <string.h>
 
 #include <gdbus.h>
diff --git a/src/tethering.c b/src/tethering.c
index 95ddce6..fbb9e77 100644
--- a/src/tethering.c
+++ b/src/tethering.c
@@ -24,6 +24,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
diff --git a/src/timeserver.c b/src/timeserver.c
index 3224f47..038d44b 100644
--- a/src/timeserver.c
+++ b/src/timeserver.c
@@ -23,6 +23,8 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
+
 #include <glib.h>
 
 #include "connman.h"
diff --git a/src/timezone.c b/src/timezone.c
index faf4488..c6d8d68 100644
--- a/src/timezone.c
+++ b/src/timezone.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <unistd.h>
diff --git a/src/wpad.c b/src/wpad.c
index 450a163..0069c49 100644
--- a/src/wpad.c
+++ b/src/wpad.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/unit/session-api.c b/unit/session-api.c
index 63d6c46..480a1ac 100644
--- a/unit/session-api.c
+++ b/unit/session-api.c
@@ -23,6 +23,8 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
+
 #include <gdbus/gdbus.h>
 
 #include "test-connman.h"
-- 
1.7.5.2

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to