File indexing completed on 2024-09-29 12:01:32
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 #include "metadata.h" 0010 0011 #include <QSharedData> 0012 0013 using namespace Attica; 0014 0015 class Q_DECL_HIDDEN Metadata::Private : public QSharedData 0016 { 0017 public: 0018 Error error; 0019 0020 /// The status of the job, for example "Ok" 0021 QString statusString; 0022 /// The status as int, for easier interpretation. 0023 /// 100 means "Ok", for other codes refer to http://www.freedesktop.org/wiki/Specifications/open-collaboration-services 0024 int statusCode; 0025 0026 /// An optional additional message from the server 0027 QString message; 0028 0029 /// The number of items returned by this job (only relevant for list jobs) 0030 int totalItems; 0031 /// The number of items per page the server was asked for 0032 int itemsPerPage; 0033 0034 QString resultingId; 0035 0036 /// The http headers for the most recent network action in the case of a network error 0037 QList<QNetworkReply::RawHeaderPair> headers; 0038 0039 Private() 0040 // values that make sense for single item jobs 0041 : error(NoError) 0042 , statusCode(0) 0043 , totalItems(1) 0044 , itemsPerPage(1) 0045 { 0046 } 0047 }; 0048 0049 Metadata::Metadata() 0050 : d(new Private) 0051 { 0052 } 0053 0054 Metadata::~Metadata() 0055 { 0056 } 0057 0058 Metadata::Metadata(const Attica::Metadata &other) 0059 : d(other.d) 0060 { 0061 } 0062 0063 Metadata &Metadata::operator=(const Attica::Metadata &other) 0064 { 0065 d = other.d; 0066 return *this; 0067 } 0068 0069 Metadata::Error Metadata::error() const 0070 { 0071 return d->error; 0072 } 0073 0074 void Metadata::setError(Metadata::Error error) 0075 { 0076 d->error = error; 0077 } 0078 0079 QString Metadata::message() 0080 { 0081 return d->message; 0082 } 0083 0084 void Metadata::setMessage(const QString &message) 0085 { 0086 d->message = message; 0087 } 0088 0089 QString Metadata::resultingId() 0090 { 0091 return d->resultingId; 0092 } 0093 0094 void Metadata::setResultingId(const QString &id) 0095 { 0096 d->resultingId = id; 0097 } 0098 0099 int Metadata::statusCode() const 0100 { 0101 return d->statusCode; 0102 } 0103 0104 void Metadata::setStatusCode(int code) 0105 { 0106 d->statusCode = code; 0107 } 0108 0109 QString Metadata::statusString() const 0110 { 0111 return d->statusString; 0112 } 0113 0114 void Metadata::setStatusString(const QString &status) 0115 { 0116 d->statusString = status; 0117 } 0118 0119 int Metadata::totalItems() 0120 { 0121 return d->totalItems; 0122 } 0123 0124 void Metadata::setTotalItems(int items) 0125 { 0126 d->totalItems = items; 0127 } 0128 0129 int Metadata::itemsPerPage() 0130 { 0131 return d->itemsPerPage; 0132 } 0133 0134 void Metadata::setItemsPerPage(int itemsPerPage) 0135 { 0136 d->itemsPerPage = itemsPerPage; 0137 } 0138 0139 QList<QNetworkReply::RawHeaderPair> Metadata::headers() const 0140 { 0141 return d->headers; 0142 } 0143 0144 void Metadata::setHeaders(const QList<QNetworkReply::RawHeaderPair> &headers) 0145 { 0146 d->headers = headers; 0147 }