hal/libhal-storage Makefile.am,1.1,1.2 libhal-storage.c,1.10,1.11

David Zeuthen david at freedesktop.org
Mon Jan 31 12:06:43 PST 2005


Update of /cvs/hal/hal/libhal-storage
In directory gabe:/tmp/cvs-serv1622/libhal-storage

Modified Files:
	Makefile.am libhal-storage.c 
Log Message:
2005-01-31  David Zeuthen  <davidz at redhat.com>

	* configure.in: Prebump to 0.5.0 - but we're not doing a release yet!
	Add libtool versioning since libhal and libhal-storage are going
	to break API and ABI backwards compatibility.

	* hald/hald_test.c: Add the beginnings of a test suite

	* hald/hald_test_libhal.c: -do-

	* hald/Makefile.am: Add build rules for test suite

	* tools/linux/hal_hotplug_map.c: Update to use new libhal API.

	* tools/lshal.c: Update to use new libhal API.

	* tools/hal_set_property.c: Update to use new libhal API.

	* tools/hal_get_property.c: Update to use new libhal API.

	* tools/fstab-sync.c: Update to use new libhal API.

	* libhal-storage/libhal-storage.c: Update to use new libhal API.
	This library will also go through a renaming/cleanup before 0.5.0.

	* libhal-storage/Makefile.am: Use library versioning

	* libhal/libhal.[ch]: Prefix all function names and other identifiers
	with libhal instead of hal. Add code for string lists. Change the
	way libhal is initialized to be a multistep process. Use HAL_PROPERTY_
	TYPE_* instead of DBUS_TYPE_*. Make all functions using IPC take
	a DBusError argument for better error handling. Notable changes
	(libhal_device_get_all_properties): Teach this function about 
	string lists
	(libhal_psi_get_strlist): New function
	(hal_initialize): Removed
	(hal_shutdown): Removed
	(libhal_device_get_property_strlist): New function
	(libhal_device_property_strlist_append): New function
	(libhal_device_property_strlist_prepend): New function
	(libhal_device_property_strlist_remove_index): New function
	(libhal_device_property_strlist_remove): New function
	(libhal_ctx_new): New function
	(libhal_ctx_set_cache): New function
	(libhal_ctx_set_dbus_connection): New function
	(libhal_ctx_init): New function
	(libhal_ctx_shutdown): New function
	(libhal_ctx_free): New function
	(libhal_ctx_set_device_added): New function
	(libhal_ctx_set_device_removed): New function
	(libhal_ctx_set_device_new_capability): New function
	(libhal_ctx_set_device_lost_capability): New function
	(libhal_ctx_set_device_property_modified): New function
	(libhal_ctx_set_device_condition): New function

	* libhal/Makefile.am: Use library versioning

	* hald/linux2/probing/probe-input.c: Port to new libhal API

	* hald/property.h: Rename property types to HAL_PROPERTY_TYPE_*.
	Add prototypes for new string list properties.

	* hald/property.c: Rename property types to HAL_PROPERTY_TYPE_*.
	(hal_property_free): Teach this function about string lists.
	(hal_property_new_strlist): New function
	(hal_property_get_strlist): New function
	(hal_property_strlist_append): New function
	(hal_property_strlist_prepend): New function
	(hal_property_strlist_remove_elem): New function
	(hal_property_strlist_add): New function
	(hal_property_strlist_remove): New function

	* hald/hald_dbus.c: Rename property types to HAL_PROPERTY_TYPE_*.
	Add new ugly code to handle string lists with the current D-BUS.
	(device_string_list_append_prepend): New function
	(hald_dbus_filter_function): Rename from filter_function. Add
	handlers for new D-BUS methods. Export this function 

	* hald/hald.[ch]: Rip out persistent property code.

	* hald/device_info.c: Rename property types to HAL_PROPERTY_TYPE_*.

	* hald/device.c: Rename to property to HAL_PROPERTY_TYPE_*. Rip out
	persistent property code.
	(hal_device_property_get_as_string): Add code for strlist type
	(hal_device_property_get_strlist): New function
	(hal_device_property_strlist_append): New function
	(hal_device_property_strlist_prepend): New function
	(hal_device_property_strlist_remove_elem): New function
	(hal_device_property_strlist_add): New function
	(hal_device_property_strlist_remove): New function

	* hald/device.h: Add new strlist prototypes

	* pstore.[ch]: Remove for now as persistent properties needs to be
	reworked



