1 /*
2  * %kadu copyright begin%
3  * Copyright 2011 Piotr Galiszewski (piotr.galiszewski@kadu.im)
4  * Copyright 2010, 2011, 2014 Bartosz Brachaczek (b.brachaczek@gmail.com)
5  * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015 Rafał Przemysław Malinowski (rafal.przemyslaw.malinowski@gmail.com)
6  * %kadu copyright end%
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #pragma once
23 
24 #include "storage/shared.h"
25 
26 #include <QtCore/QPointer>
27 #include <injeqt/injeqt.h>
28 
29 class ContactManager;
30 class Contact;
31 class FileTransferHandler;
32 class FileTransferManager;
33 
34 enum class FileTransferDirection;
35 enum class FileTransferStatus;
36 enum class FileTransferType;
37 
38 class KADUAPI FileTransferShared : public Shared
39 {
40 	Q_OBJECT
41 	Q_DISABLE_COPY(FileTransferShared)
42 
43 public:
44 	explicit FileTransferShared(const QUuid &uuid = QUuid{});
45 	virtual ~FileTransferShared();
46 
47 	virtual StorableObject * storageParent();
48 	virtual QString storageNodeName();
49 
50 	void setError(QString error);
51 	void setTransferStatus(FileTransferStatus transferStatus);
52 	void setHandler(FileTransferHandler *handler);
53 
54 	KaduShared_PropertyDeclCRW(Contact, peer, Peer)
55 	KaduShared_Property_M(const QString &, localFileName, LocalFileName)
56 	KaduShared_Property_M(const QString &, remoteFileName, RemoteFileName)
57 	KaduShared_Property_M(unsigned long, fileSize, FileSize)
58 	KaduShared_Property_M(unsigned long, transferredSize, TransferredSize)
59 	KaduShared_Property_M(FileTransferDirection, transferDirection, TransferDirection)
60 	KaduShared_Property_M(FileTransferType, transferType, TransferType)
61 	KaduShared_PropertyRead_M(QString, error)
62 	KaduShared_PropertyRead_M(FileTransferStatus, transferStatus)
63 	KaduShared_PropertyRead_M(FileTransferHandler *, handler)
64 
65 signals:
66 	void statusChanged();
67 
68 	void updated();
69 
70 protected:
71 	virtual void load();
72 	virtual void store();
73 
74 private:
75 	QPointer<ContactManager> m_contactManager;
76 	QPointer<FileTransferManager> m_fileTransferManager;
77 
78 	Contact *m_peer;
79 	QString m_localFileName;
80 	QString m_remoteFileName;
81 
82 	unsigned long m_fileSize;
83 	unsigned long m_transferredSize;
84 
85 	QString m_error;
86 	FileTransferDirection m_transferDirection;
87 	FileTransferStatus m_transferStatus;
88 	FileTransferType m_transferType;
89 
90 	FileTransferHandler *m_handler;
91 
92 private slots:
93 	INJEQT_SET void setContactManager(ContactManager *contactManager);
94 	INJEQT_SET void setFileTransferManager(FileTransferManager *fileTransferManager);
95 
96 	void handlerDestroyed();
97 
98 };
99