1/*
2 This file is part of KDE.
3
4 SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8#ifndef ATTICA_ATTICABASEJOB_H
9#define ATTICA_ATTICABASEJOB_H
10
11#include <memory>
12
13#include <QNetworkAccessManager>
14#include <QNetworkRequest>
15#include <QObject>
16#include <QSharedPointer>
17#include <QUrl>
18
19#include "attica_export.h"
20#include "metadata.h"
21
22class QNetworkReply;
23
24namespace Attica
25{
26class PlatformDependent;
27
28/**
29 * @class BaseJob atticabasejob.h
30 *
31 * The baseclass for all job classes.
32 */
33class ATTICA_EXPORT BaseJob : public QObject
34{
35 Q_OBJECT
36
37public:
38 ~BaseJob() override;
39
40 Metadata metadata() const;
41
42 enum NetworkRequestCustomAttributes {
43 UserAttribute = QNetworkRequest::User + 1,
44 PasswordAttribute,
45 };
46
47 /**
48 * @returns whether abort() has been called on the job
49 *
50 * @since 5.87
51 */
52 bool isAborted() const;
53
54public Q_SLOTS:
55 void start();
56 void abort();
57
58Q_SIGNALS:
59 void finished(Attica::BaseJob *job);
60
61protected Q_SLOTS:
62 void dataFinished();
63
64protected:
65 BaseJob(PlatformDependent *internals);
66
67 void setMetadata(const Metadata &data) const;
68
69 virtual QNetworkReply *executeRequest() = 0;
70 virtual void parse(const QString &xml) = 0;
71 PlatformDependent *internals();
72 void setError(int errorCode);
73
74private Q_SLOTS:
75 ATTICA_NO_EXPORT void doWork();
76 ATTICA_NO_EXPORT void authenticationRequired(QNetworkReply *, QAuthenticator *);
77
78private:
79 BaseJob(const BaseJob &other) = delete;
80 BaseJob &operator=(const BaseJob &other) = delete;
81
82 class Private;
83 std::unique_ptr<Private> d;
84};
85
86}
87
88#endif
89

source code of attica/src/atticabasejob.h