Bug 27769 - TpConnection needs AVATAR_REQUIREMENTS feature
Summary: TpConnection needs AVATAR_REQUIREMENTS feature
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: review+
Keywords: patch
Depends on:
Blocks:
 
Reported: 2010-04-21 01:47 UTC by Xavier Claessens
Modified: 2010-04-22 10:56 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Xavier Claessens 2010-04-21 01:47:52 UTC
Now that TpConnection can have features, we should add an AVATAR_REQUIREMENTS feature. Or maybe it can be done in CORE since it's just one dbus call with no update?
Comment 1 Xavier Claessens 2010-04-21 02:37:52 UTC
Branch implementing this:

http://git.collabora.co.uk/?p=user/xclaesse/telepathy-glib.git;a=shortlog;h=refs/heads/avatar-requirements

Didn't test that code yet, have to use it in empathy side.
Comment 2 Xavier Claessens 2010-04-21 03:03:05 UTC
Note that we also want to know the avatar requirements when offline, so maybe the TpConnectionAvatarRequirements struct could be renamed to TpAvatarRequirements so it can be used in any other APIs like TpProtocol.
Comment 3 Simon McVittie 2010-04-21 05:21:40 UTC
> Or maybe it can be done in CORE since it's just one dbus call with no
> update?

No, I prefer it as a feature. Most TpConnections won't care about this feature (it's only useful to UIs that can set the avatar, like the Empathy main window), so it'd be a waste of time and memory for (say) telepathy-logger, Mission Control, a dedicated VoIP UI or a Tubes app to download and remember this information.

