Pregunta

i'm using dbus-glib to get the currently playing file name in smplayer2 . and i got http://bpaste.net/show/161995/ i trying to use the Get method to get the Metadata(type="a{sv}" )property ,

i write some code like this DBusGConnection *bus; GError *error = NULL;

bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);

DBusGProxy *smplayer;
smplayer= dbus_g_proxy_new_for_name (bus,
        "org.mpris.MediaPlayer2.SMPlayer2",
        "/org/mpris/MediaPlayer2", 
        "org.freedesktop.DBus.Properties");

GValue *Metadata;
dbus_g_proxy_call (smplayer, "Get", &error,
        G_TYPE_STRING,"org.mpris.MediaPlayer2.Player",
        G_TYPE_STRING,"Metadata", G_TYPE_INVALID,
        G_TYPE_VALUE, &Metadata, G_TYPE_INVALID);

but Metadata seen to be empty.

can anyone know this , please , any help will appreciate

¿Fue útil?

Solución

According to the freedesktop.org DBusBindings page, DBus-GLib is obsolete. Good catch @nemequ

The replacement is GDBus (D-Bus support in GLib) which provides high level and low level API. I would strongly recommend migrating over as the new API provides methods that make working with DBus much easier.

I've only worked with the dbus low level API, not glib but I think g_dbus_gvariant_to_gvalue is what you need. Note that this method is provided in the new API GDBus, not the one that you're using DBus-GLib. The get method returns a variant type, which is a container of sorts. You need to get the value out of the container.

The API Reference is full of good stuff. Check there if the above doesn't do the trick. Hope that helps

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top