[gnome-software/mwleeds/hardcoded-pwa-list: 14/14] epiphany: Rework setup d-bus stuff




commit 309c89cb3d6dd6942e2c196be119bdb9fea06c7a
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Fri Mar 25 09:55:57 2022 -0700

    epiphany: Rework setup d-bus stuff

 plugins/epiphany/gs-plugin-epiphany.c | 37 +++++++++++------------------------
 1 file changed, 11 insertions(+), 26 deletions(-)
---
diff --git a/plugins/epiphany/gs-plugin-epiphany.c b/plugins/epiphany/gs-plugin-epiphany.c
index 14aab23d0..fb42e2c55 100644
--- a/plugins/epiphany/gs-plugin-epiphany.c
+++ b/plugins/epiphany/gs-plugin-epiphany.c
@@ -179,7 +179,6 @@ setup_thread_cb (GTask        *task,
        GsPluginEpiphany *self = GS_PLUGIN_EPIPHANY (source_object);
        g_autofree gchar *name_owner = NULL;
        g_autoptr(GError) local_error = NULL;
-       g_autoptr(GDBusProxy) portal_proxy = NULL;
        g_autoptr(GVariant) version = NULL;
        g_autoptr(GVariant) version_child = NULL;
        g_autoptr(GVariant) version_grandchild = NULL;
@@ -215,7 +214,6 @@ setup_thread_cb (GTask        *task,
        }
 
        name_owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (self->epiphany_proxy));
-
        if (name_owner == NULL) {
                g_task_return_new_error (task, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_NOT_SUPPORTED,
                                         "Couldn’t create Epiphany WebAppProvider proxy: couldn’t get name 
owner");
@@ -223,21 +221,21 @@ setup_thread_cb (GTask        *task,
        }
 
        /* Check if the dynamic launcher portal is available and disable otherwise */
-       portal_proxy = g_dbus_proxy_new_sync (self->connection, G_DBUS_PROXY_FLAGS_NONE, NULL,
-                                             "org.freedesktop.portal.Desktop",
-                                             "/org/freedesktop/portal/desktop",
-                                             "org.freedesktop.DBus.Properties",
-                                             g_task_get_cancellable (task),
-                                             &local_error);
-       if (portal_proxy == NULL) {
+       self->launcher_portal_proxy = g_dbus_proxy_new_sync (self->connection,
+                                                            G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
+                                                            NULL,
+                                                            "org.freedesktop.portal.Desktop",
+                                                            "/org/freedesktop/portal/desktop",
+                                                            "org.freedesktop.portal.DynamicLauncher",
+                                                            g_task_get_cancellable (task),
+                                                            &local_error);
+       if (self->launcher_portal_proxy == NULL) {
                gs_epiphany_error_convert (&local_error);
                g_task_return_error (task, g_steal_pointer (&local_error));
                return;
        }
-       version = g_dbus_proxy_call_sync (portal_proxy, "Get",
-                                         g_variant_new ("(ss)", "org.freedesktop.portal.DynamicLauncher", 
"version"),
-                                         G_DBUS_CALL_FLAGS_NONE,
-                                         -1, NULL, NULL);
+
+       version = g_dbus_proxy_get_cached_property (self->launcher_portal_proxy, "version");
        if (version == NULL) {
                g_task_return_new_error (task, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_NOT_SUPPORTED,
                                         "Dynamic launcher portal not available");
@@ -249,19 +247,6 @@ setup_thread_cb (GTask        *task,
                         g_variant_get_uint32 (version_grandchild));
        }
 
-       /* And make a proxy object for the dynamic launcher portal */
-       self->launcher_portal_proxy = g_dbus_proxy_new_sync (self->connection, G_DBUS_PROXY_FLAGS_NONE, NULL,
-                                                            "org.freedesktop.portal.Desktop",
-                                                            "/org/freedesktop/portal/desktop",
-                                                            "org.freedesktop.portal.DynamicLauncher",
-                                                            g_task_get_cancellable (task),
-                                                            &local_error);
-       if (self->launcher_portal_proxy == NULL) {
-               gs_epiphany_error_convert (&local_error);
-               g_task_return_error (task, g_steal_pointer (&local_error));
-               return;
-       }
-
        g_task_return_boolean (task, TRUE);
 }
 


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