diff --git a/data/org.freedesktop.Flatpak.xml b/data/org.freedesktop.Flatpak.xml
index 8e3b48ed59..435f1e1e63 100644
--- a/data/org.freedesktop.Flatpak.xml
+++ b/data/org.freedesktop.Flatpak.xml
@@ -167,6 +167,13 @@
+
+
+
+
+
+
diff --git a/system-helper/flatpak-system-helper.c b/system-helper/flatpak-system-helper.c
index 66aa36820b..bd2312da58 100644
--- a/system-helper/flatpak-system-helper.c
+++ b/system-helper/flatpak-system-helper.c
@@ -1812,6 +1812,42 @@ handle_update_summary (FlatpakSystemHelper *object,
return TRUE;
}
+static gboolean
+handle_cancel_pull (FlatpakSystemHelper *object,
+ GDBusMethodInvocation *invocation,
+ const gchar *arg_installation,
+ const gchar *arg_repo_path)
+{
+ g_autoptr(OngoingPull) ongoing_pull = NULL;
+ g_autoptr(FlatpakDir) system = NULL;
+ g_autoptr(GError) error = NULL;
+
+ g_debug ("CancelPull %s", arg_installation);
+
+ system = dir_get_system (arg_installation, &error);
+ if (system == NULL)
+ {
+ g_dbus_method_invocation_return_gerror (invocation, error);
+ return TRUE;
+ }
+
+ ongoing_pull = take_ongoing_pull_by_dir (arg_repo_path);
+ if (ongoing_pull != NULL)
+ {
+ ongoing_pull_teardown (ongoing_pull);
+ ongoing_pull_unref (ongoing_pull);
+ }
+ else
+ {
+ /* Should not be reached */
+ g_warning ("Cannot find ongoing pull to cancel at: %s", arg_repo_path);
+ }
+
+ flatpak_system_helper_complete_cancel_pull (object, invocation);
+
+ return TRUE;
+}
+
static gboolean
flatpak_authorize_method_handler (GDBusInterfaceSkeleton *interface,
GDBusMethodInvocation *invocation,
@@ -1941,7 +1977,8 @@ flatpak_authorize_method_handler (GDBusInterfaceSkeleton *interface,
g_strcmp0 (method_name, "EnsureRepo") == 0 ||
g_strcmp0 (method_name, "RunTriggers") == 0 ||
g_strcmp0 (method_name, "UpdateSummary") == 0 ||
- g_strcmp0 (method_name, "GetChildRepoForPull") == 0)
+ g_strcmp0 (method_name, "GetChildRepoForPull") == 0 ||
+ g_strcmp0 (method_name, "CancelPull") == 0)
{
const char *remote;
@@ -2013,6 +2050,7 @@ on_bus_acquired (GDBusConnection *connection,
g_signal_connect (helper, "handle-run-triggers", G_CALLBACK (handle_run_triggers), NULL);
g_signal_connect (helper, "handle-update-summary", G_CALLBACK (handle_update_summary), NULL);
g_signal_connect (helper, "handle-get-child-repo-for-pull", G_CALLBACK (handle_get_child_repo_for_pull), NULL);
+ g_signal_connect (helper, "handle-cancel-pull", G_CALLBACK (handle_cancel_pull), NULL);
g_signal_connect (helper, "g-authorize-method",
G_CALLBACK (flatpak_authorize_method_handler),