Skip to content

Commit

Permalink
gs-plugin-apk: reuse plugin's DBusConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloyoyoista committed Oct 2, 2023
1 parent bd80c9a commit fbcda9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
17 changes: 7 additions & 10 deletions src/gs-plugin-apk/gs-plugin-apk.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,19 @@ gs_plugin_apk_setup_async (GsPlugin *plugin,
gpointer user_data)
{
g_autoptr (GTask) task = NULL;
GBusType bus_type = G_BUS_TYPE_SYSTEM;

task = g_task_new (plugin, cancellable, callback, user_data);
g_task_set_source_tag (task, gs_plugin_apk_setup_async);

g_debug ("Initializing plugin");

if (g_getenv ("G_TEST_SRCDIR"))
bus_type = G_BUS_TYPE_SESSION;
apk_polkit2_proxy_new_for_bus (bus_type,
G_DBUS_PROXY_FLAGS_NONE,
"dev.Cogitri.apkPolkit2",
"/dev/Cogitri/apkPolkit2",
cancellable,
apk_polkit_proxy_setup_cb,
g_steal_pointer (&task));
apk_polkit2_proxy_new (gs_plugin_get_system_bus_connection (plugin),
G_DBUS_PROXY_FLAGS_NONE,
"dev.Cogitri.apkPolkit2",
"/dev/Cogitri/apkPolkit2",
cancellable,
apk_polkit_proxy_setup_cb,
g_steal_pointer (&task));
}

static void
Expand Down
5 changes: 4 additions & 1 deletion tests/gs-self-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ main (int argc, char **argv)
g_autofree gchar *tmp_root = NULL;
g_autoptr (GsPluginLoader) plugin_loader = NULL;
g_autoptr (GSettings) settings = NULL;
g_autoptr (GDBusConnection) bus_connection = NULL;
g_autoptr (GError) error = NULL;
gboolean ret;
int retval;
Expand Down Expand Up @@ -303,8 +304,10 @@ main (int argc, char **argv)
g_assert_true (tmp_root != NULL);
g_setenv ("GS_SELF_TEST_CACHEDIR", tmp_root, TRUE);

bus_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
g_assert_no_error (error);
/* we can only load this once per process */
plugin_loader = gs_plugin_loader_new (NULL, NULL);
plugin_loader = gs_plugin_loader_new (bus_connection, bus_connection);
/* g_signal_connect (plugin_loader, "status-changed", */
/* G_CALLBACK (gs_plugin_loader_status_changed_cb), NULL); */
gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR);
Expand Down

0 comments on commit fbcda9a

Please sign in to comment.