able to send file
This commit is contained in:
@@ -19,6 +19,8 @@ class AppController : public QObject
|
||||
Q_PROPERTY(bool serverRunning READ serverRunning NOTIFY serverRunningChanged)
|
||||
Q_PROPERTY(QString downloadPath READ downloadPath WRITE setDownloadPath NOTIFY downloadPathChanged)
|
||||
Q_PROPERTY(bool quickSave READ quickSave WRITE setQuickSave NOTIFY quickSaveChanged)
|
||||
Q_PROPERTY(bool sending READ sending NOTIFY sendingChanged)
|
||||
Q_PROPERTY(double sendProgress READ sendProgress NOTIFY sendProgressChanged)
|
||||
|
||||
public:
|
||||
explicit AppController(QObject* parent = nullptr);
|
||||
@@ -41,12 +43,18 @@ public:
|
||||
QVariantList devices() const;
|
||||
bool serverRunning() const;
|
||||
|
||||
bool sending() const;
|
||||
double sendProgress() const;
|
||||
|
||||
Q_INVOKABLE void startDiscovery();
|
||||
Q_INVOKABLE void stopDiscovery();
|
||||
Q_INVOKABLE void refreshDevices();
|
||||
|
||||
Q_INVOKABLE void acceptReceive(const QString& sessionId);
|
||||
Q_INVOKABLE void declineReceive(const QString& sessionId);
|
||||
|
||||
Q_INVOKABLE void sendFiles(const QString& deviceFingerprint, const QStringList& filePaths);
|
||||
Q_INVOKABLE void cancelSend();
|
||||
|
||||
signals:
|
||||
void aliasChanged();
|
||||
@@ -55,13 +63,15 @@ signals:
|
||||
void quickSaveChanged();
|
||||
void devicesChanged();
|
||||
void serverRunningChanged();
|
||||
void sendingChanged();
|
||||
void sendProgressChanged();
|
||||
void receiveRequest(const QString& sessionId, const QString& senderAlias,
|
||||
const QString& senderIp, const QVariantList& files);
|
||||
void receiveProgress(const QString& sessionId, const QString& fileId, double progress);
|
||||
void receiveCompleted(const QString& sessionId);
|
||||
void receiveError(const QString& sessionId, const QString& error);
|
||||
void sendProgress(const QString& sessionId, double progress);
|
||||
void sendCompleted(const QString& sessionId);
|
||||
void sendError(const QString& error);
|
||||
|
||||
private slots:
|
||||
void onDeviceDiscovered(const LocalSend::Device& device);
|
||||
@@ -76,6 +86,12 @@ private slots:
|
||||
void onSessionDeclined(const QString& sessionId);
|
||||
void onReceiveProgress(const QString& sessionId, const QString& fileId, double progress);
|
||||
void onReceiveCompleted(const QString& sessionId);
|
||||
|
||||
void onPrepareUploadResponse(const LocalSend::PrepareUploadResponseDto& response);
|
||||
void onPrepareUploadError(const QString& error);
|
||||
void onUploadProgress(qint64 sent, qint64 total);
|
||||
void onUploadCompleted();
|
||||
void onUploadError(const QString& error);
|
||||
|
||||
private:
|
||||
LocalSend::Settings* m_settings = nullptr;
|
||||
@@ -83,9 +99,19 @@ private:
|
||||
LocalSend::DiscoveryManager* m_discovery = nullptr;
|
||||
LocalSend::HttpServer* m_server = nullptr;
|
||||
LocalSend::SessionManager* m_sessions = nullptr;
|
||||
LocalSend::HttpClient* m_httpClient = nullptr;
|
||||
|
||||
QMap<QString, LocalSend::Device> m_devices;
|
||||
|
||||
QString m_currentSendSessionId;
|
||||
QString m_currentSendFileId;
|
||||
QString m_currentSendDeviceFingerprint;
|
||||
QStringList m_pendingFiles;
|
||||
int m_currentFileIndex = 0;
|
||||
double m_sendProgress = 0.0;
|
||||
|
||||
LocalSend::InfoDto buildInfoDto() const;
|
||||
QString generateUniqueFilePath(const QString& baseDir, const QString& fileName) const;
|
||||
void sendNextFile();
|
||||
LocalSend::RegisterDto buildRegisterDto() const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user