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
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
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp4
-rw-r--r--Swift/Controllers/XMPPEvents/EventController.cpp14
-rw-r--r--Swift/Controllers/XMPPEvents/EventController.h18
-rw-r--r--Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h30
-rw-r--r--Swift/QtUI/EventViewer/EventDelegate.cpp26
-rw-r--r--Swift/QtUI/EventViewer/EventDelegate.h9
-rw-r--r--Swift/QtUI/EventViewer/QtEvent.cpp24
-rw-r--r--Swift/QtUI/EventViewer/QtEventWindow.cpp28
8 files changed, 107 insertions, 46 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
@@ -59,10 +59,11 @@
59#include <Swift/Controllers/UIInterfaces/ChatListWindowFactory.h> 59#include <Swift/Controllers/UIInterfaces/ChatListWindowFactory.h>
60#include <Swift/Controllers/UIInterfaces/JoinMUCWindow.h> 60#include <Swift/Controllers/UIInterfaces/JoinMUCWindow.h>
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
65BOOST_CLASS_VERSION(Swift::ChatListWindow::Chat, 1) 66BOOST_CLASS_VERSION(Swift::ChatListWindow::Chat, 1)
66 67
67namespace boost { 68namespace boost {
68namespace serialization { 69namespace serialization {
@@ -927,10 +928,13 @@ void ChatsManager::handleMUCBookmarkActivated(const MUCBookmark& mucBookmark) {
927 928
928void ChatsManager::handleNewFileTransferController(FileTransferController* ftc) { 929void 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
934void ChatsManager::handleWhiteboardSessionRequest(const JID& contact, bool senderIsSelf) { 938void ChatsManager::handleWhiteboardSessionRequest(const JID& contact, bool senderIsSelf) {
935 ChatController* chatController = getChatControllerOrCreate(contact); 939 ChatController* chatController = getChatControllerOrCreate(contact);
936 chatController->handleWhiteboardSessionRequest(senderIsSelf); 940 chatController->handleWhiteboardSessionRequest(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,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()) {
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,27 +1,26 @@
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
18namespace Swift { 18namespace 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
26 void handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent); 25 void handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent);
27 boost::signal<void (int)> onEventQueueLengthChange; 26 boost::signal<void (int)> onEventQueueLengthChange;
@@ -33,8 +32,5 @@ namespace Swift {
33 private: 32 private:
34 void handleEventConcluded(boost::shared_ptr<StanzaEvent> event); 33 void handleEventConcluded(boost::shared_ptr<StanzaEvent> event);
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
15namespace 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
diff --git a/Swift/QtUI/EventViewer/EventDelegate.cpp b/Swift/QtUI/EventViewer/EventDelegate.cpp
index 7bbfee2..cd657b8 100644
--- a/Swift/QtUI/EventViewer/EventDelegate.cpp
+++ b/Swift/QtUI/EventViewer/EventDelegate.cpp
@@ -1,23 +1,29 @@
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#include "EventDelegate.h" 7#include <Swift/QtUI/EventViewer/EventDelegate.h>
8 8
9#include <QDebug> 9#include <QDebug>
10 10
11#include "Swift/Controllers/XMPPEvents/MessageEvent.h" 11#include <Swift/Controllers/XMPPEvents/ErrorEvent.h>
12#include "Swift/Controllers/XMPPEvents/ErrorEvent.h" 12#include <Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h>
13#include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h" 13#include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h>
14#include "Swift/Controllers/XMPPEvents/MUCInviteEvent.h" 14#include <Swift/Controllers/XMPPEvents/MessageEvent.h>
15#include <Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h>
15 16
16namespace Swift { 17namespace Swift {
17 18
18EventDelegate::EventDelegate() : QStyledItemDelegate(), messageDelegate_(QtEvent::SenderRole, Qt::DisplayRole, false), subscriptionDelegate_(QtEvent::SenderRole, Qt::DisplayRole, true), errorDelegate_(QtEvent::SenderRole, Qt::DisplayRole, true), mucInviteDelegate_(QtEvent::SenderRole, Qt::DisplayRole, false) { 19EventDelegate::EventDelegate() : QStyledItemDelegate(),
20 messageDelegate_(QtEvent::SenderRole, Qt::DisplayRole, false),
21 subscriptionDelegate_(QtEvent::SenderRole, Qt::DisplayRole, true),
22 errorDelegate_(QtEvent::SenderRole, Qt::DisplayRole, true),
23 mucInviteDelegate_(QtEvent::SenderRole, Qt::DisplayRole, false),
24 incomingFileTransferDelegate_(QtEvent::SenderRole, Qt::DisplayRole, false) {
19 25
20} 26}
21 27
22QSize EventDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index ) const { 28QSize EventDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index ) const {
23 QtEvent* item = static_cast<QtEvent*>(index.internalPointer()); 29 QtEvent* item = static_cast<QtEvent*>(index.internalPointer());
@@ -27,10 +33,11 @@ QSize EventDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIn
27 switch (getEventType(item->getEvent())) { 33 switch (getEventType(item->getEvent())) {
28 case MessageEventType: return messageDelegate_.sizeHint(option, item); 34 case MessageEventType: return messageDelegate_.sizeHint(option, item);
29 case SubscriptionEventType: return subscriptionDelegate_.sizeHint(option, item); 35 case SubscriptionEventType: return subscriptionDelegate_.sizeHint(option, item);
30 case ErrorEventType: return errorDelegate_.sizeHint(option, item); 36 case ErrorEventType: return errorDelegate_.sizeHint(option, item);
31 case MUCInviteEventType: return mucInviteDelegate_.sizeHint(option, item); 37 case MUCInviteEventType: return mucInviteDelegate_.sizeHint(option, item);
38 case IncomingFileTransferEventType: return incomingFileTransferDelegate_.sizeHint(option, item);
32 } 39 }
33 assert(false); 40 assert(false);
34 return QSize(); 41 return QSize();
35} 42}
36 43
@@ -43,10 +50,11 @@ void EventDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
43 switch (getEventType(item->getEvent())) { 50 switch (getEventType(item->getEvent())) {
44 case MessageEventType: messageDelegate_.paint(painter, option, item);break; 51 case MessageEventType: messageDelegate_.paint(painter, option, item);break;
45 case SubscriptionEventType: subscriptionDelegate_.paint(painter, option, item);break; 52 case SubscriptionEventType: subscriptionDelegate_.paint(painter, option, item);break;
46 case ErrorEventType: errorDelegate_.paint(painter, option, item);break; 53 case ErrorEventType: errorDelegate_.paint(painter, option, item);break;
47 case MUCInviteEventType: mucInviteDelegate_.paint(painter, option, item);break; 54 case MUCInviteEventType: mucInviteDelegate_.paint(painter, option, item);break;
55 case IncomingFileTransferEventType: incomingFileTransferDelegate_.paint(painter, option, item);break;
48 } 56 }
49} 57}
50 58
51EventType EventDelegate::getEventType(boost::shared_ptr<StanzaEvent> event) const { 59EventType EventDelegate::getEventType(boost::shared_ptr<StanzaEvent> event) const {
52 boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(event); 60 boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(event);
@@ -63,10 +71,14 @@ EventType EventDelegate::getEventType(boost::shared_ptr<StanzaEvent> event) cons
63 } 71 }
64 boost::shared_ptr<MUCInviteEvent> mucInviteEvent = boost::dynamic_pointer_cast<MUCInviteEvent>(event); 72 boost::shared_ptr<MUCInviteEvent> mucInviteEvent = boost::dynamic_pointer_cast<MUCInviteEvent>(event);
65 if (mucInviteEvent) { 73 if (mucInviteEvent) {
66 return MUCInviteEventType; 74 return MUCInviteEventType;
67 } 75 }
76 boost::shared_ptr<IncomingFileTransferEvent> incomingFileTransferEvent = boost::dynamic_pointer_cast<IncomingFileTransferEvent>(event);
77 if (incomingFileTransferEvent) {
78 return IncomingFileTransferEventType;
79 }
68 //I don't know what this is. 80 //I don't know what this is.
69 assert(false); 81 assert(false);
70 return MessageEventType; 82 return MessageEventType;
71} 83}
72 84
diff --git a/Swift/QtUI/EventViewer/EventDelegate.h b/Swift/QtUI/EventViewer/EventDelegate.h
index f5dd196..6ab96e4 100644
--- a/Swift/QtUI/EventViewer/EventDelegate.h
+++ b/Swift/QtUI/EventViewer/EventDelegate.h
@@ -1,20 +1,20 @@
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#pragma once 7#pragma once
8 8
9#include <QStyledItemDelegate> 9#include <QStyledItemDelegate>
10 10
11#include "Swift/QtUI/Roster/DelegateCommons.h" 11#include <Swift/QtUI/EventViewer/TwoLineDelegate.h>
12#include "Swift/QtUI/EventViewer/TwoLineDelegate.h" 12#include <Swift/QtUI/Roster/DelegateCommons.h>
13 13
14namespace Swift { 14namespace Swift {
15 enum EventType {MessageEventType, SubscriptionEventType, ErrorEventType, MUCInviteEventType}; 15 enum EventType {MessageEventType, SubscriptionEventType, ErrorEventType, MUCInviteEventType, IncomingFileTransferEventType};
16 class EventDelegate : public QStyledItemDelegate { 16 class EventDelegate : public QStyledItemDelegate {
17 Q_OBJECT 17 Q_OBJECT
18 public: 18 public:
19 EventDelegate(); 19 EventDelegate();
20 QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; 20 QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
@@ -24,8 +24,9 @@ namespace Swift {
24 DelegateCommons common_; 24 DelegateCommons common_;
25 TwoLineDelegate messageDelegate_; 25 TwoLineDelegate messageDelegate_;
26 TwoLineDelegate subscriptionDelegate_; 26 TwoLineDelegate subscriptionDelegate_;
27 TwoLineDelegate errorDelegate_; 27 TwoLineDelegate errorDelegate_;
28 TwoLineDelegate mucInviteDelegate_; 28 TwoLineDelegate mucInviteDelegate_;
29 TwoLineDelegate incomingFileTransferDelegate_;
29 }; 30 };
30} 31}
31 32
diff --git a/Swift/QtUI/EventViewer/QtEvent.cpp b/Swift/QtUI/EventViewer/QtEvent.cpp
index a84a440..4d90bd9 100644
--- a/Swift/QtUI/EventViewer/QtEvent.cpp
+++ b/Swift/QtUI/EventViewer/QtEvent.cpp
@@ -1,20 +1,21 @@
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#include "Swift/QtUI/EventViewer/QtEvent.h" 7#include <Swift/QtUI/EventViewer/QtEvent.h>
8 8
9#include <QDateTime>
10#include <QColor> 9#include <QColor>
10#include <QDateTime>
11 11
12#include "Swift/Controllers/XMPPEvents/MessageEvent.h" 12#include <Swift/Controllers/XMPPEvents/ErrorEvent.h>
13#include "Swift/Controllers/XMPPEvents/ErrorEvent.h" 13#include <Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h>
14#include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h" 14#include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h>
15#include "Swift/Controllers/XMPPEvents/MUCInviteEvent.h" 15#include <Swift/Controllers/XMPPEvents/MessageEvent.h>
16#include <Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h>
16 17
17#include "Swift/QtUI/QtSwiftUtil.h" 18#include "Swift/QtUI/QtSwiftUtil.h"
18 19
19namespace Swift { 20namespace Swift {
20 21
@@ -51,10 +52,14 @@ QString QtEvent::sender() {
51 } 52 }
52 boost::shared_ptr<MUCInviteEvent> mucInviteEvent = boost::dynamic_pointer_cast<MUCInviteEvent>(event_); 53 boost::shared_ptr<MUCInviteEvent> mucInviteEvent = boost::dynamic_pointer_cast<MUCInviteEvent>(event_);
53 if (mucInviteEvent) { 54 if (mucInviteEvent) {
54 return P2QSTRING(mucInviteEvent->getInviter().toString()); 55 return P2QSTRING(mucInviteEvent->getInviter().toString());
55 } 56 }
57 boost::shared_ptr<IncomingFileTransferEvent> incomingFTEvent = boost::dynamic_pointer_cast<IncomingFileTransferEvent>(event_);
58 if (incomingFTEvent) {
59 return P2QSTRING(incomingFTEvent->getSender().toString());
60 }
56 return ""; 61 return "";
57} 62}
58 63
59QString QtEvent::text() { 64QString QtEvent::text() {
60 boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(event_); 65 boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(event_);
@@ -80,9 +85,14 @@ QString QtEvent::text() {
80 boost::shared_ptr<MUCInviteEvent> mucInviteEvent = boost::dynamic_pointer_cast<MUCInviteEvent>(event_); 85 boost::shared_ptr<MUCInviteEvent> mucInviteEvent = boost::dynamic_pointer_cast<MUCInviteEvent>(event_);
81 if (mucInviteEvent) { 86 if (mucInviteEvent) {
82 QString message = QString(QObject::tr("%1 has invited you to enter the %2 room.")).arg(P2QSTRING(mucInviteEvent->getInviter().toBare().toString())).arg(P2QSTRING(mucInviteEvent->getRoomJID().toString())); 87 QString message = QString(QObject::tr("%1 has invited you to enter the %2 room.")).arg(P2QSTRING(mucInviteEvent->getInviter().toBare().toString())).arg(P2QSTRING(mucInviteEvent->getRoomJID().toString()));
83 return message; 88 return message;
84 } 89 }
90 boost::shared_ptr<IncomingFileTransferEvent> incomingFTEvent = boost::dynamic_pointer_cast<IncomingFileTransferEvent>(event_);
91 if (incomingFTEvent) {
92 QString message = QString(QObject::tr("%1 would like to send a file to you.")).arg(P2QSTRING(incomingFTEvent->getSender().toBare().toString()));
93 return message;
94 }
85 return ""; 95 return "";
86} 96}
87 97
88} 98}
diff --git a/Swift/QtUI/EventViewer/QtEventWindow.cpp b/Swift/QtUI/EventViewer/QtEventWindow.cpp
index 3072497..f92cd07 100644
--- a/Swift/QtUI/EventViewer/QtEventWindow.cpp
+++ b/Swift/QtUI/EventViewer/QtEventWindow.cpp
@@ -1,29 +1,29 @@
1
2/* 1/*
3 * Copyright (c) 2010-2015 Isode Limited. 2 * Copyright (c) 2010-2015 Isode Limited.
4 * All rights reserved. 3 * All rights reserved.
5 * See the COPYING file for more information. 4 * See the COPYING file for more information.
6 */ 5 */
7 6
8#include "Swift/QtUI/EventViewer/QtEventWindow.h" 7#include <Swift/QtUI/EventViewer/QtEventWindow.h>
9 8
10#include <QtDebug>
11#include <QBoxLayout> 9#include <QBoxLayout>
12#include <QPushButton>
13#include <QMessageBox> 10#include <QMessageBox>
11#include <QPushButton>
12#include <QtDebug>
14 13
15#include "Swift/Controllers/XMPPEvents/MessageEvent.h" 14#include <Swiften/Base/Platform.h>
16#include "Swift/Controllers/XMPPEvents/ErrorEvent.h"
17#include "Swift/QtUI/QtSubscriptionRequestWindow.h"
18#include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h"
19#include "Swift/Controllers/XMPPEvents/MUCInviteEvent.h"
20#include "Swift/Controllers/UIEvents/RequestChatUIEvent.h"
21#include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h"
22 15
16#include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h>
17#include <Swift/Controllers/UIEvents/RequestChatUIEvent.h>
18#include <Swift/Controllers/XMPPEvents/ErrorEvent.h>
19#include <Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h>
20#include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h>
21#include <Swift/Controllers/XMPPEvents/MessageEvent.h>
22#include <Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h>
23 23
24#include "Swiften/Base/Platform.h" 24#include <Swift/QtUI/QtSubscriptionRequestWindow.h>
25 25
26namespace Swift { 26namespace Swift {
27 27
28QtEventWindow::QtEventWindow(UIEventStream* eventStream) : EventWindow(false) { 28QtEventWindow::QtEventWindow(UIEventStream* eventStream) : EventWindow(false) {
29 QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, this); 29 QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
@@ -74,10 +74,11 @@ void QtEventWindow::handleReadClicked() {
74void QtEventWindow::handleItemActivated(const QModelIndex& item) { 74void QtEventWindow::handleItemActivated(const QModelIndex& item) {
75 QtEvent* event = model_->getItem(item.row()); 75 QtEvent* event = model_->getItem(item.row());
76 boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(event->getEvent()); 76 boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(event->getEvent());
77 boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(event->getEvent()); 77 boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(event->getEvent());
78 boost::shared_ptr<MUCInviteEvent> mucInviteEvent = boost::dynamic_pointer_cast<MUCInviteEvent>(event->getEvent()); 78 boost::shared_ptr<MUCInviteEvent> mucInviteEvent = boost::dynamic_pointer_cast<MUCInviteEvent>(event->getEvent());
79 boost::shared_ptr<IncomingFileTransferEvent> incomingFTEvent = boost::dynamic_pointer_cast<IncomingFileTransferEvent>(event->getEvent());
79 boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(event->getEvent()); 80 boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(event->getEvent());
80 81
81 if (messageEvent) { 82 if (messageEvent) {
82 if (messageEvent->getStanza()->getType() == Message::Groupchat) { 83 if (messageEvent->getStanza()->getType() == Message::Groupchat) {
83 eventStream_->send(boost::shared_ptr<UIEvent>(new JoinMUCUIEvent(messageEvent->getStanza()->getFrom().toBare(), messageEvent->getStanza()->getTo().getResource()))); 84 eventStream_->send(boost::shared_ptr<UIEvent>(new JoinMUCUIEvent(messageEvent->getStanza()->getFrom().toBare(), messageEvent->getStanza()->getTo().getResource())));
@@ -88,10 +89,13 @@ void QtEventWindow::handleItemActivated(const QModelIndex& item) {
88 QtSubscriptionRequestWindow* window = QtSubscriptionRequestWindow::getWindow(subscriptionEvent, this); 89 QtSubscriptionRequestWindow* window = QtSubscriptionRequestWindow::getWindow(subscriptionEvent, this);
89 window->show(); 90 window->show();
90 } else if (mucInviteEvent) { 91 } else if (mucInviteEvent) {
91 eventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(mucInviteEvent->getInviter()))); 92 eventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(mucInviteEvent->getInviter())));
92 mucInviteEvent->conclude(); 93 mucInviteEvent->conclude();
94 } else if (incomingFTEvent) {
95 eventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(incomingFTEvent->getSender())));
96 incomingFTEvent->conclude();
93 } else { 97 } else {
94 if (errorEvent) { 98 if (errorEvent) {
95 errorEvent->conclude(); 99 errorEvent->conclude();
96 } 100 }
97 QMessageBox msgBox; 101 QMessageBox msgBox;