[PATCH] export ieee1394.guid as string

Jon Lech Johansen jon at nanocrew.net
Thu Aug 26 15:45:44 PDT 2004


On Thu, Aug 26, 2004 at 02:24:28AM +0200, Jon Lech Johansen (jon at nanocrew.net) wrote:
> I'll send a new patch tomorrow.

Patch is attached. It breaks hal-device-manager, but lshal works. I
haven't looked into why as I'm not familiar with python.

-- 
Jon Lech Johansen
jon at member.fsf.org
nanocrew.net/blog/

Stat sua cuique dies, breve et inreparabile tempus
omnibus est vitae; sed famam extendere factis,
hoc virtutis opus.
-------------- next part --------------
diff -urN hal.orig/hald/device.c hal/hald/device.c
--- hal.orig/hald/device.c	2004-08-26 19:33:22.000000000 +0200
+++ hal/hald/device.c	2004-08-27 00:14:32.320719640 +0200
@@ -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));
diff -urN hal.orig/hald/device.h hal/hald/device.h
--- hal.orig/hald/device.h	2004-08-26 19:33:22.000000000 +0200
+++ hal/hald/device.h	2004-08-27 00:14:32.329718272 +0200
@@ -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);
diff -urN hal.orig/hald/device_info.c hal/hald/device_info.c
--- hal.orig/hald/device_info.c	2004-08-26 19:33:22.000000000 +0200
+++ hal/hald/device_info.c	2004-08-27 00:14:32.500692280 +0200
@@ -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,
diff -urN hal.orig/hald/hald_dbus.c hal/hald/hald_dbus.c
--- hal.orig/hald/hald_dbus.c	2004-08-26 19:33:22.000000000 +0200
+++ hal/hald/hald_dbus.c	2004-08-27 00:14:32.349715232 +0200
@@ -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
diff -urN hal.orig/hald/linux/common.c hal/hald/linux/common.c
--- hal.orig/hald/linux/common.c	2004-08-26 19:33:22.000000000 +0200
+++ hal/hald/linux/common.c	2004-08-27 00:14:32.351714928 +0200
@@ -101,6 +101,22 @@
 	return value;
 }
 
+/** Parse an integer represented as a hexa-decimal number (base 16) in
+ *  a string.
+ *
+ *  @param  str                 String to parse
+ *  @return                     Integer; If there was an error parsing the
+ *                              result is undefined.
+ */
+dbus_uint64_t
+parse_hex_uint64 (const char *str)
+{
+	dbus_uint64_t value;
+	value = strtoull (str, NULL, 16);
+	/** @todo Check error condition */
+	return value;
+}
+
 /** Find an integer appearing right after a substring in a string.
  *
  *  The result is LONG_MAX if the number isn't properly formatted or
diff -urN hal.orig/hald/linux/common.h hal/hald/linux/common.h
--- hal.orig/hald/linux/common.h	2004-08-26 19:33:22.000000000 +0200
+++ hal/hald/linux/common.h	2004-08-27 00:14:32.367712496 +0200
@@ -40,6 +40,7 @@
 double parse_double (const char *str);
 dbus_int32_t parse_dec (const char *str);
 dbus_int32_t parse_hex (const char *str);
+dbus_uint64_t parse_hex_uint64 (const char *str);
 
 long int find_num (char *pre, char *s, int base);
 double find_double (char *pre, char *s);
diff -urN hal.orig/hald/linux/ieee1394_node_class_device.c hal/hald/linux/ieee1394_node_class_device.c
--- hal.orig/hald/linux/ieee1394_node_class_device.c	2004-08-26 19:33:22.000000000 +0200
+++ hal/hald/linux/ieee1394_node_class_device.c	2004-08-27 00:14:32.368712344 +0200
@@ -66,7 +66,8 @@
 	struct sysfs_device *sysdevice;
 	struct sysfs_attribute *cur;
 	char attr_name[SYSFS_NAME_LEN];
-	int tmp;
+	dbus_int32_t tmp;
+ 	dbus_uint64_t tmp2;
 	const char *vendor_name = NULL;
 	int vendor_id = 0;
 
@@ -92,9 +93,9 @@
 						     "ieee1394.capabilities",
 						     tmp);
 		} else if (strcmp (attr_name, "guid") == 0) {
-			tmp = parse_hex (cur->value);
+			tmp2 = parse_hex_uint64 (cur->value);
 
-			hal_device_property_set_int (d, "ieee1394.guid", tmp);
+			hal_device_property_set_uint64 (d, "ieee1394.guid", tmp2);
 		} else if (strcmp (attr_name, "nodeid") == 0) {
 			tmp = parse_hex (cur->value);
 
diff -urN hal.orig/hald/property.c hal/hald/property.c
--- hal.orig/hald/property.c	2004-08-26 19:33:22.000000000 +0200
+++ hal/hald/property.c	2004-08-27 00:14:32.389709152 +0200
@@ -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);
diff -urN hal.orig/hald/property.h hal/hald/property.h
--- hal.orig/hald/property.h	2004-08-26 19:33:22.000000000 +0200
+++ hal/hald/property.h	2004-08-27 00:14:32.390709000 +0200
@@ -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,
diff -urN hal.orig/hald/pstore.c hal/hald/pstore.c
--- hal.orig/hald/pstore.c	2004-08-26 19:33:22.000000000 +0200
+++ hal/hald/pstore.c	2004-08-27 00:14:32.477695776 +0200
@@ -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)
diff -urN hal.orig/libhal/libhal.c hal/libhal/libhal.c
--- hal.orig/libhal/libhal.c	2004-08-26 19:33:22.000000000 +0200
+++ hal/libhal/libhal.c	2004-08-27 00:14:32.431702768 +0200
@@ -89,6 +89,8 @@
 		char *str_value;     /**< UTF-8 zero-terminated string */
 		dbus_int32_t int_value;
 				     /**< 32-bit signed integer */
