| 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 | #include "metadata.h" |
| 10 | |
| 11 | #include <QSharedData> |
| 12 | |
| 13 | using namespace Attica; |
| 14 | |
| 15 | class Q_DECL_HIDDEN Metadata::Private : public QSharedData |
| 16 | { |
| 17 | public: |
| 18 | Error error; |
| 19 | |
| 20 | /// The status of the job, for example "Ok" |
| 21 | QString statusString; |
| 22 | /// The status as int, for easier interpretation. |
| 23 | /// 100 means "Ok", for other codes refer to http://www.freedesktop.org/wiki/Specifications/open-collaboration-services |
| 24 | int statusCode; |
| 25 | |
| 26 | /// An optional additional message from the server |
| 27 | QString message; |
| 28 | |
| 29 | /// The number of items returned by this job (only relevant for list jobs) |
| 30 | int totalItems; |
| 31 | /// The number of items per page the server was asked for |
| 32 | int itemsPerPage; |
| 33 | |
| 34 | QString resultingId; |
| 35 | |
| 36 | /// The http headers for the most recent network action in the case of a network error |
| 37 | QList<QNetworkReply::RawHeaderPair> headers; |
| 38 | |
| 39 | Private() |
| 40 | // values that make sense for single item jobs |
| 41 | : error(NoError) |
| 42 | , statusCode(0) |
| 43 | , totalItems(1) |
| 44 | , itemsPerPage(1) |
| 45 | { |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | Metadata::Metadata() |
| 50 | : d(new Private) |
| 51 | { |
| 52 | } |
| 53 | |
| 54 | Metadata::~Metadata() |
| 55 | { |
| 56 | } |
| 57 | |
| 58 | Metadata::Metadata(const Attica::Metadata &other) |
| 59 | : d(other.d) |
| 60 | { |
| 61 | } |
| 62 | |
| 63 | Metadata &Metadata::operator=(const Attica::Metadata &other) |
| 64 | { |
| 65 | d = other.d; |
| 66 | return *this; |
| 67 | } |
| 68 | |
| 69 | Metadata::Error Metadata::error() const |
| 70 | { |
| 71 | return d->error; |
| 72 | } |
| 73 | |
| 74 | void Metadata::setError(Metadata::Error error) |
| 75 | { |
| 76 | d->error = error; |
| 77 | } |
| 78 | |
| 79 | QString Metadata::message() |
| 80 | { |
| 81 | return d->message; |
| 82 | } |
| 83 | |
| 84 | void Metadata::setMessage(const QString &message) |
| 85 | { |
| 86 | d->message = message; |
| 87 | } |
| 88 | |
| 89 | QString Metadata::resultingId() |
| 90 | { |
| 91 | return d->resultingId; |
| 92 | } |
| 93 | |
| 94 | void Metadata::setResultingId(const QString &id) |
| 95 | { |
| 96 | d->resultingId = id; |
| 97 | } |
| 98 | |
| 99 | int Metadata::statusCode() const |
| 100 | { |
| 101 | return d->statusCode; |
| 102 | } |
| 103 | |
| 104 | void Metadata::setStatusCode(int code) |
| 105 | { |
| 106 | d->statusCode = code; |
| 107 | } |
| 108 | |
| 109 | QString Metadata::statusString() const |
| 110 | { |
| 111 | return d->statusString; |
| 112 | } |
| 113 | |
| 114 | void Metadata::setStatusString(const QString &status) |
| 115 | { |
| 116 | d->statusString = status; |
| 117 | } |
| 118 | |
| 119 | int Metadata::totalItems() |
| 120 | { |
| 121 | return d->totalItems; |
| 122 | } |
| 123 | |
| 124 | void Metadata::setTotalItems(int items) |
| 125 | { |
| 126 | d->totalItems = items; |
| 127 | } |
| 128 | |
| 129 | int Metadata::itemsPerPage() |
| 130 | { |
| 131 | return d->itemsPerPage; |
| 132 | } |
| 133 | |
| 134 | void Metadata::setItemsPerPage(int itemsPerPage) |
| 135 | { |
| 136 | d->itemsPerPage = itemsPerPage; |
| 137 | } |
| 138 | |
| 139 | QList<QNetworkReply::RawHeaderPair> Metadata::headers() const |
| 140 | { |
| 141 | return d->headers; |
| 142 | } |
| 143 | |
| 144 | void Metadata::setHeaders(const QList<QNetworkReply::RawHeaderPair> &headers) |
| 145 | { |
| 146 | d->headers = headers; |
| 147 | } |
| 148 |
