[telepathy-gabble/master] Fake Ringing states on old Jingle dialects
Will Thompson
will.thompson at collabora.co.uk
Wed May 27 06:46:04 PDT 2009
---
src/jingle-session.c | 27 +++++++-
tests/twisted/jingle/call-state.py | 139 +++++++++++++++++++-----------------
2 files changed, 99 insertions(+), 67 deletions(-)
diff --git a/src/jingle-session.c b/src/jingle-session.c
index 414f21d..e34158a 100644
--- a/src/jingle-session.c
+++ b/src/jingle-session.c
@@ -912,6 +912,15 @@ on_session_accept (GabbleJingleSession *sess, LmMessageNode *node,
return;
set_state (sess, JS_STATE_ACTIVE, 0);
+
+ if (priv->dialect != JINGLE_DIALECT_V032)
+ {
+ /* If this is a dialect that doesn't support <active/>, we treat
+ * session-accept as the cue to remove the ringing flag.
+ */
+ priv->remote_ringing = FALSE;
+ g_signal_emit (sess, signals[REMOTE_STATE_CHANGED], 0);
+ }
}
static void
@@ -1640,11 +1649,25 @@ _on_initiate_reply (GObject *sess_as_obj,
LmMessage *reply)
{
GabbleJingleSession *sess = GABBLE_JINGLE_SESSION (sess_as_obj);
+ GabbleJingleSessionPrivate *priv = sess->priv;
if (success)
- set_state (sess, JS_STATE_PENDING_INITIATED, 0);
+ {
+ set_state (sess, JS_STATE_PENDING_INITIATED, 0);
+
+ if (priv->dialect != JINGLE_DIALECT_V032)
+ {
+ /* If this is a dialect that doesn't support <ringing/>, we treat the
+ * session-initiate being acked as the cue to say we're ringing.
+ */
+ priv->remote_ringing = TRUE;
+ g_signal_emit (sess, signals[REMOTE_STATE_CHANGED], 0);
+ }
+ }
else
- set_state (sess, JS_STATE_ENDED, TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+ {
+ set_state (sess, JS_STATE_ENDED, TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+ }
}
static void
diff --git a/tests/twisted/jingle/call-state.py b/tests/twisted/jingle/call-state.py
index 3751c62..e692b46 100644
--- a/tests/twisted/jingle/call-state.py
+++ b/tests/twisted/jingle/call-state.py
@@ -1,6 +1,6 @@
"""
-Test exposing incoming <hold/> and <active/> notifications via the CallState
-interface.
+Test exposing incoming <hold/>, <ringing/> and <active/> notifications via the
+CallState interface.
"""
from twisted.words.xish import xpath
@@ -14,12 +14,6 @@ import constants as cs
from jingletest2 import JingleTest2, test_all_dialects
def test(jp, q, bus, conn, stream):
- # We can only get call state notifications on modern jingle.
- # TODO: but if we fake Hold by changing senders="", we could check for that
- # here.
- if not jp.is_modern_jingle():
- return
-
remote_jid = 'foo at bar.com/Foo'
jt = JingleTest2(jp, conn, q, stream, 'test at localhost', remote_jid)
@@ -61,80 +55,95 @@ def test(jp, q, bus, conn, stream):
jt.set_sid_from_initiate(e.query)
- # The other person's client starts ringing, and tells us so!
- node = jp.SetIq(jt.peer, jt.jid, [
- jp.Jingle(jt.sid, jt.jid, 'session-info', [
- ('ringing', ns.JINGLE_RTP_INFO_1, {}, []) ]) ])
- stream.send(jp.xml(node))
+ if jp.is_modern_jingle():
+ # The other person's client starts ringing, and tells us so!
+ node = jp.SetIq(jt.peer, jt.jid, [
+ jp.Jingle(jt.sid, jt.jid, 'session-info', [
+ ('ringing', ns.JINGLE_RTP_INFO_1, {}, []) ]) ])
+ stream.send(jp.xml(node))
+ # If this is an old Jingle dialect, Gabble should treat the
+ # session-initiate ack as ringing notification; if it's modern Jingle, we
+ # just sent a ringing notification.
q.expect('dbus-signal', signal='CallStateChanged',
args=[handle, cs.CALL_STATE_RINGING])
call_states = chan.CallState.GetCallStates()
assert call_states == { handle: cs.CALL_STATE_RINGING }, call_states
- # We're waiting in a queue, so the other person's client tells us we're on
- # hold. Gabble should ack the IQ, and set the call state to Ringing | Held.
- # Also, Gabble certainly shouldn't tell s-e to start sending. (Although it
- # might tell it not to; we don't mind.)
- node = jp.SetIq(jt.peer, jt.jid, [
- jp.Jingle(jt.sid, jt.jid, 'session-info', [
- ('hold', ns.JINGLE_RTP_INFO_1, {}, []) ]) ])
- stream.send(jp.xml(node))
+ if jp.is_modern_jingle():
+ # We're waiting in a queue, so the other person's client tells us we're on
+ # hold. Gabble should ack the IQ, and set the call state to Ringing | Held.
+ # Also, Gabble certainly shouldn't tell s-e to start sending. (Although it
+ # might tell it not to; we don't mind.)
+ node = jp.SetIq(jt.peer, jt.jid, [
+ jp.Jingle(jt.sid, jt.jid, 'session-info', [
+ ('hold', ns.JINGLE_RTP_INFO_1, {}, []) ]) ])
+ stream.send(jp.xml(node))
+
+ forbidden = [
+ EventPattern('dbus-signal', signal='SetStreamSending', args=[True],
+ path=audio_path_suffix),
+ ]
+ q.forbid_events(forbidden)
+
+ q.expect_many(
+ EventPattern('stream-iq', iq_type='result', iq_id=node[2]['id']),
+ EventPattern('dbus-signal', signal='CallStateChanged',
+ args=[handle, cs.CALL_STATE_RINGING | cs.CALL_STATE_HELD]),
+ )
+
+ call_states = chan.CallState.GetCallStates()
+ assert call_states == { handle: cs.CALL_STATE_RINGING | cs.CALL_STATE_HELD }, call_states
+
+ # We're at the head of a queue, so the other person's client tells us we're
+ # no longer on hold. The call centre phone's still ringing, though. s-e
+ # still shouldn't start sending.
+ node = jp.SetIq(jt.peer, jt.jid, [
+ jp.Jingle(jt.sid, jt.jid, 'session-info', [
+ ('unhold', ns.JINGLE_RTP_INFO_1, {}, []) ]) ])
+ stream.send(jp.xml(node))
+
+ q.expect_many(
+ EventPattern('stream-iq', iq_type='result', iq_id=node[2]['id']),
+ EventPattern('dbus-signal', signal='CallStateChanged',
+ args=[handle, cs.CALL_STATE_RINGING]),
+ )
+
+ call_states = chan.CallState.GetCallStates()
+ assert call_states == { handle: cs.CALL_STATE_RINGING }, call_states
+
+ sync_dbus(bus, q, conn)
+ q.unforbid_events(forbidden)
- forbidden = [
- EventPattern('dbus-signal', signal='SetStreamSending', args=[True],
- path=audio_path_suffix),
- ]
- q.forbid_events(forbidden)
-
- q.expect_many(
- EventPattern('stream-iq', iq_type='result', iq_id=node[2]['id']),
- EventPattern('dbus-signal', signal='CallStateChanged',
- args=[handle, cs.CALL_STATE_RINGING | cs.CALL_STATE_HELD]),
- )
+ jt.accept()
- call_states = chan.CallState.GetCallStates()
- assert call_states == { handle: cs.CALL_STATE_RINGING | cs.CALL_STATE_HELD }, call_states
-
- # We're at the head of a queue, so the other person's client tells us we're
- # no longer on hold. The call centre phone's still ringing, though. s-e
- # still shouldn't start sending.
- node = jp.SetIq(jt.peer, jt.jid, [
- jp.Jingle(jt.sid, jt.jid, 'session-info', [
- ('unhold', ns.JINGLE_RTP_INFO_1, {}, []) ]) ])
- stream.send(jp.xml(node))
+ if jp.is_modern_jingle():
+ # The other person's client decides it's not ringing any more
+ node = jp.SetIq(jt.peer, jt.jid, [
+ jp.Jingle(jt.sid, jt.jid, 'session-info', [
+ ('active', ns.JINGLE_RTP_INFO_1, {}, []) ]) ])
+ stream.send(jp.xml(node))
+ # Gabble tells s-e to start sending, and removes the Ringing flag, either
+ # because we got <active/> or because of the session-accept in ye olde
+ # Jingle.
q.expect_many(
- EventPattern('stream-iq', iq_type='result', iq_id=node[2]['id']),
+ EventPattern('dbus-signal', signal='SetStreamSending', args=[True],
+ path=audio_path_suffix),
EventPattern('dbus-signal', signal='CallStateChanged',
- args=[handle, cs.CALL_STATE_RINGING]),
+ args=[ handle, 0 ]),
)
call_states = chan.CallState.GetCallStates()
- assert call_states == { handle: cs.CALL_STATE_RINGING }, call_states
-
- sync_dbus(bus, q, conn)
- q.unforbid_events(forbidden)
-
- jt.accept()
-
- # Various misc happens; among other things, Gabble tells s-e to start
- # sending.
- q.expect('dbus-signal', signal='SetStreamSending', args=[True],
- path=audio_path_suffix)
-
- # Plus, the other person's client decides it's not ringing any more
- node = jp.SetIq(jt.peer, jt.jid, [
- jp.Jingle(jt.sid, jt.jid, 'session-info', [
- ('active', ns.JINGLE_RTP_INFO_1, {}, []) ]) ])
- stream.send(jp.xml(node))
-
- q.expect('dbus-signal', signal='CallStateChanged', args=[ handle, 0 ])
-
- call_states = chan.CallState.GetCallStates()
assert call_states == { handle: 0 } or call_states == {}, call_states
+ # The rest of the test concerns things we only support in the glorious
+ # modern Jingle future.
+ if not jp.is_modern_jingle():
+ conn.Disconnect()
+ return
+
# The other person puts us on hold. Gabble should ack the session-info IQ,
# tell s-e to stop sending on the held stream, and set the call state.
node = jp.SetIq(jt.peer, jt.jid, [
--
1.5.6.5
More information about the telepathy-commits
mailing list