Index: Makefile.am
===================================================================
RCS file: /cvs/hal/hal/libhal-storage/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Makefile.am	23 Sep 2004 18:13:45 -0000	1.1
+++ Makefile.am	31 Jan 2005 20:06:41 -0000	1.2
@@ -18,5 +18,8 @@
 
 libhal_storage_la_LIBADD = @DBUS_LIBS@ $(top_builddir)/libhal/libhal.la
 
+libhal_storage_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
+
+
 clean-local :
 	rm -f *~

Index: libhal-storage.c
===================================================================
RCS file: /cvs/hal/hal/libhal-storage/libhal-storage.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- libhal-storage.c	25 Jan 2005 16:55:09 -0000	1.10
+++ libhal-storage.c	31 Jan 2005 20:06:41 -0000	1.11
@@ -720,15 +720,15 @@
 		return;
 
 	free (drive->udi);
-	hal_free_string (drive->device_file);
-	hal_free_string (drive->vendor);
-	hal_free_string (drive->model);
-	hal_free_string (drive->type_textual);
-	hal_free_string (drive->physical_device);
-	hal_free_string (drive->serial);
-	hal_free_string (drive->firmware_version);
-	hal_free_string (drive->desired_mount_point);
-	hal_free_string (drive->mount_filesystem);
+	libhal_free_string (drive->device_file);
+	libhal_free_string (drive->vendor);
+	libhal_free_string (drive->model);
+	libhal_free_string (drive->type_textual);
+	libhal_free_string (drive->physical_device);
+	libhal_free_string (drive->serial);
+	libhal_free_string (drive->firmware_version);
+	libhal_free_string (drive->desired_mount_point);
+	libhal_free_string (drive->mount_filesystem);
 }
 
 
@@ -743,14 +743,14 @@
 		return;
 
 	free (vol->udi);
-	hal_free_string (vol->device_file);
-	hal_free_string (vol->volume_label);
-	hal_free_string (vol->fstype);
-	hal_free_string (vol->mount_point);
-	hal_free_string (vol->fsversion);
-	hal_free_string (vol->uuid);
-	hal_free_string (vol->desired_mount_point);
-	hal_free_string (vol->mount_filesystem);
+	libhal_free_string (vol->device_file);
+	libhal_free_string (vol->volume_label);
+	libhal_free_string (vol->fstype);
+	libhal_free_string (vol->mount_point);
+	libhal_free_string (vol->fsversion);
+	libhal_free_string (vol->uuid);
+	libhal_free_string (vol->desired_mount_point);
+	libhal_free_string (vol->mount_filesystem);
 }
 
 
@@ -758,10 +758,10 @@
 
 #define HAL_PROP_EXTRACT_BEGIN if (FALSE)
 #define HAL_PROP_EXTRACT_END ;
-#define HAL_PROP_EXTRACT_INT(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == DBUS_TYPE_INT32) _where_ = hal_psi_get_int (&it)
-#define HAL_PROP_EXTRACT_STRING(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == DBUS_TYPE_STRING) _where_ = (hal_psi_get_string (&it) != NULL && strlen (hal_psi_get_string (&it)) > 0) ? strdup (hal_psi_get_string (&it)) : NULL
-#define HAL_PROP_EXTRACT_BOOL(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == DBUS_TYPE_BOOLEAN) _where_ = hal_psi_get_bool (&it)
-#define HAL_PROP_EXTRACT_BOOL_BITFIELD(_property_, _where_, _field_) else if (strcmp (key, _property_) == 0 && type == DBUS_TYPE_BOOLEAN) _where_ |= hal_psi_get_bool (&it) ? _field_ : 0
+#define HAL_PROP_EXTRACT_INT(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == DBUS_TYPE_INT32) _where_ = libhal_psi_get_int (&it)
+#define HAL_PROP_EXTRACT_STRING(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == DBUS_TYPE_STRING) _where_ = (libhal_psi_get_string (&it) != NULL && strlen (libhal_psi_get_string (&it)) > 0) ? strdup (libhal_psi_get_string (&it)) : NULL
+#define HAL_PROP_EXTRACT_BOOL(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == DBUS_TYPE_BOOLEAN) _where_ = libhal_psi_get_bool (&it)
+#define HAL_PROP_EXTRACT_BOOL_BITFIELD(_property_, _where_, _field_) else if (strcmp (key, _property_) == 0 && type == DBUS_TYPE_BOOLEAN) _where_ |= libhal_psi_get_bool (&it) ? _field_ : 0
 
 /** Given a UDI for a HAL device of capability 'storage', this
  *  function retrieves all the relevant properties into convenient
@@ -778,12 +778,14 @@
 	HalDrive *drive;
 	LibHalPropertySet *properties;
 	LibHalPropertySetIterator it;
+	DBusError error;
 
 	drive = NULL;
 	properties = NULL;
 	bus_textual = NULL;
 
-	if (!hal_device_query_capability (hal_ctx, udi, "storage"))
+	dbus_error_init (&error);
+	if (!libhal_device_query_capability (hal_ctx, udi, "storage", &error))
 		goto error;
 
 	drive = malloc (sizeof (HalDrive));
@@ -797,17 +799,17 @@
 	if (drive->udi == NULL)
 		goto error;
 
-	properties = hal_device_get_all_properties (hal_ctx, udi);
+	properties = libhal_device_get_all_properties (hal_ctx, udi, &error);
 	if (properties == NULL)
 		goto error;
 
 	/* we can count on hal to give us all these properties */
