element: Remove left overs from clean
[framework/connectivity/connman.git] / include / element.h
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2010  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifndef __CONNMAN_ELEMENT_H
23 #define __CONNMAN_ELEMENT_H
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <errno.h>
30 #include <glib.h>
31
32 #include <connman/property.h>
33 #include <connman/types.h>
34 #include <connman/ipconfig.h>
35
36 /**
37  * SECTION:element
38  * @title: Element premitives
39  * @short_description: Functions for handling elements
40  */
41
42 enum connman_element_type {
43         CONNMAN_ELEMENT_TYPE_UNKNOWN    = 0,
44         CONNMAN_ELEMENT_TYPE_ROOT       = 1,
45         CONNMAN_ELEMENT_TYPE_DEVICE     = 3,
46         CONNMAN_ELEMENT_TYPE_NETWORK    = 4,
47 };
48
49 enum connman_element_state {
50         CONNMAN_ELEMENT_STATE_UNKNOWN = 0,
51         CONNMAN_ELEMENT_STATE_ERROR   = 1,
52         CONNMAN_ELEMENT_STATE_IDLE    = 2,
53         CONNMAN_ELEMENT_STATE_DONE    = 3,
54 };
55
56 enum connman_element_error {
57         CONNMAN_ELEMENT_ERROR_UNKNOWN        = 0,
58         CONNMAN_ELEMENT_ERROR_FAILED         = 1,
59 };
60
61 struct connman_driver;
62
63 struct connman_element {
64         gint refcount;
65         gint index;
66         gchar *name;
67         gchar *path;
68         enum connman_element_type type;
69         enum connman_element_state state;
70         enum connman_element_error error;
71         gboolean enabled;
72         gchar *devname;
73
74         GHashTable *children;
75         struct connman_element *parent;
76
77         struct connman_driver *driver;
78         void *driver_data;
79
80         void (*destruct) (struct connman_element *element);
81
82         union {
83                 void *private;
84                 struct connman_device *device;
85                 struct connman_network *network;
86         };
87
88         GHashTable *properties;
89 };
90
91 struct connman_element *connman_element_create(const char *name);
92 struct connman_element *connman_element_ref(struct connman_element *element);
93 void connman_element_unref(struct connman_element *element);
94
95 int connman_element_get_value(struct connman_element *element,
96                                 enum connman_property_id id, void *value);
97
98 int connman_element_set_string(struct connman_element *element,
99                                         const char *key, const char *value);
100 const char *connman_element_get_string(struct connman_element *element,
101                                                         const char *key);
102 int connman_element_set_bool(struct connman_element *element,
103                                 const char *key, connman_bool_t value);
104 connman_bool_t connman_element_get_bool(struct connman_element *element,
105                                                         const char *key);
106 int connman_element_set_uint8(struct connman_element *element,
107                                 const char *key, connman_uint8_t value);
108 connman_uint8_t connman_element_get_uint8(struct connman_element *element,
109                                                         const char *key);
110 int connman_element_set_blob(struct connman_element *element,
111                         const char *key, const void *data, unsigned int size);
112 const void *connman_element_get_blob(struct connman_element *element,
113                                         const char *key, unsigned int *size);
114
115 int connman_element_register(struct connman_element *element,
116                                         struct connman_element *parent);
117 void connman_element_unregister(struct connman_element *element);
118 void connman_element_unregister_children(struct connman_element *element);
119
120 #ifdef __cplusplus
121 }
122 #endif
123
124 #endif /* __CONNMAN_ELEMENT_H */