[gnome-software: 14/21] packagekit: Stop connecting to D-Bus manually
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 14/21] packagekit: Stop connecting to D-Bus manually
- Date: Wed, 27 Apr 2022 10:41:23 +0000 (UTC)
commit a37115878a38cb33eab4969fa90584dbf9a49c3e
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed Mar 30 16:02:04 2022 +0100
packagekit: Stop connecting to D-Bus manually
Instead use the D-Bus connection provided by `GsPlugin`.
This simplifies the code quite a bit.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1694
plugins/packagekit/gs-plugin-packagekit.c | 50 ++++---------------------------
1 file changed, 6 insertions(+), 44 deletions(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index 6ad23e988..e207cacba 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -21,6 +21,7 @@
#include "gs-markdown.h"
#include "gs-packagekit-helper.h"
#include "gs-packagekit-task.h"
+#include "gs-plugin-private.h"
#include "gs-plugin-packagekit.h"
@@ -59,8 +60,6 @@ struct _GsPluginPackagekit {
PkClient *client_refine;
GMutex client_mutex_refine;
- GDBusConnection *connection_history;
-
PkTask *task_local;
GMutex task_mutex_local;
@@ -234,9 +233,6 @@ gs_plugin_packagekit_dispose (GObject *object)
g_clear_object (&self->client_refine);
g_clear_object (&self->control_refine);
- /* history */
- g_clear_object (&self->connection_history);
-
/* local */
g_clear_object (&self->task_local);
@@ -2298,9 +2294,6 @@ gs_plugin_systemd_trigger_changed_cb (GFileMonitor *monitor,
gs_plugin_packagekit_refresh_is_triggered (self, NULL);
}
-static void setup_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data);
static void setup_proxy_settings_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data);
@@ -2314,31 +2307,12 @@ gs_plugin_packagekit_setup_async (GsPlugin *plugin,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ GsPluginPackagekit *self = GS_PLUGIN_PACKAGEKIT (plugin);
g_autoptr(GTask) task = NULL;
task = g_task_new (plugin, cancellable, callback, user_data);
g_task_set_source_tag (task, gs_plugin_packagekit_setup_async);
- g_bus_get (G_BUS_TYPE_SYSTEM, cancellable, setup_cb, g_steal_pointer (&task));
-}
-
-static void
-setup_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
-{
- g_autoptr(GTask) task = g_steal_pointer (&user_data);
- GsPluginPackagekit *self = g_task_get_source_object (task);
- GCancellable *cancellable = g_task_get_cancellable (task);
- g_autoptr(GError) local_error = NULL;
-
- self->connection_history = g_bus_get_finish (result, &local_error);
- if (self->connection_history == NULL) {
- gs_plugin_packagekit_error_convert (&local_error);
- g_task_return_error (task, g_steal_pointer (&local_error));
- return;
- }
-
reload_proxy_settings_async (self, cancellable, setup_proxy_settings_cb, g_steal_pointer (&task));
}
@@ -2476,7 +2450,7 @@ gs_plugin_packagekit_refine_history_async (GsPluginPackagekit *self,
}
g_debug ("getting history for %u packages", gs_app_list_length (list));
- g_dbus_connection_call (self->connection_history,
+ g_dbus_connection_call (gs_plugin_get_system_bus_connection (GS_PLUGIN (self)),
"org.freedesktop.PackageKit",
"/org/freedesktop/PackageKit",
"org.freedesktop.PackageKit",
@@ -3833,16 +3807,12 @@ gs_systemd_call_trigger (GsPlugin *plugin,
GError **error)
{
const gchar *tmp;
- g_autoptr(GDBusConnection) connection = NULL;
g_autoptr(GVariant) res = NULL;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, cancellable, error);
- if (connection == NULL)
- return FALSE;
tmp = pk_offline_action_to_string (action);
- res = g_dbus_connection_call_sync (connection,
+ res = g_dbus_connection_call_sync (gs_plugin_get_system_bus_connection (plugin),
"org.freedesktop.PackageKit",
"/org/freedesktop/PackageKit",
"org.freedesktop.PackageKit.Offline",
@@ -3863,15 +3833,11 @@ gs_systemd_call_cancel (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
- g_autoptr(GDBusConnection) connection = NULL;
g_autoptr(GVariant) res = NULL;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, cancellable, error);
- if (connection == NULL)
- return FALSE;
- res = g_dbus_connection_call_sync (connection,
+ res = g_dbus_connection_call_sync (gs_plugin_get_system_bus_connection (plugin),
"org.freedesktop.PackageKit",
"/org/freedesktop/PackageKit",
"org.freedesktop.PackageKit.Offline",
@@ -3894,16 +3860,12 @@ gs_systemd_call_trigger_upgrade (GsPlugin *plugin,
GError **error)
{
const gchar *tmp;
- g_autoptr(GDBusConnection) connection = NULL;
g_autoptr(GVariant) res = NULL;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, cancellable, error);
- if (connection == NULL)
- return FALSE;
tmp = pk_offline_action_to_string (action);
- res = g_dbus_connection_call_sync (connection,
+ res = g_dbus_connection_call_sync (gs_plugin_get_system_bus_connection (plugin),
"org.freedesktop.PackageKit",
"/org/freedesktop/PackageKit",
"org.freedesktop.PackageKit.Offline",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]