diff options
author | Tobias Markmann <tm@ayena.de> | 2015-01-30 13:56:12 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2015-02-03 17:27:11 (GMT) |
commit | 53c86d070255ae1a33b7a3642bb6eb9ce42e7f70 (patch) | |
tree | f2793fbb216ffcd9b34bde3c8f6d1c419523c214 /Swift/Controllers/Chat | |
parent | 4b2c07264f6cfccf8ed577c9b68b5b237e528be0 (diff) | |
download | swift-53c86d070255ae1a33b7a3642bb6eb9ce42e7f70.zip swift-53c86d070255ae1a33b7a3642bb6eb9ce42e7f70.tar.bz2 |
Fix chat log system messages related to entering a room
In the past MUCController added a "trying to enter..." message and
later tried to replace this with "entered room as..." message. However,
any message received in between, like a system message about room topic,
came in between since MUCController replaced the *last* message added
to the log.
The new code also adds message IDs to system messages. This way the
correct message can be replaced on successful login, no matter how
many messages came in between.
Test-Information:
Tested against a MUC component that send a system message before
sending the join presence back to a user.
Change-Id: I3bcb5d78de680494965d837b2ad3edb847ff7f99
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 11 | ||||
-rw-r--r-- | Swift/Controllers/Chat/MUCController.h | 3 |
2 files changed, 8 insertions, 6 deletions
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 216aab7..e7a5e29 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -345,7 +345,8 @@ void MUCController::handleJoinComplete(const std::string& nick) { joinMessage = str(format(QT_TRANSLATE_NOOP("", "You have entered room %1% as %2%.")) % toJID_.toString() % nick); } setNick(nick); - chatWindow_->replaceLastMessage(chatMessageParser_->parseMessageBody(joinMessage), ChatWindow::UpdateTimestamp); + chatWindow_->replaceSystemMessage(chatMessageParser_->parseMessageBody(joinMessage), lastJoinMessageUID_, ChatWindow::UpdateTimestamp); + lastJoinMessageUID_ = ""; #ifdef SWIFT_EXPERIMENTAL_HISTORY addRecentLogs(); @@ -519,7 +520,7 @@ void MUCController::preHandleIncomingMessage(boost::shared_ptr<MessageEvent> mes joined_ = true; if (message->hasSubject() && message->getBody().empty()) { - chatWindow_->addSystemMessage(chatMessageParser_->parseMessageBody(str(format(QT_TRANSLATE_NOOP("", "The room subject is now: %1%")) % message->getSubject())), ChatWindow::DefaultDirection);; + chatWindow_->addSystemMessage(chatMessageParser_->parseMessageBody(str(format(QT_TRANSLATE_NOOP("", "The room subject is now: %1%")) % message->getSubject())), ChatWindow::DefaultDirection); chatWindow_->setSubject(message->getSubject()); doneGettingHistory_ = true; } @@ -596,9 +597,9 @@ void MUCController::setOnline(bool online) { if (shouldJoinOnReconnect_) { renameCounter_ = 0; if (isImpromptu_) { - chatWindow_->addSystemMessage(chatMessageParser_->parseMessageBody(QT_TRANSLATE_NOOP("", "Trying to join chat")), ChatWindow::DefaultDirection); + lastJoinMessageUID_ = chatWindow_->addSystemMessage(chatMessageParser_->parseMessageBody(QT_TRANSLATE_NOOP("", "Trying to join chat")), ChatWindow::DefaultDirection); } else { - chatWindow_->addSystemMessage(chatMessageParser_->parseMessageBody(str(format(QT_TRANSLATE_NOOP("", "Trying to enter room %1%")) % toJID_.toString())), ChatWindow::DefaultDirection); + lastJoinMessageUID_ = chatWindow_->addSystemMessage(chatMessageParser_->parseMessageBody(str(format(QT_TRANSLATE_NOOP("", "Trying to enter room %1%")) % toJID_.toString())), ChatWindow::DefaultDirection); } if (loginCheckTimer_) { loginCheckTimer_->start(); diff --git a/Swift/Controllers/Chat/MUCController.h b/Swift/Controllers/Chat/MUCController.h index 58d3de7..5f99f1e 100644 --- a/Swift/Controllers/Chat/MUCController.h +++ b/Swift/Controllers/Chat/MUCController.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2014 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -154,6 +154,7 @@ namespace Swift { bool isImpromptu_; bool isImpromptuAlreadyConfigured_; RosterVCardProvider* rosterVCardProvider_; + std::string lastJoinMessageUID_; }; } |