diff options
author | Jonathan Bauer | 2011-03-25 22:55:14 +0100 |
---|---|---|
committer | Jonathan Bauer | 2011-03-25 22:55:14 +0100 |
commit | 66244c1853caca19a24581bff37bd11dc47a0f53 (patch) | |
tree | 053ec0c4042a0894f86e1da184b3385427e7ad34 /src | |
parent | today's fixes, POST mostly (diff) | |
download | fbgui-66244c1853caca19a24581bff37bd11dc47a0f53.tar.gz fbgui-66244c1853caca19a24581bff37bd11dc47a0f53.tar.xz fbgui-66244c1853caca19a24581bff37bd11dc47a0f53.zip |
fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/downloadmanager.cpp | 44 | ||||
-rw-r--r-- | src/fbgui.cpp | 8 | ||||
-rw-r--r-- | src/html/style.css | 1 | ||||
-rw-r--r-- | src/main.cpp | 31 |
4 files changed, 49 insertions, 35 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index fbac866..3582a2a 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -2,15 +2,14 @@ #include "fbgui.h" int DownloadManager::downloaded = 0; -// ---------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------------- DownloadManager::DownloadManager(){ qxtLog->debug() << "Initializing download manager..."; checkDownloadDirectory(); qnam = new QNetworkAccessManager(); dip = false; } - -// ---------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------------- void DownloadManager::checkDownloadDirectory() { // check if downloadPath exists, if not create it. @@ -44,37 +43,40 @@ void DownloadManager::checkDownloadDirectory() qxtLog->debug() << "[dm] Saving downloads to: " << downloadDir.absolutePath(); //downloadPath = downloadDir.absolutePath(); } -// ---------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------------- +// Public access +// ------------------------------------------------------------------------------------------------------- void DownloadManager::downloadFile(const QString& filename) { QUrl fileUrl(baseURL.resolved(QUrl(filename))); this->processDownloadRequest(fileUrl); } -// ---------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------------- void DownloadManager::downloadFile(const QUrl& fileUrl) { this->processDownloadRequest(fileUrl); } -// ---------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------------- +// Private functions handling download requests and queueing +// ------------------------------------------------------------------------------------------------------- void DownloadManager::processDownloadRequest(const QUrl& url) { if (url.isEmpty()){ qxtLog->debug() << "[dm] No URL specified for download."; return; } - // if download in progress, enqueue file and return. + qxtLog->debug() << "[dm] Enqueueing:" << url.toString(); + dlQ.enqueue(url); if (dip){ - dlQ.enqueue(url); + // download in progress, return. qxtLog->debug() << "[dm] Download in progress! Queued:" << url.toString() << "(" << dlQ.size() << " in queue)"; return; } - // no running downloads: enqueue and start next download. - dlQ.enqueue(url); - qxtLog->debug() << "[dm] Enqueueing:" << url.toString(); + // no running downloads: start next in queue startNextDownload(); } -// ---------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------------- void DownloadManager::startNextDownload() { if (dlQ.isEmpty()){ @@ -120,9 +122,9 @@ void DownloadManager::startNextDownload() this, SLOT(downloadProgress(qint64, qint64))); QObject::connect(currentDownload, SIGNAL(finished()), this, SLOT(downloadFinished())); } -// ---------------------------------------------------------------------------------------- -// Private slots to process downloads -// ---------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------------- +// Private slots to handle a download in progress +// ------------------------------------------------------------------------------------------------------- void DownloadManager::processMetaInfo() { // fetch filesize from header & filename from URL (for now) @@ -131,13 +133,13 @@ void DownloadManager::processMetaInfo() QFileInfo fi(outfile); emit downloadInfo(outfile.fileName(), clinfo.toDouble()); } -// ---------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------------- void DownloadManager::downloadReady() { // data ready, save it outfile.write(currentDownload->readAll()); } -// ---------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------------- void DownloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal) { if (bytesIn > bytesTotal) return; @@ -165,18 +167,18 @@ void DownloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal) } return; } -// ---------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------------- void DownloadManager::downloadFinished() { // check for errors if (currentDownload->error()){ - currentDownload->deleteLater(); outfile.close(); outfile.remove(); int statusCode = currentDownload->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); qxtLog->debug() << "[dm] Download of " << currentDownload->url().toString() << " failed with HTTP error code: " << statusCode; emit notify(QString("Download failed! HTTP Status Code: %1").arg(statusCode)); + currentDownload->deleteLater(); } else{ // if kcl, append the session ID to it @@ -185,15 +187,15 @@ void DownloadManager::downloadFinished() outfile.write(" alpha=" + sessionID.toUtf8()); } // end download - currentDownload->deleteLater(); outfile.close(); downloaded++; qxtLog->debug() << "[dm] Download of " << currentDownload->url().toString() << " finished. (downloaded = "<< downloaded << ")"; emit notify(QString("Successfully downloaded %1").arg(currentDownload->url().toString())); + currentDownload->deleteLater(); } dip = false; - // process next in queue + // process next in queue, if any if (dlQ.isEmpty()){ emit downloadQueueEmpty(); qxtLog->debug() << "[dm] Download manager ready. (2)"; diff --git a/src/fbgui.cpp b/src/fbgui.cpp index c263b38..1f706c7 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -23,9 +23,9 @@ int debugMode = -1; fbgui::fbgui() { // test for libsys function - SysInfoLibsysfs* sil = new SysInfoLibsysfs(); - sil->getInfoAboutNetworkInterface(); - sil->getInfoAboutClassNet(); + //SysInfoLibsysfs* sil = new SysInfoLibsysfs(); + //sil->getInfoAboutNetworkInterface(); + //sil->getInfoAboutClassNet(); setupBasicDebug(); setupLayout(); @@ -208,7 +208,7 @@ QByteArray fbgui::generatePOSTData() void fbgui::setupBasicDebug() { // start basic console debug log - if (debugMode == 0 || debugMode == 1){ + if (debugMode > -1){ qxtLog->disableLoggerEngine("DEFAULT"); qxtLog->addLoggerEngine("std_logger", new LoggerEngine_std); qxtLog->initLoggerEngine("std_logger"); diff --git a/src/html/style.css b/src/html/style.css index a775f9e..9fd70aa 100644 --- a/src/html/style.css +++ b/src/html/style.css @@ -7,6 +7,7 @@ body{ background-color:black; background-image:url('bg.jpg'); background-repeat: no-repeat; + background-size:100%; } #top{ position:absolute; diff --git a/src/main.cpp b/src/main.cpp index c4902c6..3e643a4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -142,16 +142,27 @@ int main(int argc, char *argv[]) else if (confFileSettings.contains("default/serial_location")) serialLocation = confFileSettings.value("default/serial_location").toString(); else - serialLocation = QString("/serial"); - - // basic std out engine is ugly... not yet initialised so using qDebug - qDebug() << "************* CONFIG INFO *************"; - qDebug() << "configFilePath: " << configFilePath.toUtf8(); - qDebug() << "baseURL: " << baseURL.toString().toUtf8(); - qDebug() << "downloadDir : " << downloadPath.toUtf8(); - qDebug() << "trigger: " << fileToTriggerURL.toUtf8(); - qDebug() << "serialLocation: " << serialLocation.toUtf8(); - qDebug() << "*******************************************"; + serialLocation = QString("/serial"); // tests + + // debug config printing + QTextStream out(stdout); + if (debugMode > -1){ + out << "************* CONFIG INFO *************\n"; + out << "configFilePath: " << configFilePath.toUtf8() << endl; + out << "baseURL: " << baseURL.toString().toUtf8() << endl; + out << "downloadDir : " << downloadPath.toUtf8() << endl; + out << "trigger: " << fileToTriggerURL.toUtf8() << endl; + out << "serialLocation: " << serialLocation.toUtf8() << endl; + out << "*******************************************\n"; + } + + // purge /tmp/fbgui + if (QDir(QApplication::applicationFilePath()).rmdir("/tmp/fbgui")) + out << "Cleaned /tmp/fbgui...\n"; + else + out << "Nope...\n"; + + out.flush(); // start fbgui fbgui gui; |