+		dbus_uint64_t uint64_value;
+				     /**< 64-bit unsigned integer */
 		double double_value; /**< IEEE754 double precision float */
 		dbus_bool_t bool_value;
 				     /**< Truth value */
@@ -253,6 +255,10 @@
 			p->int_value =
 			    dbus_message_iter_get_int32 (&dict_iter);
 			break;
+		case DBUS_TYPE_UINT64:
+			p->uint64_value =
+			    dbus_message_iter_get_uint64 (&dict_iter);
+			break;
 		case DBUS_TYPE_DOUBLE:
 			p->double_value =
 			    dbus_message_iter_get_double (&dict_iter);
@@ -336,7 +342,7 @@
  *
  *  @param  iter		Iterator object
  *  @return			One of DBUS_TYPE_STRING, DBUS_TYPE_INT32,
- *				DBUS_TYPE_BOOL, DBUS_TYPE_DOUBLE
+ *				DBUS_TYPE_UINT64, DBUS_TYPE_BOOL, DBUS_TYPE_DOUBLE
  */
 int
 hal_psi_get_type (LibHalPropertySetIterator * iter)
@@ -383,6 +389,17 @@
 	return iter->cur_prop->int_value;
 }
 
+/** Get the value of a property of type integer. 
+ *
+ *  @param  iter		Iterator object
+ *  @return			64-bit unsigned integer
+ */
+dbus_uint64_t
+hal_psi_get_uint64 (LibHalPropertySetIterator * iter)
+{
+	return iter->cur_prop->uint64_value;
+}
+
 /** Get the value of a property of type double. 
  *
  *  @param  iter		Iterator object
@@ -731,7 +748,7 @@
  *  @param  udi			Unique Device Id
  *  @param  key			Name of the property
  *  @return			One of DBUS_TYPE_STRING, DBUS_TYPE_INT32,
- *				DBUS_TYPE_BOOL, DBUS_TYPE_DOUBLE or 
+ *				DBUS_TYPE_UINT64, DBUS_TYPE_BOOL, DBUS_TYPE_DOUBLE or 
  *				DBUS_TYPE_NIL if the property didn't exist.
  */
 int
@@ -936,6 +953,78 @@
 	return value;
 }
 
