From 5a4eaf4f6948401a7affa2aa63ed9038a9d5e1f6 Mon Sep 17 00:00:00 2001 From: rbuj Date: Mon, 18 May 2020 10:43:17 +0200 Subject: cpufreq: Port client of selector service to GDBus https://gitlab.gnome.org/GNOME/gnome-applets/-/commit/ed5418eed57cb00976603923d2ccf2b1b8acddf4 --- cpufreq/src/cpufreq-utils.c | 46 ++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'cpufreq/src/cpufreq-utils.c') diff --git a/cpufreq/src/cpufreq-utils.c b/cpufreq/src/cpufreq-utils.c index 3e3325ca..7dd358fa 100644 --- a/cpufreq/src/cpufreq-utils.c +++ b/cpufreq/src/cpufreq-utils.c @@ -33,7 +33,7 @@ #include "cpufreq-utils.h" #ifdef HAVE_POLKIT -#include +#include #endif /* HAVE_POLKIT */ guint @@ -45,7 +45,7 @@ cpufreq_utils_get_n_cpus (void) if (n_cpus > 0) return n_cpus; - + do { if (file) g_free (file); @@ -111,13 +111,14 @@ cpufreq_utils_display_error (const gchar *message, static gboolean selector_is_available (void) { - DBusGProxy *proxy; - static DBusGConnection *system_bus = NULL; + GDBusProxy *proxy; + static GDBusConnection *system_bus = NULL; GError *error = NULL; + GVariant *reply; gboolean result; if (!system_bus) { - system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); + system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); if (!system_bus) { g_warning ("%s", error->message); g_error_free (error); @@ -126,18 +127,37 @@ selector_is_available (void) } } - proxy = dbus_g_proxy_new_for_name (system_bus, - "org.mate.CPUFreqSelector", - "/org/mate/cpufreq_selector/selector", - "org.mate.CPUFreqSelector"); + proxy = g_dbus_proxy_new_sync (system_bus, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "org.mate.CPUFreqSelector", + "/org/mate/cpufreq_selector/selector", + "org.mate.CPUFreqSelector", + NULL, + &error); + + if (!proxy) { + g_warning ("%s", error->message); + g_error_free (error); + + return FALSE; + } + + reply = g_dbus_proxy_call_sync (proxy, + "CanSet", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); - if (!dbus_g_proxy_call (proxy, "CanSet", &error, - G_TYPE_INVALID, - G_TYPE_BOOLEAN, &result, - G_TYPE_INVALID)) { + if (!reply) { g_warning ("Error calling org.mate.CPUFreqSelector.CanSet: %s", error->message); g_error_free (error); result = FALSE; + } else { + g_variant_get (reply, "(b)", &result); + g_variant_unref (reply); } g_object_unref (proxy); -- cgit v1.2.1