gvfs r1508 - in trunk: . client common daemon



Author: alexl
Date: Mon Mar  3 15:52:43 2008
New Revision: 1508
URL: http://svn.gnome.org/viewvc/gvfs?rev=1508&view=rev

Log:
2008-03-03  Alexander Larsson  <alexl redhat com>

        * common/gdbusutils.[ch]:
        Add _g_dbus_message_iter_append_args_valist and
        _g_dbus_message_iter_append_args.

        * common/gvfsdaemonprotocol.h:
	Add G_VFS_DBUS_MOUNTTRACKER_OP_LIST_MOUNTABLE_INFO
	
        * client/Makefile.am:
        * client/gdaemonvfs.c:
	Use listMountableInfo to get supported uri schemes
	and information for default uri handling.
	Handle default port in uris and if host_is_inet normalize hostnames,
	including removing ipv6 brackets.
	
        * client/sftpuri.c:
	Removed, as the previous work replaces it
	
        * daemon/gvfsdaemonutils.c:
        (gvfs_file_info_populate_content_types):
	Fix uninitialized variable warning.
	
        * daemon/mount.c:
	Read new mountfile info and implement
	list_mountable_info.
	
        * daemon/sftp.mount.in:
	Add info for sftp



Removed:
   trunk/client/sftpuri.c
Modified:
   trunk/ChangeLog
   trunk/client/Makefile.am
   trunk/client/gdaemonvfs.c
   trunk/common/gdbusutils.c
   trunk/common/gdbusutils.h
   trunk/common/gvfsdaemonprotocol.h
   trunk/daemon/gvfsdaemonutils.c
   trunk/daemon/mount.c
   trunk/daemon/sftp.mount.in

Modified: trunk/client/Makefile.am
==============================================================================
--- trunk/client/Makefile.am	(original)
+++ trunk/client/Makefile.am	Mon Mar  3 15:52:43 2008
@@ -20,7 +20,6 @@
 	$(NULL)
 
 URI_PARSER_SOURCES = \
-	sftpuri.c \
 	smburi.c \
 	httpuri.c \
 	$(NULL)

Modified: trunk/client/gdaemonvfs.c
==============================================================================
--- trunk/client/gdaemonvfs.c	(original)
+++ trunk/client/gdaemonvfs.c	Mon Mar  3 15:52:43 2008
@@ -38,6 +38,13 @@
 #include "gdaemonvolumemonitor.h"
 #include <glib/gi18n-lib.h>
 
+typedef struct  {
+  char *type;
+  char *scheme;
+  char **scheme_aliases;
+  int default_port;
+  gboolean host_is_inet;
+} MountableInfo; 
 
 struct _GDaemonVfs
 {
@@ -51,7 +58,8 @@
   GHashTable *from_uri_hash;
   GHashTable *to_uri_hash;
 
-  gchar **supported_uri_schemes;
+  MountableInfo **mountable_info;
+  char **supported_uri_schemes;
 };
 
 struct _GDaemonVfsClass
@@ -66,6 +74,8 @@
 G_LOCK_DEFINE_STATIC(mount_cache);
 
 
+static void fill_mountable_info (GDaemonVfs *vfs);
+
 static void
 g_daemon_vfs_finalize (GObject *object)
 {
@@ -94,6 +104,58 @@
   G_OBJECT_CLASS (g_daemon_vfs_parent_class)->finalize (object);
 }
 