+/** Get the value of a property of type integer. 
+ *
+ *  @param  ctx                 The context for the connection to hald
+ *  @param  udi			Unique Device Id
+ *  @param  key			Name of the property
+ *  @return			64-bit unsigned integer
+ */
+dbus_uint64_t
+hal_device_get_property_uint64 (LibHalContext *ctx, 
+			     const char *udi, const char *key)
+{
+	DBusError error;
+	DBusMessage *message;
+	DBusMessage *reply;
+	DBusMessageIter iter;
+	dbus_uint64_t value;
+
+	message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
+						"org.freedesktop.Hal.Device",
+						"GetPropertyInteger");
+	if (message == NULL) {
+		fprintf (stderr,
+			 "%s %d : Couldn't allocate D-BUS message\n",
+			 __FILE__, __LINE__);
+		return -1;
+	}
+
+	dbus_message_iter_init (message, &iter);
+	dbus_message_iter_append_string (&iter, key);
+	dbus_error_init (&error);
+	reply = dbus_connection_send_with_reply_and_block (ctx->connection,
+							   message, -1,
+							   &error);
+	if (dbus_error_is_set (&error)) {
+		fprintf (stderr, "%s %d : Error sending msg: %s\n",
+			 __FILE__, __LINE__, error.message);
+		dbus_message_unref (message);
+		return -1;
+	}
+	if (reply == NULL) {
+		dbus_message_unref (message);
+		return -1;
+	}
+
+	dbus_message_iter_init (reply, &iter);
+
+	/* now analyze reply */
+	if (dbus_message_iter_get_arg_type (&iter) == DBUS_TYPE_NIL) {
+		/* property didn't exist */
+		fprintf (stderr,
+			 "%s %d : property '%s' for device '%s' does not "
+			 "exist\n", __FILE__, __LINE__, key, udi);
+		dbus_message_unref (message);
+		dbus_message_unref (reply);
+		return -1;
+	} else if (dbus_message_iter_get_arg_type (&iter) !=
+		   DBUS_TYPE_UINT64) {
+		fprintf (stderr,
+			 "%s %d : property '%s' for device '%s' is not "
+			 "of type integer\n", __FILE__, __LINE__, key,
+			 udi);
+		dbus_message_unref (message);
+		dbus_message_unref (reply);
+		return -1;
+	}
+	value = dbus_message_iter_get_uint64 (&iter);
+
+	dbus_message_unref (message);
+	dbus_message_unref (reply);
+	return value;
+}
+
 /** Get the value of a property of type double. 
  *
  *  @param  ctx                 The context for the connection to hald
@@ -1087,6 +1176,7 @@
 				int type,
 				const char *str_value,
 				dbus_int32_t int_value,
+				dbus_uint64_t uint64_value,
 				double double_value,
 				dbus_bool_t bool_value)
 {
@@ -1106,6 +1196,7 @@
 		method_name = "SetPropertyString";
 		break;
 	case DBUS_TYPE_INT32:
+	case DBUS_TYPE_UINT64:
 		method_name = "SetPropertyInteger";
 		break;
 	case DBUS_TYPE_DOUBLE:
@@ -1142,6 +1233,9 @@
 	case DBUS_TYPE_INT32:
 		dbus_message_iter_append_int32 (&iter, int_value);
 		break;
+	case DBUS_TYPE_UINT64:
+		dbus_message_iter_append_uint64 (&iter, uint64_value);
+		break;
 	case DBUS_TYPE_DOUBLE:
 		dbus_message_iter_append_double (&iter, double_value);
 		break;
@@ -1186,7 +1280,7 @@
 {
 	return hal_device_set_property_helper (ctx, udi, key,
 					       DBUS_TYPE_STRING,
-					       value, 0, 0.0f, FALSE);
+					       value, 0, 0, 0.0f, FALSE);
 }
 
 /** Set a property of type integer.
@@ -1205,7 +1299,26 @@
 {
 	return hal_device_set_property_helper (ctx, udi, key,
 					       DBUS_TYPE_INT32,
-					       NULL, value, 0.0f, FALSE);
+					       NULL, value, 0, 0.0f, FALSE);
+}
+
+/** Set a property of type integer.
+ *
+ *  @param  ctx                 The context for the connection to hald
+ *  @param  udi			Unique Device Id
+ *  @param  key			Name of the property
+ *  @param  value		Value of the property
+ *  @return			TRUE if the property was set, FALSE if
+ *				the device didn't exist or the property
+ *				had a different type.
+ */
+dbus_bool_t
+hal_device_set_property_uint64 (LibHalContext *ctx, const char *udi,
+			     const char *key, dbus_uint64_t value)
+{
+	return hal_device_set_property_helper (ctx, udi, key,
+					       DBUS_TYPE_UINT64,
+					       NULL, 0, value, 0.0f, FALSE);
 }
 
 /** Set a property of type double.
@@ -1224,7 +1337,7 @@
 {
 	return hal_device_set_property_helper (ctx, udi, key,
 					       DBUS_TYPE_DOUBLE,
-					       NULL, 0, value, FALSE);
+					       NULL, 0, 0, value, FALSE);
 }
 
 /** Set a property of type bool.
@@ -1243,7 +1356,7 @@
 {
 	return hal_device_set_property_helper (ctx, udi, key,
 					       DBUS_TYPE_BOOLEAN,
-					       NULL, 0, 0.0f, value);
+					       NULL, 0, 0, 0.0f, value);
 }
 
 
@@ -1261,7 +1374,7 @@
 {
 	return hal_device_set_property_helper (ctx, udi, key, DBUS_TYPE_NIL,	
 					       /* DBUS_TYPE_NIL means remove */
