[Telepathy] tp_cli_connection_manager_run_request_connection(): What parameter types.

Murray Cumming murrayc at murrayc.com
Mon Oct 27 09:07:21 PDT 2008


On Sat, 2008-10-25 at 11:14 +0100, Will Thompson wrote:
> >   GHashTable *parameters = g_hash_table_new (NULL, NULL);
> >   g_hash_table_insert (parameters, "s:account", "murrayc at murrayc.com");
> >   g_hash_table_insert (parameters, "s:server", "murrayc.com");
> >   g_hash_table_insert (parameters, "s:password", "TODO");
> >   
> 
> should become something like (untested):
> 
>     GValue *value;
>     GHashTable *parameters = g_hash_table_new_full (NULL, NULL, NULL, tp_g_value_slice_free);
> 
>     value = tp_g_value_slice_new (G_TYPE_STRING);
>     g_value_set_static_string (value, "murrayc at murrayc.com");
>     g_hash_table_insert (parameters, "account", value);
> 
>     /* on XMPP, you shouldn't need to set the server parameter, since presumably you have an appropriate SRV record on murrayc.com. */
> 
>     value = tp_g_value_slice_new (G_TYPE_STRING);
>     g_value_set_static_string (value, "myhovercraftisfullofeels");
>     g_hash_table_insert (parameters, "password", value);


Thanks. Shouldn't there be a varargs version of this function. It's
generally unpleasant to deal with GValues. For instance,
http://library.gnome.org/devel/gtk/unstable/GtkListStore.html#gtk-list-store-set


So now my connection request has succeeded, giving me a "A D-Bus service
name where the new Connection object can be found" and "The D-Bus object
path to the Connection on this service". I guess I can use these with
tp_connection_new(),
http://telepathy.freedesktop.org/doc/telepathy-glib/telepathy-glib-connection.html#tp-connection-new
but why didn't I just get a TpConnection object directly? And shouldn't
the API reference documentation tell me these things?


Also, when running this twice (without using tp_connection_new), I
noticed that the connection seems to be system-wide, because I got this
error the second time from 
tp_cli_connection_manager_run_request_connection()
"Connection manager already has a connection to this account."

So 
a) How can I just "get" the existing connection if it exists.
and
b) How should I "release" the connection?

> Telepathy-GLib has helper methods to get values of various types out of
> such string → GValue maps (namely tp_asv_get_…, where “a{sv}” is the
> D-Bus type signature of these dictionaries), but none to set values. We
> should add some (created
> http://bugs.freedesktop.org/show_bug.cgi?id=18220 ); then this would
> become:
> 
>     GHashTable *parameters = g_hash_table_new (NULL, NULL, NULL, tp_g_value_slice_free);
> 
>     tp_asv_set_static_string (parameters, "account", "murrayc at murrayc.com");
>     tp_asv_set_static_string (parameters, "password", "myzeppelinisfullofbees");
> 
>       
> 
> which is somewhat more palatable, and is (sadly) about the best we could
> hope for in a C binding for such a D-Bus API. We could conceivably add
> tp_connection_parameters_set_password (GHashTable *parameters, const
> gchar *password) etc. for each well-known parameter name, but any
> non-trivial program which has to care about connection parameters will
> have to deal with un-specced parameters (since every CM in existence has
> some bizarre protocol-specific parameters) so will wind up falling back
> to tp_asv_…

Yes, but explicit functions for the standard stuff would still make code
smaller clearer and safer.

> In related news, I have been investigating the list_all_protocols
> example in telepathy-doc, and have found some race conditions in the
> initialization of TpConnectionManager which means that got-info might
> never (visibly) fire… This is probably the least well-tested area of the
> client-side API, which is particularly unfortunate as it's one of the
> first things you'd have to deal with to write a full Telepathy client
> from scratch. :(

Many thanks for investigating.

In general, if it's not tested then it doesn't work.

-- 
murrayc at murrayc.com
www.murrayc.com
www.openismus.com



More information about the Telepathy mailing list