From 2a437f6cdb98782cf1f5c918a1f5b16298fbc117 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 18 Jun 2016 19:52:51 +0200 Subject: [PATCH] Fixed: Download of data and client --HG-- branch : develop --- .../client/ryzom_installer/src/downloader.cpp | 10 ++++++- .../client/ryzom_installer/src/downloader.h | 4 +++ .../ryzom_installer/src/operationdialog.cpp | 29 +++++++++++++++++++ .../ryzom_installer/src/operationdialog.h | 5 ++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp b/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp index 3c85a8031..ba49a8842 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp @@ -147,6 +147,8 @@ void CDownloader::getFileHead() { // file is already downloaded if (m_listener) m_listener->operationSuccess(m_size); + + emit downloadDone(); } else { @@ -339,6 +341,10 @@ void CDownloader::onHeadFinished() downloadFile(); } } + else + { + emit downloadPrepared(); + } } void CDownloader::onDownloadFinished() @@ -357,6 +363,8 @@ void CDownloader::onDownloadFinished() bool ok = NLMISC::CFile::setFileModificationDate(m_fullPath.toUtf8().constData(), m_lastModified.toTime_t()); if (m_listener) m_listener->operationSuccess(m_size); + + emit downloadDone(); } } @@ -380,7 +388,7 @@ void CDownloader::onDownloadProgress(qint64 current, qint64 total) if (!m_listener) return; - m_listener->operationProgress(m_offset + current, ""); // TODO: put file + m_listener->operationProgress(m_offset + current, m_url); // abort download if (m_listener->operationShouldStop() && m_reply) m_reply->abort(); diff --git a/code/ryzom/tools/client/ryzom_installer/src/downloader.h b/code/ryzom/tools/client/ryzom_installer/src/downloader.h index 4d3163723..585e4d59a 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/downloader.h +++ b/code/ryzom/tools/client/ryzom_installer/src/downloader.h @@ -42,7 +42,11 @@ public: bool isDownloading() const { return m_file != NULL; } + QString getFileFullPath() const { return m_fullPath; } + signals: + void downloadPrepared(); + void downloadDone(); void htmlPageContent(const QString &html); private slots: diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index 9870bedcf..1975364ea 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -54,6 +54,9 @@ COperationDialog::COperationDialog(QWidget *parent):QDialog(parent), m_aborting( // downloader m_downloader = new CDownloader(this, this); + connect(m_downloader, SIGNAL(downloadPrepared()), SLOT(onDownloadPrepared())); + connect(m_downloader, SIGNAL(downloadDone()), SLOT(onDownloadDone())); + connect(operationButtonBox, SIGNAL(clicked(QAbstractButton*)), SLOT(onAbortClicked())); // operations @@ -343,6 +346,19 @@ void COperationDialog::onAbortClicked() m_aborting = true; } +void COperationDialog::onDownloadPrepared() +{ + // actually download the file + m_downloader->getFile(); +} + +void COperationDialog::onDownloadDone() +{ + renamePartFile(); + + emit done(); +} + void COperationDialog::onProgressPrepare() { operationProgressBar->setFormat(tr("%p% (%v/%m KiB)")); @@ -948,3 +964,16 @@ bool COperationDialog::operationShouldStop() return m_aborting; } + +void COperationDialog::renamePartFile() +{ + QString partFile = m_downloader->getFileFullPath(); + + QString finalFile = partFile; + finalFile.remove(".part"); + + if (partFile != finalFile) + { + QFile::rename(partFile, finalFile); + } +} diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h index c37f08e42..732e0afad 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h @@ -44,6 +44,9 @@ public: public slots: void onAbortClicked(); + void onDownloadPrepared(); + void onDownloadDone(); + void onProgressPrepare(); void onProgressInit(qint64 current, qint64 total); void onProgressStart(); @@ -117,6 +120,8 @@ protected: virtual bool operationShouldStop(); + void renamePartFile(); + QWinTaskbarButton *m_button; CDownloader *m_downloader;