xref: /onnv-gate/usr/src/cmd/hal/hald/device_store.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_STORE_H
28*2912Sartem #define DEVICE_STORE_H
29*2912Sartem 
30*2912Sartem #include <glib-object.h>
31*2912Sartem 
32*2912Sartem #include "device.h"
33*2912Sartem 
34*2912Sartem typedef struct _HalDeviceStore      HalDeviceStore;
35*2912Sartem typedef struct _HalDeviceStoreClass HalDeviceStoreClass;
36*2912Sartem 
37*2912Sartem struct _HalDeviceStore {
38*2912Sartem 	GObject parent;
39*2912Sartem 
40*2912Sartem 	GSList *devices;
41*2912Sartem };
42*2912Sartem 
43*2912Sartem struct _HalDeviceStoreClass {
44*2912Sartem 	GObjectClass parent_class;
45*2912Sartem 
46*2912Sartem 	/* signals */
47*2912Sartem 	void (*store_changed) (HalDeviceStore *store,
48*2912Sartem 			       HalDevice *device,
49*2912Sartem 			       gboolean added);
50*2912Sartem 
51*2912Sartem 	void (*device_property_changed) (HalDeviceStore *store,
52*2912Sartem 					 HalDevice *device,
53*2912Sartem 					 const char *key,
54*2912Sartem 					 gboolean removed,
55*2912Sartem 					 gboolean added);
56*2912Sartem 
57*2912Sartem 	void (*device_capability_added) (HalDeviceStore *store,
58*2912Sartem 					 HalDevice *device,
59*2912Sartem 					 const char *capability);
60*2912Sartem 
61*2912Sartem };
62*2912Sartem 
63*2912Sartem #define HAL_TYPE_DEVICE_STORE              (hal_device_store_get_type ())
64*2912Sartem #define HAL_DEVICE_STORE(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
65*2912Sartem                                             HAL_TYPE_DEVICE_STORE, \
66*2912Sartem                                             HalDeviceStore))
67*2912Sartem #define HAL_DEVICE_STORE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), \
68*2912Sartem                                             HAL_TYPE_DEVICE_STORE, \
69*2912Sartem 					    HalDeviceStoreClass))
70*2912Sartem #define HAL_IS_DEVICE_STORE(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
71*2912Sartem                                             HAL_TYPE_DEVICE_STORE))
72*2912Sartem #define HAL_IS_DEVICE_STORE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), \
73*2912Sartem                                             HAL_TYPE_DEVICE_STORE))
74*2912Sartem 
75*2912Sartem typedef void     (*HalDeviceStoreAsyncCallback) (HalDeviceStore *store,
76*2912Sartem 						 HalDevice      *device,
77*2912Sartem 						 gpointer        user_data);
78*2912Sartem 
79*2912Sartem /* Return value of FALSE means that the foreach should be short-circuited */
80*2912Sartem typedef gboolean (*HalDeviceStoreForeachFn) (HalDeviceStore *store,
81*2912Sartem 					     HalDevice      *device,
82*2912Sartem 					     gpointer        user_data);
83*2912Sartem 
84*2912Sartem GType           hal_device_store_get_type   (void);
85*2912Sartem 
86*2912Sartem HalDeviceStore *hal_device_store_new        (void);
87*2912Sartem 
88*2912Sartem void            hal_device_store_add        (HalDeviceStore *store,
89*2912Sartem 					     HalDevice      *device);
90*2912Sartem gboolean        hal_device_store_remove     (HalDeviceStore *store,
91*2912Sartem 					     HalDevice      *device);
92*2912Sartem 
93*2912Sartem HalDevice      *hal_device_store_find       (HalDeviceStore *store,
94*2912Sartem 					     const char     *udi);
95*2912Sartem 
96*2912Sartem void            hal_device_store_foreach    (HalDeviceStore *store,
97*2912Sartem 					     HalDeviceStoreForeachFn callback,
98*2912Sartem 					     gpointer user_data);
99*2912Sartem 
100*2912Sartem HalDevice      *hal_device_store_match_key_value_string (HalDeviceStore *store,
101*2912Sartem 							 const char *key,
102*2912Sartem 							 const char *value);
103*2912Sartem 
104*2912Sartem HalDevice      *hal_device_store_match_key_value_int (HalDeviceStore *store,
105*2912Sartem 						      const char *key,
106*2912Sartem 						      int value);
107*2912Sartem 
108*2912Sartem GSList         *hal_device_store_match_multiple_key_value_string (HalDeviceStore *store,
109*2912Sartem 								  const char *key,
110*2912Sartem 								  const char *value);
111*2912Sartem 
112*2912Sartem void           hal_device_store_match_key_value_string_async (HalDeviceStore *store,
113*2912Sartem 							      const char *key,
114*2912Sartem 							      const char *value,
115*2912Sartem 							      HalDeviceStoreAsyncCallback callback,
116*2912Sartem 							      gpointer user_data,
117*2912Sartem 							      int timeout);
118*2912Sartem 
119*2912Sartem void hal_device_store_print (HalDeviceStore *store);
120*2912Sartem 
121*2912Sartem 
122*2912Sartem #endif /* DEVICE_STORE_H */
123