[RFC] gvfs connected servers



Hey Alex, Hey Matthias, Hey gvfs-list,

One of the the things we missed in Nautilus during the gnome-vfs ->
gio/gvfs transition was the "Connected Servers" feature. Which I really
miss; the current gtk+ bookmark feature is pretty much unusable for me
for a number of reasons. So I spent some time this weekend implementing
this feature in gvfs.

There's a bunch of changes required, I'm posting my almost-finished
patches (except for Nautilus; some more UI work is needed there) to get
some feedback before finishing them up

To recap, the main points of the "Connected Servers" feature are

 1. Servers are stored using the standard configuration system (GConf
    right now); This means that administrator can configure defaults
    and implement lockdown using standard tools built on top of GConf.

 2. The servers are visible on the desktop if even though there is no
    underlying connection/mount currently active. This is a very useful
    thing; I used (until the gio port) to have a "public_html @ fd.o"
    server for easy publishing of screenshots / files. In fact, it's the
    main reason I wrote these patches ;-)

 3. It should be possible to have multiple "servers" that points to the
    same server (think one for your home directory and one for a Movies
    directory both on the same box). The implementation must support
    changing all attributes (currently name, icon_name, uri) on the fly.

 4. The implementation must be extensible. If we at some point wants to
    add mount options (for e.g. better support of encoding for, say, 
    crappy FTP servers) it should be possible to configure this for a
    "connected server".

The way I've implemented this is via a remote volume monitor that simply
reads data from GConf and creates GVolume objects mirroring the data in
GConf.

Fixing issue 3. is also needed for the gphoto2 backend to support
multiple storage heads

 http://bugzilla.gnome.org/show_bug.cgi?id=520123

To expand on issue 3., it's perfectly sensible to have

 GVolume
  URI: ssh://quad.local/home/davidz
  Name: Home Directory on quad
  Icon: boring-work-icon

 GVolume
  URI: ssh://quad.local/media/FusionMedia/Movies
  Name: Movies
  Icon: fancy-movie-icon
 
