2013-09-14 16:30:12 +01:00
|
|
|
/*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
|
2013-09-14 16:30:12 +01:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2013-09-14 16:30:12 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef UPLOADJOB_H
|
|
|
|
#define UPLOADJOB_H
|
|
|
|
|
|
|
|
#include <KJob>
|
|
|
|
|
|
|
|
#include <QIODevice>
|
|
|
|
#include <QVariantMap>
|
2015-07-05 22:05:26 +01:00
|
|
|
#include <QSslSocket>
|
|
|
|
#include "server.h"
|
2018-11-21 18:58:44 +00:00
|
|
|
#include <QElapsedTimer>
|
2018-11-28 18:56:22 +00:00
|
|
|
#include <networkpacket.h>
|
2013-09-14 16:30:12 +01:00
|
|
|
|
2016-06-22 16:49:45 +01:00
|
|
|
class KDECONNECTCORE_EXPORT UploadJob
|
2013-09-14 16:30:12 +01:00
|
|
|
: public KJob
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-11-28 18:56:22 +00:00
|
|
|
explicit UploadJob(const NetworkPacket& networkPacket);
|
2015-08-24 23:13:41 +01:00
|
|
|
|
2018-11-28 18:56:22 +00:00
|
|
|
void setSocket(QSslSocket* socket);
|
2016-06-20 08:05:02 +01:00
|
|
|
void start() override;
|
2018-11-28 18:56:22 +00:00
|
|
|
bool stop();
|
|
|
|
const NetworkPacket getNetworkPacket();
|
2013-09-14 16:30:12 +01:00
|
|
|
|
|
|
|
private:
|
2018-11-28 18:56:22 +00:00
|
|
|
const NetworkPacket m_networkPacket;
|
|
|
|
QSharedPointer<QIODevice> m_input;
|
2017-09-03 20:39:44 +01:00
|
|
|
QSslSocket* m_socket;
|
2018-11-21 18:58:44 +00:00
|
|
|
qint64 bytesUploading;
|
|
|
|
qint64 bytesUploaded;
|
2013-09-14 16:30:12 +01:00
|
|
|
|
2017-02-14 21:52:24 +00:00
|
|
|
const static quint16 MIN_PORT = 1739;
|
|
|
|
const static quint16 MAX_PORT = 1764;
|
2018-11-21 18:58:44 +00:00
|
|
|
|
2013-09-14 16:30:12 +01:00
|
|
|
private Q_SLOTS:
|
2018-11-21 18:58:44 +00:00
|
|
|
void uploadNextPacket();
|
|
|
|
void encryptedBytesWritten(qint64 bytes);
|
2013-09-14 16:30:12 +01:00
|
|
|
void aboutToClose();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // UPLOADJOB_H
|