diff options
author | Tobias Markmann <tm@ayena.de> | 2017-03-14 15:44:38 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2017-03-14 15:44:38 (GMT) |
commit | 3368a6e5f220f00e03b3ebb41bdd8872ffdf81be (patch) | |
tree | 55d8a8745028f6765f53311d1f14ddf4dbc24691 /Swift/Controllers/Chat | |
parent | 37057bc3168b43906dd67e51607a893ae1c490af (diff) | |
download | swift-3368a6e5f220f00e03b3ebb41bdd8872ffdf81be.zip swift-3368a6e5f220f00e03b3ebb41bdd8872ffdf81be.tar.bz2 |
Show correct avatars for file-transfer messages
Previously we simply showed our default avatar. With this
change we will use the same avatar as we use for normal
chat messages.
Test-Information:
Tested on macOS 10.12.3 with Qt 5.5.1 by exchanging files
between two Swift instances.
Change-Id: I20b953a67a290820900b5b35861c1e17f72148bd
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r-- | Swift/Controllers/Chat/ChatController.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index d1cd1fe..9cef9fc 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -1,45 +1,46 @@ /* * Copyright (c) 2010-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/Controllers/Chat/ChatController.h> #include <memory> #include <boost/bind.hpp> #include <Swiften/Avatars/AvatarManager.h> #include <Swiften/Base/Algorithm.h> #include <Swiften/Base/Log.h> +#include <Swiften/Base/Path.h> #include <Swiften/Base/format.h> #include <Swiften/Chat/ChatStateNotifier.h> #include <Swiften/Chat/ChatStateTracker.h> #include <Swiften/Client/ClientBlockListManager.h> #include <Swiften/Client/NickResolver.h> #include <Swiften/Client/StanzaChannel.h> #include <Swiften/Disco/EntityCapsProvider.h> #include <Swiften/Disco/FeatureOracle.h> #include <Swiften/Elements/DeliveryReceipt.h> #include <Swiften/Elements/DeliveryReceiptRequest.h> #include <Swiften/Elements/Idle.h> #include <Swiften/FileTransfer/FileTransferManager.h> #include <Swift/Controllers/Chat/ChatMessageParser.h> #include <Swift/Controllers/FileTransfer/FileTransferController.h> #include <Swift/Controllers/Highlighting/Highlighter.h> #include <Swift/Controllers/Intl.h> #include <Swift/Controllers/SettingConstants.h> #include <Swift/Controllers/StatusUtil.h> #include <Swift/Controllers/Translator.h> #include <Swift/Controllers/UIEvents/AcceptWhiteboardSessionUIEvent.h> #include <Swift/Controllers/UIEvents/CancelWhiteboardSessionUIEvent.h> #include <Swift/Controllers/UIEvents/InviteToMUCUIEvent.h> #include <Swift/Controllers/UIEvents/RequestChangeBlockStateUIEvent.h> #include <Swift/Controllers/UIEvents/RequestInviteToMUCUIEvent.h> #include <Swift/Controllers/UIEvents/SendFileUIEvent.h> #include <Swift/Controllers/UIEvents/ShowWhiteboardUIEvent.h> #include <Swift/Controllers/UIEvents/UIEventStream.h> #include <Swift/Controllers/UIInterfaces/ChatWindowFactory.h> #include <Swift/Controllers/XMPPEvents/EventController.h> @@ -341,61 +342,69 @@ void ChatController::postSendMessage(const std::string& body, std::shared_ptr<St lastWasPresence_ = false; chatStateNotifier_->userSentMessage(); } void ChatController::handleStanzaAcked(std::shared_ptr<Stanza> stanza) { std::map<std::shared_ptr<Stanza>, std::string>::iterator unackedStanza = unackedStanzas_.find(stanza); if (unackedStanza != unackedStanzas_.end()) { chatWindow_->setAckState(unackedStanza->second, ChatWindow::Received); unackedStanzas_.erase(unackedStanza); } } void ChatController::setOnline(bool online) { if (!online) { for (auto& stanzaIdPair : unackedStanzas_) { chatWindow_->setAckState(stanzaIdPair.second, ChatWindow::Failed); } unackedStanzas_.clear(); Presence::ref fakeOffline(new Presence()); fakeOffline->setFrom(toJID_); fakeOffline->setType(Presence::Unavailable); chatStateTracker_->handlePresenceChange(fakeOffline); } ChatControllerBase::setOnline(online); } void ChatController::handleNewFileTransferController(FileTransferController* ftc) { std::string nick = senderDisplayNameFromMessage(ftc->getOtherParty()); - std::string ftID = ftc->setChatWindow(chatWindow_, nick); + std::string avatarPath; + if (ftc->isIncoming()) { + avatarPath = pathToString(avatarManager_->getAvatarPath(ftc->getOtherParty())); + } + else { + avatarPath = pathToString(avatarManager_->getAvatarPath(selfJID_)); + } + + std::string ftID = ftc->setChatWindow(chatWindow_, nick, avatarPath); ftControllers[ftID] = ftc; lastWasPresence_ = false; if (ftc->isIncoming()) { auto incomingFileTransferEvent = std::make_shared<IncomingFileTransferEvent>(ftc->getOtherParty()); if (hasOpenWindow()) { incomingFileTransferEvent->conclude(); } else { unreadMessages_.push_back(incomingFileTransferEvent); updateMessageCount(); } eventController_->handleIncomingEvent(incomingFileTransferEvent); } } void ChatController::handleWhiteboardSessionRequest(bool senderIsSelf) { lastWbID_ = chatWindow_->addWhiteboardRequest(senderIsSelf); } void ChatController::handleWhiteboardStateChange(const ChatWindow::WhiteboardSessionState state) { chatWindow_->setWhiteboardSessionStatus(lastWbID_, state); } void ChatController::handleFileTransferCancel(std::string id) { SWIFT_LOG(debug) << "handleFileTransferCancel(" << id << ")" << std::endl; if (ftControllers.find(id) != ftControllers.end()) { ftControllers[id]->cancel(); } else { std::cerr << "unknown file transfer UI id" << std::endl; |