-	for (hal_psi_init (&it, properties); hal_psi_has_more (&it); hal_psi_next (&it)) {
+	for (libhal_psi_init (&it, properties); libhal_psi_has_more (&it); libhal_psi_next (&it)) {
 		int type;
 		char *key;
 		
-		type = hal_psi_get_type (&it);
-		key = hal_psi_get_key (&it);
+		type = libhal_psi_get_type (&it);
+		key = libhal_psi_get_key (&it);
 
 		HAL_PROP_EXTRACT_BEGIN;
 
@@ -885,8 +887,10 @@
 	/* check if physical device is a camera or mp3 player */
 	if (drive->physical_device != NULL) {
 		char *category;
+		DBusError err1;
 
-		category = hal_device_get_property_string (hal_ctx, drive->physical_device, "info.category");
+		dbus_error_init (&err1);
+		category = libhal_device_get_property_string (hal_ctx, drive->physical_device, "info.category", &err1);
 		if (category != NULL) {
 			if (strcmp (category, "portable_audio_player") == 0) {
 				drive->type = HAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER;
@@ -894,7 +898,7 @@
 				drive->type = HAL_DRIVE_TYPE_CAMERA;
 			}
 
-			hal_free_string (category);
+			libhal_free_string (category);
 		}
 	}
 
@@ -910,14 +914,14 @@
 		}
 	}
 
-	hal_free_string (bus_textual);
-	hal_free_property_set (properties);
+	libhal_free_string (bus_textual);
+	libhal_free_property_set (properties);
 
 	return drive;
 
 error:
-	hal_free_string (bus_textual);
-	hal_free_property_set (properties);
+	libhal_free_string (bus_textual);
+	libhal_free_property_set (properties);
 	hal_drive_free (drive);
 	return NULL;
 }
@@ -954,12 +958,14 @@
 	HalVolume *vol;
 	LibHalPropertySet *properties;
 	LibHalPropertySetIterator it;
+	DBusError error;
 
 	vol = NULL;
 	properties = NULL;
 	disc_type_textual = NULL;
 
-	if (!hal_device_query_capability (hal_ctx, udi, "volume"))
+	dbus_error_init (&error);
+	if (!libhal_device_query_capability (hal_ctx, udi, "volume", &error))
 		goto error;
 
 	vol = malloc (sizeof (HalVolume));
@@ -969,17 +975,17 @@
 
 	vol->udi = strdup (udi);
 
-	properties = hal_device_get_all_properties (hal_ctx, udi);
+	properties = libhal_device_get_all_properties (hal_ctx, udi, &error);
 	if (properties == NULL)
 		goto error;
 
 	/* we can count on hal to give us all these properties */
