Object path values - which service do they belong to?
Colin Walters
walters at verbum.org
Tue May 17 10:27:43 PDT 2005
On Tue, 2005-05-17 at 13:07 -0400, Havoc Pennington wrote:
> On Mon, 2005-05-16 at 17:14 -0400, Colin Walters wrote:
> >
> > As I understand it, the intention is that object paths are service
> > local. If you get an object path back from a service, it refers to an
> > object on that service. If you're passing inter-service object paths,
> > I'd suggest just using DBUS_TYPE_STRING.
> >
> You can use DBUS_TYPE_OBJECT_PATH to go between services, why not?
What I'm doing in the GLib bindings now is mapping it on the client end
to DBUS_TYPE_G_PROXY, and on the server end mapping it to G_TYPE_OBJECT.
This feels pretty natural I think, but it is based on the assumption
that an object path always refers to an object on the same service as
the method.
For example, code to retrieve a list of devices from NetworkManager and
print out whether they were wireless would look like:
DBusGProxy *networkmanager;
GError *error = NULL;
GPtrArray *devices;
guint i;
if (!org_freedesktop_NetworkManager_get_devices (nm, &error))
...
for (i = 0; i < devices->len; i++) {
DBusGProxy *device;
gboolean wireless;
device = g_ptr_array_index (devices, i)
if (!org_freedesktop_NetworkManager_get_wireless_enabled (device, &wireless, &error))
...
if (wireless)
printf ("device %s is wireless\n", dbus_g_proxy_get_path (device));
/* Important: unref returned proxy */
g_object_unref (device);
}
g_ptr_array_free (devices, TRUE);
And on the server end, all NetworkManager has to do is create a
GPtrArray with references to its device objects and return that.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/dbus/attachments/20050517/374acd32/attachment.pgp
More information about the dbus
mailing list