comparison 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
comparison
equal deleted inserted replaced
14:58d51a91d448 15:95e1b6edf2fc
6 6
7 #ifdef Q_OS_WIN 7 #ifdef Q_OS_WIN
8 #endif 8 #endif
9 9
10 #include <QFile> 10 #include <QFile>
11 #include <QDir>
11 #include <QDebug> 12 #include <QDebug>
13 #include <QStandardPaths>
12 14
13 Downloader::Downloader(QObject* parent, const QString& url): 15 Downloader::Downloader(QObject* parent, const QString& url,
16 const QByteArray& certificate,
17 const QDateTime& newestSW,
18 const QDateTime& newestList):
14 QThread(parent), 19 QThread(parent),
15 mUrl(url) 20 mUrl(url),
21 mLastModSW(newestSW),
22 mLastModList(newestList)
16 { 23 {
17 QFile certResource(":certificates/https"); 24 if (certificate.isEmpty()) {
18 certResource.open(QFile::ReadOnly); 25 QFile certResource(":certificates/https");
19 mCert = certResource.readAll(); 26 certResource.open(QFile::ReadOnly);
20 certResource.close(); 27 mCert = certResource.readAll();
28 certResource.close();
29 }
21 } 30 }
22 31
23 Downloader::Downloader(QObject* parent, const QString& url, 32 QString Downloader::getDataDirectory()
24 const QByteArray& certificate):
25 QThread(parent),
26 mUrl(url),
27 mCert(certificate)
28 { 33 {
34 QString candidate =
35 QStandardPaths::writableLocation(QStandardPaths::DataLocation);
29 36
37 if (candidate.isEmpty()) {
38 qDebug() << "Could not find writeable locaction for me";
39 return QString();
40 }
41
42 QDir cDir(candidate);
43
44 if (!cDir.exists()) {
45 if (!cDir.mkpath(candidate)) {
46 qDebug() << "Could not create path to: " << candidate;
47 return QString();
48 }
49 }
50 return cDir.absolutePath();
30 } 51 }
31

http://wald.intevation.org/projects/trustbridge/