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

device_store.h

00001 /***************************************************************************
00002  * CVSID: $Id: device_store.h,v 1.9 2004/03/03 17:56:56 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     int type;         
00046     char *key;        
00049     union {
00050         char *str_value;  
00051         dbus_int32_t int_value;
00053         dbus_bool_t bool_value;
00055         double double_value;
00058     };
00059     struct HalProperty_s *prev;
00061     struct HalProperty_s *next;
00063 } HalProperty;
00064 
00067 typedef struct HalDevice_s {
00068     char *udi;           
00069     dbus_bool_t in_gdl;      
00072     int num_properties;      
00073     HalProperty *prop_head;      
00074     struct HalDevice_s *prev;    
00075     struct HalDevice_s *next;    
00076 } HalDevice;
00077 
00078 
00081 typedef struct HalPropertyIterator_s {
00082     HalDevice *device;    
00083     HalProperty *cursor;      
00084 } HalPropertyIterator;
00085 
00088 typedef struct HalDeviceIterator_s {
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
00161                              only_gdl,
00162                              int *num_results);
00163 
00164 HalDevice *ds_device_find_by_key_value_string (const char *key,
00165                            const char *value,
00166                            dbus_bool_t only_gdl);
00167 
00168 void ds_device_async_find_by_key_value_string (const char *key,
00169                            const char *value,
00170                            dbus_bool_t only_gdl,
00171                            DSAsyncFindDeviceCB
00172                            callback, void *data1,
00173                            void *data2, 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,
00202                  HalPropertyIterator * iterator);
00203 dbus_bool_t ds_property_iter_has_more (HalPropertyIterator * iterator);
00204 void ds_property_iter_next (HalPropertyIterator * iterator);
00205 HalProperty *ds_property_iter_get (HalPropertyIterator * iterator);
00206 
00207 dbus_bool_t ds_property_set_string (HalDevice * device, const char *key,
00208                     const char *value);
00209 dbus_bool_t ds_property_set_int (HalDevice * device, const char *key,
00210                  dbus_int32_t value);
00211 dbus_bool_t ds_property_set_bool (HalDevice * device, const char *key,
00212                   dbus_bool_t value);
00213 dbus_bool_t ds_property_set_double (HalDevice * device, const char *key,
00214                     double value);
00215 dbus_bool_t ds_property_remove (HalDevice * device, const char *key);
00216 
00217 /**************************************************************************/
00218 
00219 const char *ds_property_iter_get_key (HalProperty * property);
00220 int ds_property_iter_get_type (HalProperty * property);
00221 const char *ds_property_iter_get_string (HalProperty * property);
00222 dbus_int32_t ds_property_iter_get_int (HalProperty * property);
00223 dbus_bool_t ds_property_iter_get_bool (HalProperty * property);
00224 double ds_property_iter_get_double (HalProperty * property);
00225 
00226 
00227 int ds_property_get_type (HalDevice * device, const char *key);
00228 const char *ds_property_get_string (HalDevice * device, const char *key);
00229 dbus_int32_t ds_property_get_int (HalDevice * device, const char *key);
00230 dbus_bool_t ds_property_get_bool (HalDevice * device, const char *key);
00231 double ds_property_get_double (HalDevice * device, const char *key);
00232 
00233 void ds_add_capability (HalDevice * device, const char *capability);
00234 
00235 dbus_bool_t ds_query_capability (HalDevice * device,
00236                  const char *capability);
00237 
00238 
00243 #endif              /* DEVICE_STORE_H */

Generated on Thu Mar 11 21:32:22 2004 for HAL by doxygen 1.3.6-20040222