1*18c2aff7Sartem /*************************************************************************** 2*18c2aff7Sartem * CVSID: $Id$ 3*18c2aff7Sartem * 4*18c2aff7Sartem * device.c : HalDevice methods 5*18c2aff7Sartem * 6*18c2aff7Sartem * Copyright (C) 2003 David Zeuthen, <david@fubar.dk> 7*18c2aff7Sartem * Copyright (C) 2004 Novell, Inc. 8*18c2aff7Sartem * 9*18c2aff7Sartem * Licensed under the Academic Free License version 2.1 10*18c2aff7Sartem * 11*18c2aff7Sartem * This program is free software; you can redistribute it and/or modify 12*18c2aff7Sartem * it under the terms of the GNU General Public License as published by 13*18c2aff7Sartem * the Free Software Foundation; either version 2 of the License, or 14*18c2aff7Sartem * (at your option) any later version. 15*18c2aff7Sartem * 16*18c2aff7Sartem * This program is distributed in the hope that it will be useful, 17*18c2aff7Sartem * but WITHOUT ANY WARRANTY; without even the implied warranty of 18*18c2aff7Sartem * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19*18c2aff7Sartem * GNU General Public License for more details. 20*18c2aff7Sartem * 21*18c2aff7Sartem * You should have received a copy of the GNU General Public License 22*18c2aff7Sartem * along with this program; if not, write to the Free Software 23*18c2aff7Sartem * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24*18c2aff7Sartem * 25*18c2aff7Sartem **************************************************************************/ 26*18c2aff7Sartem 27*18c2aff7Sartem #ifndef DEVICE_STORE_H 28*18c2aff7Sartem #define DEVICE_STORE_H 29*18c2aff7Sartem 30*18c2aff7Sartem #include <glib-object.h> 31*18c2aff7Sartem 32*18c2aff7Sartem #include "device.h" 33*18c2aff7Sartem 34*18c2aff7Sartem typedef struct _HalDeviceStore HalDeviceStore; 35*18c2aff7Sartem typedef struct _HalDeviceStoreClass HalDeviceStoreClass; 36*18c2aff7Sartem 37*18c2aff7Sartem struct _HalDeviceStore { 38*18c2aff7Sartem GObject parent; 39*18c2aff7Sartem 40*18c2aff7Sartem GSList *devices; 41*18c2aff7Sartem }; 42*18c2aff7Sartem 43*18c2aff7Sartem struct _HalDeviceStoreClass { 44*18c2aff7Sartem GObjectClass parent_class; 45*18c2aff7Sartem 46*18c2aff7Sartem /* signals */ 47*18c2aff7Sartem void (*store_changed) (HalDeviceStore *store, 48*18c2aff7Sartem HalDevice *device, 49*18c2aff7Sartem gboolean added); 50*18c2aff7Sartem 51*18c2aff7Sartem void (*device_property_changed) (HalDeviceStore *store, 52*18c2aff7Sartem HalDevice *device, 53*18c2aff7Sartem const char *key, 54*18c2aff7Sartem gboolean removed, 55*18c2aff7Sartem gboolean added); 56*18c2aff7Sartem 57*18c2aff7Sartem void (*device_capability_added) (HalDeviceStore *store, 58*18c2aff7Sartem HalDevice *device, 59*18c2aff7Sartem const char *capability); 60*18c2aff7Sartem 61*18c2aff7Sartem }; 62*18c2aff7Sartem 63*18c2aff7Sartem #define HAL_TYPE_DEVICE_STORE (hal_device_store_get_type ()) 64*18c2aff7Sartem #define HAL_DEVICE_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\ 65*18c2aff7Sartem HAL_TYPE_DEVICE_STORE, \ 66*18c2aff7Sartem HalDeviceStore)) 67*18c2aff7Sartem #define HAL_DEVICE_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \ 68*18c2aff7Sartem HAL_TYPE_DEVICE_STORE, \ 69*18c2aff7Sartem HalDeviceStoreClass)) 70*18c2aff7Sartem #define HAL_IS_DEVICE_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\ 71*18c2aff7Sartem HAL_TYPE_DEVICE_STORE)) 72*18c2aff7Sartem #define HAL_IS_DEVICE_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \ 73*18c2aff7Sartem HAL_TYPE_DEVICE_STORE)) 74*18c2aff7Sartem 75*18c2aff7Sartem typedef void (*HalDeviceStoreAsyncCallback) (HalDeviceStore *store, 76*18c2aff7Sartem HalDevice *device, 77*18c2aff7Sartem gpointer user_data); 78*18c2aff7Sartem 79*18c2aff7Sartem /* Return value of FALSE means that the foreach should be short-circuited */ 80*18c2aff7Sartem typedef gboolean (*HalDeviceStoreForeachFn) (HalDeviceStore *store, 81*18c2aff7Sartem HalDevice *device, 82*18c2aff7Sartem gpointer user_data); 83*18c2aff7Sartem 84*18c2aff7Sartem GType hal_device_store_get_type (void); 85*18c2aff7Sartem 86*18c2aff7Sartem HalDeviceStore *hal_device_store_new (void); 87*18c2aff7Sartem 88*18c2aff7Sartem void hal_device_store_add (HalDeviceStore *store, 89*18c2aff7Sartem HalDevice *device); 90*18c2aff7Sartem gboolean hal_device_store_remove (HalDeviceStore *store, 91*18c2aff7Sartem HalDevice *device); 92*18c2aff7Sartem 93*18c2aff7Sartem HalDevice *hal_device_store_find (HalDeviceStore *store, 94*18c2aff7Sartem const char *udi); 95*18c2aff7Sartem 96*18c2aff7Sartem void hal_device_store_foreach (HalDeviceStore *store, 97*18c2aff7Sartem HalDeviceStoreForeachFn callback, 98*18c2aff7Sartem gpointer user_data); 99*18c2aff7Sartem 100*18c2aff7Sartem HalDevice *hal_device_store_match_key_value_string (HalDeviceStore *store, 101*18c2aff7Sartem const char *key, 102*18c2aff7Sartem const char *value); 103*18c2aff7Sartem 104*18c2aff7Sartem HalDevice *hal_device_store_match_key_value_int (HalDeviceStore *store, 105*18c2aff7Sartem const char *key, 106*18c2aff7Sartem int value); 107*18c2aff7Sartem 108*18c2aff7Sartem GSList *hal_device_store_match_multiple_key_value_string (HalDeviceStore *store, 109*18c2aff7Sartem const char *key, 110*18c2aff7Sartem const char *value); 111*18c2aff7Sartem 112*18c2aff7Sartem void hal_device_store_match_key_value_string_async (HalDeviceStore *store, 113*18c2aff7Sartem const char *key, 114*18c2aff7Sartem const char *value, 115*18c2aff7Sartem HalDeviceStoreAsyncCallback callback, 116*18c2aff7Sartem gpointer user_data, 117*18c2aff7Sartem int timeout); 118*18c2aff7Sartem 119*18c2aff7Sartem void hal_device_store_print (HalDeviceStore *store); 120*18c2aff7Sartem 121*18c2aff7Sartem 122*18c2aff7Sartem #endif /* DEVICE_STORE_H */ 123