summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-01-12 17:23:05 (GMT)
committerKevin Smith <kevin.smith@isode.com>2016-02-02 11:33:06 (GMT)
commit1b9ccc1fef6104eaf951153ddccdc6bb15899e9a (patch)
tree428232448e9846265605820db6f380a5b98c018a /Swift/Controllers/Chat/MUCController.cpp
parent3afd061b713ce5fff604dee62dec8410a1de6a9c (diff)
downloadswift-1b9ccc1fef6104eaf951153ddccdc6bb15899e9a.zip
swift-1b9ccc1fef6104eaf951153ddccdc6bb15899e9a.tar.bz2
Change stanza body to boost::optional<std::string> type
Changed MUCController to only handle message stanzas as subject change if <subject/> is present and neither <body/> nor <thread/> is present in the message stanza. Test-Information: Added unit tests verifying behavior described in XEP-0045 section 8.1. Unit tests pass on OS X 10.11.2. Change-Id: I1d22272da1675176be131ab360b214a98f20533f
Diffstat (limited to 'Swift/Controllers/Chat/MUCController.cpp')
-rw-r--r--Swift/Controllers/Chat/MUCController.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp
index e6c16b7..409fe1f 100644
--- a/Swift/Controllers/Chat/MUCController.cpp
+++ b/Swift/Controllers/Chat/MUCController.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2015 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -22,6 +22,7 @@
#include <Swiften/Client/StanzaChannel.h>
#include <Swiften/Disco/EntityCapsProvider.h>
#include <Swiften/Elements/Delay.h>
+#include <Swiften/Elements/Thread.h>
#include <Swiften/MUC/MUC.h>
#include <Swiften/MUC/MUCBookmark.h>
#include <Swiften/MUC/MUCBookmarkManager.h>
@@ -531,7 +532,7 @@ JID MUCController::nickToJID(const std::string& nick) {
bool MUCController::messageTargetsMe(boost::shared_ptr<Message> message) {
std::string stringRegexp(".*\\b" + boost::to_lower_copy(nick_) + "\\b.*");
boost::regex myRegexp(stringRegexp);
- return boost::regex_match(boost::to_lower_copy(message->getBody()), myRegexp);
+ return boost::regex_match(boost::to_lower_copy(message->getBody().get_value_or("")), myRegexp);
}
void MUCController::preHandleIncomingMessage(boost::shared_ptr<MessageEvent> messageEvent) {
@@ -559,7 +560,7 @@ void MUCController::preHandleIncomingMessage(boost::shared_ptr<MessageEvent> mes
receivedActivity();
joined_ = true;
- if (message->hasSubject() && message->getBody().empty()) {
+ 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);
chatWindow_->setSubject(message->getSubject());
doneGettingHistory_ = true;
@@ -1078,7 +1079,7 @@ void MUCController::addRecentLogs() {
}
void MUCController::checkDuplicates(boost::shared_ptr<Message> newMessage) {
- std::string body = newMessage->getBody();
+ std::string body = newMessage->getBody().get_value_or("");
JID jid = newMessage->getFrom();
boost::optional<boost::posix_time::ptime> time = newMessage->getTimestamp();