[gvfs/wip/oholy/runtime-dir-socket: 22/23] client: Show warning when peer-to-peer connection failed




commit 80a1bb434eddc649772bd0d38f23bfa5ff884520
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Sep 25 16:00:49 2020 +0200

    client: Show warning when peer-to-peer connection failed
    
    When peer-to-peer connection fails, the session bus is silently used
    instead by the asynchronous API. Let's add warnings to make it more
    obvious and mention that --filesystem=xdg-run/gvfsd is probably
    missing.

 client/gdaemonfile.c        | 13 ++++++++++---
 client/gdaemonfilemonitor.c |  5 +++--
 client/gdaemonmount.c       |  6 ++++--
 client/gvfsiconloadable.c   | 11 ++++++++++-
 4 files changed, 27 insertions(+), 8 deletions(-)
---
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c
index f11cf91c..9d03afd9 100644
--- a/client/gdaemonfile.c
+++ b/client/gdaemonfile.c
@@ -439,7 +439,12 @@ create_proxy_for_file2 (GFile *file1,
 
   connection = _g_dbus_connection_get_sync (mount_info1->dbus_id, cancellable, &local_error);
   if (connection == NULL)
-    goto out;
+    {
+      g_warning ("The peer-to-peer connection failed: %s. Your application is "
+                 "probably missing --filesystem=xdg-run/gvfsd privileges.",
+                 local_error->message);
+      goto out;
+    }
 
   proxy = gvfs_dbus_mount_proxy_new_sync (connection,
                                           G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | 
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
@@ -613,8 +618,10 @@ async_got_connection_cb (GDBusConnection *connection,
   
   if (connection == NULL)
     {
-      /* TODO: we should probably test if we really want a session bus;
-       *       for now, this code is on par with the old dbus code */ 
+      g_warning ("The peer-to-peer connection failed: %s. Falling back to the "
+                 "session bus. Your application is probably missing "
+                 "--filesystem=xdg-run/gvfsd privileges.", io_error->message);
+
       g_bus_get (G_BUS_TYPE_SESSION,
                  g_task_get_cancellable (data->task),
                  bus_get_cb,
diff --git a/client/gdaemonfilemonitor.c b/client/gdaemonfilemonitor.c
index 2d9f958f..17dd75d9 100644
--- a/client/gdaemonfilemonitor.c
+++ b/client/gdaemonfilemonitor.c
@@ -180,8 +180,9 @@ g_daemon_file_monitor_new (const char *remote_id,
   connection = _g_dbus_connection_get_sync (daemon_monitor->remote_id, NULL, &error);
   if (connection == NULL)
     {
-      g_printerr ("Error getting connection for monitoring: %s (%s, %d)\n",
-                  error->message, g_quark_to_string (error->domain), error->code);
+      g_warning ("The peer-to-peer connection failed: %s. Your application is "
+                 "probably missing --filesystem=xdg-run/gvfsd privileges.",
+                 error->message);
       g_error_free (error);
     }
   else
diff --git a/client/gdaemonmount.c b/client/gdaemonmount.c
index d49fad89..41277cb6 100644
--- a/client/gdaemonmount.c
+++ b/client/gdaemonmount.c
@@ -315,8 +315,10 @@ async_got_connection_cb (GDBusConnection *connection,
 
   if (connection == NULL)
     {
-      /* TODO: we should probably test if we really want a session bus;
-       *       for now, this code is on par with the old dbus code */ 
+      g_warning ("The peer-to-peer connection failed: %s. Falling back to the "
+                 "session bus. Your application is probably missing "
+                 "--filesystem=xdg-run/gvfsd privileges.", io_error->message);
+
       g_bus_get (G_BUS_TYPE_SESSION,
                  g_task_get_cancellable (task),
                  bus_get_cb,
diff --git a/client/gvfsiconloadable.c b/client/gvfsiconloadable.c
index 5050cfbe..2c001210 100644
--- a/client/gvfsiconloadable.c
+++ b/client/gvfsiconloadable.c
@@ -59,7 +59,12 @@ create_proxy_for_icon (GVfsIcon *vfs_icon,
 
   connection = _g_dbus_connection_get_sync (mount_info->dbus_id, cancellable, &local_error);
   if (connection == NULL)
-    goto out;
+    {
+      g_warning ("The peer-to-peer connection failed: %s. Your application is "
+                 "probably missing --filesystem=xdg-run/gvfsd privileges.",
+                 local_error->message);
+      goto out;
+    }
 
   proxy = gvfs_dbus_mount_proxy_new_sync (connection,
                                           G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | 
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
@@ -242,6 +247,10 @@ async_got_connection_cb (GDBusConnection *connection,
 
   if (connection == NULL)
     {
+      g_warning ("The peer-to-peer connection failed: %s. Falling back to the "
+                 "session bus. Your application is probably missing "
+                 "--filesystem=xdg-run/gvfsd privileges.", io_error->message);
+
       g_bus_get (G_BUS_TYPE_SESSION,
                  g_task_get_cancellable (data->task),
                  bus_get_cb,


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