+static MountableInfo *
+get_mountable_info_for_scheme (GDaemonVfs *vfs,
+			       const char *scheme)
+{
+  MountableInfo *info;
+  int i, j;
+
+  if (vfs->mountable_info == NULL)
+    return NULL;
+
+  for (i = 0; vfs->mountable_info[i] != NULL; i++)
+    {
+      info = vfs->mountable_info[i];
+      
+      if (info->scheme != NULL && strcmp (info->scheme, scheme) == 0)
+	return info;
+
+      if (info->scheme_aliases != NULL)
+	{
+	  for (j = 0; info->scheme_aliases[j] != NULL; j++)
+	    {
+	      if (strcmp (info->scheme_aliases[j], scheme) == 0)
+		return info;
+	    }
+	}
+      
+    }
+  
+  return NULL;
+}
+
+static MountableInfo *
+get_mountable_info_for_type (GDaemonVfs *vfs,
+			     const char *type)
+{
+  MountableInfo *info;
+  int i;
+  
+  if (vfs->mountable_info == NULL)
+    return NULL;
+  
+  for (i = 0; vfs->mountable_info[i] != NULL; i++)
+    {
+      info = vfs->mountable_info[i];
+      
+      if (strcmp (info->type, type) == 0)
+	return info;
+    }
+  
+  return NULL;
+}
+
 static gboolean
 get_mountspec_from_uri (GDaemonVfs *vfs,
 			const char *uri,
@@ -130,19 +192,49 @@
   if (spec == NULL)
     {
       GDecodedUri *decoded;
-      
+      MountableInfo *mountable;
+      char *type, *p;
+      int l;
+
       decoded = g_vfs_decode_uri (uri);
       if (decoded)
-	{
-	  spec = g_mount_spec_new (decoded->scheme);
+	{	
+	  mountable = get_mountable_info_for_scheme (vfs, decoded->scheme);
+      
+	  if (mountable)
+	    type = mountable->type;
+	  else
+	    type = decoded->scheme;
+	  
+	  spec = g_mount_spec_new (type);
 	  
 	  if (decoded->host && *decoded->host)
-	    g_mount_spec_set (spec, "host", decoded->host);
+	    {
+	      if (mountable && mountable->host_is_inet)
+		{
+		  /* Convert hostname to lower case */
+		  for (p = decoded->host; *p != 0; p++)
+		    *p = g_ascii_tolower (*p);
+		  
+		  /* Remove brackets aroung ipv6 addresses */
+		  l = strlen (decoded->host);
+		  if (decoded->host[0] == '[' &&
+		      decoded->host[l - 1] == ']')
+		    g_mount_spec_set_with_len (spec, "host", decoded->host+1, l - 2);
+		  else
+		    g_mount_spec_set (spec, "host", decoded->host);
+		}
+	      else
+		g_mount_spec_set (spec, "host", decoded->host);
+	    }
 	  
 	  if (decoded->userinfo && *decoded->userinfo)
 	    g_mount_spec_set (spec, "user", decoded->userinfo);
 	  
-	  if (decoded->port != -1)
+	  if (decoded->port != -1 &&
+	      (mountable == NULL ||
+	       mountable->default_port == 0 ||
+	       mountable->default_port != decoded->port))
 	    {
 	      char *port = g_strdup_printf ("%d", decoded->port);
 	      g_mount_spec_set (spec, "port", port);
@@ -150,7 +242,7 @@
 	    }
 	  
 	  path = g_strdup (decoded->path);
-
+	  
 	  g_vfs_decoded_uri_free (decoded);
 	}
     }
@@ -201,6 +293,8 @@
      even for somewhat modern ones like solaris.
   */
   signal (SIGPIPE, SIG_IGN);
+
+  fill_mountable_info (vfs);
   
   vfs->wrapped_vfs = g_vfs_get_local ();
 
@@ -357,24 +451,41 @@
   if (uri == NULL)
     {
       GDecodedUri decoded;
+      MountableInfo *mountable;
       const char *port;
+      gboolean free_host;
 
       memset (&decoded, 0, sizeof (decoded));
       decoded.port = -1;
-      
-      decoded.scheme = (char *)type;
+
+      mountable = get_mountable_info_for_type (the_vfs, type);
+
+      if (mountable)
+	decoded.scheme = mountable->scheme;
+      else
+	decoded.scheme = (char *)type;
       decoded.host = (char *)g_mount_spec_get (spec, "host");
+      free_host = FALSE;
+      if (mountable && mountable->host_is_inet && strchr (decoded.host, ':') != NULL)
+	{
+	  free_host = TRUE;
+	  decoded.host = g_strconcat ("[", decoded.host, "]", NULL);
+	}
+      
       decoded.userinfo = (char *)g_mount_spec_get (spec, "user");
       port = g_mount_spec_get (spec, "port");
       if (port != NULL)
 	decoded.port = atoi (port);
-
+      
       if (path == NULL)
 	decoded.path = "/";
       else
 	decoded.path = path;
       
       uri = g_vfs_encode_uri (&decoded, FALSE);
+      
+      if (free_host)
+	g_free (decoded.host);
     }
   
   return uri;
@@ -385,6 +496,7 @@
 {
   const char *type, *scheme;
   GVfsUriMapper *mapper;
+  MountableInfo *mountable;
 
   type = g_mount_spec_get_type (spec);
   mapper = g_hash_table_lookup (the_vfs->to_uri_hash, type);
@@ -401,28 +513,31 @@
     }
   
   if (scheme == NULL)
-    scheme = type;
+    {
+      mountable = get_mountable_info_for_type (the_vfs, type);
+      if (mountable)
+	scheme = mountable->scheme;
+      else
+	scheme = type;
+    }
   
   return scheme;
 }
 
 static void
-fill_supported_uri_schemes (GDaemonVfs *vfs)
+fill_mountable_info (GDaemonVfs *vfs)
 {
-  DBusConnection *connection;
   DBusMessage *message, *reply;
   DBusError error;
-  DBusMessageIter iter, array_iter;
+  DBusMessageIter iter, array_iter, struct_iter;
+  MountableInfo *info;
+  GPtrArray *infos, *uri_schemes;
   gint i, count;
-  GList *l, *list = NULL;
-
-  connection = dbus_bus_get (DBUS_BUS_SESSION, NULL);
 
-  
   message = dbus_message_new_method_call (G_VFS_DBUS_DAEMON_NAME,
                                           G_VFS_DBUS_MOUNTTRACKER_PATH,
 					  G_VFS_DBUS_MOUNTTRACKER_INTERFACE,
-					  G_VFS_DBUS_MOUNTTRACKER_OP_LIST_MOUNT_TYPES);
+					  G_VFS_DBUS_MOUNTTRACKER_OP_LIST_MOUNTABLE_INFO);
 
   if (message == NULL)
     _g_dbus_oom ();
@@ -430,96 +545,85 @@
   dbus_message_set_auto_start (message, TRUE);
   
   dbus_error_init (&error);
-  reply = dbus_connection_send_with_reply_and_block (connection,
+  reply = dbus_connection_send_with_reply_and_block (vfs->async_bus,
                                                      message,
 						     G_VFS_DBUS_TIMEOUT_MSECS,
 						     &error);
   dbus_message_unref (message);
-
+  
   if (dbus_error_is_set (&error))
     {
       dbus_error_free (&error);
-      dbus_connection_unref (connection);
       return;
     }
-
+  
   if (reply == NULL)
     _g_dbus_oom ();
 
   dbus_message_iter_init (reply, &iter);
-  g_assert (dbus_message_iter_get_element_type (&iter) == DBUS_TYPE_STRING);
 
   dbus_message_iter_recurse (&iter, &array_iter);
-  
+
+  infos = g_ptr_array_new ();
+  uri_schemes = g_ptr_array_new ();
   count = 0;
   do
     {
-      gchar *type;
-      const char *scheme = NULL;
-      GVfsUriMapper *mapper = NULL;
-      GMountSpec *spec;
-      gboolean new = TRUE;
-
-      dbus_message_iter_get_basic (&array_iter, &type);
-
-      spec = g_mount_spec_new (type);
-
-      mapper = g_hash_table_lookup (vfs->to_uri_hash, type);
-    
-      if (mapper)
+      char *type, *scheme, **scheme_aliases;
+      int scheme_aliases_len;
+      gint32 default_port;
+      dbus_bool_t host_is_inet;
+      
+      if (dbus_message_iter_get_arg_type (&array_iter) != DBUS_TYPE_STRUCT)
+	break;
+      
+      dbus_message_iter_recurse (&array_iter, &struct_iter);
+      
+      if (!_g_dbus_message_iter_get_args (&struct_iter, NULL,
+					  DBUS_TYPE_STRING, &type,
+					  DBUS_TYPE_STRING, &scheme,
+					  DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &scheme_aliases, &scheme_aliases_len,
+					  DBUS_TYPE_INT32, &default_port,
+					  DBUS_TYPE_BOOLEAN, &host_is_inet,
+					  0))
+	break;
+
+      info = g_new0 (MountableInfo, 1);
+      info->type = g_strdup (type);
+      if (*scheme != 0)
 	{
-	  GVfsUriMountInfo info;
-	  
-	  info.keys = spec->items;
-	  info.path = "/";
-	  
-	  scheme = g_vfs_uri_mapper_to_uri_scheme (mapper, &info);
+	  info->scheme = g_strdup (scheme);
+	  g_ptr_array_add (uri_schemes, g_strdup (scheme));
 	}
+      
+      info->scheme_aliases = g_new (char *, scheme_aliases_len);
+      for (i = 0; i < scheme_aliases_len; i++)
+	{
+	  info->scheme_aliases[i] = g_strdup (scheme_aliases[i]);
+	  g_ptr_array_add (uri_schemes, g_strdup (scheme_aliases[i]));
+	}
+	
+      info->default_port = default_port;
+      info->host_is_inet = host_is_inet;
+      
+      g_ptr_array_add (infos, info);
 
-      if (scheme == NULL)
-        scheme = type;
-
-      for (l = list; l != NULL; l = l->next)
-        {
-          if (strcmp (l->data, scheme) == 0)
-            {
-              new = FALSE;
-              break;
-            }
-        }
-
-      if (new)
-        {
-          list = g_list_prepend (list, g_strdup (scheme));
-          count++;
-        }
-
-      g_mount_spec_unref (spec);
+      dbus_free_string_array (scheme_aliases);
     }
   while (dbus_message_iter_next (&array_iter));
 
   dbus_message_unref (reply);
-  dbus_connection_unref (connection);
-
-  list = g_list_prepend (list, g_strdup ("file"));
-  list = g_list_sort (list, (GCompareFunc) strcmp);
-
-  vfs->supported_uri_schemes = g_new0 (gchar *, count + 2);
 
-  for (i = 0, l = list; l != NULL; l = l->next, i++)
-    vfs->supported_uri_schemes[i] = l->data;
-
-  g_list_free (list);
+  g_ptr_array_add (uri_schemes, NULL);
+  g_ptr_array_add (infos, NULL);
+  vfs->mountable_info = (MountableInfo **)g_ptr_array_free (infos, FALSE);
+  vfs->supported_uri_schemes = (char **)g_ptr_array_free (uri_schemes, FALSE);
 }
 
+
 static const gchar * const *
 g_daemon_vfs_get_supported_uri_schemes (GVfs *vfs)
 {
-  GDaemonVfs *daemon_vfs = G_DAEMON_VFS (vfs);
-
-  if (!daemon_vfs->supported_uri_schemes)
-    fill_supported_uri_schemes (daemon_vfs);
-    
   return (const gchar * const *) G_DAEMON_VFS (vfs)->supported_uri_schemes;
 }
 
@@ -833,7 +937,6 @@
   
   g_vfs_uri_mapper_register (module);
   g_vfs_uri_mapper_smb_register (module);
-  g_vfs_uri_mapper_sftp_register (module);
   g_vfs_uri_mapper_http_register (module);
 }
 

