[patch] remove /system/storage settings and use new hal api



Hey,

Attached patch does two things

 1. It uses new hal API to figure out details about crypto between
    crypted and clear volumes - this way we won't need to rely on
    a magic hal property; this also saves a single roundtrip to the
    hal daemon for every volume added - that's always good!

 2. Removes the /system/storage settings - only the hal backend used
    these and there was never any UI to modify these. In retrospect
    these settings are kind of useless

OK to commit? There are no string additions or changes; only removals.
I've also tested this patch with a few different pieces of storage
devices and it looks good to me.

     David

 $ diffstat gnome-vfs-use-new-hal-api-and-remove-settings-1.patch
 ChangeLog                          |   16 ++++
 configure.in                       |    4 -
 libgnomevfs/gnome-vfs-hal-mounts.c |  146 +------------------------------------
 po/ChangeLog                       |    4 +
 po/POTFILES.in                     |    1
 schemas/Makefile.am                |    1
 6 files changed, 28 insertions(+), 144 deletions(-)


Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-vfs/ChangeLog,v
retrieving revision 1.2381
diff -u -p -r1.2381 ChangeLog
--- ChangeLog	1 Mar 2006 13:02:25 -0000	1.2381
+++ ChangeLog	2 Mar 2006 01:02:23 -0000
@@ -1,3 +1,19 @@
+2006-03-01  David Zeuthen  <davidz redhat com>
+
+	* configure.in: Require hal 0.5.7 for new crypto bits in
+	libhal-storage 0.5.7
+
+	* libgnomevfs/gnome-vfs-hal-mounts.c: Don't read settings from
+	/system/storage and remove code that uses it. Also use new API
+	available in libhal-storage 0.5.7 and later instead of relying on
+	a magic hal property volume.crypto_luks.clear.backing_volume.
+
+	* schemas/system_storage.schemas.in: Removed
+
+	* schemas/Makefile.am: Remove system_storage.schemas.in
+
+	* po/POTFILES.in: Remove system_storage.schemas.in
+
 2006-03-01  Tor Lillqvist  <tml novell com>
 
 	* test/Makefile.am: test-parse-ls-lga is Unix-only.
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gnome-vfs/configure.in,v
retrieving revision 1.412
diff -u -p -r1.412 configure.in
--- configure.in	27 Feb 2006 10:58:22 -0000	1.412
+++ configure.in	2 Mar 2006 01:02:24 -0000
@@ -725,8 +725,8 @@ esac],
 [ENABLE_HAL=yes]) dnl Default value
 
 if test "$ENABLE_HAL" = "yes"; then