both pointing the same GMount (with mount root ssh://quad.local/). For
the gphoto2 case the situation is this

 GVolume
  URI: gphoto2://[usb:002,003]/storage1
  Name: Photos on SONY XYZ
  Icon: camera-photos-sony-xyz

 GVolume
  URI: gphoto2://[usb:002,003]/storage2
  Name: Music on SONY XYZ
  Icon: multimedia-player-sony-xyz

 GVolume
  URI: gphoto2://[usb:002,003]/storage3
  Name: Micro-SD Card Reader on SONY XYZ
  Icon: drive-removable-media-flash-sd-micro

again, all three volumes pointing to a single GDaemonMount with root
gphoto2://[usb:002,003] provided via a single instance gvfsd-gphoto2
speaking to the device over a single USB pipe (USB is (generally) single
user; it's not possible to have multiple processes speaking to the same
device).

OK, on to the patches. First the GIO patch

http://people.freedesktop.org/~david/gvfs-connected-servers/gio-connected-servers-r7045-20081005.patch

First of all we need to deprecate g_mount_get_volume() now that more
than one volume may point to a mount. Instead there's new API

 GList *g_mount_get_volumes              (GMount *mount)
 GMount *g_mount_get_volume_for_location (GMount *mount,
                                          GFile *location);

There is one catch here. GIO users that displays drives/volumes/mounts
needs fixing insofar that a single mount may now be connected to more
than one volume. 

The way, roughly, all current users do this, is using this algorithm:

 for all drives D
  for all volumes V of D
   if V has a mount M
    display M
   else
    display V

 for all volumes V without drives
  if V has a mount M
   display M
  else
   display V

 for all mounts M without volumes
   display M

The only modification needed is that, for mount M of volume V, one needs
to use the name/uri/icon_name/uri from the volume V if, and only if,
g_volume_get_activation_uri(V) is set. This results in displaying

 Photos on SONY XYZ
 Music on SONY XYZ
 Micro-SD Card Reader on SONY XYZ

instead of

 SONY XYZ camera
 SONY XYZ camera
 SONY XYZ camera

assuming "SONY XYZ camera" is the name of the mount.

Second, the quite horribly "adopt mount / foreign volume" API makes this
even harder. However, thanks to g_volume_get_activation_uri() added in
GIO 2.17, this is not needed anymore; implementations of

 g_mount_get_volumes()
 g_mount_get_volume_for_location()
 g_volume_get_mount().

can simply use the union monitor to return something sensible instead.
The way to do this is simply to traverse all volumes resp. mounts using
g_volume_get_activation_uri() resp. g_mount_get_root() to compute what
to return (for see the gvfs patch for client/gdaemonmount.c). Much
simpler and less bug-prone. 

So, we can simply deprecate g_volume_monitor_adopt_foreign_mount() and
fix up gvfs instead. 

Which leads to the next patch:

http://people.freedesktop.org/~david/gvfs-connected-servers/gvfs-connected-servers-r2042-20081005.patch

Here we

 - Add a new connected-server volume monitor; it uses the
   GProxyVolumeMonitor infrastructure added during 2.17; pretty simple
   and straightforward.

 - Provide a commandline tool gvfs-connected-server(1) to add / remove /
   modify connected servers. Just for convenience.

 - Removes use of g_volume_monitor_adopt_foreign_mount() as described
   above.

 - Fixes the computer:/// backend to use the volume details if
   activation_root is not NULL

On the the Nautilus patch

http://people.freedesktop.org/~david/gvfs-connected-servers/nautilus-connected-servers-r14682-20081005.patch

 - Modifies NautilusDesktopLinkMonitor to monitor both volumes and
   mounts. This is needed because you want an icon per connected server
   even when they point to the same mount. You also want to display
   icons for connected servers that are not yet mounted. And you still
   need to watch mounts for transient network mounts (e.g. an sftp://
   mount not backed by a Connected Server GVolume).
  
 - New preference /apps/nautilus/desktop/connected_servers_visible that
   defaults to TRUE and does what you'd expect: it toggles whether
   connected servers are shown on the desktop.

 - Fixes up the side bar to use the volume details if activation_root is
   not NULL

We also have to teach GTK+'s file chooser the trick to use the volume
details if activation_root is not NULL. 

http://people.freedesktop.org/~david/gvfs-connected-servers/gtk+-connected-servers-20081005.patch

Note that this patch, on purpose, does not use new API. Since there's
not going to be a new GTK+ release for GNOME 2.26 [1] this patch should
go into the stable GTK+ 2.18 series. This is fine to do because gvfs/gio
without these patches are never going to have multiple GVolumes pointing
to the same GMount. It will work just fine with GIO 2.18 and GVFS 2.24.

Here's what still needs fixing / thinking

 - Need to mount when dragging to a desktop icon for an unmounted
   connected server; see

     http://people.freedesktop.org/~david/gvfs-connected-servers/nautilus-gvfs-connected-servers.png

   for details (this also sorta showcases what these patches do). This
   shouldn't be hard.

 - UI integration bits; such as

   - Fix the "Connect to server" dialog to write to GConf instead of
     gtk+ bookmarks
   - Properties page for editing name, icon, uri etc. of connected
     servers
   - Some nice shortcuts to create a new connected-server from an
     existing connection.

   Not hard, but I want to get the basics done / feedback before looking
   at this.

 - We could add the following options

    - "[x] connect at startup" option; right now we attempt to automount
      on startup which is probably wrong. Maybe just never automount and
      rely on Nautilus / file chooser mounting it as needed.

    - per-connected-server thumbnailing preferences; might be useful but
      may be just me smoking crack. I don't know.

   or maybe not. I don't know.

 - Fix up other users of GIO to use volume details if the volume
   activation root is not NULL. The only user I can think of is the
   panel.

Thanks for your thoughts on this.

      David

[1] : it's bloody annoying that GTK+ isn't on the same schedule as
GNOME.. but that's for another rant.




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