Modified: trunk/common/gdbusutils.c
==============================================================================
--- trunk/common/gdbusutils.c	(original)
+++ trunk/common/gdbusutils.c	Mon Mar  3 15:52:43 2008
@@ -240,19 +240,16 @@
 }
 
 void
-_g_dbus_message_append_args_valist (DBusMessage *message,
-				    int          first_arg_type,
-				    va_list      var_args)
+_g_dbus_message_iter_append_args_valist (DBusMessageIter *iter,
+					 int          first_arg_type,
+					 va_list      var_args)
 {
   int type;
-  DBusMessageIter iter;
 
-  g_return_if_fail (message != NULL);
+  g_return_if_fail (iter != NULL);
 
   type = first_arg_type;
 
-  dbus_message_iter_init_append (message, &iter);
-
   while (type != DBUS_TYPE_INVALID)
     {
       if (type == G_DBUS_TYPE_CSTRING)
@@ -263,14 +260,14 @@
 	  value_p = va_arg (var_args, const char**);
 	  value = *value_p;
 
-	  _g_dbus_message_iter_append_cstring (&iter, value);
+	  _g_dbus_message_iter_append_cstring (iter, value);
 	}
       else if (dbus_type_is_basic (type))
         {
           const void *value;
           value = va_arg (var_args, const void*);
 
-          if (!dbus_message_iter_append_basic (&iter,
+          if (!dbus_message_iter_append_basic (iter,
                                                type,
                                                value))
 	    _g_dbus_oom ();
@@ -285,7 +282,7 @@
               
           buf[0] = element_type;
           buf[1] = '\0';
-          if (!dbus_message_iter_open_container (&iter,
+          if (!dbus_message_iter_open_container (iter,
                                                  DBUS_TYPE_ARRAY,
                                                  buf,
                                                  &array))
@@ -335,7 +332,7 @@
 		       element_type);
             }
 
-          if (!dbus_message_iter_close_container (&iter, &array))
+          if (!dbus_message_iter_close_container (iter, &array))
 	    _g_dbus_oom ();
         }
 
@@ -343,6 +340,26 @@
     }
 }
 
+
+void
+_g_dbus_message_append_args_valist (DBusMessage *message,
+				    int          first_arg_type,
+				    va_list      var_args)
+{
+  int type;
+  DBusMessageIter iter;
+
+  g_return_if_fail (message != NULL);
+
+  type = first_arg_type;
+
+  dbus_message_iter_init_append (message, &iter);
+
+  _g_dbus_message_iter_append_args_valist (&iter,
+					   first_arg_type,
+					   var_args);
+}
+
 dbus_bool_t
 _g_dbus_message_iter_get_args_valist (DBusMessageIter *iter,
 				      DBusError       *error,
@@ -567,6 +584,21 @@
   va_end (var_args);
 }
 
+void
+_g_dbus_message_iter_append_args (DBusMessageIter *iter,
+				  int          first_arg_type,
+				  ...)
+{
+  va_list var_args;
+
+  g_return_if_fail (iter != NULL);
+
+  va_start (var_args, first_arg_type);
+  _g_dbus_message_iter_append_args_valist (iter,
+					   first_arg_type,
+					   var_args);
+  va_end (var_args);
+}
 
 void
 _g_error_from_dbus (DBusError *derror, 

Modified: trunk/common/gdbusutils.h
==============================================================================
--- trunk/common/gdbusutils.h	(original)
+++ trunk/common/gdbusutils.h	Mon Mar  3 15:52:43 2008
@@ -44,6 +44,12 @@
 						     DBusError        *error);
 void         _g_dbus_message_iter_append_cstring    (DBusMessageIter  *iter,
 						     const char       *str);
+void         _g_dbus_message_iter_append_args_valist (DBusMessageIter *iter,
+						     int               first_arg_type,
+						     va_list           var_args);
+void         _g_dbus_message_iter_append_args       (DBusMessageIter  *iter,
+						     int               first_arg_type,
+						     ...);
 void         _g_dbus_message_append_args_valist     (DBusMessage      *message,
 						     int               first_arg_type,
 						     va_list           var_args);

Modified: trunk/common/gvfsdaemonprotocol.h
==============================================================================
--- trunk/common/gvfsdaemonprotocol.h	(original)
+++ trunk/common/gvfsdaemonprotocol.h	Mon Mar  3 15:52:43 2008
@@ -17,6 +17,7 @@
 #define G_VFS_DBUS_MOUNTTRACKER_OP_REGISTER_MOUNT "registerMount"
 #define G_VFS_DBUS_MOUNTTRACKER_OP_UNREGISTER_MOUNT "unregisterMount"
 #define G_VFS_DBUS_MOUNTTRACKER_OP_LIST_MOUNT_TYPES "listMountTypes"
+#define G_VFS_DBUS_MOUNTTRACKER_OP_LIST_MOUNTABLE_INFO "listMountableInfo"
 #define G_VFS_DBUS_MOUNTTRACKER_OP_REGISTER_FUSE "registerFuse"
 #define G_VFS_DBUS_MOUNTTRACKER_SIGNAL_MOUNTED "mounted"
 #define G_VFS_DBUS_MOUNTTRACKER_SIGNAL_UNMOUNTED "unmounted"

Modified: trunk/daemon/gvfsdaemonutils.c
==============================================================================
--- trunk/daemon/gvfsdaemonutils.c	(original)
+++ trunk/daemon/gvfsdaemonutils.c	Mon Mar  3 15:52:43 2008
@@ -270,7 +270,8 @@
 
   g_file_info_set_content_type (info, mimetype);
   g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE, mimetype);
