summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathon Jongsma <jonathon.jongsma@collabora.co.uk>2009-02-13 19:39:19 -0600
committerJonathon Jongsma <jonathon.jongsma@collabora.co.uk>2009-02-13 19:39:19 -0600
commit6933765064960d84c71747873851393ed88f4c9b (patch)
treee3acfb33dcc9ccd5343b776e982978cc3e7847cf
parentad2a004f8aa490f756708c42b0d8b1f1759584c1 (diff)
parentd471f42675222cce620a219b36791e7f0e69bb5f (diff)
Merge branch 'room-contact-mixup'
-rw-r--r--src/idle-handles.c6
-rw-r--r--tests/twisted/Makefile.am1
-rw-r--r--tests/twisted/channels/join-muc-channel.py2
-rw-r--r--tests/twisted/connect/connect-success-ssl.py2
-rw-r--r--tests/twisted/connect/connect-success.py2
-rw-r--r--tests/twisted/messages/leading-space.py2
-rw-r--r--tests/twisted/messages/message-order.py12
-rw-r--r--tests/twisted/messages/room-contact-mixup.py88
8 files changed, 94 insertions, 21 deletions
diff --git a/src/idle-handles.c b/src/idle-handles.c
index 2dd9ea3..d89b32a 100644
--- a/src/idle-handles.c
+++ b/src/idle-handles.c
@@ -121,12 +121,6 @@ static gchar *_nick_normalize_func(TpHandleRepoIface *repo, const gchar *id, gpo
static gchar *_channel_normalize_func(TpHandleRepoIface *repo, const gchar *id, gpointer ctx, GError **error) {
gchar *channel = g_strdup(id);
- if ((channel[0] != '#') && (channel[0] != '!') && (channel[0] != '&') && (channel[0] != '+')) {
- gchar *tmp = channel;
- channel = g_strdup_printf("#%s", channel);
- g_free(tmp);
- }
-
if (!_channelname_is_valid(channel)) {
g_set_error(error, TP_ERRORS, TP_ERROR_INVALID_HANDLE, "invalid channel ID");
return NULL;
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index b6070c2..6084e28 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -8,6 +8,7 @@ TWISTED_TESTS = \
channels/join-muc-channel.py \
messages/message-order.py \
messages/leading-space.py \
+ messages/room-contact-mixup.py \
$(NULL)
TESTS =
diff --git a/tests/twisted/channels/join-muc-channel.py b/tests/twisted/channels/join-muc-channel.py
index 126b59c..7e2e73b 100644
--- a/tests/twisted/channels/join-muc-channel.py
+++ b/tests/twisted/channels/join-muc-channel.py
@@ -36,5 +36,5 @@ def test(q, bus, conn, stream):
return True
if __name__ == '__main__':
- exec_test(test, timeout=10)
+ exec_test(test)
diff --git a/tests/twisted/connect/connect-success-ssl.py b/tests/twisted/connect/connect-success-ssl.py
index 3cf04e8..627eeb8 100644
--- a/tests/twisted/connect/connect-success-ssl.py
+++ b/tests/twisted/connect/connect-success-ssl.py
@@ -23,5 +23,5 @@ def test(q, bus, conn, stream):
return True
if __name__ == '__main__':
- exec_test(test, {'use-ssl':dbus.Boolean(True)}, protocol=SSLIRCServer, timeout=10)
+ exec_test(test, {'use-ssl':dbus.Boolean(True)}, protocol=SSLIRCServer)
diff --git a/tests/twisted/connect/connect-success.py b/tests/twisted/connect/connect-success.py
index 9ef189b..3281764 100644
--- a/tests/twisted/connect/connect-success.py
+++ b/tests/twisted/connect/connect-success.py
@@ -22,5 +22,5 @@ def test(q, bus, conn, stream):
return True
if __name__ == '__main__':
- exec_test(test, timeout=10)
+ exec_test(test)
diff --git a/tests/twisted/messages/leading-space.py b/tests/twisted/messages/leading-space.py
index a621993..ce24c76 100644
--- a/tests/twisted/messages/leading-space.py
+++ b/tests/twisted/messages/leading-space.py
@@ -51,5 +51,5 @@ def test(q, bus, conn, stream):
return True
if __name__ == '__main__':
- exec_test(test, timeout=10, protocol=LeadingSpaceIRCServer)
+ exec_test(test, protocol=LeadingSpaceIRCServer)
diff --git a/tests/twisted/messages/message-order.py b/tests/twisted/messages/message-order.py
index 68dfd11..b2259ca 100644
--- a/tests/twisted/messages/message-order.py
+++ b/tests/twisted/messages/message-order.py
@@ -28,26 +28,16 @@ def test(q, bus, conn, stream):
call_async(q, text_chan, 'Send', 0, '2')
call_async(q, text_chan, 'Send', 0, '3')
call_async(q, text_chan, 'Send', 0, '4')
- call_async(q, text_chan, 'Send', 0, '5')
- call_async(q, text_chan, 'Send', 0, '6')
- call_async(q, text_chan, 'Send', 0, '7')
- call_async(q, text_chan, 'Send', 0, '8')
- call_async(q, text_chan, 'Send', 0, '9')
q.expect('irc-privmsg', data={'message':'0','recipient':CHANNEL_NAME})
q.expect('irc-privmsg', data={'message':'1','recipient':CHANNEL_NAME})
q.expect('irc-privmsg', data={'message':'2','recipient':CHANNEL_NAME})
q.expect('irc-privmsg', data={'message':'3','recipient':CHANNEL_NAME})
q.expect('irc-privmsg', data={'message':'4','recipient':CHANNEL_NAME})
- q.expect('irc-privmsg', data={'message':'5','recipient':CHANNEL_NAME})
- q.expect('irc-privmsg', data={'message':'6','recipient':CHANNEL_NAME})
- q.expect('irc-privmsg', data={'message':'7','recipient':CHANNEL_NAME})
- q.expect('irc-privmsg', data={'message':'8','recipient':CHANNEL_NAME})
- q.expect('irc-privmsg', data={'message':'9','recipient':CHANNEL_NAME})
call_async(q, conn, 'Disconnect')
return True
if __name__ == '__main__':
- exec_test(test, timeout=10)
+ exec_test(test)
diff --git a/tests/twisted/messages/room-contact-mixup.py b/tests/twisted/messages/room-contact-mixup.py
new file mode 100644
index 0000000..dfd116f
--- /dev/null
+++ b/tests/twisted/messages/room-contact-mixup.py
@@ -0,0 +1,88 @@
+
+"""
+Regression test for a bug where, if you were in a IRC channel that had the same
+name as your nickname (e.g. user 'foo' in room '#foo'), all private 1:1 messages
+to foo would appear to also be coming through room #foo as well (bug #19766)
+"""
+
+from idletest import exec_test, BaseIRCServer
+from servicetest import EventPattern, call_async, TimeoutError, sync_dbus
+import dbus
+
+
+HANDLE_TYPE_CONTACT=1
+HANDLE_TYPE_ROOM=2
+
+# same nick and channel
+CHANNEL = '#foo'
+NICK = 'foo'
+REMOTEUSER = 'remoteuser'
+
+class CustomIRCServer(BaseIRCServer):
+
+ def handlePRIVMSG(self, args, prefix):
+ #chain up to the base class implementation which simply signals a privmsg event
+ BaseIRCServer.handlePRIVMSG(self, args, prefix)
+ sender = prefix
+ recipient = args[0]
+ if (recipient == REMOTEUSER):
+ # auto-reply with a private message
+ self.sendMessage('PRIVMSG', self.nick, ':PRIVATE', prefix=REMOTEUSER)
+ elif (recipient == self.room):
+ # auto-reply to the group
+ self.sendMessage('PRIVMSG', self.room, ':GROUP', prefix=REMOTEUSER)
+
+ def handleJOIN(self, args, prefix):
+ self.room = args[0]
+ self.sendMessage('JOIN', self.room, prefix=self.nick)
+ self._sendNameReply(self.room, [self.nick, REMOTEUSER])
+
+group_received_flag = False;
+def group_received_cb(id, timestamp, sender, type, flags, text):
+ global group_received_flag
+ group_received_flag = True
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+ q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+
+ # join a chat room with the same name as our nick
+ room_handles = conn.RequestHandles(HANDLE_TYPE_ROOM, [CHANNEL])
+ call_async(q, conn, 'RequestChannel',
+ 'org.freedesktop.Telepathy.Channel.Type.Text', HANDLE_TYPE_ROOM,
+ room_handles[0], True)
+ # wait for the join to finish
+ ret = q.expect('dbus-return', method='RequestChannel')
+ chan = bus.get_object(conn.bus_name, ret.value[0])
+ group_text_chan = dbus.Interface(chan,
+ u'org.freedesktop.Telepathy.Channel.Type.Text')
+ group_text_chan.connect_to_signal('Received', group_received_cb)
+ q.expect('dbus-signal', signal='MembersChanged')
+
+ # now request a private chat channel with the remote contact
+ contact_handles = conn.RequestHandles(HANDLE_TYPE_CONTACT, [REMOTEUSER])
+ chan_path = conn.RequestChannel('org.freedesktop.Telepathy.Channel.Type.Text',
+ HANDLE_TYPE_CONTACT, contact_handles[0], True)
+ chan = bus.get_object(conn.bus_name, chan_path)
+ priv_text_chan = dbus.Interface(chan,
+ u'org.freedesktop.Telepathy.Channel.Type.Text')
+
+ # send a private chat message -- the test server is rigged to send a private
+ # chat response
+ call_async(q, priv_text_chan, 'Send', 0, 'foo')
+ q.expect('irc-privmsg', data={'message': 'foo', 'recipient': REMOTEUSER})
+ event = q.expect('dbus-signal', signal='Received',
+ predicate=lambda x: x.args[5]=='PRIVATE' and 'ImChannel' in x.path)
+
+ # verify that we didn't receive a 'Received' D-Bus signal on the group text
+ # channel
+ global group_received_flag
+ sync_dbus(bus, q, conn)
+ assert group_received_flag == False
+
+ call_async(q, conn, 'Disconnect')
+ return True
+
+if __name__ == '__main__':
+ exec_test(test, {'account':NICK}, protocol=CustomIRCServer)
+