diff options
Diffstat (limited to 'Swift/Controllers/XMPPEvents/EventController.cpp')
| -rw-r--r-- | Swift/Controllers/XMPPEvents/EventController.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
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,22 +1,25 @@ | |||
| 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 | ||
| 21 | EventController::EventController() { | 24 | EventController::EventController() { |
| 22 | } | 25 | } |
| @@ -30,10 +33,11 @@ EventController::~EventController() { | |||
| 30 | void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent) { | 33 | void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent) { |
| 31 | boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(sourceEvent); | 34 | boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(sourceEvent); |
| 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) { |
| 38 | EventList existingEvents(events_); | 42 | EventList existingEvents(events_); |
| 39 | foreach(boost::shared_ptr<StanzaEvent> existingEvent, existingEvents) { | 43 | foreach(boost::shared_ptr<StanzaEvent> existingEvent, existingEvents) { |
| @@ -44,11 +48,11 @@ void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceE | |||
| 44 | } | 48 | } |
| 45 | } | 49 | } |
| 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())); |
| 53 | onEventQueueEventAdded(sourceEvent); | 57 | onEventQueueEventAdded(sourceEvent); |
| 54 | if (sourceEvent->getConcluded()) { | 58 | if (sourceEvent->getConcluded()) { |
Swift