File indexing completed on 2024-04-28 03:53:55
0001 /* 0002 SPDX-FileCopyrightText: 2014 Gregory Oestreicher <greg@kamago.net> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDAV_DAVJOBBASE_H 0008 #define KDAV_DAVJOBBASE_H 0009 0010 #include "kdav_export.h" 0011 0012 #include <KJob> 0013 0014 #include <memory> 0015 0016 namespace KDAV 0017 { 0018 class DavJobBasePrivate; 0019 class Error; 0020 0021 /** 0022 * @class DavJobBase davjobbase.h <KDAV/DavJobBase> 0023 * 0024 * @short base class for the jobs used by the resource. 0025 */ 0026 class KDAV_EXPORT DavJobBase : public KJob 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 explicit DavJobBase(QObject *parent = nullptr); 0032 ~DavJobBase() override; 0033 0034 /** 0035 * Get the latest response code. 0036 * 0037 * If no response code has been set then 0 will be returned, but will 0038 * be meaningless unless error() is non-zero. In that case this means 0039 * that the latest error was not at the HTTP level. 0040 */ 0041 Q_REQUIRED_RESULT int latestResponseCode() const; 0042 0043 /** 0044 * Check if the job can be retried later. 0045 * 0046 * This will return true for transient errors, i.e. if the response code 0047 * is either zero and error() is set or if the HTTP response code hints 0048 * at a temporary error. 0049 * 0050 * The HTTP response codes considered retryable are: 0051 * - 401 0052 * - 402 0053 * - 407 0054 * - 408 0055 * - 423 0056 * - 429 0057 * - 501 to 504, inclusive 0058 * - 507 0059 * - 511 0060 */ 0061 Q_REQUIRED_RESULT bool canRetryLater() const; 0062 0063 /** 0064 * Check if the job failed because of a conflict 0065 */ 0066 Q_REQUIRED_RESULT bool hasConflict() const; 0067 0068 /** 0069 * Returns a instance of the KDAV:Error to be able to translate the error 0070 */ 0071 Q_REQUIRED_RESULT Error davError() const; 0072 0073 protected: 0074 Q_DECL_HIDDEN explicit DavJobBase(DavJobBasePrivate *dd, QObject *parent = nullptr); 0075 std::unique_ptr<DavJobBasePrivate> d_ptr; 0076 0077 private: 0078 Q_DECLARE_PRIVATE(DavJobBase) 0079 }; 0080 } 0081 0082 #endif