File indexing completed on 2024-12-01 03:37:35
0001 /* 0002 This file is part of KDE. 0003 0004 SPDX-FileCopyrightText: 2009 Frederik Gladhorn <gladhorn@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #ifndef ATTICA_METADATA_H 0010 #define ATTICA_METADATA_H 0011 0012 #include <QString> 0013 0014 #include <QNetworkReply> 0015 #include <QSharedDataPointer> 0016 0017 #include "attica_export.h" 0018 0019 namespace Attica 0020 { 0021 class BaseJob; 0022 0023 /** 0024 * @class Metadata metadata.h <Attica/Metadata> 0025 * 0026 * Status messages from the server 0027 */ 0028 class ATTICA_EXPORT Metadata 0029 { 0030 public: 0031 Metadata(); 0032 Metadata(const Metadata &other); 0033 ~Metadata(); 0034 Metadata &operator=(const Metadata &other); 0035 0036 enum Error { 0037 NoError = 0, 0038 NetworkError, 0039 OcsError, 0040 }; 0041 0042 /** 0043 * Check if the job was successful. 0044 * @return the error state enum returns the type of error (network or ocs) 0045 */ 0046 Error error() const; 0047 void setError(Error error); 0048 0049 /** 0050 * The status as integer. 0051 * If the error is an OCS error, refer to http://www.freedesktop.org/wiki/Specifications/open-collaboration-services 0052 * in any other case it is the network return code. 0053 */ 0054 int statusCode() const; 0055 void setStatusCode(int code); 0056 0057 /** 0058 * The status of the job, for example "Ok" 0059 */ 0060 QString statusString() const; 0061 void setStatusString(const QString &status); 0062 0063 /// An optional additional message from the server 0064 QString message(); 0065 void setMessage(const QString &message); 0066 0067 /// The number of items returned by this job (only relevant for list jobs) 0068 int totalItems(); 0069 void setTotalItems(int items); 0070 0071 /// The number of items per page the server was asked for 0072 int itemsPerPage(); 0073 void setItemsPerPage(int itemsPerPage); 0074 0075 /// The resulting ID when a PostJob created a new item. 0076 QString resultingId(); 0077 void setResultingId(const QString &id); 0078 0079 /** 0080 * The http headers for the most recent network action in the case of a network error 0081 * Use this to further inspect the error condition if the OCS status code and string is 0082 * not enough to work out precisely what has happened (for example in case of a HTTP 0083 * 503 status, which would suggest the service is down for maintenance for an expected 0084 * duration which might be read from the Retry-After header). 0085 * @return The list of raw headers (equivalent to a QNetworkReply::rawHeaderPairs call) 0086 * @since 5.83 0087 */ 0088 QList<QNetworkReply::RawHeaderPair> headers() const; 0089 /** 0090 * Sets the http headers read by headers() 0091 * @param headers The new list of raw headers 0092 * @since 5.83 0093 */ 0094 void setHeaders(const QList<QNetworkReply::RawHeaderPair> &headers); 0095 0096 private: 0097 class Private; 0098 QSharedDataPointer<Private> d; 0099 0100 friend class Attica::BaseJob; 0101 }; 0102 0103 } 0104 0105 #endif