46 lines
1.4 KiB
Diff
46 lines
1.4 KiB
Diff
From c1871601dd00f87f075e72df7d9f07fd2d85db19 Mon Sep 17 00:00:00 2001
|
|
From: root <root@localhost.localdomain>
|
|
Date: Tue, 7 Nov 2023 15:34:59 +0800
|
|
Subject: [PATCH] add setCancel method
|
|
|
|
---
|
|
agent/polkitqt1-agent-session.cpp | 6 ++++++
|
|
agent/polkitqt1-agent-session.h | 4 ++++
|
|
2 files changed, 10 insertions(+)
|
|
|
|
diff --git a/agent/polkitqt1-agent-session.cpp b/agent/polkitqt1-agent-session.cpp
|
|
index 7aea332..c76c871 100644
|
|
--- a/agent/polkitqt1-agent-session.cpp
|
|
+++ b/agent/polkitqt1-agent-session.cpp
|
|
@@ -163,6 +163,12 @@ void AsyncResult::setCompleted()
|
|
d->result = NULL;
|
|
}
|
|
|
|
+void AsyncResult::setCancel(const QString &text)
|
|
+{
|
|
+ Q_ASSERT(d->result);
|
|
+ g_simple_async_result_set_error(d->result, POLKIT_ERROR, POLKIT_ERROR_CANCELLED, "%s", text.toUtf8().data());
|
|
+}
|
|
+
|
|
void AsyncResult::setError(const QString &text)
|
|
{
|
|
Q_ASSERT(d->result);
|
|
diff --git a/agent/polkitqt1-agent-session.h b/agent/polkitqt1-agent-session.h
|
|
index 0f763e8..8999bca 100644
|
|
--- a/agent/polkitqt1-agent-session.h
|
|
+++ b/agent/polkitqt1-agent-session.h
|
|
@@ -55,6 +55,10 @@ public:
|
|
* \brief Mark the action that is tied to this result as completed.
|
|
*/
|
|
void setCompleted();
|
|
+ /**
|
|
+ * \brief Mark the action that is tied to this result as cancelled.
|
|
+ */
|
|
+ void setCancel(const QString &text);
|
|
|
|
/**
|
|
* \brief Sets an error for the asynchronous result.
|
|
--
|
|
2.27.0
|
|
|