From 764f6d5f6fd9a0fb93ccec100add316d1a4b6828 Mon Sep 17 00:00:00 2001 From: Wu Xiaotian Date: Fri, 26 Jun 2020 22:19:23 +0800 Subject: common: migrate to GDBus --- capplets/common/activate-settings-daemon.c | 65 ++++++++++++++++-------------- 1 file changed, 34 insertions(+), 31 deletions(-) (limited to 'capplets/common/activate-settings-daemon.c') diff --git a/capplets/common/activate-settings-daemon.c b/capplets/common/activate-settings-daemon.c index 21fd2b2b..11651082 100644 --- a/capplets/common/activate-settings-daemon.c +++ b/capplets/common/activate-settings-daemon.c @@ -2,10 +2,9 @@ #include #endif -#include #include #include - +#include #include "activate-settings-daemon.h" static void popup_error_message (void) @@ -26,35 +25,39 @@ static void popup_error_message (void) gboolean activate_settings_daemon (void) { - DBusGConnection *connection = NULL; - DBusGProxy *proxy = NULL; - GError *error = NULL; - - connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (connection == NULL) - { - popup_error_message (); - g_error_free (error); - return FALSE; - } - - proxy = dbus_g_proxy_new_for_name (connection, - "org.mate.SettingsDaemon", - "/org/mate/SettingsDaemon", - "org.mate.SettingsDaemon"); - - if (proxy == NULL) - { - popup_error_message (); - return FALSE; - } - - if (!org_mate_SettingsDaemon_awake(proxy, &error)) - { - popup_error_message (); - g_error_free (error); - return FALSE; - } + GError *error = NULL; + GDBusProxy *proxy = NULL; + GVariant *ret; + + proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "org.mate.SettingsDaemon", + "/org/mate/SettingsDaemon", + "org.mate.SettingsDaemon", + NULL, + &error); + if (proxy == NULL) { + popup_error_message (); + g_error_free (error); + return FALSE; + } + + ret = g_dbus_proxy_call_sync (proxy, + "Awake", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (ret == NULL) { + popup_error_message (); + g_error_free (error); + return FALSE; + } else { + g_variant_get (ret, "()"); + g_variant_unref (ret); + } return TRUE; } -- cgit v1.2.1