[gvfs] afp: mount volumes as the user who is logged in in the afpbrowse backend



commit 86c934c0c06ce9b23baa580354a674bc39ae1443
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date:   Sun Aug 7 17:20:37 2011 +0200

    afp: mount volumes as the user who is logged in in the afpbrowse backend
    
    this way you don't have to write your user credentials twice if you're first
    browsing a server and then mounting one of it's volumes.

 daemon/gvfsafpserver.c        |   10 +++++++++-
 daemon/gvfsbackendafpbrowse.c |   10 ++++++++--
 2 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/daemon/gvfsafpserver.c b/daemon/gvfsafpserver.c
index cf1c431..a14f2e7 100644
--- a/daemon/gvfsafpserver.c
+++ b/daemon/gvfsafpserver.c
@@ -937,6 +937,9 @@ g_vfs_afp_server_login (GVfsAfpServer *afp_serv,
       res = FALSE;
       break;
     }
+    
+    if (!user)
+      user = g_strdup (olduser);
 
 try_login:
 
@@ -990,7 +993,12 @@ try_login:
   }
 
   if (logged_in_user)
-    *logged_in_user = user;
+  {
+    if (anonymous)
+      *logged_in_user = g_strdup ("anonymous");
+    else
+      *logged_in_user = user;
+  }
   else
     g_free (user);
   
diff --git a/daemon/gvfsbackendafpbrowse.c b/daemon/gvfsbackendafpbrowse.c
index 5b8b80d..4b5c5db 100644
--- a/daemon/gvfsbackendafpbrowse.c
+++ b/daemon/gvfsbackendafpbrowse.c
@@ -57,7 +57,8 @@ struct _GVfsBackendAfpBrowse
   GMountTracker      *mount_tracker;
   GVfsAfpServer      *server;
 
-  GSList *volumes;
+  char               *logged_in_user;
+  GSList             *volumes;
 };
 
 
@@ -251,6 +252,7 @@ mount_mountable_cb (GVfsBackendAfpBrowse *afp_backend,
   g_mount_spec_set (mount_spec, "host",
                     g_network_address_get_hostname (G_NETWORK_ADDRESS (afp_backend->addr)));
   g_mount_spec_set (mount_spec, "volume", vol_data->name);
+  g_mount_spec_set (mount_spec, "user", afp_backend->logged_in_user);
 
   g_vfs_job_mount_mountable_set_target (job, mount_spec, "/", TRUE);
   g_mount_spec_unref (mount_spec);
@@ -304,6 +306,7 @@ fill_info (GFileInfo *info, VolumeData *vol_data, GVfsBackendAfpBrowse *afp_back
   g_mount_spec_set (mount_spec, "host",
                     g_network_address_get_hostname (G_NETWORK_ADDRESS (afp_backend->addr)));
   g_mount_spec_set (mount_spec, "volume", vol_data->name);
+  g_mount_spec_set (mount_spec, "user", afp_backend->logged_in_user);
 
   if (g_mount_tracker_has_mount_spec (afp_backend->mount_tracker, mount_spec))
   {
@@ -455,7 +458,8 @@ do_mount (GVfsBackend *backend,
   afp_backend->server = g_vfs_afp_server_new (afp_backend->addr);
 
   res = g_vfs_afp_server_login (afp_backend->server, afp_backend->user, mount_source,
-                                NULL, G_VFS_JOB (job)->cancellable, &err);
+                                &afp_backend->logged_in_user,
+                                G_VFS_JOB (job)->cancellable, &err);
   if (!res)
     goto error;
   
@@ -539,6 +543,7 @@ g_vfs_backend_afp_browse_init (GVfsBackendAfpBrowse *object)
   afp_backend->addr = NULL;
   afp_backend->user = NULL;
 
+  afp_backend->logged_in_user = NULL;
   afp_backend->volumes = NULL;
 }
 
@@ -554,6 +559,7 @@ g_vfs_backend_afp_browse_finalize (GObject *object)
   
   g_free (afp_backend->user);
 
+  g_free (afp_backend->logged_in_user);
   g_slist_free_full (afp_backend->volumes, (GDestroyNotify)volume_data_free);
 
   G_OBJECT_CLASS (g_vfs_backend_afp_browse_parent_class)->finalize (object);



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