File indexing completed on 2024-05-12 04:58:53

0001 /*
0002  * SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #ifndef UPLOADJOB_H
0008 #define UPLOADJOB_H
0009 
0010 #include <KJob>
0011 
0012 #include "server.h"
0013 #include <QElapsedTimer>
0014 #include <QIODevice>
0015 #include <QSslSocket>
0016 #include <QVariantMap>
0017 #include <networkpacket.h>
0018 
0019 class KDECONNECTCORE_EXPORT UploadJob : public KJob
0020 {
0021     Q_OBJECT
0022 public:
0023     explicit UploadJob(const NetworkPacket &networkPacket);
0024 
0025     void setSocket(QSslSocket *socket);
0026     void start() override;
0027     bool stop();
0028     const NetworkPacket getNetworkPacket();
0029 
0030 private:
0031     const NetworkPacket m_networkPacket;
0032     QSharedPointer<QIODevice> m_input;
0033     QSslSocket *m_socket;
0034     qint64 bytesUploading;
0035     qint64 bytesUploaded;
0036 
0037     const static quint16 MIN_PORT = 1739;
0038     const static quint16 MAX_PORT = 1764;
0039 
0040 private Q_SLOTS:
0041     void uploadNextPacket();
0042     void encryptedBytesWritten(qint64 bytes);
0043     void aboutToClose();
0044 };
0045 
0046 #endif // UPLOADJOB_H