Bug 43819 - [API break] Simplify TpBaseClient constructors
Summary: [API break] Simplify TpBaseClient constructors
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: tp-glib (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Telepathy bugs list
QA Contact: Telepathy bugs list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-14 04:48 UTC by Xavier Claessens
Modified: 2012-03-29 00:55 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Xavier Claessens 2011-12-14 04:48:32 UTC
atm a simple handler that just wants to catch its channels without preparing a full TpAccountManager have to do:

dbus = tp_dbus_daemon_dup(NULL);
factory = tp_automatic_client_factory_new (dbus);
handler = tp_simple_handler_new_with_factory (factory, ...);
...
g_object_unref (dbus);
g_object_unref (factory);
g_object_unref (handler);

IMO this is a bit too much, the only thing TpBaseClient really needs is a factory, all the rest is just legacy or constructor helpers. Since we are going to break API in "next" branch, let's sort this out.

What I suggest:

1) tp_simple_handler_new (TpSimpleClientFactory *factory, ...);
if factory is NULL, then internally it does dbus = tp_dbus_daemon_dup(); self->priv->factory = tp_automatic_client_factory_new(dbus);

2) tp_simple_handler_new_with_am (TpAccountManager *am, ...){return tp_simple_handler_new (tp_proxy_get_factory (am), ...);} this is a trivial helper in the case the user already has an IM.

Like this, the example above strips down to:

handler = tp_simple_handler_new (NULL, ...);
...
g_object_unref (handler);
Comment 1 Xavier Claessens 2011-12-14 04:50:48 UTC
Of course this apply to every TpBaseClient subclasses: approvers and observers as well.

Here is a branch I've started but trying to keep ABI, it could serve as base:
http://cgit.collabora.com/git/user/xclaesse/telepathy-glib.git/log/?h=base-client
Comment 2 Jonny Lamb 2012-03-22 13:12:27 UTC
Yeah this branch looks alright so far. Just two documentation points:

> + * Since Since 0.UNRELEASED @dbus can be %NULL in which case

Double "Since".

+ * instead create a new #TpAutomaticClientFactory. If user already have a

s/have/has/
Comment 3 Xavier Claessens 2012-03-28 07:18:40 UTC
Branch updated with typos fixed.

Do you think this small behavior change can be pushed to master, or do you prefer only 'next' ?
Comment 4 Jonny Lamb 2012-03-28 09:29:50 UTC
(In reply to comment #3)
> Branch updated with typos fixed.
> 
> Do you think this small behavior change can be pushed to master, or do you
> prefer only 'next' ?

I think it'd be better with just 'next'.
Comment 5 Xavier Claessens 2012-03-29 00:55:44 UTC
Ok, merged into next. Thanks.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.