xref: /illumos-gate/usr/src/cmd/hal/hald/device_store.h (revision 55fea89d)
118c2aff7Sartem /***************************************************************************
218c2aff7Sartem  * CVSID: $Id$
318c2aff7Sartem  *
418c2aff7Sartem  * device.c : HalDevice methods
518c2aff7Sartem  *
618c2aff7Sartem  * Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
718c2aff7Sartem  * Copyright (C) 2004 Novell, Inc.
818c2aff7Sartem  *
918c2aff7Sartem  * Licensed under the Academic Free License version 2.1
1018c2aff7Sartem  *
1118c2aff7Sartem  * This program is free software; you can redistribute it and/or modify
1218c2aff7Sartem  * it under the terms of the GNU General Public License as published by
1318c2aff7Sartem  * the Free Software Foundation; either version 2 of the License, or
1418c2aff7Sartem  * (at your option) any later version.
1518c2aff7Sartem  *
1618c2aff7Sartem  * This program is distributed in the hope that it will be useful,
1718c2aff7Sartem  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1818c2aff7Sartem  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1918c2aff7Sartem  * GNU General Public License for more details.
2018c2aff7Sartem  *
2118c2aff7Sartem  * You should have received a copy of the GNU General Public License
2218c2aff7Sartem  * along with this program; if not, write to the Free Software
2318c2aff7Sartem  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
2418c2aff7Sartem  *
2518c2aff7Sartem  **************************************************************************/
2618c2aff7Sartem 
2718c2aff7Sartem #ifndef DEVICE_STORE_H
2818c2aff7Sartem #define DEVICE_STORE_H
2918c2aff7Sartem 
3018c2aff7Sartem #include <glib-object.h>
3118c2aff7Sartem 
3218c2aff7Sartem #include "device.h"
3318c2aff7Sartem 
3418c2aff7Sartem typedef struct _HalDeviceStore      HalDeviceStore;
3518c2aff7Sartem typedef struct _HalDeviceStoreClass HalDeviceStoreClass;
3618c2aff7Sartem 
3718c2aff7Sartem struct _HalDeviceStore {
3818c2aff7Sartem 	GObject parent;
3918c2aff7Sartem 
4018c2aff7Sartem 	GSList *devices;
4118c2aff7Sartem };
4218c2aff7Sartem 
4318c2aff7Sartem struct _HalDeviceStoreClass {
4418c2aff7Sartem 	GObjectClass parent_class;
4518c2aff7Sartem 
4618c2aff7Sartem 	/* signals */
4718c2aff7Sartem 	void (*store_changed) (HalDeviceStore *store,
4818c2aff7Sartem 			       HalDevice *device,
4918c2aff7Sartem 			       gboolean added);
5018c2aff7Sartem 
5118c2aff7Sartem 	void (*device_property_changed) (HalDeviceStore *store,
5218c2aff7Sartem 					 HalDevice *device,
5318c2aff7Sartem 					 const char *key,
5418c2aff7Sartem 					 gboolean removed,
5518c2aff7Sartem 					 gboolean added);
5618c2aff7Sartem 
5718c2aff7Sartem 	void (*device_capability_added) (HalDeviceStore *store,
5818c2aff7Sartem 					 HalDevice *device,
5918c2aff7Sartem 					 const char *capability);
6018c2aff7Sartem 
6118c2aff7Sartem };
6218c2aff7Sartem 
6318c2aff7Sartem #define HAL_TYPE_DEVICE_STORE              (hal_device_store_get_type ())
6418c2aff7Sartem #define HAL_DEVICE_STORE(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
6518c2aff7Sartem                                             HAL_TYPE_DEVICE_STORE, \
6618c2aff7Sartem                                             HalDeviceStore))
6718c2aff7Sartem #define HAL_DEVICE_STORE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), \
6818c2aff7Sartem                                             HAL_TYPE_DEVICE_STORE, \
6918c2aff7Sartem 					    HalDeviceStoreClass))
7018c2aff7Sartem #define HAL_IS_DEVICE_STORE(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
7118c2aff7Sartem                                             HAL_TYPE_DEVICE_STORE))
7218c2aff7Sartem #define HAL_IS_DEVICE_STORE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), \
7318c2aff7Sartem                                             HAL_TYPE_DEVICE_STORE))
7418c2aff7Sartem 
7518c2aff7Sartem typedef void     (*HalDeviceStoreAsyncCallback) (HalDeviceStore *store,
7618c2aff7Sartem 						 HalDevice      *device,
7718c2aff7Sartem 						 gpointer        user_data);
7818c2aff7Sartem 
7918c2aff7Sartem /* Return value of FALSE means that the foreach should be short-circuited */
8018c2aff7Sartem typedef gboolean (*HalDeviceStoreForeachFn) (HalDeviceStore *store,
8118c2aff7Sartem 					     HalDevice      *device,
8218c2aff7Sartem 					     gpointer        user_data);
83*55fea89dSDan Cross 
8418c2aff7Sartem GType           hal_device_store_get_type   (void);
8518c2aff7Sartem 
8618c2aff7Sartem HalDeviceStore *hal_device_store_new        (void);
8718c2aff7Sartem 
8818c2aff7Sartem void            hal_device_store_add        (HalDeviceStore *store,
8918c2aff7Sartem 					     HalDevice      *device);
9018c2aff7Sartem gboolean        hal_device_store_remove     (HalDeviceStore *store,
9118c2aff7Sartem 					     HalDevice      *device);
9218c2aff7Sartem 
9318c2aff7Sartem HalDevice      *hal_device_store_find       (HalDeviceStore *store,
9418c2aff7Sartem 					     const char     *udi);
9518c2aff7Sartem 
9618c2aff7Sartem void            hal_device_store_foreach    (HalDeviceStore *store,
9718c2aff7Sartem 					     HalDeviceStoreForeachFn callback,
9818c2aff7Sartem 					     gpointer user_data);
9918c2aff7Sartem 
10018c2aff7Sartem HalDevice      *hal_device_store_match_key_value_string (HalDeviceStore *store,
10118c2aff7Sartem 							 const char *key,
10218c2aff7Sartem 							 const char *value);
10318c2aff7Sartem 
10418c2aff7Sartem HalDevice      *hal_device_store_match_key_value_int (HalDeviceStore *store,
10518c2aff7Sartem 						      const char *key,
10618c2aff7Sartem 						      int value);
10718c2aff7Sartem 
10818c2aff7Sartem GSList         *hal_device_store_match_multiple_key_value_string (HalDeviceStore *store,
10918c2aff7Sartem 								  const char *key,
11018c2aff7Sartem 								  const char *value);
11118c2aff7Sartem 
11218c2aff7Sartem void           hal_device_store_match_key_value_string_async (HalDeviceStore *store,
11318c2aff7Sartem 							      const char *key,
11418c2aff7Sartem 							      const char *value,
11518c2aff7Sartem 							      HalDeviceStoreAsyncCallback callback,
11618c2aff7Sartem 							      gpointer user_data,
11718c2aff7Sartem 							      int timeout);
11818c2aff7Sartem 
11918c2aff7Sartem void hal_device_store_print (HalDeviceStore *store);
12018c2aff7Sartem 
12118c2aff7Sartem 
12218c2aff7Sartem #endif /* DEVICE_STORE_H */
123