-	PKG_CHECK_MODULES(HAL, hal >= 0.5.6,
-		[ USE_HAL="hal >= 0.5.6, hal-storage >= 0.5.6, dbus-1 >= 0.32, dbus-glib-1 >= 0.32"
+	PKG_CHECK_MODULES(HAL, hal >= 0.5.7,
+		[ USE_HAL="hal >= 0.5.7, hal-storage >= 0.5.7, dbus-1 >= 0.32, dbus-glib-1 >= 0.32"
 		  AC_DEFINE(USE_HAL, 1, [defined if using libhal])
 		  msg_hal=yes],
 		[ USE_HAL=""])
Index: libgnomevfs/gnome-vfs-hal-mounts.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-hal-mounts.c,v
retrieving revision 1.27
diff -u -p -r1.27 gnome-vfs-hal-mounts.c
--- libgnomevfs/gnome-vfs-hal-mounts.c	23 Feb 2006 00:40:07 -0000	1.27
+++ libgnomevfs/gnome-vfs-hal-mounts.c	2 Mar 2006 01:02:25 -0000
@@ -51,20 +51,12 @@
 #include "gnome-vfs-volume-monitor-daemon.h"
 #include "gnome-vfs-volume-monitor-private.h"
 
-#define PATH_GCONF_GNOME_VFS_STORAGE "/system/storage"
-
 #ifndef PATHNAME_MAX
 # define PATHNAME_MAX	1024
 #endif
 
 typedef struct {
 	GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon;
-	gboolean display_internal_hard_drives;
-	gboolean display_scsi_drives;
-	gboolean display_scsi_optical_drives;
-	gboolean display_external_drives;
-	gboolean display_drives_removable;
-	guint gconf_client_connection_id;
 } GnomeVFSHalUserData;
 
 typedef enum {
@@ -617,39 +609,8 @@ _hal_drive_policy_check (GnomeVFSVolumeM
 
 	g_return_val_if_fail (hal_userdata != NULL, ret);
 
-	if (!hal_userdata->display_external_drives) {
-		if (libhal_drive_is_hotpluggable (hal_drive))
-			goto out;
-	}
-
-	if (!hal_userdata->display_drives_removable) {
-		if (libhal_drive_uses_removable_media (hal_drive))
-			goto out;
-	}
-
-	if (!hal_userdata->display_internal_hard_drives) {
-		if ((libhal_drive_uses_removable_media (hal_drive) == FALSE) && 
-		    (libhal_drive_is_hotpluggable (hal_drive) == FALSE))
-			goto out;
-	}
-
-	if (!hal_userdata->display_scsi_drives) {
-		if (libhal_drive_get_bus (hal_drive) == LIBHAL_DRIVE_BUS_SCSI) {
-			if (hal_userdata->display_scsi_optical_drives) {
-				if (libhal_drive_get_type (hal_drive) == LIBHAL_DRIVE_TYPE_CDROM) {
-					/* we're safe */
-				} else {
-					goto out;
-				}
-			} else {
-				goto out;
-			}
-		}
-	}
-
 	ret = TRUE;
 
-out:
 	return ret;
 }
 
@@ -698,18 +659,11 @@ _hal_volume_policy_check (GnomeVFSVolume
 
 	/* if we contain crypto bits, only show if our cleartext volume is not yet setup */
 	if (libhal_volume_get_fsusage (hal_volume) == LIBHAL_VOLUME_USAGE_CRYPTO) {
-		DBusError error;
-		char **clear_devices;
-		int num_clear_devices;
+		char *clear_udi;
 
-		dbus_error_init (&error);
-		clear_devices = libhal_manager_find_device_string_match (volume_monitor_daemon->hal_ctx,
-									 "volume.crypto_luks.clear.backing_volume",
-									 libhal_volume_get_udi (hal_volume),
-									 &num_clear_devices,
-									 &error);
-		if (clear_devices != NULL && num_clear_devices > 0) {
-			libhal_free_string_array (clear_devices);
+		clear_udi = libhal_volume_crypto_get_clear_volume_udi (volume_monitor_daemon->hal_ctx, hal_volume);
+		if (clear_udi != NULL) {
+			free (clear_udi);
 			goto out;
 		}
 	}
@@ -910,8 +864,7 @@ _hal_add_volume (GnomeVFSVolumeMonitorDa
 	GnomeVFSHalUserData *hal_userdata;
 	char *name;
 	gboolean allowed_by_policy;
-	DBusError error;
-	char *backing_udi;
+	const char *backing_udi;
 
 	g_return_val_if_fail (hal_drive != NULL, FALSE);
 	g_return_val_if_fail (hal_volume != NULL, FALSE);
@@ -987,12 +940,7 @@ _hal_add_volume (GnomeVFSVolumeMonitorDa
 	 * GnomeVFSDrive we added so users had a way to invoke
 	 * gnome-mount for asking for the pass-phrase...
 	 */
-	dbus_error_init (&error);
-	backing_udi = libhal_device_get_property_string (
-		volume_monitor_daemon->hal_ctx,
-		libhal_volume_get_udi (hal_volume),
-		"volume.crypto_luks.clear.backing_volume",
-		&error);
+	backing_udi = libhal_volume_crypto_get_backing_volume_udi (hal_volume);
 	if (backing_udi != NULL) {
 		GnomeVFSDrive *backing_drive;
 		
@@ -1108,9 +1056,6 @@ _hal_add_volume (GnomeVFSVolumeMonitorDa
 	ret = TRUE;
 out:
 
-	if (backing_udi != NULL)
-		libhal_free_string (backing_udi);
-	
 	return ret;
 }
 
@@ -1458,67 +1403,6 @@ out:
 	if (volume != NULL)
 		libhal_volume_free (volume);
 }
-	
-
-static void 
-_hal_get_settings_from_gconf (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon)
-{
-	GnomeVFSHalUserData *hal_userdata;
-
-	g_return_if_fail (volume_monitor_daemon != NULL);
-
-	hal_userdata = (GnomeVFSHalUserData *) libhal_ctx_get_user_data (volume_monitor_daemon->hal_ctx);
-
-	g_return_if_fail (hal_userdata != NULL);
-
-	/* respect the gconf settings! */
-	hal_userdata->display_internal_hard_drives = gconf_client_get_bool (volume_monitor_daemon->gconf_client,
-									    PATH_GCONF_GNOME_VFS_STORAGE 
-									    "/display_internal_hard_drives",
-									    NULL);
-	hal_userdata->display_scsi_drives = gconf_client_get_bool (volume_monitor_daemon->gconf_client,
-								   PATH_GCONF_GNOME_VFS_STORAGE 
-								   "/display_scsi_drives",
-								   NULL);
-	hal_userdata->display_scsi_optical_drives = gconf_client_get_bool (volume_monitor_daemon->gconf_client,
-									   PATH_GCONF_GNOME_VFS_STORAGE 
-									   "/display_scsi_optical_drives",
-									   NULL);
-	hal_userdata->display_external_drives = gconf_client_get_bool (volume_monitor_daemon->gconf_client,
-								       PATH_GCONF_GNOME_VFS_STORAGE
-								       "/display_external_drives",
-								       NULL);
-	hal_userdata->display_drives_removable = gconf_client_get_bool (volume_monitor_daemon->gconf_client,
-									PATH_GCONF_GNOME_VFS_STORAGE
-									"/display_drives_with_removable_media",
-									NULL);
-}
-
-static void
-_hal_settings_changed (GConfClient* client,
-		       guint cnxn_id,
-		       GConfEntry *entry,
-		       gpointer data)
-{
-	GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon;
-
-	volume_monitor_daemon = data;
-
-	g_return_if_fail (volume_monitor_daemon != NULL);
-
-#ifdef HAL_SHOW_DEBUG
-	g_debug ("in _hal_settings_changed");
-#endif
-
-#if 0
-	/* TODO: presently we don't support reloading settings from gconf. This
-	 *       requires some fixes not presently implemented
-	 */
-	_hal_get_settings_from_gconf (volume_monitor_daemon);
-	_gnome_vfs_hal_mounts_force_reprobe (volume_monitor_daemon);
-#endif
-
-}
 
 
 gboolean
@@ -1571,27 +1455,12 @@ _gnome_vfs_hal_mounts_init (GnomeVFSVolu
 	libhal_ctx_set_user_data (volume_monitor_daemon->hal_ctx,
 				  hal_userdata);
 
-	gconf_client_add_dir (volume_monitor_daemon->gconf_client,
-			      PATH_GCONF_GNOME_VFS_STORAGE,
-			      GCONF_CLIENT_PRELOAD_RECURSIVE,
-			      NULL);
-
-	hal_userdata->gconf_client_connection_id =
-		gconf_client_notify_add (volume_monitor_daemon->gconf_client,
-					 PATH_GCONF_GNOME_VFS_STORAGE,
-					 _hal_settings_changed,
-					 volume_monitor_daemon,
-					 NULL,
-					 NULL);
-
 	/* Simply watch all property changes instead of dynamically
 	 * adding/removing match rules bus-side to only match certain
 	 * objects...
 	 */
 	libhal_device_property_watch_all (volume_monitor_daemon->hal_ctx, &error);
 
-	_hal_get_settings_from_gconf (volume_monitor_daemon);
-
 	/* add drives/volumes from HAL */
 	_hal_update_all (volume_monitor_daemon);
 
@@ -1616,9 +1485,6 @@ _gnome_vfs_hal_mounts_shutdown (GnomeVFS
 	if (!libhal_ctx_free (volume_monitor_daemon->hal_ctx)) {
 		g_warning ("hal_shutdown failed - unable to free hal context\n");
 	}
-
-	gconf_client_notify_remove (volume_monitor_daemon->gconf_client,
-				    hal_userdata->gconf_client_connection_id);
 
 }
 
Index: po/ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-vfs/po/ChangeLog,v
retrieving revision 1.978
diff -u -p -r1.978 ChangeLog
--- po/ChangeLog	27 Feb 2006 10:58:23 -0000	1.978
+++ po/ChangeLog	2 Mar 2006 01:02:28 -0000
@@ -1,3 +1,7 @@
+2006-03-01  David Zeuthen  <davidz redhat com>
+
+	* POTFILES.in: Remove system_storage.schemas.in
+
 === gnome-vfs 2.13.92 ===
 	
 2006-02-25  Beno�Dejean  <benoit placenet org>
Index: po/POTFILES.in
===================================================================
RCS file: /cvs/gnome/gnome-vfs/po/POTFILES.in,v
retrieving revision 1.36
diff -u -p -r1.36 POTFILES.in
--- po/POTFILES.in	17 Jan 2006 01:31:59 -0000	1.36
+++ po/POTFILES.in	2 Mar 2006 01:02:28 -0000
@@ -29,4 +29,3 @@ schemas/desktop_gnome_url_handlers.schem
 schemas/system_dns_sd.schemas.in
 schemas/system_http_proxy.schemas.in
 schemas/system_smb.schemas.in
-schemas/system_storage.schemas.in
Index: schemas/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-vfs/schemas/Makefile.am,v
retrieving revision 1.13
diff -u -p -r1.13 Makefile.am
--- schemas/Makefile.am	30 Jun 2005 09:17:21 -0000	1.13
+++ schemas/Makefile.am	2 Mar 2006 01:02:28 -0000
@@ -3,7 +3,6 @@ schema_in_files = \
 	system_http_proxy.schemas.in \
 	system_smb.schemas.in \
 	system_dns_sd.schemas.in \
-	system_storage.schemas.in \
 	desktop_default_applications.schemas.in \
 	desktop_gnome_url_handlers.schemas.in
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]