summaryrefslogtreecommitdiff
path: root/src/gpm-networkmanager.c
diff options
context:
space:
mode:
authormbkma <[email protected]>2026-03-15 11:12:12 +0100
committermbkma <[email protected]>2026-03-15 11:12:12 +0100
commit9d059b845030aaf2f8d374528ef666a8d274db9a (patch)
treef19e1f18ebb69cb190f709c2780959dbb55cd9ba /src/gpm-networkmanager.c
parent239eecf1017a480b4f3abb1db6c8742d820ece12 (diff)
downloadmate-power-manager-gdbus.tar.bz2
mate-power-manager-gdbus.tar.xz
migrate to gdbusgdbus
see https://github.com/GNOME/gnome-power-manager/commit/7568769f for a reference, though this is not a 1:1 copy
Diffstat (limited to 'src/gpm-networkmanager.c')
-rw-r--r--src/gpm-networkmanager.c74
1 files changed, 55 insertions, 19 deletions
diff --git a/src/gpm-networkmanager.c b/src/gpm-networkmanager.c
index 97c3210..4fd5c3d 100644
--- a/src/gpm-networkmanager.c
+++ b/src/gpm-networkmanager.c
@@ -25,7 +25,7 @@
#endif
#include <glib.h>
-#include <dbus/dbus-glib.h>
+#include <gio/gio.h>
#include "gpm-networkmanager.h"
@@ -43,26 +43,44 @@
gboolean
gpm_networkmanager_sleep (void)
{
- DBusGConnection *connection = NULL;
- DBusGProxy *nm_proxy = NULL;
+ GDBusProxy *nm_proxy = NULL;
+ GVariant *result = NULL;
GError *error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ nm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ NM_LISTENER_SERVICE,
+ NM_LISTENER_PATH,
+ NM_LISTENER_INTERFACE,
+ NULL,
+ &error);
if (error) {
g_warning ("%s", error->message);
g_error_free (error);
return FALSE;
}
-
- nm_proxy = dbus_g_proxy_new_for_name (connection,
- NM_LISTENER_SERVICE,
- NM_LISTENER_PATH,
- NM_LISTENER_INTERFACE);
if (!nm_proxy) {
g_warning ("Failed to get name owner");
return FALSE;
}
- dbus_g_proxy_call_no_reply (nm_proxy, "sleep", G_TYPE_INVALID);
+
+ result = g_dbus_proxy_call_sync (nm_proxy,
+ "sleep",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ g_object_unref (G_OBJECT (nm_proxy));
+ return FALSE;
+ }
+ if (result != NULL)
+ g_variant_unref (result);
+
g_object_unref (G_OBJECT (nm_proxy));
return TRUE;
}
@@ -77,26 +95,44 @@ gpm_networkmanager_sleep (void)
gboolean
gpm_networkmanager_wake (void)
{
- DBusGConnection *connection = NULL;
- DBusGProxy *nm_proxy = NULL;
+ GDBusProxy *nm_proxy = NULL;
+ GVariant *result = NULL;
GError *error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ nm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ NM_LISTENER_SERVICE,
+ NM_LISTENER_PATH,
+ NM_LISTENER_INTERFACE,
+ NULL,
+ &error);
if (error) {
g_warning ("%s", error->message);
g_error_free (error);
return FALSE;
}
-
- nm_proxy = dbus_g_proxy_new_for_name (connection,
- NM_LISTENER_SERVICE,
- NM_LISTENER_PATH,
- NM_LISTENER_INTERFACE);
if (!nm_proxy) {
g_warning ("Failed to get name owner");
return FALSE;
}
- dbus_g_proxy_call_no_reply (nm_proxy, "wake", G_TYPE_INVALID);
+
+ result = g_dbus_proxy_call_sync (nm_proxy,
+ "wake",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ g_object_unref (G_OBJECT (nm_proxy));
+ return FALSE;
+ }
+ if (result != NULL)
+ g_variant_unref (result);
+
g_object_unref (G_OBJECT (nm_proxy));
return TRUE;
}