diff options
author | Joanna Hulboj <joanna.hulboj@isode.com> | 2017-02-15 16:21:26 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2017-02-23 18:07:40 (GMT) |
commit | 3861c418f95555a623d3e8005c75da9b9bbcd1e1 (patch) | |
tree | d8fbfb1bb6a1a3b1c5d620f0e25d41df215467d1 /Swift/Controllers/Chat/MUCController.cpp | |
parent | 8803538bc29a3b68d3c69d900f41ddd1b383cec6 (diff) | |
download | swift-3861c418f95555a623d3e8005c75da9b9bbcd1e1.zip swift-3861c418f95555a623d3e8005c75da9b9bbcd1e1.tar.bz2 |
Change the logic of displaying chat room subject
Test-Information:
Run Swift and join any MUC room, on join there is no information
displayed regarding room subject.
Choose "Change subject", the following information is displayed
in the chat window: "The room subject
has been removed" after the subject was removed, or "The room subject is
now: some subject" after the room subject was set to "some subject".
Run Swift join any MUC room, disconnect from server (using another Swift
client change subject to "Test") after reconnecting the following
information is displayed in chat window: "The room subject is
now: Test"
Change-Id: Ice901697a6a381464d694147b17830b4e62c8198
Diffstat (limited to 'Swift/Controllers/Chat/MUCController.cpp')
-rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 9d1459d..df54d73 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -104,6 +104,8 @@ MUCController::MUCController ( shouldJoinOnReconnect_ = true; doneGettingHistory_ = false; xmppRoster_ = xmppRoster; + subject_ = ""; + isInitialJoin_ = true; roster_ = std::unique_ptr<Roster>(new Roster(false, true)); rosterVCardProvider_ = new RosterVCardProvider(roster_.get(), vcardManager, JID::WithResource); @@ -559,9 +561,13 @@ void MUCController::preHandleIncomingMessage(std::shared_ptr<MessageEvent> messa joined_ = true; if (message->hasSubject() && !message->getPayload<Body>() && !message->getPayload<Thread>()) { - chatWindow_->addSystemMessage(chatMessageParser_->parseMessageBody(str(format(QT_TRANSLATE_NOOP("", "The room subject is now: %1%")) % message->getSubject())), ChatWindow::DefaultDirection); + if (!isInitialJoin_) { + displaySubjectIfChanged(message->getSubject()); + } + isInitialJoin_ = false; chatWindow_->setSubject(message->getSubject()); doneGettingHistory_ = true; + subject_ = message->getSubject(); } if (!doneGettingHistory_ && !message->getPayload<Delay>()) { @@ -1216,4 +1222,16 @@ void MUCController::updateChatWindowBookmarkStatus(const boost::optional<MUCBook } } +void MUCController::displaySubjectIfChanged(const std::string& subject) { + if (subject_ != subject) { + if (!subject.empty()) { + chatWindow_->addSystemMessage(chatMessageParser_->parseMessageBody(str(format(QT_TRANSLATE_NOOP("", "The room subject is now: %1%")) % subject)), ChatWindow::DefaultDirection); + } + else { + chatWindow_->addSystemMessage(chatMessageParser_->parseMessageBody(str(format(QT_TRANSLATE_NOOP("", "The room subject has been removed")))), ChatWindow::DefaultDirection); + } + subject_ = subject; + } +} + } |