summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-06-10 10:59:04 (GMT)
committerKevin Smith <kevin.smith@isode.com>2016-07-01 12:18:48 (GMT)
commitb16a2d1483f59ad93a2171c6c286e12f4ebbf3be (patch)
treef49c9ba36649797070a84955423e4611dae7dd8a /Swift/Controllers/UnitTest/MockChatWindow.h
parenta1be6105b97dddc1e03db0075f6ca3fc47fa8e1d (diff)
downloadswift-b16a2d1483f59ad93a2171c6c286e12f4ebbf3be.zip
swift-b16a2d1483f59ad93a2171c6c286e12f4ebbf3be.tar.bz2
Implement Message Carbons in Swift and Swift/Controllers
If the server supports message carbons, Swift will try to enable it. Carbon copied messages will open a chat window in the background if no chat window exists for the conversation. Test-Information: Tested with a XMPP server Swift and a mobile Android client all supporting message carbons. Tested direct messages and MUC PM messages. All working as expected. Added unit tests for message carbons of sent messages and message carbons of received messages. All unit tests pass on OS X 10.11.5 Change-Id: I8d5b5d9975651a2353909dea976f58e4bf12e014
Diffstat (limited to 'Swift/Controllers/UnitTest/MockChatWindow.h')
-rw-r--r--Swift/Controllers/UnitTest/MockChatWindow.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h
index 4f874e1..d7942ff 100644
--- a/Swift/Controllers/UnitTest/MockChatWindow.h
+++ b/Swift/Controllers/UnitTest/MockChatWindow.h
@@ -7,8 +7,7 @@
#pragma once
#include <memory>
-
-#include <Swiften/Base/foreach.h>
+#include <string>
#include <Swift/Controllers/UIInterfaces/ChatWindow.h>
@@ -18,13 +17,17 @@ namespace Swift {
MockChatWindow() : labelsEnabled_(false), impromptuMUCSupported_(false) {}
virtual ~MockChatWindow();
- virtual std::string addMessage(const ChatMessage& message, const std::string& /*senderName*/, bool /*senderIsSelf*/, std::shared_ptr<SecurityLabel> /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime& /*time*/) {
+ virtual std::string addMessage(const ChatMessage& message, const std::string& senderName, bool senderIsSelf, std::shared_ptr<SecurityLabel> /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime& /*time*/) {
lastAddedMessage_ = message;
+ lastAddedMessageSenderName_ = senderName;
+ lastAddedMessageSenderIsSelf_ = senderIsSelf;
return "id";
}
- virtual std::string addAction(const ChatMessage& message, const std::string& /*senderName*/, bool /*senderIsSelf*/, std::shared_ptr<SecurityLabel> /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime& /*time*/) {
+ virtual std::string addAction(const ChatMessage& message, const std::string& senderName, bool senderIsSelf, std::shared_ptr<SecurityLabel> /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime& /*time*/) {
lastAddedAction_ = message;
+ lastAddedActionSenderName_ = senderName;
+ lastAddedActionSenderIsSelf_ = senderIsSelf;
return "id";
}
@@ -52,7 +55,9 @@ namespace Swift {
virtual void setFileTransferProgress(std::string /*id*/, const int /*alreadyTransferedBytes*/) { }
virtual void setFileTransferStatus(std::string /*id*/, const FileTransferState /*state*/, const std::string& /*msg*/) { }
- virtual void setMessageReceiptState(const std::string &/* id */, ReceiptState /* state */) { }
+ virtual void setMessageReceiptState(const std::string & id, ReceiptState state) {
+ receiptChanges_.emplace_back(id, state);
+ }
virtual void setContactChatState(ChatState::ChatStateType /*state*/) {}
virtual void setName(const std::string& name) {name_ = name;}
@@ -101,7 +106,7 @@ namespace Swift {
std::string body;
std::shared_ptr<ChatTextMessagePart> text;
std::shared_ptr<ChatHighlightingMessagePart> highlight;
- foreach (std::shared_ptr<ChatMessagePart> part, message.getParts()) {
+ for (auto &&part : message.getParts()) {
if ((text = std::dynamic_pointer_cast<ChatTextMessagePart>(part))) {
body += text->text;
}
@@ -114,11 +119,17 @@ namespace Swift {
void resetLastMessages() {
lastAddedMessage_ = lastAddedAction_ = lastAddedPresence_ = lastReplacedMessage_ = lastAddedSystemMessage_ = lastReplacedSystemMessage_ = ChatMessage();
+ lastAddedMessageSenderName_ = lastAddedActionSenderName_ = "";
+ lastAddedMessageSenderIsSelf_ = lastAddedActionSenderIsSelf_ = false;
}
std::string name_;
ChatMessage lastAddedMessage_;
+ std::string lastAddedMessageSenderName_;
+ bool lastAddedMessageSenderIsSelf_;
ChatMessage lastAddedAction_;
+ std::string lastAddedActionSenderName_;
+ bool lastAddedActionSenderIsSelf_;
ChatMessage lastAddedPresence_;
ChatMessage lastReplacedMessage_;
ChatMessage lastAddedSystemMessage_;
@@ -129,6 +140,7 @@ namespace Swift {
bool impromptuMUCSupported_;
SecurityLabelsCatalog::Item label_;
Roster* roster_;
+ std::vector<std::pair<std::string, ReceiptState>> receiptChanges_;
};
}