Bug 25293 - ChannelDispatcher: can't migrate channels between Clients
Summary: ChannelDispatcher: can't migrate channels between Clients
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: tp-spec (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: Telepathy bugs list
QA Contact: Telepathy bugs list
URL: http://git.collabora.co.uk/?p=user/ca...
Whiteboard: review+
Keywords: patch
Depends on:
Blocks: 34610
  Show dependency treegraph
 
Reported: 2009-11-26 03:44 UTC by Simon McVittie
Modified: 2011-05-09 05:28 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Simon McVittie 2009-11-26 03:44:51 UTC
+++ This bug was initially created as a clone of Bug #25286 +++

The conceptual model of a Handler is that all Clients on the same unique name share their pool of HandledChannels, so no action is needed to migrate channels between Handlers that share a unique name.

However, if a channel is moved between Handlers on different unique names, the collaborating handlers need to tell the ChannelDispatcher about it, so that it won't close the channel if the old Handler crashes, but *will* close the channel if the new Handler crashes.
Comment 1 Guillaume Desmottes 2011-01-19 04:14:19 UTC
This has been discussed in this thread as gnome-shell needs this. It can start handling the channel itself and then give it back to Empathy.

http://lists.freedesktop.org/archives/telepathy/2010-November/005061.html

The idea was to implement this:

ChannelDispatcher.GiveBack(o: Account, ao: Channels,
        x: User_Action_Time, s: Next_Handler, a{sv}: Hints) -> nothing

It has been suggested to return a ChannelRequest but I'm not convinced it buys us anything.
Comment 2 Guillaume Desmottes 2011-01-19 05:17:24 UTC
Here we go: http://git.collabora.co.uk/?p=user/cassidy/telepathy-spec;a=shortlog;h=refs/heads/re-handle-25293

I've finally choosed RedispatchChannels() as suggested by Sjoerd, I think that's clearer.
Comment 3 Guillaume Desmottes 2011-01-21 05:48:23 UTC
I started implementing this in bug #33271

It seems to work fine (in tests), the only issue is that currently the client getting the channel being re-dispatched doesn't have a way to get Hints.
That's because the only way to get it in HandleChannels() is throught the ChannelRequest() and I don't create a new CR when redispatching.

I guess we could create one, but that sounds a bit like an abuse of the first goal of ChannelRequest tbh. Maybe instead we could add a new key Handler_Info to pass the redispatching hints?
Comment 4 Guillaume Desmottes 2011-01-21 06:15:04 UTC
Note from our quick discussion on IRC.

Sjoerd suggested that instead of raising NotCapable, MC would succeed and re-call HandleChannels() on the caller. That would make things easier for the caller as it could assume after calling RedispatchChannels() that it is not longer handling the channel. (except if it passes invalid arguments or a channel it's not handling but in that case that's his fault).

If we go for that approach, should RedispatchChannels() return before or after HandleChannels() has been called?


I was also wondering if it would be useful for the new Handler to know which was the previous handler before him. We could do that by adding a key to Handler_Info if needed.
Comment 6 Guillaume Desmottes 2011-01-26 06:55:51 UTC
I added RedEnsureChannel()
http://people.freedesktop.org/~gdesmott/telepathy-spec-re_handle_25293/spec/Channel_Dispatcher.html#Method:ReEnsureChannel

I didn't include a Hints parameter as the Handler won't have any way to get it. We could solve that by adding Hints to Handler_Info as suggested above.
Comment 7 Sjoerd Simons 2011-02-23 02:58:43 UTC
Looks good to me. I don't think Hints are really needed, the use-case for this is, prod the current channel not to modify/update/put in extra hints..

If we find a usecase for it we can do a ReEnsureChannelWithHints later.
Comment 8 Guillaume Desmottes 2011-02-23 03:13:03 UTC
What about ReDispatchChannels()? Should we remove the Hints argument as well?
Comment 9 Guillaume Desmottes 2011-02-23 03:20:12 UTC
Actually, what's the point to pass the Account to ReDispatchChannels() and ReEnsureChannel()? MC should already know it from the channel(s).
Comment 10 Will Thompson 2011-03-14 06:37:32 UTC
ReDispatchChannels
------------------

I think something like DelegateChannels() would be a better name. It doesn't actually send the channel through the whole dispatcher again—or does it? Do Observers get the channel again? Is a ChannelRequest created? I guess you think this is an open question too. :)

(In reply to comment #9)
> Actually, what's the point to pass the Account to ReDispatchChannels() and
> ReEnsureChannel()? MC should already know it from the channel(s).

I kind of agree. If ReDispatchChannels() is plural, then why shouldn't we be able to redispatch channels from different accounts? This would also make it marginally easier to use.

    The time at which user action occurred, or 0 if this channel request is for
    some reason not involving user action.

What channel request?

    Either the well-known bus name (starting with
    org.freedesktop.Telepathy.Client.) of the preferred new handler for these
    channels, or an empty string to indicate that any handler would be
    acceptable. The behaviour and rationale are the same as for the
    corresponding parameter to CreateChannelWithHints.

If I pass the empty string for the preferred handler, is it okay for MC to give me the channel right back again (if I'm the best match)?

I think this method needs an example of how it would be used.

    Additional information about the channels request, which will be used as
    the value for the resulting request's Hints property.

What channel request? :)


ReEnsureChannel
---------------

Again, I think it would be better to have a different method name to more clearly signal the intent of this method. How about EvokeChannel()? EvokeHandlerForChannel()? KickHandler()? SummonHandler()?

I think it's inconsistent that one of these methods can take hints and stuff, bu the other cannot. Since they both end up being a call to HandleChannels() on some handler…

(Also I wonder how many handlers will deal correctly with being given 5 text channels at once... ;-))
Comment 11 Guillaume Desmottes 2011-03-23 04:09:21 UTC
(In reply to comment #10)
> ReDispatchChannels
> ------------------
> 
> I think something like DelegateChannels() would be a better name. It doesn't
> actually send the channel through the whole dispatcher again—or does it? Do
> Observers get the channel again? Is a ChannelRequest created? I guess you think
> this is an open question too. :)

I'd say 'no' to all of these questions, so yeah DelegateChannels() sounds like
a better name. I renamed it.

> (In reply to comment #9)
> > Actually, what's the point to pass the Account to ReDispatchChannels() and
> > ReEnsureChannel()? MC should already know it from the channel(s).
> 
> I kind of agree. If ReDispatchChannels() is plural, then why shouldn't we be
> able to redispatch channels from different accounts? This would also make it
> marginally easier to use.

Ok, I removed the Account.

>     The time at which user action occurred, or 0 if this channel request is for
>     some reason not involving user action.
> 
> What channel request?

fixed.

>     Either the well-known bus name (starting with
>     org.freedesktop.Telepathy.Client.) of the preferred new handler for these
>     channels, or an empty string to indicate that any handler would be
>     acceptable. The behaviour and rationale are the same as for the
>     corresponding parameter to CreateChannelWithHints.
> 
> If I pass the empty string for the preferred handler, is it okay for MC to give
> me the channel right back again (if I'm the best match)?

I'd say no as the goal is explicitely to pass the channel to another client.
What do you think?

> I think this method needs an example of how it would be used.

I'll add one once we agree on the API.

>     Additional information about the channels request, which will be used as
>     the value for the resulting request's Hints property.
> 
> What channel request? :)

Right. This move us back to the question "Should we allow to pass Hints" ?
If we want to (which is probably a good idea) and we don't create a
ChannelRequest (which I also think is a good idea) then our only option is to
add a 'Hints' (a(a{sv}) key to Handler_Info.

> ReEnsureChannel
> ---------------
> 
> Again, I think it would be better to have a different method name to more
> clearly signal the intent of this method. How about EvokeChannel()?
> EvokeHandlerForChannel()? KickHandler()? SummonHandler()?

PresentChannel()?

> I think it's inconsistent that one of these methods can take hints and stuff,
> bu the other cannot. Since they both end up being a call to HandleChannels() on
> some handler…

If we go for the 'Hints' key in Handler_Info approach we can easily add one.

I updated:
http://git.collabora.co.uk/?p=user/cassidy/telepathy-spec;a=shortlog;h=refs/heads/re-handle-25293
http://people.freedesktop.org/~gdesmott/telepathy-spec-re_handle_25293/spec/Channel_Dispatcher.html#Method:DelegateChannels
Comment 12 Will Thompson 2011-04-04 10:01:44 UTC
(In reply to comment #11)
> (In reply to comment #10)
> > If I pass the empty string for the preferred handler, is it okay for MC to give
> > me the channel right back again (if I'm the best match)?
> 
> I'd say no as the goal is explicitely to pass the channel to another client.
> What do you think?

I agree. I think the method call should fail if the preferred handler doesn't exist, or if you pass "" and there are no handlers beside yourself.

> >     Additional information about the channels request, which will be used as
> >     the value for the resulting request's Hints property.
> > 
> > What channel request? :)
> 
> Right. This move us back to the question "Should we allow to pass Hints" ?
> If we want to (which is probably a good idea) and we don't create a
> ChannelRequest (which I also think is a good idea) then our only option is to
> add a 'Hints' (a(a{sv}) key to Handler_Info.

I don't really like this because it means that every implementation of HandleChannels() will have to look in two different places for hints. It won't be right by default.

I don't think making a ChannelRequest spring up would be so bad. It's a bit of an abuse, but…

I'm undecided about which I think would be worse.

> > ReEnsureChannel
> > ---------------
> > 
> > Again, I think it would be better to have a different method name to more
> > clearly signal the intent of this method. How about EvokeChannel()?
> > EvokeHandlerForChannel()? KickHandler()? SummonHandler()?
> 
> PresentChannel()?

Someone got upset last time someone suggested “Present”—which is why I didn't suggest it—but given that this is what this method is *for* I think it's reasonable.

> > I think it's inconsistent that one of these methods can take hints and stuff,
> > bu the other cannot. Since they both end up being a call to HandleChannels() on
> > some handler…
> 
> If we go for the 'Hints' key in Handler_Info approach we can easily add one.

And if we go for “create a ChannelRequest”, then we can add one too. :)
Comment 13 Guillaume Desmottes 2011-04-05 02:01:57 UTC
(In reply to comment #12)
> (In reply to comment #11)
> > (In reply to comment #10)
> > > If I pass the empty string for the preferred handler, is it okay for MC to give
> > > me the channel right back again (if I'm the best match)?
> > 
> > I'd say no as the goal is explicitely to pass the channel to another client.
> > What do you think?
> 
> I agree. I think the method call should fail if the preferred handler doesn't
> exist, or if you pass "" and there are no handlers beside yourself.

Cool, that's already what the spec says (Not Capable error).

> > >     Additional information about the channels request, which will be used as
> > >     the value for the resulting request's Hints property.
> > > 
> > > What channel request? :)
> > 
> > Right. This move us back to the question "Should we allow to pass Hints" ?
> > If we want to (which is probably a good idea) and we don't create a
> > ChannelRequest (which I also think is a good idea) then our only option is to
> > add a 'Hints' (a(a{sv}) key to Handler_Info.
> 
> I don't really like this because it means that every implementation of
> HandleChannels() will have to look in two different places for hints. It won't
> be right by default.
> 
> I don't think making a ChannelRequest spring up would be so bad. It's a bit of
> an abuse, but…
> 
> I'm undecided about which I think would be worse.

I'm still not convinced we should have a ChannelRequest; that's a re-dispatch
request, not a channel one. And then, should DelegateChannels() return a CR
and the dispatching be delayed until we call CR.Proceed()?
If we don't, we have 2 different way to use CRs.

> > > ReEnsureChannel
> > > ---------------
> > > 
> > > Again, I think it would be better to have a different method name to more
> > > clearly signal the intent of this method. How about EvokeChannel()?
> > > EvokeHandlerForChannel()? KickHandler()? SummonHandler()?
> > 
> > PresentChannel()?
> 
> Someone got upset last time someone suggested “Present”—which is why I didn't
> suggest it—but given that this is what this method is *for* I think it's
> reasonable.

PresentChannel() it is then: changed.

> > > I think it's inconsistent that one of these methods can take hints and stuff,
> > > bu the other cannot. Since they both end up being a call to HandleChannels() on
> > > some handler…
> > 
> > If we go for the 'Hints' key in Handler_Info approach we can easily add one.
> 
> And if we go for “create a ChannelRequest”, then we can add one too. :)

Right.

So I think the last thing to decide is if we go for a CR or not.

Don't use CR
============

- Current approach in my branch/html file.
- Make things easier to use.
- The main (only) problem is how to pass the Hints to the Handler. Using
Handler_Info is handy but means we have 2 code paths to find Hints (sadface).

Use CR
======
- DelegateChannels() and PresentChannel() returns a CR.
- We have to change the description of ChannelRequel.
- Should user call CR.Proceed()?
- What would contain CR.Requests? The properties of the channel(s)?
Comment 14 Guillaume Desmottes 2011-04-07 03:38:37 UTC
Humm I thought about a potential issue with DelegateChannels(). Handlers are
supposed to announce the channels they are handling in Handler.HandledChannels [1].

In practice clients don't have to care as TpBaseClient (or the tp-qt4
equivalent) transparently does it for them. We'll have to make sure that
TpBaseClient is informed when a channel is delegated as it'll have to remove
the channel from the HandledChannels list.
Maybe we should announce that on D-Bus? Another option would be to hook the
tp-glib DelegateChannels API with TpBaseClient but that sounds pretty fragile
a bit hacky to me.

[1] http://telepathy.freedesktop.org/spec/Client_Handler.html#Property:HandledChannels
Comment 15 Guillaume Desmottes 2011-05-04 02:38:28 UTC
(In reply to comment #14)
> Maybe we should announce that on D-Bus? Another option would be to hook the
> tp-glib DelegateChannels API with TpBaseClient

I did that in http://cgit.collabora.co.uk/git/user/cassidy/telepathy-glib/log/?h=re-dispatch-34610 and it worked pretty well (I can now move channels from the Shell to Empathy) so I think that's the way to go.


As the main issue with the spec was to retrive Hints argument, I just removed them. We don't need it for now and I'd rather not stay blocked on this.

New branch: http://cgit.collabora.co.uk/git/user/cassidy/telepathy-spec/log/?id=refs/heads/re-handle-25293

HTML:
http://people.freedesktop.org/~gdesmott/telepathy-spec-re_handle_25293/spec/Channel_Dispatcher.html#Method:DelegateChannels
Comment 16 Will Thompson 2011-05-09 05:02:58 UTC
+        with a Requested_Properties which would result in ensuring
+        Channel.</p>

Generally speaking I mark up argument names with <var/>. But obvs. not a merge blocker.

Yus yus let's do this.
Comment 17 Guillaume Desmottes 2011-05-09 05:28:32 UTC
Merged to master ! Will be in 0.23.1 (I think).


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.