dbus_g_pending_call and proxies

Colin Walters walters at verbum.org
Thu Jun 30 16:46:52 PDT 2005


I've been working on a more "real" application using the GLib bindings,
and one of the things that's immediately apparent to me is that
dbus_g_proxy_end_call is difficult to use.

For example, I have code that looks like this:

	DBusGPendingCall *call;
	
	call = dbus_g_proxy_begin_call (server, "CreateMachine", G_TYPE_STRING, "machine1", G_TYPE_INVALID);
	dbus_g_pending_call_set_notify (call,
					create_machine_completed_cb,
					state,
					NULL);
	state->pending_creation_calls = g_slist_prepend (state->pending_creation_calls, call);

And I want to do this:

static void
create_machine_completed_cb (DBusGPendingCall *call, gpointer data)
{
  StateData *state = data;
  GError *error = NULL;
  guint id;

  if (!dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &id, G_TYPE_INVALID))
    lose_gerror ("Failed to create new state machine", error);
  state->machines = g_slist_prepend (state->machines,  GUINT_TO_POINTER (id));
  state->pending_creation_calls = g_slist_remove (state->pending_creation_calls, call);
}

But where do I get the "proxy" variable?  As far as I can see, I
basically have to pass the proxy manually to dbus_g_proxy_end_call,
which means I have to create a special structure just to hold the proxy
and my ordinary application state data, and pass that as the user_data
for dbus_g_pending_call_set_notify.  Yuck.

I guess the most obvious thing to me would be if the proxy itself kept a
reference to all the outgoing calls.  When a call returned, the proxy
would pass itself *and* the call as an argument to the user's specified
callback.  Also this means if you destroy a proxy, all its pending calls
could be automatically cancelled.

It seems the original idea was that the lifecycle of the pending calls
is separate from that of the proxy, but that doesn't seem valuable to me
if you need the proxy to actually end the call. 

I've started to write a patch, but before I go and do that I just wanted
to be sure I wasn't missing something...

-------------- 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/20050630/f9585f6c/attachment.pgp


More information about the dbus mailing list