That is perfect ! Many thanks !
On Mon, Dec 6, 2010 at 7:30 PM, Dan Williams <[email protected]> wrote: > On Mon, 2010-12-06 at 17:05 +0100, Maxime Boure wrote: > > Hello everybody, > > > > > > I am developing an application using dbus to control Network Manager. > > The only problem I encounter is how to get the properties of type "- o > > -" > > Right. So 'o' (object path) is the type of the property you're looking > for, but the way to access that property is the D-Bus Properties > interface, which NM objects implement: > > > http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties > > in which the Get() call does return an VARIANT. > > > for example the property of > > org.freedesktop.NetworkManager.Connection.Active > > Connection - o - (read) > > The path of the connection. > > > > > > I use the glib library. > > > > > > I tried > > if (!dbus_g_proxy_call (proxy_props, "Get", &error, > > G_TYPE_STRING, "org.freedesktop.NetworkManager.Connection.Active", > > G_TYPE_STRING, "Connection", > > G_TYPE_INVALID, > > DBUS_TYPE_G_OBJECT_PATH, > > &conn, > > G_TYPE_INVALID)) > > { > > ERROR ("Error getting device's connection name : %s", error->message); > > g_error_free (error); > > } > > > > > > Which through the error : Error getting device's connection name : > > Expected D-BUS object path, got type code 'v' > > > > > > I replaced the DBUS_TYPE_G_OBJECT_PATH by G_TYPE_VALUE, the error > > disappear but I can't find the good g_value_get_xxx that can get me > > this value. > > GValue is just a container type which can create and free various other > types of values. So it "wraps" the real type that gets returned. So if > you get a GValue back, you can do something like this to see what's in > it, if you don't already know: > > GValue value = { 0 }; > GError *error = NULL; > > if (!dbus_g_proxy_call (proxy, "Get", &error, > G_TYPE_STRING, NM_DBUS_INTERFACE, > G_TYPE_STRING, "ActiveConnections", > G_TYPE_INVALID, > G_TYPE_VALUE, &value, > G_TYPE_INVALID)) { > g_warning ("Failed to get property: %s", error->message); > g_error_free (error); > return; > } > > g_message ("value type %s", G_VALUE_TYPE_NAME (&value)); > g_value_unset (&value); > > In the case of an object path, you would do this: > > const char *path; > > path = g_value_get_boxed (&value); > > since you know that DBUS_TYPE_G_OBJECT_PATH is actually a string > underneath. > > In any case, I've posted an example here: > > > http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/C/get-active-connections.c > > that should show you what needs to get done. Let me know if you have > any further questions or comments! > > Dan > > > > > Does anyone has succeeded that ? > > > > > > Many thanks > > > > > > -- > > Maxime Bouré > > > > > > _______________________________________________ > > networkmanager-list mailing list > > [email protected] > > http://mail.gnome.org/mailman/listinfo/networkmanager-list > > > -- *Maxime Bouré* Development Engineer Ubiquiet 332, rue Lecourbe 75015 Paris, France Tél. : +33 1 73 79 46 50
_______________________________________________ networkmanager-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/networkmanager-list
