Changeset View
Changeset View
Standalone View
Standalone View
core/backends/lan/uploadjob.h
Show All 19 Lines | |||||
20 | 20 | | |||
21 | #ifndef UPLOADJOB_H | 21 | #ifndef UPLOADJOB_H | ||
22 | #define UPLOADJOB_H | 22 | #define UPLOADJOB_H | ||
23 | 23 | | |||
24 | #include <KJob> | 24 | #include <KJob> | ||
25 | 25 | | |||
26 | #include <QIODevice> | 26 | #include <QIODevice> | ||
27 | #include <QVariantMap> | 27 | #include <QVariantMap> | ||
28 | #include <QSharedPointer> | | |||
29 | #include <QSslSocket> | 28 | #include <QSslSocket> | ||
30 | #include "server.h" | 29 | #include "server.h" | ||
31 | #include <QElapsedTimer> | 30 | #include <QElapsedTimer> | ||
32 | #include <QTimer> | 31 | #include <networkpacket.h> | ||
33 | 32 | | |||
34 | class KDECONNECTCORE_EXPORT UploadJob | 33 | class KDECONNECTCORE_EXPORT UploadJob | ||
35 | : public KJob | 34 | : public KJob | ||
36 | { | 35 | { | ||
37 | Q_OBJECT | 36 | Q_OBJECT | ||
38 | public: | 37 | public: | ||
39 | explicit UploadJob(const QSharedPointer<QIODevice>& source, const QString& deviceId); | 38 | explicit UploadJob(const NetworkPacket& networkPacket); | ||
40 | 39 | | |||
40 | void setSocket(QSslSocket* socket); | ||||
41 | void start() override; | 41 | void start() override; | ||
42 | 42 | bool stop(); | |||
43 | QVariantMap transferInfo(); | 43 | const NetworkPacket getNetworkPacket(); | ||
44 | 44 | | |||
45 | private: | 45 | private: | ||
46 | const QSharedPointer<QIODevice> m_input; | 46 | const NetworkPacket m_networkPacket; | ||
47 | Server * const m_server; | 47 | QSharedPointer<QIODevice> m_input; | ||
48 | QSslSocket* m_socket; | 48 | QSslSocket* m_socket; | ||
49 | quint16 m_port; | | |||
50 | const QString m_deviceId; | | |||
51 | qint64 bytesUploading; | 49 | qint64 bytesUploading; | ||
52 | qint64 bytesUploaded; | 50 | qint64 bytesUploaded; | ||
53 | QElapsedTimer m_timer; | | |||
54 | 51 | | |||
55 | const static quint16 MIN_PORT = 1739; | 52 | const static quint16 MIN_PORT = 1739; | ||
56 | const static quint16 MAX_PORT = 1764; | 53 | const static quint16 MAX_PORT = 1764; | ||
57 | 54 | | |||
58 | protected: | | |||
59 | bool doKill() override; | | |||
60 | | ||||
61 | private Q_SLOTS: | 55 | private Q_SLOTS: | ||
62 | void startUploading(); | | |||
63 | void uploadNextPacket(); | 56 | void uploadNextPacket(); | ||
64 | void newConnection(); | | |||
65 | void encryptedBytesWritten(qint64 bytes); | 57 | void encryptedBytesWritten(qint64 bytes); | ||
66 | void aboutToClose(); | 58 | void aboutToClose(); | ||
67 | void cleanup(); | | |||
68 | | ||||
69 | void socketFailed(QAbstractSocket::SocketError); | | |||
70 | void sslErrors(const QList<QSslError>& errors); | | |||
71 | }; | 59 | }; | ||
72 | 60 | | |||
73 | #endif // UPLOADJOB_H | 61 | #endif // UPLOADJOB_H |