Commit f936fa8d authored by Simon McVittie's avatar Simon McVittie

CbyPerUserBridge: Implement TerminateBundle using CbyServiceManager

Apertis: https://phabricator.apertis.org/T2710Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
Reviewed-by: Frédéric Dalleau's avatarFrédéric Dalleau <frederic.dalleau@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D7072
parent c33467d2
......@@ -42,6 +42,25 @@ terminate_bundle_final_cb (GObject *source_object,
g_dbus_method_invocation_return_gerror (invocation, error);
}
static void
stop_bundle_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
g_autoptr (GTask) task = user_data;
g_autoptr (GError) error = NULL;
CbyPerUserBridge *self = g_task_get_source_object (task);
if (!_cby_service_manager_stop_bundle_finish (self->service_manager, result,
&error))
{
g_task_return_error (task, g_steal_pointer (&error));
return;
}
g_task_return_boolean (task, TRUE);
}
static void
terminate_bundle_process_info_cb (GObject *nil G_GNUC_UNUSED,
GAsyncResult *result,
......@@ -51,6 +70,7 @@ terminate_bundle_process_info_cb (GObject *nil G_GNUC_UNUSED,
g_autoptr (GError) error = NULL;
g_autoptr (CbyProcessInfo) process_info =
cby_process_info_new_for_dbus_invocation_finish (result, &error);
CbyPerUserBridge *self = g_task_get_source_object (task);
const gchar *label;
const gchar *bundle_id = g_task_get_task_data (task);
......@@ -83,8 +103,9 @@ terminate_bundle_process_info_cb (GObject *nil G_GNUC_UNUSED,
return;
}
DEBUG ("stub: pretending to terminate %s", bundle_id);
g_task_return_boolean (task, TRUE);
_cby_service_manager_stop_bundle_async (self->service_manager,
bundle_id, NULL, stop_bundle_cb,
g_object_ref (task));
}
static gboolean
......@@ -97,6 +118,13 @@ cby_per_user_bridge_terminate_bundle (CbyPerUserBridge *self,
terminate_bundle_final_cb,
g_object_ref (invocation));
if (!cby_is_bundle_id (bundle_id))
{
g_task_return_new_error (task, CBY_ERROR, CBY_ERROR_INVALID_ARGUMENT,
"Not a valid bundle ID: \"%s\"", bundle_id);
return TRUE; /* handled */
}
g_task_set_task_data (task, g_strdup (bundle_id), g_free);
cby_process_info_new_for_dbus_invocation_async (invocation, NULL,
terminate_bundle_process_info_cb, g_object_ref (task));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment