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

device.h

00001 /***************************************************************************
00002  * CVSID: $Id: device.h,v 1.4 2004/04/20 20:54:15 joe Exp $
00003  *
00004  * device.c : HalDevice methods
00005  *
00006  * Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
00007  * Copyright (C) 2004 Novell, Inc.
00008  *
00009  * Licensed under the Academic Free License version 2.0
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  *
00025  **************************************************************************/
00026 
00027 #ifndef DEVICE_H
00028 #define DEVICE_H
00029 
00030 #include <glib-object.h>
00031 #include <dbus/dbus.h>
00032 
00033 #include "property.h"
00034 
00035 typedef struct _HalDevice      HalDevice;
00036 typedef struct _HalDeviceClass HalDeviceClass;
00037 
00038 struct _HalDevice {
00039     GObject parent;
00040 
00041     char *udi;
00042     
00043     GSList *properties;
00044 };
00045 
00046 struct _HalDeviceClass {
00047     GObjectClass parent_class;
00048 
00049     /* signals */
00050     void (*property_changed) (HalDevice *device,
00051                   const char *key,
00052                   gboolean removed,
00053                   gboolean added);
00054 
00055     void (*capability_added) (HalDevice *device,
00056                   const char *capability);
00057 };
00058 
00059 #define HAL_TYPE_DEVICE             (hal_device_get_type ())
00060 #define HAL_DEVICE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
00061                                      HAL_TYPE_DEVICE, HalDevice))
00062 #define HAL_DEVICE_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), \
00063                                      HAL_TYPE_DEVICE, HalDeviceClass))
00064 #define HAL_IS_DEVICE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
00065                                      HAL_TYPE_DEVICE))
00066 #define HAL_IS_DEVICE_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
00067                                      HAL_TYPE_DEVICE))
00068 
00069 typedef void     (*HalDeviceAsyncCallback) (HalDevice *device,
00070                         gpointer user_data,
00071                         gboolean prop_exists);
00072 
00073 /* Return value of FALSE means that the foreach should be short-circuited */
00074 typedef gboolean (*HalDevicePropertyForeachFn) (HalDevice *device,
00075                         HalProperty *property,
00076                         gpointer user_data);
00077 
00078 GType         hal_device_get_type            (void);
00079 
00080 HalDevice   *hal_device_new                  (void);
00081 
00082 void          hal_device_merge               (HalDevice    *target,
00083                           HalDevice    *source);
00084 
00085 void          hal_device_merge_with_rewrite  (HalDevice    *target,
00086                           HalDevice    *source,
00087                           const char   *target_namespace,
00088                           const char   *source_namespace);
00089 
00090 gboolean      hal_device_matches             (HalDevice    *device1,
00091                           HalDevice    *device2,
00092                           const char   *namespace);
00093 
00094 const char   *hal_device_get_udi             (HalDevice    *device);
00095 void          hal_device_set_udi             (HalDevice    *device,
00096                           const char   *udi);
00097 
00098 void          hal_device_add_capability      (HalDevice    *device,
00099                           const char   *capability);
00100 gboolean      hal_device_has_capability      (HalDevice    *device,
00101                           const char   *capability);
00102 
00103 gboolean      hal_device_has_property        (HalDevice    *device,
00104                           const char   *key);
00105 HalProperty  *hal_device_property_find       (HalDevice    *device,
00106                           const char   *key);
00107 int           hal_device_num_properties      (HalDevice    *device);
00108 char *        hal_device_property_to_string  (HalDevice    *device,
00109                           const char   *key);
00110 void          hal_device_property_foreach    (HalDevice    *device,
00111                           HalDevicePropertyForeachFn callback,
00112                           gpointer      user_data);
00113 
00114 int           hal_device_property_get_type   (HalDevice    *device,
00115                           const char   *key);
00116 const char   *hal_device_property_get_string (HalDevice    *device,
00117                           const char   *key);
00118 dbus_int32_t  hal_device_property_get_int    (HalDevice    *device,
00119                           const char   *key);
00120 dbus_bool_t   hal_device_property_get_bool   (HalDevice    *device,
00121                           const char   *key);
00122 double        hal_device_property_get_double (HalDevice    *device,
00123                           const char   *key);
00124 
00125 gboolean      hal_device_property_set_string (HalDevice    *device,
00126                           const char   *key,
00127                           const char   *value);
00128 gboolean      hal_device_property_set_int    (HalDevice    *device,
00129                           const char   *key,
00130                           dbus_int32_t  value);
00131 gboolean      hal_device_property_set_bool   (HalDevice    *device,
00132                           const char   *key,
00133                           dbus_bool_t   value);
00134 gboolean      hal_device_property_set_double (HalDevice    *device,
00135                           const char   *key,
00136                           double        value);
00137 
00138 gboolean      hal_device_property_remove     (HalDevice    *device,
00139                           const char   *key);
00140 
00141 void          hal_device_print               (HalDevice    *device);
00142 
00143 void          hal_device_async_wait_property (HalDevice    *device,
00144                           const char   *key,
00145                           HalDeviceAsyncCallback callback,
00146                           gpointer     user_data,
00147                           int          timeout);
00148 
00149 #endif /* DEVICE_H */

Generated on Sat Apr 24 19:57:44 2004 for HAL by doxygen 1.3.6-20040222