summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-05-07 13:04:39 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-05-07 13:04:39 (GMT)
commit7860e69576284f94baa433436c0ae2af6e194c64 (patch)
tree367914422861fd6030825fa4a414d87491f35f9f /Swift/Controllers/Chat
parent48f5bf16ff9e2c8acd095bed521ff7951a8afddf (diff)
downloadswift-7860e69576284f94baa433436c0ae2af6e194c64.zip
swift-7860e69576284f94baa433436c0ae2af6e194c64.tar.bz2
Don't open MUC PMs to different people into the same window
Resolves: #317
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp2
-rw-r--r--Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp37
2 files changed, 37 insertions, 2 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp
index 312af76..a4ade48 100644
--- a/Swift/Controllers/Chat/ChatsManager.cpp
+++ b/Swift/Controllers/Chat/ChatsManager.cpp
@@ -172,7 +172,7 @@ void ChatsManager::handleChatRequest(const String &contact) {
ChatController* ChatsManager::getChatControllerOrFindAnother(const JID &contact) {
ChatController* controller = getChatControllerIfExists(contact);
- if (!controller) {
+ if (!controller && !isMUC(contact.toBare())) {
foreach (JIDChatControllerPair pair, chatControllers_) {
if (pair.first.toBare() == contact.toBare()) {
controller = pair.second;
diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
index f671fb1..99b2f90 100644
--- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
+++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
@@ -26,6 +26,7 @@
#include "Swiften/Queries/DummyIQChannel.h"
#include "Swiften/Presence/PresenceOracle.h"
#include "Swift/Controllers/UIEvents/RequestChatUIEvent.h"
+#include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h"
#include "Swift/Controllers/UIEvents/UIEventStream.h"
@@ -41,6 +42,7 @@ class ChatsManagerTest : public CppUnit::TestFixture
CPPUNIT_TEST(testSecondWindow);
CPPUNIT_TEST(testUnbindRebind);
CPPUNIT_TEST(testNoDuplicateUnbind);
+ CPPUNIT_TEST(testThreeMUCWindows);
CPPUNIT_TEST_SUITE_END();
public:
@@ -58,7 +60,7 @@ public:
nickResolver_ = new NickResolver(xmppRoster_);
presenceOracle_ = new PresenceOracle(stanzaChannel_);
serverDiscoInfo_ = boost::shared_ptr<DiscoInfo>(new DiscoInfo());
- presenceSender_ = NULL;
+ presenceSender_ = new PresenceSender(stanzaChannel_);
uiEventStream_ = new UIEventStream();
chatListWindowFactory_ = mocks_->InterfaceMock<ChatListWindowFactory>();
mocks_->ExpectCall(chatListWindowFactory_, ChatListWindowFactory::createWindow).With(uiEventStream_).Return(NULL);
@@ -198,6 +200,39 @@ public:
}
/**
+ * Test that MUC PMs get opened in the right windows
+ */
+ void testThreeMUCWindows() {
+ JID muc("testling@test.com");
+ ChatWindow* mucWindow = new MockChatWindow();
+ mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(muc, uiEventStream_).Return(mucWindow);
+ uiEventStream_->send(boost::shared_ptr<JoinMUCUIEvent>(new JoinMUCUIEvent(muc, String("nick"))));
+
+
+ String messageJIDString1("testling@test.com/1");
+ ChatWindow* window1 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>();
+ mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString1), uiEventStream_).Return(window1);
+ uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(JID(messageJIDString1))));
+
+ String messageJIDString2("testling@test.com/2");
+ ChatWindow* window2 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>();
+ mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString2), uiEventStream_).Return(window2);
+
+ uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(JID(messageJIDString2))));
+
+ String messageJIDString3("testling@test.com/3");
+ ChatWindow* window3 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>();
+ mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString3), uiEventStream_).Return(window3);
+
+ uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(JID(messageJIDString3))));
+
+ /* Refetch an earlier window */
+ /* We do not expect a new window to be created */
+ uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(JID(messageJIDString1))));
+
+ }
+
+ /**
Test that a second window isn't unbound where there's already an unbound one.
Bind 1
Bind 2