[PATCH] Fix AFC mounts being shadowed



We don't need an activation root on the volume, we can
figure out what to mount from the UUID.
---
 monitor/afc/afc-volume-monitor.c |   13 +----------
 monitor/afc/afc-volume.c         |   42 +++++++++++++++++--------------------
 monitor/afc/afc-volume.h         |    3 +-
 3 files changed, 21 insertions(+), 37 deletions(-)

diff --git a/monitor/afc/afc-volume-monitor.c b/monitor/afc/afc-volume-monitor.c
index 0c2fda5..dd4b0dd 100644
--- a/monitor/afc/afc-volume-monitor.c
+++ b/monitor/afc/afc-volume-monitor.c
@@ -32,8 +32,6 @@ static void g_vfs_afc_monitor_create_volume(GVfsAfcVolumeMonitor *self, const
     DBusError err;
     GVfsAfcVolume *volume = NULL;
     gchar *uuid = NULL;
-    GFile *activation_mount_root = NULL; 
-    gchar *uri;
 
     dbus_error_init(&err);
 
@@ -45,12 +43,7 @@ static void g_vfs_afc_monitor_create_volume(GVfsAfcVolumeMonitor *self, const
 
     g_print("creating volume for device uuid '%s'\n", uuid);
 
-    uri = g_strdup_printf("afc://%s", uuid);
-
-    activation_mount_root = g_file_new_for_uri(uri);
-    g_free(uri);
-
-    volume = g_vfs_afc_volume_new(G_VOLUME_MONITOR (self), udi, uuid, activation_mount_root);
+    volume = g_vfs_afc_volume_new(G_VOLUME_MONITOR (self), udi, uuid);
     if (volume != NULL) {
 	self->volumes = g_list_prepend(self->volumes, volume);
 	g_signal_emit_by_name(self, "volume_added", volume);
@@ -59,10 +52,6 @@ static void g_vfs_afc_monitor_create_volume(GVfsAfcVolumeMonitor *self, const
     if (uuid != NULL) {
 	g_free (uuid);
     }
-
-    if (activation_mount_root != NULL) {
-	g_object_unref (activation_mount_root);
-    }
 }
 
 static GVfsAfcVolume *find_volume_by_uuid(GVfsAfcVolumeMonitor *self, const char * uuid)
diff --git a/monitor/afc/afc-volume.c b/monitor/afc/afc-volume.c
index 5979a20..50c8c15 100644
--- a/monitor/afc/afc-volume.c
+++ b/monitor/afc/afc-volume.c
@@ -14,8 +14,6 @@ struct _GVfsAfcVolume {
 
     GVolumeMonitor *monitor;
 
-    GFile *activation_root;
-    
     char *uuid;
     char *udi;
 
@@ -35,9 +33,6 @@ static void g_vfs_afc_volume_finalize(GObject *self_)
 
     self = G_VFS_AFC_VOLUME(self);
 
-    if (self->activation_root != NULL)
-      g_object_unref (self->activation_root);
-
     g_free (self->uuid);
     g_free (self->udi);
 
@@ -67,8 +62,7 @@ static void g_vfs_afc_volume_class_init(GVfsAfcVolumeClass *klass)
 
 GVfsAfcVolume *g_vfs_afc_volume_new(GVolumeMonitor *monitor,
                                     const char     *udi,
-				    const char     *uuid,
-                                    GFile          *activation_root)
+				    const char     *uuid)
 {
     GVfsAfcVolume *self;
 
@@ -76,7 +70,6 @@ GVfsAfcVolume *g_vfs_afc_volume_new(GVolumeMonitor *monitor,
     self->monitor = monitor;
     self->uuid = g_strdup (uuid);
     self->udi = g_strdup (udi);
-    self->activation_root = g_object_ref (activation_root);
 
     return self;
 }
@@ -146,6 +139,7 @@ typedef struct
 {
   GVfsAfcVolume *enclosing_volume;
   GAsyncReadyCallback  callback;
+  GFile *root;
   gpointer user_data;
 } ActivationMountOp;
 
@@ -156,6 +150,7 @@ mount_callback (GObject *source_object,
 {
   ActivationMountOp *data = user_data;
   data->callback (G_OBJECT (data->enclosing_volume), res, data->user_data);
+  g_object_unref (data->root);
   g_free (data);
 }
 
@@ -169,18 +164,26 @@ g_vfs_afc_volume_mount (GVolume             *volume,
 {
   GVfsAfcVolume *afc_volume = G_VFS_AFC_VOLUME (volume);
   ActivationMountOp *data;
+  GFile *root;
+  char *uri;
 
-  g_print ("gphoto2_volume_mount (can_mount=%d foreign=%p uuid=%s)",
+  g_print ("g_vgs_afc_volume_mount (can_mount=%d uuid=%s)",
               g_vfs_afc_volume_can_mount (volume),
-              afc_volume->activation_root,
               afc_volume->uuid);
 
+  uri = g_strdup_printf ("afc://%s", afc_volume->uuid);
+  root = g_file_new_for_uri (uri);
+  g_free (uri);
+
   data = g_new0 (ActivationMountOp, 1);
   data->enclosing_volume = afc_volume;
   data->callback = callback;
   data->user_data = user_data;
+  data->root = root;
 
-  g_file_mount_enclosing_volume (afc_volume->activation_root,
+  g_object_set_data_full (G_OBJECT(volume), "root", g_object_ref (root), g_object_unref);
+
+  g_file_mount_enclosing_volume (root,
                                  0,
                                  mount_operation,
                                  cancellable,
@@ -190,13 +193,15 @@ g_vfs_afc_volume_mount (GVolume             *volume,
 
 static gboolean
 g_vfs_afc_volume_mount_finish (GVolume       *volume,
-                           GAsyncResult  *result,
-                           GError       **error)
+			       GAsyncResult  *result,
+			       GError       **error)
 {
   GVfsAfcVolume *afc_volume = G_VFS_AFC_VOLUME (volume);
+  GFile *root;
   gboolean res;
 
-  res = g_file_mount_enclosing_volume_finish (afc_volume->activation_root, result, error);
+  root = g_object_get_data (G_OBJECT (volume), "root");
+  res = g_file_mount_enclosing_volume_finish (root, result, error);
 
   return res;
 }
@@ -238,14 +243,6 @@ g_vfs_afc_volume_enumerate_identifiers (GVolume *volume)
   return (char **)g_ptr_array_free (res, FALSE);
 }
 
-static GFile *
-g_vfs_afc_volume_get_activation_root (GVolume *volume)
-{
-    GVfsAfcVolume *afc_volume = G_VFS_AFC_VOLUME (volume);
-
-    return g_object_ref (afc_volume->activation_root);
-}
-
 static void
 g_vfs_afc_volume_iface_init (GVolumeIface *iface)
 {
@@ -263,7 +260,6 @@ g_vfs_afc_volume_iface_init (GVolumeIface *iface)
     iface->eject_finish = NULL;
     iface->get_identifier = g_vfs_afc_volume_get_identifier;
     iface->enumerate_identifiers = g_vfs_afc_volume_enumerate_identifiers;
-    iface->get_activation_root = g_vfs_afc_volume_get_activation_root;
 }
 
 char *g_vfs_afc_volume_get_udi(GVfsAfcVolume *volume)
diff --git a/monitor/afc/afc-volume.h b/monitor/afc/afc-volume.h
index 16f2398..703610f 100644
--- a/monitor/afc/afc-volume.h
+++ b/monitor/afc/afc-volume.h
@@ -37,8 +37,7 @@ GType g_vfs_afc_volume_get_type(void) G_GNUC_CONST;
 
 GVfsAfcVolume *g_vfs_afc_volume_new(GVolumeMonitor *monitor,
                                     const char     *udi,
-				    const char     *uuid,
-                                    GFile          *activation_root);
+				    const char     *uuid);
 
 char *g_vfs_afc_volume_get_udi(GVfsAfcVolume *volume);
 gboolean g_vfs_afc_volume_has_uuid(GVfsAfcVolume *volume, const char *uuid);
-- 
1.6.2.5


--=-ZdDpsDIljr8Yfo3y12I2--



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