1 | /* |
2 | SPDX-FileCopyrightText: 2014 Gregory Oestreicher <greg@kamago.net> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef KDAV_DAVJOBBASE_H |
8 | #define KDAV_DAVJOBBASE_H |
9 | |
10 | #include "kdav_export.h" |
11 | |
12 | #include <KJob> |
13 | |
14 | #include <memory> |
15 | |
16 | namespace KDAV |
17 | { |
18 | class DavJobBasePrivate; |
19 | class Error; |
20 | |
21 | /** |
22 | * @class DavJobBase davjobbase.h <KDAV/DavJobBase> |
23 | * |
24 | * @short base class for the jobs used by the resource. |
25 | */ |
26 | class KDAV_EXPORT DavJobBase : public KJob |
27 | { |
28 | Q_OBJECT |
29 | |
30 | public: |
31 | explicit DavJobBase(QObject *parent = nullptr); |
32 | ~DavJobBase() override; |
33 | |
34 | /** |
35 | * Get the latest response code. |
36 | * |
37 | * If no response code has been set then 0 will be returned, but will |
38 | * be meaningless unless error() is non-zero. In that case this means |
39 | * that the latest error was not at the HTTP level. |
40 | */ |
41 | Q_REQUIRED_RESULT int latestResponseCode() const; |
42 | |
43 | /** |
44 | * Check if the job can be retried later. |
45 | * |
46 | * This will return true for transient errors, i.e. if the response code |
47 | * is either zero and error() is set or if the HTTP response code hints |
48 | * at a temporary error. |
49 | * |
50 | * The HTTP response codes considered retryable are: |
51 | * - 401 |
52 | * - 402 |
53 | * - 407 |
54 | * - 408 |
55 | * - 423 |
56 | * - 429 |
57 | * - 501 to 504, inclusive |
58 | * - 507 |
59 | * - 511 |
60 | */ |
61 | Q_REQUIRED_RESULT bool canRetryLater() const; |
62 | |
63 | /** |
64 | * Check if the job failed because of a conflict |
65 | */ |
66 | Q_REQUIRED_RESULT bool hasConflict() const; |
67 | |
68 | /** |
69 | * Returns a instance of the KDAV:Error to be able to translate the error |
70 | */ |
71 | Q_REQUIRED_RESULT Error davError() const; |
72 | |
73 | protected: |
74 | Q_DECL_HIDDEN explicit DavJobBase(DavJobBasePrivate *dd, QObject *parent = nullptr); |
75 | std::unique_ptr<DavJobBasePrivate> d_ptr; |
76 | |
77 | private: |
78 | Q_DECLARE_PRIVATE(DavJobBase) |
79 | }; |
80 | } |
81 | |
82 | #endif |
83 | |