Changeset View
Changeset View
Standalone View
Standalone View
core/backends/lan/compositeuploadjob.h
- This file was added.
1 | /** | ||||
---|---|---|---|---|---|
2 | * Copyright 2018 Erik Duisters | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #ifndef COMPOSITEUPLOADJOB_H | ||||
22 | #define COMPOSITEUPLOADJOB_H | ||||
23 | | ||||
24 | #include "kdeconnectcore_export.h" | ||||
25 | #include <KCompositeJob> | ||||
26 | #include "server.h" | ||||
27 | #include "uploadjob.h" | ||||
28 | | ||||
29 | class KDECONNECTCORE_EXPORT CompositeUploadJob | ||||
30 | : public KCompositeJob | ||||
31 | { | ||||
32 | Q_OBJECT | ||||
33 | | ||||
34 | public: | ||||
35 | explicit CompositeUploadJob(const QString& deviceId, bool displayNotification); | ||||
36 | | ||||
37 | void start() override; | ||||
38 | QVariantMap transferInfo(); | ||||
39 | bool isRunning(); | ||||
40 | bool addSubjob(KJob* job) override; | ||||
41 | | ||||
42 | private: | ||||
43 | bool startListening(); | ||||
44 | void emitDescription(const QString& currentFileName); | ||||
45 | | ||||
46 | protected: | ||||
47 | bool doKill() override; | ||||
48 | | ||||
49 | private: | ||||
50 | enum { | ||||
51 | NoPortAvailable = UserDefinedError, | ||||
52 | SendingNetworkPacketFailed, | ||||
53 | SocketError, | ||||
54 | SslError | ||||
55 | }; | ||||
56 | | ||||
57 | Server *const m_server; | ||||
58 | QSslSocket *m_socket; | ||||
59 | quint16 m_port; | ||||
60 | const QString& m_deviceId; | ||||
61 | bool m_running; | ||||
62 | int m_currentJobNum; | ||||
63 | int m_totalJobs; | ||||
64 | quint64 m_currentJobSendPayloadSize; | ||||
65 | quint64 m_totalSendPayloadSize; | ||||
66 | quint64 m_totalPayloadSize; | ||||
67 | UploadJob *m_currentJob; | ||||
68 | QElapsedTimer m_timer; | ||||
69 | | ||||
70 | const static quint16 MIN_PORT = 1739; | ||||
71 | const static quint16 MAX_PORT = 1764; | ||||
72 | | ||||
73 | private Q_SLOTS: | ||||
74 | void newConnection(); | ||||
75 | void socketDisconnected(); | ||||
76 | void socketError(QAbstractSocket::SocketError socketError); | ||||
77 | void sslError(const QList<QSslError>& errors); | ||||
78 | void encrypted(); | ||||
79 | void slotProcessedAmount(KJob *job, KJob::Unit unit, qulonglong amount); | ||||
80 | void slotResult(KJob *job) override; | ||||
81 | void startNextSubJob(); | ||||
82 | }; | ||||
83 | | ||||
84 | #endif //COMPOSITEUPLOADJOB_H |