gvfs r1133 - in trunk: . hal



Author: alexl
Date: Tue Jan 15 09:47:53 2008
New Revision: 1133
URL: http://svn.gnome.org/viewvc/gvfs?rev=1133&view=rev

Log:
2008-01-15  David Zeuthen  <davidz redhat com>

	* hal/ghaldrive.c: (_eject_unmount_mounts_cb),
	(_eject_unmount_mounts), (g_hal_drive_eject):
	* hal/ghalvolume.c: (g_hal_volume_new), (g_hal_volume_can_mount),
	(g_hal_volume_has_device_path), (g_hal_volume_mount),
	(g_hal_volume_eject):
	* hal/ghalvolume.h:
	* hal/ghalvolumemonitor.c:
	(g_hal_volume_monitor_lookup_volume_for_device_path),
	(update_volumes), (update_mounts), (update_discs):
	Fix debug spew and use try device path before mount path to tie
	volume and mount objects together. Also fix some issues with
	mounting and unmounting.



Modified:
   trunk/ChangeLog
   trunk/hal/ghaldrive.c
   trunk/hal/ghalvolume.c
   trunk/hal/ghalvolume.h
   trunk/hal/ghalvolumemonitor.c

Modified: trunk/hal/ghaldrive.c
==============================================================================
--- trunk/hal/ghaldrive.c	(original)
+++ trunk/hal/ghaldrive.c	Tue Jan 15 09:47:53 2008
@@ -347,7 +347,7 @@
 {
   GHalDrive *hal_drive = G_HAL_DRIVE (user_data);
   
-  //g_warning ("volhal modifying %s (property %s changed)", hal_drive->device_path, key);
+  /*g_warning ("volhal modifying %s (property %s changed)", hal_drive->device_path, key);*/
   _update_from_hal (hal_drive, TRUE);
 }
 
