[gnome-software: 11/21] gs-plugin-loader: Add D-Bus connection arguments to constructor
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 11/21] gs-plugin-loader: Add D-Bus connection arguments to constructor
- Date: Wed, 27 Apr 2022 10:41:23 +0000 (UTC)
commit c92b18b096bb50a5adb71f72503d567a06dd9e44
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed Mar 30 15:58:38 2022 +0100
gs-plugin-loader: Add D-Bus connection arguments to constructor
And port all the existing calls to `gs_plugin_loader_new()` to pass
them.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1694
lib/gs-cmd.c | 2 +-
lib/gs-plugin-loader.c | 25 ++++++++++++++++++++-----
lib/gs-plugin-loader.h | 3 ++-
plugins/core/gs-self-test.c | 2 +-
plugins/dpkg/gs-self-test.c | 2 +-
plugins/dummy/gs-self-test.c | 2 +-
plugins/fedora-langpacks/gs-self-test.c | 2 +-
plugins/flatpak/gs-self-test.c | 2 +-
plugins/fwupd/gs-self-test.c | 2 +-
plugins/modalias/gs-self-test.c | 2 +-
plugins/packagekit/gs-self-test.c | 2 +-
plugins/repos/gs-self-test.c | 2 +-
plugins/snap/gs-self-test.c | 2 +-
src/gs-application.c | 2 +-
14 files changed, 34 insertions(+), 18 deletions(-)
---
diff --git a/lib/gs-cmd.c b/lib/gs-cmd.c
index 22b94b1da..dc4b7e640 100644
--- a/lib/gs-cmd.c
+++ b/lib/gs-cmd.c
@@ -362,7 +362,7 @@ main (int argc, char **argv)
}
/* load plugins */
- self->plugin_loader = gs_plugin_loader_new ();
+ self->plugin_loader = gs_plugin_loader_new (NULL, NULL);
if (g_file_test (LOCALPLUGINDIR, G_FILE_TEST_EXISTS))
gs_plugin_loader_add_location (self->plugin_loader, LOCALPLUGINDIR);
if (plugin_allowlist_str != NULL)
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index e72f47766..b92b6b3de 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -3099,15 +3099,30 @@ gs_plugin_loader_init (GsPluginLoader *plugin_loader)
/**
* gs_plugin_loader_new:
+ * @session_bus_connection: (nullable) (transfer none): a D-Bus session bus
+ * connection to use, or %NULL to use the default
+ * @system_bus_connection: (nullable) (transfer none): a D-Bus system bus
+ * connection to use, or %NULL to use the default
*
- * Return value: a new GsPluginLoader object.
+ * Create a new #GsPluginLoader.
+ *
+ * The D-Bus connection arguments should typically be %NULL, and only be
+ * non-%NULL when doing unit tests.
+ *
+ * Return value: (transfer full) (not nullable): a new #GsPluginLoader
+ * Since: 43
**/
GsPluginLoader *
-gs_plugin_loader_new (void)
+gs_plugin_loader_new (GDBusConnection *session_bus_connection,
+ GDBusConnection *system_bus_connection)
{
- GsPluginLoader *plugin_loader;
- plugin_loader = g_object_new (GS_TYPE_PLUGIN_LOADER, NULL);
- return GS_PLUGIN_LOADER (plugin_loader);
+ g_return_val_if_fail (session_bus_connection == NULL || G_IS_DBUS_CONNECTION
(session_bus_connection), NULL);
+ g_return_val_if_fail (system_bus_connection == NULL || G_IS_DBUS_CONNECTION (system_bus_connection),
NULL);
+
+ return g_object_new (GS_TYPE_PLUGIN_LOADER,
+ "session-bus-connection", session_bus_connection,
+ "system-bus-connection", system_bus_connection,
+ NULL);
}
static void
diff --git a/lib/gs-plugin-loader.h b/lib/gs-plugin-loader.h
index e7edeeecf..2fbda9a1e 100644
--- a/lib/gs-plugin-loader.h
+++ b/lib/gs-plugin-loader.h
@@ -25,7 +25,8 @@ G_DECLARE_FINAL_TYPE (GsPluginLoader, gs_plugin_loader, GS, PLUGIN_LOADER, GObje
#include "gs-plugin-job.h"
-GsPluginLoader *gs_plugin_loader_new (void);
+GsPluginLoader *gs_plugin_loader_new (GDBusConnection *session_bus_connection,
+ GDBusConnection *system_bus_connection);
void gs_plugin_loader_job_process_async (GsPluginLoader *plugin_loader,
GsPluginJob *plugin_job,
GCancellable *cancellable,
diff --git a/plugins/core/gs-self-test.c b/plugins/core/gs-self-test.c
index a786e58bb..260066b38 100644
--- a/plugins/core/gs-self-test.c
+++ b/plugins/core/gs-self-test.c
@@ -242,7 +242,7 @@ main (int argc, char **argv)
g_setenv ("GS_SELF_TEST_APPSTREAM_XML", xml, TRUE);
/* we can only load this once per process */
- plugin_loader = gs_plugin_loader_new ();
+ plugin_loader = gs_plugin_loader_new (NULL, NULL);
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR);
ret = gs_plugin_loader_setup (plugin_loader,
allowlist,
diff --git a/plugins/dpkg/gs-self-test.c b/plugins/dpkg/gs-self-test.c
index 0318e70eb..ecb567d45 100644
--- a/plugins/dpkg/gs-self-test.c
+++ b/plugins/dpkg/gs-self-test.c
@@ -68,7 +68,7 @@ main (int argc, char **argv)
gs_test_init (&argc, &argv);
/* we can only load this once per process */
- plugin_loader = gs_plugin_loader_new ();
+ plugin_loader = gs_plugin_loader_new (NULL, NULL);
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR);
ret = gs_plugin_loader_setup (plugin_loader,
allowlist,
diff --git a/plugins/dummy/gs-self-test.c b/plugins/dummy/gs-self-test.c
index 9964f166c..d2e41364e 100644
--- a/plugins/dummy/gs-self-test.c
+++ b/plugins/dummy/gs-self-test.c
@@ -823,7 +823,7 @@ main (int argc, char **argv)
g_setenv ("GS_SELF_TEST_APPSTREAM_XML", xml, TRUE);
/* we can only load this once per process */
- plugin_loader = gs_plugin_loader_new ();
+ plugin_loader = gs_plugin_loader_new (NULL, NULL);
g_signal_connect (plugin_loader, "status-changed",
G_CALLBACK (gs_plugin_loader_status_changed_cb), NULL);
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR);
diff --git a/plugins/fedora-langpacks/gs-self-test.c b/plugins/fedora-langpacks/gs-self-test.c
index 4e95fa867..6a0d99dde 100644
--- a/plugins/fedora-langpacks/gs-self-test.c
+++ b/plugins/fedora-langpacks/gs-self-test.c
@@ -70,7 +70,7 @@ main (int argc, char **argv)
gs_test_init (&argc, &argv);
/* we can only load this once per process */
- plugin_loader = gs_plugin_loader_new ();
+ plugin_loader = gs_plugin_loader_new (NULL, NULL);
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR);
ret = gs_plugin_loader_setup (plugin_loader,
allowlist,
diff --git a/plugins/flatpak/gs-self-test.c b/plugins/flatpak/gs-self-test.c
index 5b4a1faf8..d414a6673 100644
--- a/plugins/flatpak/gs-self-test.c
+++ b/plugins/flatpak/gs-self-test.c
@@ -1927,7 +1927,7 @@ main (int argc, char **argv)
g_setenv ("GS_SELF_TEST_APPSTREAM_XML", xml, TRUE);
/* we can only load this once per process */
- plugin_loader = gs_plugin_loader_new ();
+ plugin_loader = gs_plugin_loader_new (NULL, NULL);
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR);
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR_CORE);
ret = gs_plugin_loader_setup (plugin_loader,
diff --git a/plugins/fwupd/gs-self-test.c b/plugins/fwupd/gs-self-test.c
index 34e6ecbcf..6b56e6bd7 100644
--- a/plugins/fwupd/gs-self-test.c
+++ b/plugins/fwupd/gs-self-test.c
@@ -87,7 +87,7 @@ main (int argc, char **argv)
gs_test_init (&argc, &argv);
/* we can only load this once per process */
- plugin_loader = gs_plugin_loader_new ();
+ plugin_loader = gs_plugin_loader_new (NULL, NULL);
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR);
ret = gs_plugin_loader_setup (plugin_loader,
allowlist,
diff --git a/plugins/modalias/gs-self-test.c b/plugins/modalias/gs-self-test.c
index e7730f77b..7ab8bb0be 100644
--- a/plugins/modalias/gs-self-test.c
+++ b/plugins/modalias/gs-self-test.c
@@ -82,7 +82,7 @@ main (int argc, char **argv)
g_setenv ("GS_SELF_TEST_CACHEDIR", tmp_root, TRUE);
/* we can only load this once per process */
- plugin_loader = gs_plugin_loader_new ();
+ plugin_loader = gs_plugin_loader_new (NULL, NULL);
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR);
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR_CORE);
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR_DUMMY);
diff --git a/plugins/packagekit/gs-self-test.c b/plugins/packagekit/gs-self-test.c
index f6a48096f..51ae947fb 100644
--- a/plugins/packagekit/gs-self-test.c
+++ b/plugins/packagekit/gs-self-test.c
@@ -254,7 +254,7 @@ main (int argc, char **argv)
g_test_add_func ("/gnome-software/markdown", gs_markdown_func);
/* we can only load this once per process */
- plugin_loader = gs_plugin_loader_new ();
+ plugin_loader = gs_plugin_loader_new (NULL, NULL);
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR);
ret = gs_plugin_loader_setup (plugin_loader,
allowlist,
diff --git a/plugins/repos/gs-self-test.c b/plugins/repos/gs-self-test.c
index f72241547..5a0d10856 100644
--- a/plugins/repos/gs-self-test.c
+++ b/plugins/repos/gs-self-test.c
@@ -52,7 +52,7 @@ main (int argc, char **argv)
g_setenv ("GS_SELF_TEST_REPOS_DIR", reposdir, TRUE);
/* we can only load this once per process */
- plugin_loader = gs_plugin_loader_new ();
+ plugin_loader = gs_plugin_loader_new (NULL, NULL);
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR);
ret = gs_plugin_loader_setup (plugin_loader,
allowlist,
diff --git a/plugins/snap/gs-self-test.c b/plugins/snap/gs-self-test.c
index fdafa2c26..0cdb2cc4e 100644
--- a/plugins/snap/gs-self-test.c
+++ b/plugins/snap/gs-self-test.c
@@ -357,7 +357,7 @@ main (int argc, char **argv)
gs_test_init (&argc, &argv);
/* we can only load this once per process */
- plugin_loader = gs_plugin_loader_new ();
+ plugin_loader = gs_plugin_loader_new (NULL, NULL);
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR);
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR_CORE);
ret = gs_plugin_loader_setup (plugin_loader,
diff --git a/src/gs-application.c b/src/gs-application.c
index db1d4e2d1..a2875c513 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -945,7 +945,7 @@ gs_application_startup (GApplication *application)
if (tmp != NULL)
plugin_allowlist = g_strsplit (tmp, ",", -1);
- app->plugin_loader = gs_plugin_loader_new ();
+ app->plugin_loader = gs_plugin_loader_new (g_application_get_dbus_connection (application), NULL);
if (g_file_test (LOCALPLUGINDIR, G_FILE_TEST_EXISTS))
gs_plugin_loader_add_location (app->plugin_loader, LOCALPLUGINDIR);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]