[gvfs/gdbus-core: 19/38] gdbus: Treat empty non-NULL strings for the "ay" type as NULL



commit ccf1eb9be026e95f25cecb8581a21ccddd4fca88
Author: Tomas Bzatek <tbzatek redhat com>
Date:   Fri Jun 8 18:21:03 2012 +0200

    gdbus: Treat empty non-NULL strings for the "ay" type as NULL
    
    A fallout of port away from convenient G_DBUS_TYPE_CSTRING type and
    _g_dbus_message_append_args() + _g_dbus_message_iter_get_args() functions
    that masked NULL strings as non-NULL empty strings ("") for transferring
    over d-bus and on the other side reconstructed the original value.
    
    Portions of other code treat non-NULL strings differently even if they
    were empty. This fixes e.g. opening http URLs via gvfs-open.

 client/gdaemonfile.c   |    6 +++---
 common/gmountspec.c    |    4 +++-
 common/gmounttracker.c |    5 +++++
 daemon/gvfsbackend.c   |    2 +-
 daemon/mount.c         |    2 +-
 5 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c
index f457f82..093e044 100644
--- a/client/gdaemonfile.c
+++ b/client/gdaemonfile.c
@@ -2334,7 +2334,7 @@ g_daemon_file_set_display_name (GFile *file,
 
   res = gvfs_dbus_mount_call_set_display_name_sync (proxy,
                                                     path,
-                                                    display_name,
+                                                    display_name ? display_name : "",
                                                     &new_path,
                                                     cancellable,
                                                     error);
@@ -2454,7 +2454,7 @@ g_daemon_file_make_symbolic_link (GFile *file,
 
   res = gvfs_dbus_mount_call_make_symbolic_link_sync (proxy,
                                                       path,
-                                                      symlink_value,
+                                                      symlink_value ? symlink_value : "",
                                                       cancellable,
                                                       error);
   g_print ("g_daemon_file_make_symbolic_link: done, res = %d\n", res);
@@ -3523,7 +3523,7 @@ set_display_name_async_get_proxy_cb (GVfsDBusMount *proxy,
   
   gvfs_dbus_mount_call_set_display_name (proxy,
                                          path,
-                                         data->display_name,
+                                         data->display_name ? data->display_name : "",
                                          cancellable,
                                          (GAsyncReadyCallback) set_display_name_async_cb,
                                          data);
diff --git a/common/gmountspec.c b/common/gmountspec.c
index eadf4a1..60c93d3 100644
--- a/common/gmountspec.c
+++ b/common/gmountspec.c
@@ -240,7 +240,9 @@ g_mount_spec_from_dbus (GVariant *iter)
   
   spec = g_mount_spec_new (NULL);
   g_free (spec->mount_prefix);
-  spec->mount_prefix = g_strdup (mount_prefix);
+  spec->mount_prefix = NULL;
+  if (mount_prefix && mount_prefix[0])
+    spec->mount_prefix = g_strdup (mount_prefix);
 
   while (g_variant_iter_loop (iter_mount_spec_items, "{&sv}", &key, &value))
     {
diff --git a/common/gmounttracker.c b/common/gmounttracker.c
index abfce02..b4b6264 100644
--- a/common/gmounttracker.c
+++ b/common/gmounttracker.c
@@ -208,6 +208,11 @@ g_mount_info_from_dbus (GVariant *iter)
   if (mount_spec == NULL)
     return NULL;
 
+  if (fuse_mountpoint && fuse_mountpoint[0] == '\0')
+    fuse_mountpoint = NULL;
+  if (default_location && default_location[0] == '\0')
+    default_location = NULL;
+
   if (icon_str == NULL || strlen (icon_str) == 0)
     icon_str = "drive-removable-media";
   error = NULL;
diff --git a/daemon/gvfsbackend.c b/daemon/gvfsbackend.c
index c5fc36a..6a8cac9 100644
--- a/daemon/gvfsbackend.c
+++ b/daemon/gvfsbackend.c
@@ -685,7 +685,7 @@ register_mount_got_proxy_cb (GObject *source_object,
                                                backend->priv->prefered_filename_encoding,
                                                backend->priv->user_visible,
                                                g_mount_spec_to_dbus (backend->priv->mount_spec),
-                                               backend->priv->default_location,
+                                               backend->priv->default_location ? backend->priv->default_location : "",
                                                NULL,
                                                data->callback, data->callback_data);
 
diff --git a/daemon/mount.c b/daemon/mount.c
index 4d1c412..9b0cfb2 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -216,7 +216,7 @@ vfs_mount_to_dbus (VfsMount *mount)
                         mount->user_visible,
                         (fuse_available && mount->fuse_mountpoint) ? mount->fuse_mountpoint : "",
                         g_mount_spec_to_dbus (mount->mount_spec),
-                        mount->default_location);
+                        mount->default_location ? mount->default_location : "");
 }
 
 static GVariant *



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