-					       NULL, 0, 0.0f, FALSE);
+					       NULL, 0, 0, 0.0f, FALSE);
 }
 
 
@@ -1747,6 +1860,11 @@
 				hal_psi_get_int (&i),
 				hal_psi_get_int (&i));
 			break;
+		case DBUS_TYPE_UINT64:
+			printf ("    %s = %lld = 0x%llx (uint64)\n", key,
+				hal_psi_get_uint64 (&i),
+				hal_psi_get_uint64 (&i));
+			break;
 		case DBUS_TYPE_BOOLEAN:
 			printf ("    %s = %s (bool)\n", key,
 				(hal_psi_get_bool (&i) ? "true" :
diff -urN hal.orig/libhal/libhal.h hal/libhal/libhal.h
--- hal.orig/libhal/libhal.h	2004-08-26 19:33:22.000000000 +0200
+++ hal/libhal/libhal.h	2004-08-27 00:14:32.432702616 +0200
@@ -166,6 +166,10 @@
 					  const char *udi,
 					  const char *key);
 
+dbus_uint64_t hal_device_get_property_uint64 (LibHalContext *ctx, 
+					  const char *udi,
+					  const char *key);
+
 double hal_device_get_property_double (LibHalContext *ctx, 
 				       const char *udi,
 				       const char *key);
@@ -184,6 +188,11 @@
 					 const char *key,
 					 dbus_int32_t value);
 
