diff options
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 4 | ||||
-rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 30 | ||||
-rw-r--r-- | Swift/Controllers/Chat/MUCController.h | 3 | ||||
-rw-r--r-- | Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp | 17 | ||||
-rw-r--r-- | Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp | 7 |
5 files changed, 33 insertions, 28 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 9db343f..d9f80ba 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -877,2 +877,6 @@ MUC::ref ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::opti } + auto chatListWindowIter = std::find_if(recentChats_.begin(), recentChats_.end(), [&](const ChatListWindow::Chat& chatListWindow) { return mucJID == (chatListWindow.jid); }); + if (chatListWindowIter != recentChats_.end()) { + mucControllers_[mucJID]->setChatWindowTitle(chatListWindowIter->getTitle()); + } diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index fd3dc37..d10e6d4 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -112,2 +112,3 @@ MUCController::MUCController ( isInitialJoin_ = true; + chatWindowTitle_ = ""; @@ -408,6 +409,2 @@ void MUCController::handleJoinComplete(const std::string& nick) { onUserJoined(); - - if (isImpromptu_) { - setImpromptuWindowTitle(); - } } @@ -466,3 +463,2 @@ void MUCController::handleOccupantJoined(const MUCOccupant& occupant) { if (isImpromptu_) { - setImpromptuWindowTitle(); onActivity(""); @@ -771,6 +767,2 @@ void MUCController::handleOccupantLeft(const MUCOccupant& occupant, MUC::Leaving } - - if (isImpromptu_) { - setImpromptuWindowTitle(); - } } @@ -1180,17 +1172,2 @@ Form::ref MUCController::buildImpromptuRoomConfiguration(Form::ref roomConfigura -void MUCController::setImpromptuWindowTitle() { - std::string title; - std::map<std::string, MUCOccupant> occupants = muc_->getOccupants(); - if (occupants.size() <= 1) { - title = QT_TRANSLATE_NOOP("", "Empty Chat"); - } else { - for (const auto& pair : occupants) { - if (pair.first != nick_) { - title += (title.empty() ? "" : ", ") + pair.first; - } - } - } - chatWindow_->setName(title); -} - void MUCController::handleRoomUnlocked() { @@ -1263,2 +1240,7 @@ void MUCController::addChatSystemMessage() { +void MUCController::setChatWindowTitle(const std::string& title) { + chatWindowTitle_ = title; + chatWindow_->setName(chatWindowTitle_); +} + } diff --git a/Swift/Controllers/Chat/MUCController.h b/Swift/Controllers/Chat/MUCController.h index b8f2aac..258eaaf 100644 --- a/Swift/Controllers/Chat/MUCController.h +++ b/Swift/Controllers/Chat/MUCController.h @@ -75,2 +75,3 @@ namespace Swift { void sendInvites(const std::vector<JID>& jids, const std::string& reason) const; + void setChatWindowTitle(const std::string& title); @@ -136,3 +137,2 @@ namespace Swift { void setNick(const std::string& nick); - void setImpromptuWindowTitle(); void handleRoomUnlocked(); @@ -189,2 +189,3 @@ namespace Swift { bool isInitialJoin_; + std::string chatWindowTitle_; }; diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp index 52537a9..20c959c 100644 --- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp @@ -154,2 +154,3 @@ class ChatsManagerTest : public CppUnit::TestFixture { CPPUNIT_TEST(testImpromptuChatTitle); + CPPUNIT_TEST(testImpromptuChatWindowTitle); @@ -1513,3 +1514,3 @@ public: - void testImpromptuChatTitle() { + void impromptuChatSetup(MockChatWindow* window) { stanzaChannel_->uniqueIDs_ = true; @@ -1518,4 +1519,2 @@ public: - // Open chat window to a sender. - MockChatWindow* window = new MockChatWindow(); std::shared_ptr<IQ> infoRequest = std::dynamic_pointer_cast<IQ>(stanzaChannel_->sentStanzas[1]); @@ -1571,3 +1570,8 @@ public: } + } + void testImpromptuChatTitle() { + // Open a new chat window to a sender. + MockChatWindow* window = new MockChatWindow(); + impromptuChatSetup(window); // After people joined, the title is the list of participant nicknames or names coming from Roster (if nicknames are unavailable) @@ -1576,2 +1580,9 @@ public: + void testImpromptuChatWindowTitle() { + // Open a new chat window to a sender. + MockChatWindow* window = new MockChatWindow(); + impromptuChatSetup(window); + // After people joined, the title of chat window is combined of participant nicknames or names coming from Roster (if nicknames are unavailable) + CPPUNIT_ASSERT_EQUAL(std::string("bar@test.com, foo@test.com"), window->name_); + } diff --git a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp index e7b4b3e..1f69f4f 100644 --- a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp @@ -67,2 +67,5 @@ class MUCControllerTest : public CppUnit::TestFixture { CPPUNIT_TEST(testHandleChangeSubjectRequest); + + CPPUNIT_TEST(testNonImpromptuMUCWindowTitle); + CPPUNIT_TEST_SUITE_END(); @@ -588,2 +591,6 @@ public: + void testNonImpromptuMUCWindowTitle() { + CPPUNIT_ASSERT_EQUAL(muc_->getJID().getNode(), window_->name_); + } + private: |