xref: /titanic_44/usr/src/cmd/hal/hald/property.h (revision a38ddfee9c8c6b6c5a2947ff52fd2338362a4444)
1 /***************************************************************************
2  * CVSID: $Id$
3  *
4  * property.c : HalProperty methods
5  *
6  * Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
7  * Copyright (C) 2004 Novell, Inc.
8  *
9  * Licensed under the Academic Free License version 2.1
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24  *
25  **************************************************************************/
26 
27 #ifndef PROPERTY_H
28 #define PROPERTY_H
29 
30 #include <dbus/dbus.h>
31 
32 typedef struct _HalProperty HalProperty;
33 
34 #define HAL_PROPERTY_TYPE_INVALID         DBUS_TYPE_INVALID
35 #define HAL_PROPERTY_TYPE_INT32       DBUS_TYPE_INT32
36 #define HAL_PROPERTY_TYPE_UINT64      DBUS_TYPE_UINT64
37 #define HAL_PROPERTY_TYPE_DOUBLE      DBUS_TYPE_DOUBLE
38 #define HAL_PROPERTY_TYPE_BOOLEAN     DBUS_TYPE_BOOLEAN
39 #define HAL_PROPERTY_TYPE_STRING      DBUS_TYPE_STRING
40 #define HAL_PROPERTY_TYPE_STRLIST     ((int) (DBUS_TYPE_STRING<<8)+('l'))
41 
42 enum PropertyAttribute {
43 	READONLY,
44 	PERSISTENCE,
45 	CALLOUT
46 };
47 
48 void          hal_property_free               (HalProperty  *prop);
49 
50 HalProperty *hal_property_new_string          (const char   *key,
51 					       const char   *value);
52 HalProperty *hal_property_new_int             (const char   *key,
53 					       dbus_int32_t  value);
54 HalProperty *hal_property_new_uint64          (const char   *key,
55 					       dbus_uint64_t value);
56 HalProperty *hal_property_new_bool            (const char   *key,
57 					       dbus_bool_t   value);
58 HalProperty *hal_property_new_double          (const char   *key,
59 					       double        value);
60 HalProperty *hal_property_new_strlist         (const char   *key);
61 
62 const char   *hal_property_get_key            (HalProperty  *prop);
63 int           hal_property_get_type           (HalProperty  *prop);
64 char         *hal_property_to_string          (HalProperty  *prop);
65 
66 const char   *hal_property_get_string         (HalProperty  *prop);
67 dbus_int32_t  hal_property_get_int            (HalProperty  *prop);
68 dbus_uint64_t hal_property_get_uint64         (HalProperty  *prop);
69 dbus_bool_t   hal_property_get_bool           (HalProperty  *prop);
70 double        hal_property_get_double         (HalProperty  *prop);
71 GSList       *hal_property_get_strlist        (HalProperty  *prop);
72 
73 void          hal_property_set_string         (HalProperty  *prop,
74 					       const char   *value);
75 void          hal_property_set_int            (HalProperty  *prop,
76 					       dbus_int32_t  value);
77 void          hal_property_set_uint64         (HalProperty  *prop,
78 					       dbus_uint64_t value);
79 void          hal_property_set_bool           (HalProperty  *prop,
80 					       dbus_bool_t   value);
81 void          hal_property_set_double         (HalProperty  *prop,
82 					       double        value);
83 gboolean      hal_property_strlist_append     (HalProperty  *prop,
84 					       const char   *value);
85 gboolean      hal_property_strlist_prepend    (HalProperty  *prop,
86 					       const char   *value);
87 gboolean      hal_property_strlist_remove_elem (HalProperty  *prop,
88 					        guint index);
89 
90 gboolean      hal_property_strlist_add        (HalProperty  *prop,
91 					       const char *value);
92 gboolean      hal_property_strlist_remove     (HalProperty  *prop,
93 					       const char *value);
94 gboolean      hal_property_strlist_clear      (HalProperty  *prop);
95 
96 
97 void          hal_property_set_attribute      (HalProperty *prop,
98 					       enum PropertyAttribute attr,
99 					       gboolean val);
100 gboolean      hal_property_get_attribute      (HalProperty *prop,
101 					       enum PropertyAttribute attr);
102 
103 #endif /* PROPERTY_H */
104