Bug 32609 - TpContact should have properties to know subscribe/publish state
Summary: TpContact should have properties to know subscribe/publish state
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: tp-glib (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Xavier Claessens
QA Contact: Telepathy bugs list
URL: http://git.collabora.co.uk/?p=user/xc...
Whiteboard:
Keywords: patch
Depends on:
Blocks: 32702
  Show dependency treegraph
 
Reported: 2010-12-23 08:14 UTC by Xavier Claessens
Modified: 2011-01-29 03:18 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Xavier Claessens 2010-12-23 08:14:40 UTC
This is made easy with the Connection.ContactList interface, because it has contact attributes.
Comment 1 Xavier Claessens 2010-12-23 08:15:21 UTC
Branch ready for review :)
Comment 2 Guillaume Desmottes 2010-12-24 04:19:38 UTC
"states" sounds like a poor name to me but I can't think of a better one.

Bouh, no test :(
Comment 3 Xavier Claessens 2010-12-26 02:01:24 UTC
I shamelessly copied naming from tp_base_contact_list_dup_states(). But now I'm wondering if I should rather have 3 getters instead of one. Also wondering if I should rename property "subscription-state" to "subscribe" and "publish-state" to "publish". Do you have an opinion on this?

For tests, I have patched contacts-conn.c to use a TpBaseContactList for my contactsd work on Harmattan, it is in my todo list to backport this to tp-glib.
Comment 4 Xavier Claessens 2010-12-28 01:57:27 UTC
I modified a bit the API to be more convenient, and I added unit tests
Comment 5 Simon McVittie 2011-01-03 05:57:39 UTC
> + * tp_contact_get_publish_request:

Please document whether/under what circumstances this returns %NULL or "". One nice set of semantics would be to guarantee that it's non-NULL if and only if publish-state is REQUESTED; an alternative nice set of semantics would be to guarantee that it's never NULL (in which case you'd either need a special case in the getter, or initialization to g_strdup (NULL)).

The doc-comments for the getters should cross-reference to the properties. I like the wording "Returns: the value of #TpContact:publish-state", personally.

> +      TP_SUBSCRIPTION_STATE_UNKNOWN,
> +      TP_SUBSCRIPTION_STATE_YES,
> +      TP_SUBSCRIPTION_STATE_UNKNOWN,

Can this go above YES if you're given a stupid value from D-Bus? I think it can - so the limit needs to be G_MAXUINT32. Or, clip out-of-range values to UNKNOWN whenever you receive information from D-Bus.

I don't like using an enum member as the upper limit: if anything it should be (NUM_TP_SUBSCRIPTION_STATES - 1) (which is numerically equal, at the moment).

> Simplify contacts-conn by using TpConnectionPresenceType

I'm not keen on this; I know it's only test code, but it's a misleading thing to do. The point of not using TpConnectionPresenceType is that basically no connection managers will have exactly one status per TpConnectionPresenceType - in the general case, a CM will lack support for some of the "important" (i.e. directly mapped to presence type) statuses, and will have some statuses that share a TpConnectionPresenceType (e.g. in Gabble, "available" and "chat" (free for chat) are both AVAILABLE; in MSN, AIUI, "on-the-phone" and "having-lunch" could both be BUSY, but there is no "busy" as such).
Comment 6 Xavier Claessens 2011-01-09 06:58:13 UTC
(In reply to comment #5)
> > + * tp_contact_get_publish_request:
> 
> Please document whether/under what circumstances this returns %NULL or "". One
> nice set of semantics would be to guarantee that it's non-NULL if and only if
> publish-state is REQUESTED; an alternative nice set of semantics would be to
> guarantee that it's never NULL (in which case you'd either need a special case
> in the getter, or initialization to g_strdup (NULL)).

With current implementation, it is guaranteed to be non-NULL once the feature is prepared. I think that's a reasonable behavior. I added documentation for it.

> The doc-comments for the getters should cross-reference to the properties. I
> like the wording "Returns: the value of #TpContact:publish-state", personally.

Fixed

> > +      TP_SUBSCRIPTION_STATE_UNKNOWN,
> > +      TP_SUBSCRIPTION_STATE_YES,
> > +      TP_SUBSCRIPTION_STATE_UNKNOWN,
> 
> Can this go above YES if you're given a stupid value from D-Bus? I think it can
> - so the limit needs to be G_MAXUINT32. Or, clip out-of-range values to UNKNOWN
> whenever you receive information from D-Bus.
> 
> I don't like using an enum member as the upper limit: if anything it should be
> (NUM_TP_SUBSCRIPTION_STATES - 1) (which is numerically equal, at the moment).

Ok, I changed to be in [0, G_MAXUINT]. If/When we want to restrict the values, we could use mkenum anyway.

> > Simplify contacts-conn by using TpConnectionPresenceType
> 
> I'm not keen on this; I know it's only test code, but it's a misleading thing
> to do. The point of not using TpConnectionPresenceType is that basically no
> connection managers will have exactly one status per TpConnectionPresenceType -
> in the general case, a CM will lack support for some of the "important" (i.e.
> directly mapped to presence type) statuses, and will have some statuses that
> share a TpConnectionPresenceType (e.g. in Gabble, "available" and "chat" (free
> for chat) are both AVAILABLE; in MSN, AIUI, "on-the-phone" and "having-lunch"
> could both be BUSY, but there is no "busy" as such).

Ok dropped that commit
Comment 7 Guillaume Desmottes 2011-01-14 04:19:28 UTC
Implementation looks good to me, just some documentation details to fix.
I'd prefer to get an API++ from smcv before merging this though.

+ *  (available since UNRELEASED)

We use 0.13.UNRELEASED

+   * TpContact:publish-request:
Documentation is unclear about what's returned if TpContact:publish-state is
not TP_SUBSCRIPTION_STATE_ASK. I think it's "", we should document that.

+   * @contact: A #TpContact
should be "a #TpContact". Same for other arguments.
Comment 8 Simon McVittie 2011-01-18 07:05:17 UTC
The API looks fine. Drive-by documentation nits:

> + *  #TpContact:publish-state and #TpContact:publish-request. Require a
> + *  Connection implementing ContactList interface.

... Requires a Connection implementing the %TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST interface.

The use of @self as the argument name in tp_contact_get_subscribe_state(), tp_contact_get_publish_state() and tp_contact_get_publish_request() meant I had to read the documentation at least twice, due to confusion with the other meaning of "self" (SelfHandle, etc.).

Replacing "@self" with "this contact" or even "this remote contact" in the text of the doc-comment would improve it, I think - an exception to the usual rule that more cross-references make documentation better :-)

Perhaps saying "the local user" instead of "the user" in these docstrings would also be a good way to disambiguate how our jargon works.

> +   * A #TpSubscriptionState indicating the state of the user's subscription
> +   * to contact's presence.

English grammar: "subscription to this contact's presence" (i.e. add "this")

> +   * A #TpSubscriptionState indicating the state of contact's subscription to
> +   * the user's presence.

English grammar: "the state of this contact's subscription" (i.e. add "this")
Comment 9 Xavier Claessens 2011-01-29 03:18:50 UTC
Fixed all those comments and merged. 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.