DBusConnection -> DBusGConnection woes

Rob Taylor rob.taylor at codethink.co.uk
Wed Mar 28 16:53:34 PDT 2007


Ross Burton wrote:
> On Wed, 2007-03-28 at 14:25 -0400, Havoc Pennington wrote:
>> Robert McQueen wrote:
>>> Yes it's reasonably guaranteed currently, but I meant that we add the
>>> API here as a way to lift people from the lower-level DBusConnection
>>> (which you pointed dbus-glib at manually) to a DBusGConnection (which
>>> you can export objects on and otherwise use normally).
>>>
>> There's nothing wrong with having a g_connection_from_connection afaik - 
>> should not be any problem, as long as it's documented that you have to 
>> 'setup with g main' if you created the connection yourself.
> 
> Something like this?
> 
> Ross
> 
> 
> ------------------------------------------------------------------------
> 
> --- a/dbus/dbus-glib-lowlevel.h
> +++ b/dbus/dbus-glib-lowlevel.h
> @@ -49,6 +49,7 @@ void dbus_g_proxy_send (DBusGProxy    *proxy,
>                          dbus_uint32_t *client_serial);
>  
>  DBusConnection*  dbus_g_connection_get_connection (DBusGConnection *gconnection);
> +DBusGConnection*  dbus_connection_get_g_connection (DBusConnection *connection);
>  DBusMessage*     dbus_g_message_get_message       (DBusGMessage    *gmessage);
>  
>  /* dbus_g_pending_call_get_pending_call() deliberately skipped for now;
> diff --git a/dbus/dbus-glib.c b/dbus/dbus-glib.c
> index 4b467d3..79b18f1 100644
> --- a/dbus/dbus-glib.c
> +++ b/dbus/dbus-glib.c
> @@ -309,6 +309,25 @@ dbus_g_connection_get_connection (DBusGConnection *gconnection)
>  }
>  
>  /**
> + * dbus_connection_get_g_connection:
> + * @connection:  a #DBusConnection
> + *
> + * Get the #DBusGConnection corresponding to this #DBusConnection.  This only
> + * makes sense if the #DBusConnection was originally a #DBusGConnection that was
> + * registered with the GLib main loop.  The return value does not have its
> + * refcount incremented.
> + *
> + * Returns: #DBusGConnection 
> + */
> +DBusGConnection*
> +dbus_connection_get_g_connection (DBusConnection *connection)
> +{
> +  /* TODO: this should sanity check that the connection is registered with glib */
> +  return DBUS_G_CONNECTION_FROM_CONNECTION (connection);
> +}
> +
> +
> +/**
>   * dbus_g_message_get_message:
>   * @gmessage: a #DBusGMessage
>   *
> 

If you can fill in the sanity check, it looks fine to me :)

Thanks,
Rob Taylor


More information about the dbus mailing list