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