1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
/***************************************************************************
* CVSID: $Id$
*
* device.c : HalDevice methods
*
* Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
* Copyright (C) 2004 Novell, Inc.
*
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
**************************************************************************/
#ifndef DEVICE_H
#define DEVICE_H
#ifndef DBUS_API_SUBJECT_TO_CHANGE
#define DBUS_API_SUBJECT_TO_CHANGE
#endif
#include <glib-object.h>
#include <dbus/dbus.h>
struct _HalDevicePrivate;
typedef struct _HalDevicePrivate HalDevicePrivate;
typedef struct _HalDevice HalDevice;
typedef struct _HalDeviceClass HalDeviceClass;
struct _HalDevice {
GObject parent;
HalDevicePrivate *private;
};
struct _HalDeviceClass {
GObjectClass parent_class;
/* signals */
void (*property_changed) (HalDevice *device,
const char *key,
gboolean removed,
gboolean added);
void (*capability_added) (HalDevice *device,
const char *capability);
void (*lock_acquired) (HalDevice *device,
const char *lock_name,
const char *lock_owner);
void (*lock_released) (HalDevice *device,
const char *lock_name,
const char *lock_owner);
};
#define HAL_TYPE_DEVICE (hal_device_get_type ())
#define HAL_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
HAL_TYPE_DEVICE, HalDevice))
#define HAL_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
HAL_TYPE_DEVICE, HalDeviceClass))
#define HAL_IS_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
HAL_TYPE_DEVICE))
#define HAL_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
HAL_TYPE_DEVICE))
#define HAL_PROPERTY_TYPE_INVALID DBUS_TYPE_INVALID
#define HAL_PROPERTY_TYPE_INT32 DBUS_TYPE_INT32
#define HAL_PROPERTY_TYPE_UINT64 DBUS_TYPE_UINT64
#define HAL_PROPERTY_TYPE_DOUBLE DBUS_TYPE_DOUBLE
#define HAL_PROPERTY_TYPE_BOOLEAN DBUS_TYPE_BOOLEAN
#define HAL_PROPERTY_TYPE_STRING DBUS_TYPE_STRING
#define HAL_PROPERTY_TYPE_STRLIST ((int) (DBUS_TYPE_STRING<<8)+('l'))
/* private; do not access; might change in the future */
typedef struct _HalDeviceStrListIter HalDeviceStrListIter;
struct _HalDeviceStrListIter {
GSList *i;
};
typedef void (*HalDevicePropertyForeachFn) (HalDevice *device,
const char *key,
gpointer user_data);
GType hal_device_get_type (void);
HalDevice *hal_device_new (void);
void hal_device_merge_with_rewrite (HalDevice *target,
HalDevice *source,
const char *target_namespace,
const char *source_namespace);
const char *hal_device_get_udi (HalDevice *device);
void hal_device_set_udi (HalDevice *device,
const char *udi);
void hal_device_add_capability (HalDevice *device,
const char *capability);
gboolean hal_device_has_capability (HalDevice *device,
const char *capability);
gboolean hal_device_has_property (HalDevice *device,
const char *key);
int hal_device_num_properties (HalDevice *device);
char * hal_device_property_to_string (HalDevice *device,
const char *key);
void hal_device_property_foreach (HalDevice *device,
HalDevicePropertyForeachFn callback,
gpointer user_data);
int hal_device_property_get_type (HalDevice *device,
const char *key);
const char *hal_device_property_get_as_string (HalDevice *device,
const char *key,
char *buf,
size_t bufsize);
const char *hal_device_property_get_string (HalDevice *device,
const char *key);
dbus_int32_t hal_device_property_get_int (HalDevice *device,
const char *key);
dbus_uint64_t hal_device_property_get_uint64 (HalDevice *device,
const char *key);
dbus_bool_t hal_device_property_get_bool (HalDevice *device,
const char *key);
double hal_device_property_get_double (HalDevice *device,
const char *key);
const char *hal_device_property_get_strlist_elem (HalDevice *device,
const char *key,
guint index);
guint hal_device_property_get_strlist_length (HalDevice *device,
const char *key);
gboolean hal_device_property_strlist_contains (HalDevice *device,
const char *key,
const char *value);
char **hal_device_property_dup_strlist_as_strv (HalDevice *device,
const char *key);
void hal_device_property_strlist_iter_init (HalDevice *device,
const char *key,
HalDeviceStrListIter *iter);
const char *hal_device_property_strlist_iter_get_value (HalDeviceStrListIter *iter);
void hal_device_property_strlist_iter_next (HalDeviceStrListIter *iter);
gboolean hal_device_property_strlist_iter_is_valid (HalDeviceStrListIter *iter);
gboolean hal_device_property_set_string (HalDevice *device,
const char *key,
const char *value);
gboolean hal_device_property_set_int (HalDevice *device,
const char *key,
dbus_int32_t value);
gboolean hal_device_property_set_uint64 (HalDevice *device,
const char *key,
dbus_uint64_t value);
gboolean hal_device_property_set_bool (HalDevice *device,
const char *key,
dbus_bool_t value);
gboolean hal_device_property_set_double (HalDevice *device,
const char *key,
double value);
gboolean hal_device_property_set_strlist (HalDevice *device,
const char *key,
GSList *value);
gboolean hal_device_property_strlist_append (HalDevice *device,
const char *key,
const char *value,
gboolean changeset);
gboolean hal_device_property_strlist_append_finish_changeset (HalDevice *device,
const char *key,
gboolean is_added);
gboolean hal_device_property_strlist_prepend (HalDevice *device,
const char *key,
const char *value);
gboolean hal_device_property_strlist_remove_elem (HalDevice *device,
const char *key,
guint index);
gboolean hal_device_property_strlist_clear (HalDevice *device,
const char *key,
gboolean changeset);
gboolean hal_device_property_strlist_add (HalDevice *device,
const char *key,
const char *value);
gboolean hal_device_property_strlist_remove (HalDevice *device,
const char *key,
const char *value);
gboolean hal_device_property_strlist_is_empty (HalDevice *device,
const char *key);
gboolean hal_device_property_remove (HalDevice *device,
const char *key);
void hal_device_print (HalDevice *device);
gboolean hal_device_copy_property (HalDevice *from_device,
const char *from,
HalDevice *to_device,
const char *to);
void hal_device_inc_num_addons (HalDevice *device);
gboolean hal_device_inc_num_ready_addons (HalDevice *device);
gboolean hal_device_are_all_addons_ready (HalDevice *device);
gboolean hal_device_acquire_lock (HalDevice *device, const char *lock_name, gboolean exclusive, const char *sender);
gboolean hal_device_release_lock (HalDevice *device, const char *lock_name, const char *sender);
gboolean hal_device_is_lock_exclusive (HalDevice *device, const char *lock_name);
char **hal_device_get_lock_holders (HalDevice *device, const char *lock_name);
int hal_device_get_num_lock_holders (HalDevice *device, const char *lock_name);
/* static method */
void hal_device_client_disconnected (const char *sender);
#endif /* DEVICE_H */
|