@@ -641,7 +641,7 @@
   else
     {
 
-      g_warning ("successfully unmount %p", mount);
+      /*g_warning ("successfully unmounted %p", mount);*/
 
       /* move on to the next mount.. */
       _eject_unmount_mounts (data);
@@ -658,7 +658,7 @@
   if (data->pending_mounts == NULL)
     {
 
-      g_warning ("all pending mounts done; ejecting drive");
+      /*g_warning ("all pending mounts done; ejecting drive");*/
 
       g_hal_drive_eject_do (data->drive,
                             data->cancellable,
@@ -671,7 +671,7 @@
       mount = data->pending_mounts->data;
       data->pending_mounts = g_list_remove (data->pending_mounts, mount);
 
-      g_warning ("unmounting %p", mount);
+      /*g_warning ("unmounting %p", mount);*/
 
       g_mount_unmount (mount,
                        data->flags,
@@ -707,7 +707,7 @@
       GMount *mount; /* the mount may be foreign; cannot assume GHalMount */
 
       mount = g_volume_get_mount (G_VOLUME (volume));
-      if (mount != NULL)
+      if (mount != NULL && g_mount_can_unmount (mount))
         data->pending_mounts = g_list_prepend (data->pending_mounts, g_object_ref (mount));
     }
 
@@ -794,7 +794,7 @@
   data->user_data = user_data;
   data->cancellable = cancellable;
 
-  //g_warning ("Rescanning udi %s", hal_device_get_udi (hal_drive->device));
+  /*g_warning ("Rescanning udi %s", hal_device_get_udi (hal_drive->device));*/
   
   con = hal_pool_get_dbus_connection (hal_drive->pool);
   
@@ -832,7 +832,7 @@
                                    GAsyncResult  *result,
                                    GError       **error)
 {
-  //g_warning ("poll finish");
+  /*g_warning ("poll finish");*/
   return TRUE;
 }
 

Modified: trunk/hal/ghalvolume.c
==============================================================================
--- trunk/hal/ghalvolume.c	(original)
+++ trunk/hal/ghalvolume.c	Tue Jan 15 09:47:53 2008
@@ -55,6 +55,7 @@
    */
   GFile *foreign_mount_root;
   GMount *foreign_mount;
+  gboolean is_mountable;
 
   char *name;
   char *icon;
@@ -311,7 +312,7 @@
 {
   GHalVolume *hal_volume = G_HAL_VOLUME (user_data);
   
-  //g_warning ("hal modifying %s (property %s changed)", hal_volume->device_path, key);
+  /*g_warning ("hal modifying %s (property %s changed)", hal_volume->device_path, key);*/
   update_from_hal (hal_volume, TRUE);
 }
 
@@ -348,6 +349,7 @@
                   HalDevice        *device,
                   HalPool          *pool,
                   GFile            *foreign_mount_root,
+                  gboolean          is_mountable,
                   GHalDrive        *drive)
 {
   GHalVolume *volume;
@@ -370,6 +372,7 @@
   volume->device = g_object_ref (device);
   volume->drive_device = g_object_ref (drive_device);
   volume->foreign_mount_root = foreign_mount_root != NULL ? g_object_ref (foreign_mount_root) : NULL;
+  volume->is_mountable = is_mountable;
   
   g_signal_connect_object (device, "hal_property_changed", (GCallback) hal_changed, volume, 0);
   g_signal_connect_object (drive_device, "hal_property_changed", (GCallback) hal_changed, volume, 0);
@@ -494,7 +497,8 @@
 static gboolean
 g_hal_volume_can_mount (GVolume *volume)
 {
-  return TRUE;
+  GHalVolume *hal_volume = G_HAL_VOLUME (volume);
+  return hal_volume->is_mountable;
 }
 
 static gboolean
@@ -539,6 +543,15 @@
 }
 
 gboolean
+g_hal_volume_has_device_path (GHalVolume *volume,
+                              const char  *device_path)
+{
+  if (volume->device_path != NULL)
+    return strcmp (volume->device_path, device_path) == 0;
+  return FALSE;
+}
+
+gboolean
 g_hal_volume_has_udi (GHalVolume  *volume,
                       const char  *udi)
 {
@@ -706,6 +719,11 @@
 {
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
 
+  /*g_warning ("hal_volume_mount (can_mount=%d foreign=%p device_path=%s)", 
+              g_hal_volume_can_mount (volume),
+              hal_volume->foreign_mount_root,
+              hal_volume->device_path);*/
+
   if (hal_volume->foreign_mount_root != NULL)
     {
       ForeignMountOp *data;
@@ -723,8 +741,11 @@
     }
   else
     {
-      char *argv[] = {"gnome-mount", "-b", "-d", NULL, NULL};
+      char *argv[] = {"gnome-mount", "-b", "-d", NULL, NULL, NULL};
       argv[3] = hal_volume->device_path;
+      /* ask for no dialogs if mount_operation is NULL */
+      if (mount_operation == NULL)
+        argv[4] = "-n";
       spawn_do (volume, cancellable, callback, user_data, argv);
     }
 }
@@ -771,7 +792,7 @@
 {
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
 
-  g_warning ("hal_volume_eject");
+  /*g_warning ("hal_volume_eject");*/
 
   if (hal_volume->drive != NULL)
     {

Modified: trunk/hal/ghalvolume.h
==============================================================================
--- trunk/hal/ghalvolume.h	(original)
+++ trunk/hal/ghalvolume.h	Tue Jan 15 09:47:53 2008
@@ -50,10 +50,13 @@
 					 HalDevice        *device,
 					 HalPool          *pool,
                                          GFile            *foreign_mount_root,
+                                         gboolean          is_mountable,
 					 GHalDrive        *drive);
 
 gboolean    g_hal_volume_has_mount_path (GHalVolume       *volume,
 					 const char       *mount_path);
+gboolean    g_hal_volume_has_device_path (GHalVolume       *volume,
+                                          const char       *device_path);
 gboolean    g_hal_volume_has_udi        (GHalVolume       *volume,
 					 const char       *udi);
 gboolean    g_hal_volume_has_uuid       (GHalVolume       *volume,

Modified: trunk/hal/ghalvolumemonitor.c
==============================================================================
--- trunk/hal/ghalvolumemonitor.c	(original)
+++ trunk/hal/ghalvolumemonitor.c	Tue Jan 15 09:47:53 2008
@@ -336,7 +336,7 @@
 {
   GHalVolumeMonitor *monitor = G_HAL_VOLUME_MONITOR (user_data);
   
-  //g_warning ("hal changed");
+  /*g_warning ("hal changed");*/
   
   update_drives (monitor);
   update_volumes (monitor);
@@ -360,7 +360,7 @@
       return object;
     }
 
-  //g_warning ("creating hal vm");
+  /*g_warning ("creating hal vm");*/
 
   object = NULL;
 
@@ -551,6 +551,23 @@
   return NULL;
 }
 
+static GHalVolume *
+g_hal_volume_monitor_lookup_volume_for_device_path (GHalVolumeMonitor *monitor,
+                                                    const char         *device_path)
+{
+  GList *l;
+
+  for (l = monitor->volumes; l != NULL; l = l->next)
+    {
+      GHalVolume *volume = l->data;
+
+      if (g_hal_volume_has_device_path (volume, device_path))
+	return volume;
+    }
+  
+  return NULL;
+}
+
 
 
 static GHalMount *
@@ -651,7 +668,7 @@
   
   if (volume_fsusage == NULL)
     {
-      //g_warning ("no volume.fsusage property. Refusing to ignore");
+      /*g_warning ("no volume.fsusage property. Refusing to ignore");*/
       return FALSE;
     }
 
@@ -696,7 +713,7 @@
       drive = find_drive_by_udi (monitor, hal_device_get_udi (d));
       if (drive != NULL)
         {
-          //g_warning ("hal removing drive %s", hal_device_get_property_string (d, "block.device"));
+          /*g_warning ("hal removing drive %s", hal_device_get_property_string (d, "block.device"));*/
           g_hal_drive_disconnected (drive);
           monitor->drives = g_list_remove (monitor->drives, drive);
           g_signal_emit_by_name (monitor, "drive_disconnected", drive);
@@ -711,7 +728,7 @@
       drive = find_drive_by_udi (monitor, hal_device_get_udi (d));
       if (drive == NULL)
         {
-          //g_warning ("hal adding drive %s", hal_device_get_property_string (d, "block.device"));
+          /*g_warning ("hal adding drive %s", hal_device_get_property_string (d, "block.device"));*/
           drive = g_hal_drive_new (G_VOLUME_MONITOR (monitor), d, monitor->pool);
           if (drive != NULL)
             {
@@ -764,7 +781,7 @@
       volume = find_volume_by_udi (monitor, hal_device_get_udi (d));
       if (volume != NULL)
         {
-          //g_warning ("hal removing vol %s", hal_device_get_property_string (d, "block.device"));
+          /*g_warning ("hal removing vol %s", hal_device_get_property_string (d, "block.device"));*/
           g_hal_volume_removed (volume);
           monitor->volumes = g_list_remove (monitor->volumes, volume);
           g_signal_emit_by_name (monitor, "volume_removed", volume);
@@ -782,8 +799,8 @@
         {
           drive = find_drive_by_udi (monitor, hal_device_get_property_string (d, "block.storage_device"));
 
-          //g_warning ("hal adding vol %s (drive %p)", hal_device_get_property_string (d, "block.device"), drive);
-          volume = g_hal_volume_new (G_VOLUME_MONITOR (monitor), d, monitor->pool, NULL, drive);
+          /*g_warning ("hal adding vol %s (drive %p)", hal_device_get_property_string (d, "block.device"), drive);*/
+          volume = g_hal_volume_new (G_VOLUME_MONITOR (monitor), d, monitor->pool, NULL, TRUE, drive);
           if (volume != NULL)
             {
               monitor->volumes = g_list_prepend (monitor->volumes, volume);
@@ -807,6 +824,7 @@
   GList *l;
   GHalMount *mount;
   GHalVolume *volume;
+  const char *device_path;
   const char *mount_path;
   
   new_mounts = g_unix_mounts_get (NULL);
@@ -822,7 +840,7 @@
       GUnixMountEntry *mount_entry = l->data;
       
       mount = find_mount_by_mount_path (monitor, g_unix_mount_get_mount_path (mount_entry));
-      //g_warning ("hal removing mount %s (%p)", g_unix_mount_get_device_path (mount_entry), mount);
+      /*g_warning ("hal removing mount %s (%p)", g_unix_mount_get_device_path (mount_entry), mount);*/
       if (mount)
 	{
 	  g_hal_mount_unmounted (mount);
@@ -837,10 +855,14 @@
     {
       GUnixMountEntry *mount_entry = l->data;
 
+      device_path = g_unix_mount_get_device_path (mount_entry);
       mount_path = g_unix_mount_get_mount_path (mount_entry);
-      volume = g_hal_volume_monitor_lookup_volume_for_mount_path (monitor, mount_path);
+      volume = g_hal_volume_monitor_lookup_volume_for_device_path (monitor, device_path);
+      if (volume == NULL) {
+        volume = g_hal_volume_monitor_lookup_volume_for_mount_path (monitor, mount_path);
+      }
 
-      //g_warning ("hal adding mount %s (vol %p)", g_unix_mount_get_device_path (mount_entry), volume);
+      /*g_warning ("hal adding mount %s (vol %p)", g_unix_mount_get_device_path (mount_entry), volume);*/
       mount = g_hal_mount_new (G_VOLUME_MONITOR (monitor), mount_entry, monitor->pool, volume);
       if (mount)
 	{
@@ -865,7 +887,7 @@
   GList *l, *ll;
   GHalDrive *drive;
   GHalVolume *volume;
-  GHalMount *mount;
+  GHalMount *mount = NULL;
   const char *udi;
   const char *drive_udi;
 
@@ -901,7 +923,7 @@
       HalDevice *d = l->data;
 
       udi = hal_device_get_udi (d);
-      //g_warning ("audio/blank disc removing %s", udi);
+      /*g_warning ("audio/blank disc removing %s", udi);*/
 
       mount = find_disc_mount_by_udi (monitor, udi);
       if (mount != NULL)
@@ -929,7 +951,7 @@
       HalDevice *d = l->data;
 
       udi = hal_device_get_udi (d);
-      //g_warning ("audio/blank disc adding %s", udi);
+      /*g_warning ("audio/blank disc adding %s", udi);*/
 
       drive_udi = hal_device_get_property_string (d, "block.storage_device");
       drive = find_drive_by_udi (monitor, drive_udi);
@@ -937,7 +959,8 @@
         {
           if (hal_device_get_property_bool (d, "volume.disc.is_blank"))
             {
-              volume = g_hal_volume_new (G_VOLUME_MONITOR (monitor), d, monitor->pool, NULL, drive);
+              /* burn:/// is not mountable ... */
+              volume = g_hal_volume_new (G_VOLUME_MONITOR (monitor), d, monitor->pool, NULL, FALSE, drive);
               if (volume != NULL)
                 {
                   GFile *file;
@@ -966,7 +989,7 @@
               g_free (device_basename);
               g_free (uri);
 
-              volume = g_hal_volume_new (G_VOLUME_MONITOR (monitor), d, monitor->pool, foreign_mount_root, drive);
+              volume = g_hal_volume_new (G_VOLUME_MONITOR (monitor), d, monitor->pool, foreign_mount_root, TRUE, drive);
               g_object_unref (foreign_mount_root);
               mount = NULL;
             }



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