Mercurial > trustbridge
diff ui/downloader.cpp @ 15:95e1b6edf2fc
Implement more downloader functionality for Windows
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 19 Feb 2014 10:45:06 +0000 |
parents | 9121eea6d93f |
children | f4f957c58e0a |
line wrap: on
line diff
--- a/ui/downloader.cpp Wed Feb 19 10:44:40 2014 +0000 +++ b/ui/downloader.cpp Wed Feb 19 10:45:06 2014 +0000 @@ -8,24 +8,44 @@ #endif #include <QFile> +#include <QDir> #include <QDebug> +#include <QStandardPaths> -Downloader::Downloader(QObject* parent, const QString& url): +Downloader::Downloader(QObject* parent, const QString& url, + const QByteArray& certificate, + const QDateTime& newestSW, + const QDateTime& newestList): QThread(parent), - mUrl(url) + mUrl(url), + mLastModSW(newestSW), + mLastModList(newestList) { - QFile certResource(":certificates/https"); - certResource.open(QFile::ReadOnly); - mCert = certResource.readAll(); - certResource.close(); + if (certificate.isEmpty()) { + QFile certResource(":certificates/https"); + certResource.open(QFile::ReadOnly); + mCert = certResource.readAll(); + certResource.close(); + } } -Downloader::Downloader(QObject* parent, const QString& url, - const QByteArray& certificate): - QThread(parent), - mUrl(url), - mCert(certificate) +QString Downloader::getDataDirectory() { + QString candidate = + QStandardPaths::writableLocation(QStandardPaths::DataLocation); + if (candidate.isEmpty()) { + qDebug() << "Could not find writeable locaction for me"; + return QString(); + } + + QDir cDir(candidate); + + if (!cDir.exists()) { + if (!cDir.mkpath(candidate)) { + qDebug() << "Could not create path to: " << candidate; + return QString(); + } + } + return cDir.absolutePath(); } -