Libkdav2

davjobbase.h
1/*
2 Copyright (c) 2014 Gregory Oestreicher <greg@kamago.net>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17*/
18
19#ifndef KDAV2_DAVJOBBASE_H
20#define KDAV2_DAVJOBBASE_H
21
22#include <memory>
23#include "kpimkdav2_export.h"
24#include <KJob>
25#include "daverror.h"
26
27struct DavJobBasePrivate;
28
29namespace KDAV2
30{
31class Error;
32class DavJob;
33
34/**
35 * @short base class for the jobs used by the resource.
36 */
37class KPIMKDAV2_EXPORT DavJobBase : public KJob
38{
39 Q_OBJECT
40
41public:
42 explicit DavJobBase(QObject *parent = nullptr);
44
45 /**
46 * Get the latest http status code.
47 *
48 * If no response code has been set then 0 will be returned, but will
49 * be meaningless unless error() is non-zero. In that case this means
50 * that the latest error was not at the HTTP level.
51 */
52 unsigned int latestHttpStatusCode() const;
53
54 /**
55 * Get the response code.
56 *
57 * This is a QNetworkReply::NetworkError
58 *
59 * If no response code has been set then 0 will be returned, but will
60 * be meaningless unless error() is non-zero. In that case this means
61 * that the latest error was not at the HTTP level.
62 *
63 */
64 unsigned int latestResponseCode() const;
65
66 /**
67 * Check if the job can be retried later.
68 *
69 * This will return true for transient errors, i.e. if the response code
70 * is either zero and error() is set or if the HTTP response code hints
71 * at a temporary error.
72 *
73 * The HTTP response codes considered retryable are:
74 * - 401
75 * - 402
76 * - 407
77 * - 408
78 * - 423
79 * - 429
80 * - 501 to 504, inclusive
81 * - 507
82 * - 511
83 */
84 bool canRetryLater() const;
85
86 /**
87 * Check if the job failed because of a conflict
88 */
89 bool hasConflict() const;
90
91 /**
92 * Returns a instance of the KDAV2:Error to be able to translate the error
93 */
94 Error davError() const;
95
96protected:
97 void setErrorTextFromDavError();
98 void setDavError(const Error &error);
99
100 /**
101 * Set the error of this job from a failed DavJob (executed by this job).
102 */
103 void setErrorFromJob(DavJob*, ErrorNumber jobErrorCode = ERR_PROBLEM_WITH_REQUEST);
104private:
105 std::unique_ptr<DavJobBasePrivate> d;
106};
107
108}
109
110#endif
base class for the jobs used by the resource.
Definition davjobbase.h:38
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:05 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.