From 331c6d2570b76f126491e9c955963879c5a76a54 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Mon, 1 Aug 2016 18:18:41 +0200 Subject: Open corresponding chat window when sending files via roster Incoming and outgoing file transfers open the corresponding chat window, but only for outgoing file transfers the window is activated, i.e. shown at the top and focused. For incoming transfers the window is opened in the background. Test-Information: Tested on OS X 10.11.6 with Qt 5.5.1 against another Swift instance. Change-Id: Ie786c135d4f7854a558561cadd715dc87a209316 diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index f3bb8d3..232d903 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -975,6 +975,9 @@ void ChatsManager::handleMUCBookmarkActivated(const MUCBookmark& mucBookmark) { void ChatsManager::handleNewFileTransferController(FileTransferController* ftc) { ChatController* chatController = getChatControllerOrCreate(ftc->getOtherParty()); chatController->handleNewFileTransferController(ftc); + if (!ftc->isIncoming()) { + chatController->activateChatWindow(); + } } void ChatsManager::handleWhiteboardSessionRequest(const JID& contact, bool senderIsSelf) { diff --git a/Swift/Controllers/Roster/RosterController.cpp b/Swift/Controllers/Roster/RosterController.cpp index 47c24fc..1c750a3 100644 --- a/Swift/Controllers/Roster/RosterController.cpp +++ b/Swift/Controllers/Roster/RosterController.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -141,7 +140,7 @@ void RosterController::handleOnJIDAdded(const JID& jid) { std::vector groups = xmppRoster_->getGroupsForJID(jid); std::string name = nickResolver_->jidToNick(jid); if (!groups.empty()) { - foreach(const std::string& group, groups) { + for (const auto& group : groups) { roster_->addContact(jid, jid, name, group, avatarManager_->getAvatarPath(jid)); } } @@ -152,7 +151,7 @@ void RosterController::handleOnJIDAdded(const JID& jid) { } void RosterController::applyAllPresenceTo(const JID& jid) { - foreach (Presence::ref presence, presenceOracle_->getAllPresence(jid)) { + for (auto&& presence : presenceOracle_->getAllPresence(jid)) { roster_->applyOnItems(SetPresence(presence)); } } @@ -179,12 +178,12 @@ void RosterController::handleOnJIDUpdated(const JID& jid, const std::string& old if (groups.empty()) { groups.push_back(contactsGroup); } - foreach(const std::string& group, groups) { + for (const auto& group : groups) { if (std::find(oldGroups.begin(), oldGroups.end(), group) == oldGroups.end()) { roster_->addContact(jid, jid, name, group, avatarManager_->getAvatarPath(jid)); } } - foreach(const std::string& group, oldGroups) { + for (const auto& group : oldGroups) { if (std::find(groups.begin(), groups.end(), group) == groups.end()) { roster_->removeContactFromGroup(jid, group); if (roster_->getGroup(group)->getChildren().size() == 0) { @@ -203,7 +202,7 @@ void RosterController::handleSettingChanged(const std::string& settingPath) { void RosterController::handleBlockingStateChanged() { if (clientBlockListManager_->getBlockList()->getState() == BlockList::Available) { - foreach(const JID& jid, clientBlockListManager_->getBlockList()->getItems()) { + for (const auto& jid : clientBlockListManager_->getBlockList()->getItems()) { roster_->applyOnItems(SetBlockingState(jid, ContactRosterItem::IsBlocked)); } } @@ -256,7 +255,7 @@ void RosterController::handleUIEvent(std::shared_ptr event) { if (group == QT_TRANSLATE_NOOP("", "Contacts")) { group = ""; } - foreach(XMPPRosterItem& item, items) { + for (auto& item : items) { std::vector groups = item.getGroups(); if ( (group.empty() && groups.empty()) || std::find(groups.begin(), groups.end(), group) != groups.end()) { groups.erase(std::remove(groups.begin(), groups.end(), group), groups.end()); @@ -269,7 +268,6 @@ void RosterController::handleUIEvent(std::shared_ptr event) { } } else if (std::shared_ptr sendFileEvent = std::dynamic_pointer_cast(event)) { - //TODO add send file dialog to ChatView of receipient jid ftOverview_->sendFile(sendFileEvent->getJID(), sendFileEvent->getFilename()); } } @@ -298,7 +296,7 @@ void RosterController::initBlockingCommand() { blockingOnItemRemovedConnection_ = blockList->onItemRemoved.connect(boost::bind(&RosterController::handleBlockingItemRemoved, this, _1)); roster_->setBlockingSupported(true); if (blockList->getState() == BlockList::Available) { - foreach(const JID& jid, blockList->getItems()) { + for (const auto& jid : blockList->getItems()) { roster_->applyOnItems(SetBlockingState(jid, ContactRosterItem::IsBlocked)); } } -- cgit v0.10.2-6-g49f6