-	for (hal_psi_init (&it, properties); hal_psi_has_more (&it); hal_psi_next (&it)) {
+	for (libhal_psi_init (&it, properties); libhal_psi_has_more (&it); libhal_psi_next (&it)) {
 		int type;
 		char *key;
 		
-		type = hal_psi_get_type (&it);
-		key = hal_psi_get_key (&it);
+		type = libhal_psi_get_type (&it);
+		key = libhal_psi_get_key (&it);
 
 		HAL_PROP_EXTRACT_BEGIN;
 
@@ -1035,12 +1041,12 @@
 		}
 	}
 
-	hal_free_string (disc_type_textual);
-	hal_free_property_set (properties);
+	libhal_free_string (disc_type_textual);
+	libhal_free_property_set (properties);
 	return vol;
 error:
-	hal_free_string (disc_type_textual);
-	hal_free_property_set (properties);
+	libhal_free_string (disc_type_textual);
+	libhal_free_property_set (properties);
 	hal_volume_free (vol);
 	return NULL;
 }
@@ -1077,32 +1083,39 @@
 	int num_hal_udis;
 	HalDrive *result;
 	char *found_udi;
+	DBusError error;
 
 	result = NULL;
 	found_udi = NULL;
 
-	if ((hal_udis = hal_manager_find_device_string_match (hal_ctx, "block.device", 
-							      device_file, &num_hal_udis)) == NULL)
+	dbus_error_init (&error);
+	if ((hal_udis = libhal_manager_find_device_string_match (hal_ctx, "block.device", 
+								 device_file, &num_hal_udis, &error)) == NULL)
 		goto out;
 
 	for (i = 0; i < num_hal_udis; i++) {
 		char *udi;
 		char *storage_udi;
+		DBusError err1;
+		DBusError err2;
 		udi = hal_udis[i];
-		if (hal_device_query_capability (hal_ctx, udi, "volume")) {
 
-			storage_udi = hal_device_get_property_string (hal_ctx, udi, "block.storage_device");
+		dbus_error_init (&err1);
+		dbus_error_init (&err2);
+		if (libhal_device_query_capability (hal_ctx, udi, "volume", &err1)) {
+
+			storage_udi = libhal_device_get_property_string (hal_ctx, udi, "block.storage_device", &err1);
 			if (storage_udi == NULL)
 				continue;
 			found_udi = strdup (storage_udi);
-			hal_free_string (storage_udi);
+			libhal_free_string (storage_udi);
 			break;
-		} else if (hal_device_query_capability (hal_ctx, udi, "storage")) {
+		} else if (libhal_device_query_capability (hal_ctx, udi, "storage", &err2)) {
 			found_udi = strdup (udi);
 		}
 	}
 
-	hal_free_string_array (hal_udis);
+	libhal_free_string_array (hal_udis);
 
 	if (found_udi != NULL)
 		result = hal_drive_from_udi (hal_ctx, found_udi);
@@ -1127,24 +1140,26 @@
 	int num_hal_udis;
 	HalVolume *result;
 	char *found_udi;
+	DBusError error;
 
 	result = NULL;
 	found_udi = NULL;
 
-	if ((hal_udis = hal_manager_find_device_string_match (hal_ctx, "block.device", 
-							      device_file, &num_hal_udis)) == NULL)
+	dbus_error_init (&error);
+	if ((hal_udis = libhal_manager_find_device_string_match (hal_ctx, "block.device", 
+								 device_file, &num_hal_udis, &error)) == NULL)
 		goto out;
 
 	for (i = 0; i < num_hal_udis; i++) {
 		char *udi;
 		udi = hal_udis[i];
-		if (hal_device_query_capability (hal_ctx, udi, "volume")) {
+		if (libhal_device_query_capability (hal_ctx, udi, "volume", &error)) {
 			found_udi = strdup (udi);
 			break;
 		}
 	}
 
-	hal_free_string_array (hal_udis);
+	libhal_free_string_array (hal_udis);
 
 	if (found_udi != NULL)
 		result = hal_volume_from_udi (hal_ctx, found_udi);
@@ -1373,6 +1388,7 @@
 	int num_udis;
 	const char *drive_udi;
 	char **result;
+	DBusError error;
 
 	udis = NULL;
 	result = NULL;
@@ -1383,8 +1399,9 @@
 		goto out;
 
 	/* get initial list... */
-	if ((udis = hal_manager_find_device_string_match (hal_ctx, "block.storage_device", 
-							  drive_udi, &num_udis)) == NULL)
+	dbus_error_init (&error);
+	if ((udis = libhal_manager_find_device_string_match (hal_ctx, "block.storage_device", 
+							     drive_udi, &num_udis, &error)) == NULL)
 		goto out;
 
 	result = malloc (sizeof (char *) * num_udis);
@@ -1400,7 +1417,7 @@
 	}
 
 out:
-	hal_free_string_array (udis);
+	libhal_free_string_array (udis);
 	return result;
 }
 