-      
+
+  icon = NULL;
   if (type == G_FILE_TYPE_DIRECTORY)
     icon = g_themed_icon_new ("folder");
   else if (mimetype)

Modified: trunk/daemon/mount.c
==============================================================================
--- trunk/daemon/mount.c	(original)
+++ trunk/daemon/mount.c	Mon Mar  3 15:52:43 2008
@@ -56,6 +56,10 @@
   char *exec;
   char *dbus_name;
   gboolean automount;
+  char *scheme;
+  char **scheme_aliases;
+  int default_port;
+  gboolean hostname_is_inet;
 } VfsMountable; 
 
 typedef void (*MountCallback) (VfsMountable *mountable,
@@ -143,6 +147,8 @@
   g_free (mountable->type);
   g_free (mountable->exec);
   g_free (mountable->dbus_name);
+  g_free (mountable->scheme);
+  g_strfreev (mountable->scheme_aliases);
   g_free (mountable);
 }
 
@@ -233,6 +239,60 @@
     _g_dbus_oom ();
 }
 
+static void
+vfs_mountable_to_dbus (VfsMountable *mountable,
+		       DBusMessageIter *iter)
+{
+  DBusMessageIter struct_iter;
+  dbus_bool_t bool;
+  guint32 int32;
+  char *s;
+  char **a;
+  char *empty[] = {NULL};
+  
+  if (!dbus_message_iter_open_container (iter,
+					 DBUS_TYPE_STRUCT,
+					 NULL,
+					 &struct_iter))
+    _g_dbus_oom ();
+
+  if (!dbus_message_iter_append_basic (&struct_iter,
+				       DBUS_TYPE_STRING,
+				       &mountable->type))
+    _g_dbus_oom ();
+  
+  s = mountable->scheme;
+  if (s == NULL)
+    s = "";
+  if (!dbus_message_iter_append_basic (&struct_iter,
+				       DBUS_TYPE_STRING,
+				       &s))
+    _g_dbus_oom ();
+
+  a = mountable->scheme_aliases;
+  if (a == NULL)
+    a = empty;
+  _g_dbus_message_iter_append_args (&struct_iter,
+				    DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &a, (int)g_strv_length (a),
+				    0);
+  
+  int32 = mountable->default_port;
+  if (!dbus_message_iter_append_basic (&struct_iter,
+				       DBUS_TYPE_INT32,
+				       &int32))
+    _g_dbus_oom ();
+  
+  bool = mountable->hostname_is_inet;
+  if (!dbus_message_iter_append_basic (&struct_iter,
+				       DBUS_TYPE_BOOLEAN,
+				       &bool))
+    _g_dbus_oom ();
+
+  if (!dbus_message_iter_close_container (iter, &struct_iter))
+    _g_dbus_oom ();
+}
+
+
 /************************************************************************
  * Support for mounting a VfsMountable                                  *
  ************************************************************************/
