diff options
| author | Jonathan Bauer | 2011-03-15 23:37:21 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2011-03-15 23:37:21 +0100 |
| commit | f895dda6697c9c5edab87e7263d9c38a17ccb811 (patch) | |
| tree | 3186bd8b6bf1a94079068546182f457e19898df2 | |
| parent | fbgui.conf default paths checks, update interval modifiable (only in .conf), ... (diff) | |
| download | fbgui-f895dda6697c9c5edab87e7263d9c38a17ccb811.tar.gz fbgui-f895dda6697c9c5edab87e7263d9c38a17ccb811.tar.xz fbgui-f895dda6697c9c5edab87e7263d9c38a17ccb811.zip | |
fixes
| -rw-r--r-- | src/downloadManager.cpp | 19 | ||||
| -rw-r--r-- | src/downloadManager.h | 2 | ||||
| -rw-r--r-- | src/fbgui.conf | 2 | ||||
| -rw-r--r-- | src/fbgui.cpp | 3 | ||||
| -rw-r--r-- | src/sysInfo.cpp | 6 |
5 files changed, 20 insertions, 12 deletions
diff --git a/src/downloadManager.cpp b/src/downloadManager.cpp index dca99d3..f7a6372 100644 --- a/src/downloadManager.cpp +++ b/src/downloadManager.cpp @@ -19,7 +19,8 @@ downloadManager::downloadManager() else if (debug) qDebug() << "Download directory: " << downloadDir.path() << "exists."; } // ---------------------------------------------------------------------------------------- -void downloadManager::downloadFile(QString& filename){ +void downloadManager::downloadFile(QString& filename) +{ if (debug) qDebug() << "Received downloadFile signal for:" << filename; QUrl fileUrl; fileUrl = baseURL.resolved(QUrl(filename)); @@ -27,7 +28,8 @@ void downloadManager::downloadFile(QString& filename){ this->processDownloadRequest(fileUrl); } // ---------------------------------------------------------------------------------------- -void downloadManager::downloadFile(QUrl& fileUrl){ +void downloadManager::downloadFile(QUrl& fileUrl) +{ if (debug) qDebug() << "Received downloadFile signal for:" << fileUrl; this->processDownloadRequest(fileUrl); } @@ -88,6 +90,7 @@ void downloadManager::startNextDownload() } lastProgress = 0; + currentProgress = 0; dip = true; QObject::connect(currentDownload, SIGNAL(readyRead()), this, SLOT(downloadReady())); QObject::connect(currentDownload, SIGNAL(downloadProgress(qint64, qint64)), @@ -105,9 +108,14 @@ void downloadManager::downloadReady() // ---------------------------------------------------------------------------------------- void downloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal) { + if (bytesIn > bytesTotal) + return; + /* Update progress only if difference higher than the updateInterval setting */ - int currentProgress = ((bytesIn * 100) / bytesTotal); - if (currentProgress - lastProgress > updateInterval){ + int tmp = ((bytesIn * 100) / bytesTotal); + if (tmp > 0) + currentProgress = tmp; + if (currentProgress - lastProgress >= updateInterval){ lastProgress = currentProgress; emit updateProgress(currentDownload->url().toString(), currentProgress); if (debug) qDebug() << "Download progress of " << currentDownload->url().toString() @@ -118,7 +126,7 @@ void downloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal) // ---------------------------------------------------------------------------------------- void downloadManager::downloadFinished() { - /* Header filename fetching & renaming, old-ish + /* Header filename fetching & renaming const QByteArray cd = "Content-Disposition"; QByteArray cdc = currentDownload->rawHeader(cd); int x = cdc.indexOf("filename=\"") + 10; @@ -154,4 +162,5 @@ void downloadManager::downloadFinished() } startNextDownload(); } +// ---------------------------------------------------------------------------------------- diff --git a/src/downloadManager.h b/src/downloadManager.h index 98381a2..c556cb3 100644 --- a/src/downloadManager.h +++ b/src/downloadManager.h @@ -47,7 +47,7 @@ private: QFile outfile; QDir downloadDir; bool dip; - int lastProgress; + int currentProgress, lastProgress; static int downloaded; QString currentTargetFilename; diff --git a/src/fbgui.conf b/src/fbgui.conf index 58c35e8..c4642dc 100644 --- a/src/fbgui.conf +++ b/src/fbgui.conf @@ -1,4 +1,4 @@ [default] url=http://m.openslx.org downloadDirectory=/downloads -updateInterval=2 +updateInterval=7 diff --git a/src/fbgui.cpp b/src/fbgui.cpp index cd58863..e74db26 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -44,7 +44,8 @@ fbgui::fbgui() } //------------------------------------------------------------------------------------------- -void fbgui::checkHost() const { +void fbgui::checkHost() const +{ QHostInfo hostInfo = QHostInfo::fromName(baseURL.host()); if (hostInfo.error() != QHostInfo::NoError){ qDebug() << "Lookup of " << baseURL.host() << "failed." << "Exiting..."; diff --git a/src/sysInfo.cpp b/src/sysInfo.cpp index f17f42b..ca20b95 100644 --- a/src/sysInfo.cpp +++ b/src/sysInfo.cpp @@ -6,7 +6,6 @@ #include <QVariantList> #include <QByteArray> -//static int eth0_index = 0; // ------------------------------------------------------------------------------------------------ sysInfo::sysInfo(){ if (debug) qDebug() << "sysInfo created."; @@ -25,7 +24,7 @@ QString sysInfo::getInfo(QString& infoName){ return getAllInfos(); else if (infoName == QString("json")) return getNames(); - // still here? + /* unknown code */ return "info_error"; } // ------------------------------------------------------------------------------------------------ @@ -56,6 +55,7 @@ QString sysInfo::getIPAddress(){ if (debug) qDebug() << "ip_error"; return "ip_error"; } +// ------------------------------------------------------------------------------------------------ QByteArray sysInfo::getNames(){ QVariantMap foo; @@ -91,8 +91,6 @@ QString sysInfo::getAllInfos(){ return json; } // ------------------------------------------------------------------------------------------------ - -// ------------------------------------------------------------------------------------------------ QString sysInfo::getScriptOutput(QString cmd) { QProcess *process = new QProcess(); |
