Bug 77772 - [next] TpBaseContactList GInterfaces: take vfunc arguments of the appropriate type
Summary: [next] TpBaseContactList GInterfaces: take vfunc arguments of the appropriate...
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: tp-glib (show other bugs)
Version: git master
Hardware: Other All
: medium normal
Assignee: Telepathy bugs list
QA Contact: Telepathy bugs list
URL: http://cgit.collabora.com/git/user/ca...
Whiteboard:
Keywords: patch
Depends on:
Blocks: 68661
  Show dependency treegraph
 
Reported: 2014-04-22 18:22 UTC by Simon McVittie
Modified: 2014-09-17 12:39 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Simon McVittie 2014-04-22 18:22:01 UTC
> GStrv
> (*TpBaseContactListDupContactGroupsFunc)
>                               (TpBaseContactList *self,
>                                TpHandle contact);

I don't think this vfunc in TpContactGroupListInterface can be introspectable unless it is changed to take a TpContactGroupList * as its first argument.

This is an easy change for 1.0, it just needs someone to sit down and write the boilerplate in the top 5 connection managers.
Comment 1 Guillaume Desmottes 2014-05-15 07:35:50 UTC
You mean that it should be:

typedef GStrv (*TpBaseContactListDupContactGroupsFunc) (
    TpContactGroupListInterface *self,
    TpHandle contact);

instead of:

typedef GStrv (*TpBaseContactListDupContactGroupsFunc) (
    TpBaseContactList *self,
    TpHandle contact);

?

