62 lines
1.8 KiB
C++
62 lines
1.8 KiB
C++
#ifndef THREADSENDPRO_H
|
|
#define THREADSENDPRO_H
|
|
#include <QThread>
|
|
#include <QFile>
|
|
#include <QTcpSocket>
|
|
#include <QJsonValue>
|
|
#include <QJsonObject>
|
|
#include <QJsonDocument>
|
|
#include <QAbstractSocket>
|
|
#include <QSemaphore>
|
|
#include <QDataStream>
|
|
const quint16 PORT = 3333;
|
|
const qint64 LOADBYTES = 4 * 1024; // 4 kilo-byte
|
|
const int DATA_STREAM_VERSION = QDataStream::Qt_4_8;
|
|
class ThreadSendPro:public QThread
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
ThreadSendPro(QString strProPathAndName,QString strIp="",int iPort=3333);
|
|
~ThreadSendPro();
|
|
void run();
|
|
private slots:
|
|
void show_error(QAbstractSocket::SocketError);
|
|
int connect_sucessful();
|
|
void recevie_file();
|
|
signals:
|
|
void sigSetLableText(QString);
|
|
|
|
void sigSetProgressValue(int);
|
|
void sigSetProgressMax(int);
|
|
|
|
private:
|
|
QTcpSocket *send;
|
|
bool bSendCloseFlag=true;
|
|
QFile *file;
|
|
QString m_strfileName;
|
|
QString m_strProName;
|
|
QString strCurSendDir="";
|
|
QSemaphore readAckSempahore;
|
|
qint64 sentAllBytes, restBytes, loadBytes;
|
|
QString m_strIp="";
|
|
int m_iPort=3333;
|
|
bool SendFileData(QString fileName);
|
|
qint64 dirFileSize(const QString &path,QStringList *list);
|
|
QStringList GetNeedFileList();
|
|
qint64 GetNeedFileAllSize(const QString &path,QStringList list);
|
|
void sendProJsonStart(qint64 iAllSize);
|
|
void sendProJsonFinished();
|
|
void start_transfer_byAckConsult(const QString &path,QStringList list);
|
|
QString FindLocalFileFromPath(const QString &strFilePath, const QString filename);
|
|
|
|
//void start_transfer(const QString &path, QStringList *list);
|
|
bool SendFileHead(QString fileName,QString strRelativePath);
|
|
bool SendFileEnd(QString fileName);
|
|
bool SynchronousSocketWrite();
|
|
QStringList m_NeedSendFileList;
|
|
bool m_bGetConsultAckFlag=false;
|
|
int m_reSendCount=0;
|
|
};
|
|
|
|
#endif // THREADSENDPRO_H
|