summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-07-09 08:30:11 (GMT)
committerTobias Markmann <tm@ayena.de>2015-07-10 14:00:16 (GMT)
commit7af21fdd59af3b3112cff69996301605859af84c (patch)
tree5a1c79ac5d8c3a5521b098f68ae6c190a291455c /Swift/Controllers/XMPPEvents/EventController.cpp
parenta23d903d67f05257f0e9376a212b83045ea768f1 (diff)
downloadswift-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/XMPPEvents/EventController.cpp')
-rw-r--r--Swift/Controllers/XMPPEvents/EventController.cpp14
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
19namespace Swift { 22namespace Swift {
20 23
21EventController::EventController() { 24EventController::EventController() {
22} 25}
@@ -30,10 +33,11 @@ EventController::~EventController() {
30void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent) { 33void 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()) {