Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

device_store.h

00001 /***************************************************************************
00002  * CVSID: $Id: device_store.h,v 1.8 2004/01/16 13:26:47 david Exp $
00003  *
00004  * device_store.h : device store interface
00005  *
00006  * Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
00007  *
00008  * Licensed under the Academic Free License version 2.0
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  **************************************************************************/
00025 
00026 #ifndef DEVICE_STORE_H
00027 #define DEVICE_STORE_H
00028 
00029 #include <stdarg.h>
00030 #include <stdint.h>
00031 #include <dbus/dbus.h>
00032 
00033 
00042 typedef struct HalProperty_s
00043 {
00044     int type;                     
00047     char* key;                    
00050     union
00051     {
00052         char* str_value;          
00053         dbus_int32_t int_value;   
00054         dbus_bool_t bool_value;   
00055         double double_value;      
00057     };
00058     struct HalProperty_s* prev;   
00059     struct HalProperty_s* next;   
00060 } HalProperty;
00061 
00064 typedef struct HalDevice_s
00065 {
00066     char* udi;                       
00067     dbus_bool_t in_gdl;              
00070     int num_properties;              
00071     HalProperty* prop_head;          
00072     struct HalDevice_s* prev;        
00073     struct HalDevice_s* next;        
00074 } HalDevice;
00075 
00076 
00079 typedef struct HalPropertyIterator_s
00080 {
00081     HalDevice* device;            
00082     HalProperty* cursor;          
00083 } HalPropertyIterator;
00084 
00087 typedef struct HalDeviceIterator_s
00088 {
00089     HalDevice* cursor;            
00090     unsigned int position;        
00091 } HalDeviceIterator;
00092 
00102 typedef void (*HalDevicePropertyChangedCallback)(HalDevice* device,
00103                                                  const char* key, 
00104                                                  dbus_bool_t in_gdl, 
00105                                                  dbus_bool_t removed,
00106                                                  dbus_bool_t added);
00107 
00114 typedef void (*HalDeviceGDLChangedCallback)(HalDevice* device,
00115                                             dbus_bool_t is_added);
00116 
00117 
00124 typedef void (*HalDeviceNewCapabilityCallback)(HalDevice* device,
00125                                                const char* capability,
00126                                                dbus_bool_t in_gdl);
00127 
00128 void ds_init();
00129 void ds_shutdown();
00130 void ds_print(HalDevice* device);
00131 
00132 void ds_add_cb_newcap(HalDeviceNewCapabilityCallback cb);
00133 
00134 void ds_add_cb_property_changed(HalDevicePropertyChangedCallback cb);
00135 
00136 void ds_add_cb_gdl_changed(HalDeviceGDLChangedCallback cb);
00137 
00138 /**************************************************************************/
00139 
00152 typedef void (*DSAsyncFindDeviceCB)(HalDevice* result, 
00153                                     void* data1, void* data2);
00154 
00155 
00156 HalDevice* ds_device_find(const char* udi);
00157 
00158 HalDevice** ds_device_find_multiple_by_key_value_string(const char* key, 
00159                                                         const char* value,
00160                                                         dbus_bool_t only_gdl,
00161                                                         int* num_results);
00162 
00163 HalDevice* ds_device_find_by_key_value_string(const char* key, 
00164                                               const char* value,
00165                                               dbus_bool_t only_gdl);
00166 
00167 void ds_device_async_find_by_key_value_string(const char* key, 
00168                                               const char* value,
00169                                               dbus_bool_t only_gdl,
00170                                               DSAsyncFindDeviceCB callback, 
00171                                               void* data1, 
00172                                               void* data2, 
00173                                               int timeout);
00174 HalDevice* ds_device_new();
00175 void ds_device_destroy(HalDevice* device);
00176 
00177 void ds_device_merge(HalDevice* target, HalDevice* source);
00178 
00179 dbus_bool_t ds_device_matches(HalDevice* device1, HalDevice* device, 
00180                               const char* namespace);
00181 
00182 /**************************************************************************/
00183 
00184 void ds_gdl_add(HalDevice* device);
00185 
00186 unsigned int ds_device_size();
00187 void ds_device_iter_begin(HalDeviceIterator* iterator);
00188 dbus_bool_t ds_device_iter_has_more(HalDeviceIterator* iterator);
00189 void ds_device_iter_next(HalDeviceIterator* iterator);
00190 HalDevice* ds_device_iter_get(HalDeviceIterator* iterator);
00191 
00192 const char* ds_device_get_udi(HalDevice* device);
00193 dbus_bool_t ds_device_set_udi(HalDevice* device, const char* udi);
00194 
00195 
00196 /**************************************************************************/
00197 
00198 unsigned int ds_properties_size(HalDevice* device);
00199 dbus_bool_t ds_property_exists(HalDevice* device, const char* key);
00200 HalProperty* ds_property_find(HalDevice* device, const char* key);
00201 void ds_property_iter_begin(HalDevice* device, HalPropertyIterator* iterator);
00202 dbus_bool_t ds_property_iter_has_more(HalPropertyIterator* iterator);
00203 void ds_property_iter_next(HalPropertyIterator* iterator);
00204 HalProperty* ds_property_iter_get(HalPropertyIterator* iterator);
00205 
00206 dbus_bool_t ds_property_set_string(HalDevice* device, const char* key, 
00207                                    const char* value);
00208 dbus_bool_t ds_property_set_int(HalDevice* device, const char* key, 
00209                                 dbus_int32_t value);
00210 dbus_bool_t ds_property_set_bool(HalDevice* device, const char* key, 
00211                                  dbus_bool_t value);
00212 dbus_bool_t ds_property_set_double(HalDevice* device, const char* key, 
00213                                    double value);
00214 dbus_bool_t ds_property_remove(HalDevice* device, const char* key);
00215 
00216 /**************************************************************************/
00217 
00218 const char* ds_property_iter_get_key(HalProperty* property);
00219 int ds_property_iter_get_type(HalProperty* property);
00220 const char* ds_property_iter_get_string(HalProperty* property);
00221 dbus_int32_t ds_property_iter_get_int(HalProperty* property);
00222 dbus_bool_t ds_property_iter_get_bool(HalProperty* property);
00223 double ds_property_iter_get_double(HalProperty* property);
00224 
00225 
00226 int ds_property_get_type(HalDevice* device, const char* key);
00227 const char* ds_property_get_string(HalDevice* device, const char* key);
00228 dbus_int32_t ds_property_get_int(HalDevice* device, const char* key);
00229 dbus_bool_t ds_property_get_bool(HalDevice* device, const char* key);
00230 double ds_property_get_double(HalDevice* device, const char* key);
00231 
00232 void ds_add_capability(HalDevice* device, const char* capability);
00233 
00234 dbus_bool_t ds_query_capability(HalDevice* device, const char* capability);
00235 
00236 
00241 #endif /* DEVICE_STORE_H */

Generated on Sat Feb 7 22:11:46 2004 for HAL by doxygen 1.3.5