diff options
| author | Tobias Markmann <tm@ayena.de> | 2015-07-09 08:30:11 (GMT) |
|---|---|---|
| committer | Tobias Markmann <tm@ayena.de> | 2015-07-10 14:00:16 (GMT) |
| commit | 7af21fdd59af3b3112cff69996301605859af84c (patch) | |
| tree | 5a1c79ac5d8c3a5521b098f68ae6c190a291455c /Swift/Controllers | |
| parent | a23d903d67f05257f0e9376a212b83045ea768f1 (diff) | |
| download | swift-7af21fdd59af3b3112cff69996301605859af84c.zip swift-7af21fdd59af3b3112cff69996301605859af84c.tar.bz2 | |
Create notice events for incoming file-transfers
Test-Information:
Send a file from one Swift instance to another. The UX is similar to
that of a MUC invite, clicking the notice will bring the relevant chat
in front.
Change-Id: Ief3cd7371ae01b2b38b6d1af36189df961eacef4
Diffstat (limited to 'Swift/Controllers')
| -rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 4 | ||||
| -rw-r--r-- | Swift/Controllers/XMPPEvents/EventController.cpp | 14 | ||||
| -rw-r--r-- | Swift/Controllers/XMPPEvents/EventController.h | 18 | ||||
| -rw-r--r-- | Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h | 30 |
4 files changed, 50 insertions, 16 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 7595d44..f39f503 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp | |||
| @@ -61,6 +61,7 @@ | |||
| 61 | #include <Swift/Controllers/UIInterfaces/JoinMUCWindowFactory.h> | 61 | #include <Swift/Controllers/UIInterfaces/JoinMUCWindowFactory.h> |
| 62 | #include <Swift/Controllers/WhiteboardManager.h> | 62 | #include <Swift/Controllers/WhiteboardManager.h> |
| 63 | #include <Swift/Controllers/XMPPEvents/EventController.h> | 63 | #include <Swift/Controllers/XMPPEvents/EventController.h> |
| 64 | #include <Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h> | ||
| 64 | 65 | ||
| 65 | BOOST_CLASS_VERSION(Swift::ChatListWindow::Chat, 1) | 66 | BOOST_CLASS_VERSION(Swift::ChatListWindow::Chat, 1) |
| 66 | 67 | ||
| @@ -929,6 +930,9 @@ void ChatsManager::handleNewFileTransferController(FileTransferController* ftc) | |||
| 929 | ChatController* chatController = getChatControllerOrCreate(ftc->getOtherParty()); | 930 | ChatController* chatController = getChatControllerOrCreate(ftc->getOtherParty()); |
| 930 | chatController->handleNewFileTransferController(ftc); | 931 | chatController->handleNewFileTransferController(ftc); |
| 931 | chatController->activateChatWindow(); | 932 | chatController->activateChatWindow(); |
| 933 | if (ftc->isIncoming()) { | ||
| 934 | eventController_->handleIncomingEvent(boost::make_shared<IncomingFileTransferEvent>(ftc->getOtherParty())); | ||
| 935 | } | ||
| 932 | } | 936 | } |
| 933 | 937 | ||
| 934 | void ChatsManager::handleWhiteboardSessionRequest(const JID& contact, bool senderIsSelf) { | 938 | void ChatsManager::handleWhiteboardSessionRequest(const JID& contact, bool senderIsSelf) { |
diff --git a/Swift/Controllers/XMPPEvents/EventController.cpp b/Swift/Controllers/XMPPEvents/EventController.cpp index 1561905..bbe7356 100644 --- a/Swift/Controllers/XMPPEvents/EventController.cpp +++ b/Swift/Controllers/XMPPEvents/EventController.cpp | |||
| @@ -1,20 +1,23 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2010-2012 Isode Limited. | 2 | * Copyright (c) 2010-2015 Isode Limited. |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * See the COPYING file for more information. | 4 | * See the COPYING file for more information. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <Swift/Controllers/XMPPEvents/EventController.h> | 7 | #include <Swift/Controllers/XMPPEvents/EventController.h> |
| 8 | 8 | ||
| 9 | #include <algorithm> | ||
| 10 | |||
| 9 | #include <boost/bind.hpp> | 11 | #include <boost/bind.hpp> |
| 10 | #include <boost/numeric/conversion/cast.hpp> | 12 | #include <boost/numeric/conversion/cast.hpp> |
| 11 | #include <algorithm> | ||
| 12 | 13 | ||
| 13 | #include <Swiften/Base/foreach.h> | 14 | #include <Swiften/Base/foreach.h> |
| 14 | #include <Swift/Controllers/XMPPEvents/MessageEvent.h> | 15 | |
| 15 | #include <Swift/Controllers/XMPPEvents/ErrorEvent.h> | 16 | #include <Swift/Controllers/XMPPEvents/ErrorEvent.h> |
| 16 | #include <Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h> | 17 | #include <Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h> |
| 17 | #include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h> | 18 | #include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h> |
| 19 | #include <Swift/Controllers/XMPPEvents/MessageEvent.h> | ||
| 20 | #include <Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h> | ||
| 18 | 21 | ||
| 19 | namespace Swift { | 22 | namespace Swift { |
| 20 | 23 | ||
| @@ -32,6 +35,7 @@ void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceE | |||
| 32 | boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(sourceEvent); | 35 | boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(sourceEvent); |
| 33 | boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(sourceEvent); | 36 | boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(sourceEvent); |
| 34 | boost::shared_ptr<MUCInviteEvent> mucInviteEvent = boost::dynamic_pointer_cast<MUCInviteEvent>(sourceEvent); | 37 | boost::shared_ptr<MUCInviteEvent> mucInviteEvent = boost::dynamic_pointer_cast<MUCInviteEvent>(sourceEvent); |
| 38 | boost::shared_ptr<IncomingFileTransferEvent> incomingFileTransferEvent = boost::dynamic_pointer_cast<IncomingFileTransferEvent>(sourceEvent); | ||
| 35 | 39 | ||
| 36 | /* If it's a duplicate subscription request, remove the previous request first */ | 40 | /* If it's a duplicate subscription request, remove the previous request first */ |
| 37 | if (subscriptionEvent) { | 41 | if (subscriptionEvent) { |
| @@ -46,7 +50,7 @@ void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceE | |||
| 46 | } | 50 | } |
| 47 | } | 51 | } |
| 48 | 52 | ||
| 49 | if ((messageEvent && messageEvent->isReadable()) || subscriptionEvent || errorEvent || mucInviteEvent) { | 53 | if ((messageEvent && messageEvent->isReadable()) || subscriptionEvent || errorEvent || mucInviteEvent || incomingFileTransferEvent) { |
| 50 | events_.push_back(sourceEvent); | 54 | events_.push_back(sourceEvent); |
| 51 | sourceEvent->onConclusion.connect(boost::bind(&EventController::handleEventConcluded, this, sourceEvent)); | 55 | sourceEvent->onConclusion.connect(boost::bind(&EventController::handleEventConcluded, this, sourceEvent)); |
| 52 | onEventQueueLengthChange(boost::numeric_cast<int>(events_.size())); | 56 | onEventQueueLengthChange(boost::numeric_cast<int>(events_.size())); |
diff --git a/Swift/Controllers/XMPPEvents/EventController.h b/Swift/Controllers/XMPPEvents/EventController.h index 026d03e..35938ac 100644 --- a/Swift/Controllers/XMPPEvents/EventController.h +++ b/Swift/Controllers/XMPPEvents/EventController.h | |||
| @@ -1,25 +1,24 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2010 Isode Limited. | 2 | * Copyright (c) 2010-2015 Isode Limited. |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * See the COPYING file for more information. | 4 | * See the COPYING file for more information. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #ifndef SWIFTEN_EventController_H | 7 | #pragma once |
| 8 | #define SWIFTEN_EventController_H | ||
| 9 | 8 | ||
| 9 | #include <vector> | ||
| 10 | 10 | ||
| 11 | #include "Swiften/Base/boost_bsignals.h" | ||
| 12 | #include <boost/shared_ptr.hpp> | 11 | #include <boost/shared_ptr.hpp> |
| 13 | #include <vector> | ||
| 14 | 12 | ||
| 15 | #include "Swift/Controllers/XMPPEvents/StanzaEvent.h" | 13 | #include <Swiften/Base/boost_bsignals.h> |
| 16 | #include "Swift/Controllers/XMPPEvents/MessageEvent.h" | 14 | |
| 15 | #include <Swift/Controllers/XMPPEvents/MessageEvent.h> | ||
| 16 | #include <Swift/Controllers/XMPPEvents/StanzaEvent.h> | ||
| 17 | 17 | ||
| 18 | namespace Swift { | 18 | namespace Swift { |
| 19 | typedef std::vector<boost::shared_ptr<StanzaEvent> > EventList; | 19 | typedef std::vector<boost::shared_ptr<StanzaEvent> > EventList; |
| 20 | class EventController { | 20 | class EventController { |
| 21 | public: | 21 | public: |
| 22 | |||
| 23 | EventController(); | 22 | EventController(); |
| 24 | ~EventController(); | 23 | ~EventController(); |
| 25 | 24 | ||
| @@ -35,6 +34,3 @@ namespace Swift { | |||
| 35 | EventList events_; | 34 | EventList events_; |
| 36 | }; | 35 | }; |
| 37 | } | 36 | } |
| 38 | #endif | ||
| 39 | |||
| 40 | |||
diff --git a/Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h b/Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h new file mode 100644 index 0000000..24af640 --- /dev/null +++ b/Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2015 Isode Limited. | ||
| 3 | * All rights reserved. | ||
| 4 | * See the COPYING file for more information. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #pragma once | ||
| 8 | |||
| 9 | #include <boost/shared_ptr.hpp> | ||
| 10 | |||
| 11 | #include <Swiften/JID/JID.h> | ||
| 12 | |||
| 13 | #include <Swift/Controllers/XMPPEvents/StanzaEvent.h> | ||
| 14 | |||
| 15 | namespace Swift { | ||
| 16 | class IncomingFileTransferEvent : public StanzaEvent { | ||
| 17 | public: | ||
| 18 | typedef boost::shared_ptr<IncomingFileTransferEvent> ref; | ||
| 19 | |||
| 20 | IncomingFileTransferEvent(const JID& sender) : sender_(sender) {} | ||
| 21 | |||
| 22 | const JID& getSender() const { | ||
| 23 | return sender_; | ||
| 24 | } | ||
| 25 | |||
| 26 | private: | ||
| 27 | JID sender_; | ||
| 28 | }; | ||
| 29 | } | ||
| 30 | |||
Swift