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