[gvfs/wip/oholy/runtime-dir-socket: 23/23] client: Add fallback to session bus also for synchronous API
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/wip/oholy/runtime-dir-socket: 23/23] client: Add fallback to session bus also for synchronous API
- Date: Tue, 8 Dec 2020 11:32:25 +0000 (UTC)
commit 39cf4dac0a93ef05cb37bcd027139ccd3de3ea6c
Author: Ondrej Holy <oholy redhat com>
Date: Fri Sep 25 16:12:18 2020 +0200
client: Add fallback to session bus also for synchronous API
Asynchronous API fallbacks to session bus when peer-to-peer connection
fails, however, synchronous API fails in the same case. Let's add
fallback to session bus also for the synchronous case.
client/gdaemonfile.c | 13 +++++++++----
client/gdaemonfilemonitor.c | 15 ++++++++++++---
client/gvfsiconloadable.c | 13 +++++++++----
3 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c
index 9d03afd9..76686aff 100644
--- a/client/gdaemonfile.c
+++ b/client/gdaemonfile.c
@@ -440,12 +440,17 @@ create_proxy_for_file2 (GFile *file1,
connection = _g_dbus_connection_get_sync (mount_info1->dbus_id, cancellable, &local_error);
if (connection == NULL)
{
- g_warning ("The peer-to-peer connection failed: %s. Your application is "
- "probably missing --filesystem=xdg-run/gvfsd privileges.",
- local_error->message);
- goto out;
+ 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.", local_error->message);
+ g_clear_error (&local_error);
+
+ connection = g_bus_get_sync (G_BUS_TYPE_SESSION, cancellable, &local_error);
}
+ if (connection == NULL)
+ 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,
mount_info1->dbus_id,
diff --git a/client/gdaemonfilemonitor.c b/client/gdaemonfilemonitor.c
index 17dd75d9..1dadd617 100644
--- a/client/gdaemonfilemonitor.c
+++ b/client/gdaemonfilemonitor.c
@@ -180,9 +180,18 @@ 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_warning ("The peer-to-peer connection failed: %s. Your application is "
- "probably missing --filesystem=xdg-run/gvfsd privileges.",
- error->message);
+ 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.", error->message);
+ g_clear_error (&error);
+
+ connection = g_bus_get_sync (G_BUS_TYPE_SESSION, 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_error_free (error);
}
else
diff --git a/client/gvfsiconloadable.c b/client/gvfsiconloadable.c
index 2c001210..a10a2fe9 100644
--- a/client/gvfsiconloadable.c
+++ b/client/gvfsiconloadable.c
@@ -60,12 +60,17 @@ create_proxy_for_icon (GVfsIcon *vfs_icon,
connection = _g_dbus_connection_get_sync (mount_info->dbus_id, cancellable, &local_error);
if (connection == NULL)
{
- g_warning ("The peer-to-peer connection failed: %s. Your application is "
- "probably missing --filesystem=xdg-run/gvfsd privileges.",
- local_error->message);
- goto out;
+ 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.", local_error->message);
+ g_clear_error (&local_error);
+
+ connection = g_bus_get_sync (G_BUS_TYPE_SESSION, cancellable, &local_error);
}
+ if (connection == NULL)
+ 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,
mount_info->dbus_id,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]