[gnome-software/135-restart-and-install-update-button-does-not-trigger-reboot-when-using-lxde] gs-common: Add a finish() function for gs_utils_invoke_reboot_async()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/135-restart-and-install-update-button-does-not-trigger-reboot-when-using-lxde] gs-common: Add a finish() function for gs_utils_invoke_reboot_async()
- Date: Tue, 21 Jun 2022 09:54:49 +0000 (UTC)
commit 788bd0a7ec2e8cf50305eac57db2b52de3096df5
Author: Milan Crha <mcrha redhat com>
Date: Tue Jun 21 08:53:20 2022 +0200
gs-common: Add a finish() function for gs_utils_invoke_reboot_async()
This helps to do more than one call for a reboot attempt with less
expectations on the caller side about the internals of the async()
function.
src/gs-common.c | 30 +++++++++++++++++++++++++-----
src/gs-common.h | 3 +++
2 files changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-common.c b/src/gs-common.c
index 948fdadbf..e0c6380b3 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -902,8 +902,7 @@ gs_utils_reboot_call_done_cb (GObject *source,
g_autoptr(GVariant) retval = NULL;
/* get result */
- retval = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source), res, &error);
- if (retval != NULL)
+ if (gs_utils_invoke_reboot_finish (source, res, &error))
return;
if (error != NULL) {
g_warning ("Calling org.gnome.SessionManager.Reboot failed: %s",
@@ -917,9 +916,8 @@ gs_utils_reboot_call_done_cb (GObject *source,
* @ready_callback: (nullable): a callback to be called after the call is finished, or %NULL
* @user_data: user data for the @ready_callback
*
- * Asynchronously invokes a reboot request using D-Bus. The @ready_callback should
- * use g_dbus_connection_call_finish (G_DBUS_CONNECTION (source), result, &error);
- * to get the result of the operation.
+ * Asynchronously invokes a reboot request. Finish the operation
+ * with gs_utils_invoke_reboot_finish().
*
* When the @ready_callback is %NULL, a default callback is used, which shows
* a runtime warning (using g_warning) on the console when the call fails.
@@ -948,6 +946,28 @@ gs_utils_invoke_reboot_async (GCancellable *cancellable,
user_data);
}
+/**
+ * gs_utils_invoke_reboot_finish:
+ * @source_object: the source object provided in the ready callback
+ * @result: the result object provided in the ready callback
+ * @error: a #GError, or %NULL
+ *
+ * Finishes gs_utils_invoke_reboot_async() call.
+ *
+ * Returns: Whether succeeded. If failed, the @error is set.
+ *
+ * Since: 43
+ **/
+gboolean
+gs_utils_invoke_reboot_finish (GObject *source_object,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_autoptr(GVariant) res = NULL;
+ res = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object), result, error);
+ return res != NULL;
+}
+
/**
* gs_utils_format_size:
* @size_bytes: size to format, in bytes
diff --git a/src/gs-common.h b/src/gs-common.h
index 8d60d46d3..f7292e933 100644
--- a/src/gs-common.h
+++ b/src/gs-common.h
@@ -55,6 +55,9 @@ gchar *gs_utils_time_to_string (gint64 unix_time_seconds);
void gs_utils_invoke_reboot_async (GCancellable *cancellable,
GAsyncReadyCallback ready_callback,
gpointer user_data);
+gboolean gs_utils_invoke_reboot_finish (GObject *source_object,
+ GAsyncResult *result,
+ GError **error);
gboolean gs_utils_split_time_difference (gint64 unix_time_seconds,
gint *out_minutes_ago,
gint *out_hours_ago,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]