element: Remove device code
[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_NETWORK    = 4,
46 };
47
48 enum connman_element_state {
49         CONNMAN_ELEMENT_STATE_UNKNOWN = 0,
50         CONNMAN_ELEMENT_STATE_ERROR   = 1,
51         CONNMAN_ELEMENT_STATE_IDLE    = 2,
52         CONNMAN_ELEMENT_STATE_DONE    = 3,
53 };
54
55 enum connman_element_error {
56         CONNMAN_ELEMENT_ERROR_UNKNOWN        = 0,
57         CONNMAN_ELEMENT_ERROR_FAILED         = 1,
58 };
59
60 struct connman_driver;
61
62 struct connman_element {
63         gint refcount;
64         gint index;
65         gchar *name;
66         gchar *path;
67         enum connman_element_type type;
68         enum connman_element_state state;
69         enum connman_element_error error;
70         gboolean enabled;
71         gchar *devname;
72
73         GHashTable *children;
74         struct connman_element *parent;
75
76         struct connman_driver *driver;
77         void *driver_data;
78
79         void (*destruct) (struct connman_element *element);
80
81         union {
82                 void *private;
83                 struct connman_network *network;
84         };
85
86         GHashTable *properties;
87 };
88
89 struct connman_element *connman_element_create(const char *name);
90 struct connman_element *connman_element_ref(struct connman_element *element);
91 void connman_element_unref(struct connman_element *element);
92
93 int connman_element_get_value(struct connman_element *element,
94                                 enum connman_property_id id, void *value);
95
96 int connman_element_set_string(struct connman_element *element,
97                                         const char *key, const char *value);
98 const char *connman_element_get_string(struct connman_element *element,
99                                                         const char *key);
100 int connman_element_set_bool(struct connman_element *element,
101                                 const char *key, connman_bool_t value);
102 connman_bool_t connman_element_get_bool(struct connman_element *element,
103                                                         const char *key);
104 int connman_element_set_uint8(struct connman_element *element,
105                                 const char *key, connman_uint8_t value);
106 connman_uint8_t connman_element_get_uint8(struct connman_element *element,
107                                                         const char *key);
108 int connman_element_set_blob(struct connman_element *element,
109                         const char *key, const void *data, unsigned int size);
110 const void *connman_element_get_blob(struct connman_element *element,
111                                         const char *key, unsigned int *size);
112
113 int connman_element_register(struct connman_element *element,
114                                         struct connman_element *parent);
115 void connman_element_unregister(struct connman_element *element);
116 void connman_element_unregister_children(struct connman_element *element);
117
118 #ifdef __cplusplus
119 }
120 #endif
121
122 #endif /* __CONNMAN_ELEMENT_H */