[telepathy-idle/master] Bug #17354 - Emits Send immediately, even if the message is queued

Jonathon Jongsma jonathon.jongsma at collabora.co.uk
Wed May 27 16:29:15 PDT 2009


Contrary to what the bug implies, it was decided that it's OK to emit the 'Sent'
signal immediately even if the message is only queued and is not yet actually
sent.  But there is still a problem in that if the message was long enough to be
split into multiple messages, only one 'Sent' signal is emitted instead of one
for each separate message.

This patch emits a signal for each individual message.
---
 src/idle-text.c                                 |    6 ++--
 tests/twisted/Makefile.am                       |    1 +
 tests/twisted/messages/split-msg-sent-signal.py |   38 +++++++++++++++++++++++
 3 files changed, 42 insertions(+), 3 deletions(-)
 create mode 100644 tests/twisted/messages/split-msg-sent-signal.py

diff --git a/src/idle-text.c b/src/idle-text.c
index fd36671..6f08bd9 100644
--- a/src/idle-text.c
+++ b/src/idle-text.c
@@ -141,13 +141,13 @@ void idle_text_send(GObject *obj, guint type, const gchar *recipient, const gcha
 
 	for(GStrv m = messages; *m != NULL; m++) {
 		idle_connection_send(conn, *m);
+
+		timestamp = time(NULL);
+		tp_svc_channel_type_text_emit_sent(obj, timestamp, type, *m);
 	}
 
 	g_strfreev(messages);
 
-	timestamp = time(NULL);
-	tp_svc_channel_type_text_emit_sent(obj, timestamp, type, text);
-
 	tp_svc_channel_type_text_return_from_send(context);
 }
 
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index b2c1498..b9aa5ab 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -11,6 +11,7 @@ TWISTED_TESTS = \
 		messages/leading-space.py \
 		messages/long-message-split.py \
 		messages/room-contact-mixup.py \
+		messages/split-msg-sent-signal.py \
 		$(NULL)
 
 TESTS =
diff --git a/tests/twisted/messages/split-msg-sent-signal.py b/tests/twisted/messages/split-msg-sent-signal.py
new file mode 100644
index 0000000..217b447
--- /dev/null
+++ b/tests/twisted/messages/split-msg-sent-signal.py
@@ -0,0 +1,38 @@
+"""
+Test that the 'Sent' signal is emitted properly when long messages are split
+into multiple messages
+"""
+
+from idletest import exec_test
+from servicetest import EventPattern, call_async
+import dbus
+
+LONG_MESSAGE='one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one twenty-two twenty-three twenty-four twenty-five twenty-six twenty-seven twenty-eight twenty-nine thirty thirty-one thirty-two thirty-three thirty-four thirty-five thirty-six thirty-seven thirty-eight thirty-nine forty forty-one forty-two forty-three forty-four forty-five forty-six forty-seven forty-eight forty-nine fifty fifty-one fifty-two fifty-three fifty-four fifty-five fifty-six fifty-seven fifty-eight fifty-nine sixty sixty-one sixty-two sixty-three sixty-four sixty-five sixty-six sixty-seven sixty-eight sixty-nine'
+
+def test(q, bus, conn, stream):
+    conn.Connect()
+    q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+    CHANNEL_NAME = '#idletest'
+    room_handles = conn.RequestHandles(2, [CHANNEL_NAME])
+    call_async(q, conn, 'RequestChannel', 'org.freedesktop.Telepathy.Channel.Type.Text', 2, room_handles[0], True)
+
+    ret = q.expect('dbus-return', method='RequestChannel')
+    q.expect('dbus-signal', signal='MembersChanged')
+    chan = bus.get_object(conn.bus_name, ret.value[0])
+
+    text_chan = dbus.Interface(chan,
+        u'org.freedesktop.Telepathy.Channel.Type.Text')
+    # send a whole bunch of messages in a row
+    call_async(q, text_chan, 'Send', 0, LONG_MESSAGE)
+
+    # should emit two Sent signals since the message is long enough to be
+    # split into two messages
+    q.expect('dbus-signal', signal='Sent')
+    q.expect('dbus-signal', signal='Sent')
+
+    call_async(q, conn, 'Disconnect')
+    return True
+
+if __name__ == '__main__':
+    exec_test(test)
+
-- 
1.5.6.5




More information about the telepathy-commits mailing list