1 /*
2  * %kadu copyright begin%
3  * Copyright 2016 Rafał Przemysław Malinowski (rafal.przemyslaw.malinowski@gmail.com)
4  * %kadu copyright end%
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #pragma once
21 
22 #include "injeqt-type-roles.h"
23 
24 #include "notification/notification-callback.h"
25 #include "notification/notification-event.h"
26 
27 #include <QtCore/QObject>
28 #include <QtCore/QPointer>
29 #include <injeqt/injeqt.h>
30 
31 class ChatManager;
32 class ChatStorage;
33 class Chat;
34 class FileTransferManager;
35 class FileTransfer;
36 class NormalizedHtmlString;
37 class NotificationCallbackRepository;
38 class NotificationEventRepository;
39 class NotificationService;
40 struct Notification;
41 
42 class FileTransferNotificationService : public QObject
43 {
44 	Q_OBJECT
45 	INJEQT_TYPE_ROLE(SERVICE)
46 
47 public:
48 	Q_INVOKABLE explicit FileTransferNotificationService(QObject *parent = nullptr);
49 	virtual ~FileTransferNotificationService();
50 
51 public slots:
52 	void notifyIncomingFileTransfer(const FileTransfer &fileTransfer);
53 
54 private:
55 	QPointer<ChatManager> m_chatManager;
56 	QPointer<ChatStorage> m_chatStorage;
57 	QPointer<FileTransferManager> m_fileTransferManager;
58 	QPointer<NotificationCallbackRepository> m_notificationCallbackRepository;
59 	QPointer<NotificationEventRepository> m_notificationEventRepository;
60 	QPointer<NotificationService> m_notificationService;
61 
62 	NotificationCallback m_fileTransferAcceptCallback;
63 	NotificationCallback m_fileTransferSaveCallback;
64 	NotificationCallback m_fileTransferRejectCallback;
65 	NotificationCallback m_fileTransferIgnoreCallback;
66 	NotificationEvent m_fileTransferEvent;
67 	NotificationEvent m_fileTransferIncomingEvent;
68 
69 	NormalizedHtmlString incomingFileTransferDetails(const Chat &chat, const FileTransfer &fileTransfer);
70 
71 	void acceptFileTransfer(const Notification &notification);
72 	void rejectFileTransfer(const Notification &notification);
73 
74 private slots:
75 	INJEQT_SET void setChatManager(ChatManager *chatManager);
76 	INJEQT_SET void setChatStorage(ChatStorage *chatStorage);
77 	INJEQT_SET void setFileTransferManager(FileTransferManager *fileTransferManager);
78 	INJEQT_SET void setNotificationCallbackRepository(NotificationCallbackRepository *notificationCallbackRepository);
79 	INJEQT_SET void setNotificationEventRepository(NotificationEventRepository *notificationEventRepository);
80 	INJEQT_SET void setNotificationService(NotificationService *notificationService);
81 	INJEQT_INIT void init();
82 	INJEQT_DONE void done();
83 
84 };
85