Welcome to mirror list, hosted at ThFree Co, Russian Federation.

thumbnailjob.cpp « gui « src - github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8d3ae5b30645fda5780898db45b6eaa4e21e1f3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * Copyright (C) by Roeland Jago Douma <roeland@famdouma.nl>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * for more details.
 */

#include "thumbnailjob.h"
#include "networkjobs.h"
#include "account.h"

namespace OCC {

ThumbnailJob::ThumbnailJob(const QString &path, AccountPtr account, QObject *parent)
    : AbstractNetworkJob(account, account->davUrl(), QStringLiteral("index.php/apps/files/api/v1/thumbnail/150/150") + path, parent)
{
    Q_ASSERT(path.startsWith(QLatin1Char('/')));
    setIgnoreCredentialFailure(true);
}

void ThumbnailJob::start()
{
    sendRequest("GET");
    AbstractNetworkJob::start();
}

bool ThumbnailJob::finished()
{
    const auto result = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
    QPixmap p;
    if (result == 200) {
        p.loadFromData(reply()->readAll());
        if (p.isNull()) {
            qWarning() << Q_FUNC_INFO << "Invalid thumbnail";
        }
    }
    emit jobFinished(result, p);
    return true;
}
}