+dbus_bool_t hal_device_set_property_uint64 (LibHalContext *ctx, 
+					 const char *udi,
+					 const char *key,
+					 dbus_uint64_t value);
+
 dbus_bool_t hal_device_set_property_double (LibHalContext *ctx, 
 					    const char *udi,
 					    const char *key,
@@ -242,6 +251,7 @@
 
 char *hal_psi_get_string (LibHalPropertySetIterator * iter);
 dbus_int32_t hal_psi_get_int (LibHalPropertySetIterator * iter);
+dbus_uint64_t hal_psi_get_uint64 (LibHalPropertySetIterator * iter);
 double hal_psi_get_double (LibHalPropertySetIterator * iter);
 dbus_bool_t hal_psi_get_bool (LibHalPropertySetIterator * iter);
 
diff -urN hal.orig/tools/hal_get_property.c hal/tools/hal_get_property.c
--- hal.orig/tools/hal_get_property.c	2004-08-26 19:33:22.000000000 +0200
+++ hal/tools/hal_get_property.c	2004-08-27 00:14:32.453699424 +0200
@@ -176,6 +176,13 @@
 		printf ((is_hex ? "%x\n" : "%d\n"),
 			hal_device_get_property_int (hal_ctx, udi, key));
 		break;
+	case DBUS_TYPE_UINT64:
+		if (is_verbose)
+			printf ("Type is uint64 (shown in %s)\n",
+				(is_hex ? "hexadecimal" : "decimal"));
+		printf ((is_hex ? "%llx\n" : "%lld\n"),
+			hal_device_get_property_uint64 (hal_ctx, udi, key));
+		break;
 	case DBUS_TYPE_DOUBLE:
 		if (is_verbose)
 			printf ("Type is double\n");
diff -urN hal.orig/tools/hal_set_property.c hal/tools/hal_set_property.c
--- hal.orig/tools/hal_set_property.c	2004-08-26 19:33:22.000000000 +0200
+++ hal/tools/hal_set_property.c	2004-08-27 00:14:32.454699272 +0200
@@ -65,6 +65,8 @@
  "        --key            Key of the property to set\n"
  "        --int            Set value to an integer. Accepts decimal and "
  "                         hexadecimal prefixed with 0x or x\n"
+ "        --uint64         Set value to an integer. Accepts decimal and "
+ "                         hexadecimal prefixed with 0x or x\n"
  "        --string         Set value to a string\n"
  "        --double         Set value to a floating point number\n"
  "        --bool           Set value to a boolean, ie. true or false\n"
@@ -93,6 +95,7 @@
 	char *key = NULL;
 	char *str_value = NULL;
 	dbus_int32_t int_value = 0;
+	dbus_uint64_t uint64_value = 0;
 	double double_value = 0.0f;
 	dbus_bool_t bool_value = TRUE;
 	dbus_bool_t remove = FALSE;
@@ -112,6 +115,7 @@
 			{"udi", 1, NULL, 0},
 			{"key", 1, NULL, 0},
 			{"int", 1, NULL, 0},
+			{"uint64", 1, NULL, 0},
 			{"string", 1, NULL, 0},
 			{"double", 1, NULL, 0},
 			{"bool", 1, NULL, 0},
@@ -141,6 +145,9 @@
 			} else if (strcmp (opt, "int") == 0) {
 				int_value = strtol (optarg, NULL, 0);
 				type = DBUS_TYPE_INT32;
+			} else if (strcmp (opt, "uint64") == 0) {
+				uint64_value = strtoull (optarg, NULL, 0);
+				type = DBUS_TYPE_UINT64;
 			} else if (strcmp (opt, "double") == 0) {
 				double_value = (double) atof (optarg);
 				type = DBUS_TYPE_DOUBLE;
@@ -203,6 +210,10 @@
 			rc = hal_device_set_property_int (hal_ctx, udi, key,
 							  int_value);
 			break;
+		case DBUS_TYPE_UINT64:
+			rc = hal_device_set_property_uint64 (hal_ctx, udi, key,
+							  uint64_value);
+			break;
 		case DBUS_TYPE_DOUBLE:
 			rc = hal_device_set_property_double (hal_ctx, udi, key,
 							     double_value);
diff -urN hal.orig/tools/lshal.c hal/tools/lshal.c
--- hal.orig/tools/lshal.c	2004-08-26 19:33:22.000000000 +0200
+++ hal/tools/lshal.c	2004-08-27 00:14:32.476695928 +0200
@@ -110,6 +110,13 @@
 					hal_psi_get_int (&it));
 				break;
 
+			case DBUS_TYPE_UINT64:
+				printf ("  %s = %lld  (0x%llx)  (uint64)\n",
+					hal_psi_get_key (&it),
+					hal_psi_get_uint64 (&it),
+					hal_psi_get_uint64 (&it));
+				break;
+
 			case DBUS_TYPE_DOUBLE:
 				printf ("  %s = %g  (double)\n",
 					hal_psi_get_key (&it),
@@ -225,6 +232,15 @@
 				 value, value);
 		}
 		break;
+	case DBUS_TYPE_UINT64:
+		{
+			dbus_uint64_t value =
+			    hal_device_get_property_uint64 (hal_ctx, udi, key);
+			fprintf (stderr,
+				 "*** new value: %lld (0x%llx)  (uint64)\n",
+				 value, value);
+		}
+		break;
 	case DBUS_TYPE_DOUBLE:
 		fprintf (stderr, "*** new value: %g  (double)\n",
 			 hal_device_get_property_double (hal_ctx, udi, key));
-------------- next part --------------
_______________________________________________
hal mailing list
hal at freedesktop.org
http://freedesktop.org/mailman/listinfo/hal


More information about the Hal mailing list