1 /***************************************************************************
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 **************************************************************************/
30 #include <glib-object.h>
31 #include <dbus/dbus.h>
35 typedef struct _HalDevice HalDevice
;
36 typedef struct _HalDeviceClass HalDeviceClass
;
49 struct _HalDeviceClass
{
50 GObjectClass parent_class
;
53 void (*property_changed
) (HalDevice
*device
,
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), \
73 #define HAL_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
76 typedef void (*HalDeviceAsyncCallback
) (HalDevice
*device
,
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
,
85 GType
hal_device_get_type (void);
87 HalDevice
*hal_device_new (void);
89 void hal_device_merge (HalDevice
*target
,
92 void hal_device_merge_with_rewrite (HalDevice
*target
,
94 const char *target_namespace
,
95 const char *source_namespace
);
97 gboolean
hal_device_matches (HalDevice
*device1
,
99 const char *namespace);
101 const char *hal_device_get_udi (HalDevice
*device
);
102 void hal_device_set_udi (HalDevice
*device
,
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
,
112 HalProperty
*hal_device_property_find (HalDevice
*device
,
114 int hal_device_num_properties (HalDevice
*device
);
115 char * hal_device_property_to_string (HalDevice
*device
,
117 void hal_device_property_foreach (HalDevice
*device
,
118 HalDevicePropertyForeachFn callback
,
121 int hal_device_property_get_type (HalDevice
*device
,
123 const char *hal_device_property_get_as_string (HalDevice
*device
,
129 const char *hal_device_property_get_string (HalDevice
*device
,
131 dbus_int32_t
hal_device_property_get_int (HalDevice
*device
,
133 dbus_uint64_t
hal_device_property_get_uint64 (HalDevice
*device
,
135 dbus_bool_t
hal_device_property_get_bool (HalDevice
*device
,
137 double hal_device_property_get_double (HalDevice
*device
,
139 GSList
*hal_device_property_get_strlist (HalDevice
*device
,
141 const char *hal_device_property_get_strlist_elem (HalDevice
*device
,
147 gboolean
hal_device_property_set_string (HalDevice
*device
,
150 gboolean
hal_device_property_set_int (HalDevice
*device
,
153 gboolean
hal_device_property_set_uint64 (HalDevice
*device
,
155 dbus_uint64_t value
);
156 gboolean
hal_device_property_set_bool (HalDevice
*device
,
159 gboolean
hal_device_property_set_double (HalDevice
*device
,
162 gboolean
hal_device_property_strlist_append (HalDevice
*device
,
165 gboolean
hal_device_property_strlist_prepend (HalDevice
*device
,
168 gboolean
hal_device_property_strlist_remove_elem (HalDevice
*device
,
171 gboolean
hal_device_property_strlist_clear (HalDevice
*device
,
173 gboolean
hal_device_property_strlist_add (HalDevice
*device
,
176 gboolean
hal_device_property_strlist_remove (HalDevice
*device
,
179 gboolean
hal_device_property_strlist_is_empty (HalDevice
*device
,
182 gboolean
hal_device_property_remove (HalDevice
*device
,
185 gboolean
hal_device_copy_property (HalDevice
*from_device
,
187 HalDevice
*to_device
,
191 void hal_device_print (HalDevice
*device
);
193 void hal_device_async_wait_property (HalDevice
*device
,
195 HalDeviceAsyncCallback callback
,
199 void hal_device_callouts_finished (HalDevice
*device
);
201 void hal_device_cancel (HalDevice
*device
);
203 gboolean
hal_device_property_set_attribute (HalDevice
*device
,
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 */