(In reply to comment #2)
> Note that we also want to know the avatar requirements when offline, so maybe
> the TpConnectionAvatarRequirements struct could be renamed to
> TpAvatarRequirements so it can be used in any other APIs like TpProtocol.

Yes please. Also, it should have a boxed type (look at recent patches that make TpIntSet into a boxed type - basically you need a get_type function, a copy function and a free function), and a spare pointer or two in case we need to add more fields (I can't think of any, but I'd have said that before we added the "recommended" ones too).

The struct needs documentation; as a minimum, please `make check` with --enable-gtk-doc and add docs in the source, and entries in sections.txt, until it stops complaining.

> +  ar->supported_mime_types = g_strdupv ((GStrv) tp_asv_get_strv (properties,
> +      TP_PROP_CONNECTION_INTERFACE_AVATARS_SUPPORTED_AVATAR_MIME_TYPES));

This doesn't work, and neither do any of the other properties. The key in the a{sv} returned by GetAll isn't namespaced, so you need to use "SupportedAvatarMIMETypes".

It would be nice if you replaced NULL with { NULL } (i.e. an empty GStrv) after retrieving SupportedAvatarMIMETypes, so that you could guarantee to API users that the GStrv was non-NULL.

> +finally:
> +  _tp_proxy_set_feature_prepared (proxy, TP_CONNECTION_FEATURE_AVATAR_REQUIREMENTS,
> +      TRUE);

The third argument should be FALSE if getting the properties failed. You can use (self->priv->avatar_requirements != NULL), probably.
Comment 4 Xavier Claessens 2010-04-21 08:06:44 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > Note that we also want to know the avatar requirements when offline, so maybe
> > the TpConnectionAvatarRequirements struct could be renamed to
> > TpAvatarRequirements so it can be used in any other APIs like TpProtocol.
> 
> Yes please. Also, it should have a boxed type (look at recent patches that make
> TpIntSet into a boxed type - basically you need a get_type function, a copy
> function and a free function), and a spare pointer or two in case we need to
> add more fields (I can't think of any, but I'd have said that before we added
> the "recommended" ones too).

done

> The struct needs documentation; as a minimum, please `make check` with
> --enable-gtk-doc and add docs in the source, and entries in sections.txt, until
> it stops complaining.

done

> > +  ar->supported_mime_types = g_strdupv ((GStrv) tp_asv_get_strv (properties,
> > +      TP_PROP_CONNECTION_INTERFACE_AVATARS_SUPPORTED_AVATAR_MIME_TYPES));
> 
> This doesn't work, and neither do any of the other properties. The key in the
> a{sv} returned by GetAll isn't namespaced, so you need to use
> "SupportedAvatarMIMETypes".

done

> It would be nice if you replaced NULL with { NULL } (i.e. an empty GStrv) after
> retrieving SupportedAvatarMIMETypes, so that you could guarantee to API users
> that the GStrv was non-NULL.

done

> > +finally:
> > +  _tp_proxy_set_feature_prepared (proxy, TP_CONNECTION_FEATURE_AVATAR_REQUIREMENTS,
> > +      TRUE);
> 
> The third argument should be FALSE if getting the properties failed. You can
> use (self->priv->avatar_requirements != NULL), probably.

I copied from tp_connection_get_rcc_cb() where it also give TRUE even in case of failure. Is that a bug in both functions?

I updated my branch.
Comment 5 Xavier Claessens 2010-04-21 09:04:59 UTC
I tested that branch in empathy and it works at least with gabble. But butterfly does not implement those properties. I think we need a fallback to the old DBus call.

fyi here is empathy branch: http://git.collabora.co.uk/?p=user/xclaesse/empathy.git;a=shortlog;h=refs/heads/avatar-req
Comment 6 Simon McVittie 2010-04-21 09:53:49 UTC
Can't we just fix Butterfly? :-)
Comment 7 Simon McVittie 2010-04-21 09:55:16 UTC
(In reply to comment #4)
> I copied from tp_connection_get_rcc_cb() where it also give TRUE even in case
> of failure. Is that a bug in both functions?

RequestableChannelClasses is a bit different, since the Requests interface is mandatory, and if it doesn't work, then you've lost the ability to do Telepathy correctly - anything we do after that is just a matter of how we recover.
Comment 8 Simon McVittie 2010-04-21 10:20:06 UTC
For the CMs with Avatars but without these properties:

* Bug #27776 (in Butterfly) has a patch.
* Bug #27777 is the same thing for Sunshine; a very similar patch should work.
* Bug #22304 is the same thing for Haze; it should be easy to do based on Gabble?
Comment 9 Xavier Claessens 2010-04-21 11:58:10 UTC
(In reply to comment #7)
> (In reply to comment #4)
> > I copied from tp_connection_get_rcc_cb() where it also give TRUE even in case
> > of failure. Is that a bug in both functions?
> 
> RequestableChannelClasses is a bit different, since the Requests interface is
> mandatory, and if it doesn't work, then you've lost the ability to do Telepathy
> correctly - anything we do after that is just a matter of how we recover.

Ok, updated the patch.
Comment 10 Simon McVittie 2010-04-22 09:04:24 UTC
> +TP_TYPE_AVATAR_REQUIREMENTS

This should be in a non-Standard, non-Private section: otherwise it's not obvious that a boxed type exists.

> +                            guint minimum_height,
> +                            guint minimum_width,

Would it be more normal to put widths before heights, so they're in the order (x, y)?

> + * Since: 0.11.FUTURE

Our release scripts don't grep for FUTURE. Please use UNRELEASED.
Comment 11 Simon McVittie 2010-04-22 09:07:44 UTC
> + * <!--badger-->

Surely you have more to say about TpAvatarRequirements than that? "The requirements for setting an avatar on a particular protocol", perhaps?
Comment 12 Xavier Claessens 2010-04-22 09:19:31 UTC
(In reply to comment #10)
> > +TP_TYPE_AVATAR_REQUIREMENTS
> 
> This should be in a non-Standard, non-Private section: otherwise it's not
> obvious that a boxed type exists.

done

> > +                            guint minimum_height,
> > +                            guint minimum_width,
> 
> Would it be more normal to put widths before heights, so they're in the order
> (x, y)?

Just copied the list from the spec, but indeed with usually have width before height.

Fixed.

> > + * Since: 0.11.FUTURE
> 
> Our release scripts don't grep for FUTURE. Please use UNRELEASED.

done

(In reply to comment #11)
> > + * <!--badger-->
> 
> Surely you have more to say about TpAvatarRequirements than that? "The
> requirements for setting an avatar on a particular protocol", perhaps?

done.

patch updated.
Comment 13 Simon McVittie 2010-04-22 09:44:08 UTC
Ship it.
Comment 14 Xavier Claessens 2010-04-22 10:56:05 UTC
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.