dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / hal / hald / device.h
bloba9531baf33fbb1b0026269bb44f73d2dc909fb3f
1 /***************************************************************************
2 * CVSID: $Id$
4 * device.c : HalDevice methods
6 * Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
7 * Copyright (C) 2004 Novell, Inc.
9 * Licensed under the Academic Free License version 2.1
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 **************************************************************************/
27 #ifndef DEVICE_H
28 #define DEVICE_H
30 #include <glib-object.h>
31 #include <dbus/dbus.h>
33 #include "property.h"
35 typedef struct _HalDevice HalDevice;
36 typedef struct _HalDeviceClass HalDeviceClass;
38 struct _HalDevice {
39 GObject parent;
41 char *udi;
43 GSList *properties;
45 int num_addons;
46 int num_addons_ready;
49 struct _HalDeviceClass {
50 GObjectClass parent_class;
52 /* signals */
53 void (*property_changed) (HalDevice *device,
54 const char *key,
55 gboolean removed,
56 gboolean added);
58 void (*capability_added) (HalDevice *device,
59 const char *capability);
61 void (*callouts_finished) (HalDevice *device);
63 void (*cancelled) (HalDevice *device);
66 #define HAL_TYPE_DEVICE (hal_device_get_type ())
67 #define HAL_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
68 HAL_TYPE_DEVICE, HalDevice))
69 #define HAL_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
70 HAL_TYPE_DEVICE, HalDeviceClass))
71 #define HAL_IS_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
72 HAL_TYPE_DEVICE))
73 #define HAL_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
74 HAL_TYPE_DEVICE))
76 typedef void (*HalDeviceAsyncCallback) (HalDevice *device,
77 gpointer user_data,
78 gboolean prop_exists);
80 /* Return value of FALSE means that the foreach should be short-circuited */
81 typedef gboolean (*HalDevicePropertyForeachFn) (HalDevice *device,
82 HalProperty *property,
83 gpointer user_data);
85 GType hal_device_get_type (void);
87 HalDevice *hal_device_new (void);
89 void hal_device_merge (HalDevice *target,
90 HalDevice *source);
92 void hal_device_merge_with_rewrite (HalDevice *target,
93 HalDevice *source,
94 const char *target_namespace,
95 const char *source_namespace);
97 gboolean hal_device_matches (HalDevice *device1,
98 HalDevice *device2,
99 const char *namespace);
101 const char *hal_device_get_udi (HalDevice *device);
102 void hal_device_set_udi (HalDevice *device,
103 const char *udi);
105 void hal_device_add_capability (HalDevice *device,
106 const char *capability);
107 gboolean hal_device_has_capability (HalDevice *device,
108 const char *capability);
110 gboolean hal_device_has_property (HalDevice *device,
111 const char *key);
112 HalProperty *hal_device_property_find (HalDevice *device,
113 const char *key);
114 int hal_device_num_properties (HalDevice *device);
115 char * hal_device_property_to_string (HalDevice *device,
116 const char *key);
117 void hal_device_property_foreach (HalDevice *device,
118 HalDevicePropertyForeachFn callback,
119 gpointer user_data);
121 int hal_device_property_get_type (HalDevice *device,
122 const char *key);
123 const char *hal_device_property_get_as_string (HalDevice *device,
124 const char *key,
125 char *buf,
126 size_t bufsize);
129 const char *hal_device_property_get_string (HalDevice *device,
130 const char *key);
131 dbus_int32_t hal_device_property_get_int (HalDevice *device,
132 const char *key);
133 dbus_uint64_t hal_device_property_get_uint64 (HalDevice *device,
134 const char *key);
135 dbus_bool_t hal_device_property_get_bool (HalDevice *device,
136 const char *key);
137 double hal_device_property_get_double (HalDevice *device,
138 const char *key);
139 GSList *hal_device_property_get_strlist (HalDevice *device,
140 const char *key);
141 const char *hal_device_property_get_strlist_elem (HalDevice *device,
142 const char *key,
143 guint index);
147 gboolean hal_device_property_set_string (HalDevice *device,
148 const char *key,
149 const char *value);
150 gboolean hal_device_property_set_int (HalDevice *device,
151 const char *key,
152 dbus_int32_t value);
153 gboolean hal_device_property_set_uint64 (HalDevice *device,
154 const char *key,
155 dbus_uint64_t value);
156 gboolean hal_device_property_set_bool (HalDevice *device,
157 const char *key,
158 dbus_bool_t value);
159 gboolean hal_device_property_set_double (HalDevice *device,
160 const char *key,
161 double value);
162 gboolean hal_device_property_strlist_append (HalDevice *device,
163 const char *key,
164 const char *value);
165 gboolean hal_device_property_strlist_prepend (HalDevice *device,
166 const char *key,
167 const char *value);
168 gboolean hal_device_property_strlist_remove_elem (HalDevice *device,
169 const char *key,
170 guint index);
171 gboolean hal_device_property_strlist_clear (HalDevice *device,
172 const char *key);
173 gboolean hal_device_property_strlist_add (HalDevice *device,
174 const char *key,
175 const char *value);
176 gboolean hal_device_property_strlist_remove (HalDevice *device,
177 const char *key,
178 const char *value);
179 gboolean hal_device_property_strlist_is_empty (HalDevice *device,
180 const char *key);
182 gboolean hal_device_property_remove (HalDevice *device,
183 const char *key);
185 gboolean hal_device_copy_property (HalDevice *from_device,
186 const char *from,
187 HalDevice *to_device,
188 const char *to);
191 void hal_device_print (HalDevice *device);
193 void hal_device_async_wait_property (HalDevice *device,
194 const char *key,
195 HalDeviceAsyncCallback callback,
196 gpointer user_data,
197 int timeout);
199 void hal_device_callouts_finished (HalDevice *device);
201 void hal_device_cancel (HalDevice *device);
203 gboolean hal_device_property_set_attribute (HalDevice *device,
204 const char *key,
205 enum PropertyAttribute attr,
206 gboolean persistence);
208 void hal_device_inc_num_addons (HalDevice *device);
210 gboolean hal_device_inc_num_ready_addons (HalDevice *device);
212 gboolean hal_device_are_all_addons_ready (HalDevice *device);
215 #endif /* DEVICE_H */