@@ -1409,29 +1426,37 @@
 char *
 hal_drive_policy_default_get_mount_root (LibHalContext *hal_ctx)
 {
-	return hal_device_get_property_string (hal_ctx, "/org/freedesktop/Hal/devices/computer",
-					       "storage.policy.default.mount_root");
+	DBusError error;
+	dbus_error_init (&error);
+	return libhal_device_get_property_string (hal_ctx, "/org/freedesktop/Hal/devices/computer",
+						  "storage.policy.default.mount_root", &error);
 }
 
 dbus_bool_t
 hal_drive_policy_default_use_managed_keyword (LibHalContext *hal_ctx)
 {
-	return hal_device_get_property_bool (hal_ctx, "/org/freedesktop/Hal/devices/computer",
-					     "storage.policy.default.use_managed_keyword");
+	DBusError error;
+	dbus_error_init (&error);
+	return libhal_device_get_property_bool (hal_ctx, "/org/freedesktop/Hal/devices/computer",
+						"storage.policy.default.use_managed_keyword", &error);
 }
 
 char *
 hal_drive_policy_default_get_managed_keyword_primary (LibHalContext *hal_ctx)
 {
-	return hal_device_get_property_string (hal_ctx, "/org/freedesktop/Hal/devices/computer",
-					       "storage.policy.default.managed_keyword.primary");
+	DBusError error;
+	dbus_error_init (&error);
+	return libhal_device_get_property_string (hal_ctx, "/org/freedesktop/Hal/devices/computer",
+						  "storage.policy.default.managed_keyword.primary", &error);
 }
 
 char *
 hal_drive_policy_default_get_managed_keyword_secondary (LibHalContext *hal_ctx)
 {
-	return hal_device_get_property_string (hal_ctx, "/org/freedesktop/Hal/devices/computer",
-					       "storage.policy.default.managed_keyword.secondary");
+	DBusError error;
+	dbus_error_init (&error);
+	return libhal_device_get_property_string (hal_ctx, "/org/freedesktop/Hal/devices/computer",
+						  "storage.policy.default.managed_keyword.secondary", &error);
 }
 
 /*************************************************************************/
@@ -1461,18 +1486,21 @@
 {
 	LibHalPropertySet *properties;
 	LibHalPropertySetIterator it;
+	DBusError error;
+
+	dbus_error_init (&error);
 
 	/* first collect from root computer device */
-	properties = hal_device_get_all_properties (hal_ctx, udi);
+	properties = libhal_device_get_all_properties (hal_ctx, udi, &error);
 	if (properties == NULL)
 		goto error;
-	for (hal_psi_init (&it, properties); hal_psi_has_more (&it); hal_psi_next (&it)) {
+	for (libhal_psi_init (&it, properties); libhal_psi_has_more (&it); libhal_psi_next (&it)) {
 		int type;
 		char *key;
 		
-		type = hal_psi_get_type (&it);
-		key = hal_psi_get_key (&it);
-		if (hal_psi_get_type (&it) == DBUS_TYPE_BOOLEAN &&
+		type = libhal_psi_get_type (&it);
+		key = libhal_psi_get_key (&it);
+		if (libhal_psi_get_type (&it) == DBUS_TYPE_BOOLEAN &&
 		    strncmp (key, namespace, namespace_len - 1) == 0) {
 			const char *option = key + namespace_len - 1;
 			char *location;
@@ -1494,7 +1522,7 @@
 					continue;
 			}
 
-			if (hal_psi_get_bool (&it)) {
+			if (libhal_psi_get_bool (&it)) {
 				/* see if option is already there */
 				location = strstr (options_string, option);
 				if (location == NULL) {
@@ -1520,7 +1548,7 @@
 		}
 	}
 error:
-	hal_free_property_set (properties);
+	libhal_free_property_set (properties);
 }
 
 




More information about the hal-commit mailing list