Attica

atticabasejob.h
1 /*
2  This file is part of KDE.
3 
4  SPDX-FileCopyrightText: 2008 Cornelius Schumacher <[email protected]>
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 <QNetworkAccessManager>
12 #include <QNetworkRequest>
13 #include <QObject>
14 #include <QSharedPointer>
15 #include <QUrl>
16 
17 #include "attica_export.h"
18 #include "metadata.h"
19 
20 class QNetworkReply;
21 
22 namespace Attica
23 {
24 class PlatformDependent;
25 
26 /**
27  * @class BaseJob atticabasejob.h
28  *
29  * The baseclass for all job classes.
30  */
31 class ATTICA_EXPORT BaseJob : public QObject
32 {
33  Q_OBJECT
34 
35 public:
36  ~BaseJob() override;
37 
38  Metadata metadata() const;
39 
40  enum NetworkRequestCustomAttributes {
41  UserAttribute = QNetworkRequest::User + 1,
42  PasswordAttribute,
43  };
44 
45  /**
46  * @returns whether abort() has been called on the job
47  *
48  * @since 5.87
49  */
50  bool isAborted() const;
51 
52 public Q_SLOTS:
53  void start();
54  void abort();
55 
56 Q_SIGNALS:
57  void finished(Attica::BaseJob *job);
58 
59 protected Q_SLOTS:
60  void dataFinished();
61 
62 protected:
63  BaseJob(PlatformDependent *internals);
64 
65  void setMetadata(const Metadata &data) const;
66 
67  virtual QNetworkReply *executeRequest() = 0;
68  virtual void parse(const QString &xml) = 0;
69  PlatformDependent *internals();
70  void setError(int errorCode);
71 
72 private Q_SLOTS:
73  ATTICA_NO_EXPORT void doWork();
74  ATTICA_NO_EXPORT void authenticationRequired(QNetworkReply *, QAuthenticator *);
75 
76 private:
77  BaseJob(const BaseJob &other) = delete;
78  BaseJob &operator=(const BaseJob &other) = delete;
79 
80  class Private;
81  Private *d;
82 };
83 
84 }
85 
86 #endif
Q_SCRIPTABLE Q_NOREPLY void start()
Q_SCRIPTABLE Q_NOREPLY void abort()
The Attica namespace,.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 04:08:16 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.