[Utopia] [patch] only run g-v-m policy if g-v-m mounted the device



g-v-m was running its policy not only when it mounted a device itself.
It would run policy every time it got a mount property change signal
from hal.  This caused problems such as a nautilus window opening when
mounting from the command line and other such weird behavior.

This patch places the udi of a device in a policy list when it is
mounted by g-v-m and only runs policy in the property change handler if
the given udi is in the list. 

-- 
John (J5) Palmieri
Associate Software Engineer
Desktop Group
Red Hat, Inc.
Blog: http://martianrock.com
--- gnome-volume-manager-1.1.0/src/manager.c.policy-after-explicit-mount-only	2004-10-15 18:03:15.272545000 -0400
+++ gnome-volume-manager-1.1.0/src/manager.c	2004-10-15 18:04:19.227526000 -0400
@@ -55,8 +55,8 @@
 static struct gvm_configuration config;
 static LibHalContext *hal_ctx;
 
-/** List of UDI's for volumes mounted when starting up */
-static GSList *mount_ignore_udi_list = NULL;
+/** List of UDI's for volumes mounted by g-v-m that we need to apply policy to*/
+static GSList *mounted_volumes_policy_queue = NULL;
 
 /** List of UDI's of all volumes mounted during the lifetime of the program */
 static GSList *all_mounted_volumes = NULL;
@@ -561,6 +561,7 @@
 	switch (action) {
 	case MOUNT:
 		gvm_device_mount (device);
+		mounted_volumes_policy_queue = g_slist_append (mounted_volumes_policy_queue, g_strdup (udi));
 		break;
 	case PLAY:
 		gvm_run_cdplayer (device, device, udi);
@@ -635,8 +636,10 @@
 	} else if (has_audio && has_data) {
 		gvm_ask_mixed (udi);
 	} else if (has_data) {
-		if (config.automount_media)
+		if (config.automount_media) {
 			gvm_device_mount (device);
+			mounted_volumes_policy_queue = g_slist_append (mounted_volumes_policy_queue, g_strdup (udi));
+		}
 	} else if (is_blank) {
 		if (gvm_device_is_writer (drive_udi))
 			gvm_run_cdburner (device, device, udi);
@@ -691,8 +694,10 @@
 	} else {
 		dbg ("Added: %s\n", device);
 		
-		if (config.automount_drives)
+		if (config.automount_drives) {
 			gvm_device_mount (device);
+			mounted_volumes_policy_queue = g_slist_append (mounted_volumes_policy_queue, g_strdup (udi));
+		}
 	}
 
 	hal_free_string (media_type);
@@ -753,8 +758,10 @@
 	/* folks, we have a new device! */
 	dbg ("Added: %s\n", device);
 	
-	if (config.automount_drives)
+	if (config.automount_drives) {
 		gvm_device_mount (device);
+		mounted_volumes_policy_queue = g_slist_append (mounted_volumes_policy_queue, g_strdup (udi));
+	}
 	
 out:
 	hal_free_string (device);
@@ -822,7 +829,7 @@
 	
 	val = hal_device_get_property_bool (hal_ctx, udi, key);
 	if (val == TRUE) {
-		gboolean ignore_mount;
+		GSList *policy_udi;
 
 		dbg ("Mounted: %s\n", udi);
 
@@ -830,26 +837,15 @@
 		all_mounted_volumes = g_slist_append (all_mounted_volumes,
 						      g_strdup (udi));
 
-		ignore_mount = FALSE;
-		for (i = mount_ignore_udi_list; i != NULL; i = next) {
-			next = g_slist_next (i);
-
-			if (strcmp (udi, (const char *)i->data) == 0) {
-				ignore_mount = TRUE;
-				g_free (i->data);
-				mount_ignore_udi_list = 
-					g_slist_delete_link (
-						mount_ignore_udi_list, i);
-				break;
-			}
-		}
-		
-		
-		/* only autorun if not in ignore list, cf.
-		 * function mount_all
-			 */
-		if (!ignore_mount)
+		policy_udi = g_slist_find_custom (mounted_volumes_policy_queue, 
+						  udi, 
+						  g_ascii_strcasecmp);
+		if (policy_udi != NULL) {
+			g_free (policy_udi->data);
+			mounted_volumes_policy_queue = g_slist_delete_link (mounted_volumes_policy_queue, 
+									    policy_udi);
 			gvm_device_autorun (udi);
+		}
 
 	} else {
 		dbg ("Unmounted: %s\n", udi);
@@ -981,17 +977,7 @@
 
 			dbg ("mount_all: mounting %s\n", device_file);
 
-			if (gvm_device_mount (device_file)) {
-				/* yay, it worked; add to list of
-				 * udi's not to autorun from hal_property_
-				 * changed
-				 */
-
-				mount_ignore_udi_list = 
-					g_slist_append (mount_ignore_udi_list,
-							g_strdup (udi));
-
-			}
+			gvm_device_mount (device_file);
 
 			hal_free_string (device_file);
 		} else {


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