@@ -496,6 +556,14 @@
 			  mountable->exec = g_key_file_get_string (keyfile, "Mount", "Exec", NULL);
 			  mountable->dbus_name = g_key_file_get_string (keyfile, "Mount", "DBusName", NULL);
 			  mountable->automount = g_key_file_get_boolean (keyfile, "Mount", "AutoMount", NULL);
+			  mountable->scheme = g_key_file_get_string (keyfile, "Mount", "Scheme", NULL);
+			  mountable->scheme_aliases =
+			    g_key_file_get_string_list (keyfile, "Mount", "SchemeAliases", NULL, NULL);
+			  mountable->default_port = g_key_file_get_integer (keyfile, "Mount", "DefaultPort", NULL);
+			  mountable->hostname_is_inet = g_key_file_get_boolean (keyfile, "Mount", "HostnameIsInetAddress", NULL);
+
+			  if (mountable->scheme == NULL)
+			    mountable->scheme = g_strdup (mountable->type);
 			  
 			  mountables = g_list_prepend (mountables, mountable);
 			}
@@ -942,6 +1010,47 @@
   dbus_connection_send (connection, reply, NULL);
 }
 
+static void
+list_mountable_info (DBusConnection *connection,
+		     DBusMessage *message)
+{
+  VfsMountable *mountable;
+  DBusMessage *reply;
+  DBusMessageIter iter, array_iter;
+  GList *l;
+
+  reply = dbus_message_new_method_return (message);
+  if (reply == NULL)
+    _g_dbus_oom ();
+
+  dbus_message_iter_init_append (reply, &iter);
+
+  
+  if (!dbus_message_iter_open_container (&iter,
+					 DBUS_TYPE_ARRAY,
+					 DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+					   DBUS_TYPE_STRING_AS_STRING /* type */
+					   DBUS_TYPE_STRING_AS_STRING /* scheme */
+					   DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING /* scheme aliases */
+					   DBUS_TYPE_INT32_AS_STRING /* default port */
+					   DBUS_TYPE_BOOLEAN_AS_STRING /* host is inet */
+					 DBUS_STRUCT_END_CHAR_AS_STRING,
+					 &array_iter))
+    _g_dbus_oom ();
+
+  for (l = mountables; l != NULL; l = l->next)
+    {
+      mountable = l->data;
+      
+      vfs_mountable_to_dbus (mountable, &array_iter);
+    }
+
+  if (!dbus_message_iter_close_container (&iter, &array_iter))
+    _g_dbus_oom ();
+  
+  dbus_connection_send (connection, reply, NULL);
+}
+
 static DBusHandlerResult
 dbus_message_function (DBusConnection  *connection,
 		       DBusMessage     *message,
@@ -974,6 +1083,10 @@
   					G_VFS_DBUS_MOUNTTRACKER_INTERFACE,
 					G_VFS_DBUS_MOUNTTRACKER_OP_LIST_MOUNT_TYPES))
     list_mount_types (connection, message);
+  else if (dbus_message_is_method_call (message,
+  					G_VFS_DBUS_MOUNTTRACKER_INTERFACE,
+					G_VFS_DBUS_MOUNTTRACKER_OP_LIST_MOUNTABLE_INFO))
+    list_mountable_info (connection, message);
   else
     res = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
   

Modified: trunk/daemon/sftp.mount.in
==============================================================================
--- trunk/daemon/sftp.mount.in	(original)
+++ trunk/daemon/sftp.mount.in	Mon Mar  3 15:52:43 2008
@@ -2,3 +2,7 @@
 Type=sftp
 Exec= libexecdir@/gvfsd-sftp
 AutoMount=false
+Scheme=sftp
+SchemeAliases=ssh
+DefaultPort=22
+HostnameIsInetAddress=true



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