Re: Identifying drives/volumes



On Tue, 2004-10-19 at 10:31 +0200, Alexander Larsson wrote:

[Sorry for quoting the full text; this is to get gtk-devel-list on the
loop.]

> On Mon, 2004-10-18 at 12:44 -0500, Federico Mena Quintero wrote:
> > Hi,
> > 
> > For the GtkFileChooser's extension mechanism, I need to be able to
> > identify drives/volumes through a URI.  Are these guaranteed to refer
> > uniquely to the corresponding drive/volume?
> > 
> > 	gnome_vfs_drive_get_activation_uri()
> > 	gnome_vfs_volume_get_activation_uri()
> > 
> > Background:  a file chooser extension is an implementation of the
> > abstract interface GtkFileChooserExtensionIface.  This has a virtual
> > method called "is_volume_visible", which is used to implement lock-down:
> > 
> > 	gboolean (* is_volume_visible) (GtkFileChooserExtension *extension,
> > 					const char              *base_uri);
> > 
> > This base_uri is the URI that you would use to get to the root of a
> > volume.  The idea is that every time the file chooser needs to display
> > or enter a volume, it first asks the lock-down extension whether that
> > volume should be visible to the user.
> > 
> > So, I need to know if the activation_uri for a drive/volume is what I
> > need.  I don't want to expose the opaque GtkFileSystemVolume to
> > extensions.
> 
> There is no such guarantee. You can easily connect to server the same
> uri twice.

Hmm, I see.

The problem is this:  right now GtkFileSystemVolume and friends are
private structures, exposed only to file system implementations, and I
would prefer not to expose them to file chooser extensions --- ideally
extensions would deal with just URIs.

However, using the activation_uri to identify volumes would still work,
right?  The code path I'm envisioning is this:

  gboolean
  lockdown_extension_is_volume_visible (LockdownExt *ext, const char *base_uri)
  {
     GnomeVFSVolume *vol;
     char *path;
     gboolean visible;

     if (is_remote (base_uri))
       return can_user_see_remote_volume (base_uri);

     path = uri_to_path (base_uri);
     vol = gnome_vfs_volume_monitor_get_volume_for_path (vm, path);
     g_free (path);

     if (vol) {
       visible = can_user_see_volume (vol);
       gnome_vfs_volume_unref (vol);
     } else
       visible = FALSE;

     return visible;
  }

Even if the file chooser were using the GtkFileSystemUnix backend, the
only base_uri that would ever be fed into the lockdown extension would
be "file:///", for the file system's root.  If you were using
GtkFileSystemGnomeVFS, the extension would get fed "file:///",
"file:///mnt/cdrom", etc.

  Federico




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