view 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 source
#include "downloader.h"

#ifndef DOWNLOAD_SERVER
#define DOWNLOAD_SERVER "https://www.intevation.de"
#endif

#ifdef Q_OS_WIN
#endif

#include <QFile>
#include <QDir>
#include <QDebug>
#include <QStandardPaths>

Downloader::Downloader(QObject* parent, const QString& url,
                       const QByteArray& certificate,
                       const QDateTime& newestSW,
                       const QDateTime& newestList):
    QThread(parent),
    mUrl(url),
    mLastModSW(newestSW),
    mLastModList(newestList)
{
    if (certificate.isEmpty()) {
        QFile certResource(":certificates/https");
        certResource.open(QFile::ReadOnly);
        mCert = certResource.readAll();
        certResource.close();
    }
}

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();
}

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