hal/hald device.c, 1.8, 1.9 device.h, 1.7, 1.8 device_info.c, 1.11,
1.12 hald_dbus.c, 1.8, 1.9 property.c, 1.6, 1.7 property.h,
1.4, 1.5 pstore.c, 1.2, 1.3
David Zeuthen
david at freedesktop.org
Wed Sep 1 10:39:01 PDT 2004
Update of /cvs/hal/hal/hald
In directory gabe:/tmp/cvs-serv13914/hald
Modified Files:
device.c device.h device_info.c hald_dbus.c property.c
property.h pstore.c
Log Message:
2004-09-01 David Zeuthen <david at fubar.dk>
Patch from Jon Lech Johansen <jon at nanocrew.net>. Add support for
properties of 64-bit unsigned integers. Right now this is not used
as the D-BUS python bindings needs a patch.
* hald/device.c: (hal_device_merge_with_rewrite),
(hal_device_merge), (hal_device_matches),
(hal_device_property_get_uint64), (hal_device_property_set_uint64),
(hal_device_print):
* hald/device.h:
* hald/device_info.c: (handle_match), (handle_merge), (end):
* hald/hald_dbus.c: (foreach_property_append),
(device_get_property), (device_set_property):
* hald/linux/common.c: (parse_hex_uint64):
* hald/linux/common.h:
* hald/linux/ieee1394_node_class_device.c:
(ieee1394_node_class_pre_process):
* hald/linux/net_class_device.c: (net_class_pre_process):
* hald/property.c: (hal_property_new_uint64),
(hal_property_get_uint64), (hal_property_to_string),
(hal_property_set_uint64):
* hald/property.h:
* hald/pstore.c: (hal_pstore_save_property),
(hal_pstore_load_property):
* libhal/libhal.c: (hal_device_get_all_properties),
(hal_psi_get_uint64), (hal_device_get_property_uint64),
(hal_device_set_property_helper), (hal_device_set_property_string),
(hal_device_set_property_int), (hal_device_set_property_uint64),
(hal_device_set_property_double), (hal_device_set_property_bool),
(hal_device_remove_property), (hal_device_print):
* libhal/libhal.h:
* tools/device-manager/DeviceManager.py:
* tools/hal_get_property.c: (main):
* tools/hal_set_property.c: (usage), (main):
* tools/lshal.c: (dump_devices), (print_property):
Index: device.c
===================================================================
RCS file: /cvs/hal/hal/hald/device.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- device.c 25 Aug 2004 20:55:13 -0000 1.8
+++ device.c 1 Sep 2004 17:38:58 -0000 1.9
@@ -222,6 +222,12 @@
hal_property_get_int (p));
break;
+ case DBUS_TYPE_UINT64:
+ hal_device_property_set_uint64 (
+ target, target_key,
+ hal_property_get_uint64 (p));
+ break;
+
case DBUS_TYPE_BOOLEAN:
hal_device_property_set_bool (
target, target_key,
@@ -286,6 +292,12 @@
hal_property_get_int (p));
break;
+ case DBUS_TYPE_UINT64:
+ hal_device_property_set_uint64 (
+ target, key,
+ hal_property_get_uint64 (p));
+ break;
+
case DBUS_TYPE_BOOLEAN:
hal_device_property_set_bool (
target, key,
@@ -359,6 +371,12 @@
return FALSE;
break;
+ case DBUS_TYPE_UINT64:
+ if (hal_property_get_uint64 (p) !=
+ hal_device_property_get_uint64 (device2, key))
+ return FALSE;
+ break;
+
case DBUS_TYPE_BOOLEAN:
if (hal_property_get_bool (p) !=
hal_device_property_get_bool (device2, key))
@@ -562,6 +580,22 @@
return -1;
}
+dbus_uint64_t
+hal_device_property_get_uint64 (HalDevice *device, const char *key)
+{
+ HalProperty *prop;
+
+ g_return_val_if_fail (device != NULL, -1);
+ g_return_val_if_fail (key != NULL, -1);
+
+ prop = hal_device_property_find (device, key);
+
+ if (prop != NULL)
+ return hal_property_get_uint64 (prop);
+ else
+ return -1;
+}
+
dbus_bool_t
hal_device_property_get_bool (HalDevice *device, const char *key)
{
@@ -677,6 +711,46 @@
}
gboolean
+hal_device_property_set_uint64 (HalDevice *device, const char *key,
+ dbus_uint64_t value)
+{
+ HalProperty *prop;
+
+ /* check if property already exists */
+ prop = hal_device_property_find (device, key);
+
+ if (prop != NULL) {
+ if (hal_property_get_type (prop) != DBUS_TYPE_UINT64)
+ return FALSE;
+
+ /* don't bother setting the same value */
+ if (hal_property_get_uint64 (prop) == value)
+ return TRUE;
+
+ hal_property_set_uint64 (prop, value);
+
+ g_signal_emit (device, signals[PROPERTY_CHANGED], 0,
+ key, FALSE, FALSE);
+
+ if (hal_property_get_attribute (prop, PERSISTENCE) &&
+ hald_get_conf ()->persistent_device_list) {
+ hal_pstore_save_property (hald_get_pstore_sys (),
+ device, prop);
+ }
+
+ } else {
+ prop = hal_property_new_uint64 (key, value);
+
+ device->properties = g_slist_prepend (device->properties, prop);
+
+ g_signal_emit (device, signals[PROPERTY_CHANGED], 0,
+ key, FALSE, TRUE);
+ }
+
+ return TRUE;
+}
+
+gboolean
hal_device_property_set_bool (HalDevice *device, const char *key,
dbus_bool_t value)
{
@@ -839,6 +913,12 @@
hal_property_get_int (p));
break;
+ case DBUS_TYPE_UINT64:
+ fprintf (stderr, " %s = %lld 0x%llx (uint64)\n", key,
+ hal_property_get_uint64 (p),
+ hal_property_get_uint64 (p));
+ break;
+
case DBUS_TYPE_DOUBLE:
fprintf (stderr, " %s = %g (double)\n", key,
hal_property_get_double (p));
Index: device.h
===================================================================
RCS file: /cvs/hal/hal/hald/device.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- device.h 25 Aug 2004 20:55:13 -0000 1.7
+++ device.h 1 Sep 2004 17:38:58 -0000 1.8
@@ -121,6 +121,8 @@
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,
@@ -132,6 +134,9 @@
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);
Index: device_info.c
===================================================================
RCS file: /cvs/hal/hal/hald/device_info.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- device_info.c 15 Aug 2004 18:54:56 -0000 1.11
+++ device_info.c 1 Sep 2004 17:38:58 -0000 1.12
@@ -184,6 +184,25 @@
}
return TRUE;
+ } else if (strcmp (attr[2], "uint64") == 0) {
+ dbus_uint64_t value;
+
+ /* match integer property */
+ value = strtoull (attr[3], NULL, 0);
+
+ /** @todo Check error condition */
+
+ /*HAL_INFO (("Checking that key='%s' is a int that equals %d",
+ key, value));*/
+
+ if (hal_device_property_get_type (pc->device, key) != DBUS_TYPE_UINT64)
+ return FALSE;
+
+ if (hal_device_property_get_uint64 (pc->device, key) != value) {
+ return FALSE;
+ }
+
+ return TRUE;
} else if (strcmp (attr[2], "bool") == 0) {
dbus_bool_t value;
@@ -250,6 +269,10 @@
/* match string property */
pc->merge_type = DBUS_TYPE_INT32;
return;
+ } else if (strcmp (attr[3], "uint64") == 0) {
+ /* match string property */
+ pc->merge_type = DBUS_TYPE_UINT64;
+ return;
} else if (strcmp (attr[3], "double") == 0) {
/* match string property */
pc->merge_type = DBUS_TYPE_DOUBLE;
@@ -413,6 +436,20 @@
break;
}
+ case DBUS_TYPE_UINT64:
+ {
+ dbus_uint64_t value;
+
+ /* match integer property */
+ value = strtoull (pc->cdata_buf, NULL, 0);
+
+ /** @todo FIXME: Check error condition */
+
+ hal_device_property_set_uint64 (pc->device,
+ pc->merge_key, value);
+ break;
+ }
+
case DBUS_TYPE_BOOLEAN:
hal_device_property_set_bool (pc->device, pc->merge_key,
(strcmp (pc->cdata_buf,
Index: hald_dbus.c
===================================================================
RCS file: /cvs/hal/hal/hald/hald_dbus.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- hald_dbus.c 30 Jul 2004 17:00:42 -0000 1.8
+++ hald_dbus.c 1 Sep 2004 17:38:58 -0000 1.9
@@ -576,6 +576,10 @@
dbus_message_iter_append_int32 (iter,
hal_property_get_int (p));
break;
+ case DBUS_TYPE_UINT64:
+ dbus_message_iter_append_uint64 (iter,
+ hal_property_get_uint64 (p));
+ break;
case DBUS_TYPE_DOUBLE:
dbus_message_iter_append_double (iter,
hal_property_get_double (p));
@@ -722,6 +726,10 @@
dbus_message_iter_append_int32 (&iter,
hal_property_get_int (p));
break;
+ case DBUS_TYPE_UINT64:
+ dbus_message_iter_append_uint64 (&iter,
+ hal_property_get_uint64 (p));
+ break;
case DBUS_TYPE_DOUBLE:
dbus_message_iter_append_double (&iter,
hal_property_get_double (p));
@@ -884,6 +892,11 @@
dbus_message_iter_get_int32
(&iter));
break;
+ case DBUS_TYPE_UINT64:
+ rc = hal_device_property_set_uint64 (device, key,
+ dbus_message_iter_get_uint64
+ (&iter));
+ break;
case DBUS_TYPE_DOUBLE:
rc = hal_device_property_set_double (device, key,
dbus_message_iter_get_double
Index: property.c
===================================================================
RCS file: /cvs/hal/hal/hald/property.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- property.c 11 Aug 2004 18:53:50 -0000 1.6
+++ property.c 1 Sep 2004 17:38:58 -0000 1.7
@@ -40,6 +40,7 @@
union {
char *str_value;
dbus_int32_t int_value;
+ dbus_uint64_t uint64_value;
dbus_bool_t bool_value;
double double_value;
};
@@ -101,6 +102,20 @@
}
HalProperty *
+hal_property_new_uint64 (const char *key, dbus_uint64_t value)
+{
+ HalProperty *prop;
+
+ prop = g_new0 (HalProperty, 1);
+
+ prop->type = DBUS_TYPE_UINT64;
+ prop->key = g_strdup (key);
+ prop->uint64_value = value;
+
+ return prop;
+}
+
+HalProperty *
hal_property_new_bool (const char *key, dbus_bool_t value)
{
HalProperty *prop;
@@ -162,6 +177,15 @@
return prop->int_value;
}
+dbus_uint64_t
+hal_property_get_uint64 (HalProperty *prop)
+{
+ g_return_val_if_fail (prop != NULL, -1);
+ g_return_val_if_fail (prop->type == DBUS_TYPE_UINT64, -1);
+
+ return prop->uint64_value;
+}
+
dbus_bool_t
hal_property_get_bool (HalProperty *prop)
{
@@ -181,6 +205,8 @@
return g_strdup (prop->str_value);
case DBUS_TYPE_INT32:
return g_strdup_printf ("%d", prop->int_value);
+ case DBUS_TYPE_UINT64:
+ return g_strdup_printf ("%lld", prop->uint64_value);
case DBUS_TYPE_BOOLEAN:
/* FIXME: Maybe use 1 and 0 here instead? */
return g_strdup (prop->bool_value ? "true" : "false");
@@ -237,6 +263,17 @@
}
void
+hal_property_set_uint64 (HalProperty *prop, dbus_uint64_t value)
+{
+ g_return_if_fail (prop != NULL);
+ g_return_if_fail (prop->type == DBUS_TYPE_UINT64 ||
+ prop->type == DBUS_TYPE_NIL);
+
+ prop->type = DBUS_TYPE_UINT64;
+ prop->uint64_value = value;
+}
+
+void
hal_property_set_bool (HalProperty *prop, dbus_bool_t value)
{
g_return_if_fail (prop != NULL);
Index: property.h
===================================================================
RCS file: /cvs/hal/hal/hald/property.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- property.h 20 Jun 2004 13:27:45 -0000 1.4
+++ property.h 1 Sep 2004 17:38:58 -0000 1.5
@@ -43,6 +43,8 @@
const char *value);
HalProperty *hal_property_new_int (const char *key,
dbus_int32_t value);
+HalProperty *hal_property_new_uint64 (const char *key,
+ dbus_uint64_t value);
HalProperty *hal_property_new_bool (const char *key,
dbus_bool_t value);
HalProperty *hal_property_new_double (const char *key,
@@ -54,6 +56,7 @@
const char *hal_property_get_string (HalProperty *prop);
dbus_int32_t hal_property_get_int (HalProperty *prop);
+dbus_uint64_t hal_property_get_uint64 (HalProperty *prop);
dbus_bool_t hal_property_get_bool (HalProperty *prop);
double hal_property_get_double (HalProperty *prop);
@@ -61,6 +64,8 @@
const char *value);
void hal_property_set_int (HalProperty *prop,
dbus_int32_t value);
+void hal_property_set_uint64 (HalProperty *prop,
+ dbus_uint64_t value);
void hal_property_set_bool (HalProperty *prop,
dbus_bool_t value);
void hal_property_set_double (HalProperty *prop,
Index: pstore.c
===================================================================
RCS file: /cvs/hal/hal/hald/pstore.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- pstore.c 23 Jun 2004 19:58:44 -0000 1.2
+++ pstore.c 1 Sep 2004 17:38:58 -0000 1.3
@@ -39,6 +39,7 @@
#define PSTR "String:"
#define PINT32 "Int32:"
+#define PUINT64 "UInt64:"
#define PBOOL "Bool:"
#define PDOUBLE "Double:"
#define UDI_STRIP "/org/freedesktop/Hal"
@@ -212,6 +213,9 @@
case DBUS_TYPE_INT32:
id = PINT32;
break;
+ case DBUS_TYPE_UINT64:
+ id = PUINT64;
+ break;
case DBUS_TYPE_BOOLEAN:
id = PBOOL;
break;
@@ -269,6 +273,7 @@
char *buf;
char *str;
int i;
+ unsigned long long ull;
double d;
g_return_if_fail (pstore != NULL);
@@ -298,6 +303,13 @@
goto exit;
}
+ if (g_ascii_strncasecmp (buf, PUINT64, sizeof (PUINT64)-1) == 0) {
+ str = &buf[sizeof (PUINT64)-1];
+ ull = strtoull (str, NULL, 10);
+ hal_device_property_set_uint64 (device, key, ull);
+ goto exit;
+ }
+
if (g_ascii_strncasecmp (buf, PBOOL, sizeof (PBOOL)-1) == 0) {
str = &buf[sizeof (PBOOL)-1];
if (g_ascii_strcasecmp (str, "true") == 0)
More information about the hal-commit
mailing list