hal/hald device.c, 1.12, 1.13 device_info.c, 1.21, 1.22 hald_dbus.c,
1.21, 1.22 hald_test.c, 1.2, 1.3 hald_test_libhal.c, 1.2,
1.3 property.c, 1.10, 1.11 property.h, 1.6, 1.7 util.c, 1.3, 1.4
David Zeuthen
david at freedesktop.org
Mon Feb 14 10:20:07 PST 2005
Update of /cvs/hal/hal/hald
In directory gabe:/tmp/cvs-serv18090/hald
Modified Files:
device.c device_info.c hald_dbus.c hald_test.c
hald_test_libhal.c property.c property.h util.c
Log Message:
2005-02-14 David Zeuthen <davidz at redhat.com>
* configure.in: Require dbus >= 0.30
2005-02-11 John (J5) Palmieri <johnp at redhat.com>
* hald/device.c, hald/device_info.c, hald/property.c, hald/property.h,
tools/hal_set_property.c, tools/hal_get_property.c:
s/HAL_PROPERTY_TYPE_NIL/HAL_PROPERTY_TYPE_INVALID
* hald/hald_dbus.c: ported to new dbus-0.30 API
(foreach_property_append): implemented real string lists
and got rid of the \tval\tval\tval\t hack
* libhal/libhal.c: ported to new dbus-0.30 API
s/HAL_PROPERTY_TYPE_NIL/HAL_PROPERTY_TYPE_INVALID
(libhal_get_string_array_from_iter): new helper function to create
string arrays from dbus arrays
(libhal_property_fill_value_from_variant): new helper function
that fills in properties from variants. Used when getting
a hash of properties from hald
* libhal/libhal.h: s/HAL_PROPERTY_TYPE_NIL/HAL_PROPERTY_TYPE_INVALID
HAL_PROPERTY_TYPE_INVALID = DBUS_TYPE_INVALID
* hald/hald_test_libhal.c: ported to new dbus-0.30 API
Added success messages and more detailed failed messages
* hald/util.c (hal_util_compute_udi): Change all illegal characters
to underscores '_'
* tools/device-manager/DeviceManager.py
(DeviceManager::__init__, add_device_signal_recv):
change add_signal_receiver calls to add expand_args=False parameter.
(DeviceManager::device_changed, gdl_changed): changed handlers
to conform with the new way we call signal handlers
Index: device.c
===================================================================
RCS file: /cvs/hal/hal/hald/device.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- device.c 31 Jan 2005 20:06:39 -0000 1.12
+++ device.c 14 Feb 2005 18:20:04 -0000 1.13
@@ -204,7 +204,7 @@
/* only remove target if it exists with a different type */
target_type = hal_device_property_get_type (target, key);
- if (target_type != HAL_PROPERTY_TYPE_NIL && target_type != type)
+ if (target_type != HAL_PROPERTY_TYPE_INVALID && target_type != type)
hal_device_property_remove (target, key);
switch (type) {
@@ -274,7 +274,7 @@
/* only remove target if it exists with a different type */
target_type = hal_device_property_get_type (target, key);
- if (target_type != HAL_PROPERTY_TYPE_NIL && target_type != type)
+ if (target_type != HAL_PROPERTY_TYPE_INVALID && target_type != type)
hal_device_property_remove (target, key);
switch (type) {
@@ -536,15 +536,15 @@
{
HalProperty *prop;
- g_return_val_if_fail (device != NULL, HAL_PROPERTY_TYPE_NIL);
- g_return_val_if_fail (key != NULL, HAL_PROPERTY_TYPE_NIL);
+ g_return_val_if_fail (device != NULL, HAL_PROPERTY_TYPE_INVALID);
+ g_return_val_if_fail (key != NULL, HAL_PROPERTY_TYPE_INVALID);
prop = hal_device_property_find (device, key);
if (prop != NULL)
return hal_property_get_type (prop);
else
- return HAL_PROPERTY_TYPE_NIL;
+ return HAL_PROPERTY_TYPE_INVALID;
}
const char *
Index: device_info.c
===================================================================
RCS file: /cvs/hal/hal/hald/device_info.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- device_info.c 10 Feb 2005 17:03:57 -0000 1.21
+++ device_info.c 14 Feb 2005 18:20:04 -0000 1.22
@@ -981,7 +981,7 @@
case MERGE_TYPE_STRLIST:
{
int type = hal_device_property_get_type (pc->device, pc->merge_key);
- if (type == HAL_PROPERTY_TYPE_STRLIST || type == HAL_PROPERTY_TYPE_NIL) {
+ if (type == HAL_PROPERTY_TYPE_STRLIST || type == HAL_PROPERTY_TYPE_INVALID) {
hal_device_property_remove (pc->device, pc->merge_key);
hal_device_property_strlist_append (pc->device, pc->merge_key, pc->cdata_buf);
}
@@ -1065,7 +1065,7 @@
} else if (pc->curelem == CURELEM_APPEND && pc->match_ok &&
(hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_STRING ||
hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_STRLIST ||
- hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_NIL)) {
+ hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_INVALID)) {
char buf[256];
char buf2[256];
@@ -1103,7 +1103,7 @@
} else if (pc->curelem == CURELEM_PREPEND && pc->match_ok &&
(hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_STRING ||
hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_STRLIST ||
- hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_NIL)) {
+ hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_INVALID)) {
char buf[256];
char buf2[256];
Index: hald_dbus.c
===================================================================
RCS file: /cvs/hal/hal/hald/hald_dbus.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- hald_dbus.c 2 Feb 2005 20:44:25 -0000 1.21
+++ hald_dbus.c 14 Feb 2005 18:20:04 -0000 1.22
@@ -260,8 +260,11 @@
gpointer user_data)
{
DBusMessageIter *iter = user_data;
+ const char *udi;
- dbus_message_iter_append_string (iter, hal_device_get_udi (device));
+ udi = hal_device_get_udi (device);
+
+ dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &udi);
return TRUE;
}
@@ -290,14 +293,18 @@
if (reply == NULL)
DIE (("No memory"));
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_append_array (&iter, &iter_array,
- DBUS_TYPE_STRING);
+ dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_open_container (&iter,
+ DBUS_TYPE_ARRAY,
+ DBUS_TYPE_STRING_AS_STRING,
+ &iter_array);
hal_device_store_foreach (hald_get_gdl (),
foreach_device_get_udi,
&iter_array);
+ dbus_message_iter_close_container (&iter, &iter_array);
+
if (!dbus_connection_send (connection, reply, NULL))
DIE (("No memory"));
@@ -326,8 +333,11 @@
dev_value = hal_device_property_get_string (device, info->key);
if (dev_value != NULL && strcmp (dev_value, info->value) == 0) {
- dbus_message_iter_append_string (info->iter,
- hal_device_get_udi (device));
+ const char *udi;
+ udi = hal_device_get_udi (device);
+ dbus_message_iter_append_basic (info->iter,
+ DBUS_TYPE_STRING,
+ &udi);
}
return TRUE;
@@ -352,8 +362,12 @@
dev_value = hal_device_property_get_string (device, info->key);
if (dev_value != NULL && strcmp (dev_value, info->value) == 0) {
- dbus_message_iter_append_string (info->iter,
- hal_device_get_udi (device));
+ const char *udi;
+ udi = hal_device_get_udi (device);
+
+ dbus_message_iter_append_basic (info->iter,
+ DBUS_TYPE_STRING,
+ &udi);
}
return TRUE;
@@ -399,9 +413,11 @@
if (reply == NULL)
DIE (("No memory"));
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_append_array (&iter, &iter_array,
- DBUS_TYPE_STRING);
+ dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_open_container (&iter,
+ DBUS_TYPE_ARRAY,
+ DBUS_TYPE_STRING_AS_STRING,
+ &iter_array);
info.key = key;
info.value = value;
@@ -416,6 +432,8 @@
foreach_device_match_get_udi_tdl,
&info);
+ dbus_message_iter_close_container (&iter, &iter_array);
+
if (!dbus_connection_send (connection, reply, NULL))
DIE (("No memory"));
@@ -439,8 +457,12 @@
caps = hal_device_property_get_string (device, "info.capabilities");
if (caps != NULL && strstr (caps, info->capability) != NULL) {
- dbus_message_iter_append_string (info->iter,
- hal_device_get_udi (device));
+ const char *udi;
+ udi = hal_device_get_udi (device);
+
+ dbus_message_iter_append_basic (info->iter,
+ DBUS_TYPE_STRING,
+ &udi);
}
return TRUE;
@@ -482,9 +504,11 @@
if (reply == NULL)
DIE (("No memory"));
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_append_array (&iter, &iter_array,
- DBUS_TYPE_STRING);
+ dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_open_container (&iter,
+ DBUS_TYPE_ARRAY,
+ DBUS_TYPE_ARRAY_AS_STRING,
+ &iter_array);
info.capability = capability;
info.iter = &iter_array;
@@ -493,6 +517,8 @@
foreach_device_by_capability,
&info);
+ dbus_message_iter_close_container (&iter, &iter_array);
+
if (!dbus_connection_send (connection, reply, NULL))
DIE (("No memory"));
@@ -520,6 +546,7 @@
DBusError error;
HalDevice *d;
const char *udi;
+ dbus_bool_t b;
dbus_error_init (&error);
if (!dbus_message_get_args (message, &error,
@@ -537,8 +564,9 @@
d = hal_device_store_find (hald_get_tdl (), udi);
reply = dbus_message_new_method_return (message);
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_append_boolean (&iter, d != NULL);
+ dbus_message_iter_init_append (reply, &iter);
+ b = d != NULL;
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &b);
if (reply == NULL)
DIE (("No memory"));
@@ -568,8 +596,8 @@
"org.freedesktop.Hal.Manager",
"DeviceAdded");
- dbus_message_iter_init (message, &iter);
- dbus_message_iter_append_string (&iter, udi);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &udi);
if (!dbus_connection_send (dbus_connection, message, NULL))
DIE (("error broadcasting message"));
@@ -595,8 +623,8 @@
"org.freedesktop.Hal.Manager",
"DeviceRemoved");
- dbus_message_iter_init (message, &iter);
- dbus_message_iter_append_string (&iter, udi);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &udi);
if (!dbus_connection_send (dbus_connection, message, NULL))
DIE (("error broadcasting message"));
@@ -625,9 +653,9 @@
"org.freedesktop.Hal.Manager",
"NewCapability");
- dbus_message_iter_init (message, &iter);
- dbus_message_iter_append_string (&iter, udi);
- dbus_message_iter_append_string (&iter, capability);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &udi);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &capability);
if (!dbus_connection_send (dbus_connection, message, NULL))
DIE (("error broadcasting message"));
@@ -648,61 +676,168 @@
foreach_property_append (HalDevice *device, HalProperty *p,
gpointer user_data)
{
- DBusMessageIter *iter = user_data;
+ DBusMessageIter *iter;
+ DBusMessageIter iter_dict_entry;
const char *key;
int type;
+ iter = (DBusMessageIter *)user_data;
+
+ dbus_message_iter_open_container (iter,
+ DBUS_TYPE_DICT_ENTRY,
+ NULL,
+ &iter_dict_entry);
+
key = hal_property_get_key (p);
type = hal_property_get_type (p);
+ dbus_message_iter_append_basic (&iter_dict_entry, DBUS_TYPE_STRING, &key);
+
switch (type) {
case HAL_PROPERTY_TYPE_STRING:
- dbus_message_iter_append_dict_key (iter, key);
- dbus_message_iter_append_string (iter, hal_property_get_string (p));
+ {
+ DBusMessageIter iter_var;
+ const char *v;
+
+ v = hal_property_get_string (p);
+
+ dbus_message_iter_open_container (&iter_dict_entry,
+ DBUS_TYPE_VARIANT,
+ DBUS_TYPE_STRING_AS_STRING,
+ &iter_var);
+
+ dbus_message_iter_append_basic (&iter_var,
+ DBUS_TYPE_STRING,
+ &v);
+
+ dbus_message_iter_close_container (&iter_dict_entry,
+ &iter_var);
break;
+ }
case HAL_PROPERTY_TYPE_INT32:
- dbus_message_iter_append_dict_key (iter, key);
- dbus_message_iter_append_int32 (iter, hal_property_get_int (p));
+ {
+ DBusMessageIter iter_var;
+ dbus_int32_t v;
+
+ v = hal_property_get_int (p);
+
+ dbus_message_iter_open_container (&iter_dict_entry,
+ DBUS_TYPE_VARIANT,
+ DBUS_TYPE_INT32_AS_STRING,
+ &iter_var);
+
+ dbus_message_iter_append_basic (&iter_var,
+ DBUS_TYPE_INT32,
+ &v);
+
+ dbus_message_iter_close_container (&iter_dict_entry,
+ &iter_var);
break;
+ }
case HAL_PROPERTY_TYPE_UINT64:
- dbus_message_iter_append_dict_key (iter, key);
- dbus_message_iter_append_uint64 (iter, hal_property_get_uint64 (p));
+ {
+ DBusMessageIter iter_var;
+ dbus_uint64_t v;
+
+ v = hal_property_get_uint64 (p);
+
+ dbus_message_iter_open_container (&iter_dict_entry,
+ DBUS_TYPE_VARIANT,
+ DBUS_TYPE_UINT64_AS_STRING,
+ &iter_var);
+
+ dbus_message_iter_append_basic (&iter_var,
+ DBUS_TYPE_UINT64,
+ &v);
+
+ dbus_message_iter_close_container (&iter_dict_entry,
+ &iter_var);
break;
+ }
case HAL_PROPERTY_TYPE_DOUBLE:
- dbus_message_iter_append_dict_key (iter, key);
- dbus_message_iter_append_double (iter, hal_property_get_double (p));
+ {
+ DBusMessageIter iter_var;
+ double v;
+
+ v = hal_property_get_double (p);
+
+ dbus_message_iter_open_container (&iter_dict_entry,
+ DBUS_TYPE_VARIANT,
+ DBUS_TYPE_DOUBLE_AS_STRING,
+ &iter_var);
+
+ dbus_message_iter_append_basic (&iter_var,
+ DBUS_TYPE_DOUBLE,
+ &v);
+
+ dbus_message_iter_close_container (&iter_dict_entry,
+ &iter_var);
break;
+ }
case HAL_PROPERTY_TYPE_BOOLEAN:
- dbus_message_iter_append_dict_key (iter, key);
- dbus_message_iter_append_boolean (iter, hal_property_get_bool (p));
+ {
+ DBusMessageIter iter_var;
+ dbus_bool_t v;
+
+ v = hal_property_get_bool (p);
+
+ dbus_message_iter_open_container (&iter_dict_entry,
+ DBUS_TYPE_VARIANT,
+ DBUS_TYPE_BOOLEAN_AS_STRING,
+ &iter_var);
+
+ dbus_message_iter_append_basic (&iter_var,
+ DBUS_TYPE_BOOLEAN,
+ &v);
+
+ dbus_message_iter_close_container (&iter_dict_entry,
+ &iter_var);
break;
+ }
case HAL_PROPERTY_TYPE_STRLIST:
{
- char buf[256];
+ DBusMessageIter iter_var, iter_array;
+ GSList *iter;
- /* yikes, this is *really* ugly - we kind of have to do it, as D-BUS as of 0.23 doesn't
- * support anything but primitive types as dict values. D-BUS CVS as of Jan 27, 2005
- * should work (since it got recursive data types); TODO FIXME HACK XXX
- *
- * So, instead, send it over the wire as '\tval1\tval2\tval3\t' and put some brains
- * in the other end (libhal) to clean it up...
- *
- * Of course, this will sort of break stuff not using libhal.
- *
- * I did say *really* ugly... sue me..
- */
+ dbus_message_iter_open_container (&iter_dict_entry,
+ DBUS_TYPE_VARIANT,
+ DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING,
+ &iter_var);
+
+ dbus_message_iter_open_container (&iter_var,
+ DBUS_TYPE_ARRAY,
+ DBUS_TYPE_STRING_AS_STRING,
+ &iter_array);
+
+ for (iter = hal_property_get_strlist (p);
+ iter != NULL;
+ iter = iter->next) {
+
+ const char *v;
+ v = (const char *) iter->data;
+
+ dbus_message_iter_append_basic (&iter_array,
+ DBUS_TYPE_STRING,
+ &v);
+ }
- dbus_message_iter_append_dict_key (iter, key);
- dbus_message_iter_append_string (iter,
- hal_device_property_get_as_string (device, key, buf, sizeof (buf)));
- }
+ dbus_message_iter_close_container (&iter_var,
+ &iter_array);
+
+ dbus_message_iter_close_container (&iter_dict_entry,
+ &iter_var);
break;
+ }
default:
HAL_WARNING (("Unknown property type 0x%04x", type));
break;
}
+ dbus_message_iter_close_container (iter, &iter_dict_entry);
+
+
return TRUE;
}
@@ -747,13 +882,22 @@
if (reply == NULL)
DIE (("No memory"));
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_append_dict (&iter, &iter_dict);
+ dbus_message_iter_init_append (reply, &iter);
+
+ dbus_message_iter_open_container (&iter,
+ DBUS_TYPE_ARRAY,
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+ &iter_dict);
hal_device_property_foreach (d,
foreach_property_append,
&iter_dict);
+ dbus_message_iter_close_container (&iter, &iter_dict);
+
if (!dbus_connection_send (connection, reply, NULL))
DIE (("No memory"));
@@ -823,33 +967,60 @@
if (reply == NULL)
DIE (("No memory"));
- dbus_message_iter_init (reply, &iter);
+ dbus_message_iter_init_append (reply, &iter);
type = hal_property_get_type (p);
switch (type) {
case HAL_PROPERTY_TYPE_STRING:
- dbus_message_iter_append_string (&iter, hal_property_get_string (p));
+ {
+ const char *s;
+ s = hal_property_get_string (p);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &s);
break;
+ }
case HAL_PROPERTY_TYPE_INT32:
- dbus_message_iter_append_int32 (&iter, hal_property_get_int (p));
+ {
+ dbus_int32_t i;
+ i = hal_property_get_int (p);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &i);
break;
+ }
case HAL_PROPERTY_TYPE_UINT64:
- dbus_message_iter_append_uint64 (&iter, hal_property_get_uint64 (p));
+ {
+ dbus_uint64_t ul;
+ ul = hal_property_get_uint64 (p);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT64, &ul);
break;
+ }
case HAL_PROPERTY_TYPE_DOUBLE:
- dbus_message_iter_append_double (&iter, hal_property_get_double (p));
+ {
+ double d;
+ d = hal_property_get_double (p);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_DOUBLE, &d);
break;
+ }
case HAL_PROPERTY_TYPE_BOOLEAN:
- dbus_message_iter_append_boolean (&iter, hal_property_get_bool (p));
+ {
+ dbus_bool_t b;
+ b = hal_property_get_bool (p);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &b);
break;
+ }
case HAL_PROPERTY_TYPE_STRLIST:
{
GSList *l;
DBusMessageIter iter_array;
- dbus_message_iter_append_array (&iter, &iter_array, DBUS_TYPE_STRING);
+
+ dbus_message_iter_open_container (&iter,
+ DBUS_TYPE_ARRAY,
+ DBUS_TYPE_STRING_AS_STRING,
+ &iter_array);
+
for (l = hal_property_get_strlist (p); l != NULL; l = g_slist_next (l)) {
- dbus_message_iter_append_string (&iter_array, l->data);
+ dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_STRING, &(l->data));
}
+
+ dbus_message_iter_close_container (&iter, &iter_array);
}
break;
@@ -891,6 +1062,7 @@
const char *udi;
char *key;
HalProperty *p;
+ dbus_int32_t i;
udi = dbus_message_get_path (message);
@@ -923,9 +1095,9 @@
if (reply == NULL)
DIE (("No memory"));
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_append_int32 (&iter,
- hal_property_get_type (p));
+ i = hal_property_get_type (p);
+ dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &i);
if (!dbus_connection_send (connection, reply, NULL))
DIE (("No memory"));
@@ -1007,7 +1179,7 @@
raise_syntax (connection, message, "SetProperty");
return DBUS_HANDLER_RESULT_HANDLED;
}
- key = dbus_message_iter_get_string (&iter);
+ dbus_message_iter_get_basic (&iter, &key);
if (!sender_has_privileges (connection, message)) {
raise_permission_denied (connection, message, "SetProperty: not privileged");
@@ -1033,31 +1205,55 @@
switch (type) {
case DBUS_TYPE_STRING:
- rc = hal_device_property_set_string (device, key,
- dbus_message_iter_get_string
- (&iter));
+ {
+ const char *v;
+
+ dbus_message_iter_get_basic (&iter, &v);
+
+ rc = hal_device_property_set_string (device, key, v);
+
break;
+ }
case DBUS_TYPE_INT32:
- rc = hal_device_property_set_int (device, key,
- dbus_message_iter_get_int32
- (&iter));
+ {
+ dbus_int32_t v;
+
+ dbus_message_iter_get_basic (&iter, &v);
+
+ rc = hal_device_property_set_int (device, key, v);
+
break;
+ }
case DBUS_TYPE_UINT64:
- rc = hal_device_property_set_uint64 (device, key,
- dbus_message_iter_get_uint64
- (&iter));
+ {
+ dbus_uint64_t v;
+
+ dbus_message_iter_get_basic (&iter, &v);
+
+ rc = hal_device_property_set_uint64 (device, key, v);
+
break;
+ }
case DBUS_TYPE_DOUBLE:
- rc = hal_device_property_set_double (device, key,
- dbus_message_iter_get_double
- (&iter));
+ {
+ double v;
+
+ dbus_message_iter_get_basic (&iter, &v);
+
+ rc = hal_device_property_set_double (device, key, v);
+
break;
+ }
case DBUS_TYPE_BOOLEAN:
- rc = hal_device_property_set_bool (device, key,
- dbus_message_iter_get_boolean
- (&iter));
- break;
+ {
+ dbus_bool_t v;
+
+ dbus_message_iter_get_basic (&iter, &v);
+ rc = hal_device_property_set_bool (device, key, v);
+
+ break;
+ }
default:
HAL_WARNING (("Unsupported property type %d", type));
break;
@@ -1319,6 +1515,7 @@
DBusMessage *reply;
DBusError error;
DBusMessageIter iter;
+ dbus_bool_t b;
HAL_TRACE (("entering"));
@@ -1345,9 +1542,9 @@
if (reply == NULL)
DIE (("No memory"));
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_append_boolean (&iter,
- hal_device_has_property (d, key));
+ b = hal_device_has_property (d, key);
+ dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &b);
if (!dbus_connection_send (connection, reply, NULL))
DIE (("No memory"));
@@ -1425,8 +1622,8 @@
dbus_free (capability);
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_append_boolean (&iter, rc);
+ dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &rc);
if (!dbus_connection_send (connection, reply, NULL))
DIE (("No memory"));
@@ -1686,18 +1883,24 @@
pu_iter->udi,
"org.freedesktop.Hal.Device",
"PropertyModified");
- dbus_message_iter_init (message, &iter);
- dbus_message_iter_append_int32 (&iter,
- num_updates_this);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32,
+ &num_updates_this);
for (pu_iter2 = pu_iter; pu_iter2 != NULL;
pu_iter2 = pu_iter2->next) {
if (strcmp (pu_iter2->udi, pu_iter->udi) == 0) {
- dbus_message_iter_append_string
- (&iter, pu_iter2->key);
- dbus_message_iter_append_boolean
- (&iter, pu_iter2->removed);
- dbus_message_iter_append_boolean
- (&iter, pu_iter2->added);
+ dbus_message_iter_append_basic
+ (&iter,
+ DBUS_TYPE_STRING,
+ &(pu_iter2->key));
+ dbus_message_iter_append_basic
+ (&iter,
+ DBUS_TYPE_BOOLEAN,
+ &(pu_iter2->removed));
+ dbus_message_iter_append_basic
+ (&iter,
+ DBUS_TYPE_BOOLEAN,
+ &(pu_iter2->added));
/* signal this is already processed */
if (pu_iter2 != pu_iter) {
@@ -1755,15 +1958,20 @@
pending_updates_head = pu;
num_pending_updates++;
} else {
+ dbus_int32_t i;
+
message = dbus_message_new_signal (udi,
"org.freedesktop.Hal.Device",
"PropertyModified");
- dbus_message_iter_init (message, &iter);
- dbus_message_iter_append_int32 (&iter, 1);
- dbus_message_iter_append_string (&iter, key);
- dbus_message_iter_append_boolean (&iter, removed);
- dbus_message_iter_append_boolean (&iter, added);
+ dbus_message_iter_init_append (message, &iter);
+ i = 1;
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &i);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &key);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN,
+ &removed);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN,
+ &added);
if (!dbus_connection_send (dbus_connection, message, NULL))
DIE (("error broadcasting message"));
@@ -1803,8 +2011,10 @@
message = dbus_message_new_signal (udi,
"org.freedesktop.Hal.Device",
"Condition");
- dbus_message_iter_init (message, &iter);
- dbus_message_iter_append_string (&iter, condition_name);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter,
+ DBUS_TYPE_STRING,
+ &condition_name);
va_start (var_args, first_arg_type);
dbus_message_append_args_valist (message, first_arg_type,
@@ -1837,7 +2047,7 @@
if (!dbus_message_get_args (message, NULL,
DBUS_TYPE_STRING, &service_name,
DBUS_TYPE_INVALID)) {
- HAL_ERROR (("Invalid ServiceDeleted signal from bus!"));
+ HAL_ERROR (("Invalid NameLost signal from bus!"));
return;
}
@@ -1888,8 +2098,8 @@
reply = dbus_message_new_method_return (message);
if (reply == NULL)
DIE (("No memory"));
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_append_boolean (&iter, res);
+ dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &res);
if (!dbus_connection_send (connection, reply, NULL))
DIE (("No memory"));
@@ -1932,8 +2142,8 @@
reply = dbus_message_new_method_return (message);
if (reply == NULL)
DIE (("No memory"));
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_append_boolean (&iter, res);
+ dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &res);
if (!dbus_connection_send (connection, reply, NULL))
DIE (("No memory"));
@@ -1967,7 +2177,7 @@
} else if (dbus_message_is_signal (message,
DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS,
- "ServiceDeleted")) {
+ "NameLost")) {
if (services_with_locks != NULL)
service_deleted (message);
@@ -2115,10 +2325,10 @@
dbus_connection_setup_with_g_main (dbus_connection, NULL);
dbus_connection_set_exit_on_disconnect (dbus_connection, FALSE);
- dbus_bus_acquire_service (dbus_connection, "org.freedesktop.Hal",
+ dbus_bus_request_name (dbus_connection, "org.freedesktop.Hal",
0, &dbus_error);
if (dbus_error_is_set (&dbus_error)) {
- HAL_ERROR (("dbus_bus_acquire_service(): %s",
+ HAL_ERROR (("dbus_bus_request_name(): %s",
dbus_error.message));
return FALSE;
}
@@ -2130,7 +2340,7 @@
"type='signal',"
"interface='"DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS"',"
"sender='"DBUS_SERVICE_ORG_FREEDESKTOP_DBUS"',"
- "member='ServiceDeleted'",
+ "member='NameLost'",
NULL);
return TRUE;
Index: hald_test.c
===================================================================
RCS file: /cvs/hal/hal/hald/hald_test.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- hald_test.c 2 Feb 2005 20:44:25 -0000 1.2
+++ hald_test.c 14 Feb 2005 18:20:04 -0000 1.3
@@ -561,3 +561,13 @@
out:
return num_tests_failed;
}
+
+gboolean osspec_device_rescan (HalDevice *d)
+{
+ return FALSE;
+}
+
+gboolean osspec_device_reprobe (HalDevice *d)
+{
+ return FALSE;
+}
Index: hald_test_libhal.c
===================================================================
RCS file: /cvs/hal/hal/hald/hald_test_libhal.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- hald_test_libhal.c 2 Feb 2005 20:44:25 -0000 1.2
+++ hald_test_libhal.c 14 Feb 2005 18:20:04 -0000 1.3
@@ -66,8 +66,8 @@
goto out;
}
- dbus_message_iter_init (message, &iter);
- dbus_message_iter_append_boolean (&iter, passed);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &passed);
dbus_error_init (&error);
reply = dbus_connection_send_with_reply_and_block (conn, message, -1, &error);
@@ -122,20 +122,39 @@
/* TODO: handle */
}
+
libhal_ctx_set_dbus_connection (ctx, conn);
+
libhal_ctx_init (ctx, &error);
+
+ if (dbus_error_is_set (&error)) {
+ printf ("FAILED98: %s\n", error.message);
+ goto fail;
+ }
+ printf ("SUCCESS98\n");
+
libhal_device_print (ctx, "/org/freedesktop/Hal/devices/testobj1", &error);
+
+ if (dbus_error_is_set (&error)) {
+ printf ("FAILED99: %s\n", error.message);
+ goto fail;
+ }
+ printf ("SUCCESS99\n");
+
passed = FALSE;
{
char *val;
+
val = libhal_device_get_property_string (ctx, "/org/freedesktop/Hal/devices/testobj1", "test.string", &error);
+
if (val == NULL || strcmp (val, "fooooobar22") != 0 || dbus_error_is_set (&error)) {
libhal_free_string (val);
printf ("FAILED100\n");
goto fail;
}
+ printf ("SUCCESS100\n");
libhal_free_string (val);
}
@@ -144,18 +163,24 @@
val = libhal_device_get_property_string (ctx, "/org/freedesktop/Hal/devices/testobj1", "test.string2", &error);
if (val == NULL || strcmp (val, "fooøة×") != 0 || dbus_error_is_set (&error)) {
libhal_free_string (val);
- printf ("FAILED100\n");
+ printf ("FAILED101: %s\n", error.message);
goto fail;
}
libhal_free_string (val);
+ printf ("SUCCESS101\n");
}
-
- if (libhal_device_get_property_bool (
- ctx, "/org/freedesktop/Hal/devices/testobj1", "test.bool", &error) != TRUE ||
- dbus_error_is_set (&error)) {
- printf ("FAILED102\n");
- goto fail;
+ {
+ dbus_bool_t b;
+ b = libhal_device_get_property_bool (
+ ctx, "/org/freedesktop/Hal/devices/testobj1",
+ "test.bool", &error);
+
+ if (!b || dbus_error_is_set (&error)) {
+ printf ("FAILED102: %s, %i\n", error.message, b);
+ goto fail;
+ }
+ printf ("SUCCESS102\n");
}
{
@@ -168,30 +193,34 @@
printf ("FAILED103\n");
goto fail;
}
+ printf ("SUCCESS103\n");
}
if (libhal_device_get_property_uint64 (
ctx, "/org/freedesktop/Hal/devices/testobj1", "test.uint64", &error) !=
((((dbus_uint64_t)1)<<35) + 5) ||
dbus_error_is_set (&error)) {
- printf ("FAILED104\n");
+ printf ("FAILED104: %s\n", error.message);
goto fail;
}
-
+ printf ("SUCCESS104\n");
+
{
char **val;
val = libhal_device_get_property_strlist (ctx, "/org/freedesktop/Hal/devices/testobj1", "test.strlist", &error);
if (val == NULL || dbus_error_is_set (&error)) {
libhal_free_string_array (val);
- printf ("FAILED105\n");
+ printf ("FAILED105: %s\n", error.message);
goto fail;
}
-
+ printf ("SUCCESS105\n");
+
if (libhal_string_array_length (val) != 2) {
libhal_free_string_array (val);
printf ("FAILED106\n");
goto fail;
}
+ printf ("SUCCESS106\n");
if (strcmp (val[0], "foostrlist2") != 0 ||
strcmp (val[1], "foostrlist3") != 0) {
@@ -199,6 +228,7 @@
printf ("FAILED107\n");
goto fail;
}
+ printf ("SUCCESS107\n");
libhal_free_string_array (val);
}
@@ -209,6 +239,8 @@
printf ("FAILED108\n");
goto fail;
}
+ printf ("SUCCESS108\n");
+
printf ("Passed all libhal tests\n");
passed = TRUE;
Index: property.c
===================================================================
RCS file: /cvs/hal/hal/hald/property.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- property.c 8 Feb 2005 16:44:20 -0000 1.10
+++ property.c 14 Feb 2005 18:20:04 -0000 1.11
@@ -164,7 +164,7 @@
int
hal_property_get_type (HalProperty *prop)
{
- g_return_val_if_fail (prop != NULL, HAL_PROPERTY_TYPE_NIL);
+ g_return_val_if_fail (prop != NULL, HAL_PROPERTY_TYPE_INVALID);
return prop->type;
}
@@ -270,7 +270,7 @@
g_return_if_fail (prop != NULL);
g_return_if_fail (prop->type == HAL_PROPERTY_TYPE_STRING ||
- prop->type == HAL_PROPERTY_TYPE_NIL);
+ prop->type == HAL_PROPERTY_TYPE_INVALID);
prop->type = HAL_PROPERTY_TYPE_STRING;
prop->str_value = g_strdup (value);
@@ -292,7 +292,7 @@
{
g_return_if_fail (prop != NULL);
g_return_if_fail (prop->type == HAL_PROPERTY_TYPE_INT32 ||
- prop->type == HAL_PROPERTY_TYPE_NIL);
+ prop->type == HAL_PROPERTY_TYPE_INVALID);
prop->type = HAL_PROPERTY_TYPE_INT32;
prop->int_value = value;
@@ -303,7 +303,7 @@
{
g_return_if_fail (prop != NULL);
g_return_if_fail (prop->type == HAL_PROPERTY_TYPE_UINT64 ||
- prop->type == HAL_PROPERTY_TYPE_NIL);
+ prop->type == HAL_PROPERTY_TYPE_INVALID);
prop->type = HAL_PROPERTY_TYPE_UINT64;
prop->uint64_value = value;
@@ -314,7 +314,7 @@
{
g_return_if_fail (prop != NULL);
g_return_if_fail (prop->type == HAL_PROPERTY_TYPE_BOOLEAN ||
- prop->type == HAL_PROPERTY_TYPE_NIL);
+ prop->type == HAL_PROPERTY_TYPE_INVALID);
prop->type = HAL_PROPERTY_TYPE_BOOLEAN;
prop->bool_value = value;
@@ -325,7 +325,7 @@
{
g_return_if_fail (prop != NULL);
g_return_if_fail (prop->type == HAL_PROPERTY_TYPE_DOUBLE ||
- prop->type == HAL_PROPERTY_TYPE_NIL);
+ prop->type == HAL_PROPERTY_TYPE_INVALID);
prop->type = HAL_PROPERTY_TYPE_DOUBLE;
prop->double_value = value;
Index: property.h
===================================================================
RCS file: /cvs/hal/hal/hald/property.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- property.h 31 Jan 2005 20:06:39 -0000 1.6
+++ property.h 14 Feb 2005 18:20:04 -0000 1.7
@@ -31,7 +31,7 @@
typedef struct _HalProperty HalProperty;
-#define HAL_PROPERTY_TYPE_NIL DBUS_TYPE_NIL
+#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
Index: util.c
===================================================================
RCS file: /cvs/hal/hal/hald/util.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- util.c 10 Feb 2005 17:03:57 -0000 1.3
+++ util.c 14 Feb 2005 18:20:04 -0000 1.4
@@ -403,12 +403,18 @@
g_vsnprintf (buf, sizeof (buf), format, args);
va_end (args);
+ g_strcanon (buf,
+ "/_"
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "1234567890", '_');
+
g_strlcpy (dst, buf, dstsize);
if (hal_device_store_find (store, dst) == NULL)
goto out;
for (i = 0; ; i++) {
- g_snprintf (dst, dstsize, "%s-%d", buf, i);
+ g_snprintf (dst, dstsize, "%s_%d", buf, i);
if (hal_device_store_find (store, dst) == NULL)
goto out;
}
More information about the hal-commit
mailing list