| 1 | /* |
| 2 | This file is part of KDE. |
| 3 | |
| 4 | SPDX-FileCopyrightText: 2009 Frederik Gladhorn <gladhorn@kde.org> |
| 5 | |
| 6 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 7 | */ |
| 8 | |
| 9 | #ifndef ATTICA_METADATA_H |
| 10 | #define ATTICA_METADATA_H |
| 11 | |
| 12 | #include <QString> |
| 13 | |
| 14 | #include <QNetworkReply> |
| 15 | #include <QSharedDataPointer> |
| 16 | |
| 17 | #include "attica_export.h" |
| 18 | |
| 19 | namespace Attica |
| 20 | { |
| 21 | class BaseJob; |
| 22 | |
| 23 | /*! |
| 24 | * \class Attica::Metadata |
| 25 | * \inheaderfile Attica/Metadata |
| 26 | * \inmodule Attica |
| 27 | * |
| 28 | * \brief Status messages from the server. |
| 29 | */ |
| 30 | class ATTICA_EXPORT Metadata |
| 31 | { |
| 32 | public: |
| 33 | /*! |
| 34 | * |
| 35 | */ |
| 36 | Metadata(); |
| 37 | Metadata(const Metadata &other); |
| 38 | ~Metadata(); |
| 39 | Metadata &operator=(const Metadata &other); |
| 40 | |
| 41 | /*! |
| 42 | * \value NoError |
| 43 | * \value NetworkError |
| 44 | * \value OcsError |
| 45 | */ |
| 46 | enum Error { |
| 47 | NoError = 0, |
| 48 | NetworkError, |
| 49 | OcsError, |
| 50 | }; |
| 51 | |
| 52 | /*! |
| 53 | * Check if the job was successful. |
| 54 | * |
| 55 | * Returns the error state enum returns the type of error (network or ocs) |
| 56 | */ |
| 57 | Error error() const; |
| 58 | |
| 59 | /*! |
| 60 | * |
| 61 | */ |
| 62 | void setError(Error error); |
| 63 | |
| 64 | /*! |
| 65 | * The status as integer. |
| 66 | * |
| 67 | * If the error is an OCS error, refer to http://www.freedesktop.org/wiki/Specifications/open-collaboration-services |
| 68 | * in any other case it is the network return code. |
| 69 | */ |
| 70 | int statusCode() const; |
| 71 | |
| 72 | /*! |
| 73 | * |
| 74 | */ |
| 75 | void setStatusCode(int code); |
| 76 | |
| 77 | /*! |
| 78 | * The status of the job, for example "Ok" |
| 79 | */ |
| 80 | QString statusString() const; |
| 81 | |
| 82 | /*! |
| 83 | * |
| 84 | */ |
| 85 | void setStatusString(const QString &status); |
| 86 | |
| 87 | /*! |
| 88 | * An optional additional message from the server |
| 89 | */ |
| 90 | QString message(); |
| 91 | |
| 92 | /*! |
| 93 | * |
| 94 | */ |
| 95 | void setMessage(const QString &message); |
| 96 | |
| 97 | /*! |
| 98 | * The number of items returned by this job (only relevant for list jobs) |
| 99 | */ |
| 100 | int totalItems(); |
| 101 | |
| 102 | /*! |
| 103 | * |
| 104 | */ |
| 105 | void setTotalItems(int items); |
| 106 | |
| 107 | /*! |
| 108 | * The number of items per page the server was asked for |
| 109 | */ |
| 110 | int itemsPerPage(); |
| 111 | |
| 112 | /*! |
| 113 | * |
| 114 | */ |
| 115 | void setItemsPerPage(int itemsPerPage); |
| 116 | |
| 117 | /*! |
| 118 | * The resulting ID when a PostJob created a new item. |
| 119 | */ |
| 120 | QString resultingId(); |
| 121 | |
| 122 | /*! |
| 123 | * |
| 124 | */ |
| 125 | void setResultingId(const QString &id); |
| 126 | |
| 127 | /*! |
| 128 | * The http headers for the most recent network action in the case of a network error |
| 129 | * |
| 130 | * Use this to further inspect the error condition if the OCS status code and string is |
| 131 | * not enough to work out precisely what has happened (for example in case of a HTTP |
| 132 | * 503 status, which would suggest the service is down for maintenance for an expected |
| 133 | * duration which might be read from the Retry-After header). |
| 134 | * |
| 135 | * Returns the list of raw headers (equivalent to a QNetworkReply::rawHeaderPairs call) |
| 136 | * \since 5.83 |
| 137 | */ |
| 138 | QList<QNetworkReply::RawHeaderPair> () const; |
| 139 | |
| 140 | /*! |
| 141 | * Sets the http headers read by headers() |
| 142 | * |
| 143 | * \a headers The new list of raw headers |
| 144 | * \since 5.83 |
| 145 | */ |
| 146 | void (const QList<QNetworkReply::RawHeaderPair> &); |
| 147 | |
| 148 | private: |
| 149 | class Private; |
| 150 | QSharedDataPointer<Private> d; |
| 151 | |
| 152 | friend class Attica::BaseJob; |
| 153 | }; |
| 154 | |
| 155 | } |
| 156 | |
| 157 | #endif |
| 158 | |