Pimcommon

needupdateparsehtmljob.cpp
1/*
2 SPDX-FileCopyrightText: 2025 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "needupdateparsehtmljob.h"
8#include "pimcommon_debug.h"
9#include <QUrl>
10#include <kio/transferjob.h>
11
12using namespace PimCommon;
13NeedUpdateParseHtmlJob::NeedUpdateParseHtmlJob(QObject *parent)
14 : QObject{parent}
15{
16}
17
18NeedUpdateParseHtmlJob::~NeedUpdateParseHtmlJob() = default;
19
20bool NeedUpdateParseHtmlJob::canStart() const
21{
22 return !mUrl.isEmpty();
23}
24
25QUrl NeedUpdateParseHtmlJob::url() const
26{
27 return mUrl;
28}
29
30void NeedUpdateParseHtmlJob::setUrl(const QUrl &newUrl)
31{
32 mUrl = newUrl;
33}
34
35void NeedUpdateParseHtmlJob::start()
36{
37 if (!canStart()) {
38 qCWarning(PIMCOMMON_LOG) << "Impossible to start NeedUpdateParseHtmlJob";
39 Q_EMIT downLoadDone({});
41 return;
42 }
43 KIO::TransferJob *tjob = KIO::get(mUrl, KIO::Reload);
44 connect(tjob, &KIO::TransferJob::data, this, &NeedUpdateParseHtmlJob::slotHttpDataFile);
45}
46
47void NeedUpdateParseHtmlJob::slotHttpDataFile(KIO::Job *job, const QByteArray &data)
48{
49 Q_UNUSED(job);
50 if (data.isEmpty()) {
51 Q_EMIT downLoadDone(mData);
53 } else {
54 mData.append(QString::fromUtf8(data));
55 }
56}
57
58#include "moc_needupdateparsehtmljob.cpp"
void data(KIO::Job *job, const QByteArray &data)
KIOCORE_EXPORT TransferJob * get(const QUrl &url, LoadType reload=NoReload, JobFlags flags=DefaultFlags)
folderdialogacltab.h
bool isEmpty() const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void deleteLater()
QString fromUtf8(QByteArrayView str)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:47:24 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.