Bug 56044

Summary: tp_base_call_channel_hangup: Only set_state to ENDED if not set
Product: Telepathy Reporter: Debarshi Ray <rishi.is>
Component: tp-glibAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium CC: xclaesse
Version: git master   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: DBus log
base-call-channel: Set state to ENDED in hangup only if not set
base-call-channel: Ignore spurious transitions
base-call-channel: Ignore transitions with same flags and state
base-call-channel: Ignore transitions with the same state
base-call-channel: Don't call set_state from set_ringing and set_queued
base-call-channel: Ignore transitions with the same state

Description Debarshi Ray 2012-10-16 18:28:05 UTC
Created attachment 68639 [details]
DBus log

Gabble's implementation of the hangup virtual method sets the state to TP_CALL_STATE_ENDED. See call_session_terminated_cb in telepathy-gabble.

This causes an extra CallStateChanged signal to be emitted on the bus. See attached log.
Comment 1 Debarshi Ray 2012-10-16 18:36:26 UTC
Created attachment 68640 [details] [review]
base-call-channel: Set state to ENDED in hangup only if not set

Against telepathy-glib-0.20 branch.

(I am wondering why tp_base_call_channel_set_state does not check and ignore transitions where the current and destination states are the same.)
Comment 2 Debarshi Ray 2012-10-17 09:28:36 UTC
Created attachment 68678 [details] [review]
base-call-channel: Ignore spurious transitions

Against telepathy-glib-0.20 branch.

Lets make tp_base_call_channel_set_state check and ignore this, as hinted earlier.

--

However, this causes the following failure in tp-gabble's test suite:
Traceback (most recent call last):
  File "/home/rishi/devel/telepathy/git/telepathy-gabble/tests/twisted/gabbletest.py", line 634, in exec_test_deferred
    fun(queue, bus, conns[0], streams[0])
  File "/home/rishi/devel/telepathy/git/telepathy-gabble/tests/twisted/jingle/call_helper.py", line 809, in run_call_test
    test.run()
  File "/home/rishi/devel/telepathy/git/telepathy-gabble/tests/twisted/jingle/call_helper.py", line 802, in run
    self.pickup()
  File "./jingle/call-basics.py", line 116, in pickup
    CallTest.pickup(self)
  File "/home/rishi/devel/telepathy/git/telepathy-gabble/tests/twisted/jingle/call_helper.py", line 644, in pickup
    signal = self.q.expect('dbus-signal', signal='CallStateChanged')
  File "/home/rishi/devel/telepathy/git/telepathy-gabble/tests/twisted/servicetest.py", line 173, in expect
    event = self.wait([pattern.subqueue])
  File "/home/rishi/devel/telepathy/git/telepathy-gabble/tests/twisted/servicetest.py", line 307, in wait
    raise TimeoutError
TimeoutError
FAIL: jingle/call-basics.py
Comment 3 Xavier Claessens 2012-10-17 10:03:49 UTC
In tp_base_call_channel_set_state() the 2 if conditions at the end actually check if self->priv->state != old_state, which indicate there were a reason for not early return.

It's probably me who wrote that, but I rekon I don't remember the reason. A failing unit test seems to also indicate that there is a reason for not early returning. Olivier may know, I'll ask him.
Comment 4 Xavier Claessens 2012-10-17 10:11:08 UTC
Ok, reading the unit test, I actually see the reason (good think this is all well tested). So in tp_base_call_channel_set_ringing() we call tp_base_call_channel_set_state() not to change the state, but to add the RINGING flag. This actually makes sense, the state of the call did not actually change, but the UI is reporting that it is now playing ringing sound.
Comment 5 Debarshi Ray 2012-10-17 12:12:43 UTC
Created attachment 68689 [details] [review]
base-call-channel: Ignore transitions with same flags and state

Compare the flags too and special case TP_CALL_FLAG_LOCALLY_RINGING.
Comment 6 Debarshi Ray 2012-10-17 12:57:48 UTC
Created attachment 68700 [details] [review]
base-call-channel: Ignore transitions with the same state
Comment 7 Debarshi Ray 2012-10-17 12:58:21 UTC
Created attachment 68701 [details] [review]
base-call-channel: Don't call set_state from set_ringing and set_queued
Comment 8 Debarshi Ray 2012-10-17 13:53:17 UTC
Created attachment 68707 [details] [review]
base-call-channel: Ignore transitions with the same state
Comment 9 Xavier Claessens 2012-10-17 14:01:32 UTC
Looks good, ship it :)

Thanks.
Comment 10 Debarshi Ray 2012-10-17 15:01:56 UTC
Pushed to both master and telepathy-glib-0.20 branches.

commit 48a6895f21fd3a3ef996e3e18ded4ed8a8f9f576
Author: Debarshi Ray <rishi@gnu.org>
Date:   Wed Oct 17 14:48:11 2012 +0200

    base-call-channel: Don't call set_state from set_ringing and set_queued
    
    ... because they only change the flags and not the state. Instead emit
    CallStateChanged directly.
    
    Fixes: https://bugs.freedesktop.org/56044

commit dfca38a93e2c504c1a4643eec291c4ddb4368f4f
Author: Debarshi Ray <rishi@gnu.org>
Date:   Wed Oct 17 10:50:24 2012 +0200

    base-call-channel: Ignore transitions with the same state
    
    Fixes: https://bugs.freedesktop.org/56044

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.