[Utopia] [patch] gvm and locking



Hey Robert,

Here is a patch for gnome-volume-manager such that policy is not
enforced when media is inserted into a drive that another process has a
hal advisory lock on. 

This is useful as it solves the problem of g-v-m popping up a burn
Nautilus window when nautilus-cd-burner is asking me to insert a disc.
Hence, with this patch n-c-b can just lock the hal device object
representing the drive. Btw, I think Alexander Larsson is working on
such a patch for n-c-b.

The patch also bumps the requirement to the latest and greatest version
of hal as only this one got Joe's sweet locking code in.

Thanks,
David

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-volume-manager/ChangeLog,v
retrieving revision 1.106
diff -u -p -r1.106 ChangeLog
--- ChangeLog	13 Sep 2004 07:10:51 -0000	1.106
+++ ChangeLog	20 Sep 2004 14:41:18 -0000
@@ -1,3 +1,11 @@
+2004-09-20  David Zeuthen  <david fubar dk>
+
+	* configure.in: Update hal version requirement to 0.2.98
+
+	* src/manager.c (gvm_media_changed): Now that HAL supports locking
+	of devices (thanks to Joe Shaw) we refuse to enforce policy for
+	removable media if the drive is locked by another application
+
 2004-09-13  Robert Love  <rml ximian com>
 
 	* configure.in: update HAL dep
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gnome-volume-manager/configure.in,v
retrieving revision 1.63
diff -u -p -r1.63 configure.in
--- configure.in	13 Sep 2004 07:09:38 -0000	1.63
+++ configure.in	20 Sep 2004 14:41:18 -0000
@@ -71,11 +71,11 @@ AC_SUBST(GETTEXT_PACKAGE)
 AC_PROG_INTLTOOL([0.27.2])
 AM_GLIB_GNU_GETTEXT
 
-PKG_CHECK_MODULES(GVM, libgnomeui-2.0 dbus-glib-1 >= 0.20 hal >= 0.2.97)
+PKG_CHECK_MODULES(GVM, libgnomeui-2.0 dbus-glib-1 >= 0.20 hal >= 0.2.98)
 AC_SUBST(GVM_CFLAGS)
 AC_SUBST(GVM_LIBS)
 
-PKG_CHECK_MODULES(CAPPLET, libgnomeui-2.0 >= 2.1.5 libglade-2.0 hal >= 0.2.91)
+PKG_CHECK_MODULES(CAPPLET, libgnomeui-2.0 >= 2.1.5 libglade-2.0 hal >= 0.2.98)
 AC_SUBST(CAPPLET_CFLAGS)
 AC_SUBST(CAPPLET_LIBS)
 
Index: src/manager.c
===================================================================
RCS file: /cvs/gnome/gnome-volume-manager/src/manager.c,v
retrieving revision 1.31
diff -u -p -r1.31 manager.c
--- src/manager.c	1 Sep 2004 19:17:41 -0000	1.31
+++ src/manager.c	20 Sep 2004 14:41:18 -0000
@@ -38,7 +38,7 @@
 # define N_(String) (String)
 #endif
 
-/*#define GVM_DEBUG*/
+#define GVM_DEBUG
 #ifdef GVM_DEBUG
 # define dbg(fmt,arg...) fprintf(stderr, "%s/%d: " fmt,__FILE__,__LINE__,##arg)
 #else
@@ -663,6 +663,16 @@ gvm_media_changed (const char *udi, cons
 		   const char *device)
 {
 	char *media_type;
+
+	/* Refuse to enforce policy on removable media if drive is locked */
+	if (hal_device_property_exists (
+		    hal_ctx, storage_device, "info.locked") &&
+	    hal_device_get_property_bool (
+		    hal_ctx, storage_device, "info.locked")) {
+		dbg ("Drive with udi %s is locked through hal; "
+		     "skipping policy\n", storage_device);
+		return;
+	}
 
 	/*
 	 * Get HAL's interpretation of our media type.  Note that we must check


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