If yes, then I guess we should do this change for all the vfunc in this interface, don't we?
Comment 2 Simon McVittie 2014-05-15 09:53:03 UTC
(In reply to comment #1)
> You mean that it should be:
> 
> typedef GStrv (*TpBaseContactListDupContactGroupsFunc) (
>     TpContactGroupListInterface *self,
>     TpHandle contact);
> 
> instead of:
> 
> typedef GStrv (*TpBaseContactListDupContactGroupsFunc) (
>     TpBaseContactList *self,
>     TpHandle contact);
> 
> ?
> 
> If yes, then I guess we should do this change for all the vfunc in this
> interface, don't we?

Yes. The pattern is, wherever we have

typedef Mushroom (*BadgerFunc) (Snake *self, ...);
                            //  ^^^^^
struct _BadgerInterface {
  ...
  BadgerFunc dance;
}

the vfunc's "self" parameter needs to be changed to match the dummy typedef for the interface:

typedef Mushroom (*BadgerFunc) (Badger *self, ...);
                             // ^^^^^^
struct _BadgerInterface {
  ...
  BadgerFunc dance;
}

This might mean splitting up some of the typedefs that are currently shared between interfaces, according to the type that their "self" parameter needs.
Comment 3 Guillaume Desmottes 2014-05-16 10:12:15 UTC
Simon: can you please take a quick look on http://cgit.collabora.com/git/user/cassidy/telepathy-glib/log/?h=next-contact-list-iface-77772 and check if this is going into the right direction?

As you can see in the top commit, doing this means duplicating a bit of generic functions and typedef but I don't see any another option.

Also, should method like "GStrv tp_base_contact_list_dup_groups (TpBaseContactList *self);" be changed to take a TpContactGroupList as first argument? This methods assert that the iface is implemented so I guess that would be ok. But for example tp_base_contact_list_normalize_group() just return FALSE in that case.
Comment 4 Simon McVittie 2014-05-16 12:15:33 UTC
(In reply to comment #3)
> Simon: can you please take a quick look on
> http://cgit.collabora.com/git/user/cassidy/telepathy-glib/log/?h=next-
> contact-list-iface-77772 and check if this is going into the right direction?

Yes, this is the right direction.

> As you can see in the top commit, doing this means duplicating a bit of
> generic functions and typedef but I don't see any another option.

Agreed.

> Also, should method like "GStrv tp_base_contact_list_dup_groups
> (TpBaseContactList *self);" be changed to take a TpContactGroupList as first
> argument? This methods assert that the iface is implemented so I guess that
> would be ok. But for example tp_base_contact_list_normalize_group() just
> return FALSE in that case.

Oh, I'd forgotten there were functions like that. I must have thought I was being so clever while designing those interfaces :-(

For the methods where it's considered to be a programming error to call them on the wrong type, it is correct to change the first argument.

For the methods where calling them on the wrong type is allowed ... I think we should probably change the semantics to "it's a programming error to call it on the wrong type" (g_return_if_fail), and move the graceful type-check into the callers. A bit of "git grep" will be necessary.
Comment 5 Guillaume Desmottes 2014-05-19 12:59:31 UTC
This part can already be reviewed and merged:
http://cgit.collabora.com/git/user/cassidy/telepathy-glib/log/?h=next-contact-list-iface-77772

If it's fine, I'll do the other ifaces next.
Comment 7 Guillaume Desmottes 2014-05-20 09:18:33 UTC
(In reply to comment #4)
> For the methods where calling them on the wrong type is allowed ... I think
> we should probably change the semantics to "it's a programming error to call
> it on the wrong type" (g_return_if_fail), and move the graceful type-check
> into the callers. A bit of "git grep" will be necessary.

Does this apply to tp_base_contact_list_can_block() as well which is explicitely used to check if the contact list support blocking?
Comment 8 Simon McVittie 2014-05-26 11:21:48 UTC
+ * It is an error to call this fonction if @self subclass does not implement

"function" (please git grep)

I think "if @self does not implement" would also be better.

All looks OK so far, apart from those comments.

(In reply to comment #7)
> Does this apply to tp_base_contact_list_can_block() as well which is
> explicitely used to check if the contact list support blocking?

Hmm. For now let's say "no, leave can_block() as-is" and see what the g-i looks like.

If necessary we can change all its callers to

    (TP_IS_BLOCKABLE_CONTACT_LIST (cl) &&
     tp_blockable_contact_list_can_block ((TpBlockableContactList *) cl))

but that's pretty cumbersome...
Comment 9 Guillaume Desmottes 2014-05-26 13:20:55 UTC
(In reply to comment #8)
> + * It is an error to call this fonction if @self subclass does not implement
> 
> "function" (please git grep)
> 
> I think "if @self does not implement" would also be better.
> 
> All looks OK so far, apart from those comments.

Fixed and merged.
Comment 11 Guillaume Desmottes 2014-05-27 14:21:35 UTC
> (In reply to comment #7)
> > Does this apply to tp_base_contact_list_can_block() as well which is
> > explicitely used to check if the contact list support blocking?
> 
> Hmm. For now let's say "no, leave can_block() as-is" and see what the g-i
> looks like.


      <method name="can_block"
              c:identifier="tp_base_contact_list_can_block"
              version="0.13.0">
        <doc xml:space="preserve">Return whether this contact list has a list of blocked contacts. If it
does, that list is assumed to be modifiable.

If the #TpBaseContactList subclass does not implement
%TP_TYPE_BLOCKABLE_CONTACT_LIST, this method always returns %FALSE.

For implementations of %TP_TYPE_BLOCKABLE_CONTACT_LIST, this is a virtual
method, implemented using #TpBlockableContactListInterface.can_block.
The default implementation always returns %TRUE.

In the case of a protocol where blocking may or may not work
and this is detected while connecting, the subclass can implement another
#TpBaseContactListBooleanFunc (whose result must remain constant
after the #TpBaseConnection has moved to state
%TP_CONNECTION_STATUS_CONNECTED), and use that as the implementation.

(For instance, this could be useful for XMPP, where support for contact
blocking is server-dependent: telepathy-gabble 0.8.x implements it for
connections to Google Talk servers, but not for any other server.)</doc>
        <return-value transfer-ownership="none">
          <doc xml:space="preserve">%TRUE if communication from contacts can be blocked</doc>
          <type name="gboolean" c:type="gboolean"/>
        </return-value>
        <parameters>
          <instance-parameter name="self" transfer-ownership="none">
            <doc xml:space="preserve">a contact list manager</doc>
            <type name="BaseContactList" c:type="TpBaseContactList*"/>
          </instance-parameter>
        </parameters>
      </method>
Comment 12 Simon McVittie 2014-05-28 10:36:31 UTC
(In reply to comment #11)
>       <method name="can_block"
>               c:identifier="tp_base_contact_list_can_block"

I think that g-i looks OK.

(In reply to comment #10)
> More of this:
> http://cgit.collabora.com/git/user/cassidy/telepathy-glib/log/?h=next-
> contact-list-iface-77772

I don't see any new commits there?

> http://cgit.collabora.com/git/user/cassidy/telepathy-gabble/log/?h=next-
> contact-list-iface-77772

The Gabble changes look OK, assuming reasonable tp-glib changes.

One comment: casting "TpMutableContactList *base" to TpBaseContactList * seems confusing. Shouldn't it be called iface or mutable or something instead? (I would be happy for your answer to be "yes but it's too much diffstat to be worth it", though.)

I assume Haze will also need updating?
Comment 13 Guillaume Desmottes 2014-05-28 11:46:43 UTC
(In reply to comment #12)
> (In reply to comment #11)
> >       <method name="can_block"
> >               c:identifier="tp_base_contact_list_can_block"
> 
> I think that g-i looks OK.
> 
> (In reply to comment #10)
> > More of this:
> > http://cgit.collabora.com/git/user/cassidy/telepathy-glib/log/?h=next-
> > contact-list-iface-77772
> 
> I don't see any new commits there?

Is cgit being shit again? Here it show 9 commits (from db6d23db0fda5fe91f30e1bb99b6120b423a98a3 to 444f4ab3ff429e36c1a31c199b323751b74ff1c8) on top of next.

> > http://cgit.collabora.com/git/user/cassidy/telepathy-gabble/log/?h=next-
> > contact-list-iface-77772
> 
> The Gabble changes look OK, assuming reasonable tp-glib changes.
> 
> One comment: casting "TpMutableContactList *base" to TpBaseContactList *
> seems confusing. Shouldn't it be called iface or mutable or something
> instead? (I would be happy for your answer to be "yes but it's too much
> diffstat to be worth it", though.)

Yeah I know, but I have been too lazy to change those. :p

> I assume Haze will also need updating?

Actually no, it doesn't use any of those API.
Comment 14 Guillaume Desmottes 2014-06-17 14:15:19 UTC
Ping? I think there is not much work left before merging this.
Comment 15 Simon McVittie 2014-09-17 12:39:51 UTC
Fixed in git for 0.99.12, 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.