g_dbus_proxy_new_for_bus_sync: assertion 'g_variant_is_object_path (object_path)' failed

Germano Massullo <[email protected]>
Newsgroups gmane.comp.freedesktop.dbus
Message-ID <CAGa=++STuxaNbKYdWNkg5wO_f6Vvk7VnTs+_TDs-Gkd5XbLyrg@mail.gmail.com>
I am implementing some code (in attachment) that should retrieve
systemd-logind `IdleSinceHint` property exposed on DBus, but when it
is runned it fails on assertion `g_assert (proxy != NULL);` with error

    (process:9059): GLib-GIO-CRITICAL **: 17:29:07.245:
g_dbus_proxy_new_for_bus_sync: assertion 'g_variant_is_object_path
(object_path)' failed
    **
    ERROR:print_user_idle_time.c:44:main: assertion failed: (proxy != NULL)

What can be the problem?
Thank you for your time

_______________________________________________
dbus mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dbus
print_user_idle_time.c (text/x-csrc, 1.3 KB)
/*
 * Compile with:
 *   gcc -Wall print_user_idle_time.c -o print_user_idle_time `pkg-config --libs gio-2.0 --cflags`
 */

#include <gio/gio.h>

static void
print_user_idle_time (GDBusProxy *proxy)
{
    gchar *property = "IdleSinceHint";
	GError *error = NULL;
	GVariant *ret;
	guint64 user_idle_time;

	ret = g_dbus_proxy_get_cached_property(proxy, property);
	if (!ret) {
		g_dbus_error_strip_remote_error (error);
		g_print ("IdleSinceHint failed: %s\n", error->message);
		g_error_free (error);
		return;
	}

	g_variant_get (ret, "(^ao)", &user_idle_time);
	g_print("%lu\n", user_idle_time);
    g_variant_unref (ret);
}

int
main (int argc, char *argv[])
{
	GDBusProxy *proxy;
    gchar *name = "org.freedesktop.login1";
    gchar *object_path = "org/freedesktop/login1";
    gchar *interface_name = "org.freedesktop.login1.Manager";
	/* Create a D-Bus proxy */
	proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
	                                       G_DBUS_PROXY_FLAGS_NONE,
	                                       NULL,
	                                       name,
	                                       object_path,
	                                       interface_name,
	                                       NULL, NULL);
	g_assert (proxy != NULL);

	print_user_idle_time (proxy);

	g_object_unref (proxy);

	return 0;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.