diff --git a/src/common/davcollectionsfetchjob.h b/src/common/davcollectionsfetchjob.h index ff2b894..5f939a3 100644 --- a/src/common/davcollectionsfetchjob.h +++ b/src/common/davcollectionsfetchjob.h @@ -1,74 +1,74 @@ /* SPDX-FileCopyrightText: 2010 Tobias Koenig SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KDAV_DAVCOLLECTIONSFETCHJOB_H #define KDAV_DAVCOLLECTIONSFETCHJOB_H #include "kdav_export.h" #include "davcollection.h" #include "davjobbase.h" #include "davurl.h" #include namespace KDAV { class DavCollectionsFetchJobPrivate; /** * @short A job that fetches all DAV collection. * * This job is used to fetch all DAV collection that are available * under a certain DAV url. */ class KDAV_EXPORT DavCollectionsFetchJob : public DavJobBase { Q_OBJECT public: /** * Creates a new dav collections fetch job. * * @param url The DAV url of the DAV collection whose sub collections shall be fetched. * @param parent The parent object. */ explicit DavCollectionsFetchJob(const DavUrl &url, QObject *parent = nullptr); /** * Starts the job. */ void start() override; /** * Returns the list of fetched DAV collections. */ Q_REQUIRED_RESULT DavCollection::List collections() const; /** * Return the DavUrl used by this job */ Q_REQUIRED_RESULT DavUrl davUrl() const; Q_SIGNALS: /** * This signal is emitted every time a new collection has been discovered. * * @param collectionUrl The URL of the discovered collection * @param configuredUrl The URL given to the job */ - void collectionDiscovered(int protocol, const QString &collectionUrl, const QString &configuredUrl); + void collectionDiscovered(KDAV::Protocol protocol, const QString &collectionUrl, const QString &configuredUrl); private: void principalFetchFinished(KJob *); void collectionsFetchFinished(KJob *); void doCollectionsFetch(const QUrl &url); void subjobFinished(); Q_DECLARE_PRIVATE(DavCollectionsFetchJob) }; } #endif diff --git a/src/common/davcollectionsmultifetchjob.h b/src/common/davcollectionsmultifetchjob.h index ccbc7d7..a704540 100644 --- a/src/common/davcollectionsmultifetchjob.h +++ b/src/common/davcollectionsmultifetchjob.h @@ -1,71 +1,71 @@ /* SPDX-FileCopyrightText: 2010 Tobias Koenig SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KDAV_DAVCOLLECTIONSMULTIFETCHJOB_H #define KDAV_DAVCOLLECTIONSMULTIFETCHJOB_H #include "kdav_export.h" #include "davcollection.h" #include "davurl.h" #include #include namespace KDAV { class DavCollectionsMultiFetchJobPrivate; /** * @short A job that fetches all DAV collection. * * This job is used to fetch all DAV collection that are available * under a certain list of DAV urls. * * @note This class just combines multiple calls of DavCollectionsFetchJob * into one job. */ class KDAV_EXPORT DavCollectionsMultiFetchJob : public KJob { Q_OBJECT public: /** * Creates a new dav collections multi fetch job. * * @param urls The list of DAV urls whose sub collections shall be fetched. * @param parent The parent object. */ explicit DavCollectionsMultiFetchJob(const DavUrl::List &urls, QObject *parent = nullptr); ~DavCollectionsMultiFetchJob(); /** * Starts the job. */ void start() override; /** * Returns the list of fetched DAV collections. */ Q_REQUIRED_RESULT DavCollection::List collections() const; Q_SIGNALS: /** * This signal is emitted every time a new collection has been discovered. * * @param collectionUrl The URL of the discovered collection * @param configuredUrl The URL given to the job */ - void collectionDiscovered(int protocol, const QString &collectionUrl, const QString &configuredUrl); + void collectionDiscovered(KDAV::Protocol protocol, const QString &collectionUrl, const QString &configuredUrl); private: void davJobFinished(KJob *); const std::unique_ptr d; }; } #endif diff --git a/src/common/davjobbase.h b/src/common/davjobbase.h index c1b375c..2c34283 100644 --- a/src/common/davjobbase.h +++ b/src/common/davjobbase.h @@ -1,94 +1,94 @@ /* SPDX-FileCopyrightText: 2014 Gregory Oestreicher SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KDAV_DAVJOBBASE_H #define KDAV_DAVJOBBASE_H #include "kdav_export.h" #include -#include +#include class DavJobBasePrivate; namespace KDAV { class Error; /** * @short base class for the jobs used by the resource. */ class KDAV_EXPORT DavJobBase : public KJob { Q_OBJECT public: explicit DavJobBase(QObject *parent = nullptr); ~DavJobBase(); /** * Get the latest response code. * * If no response code has been set then 0 will be returned, but will * be meaningless unless error() is non-zero. In that case this means * that the latest error was not at the HTTP level. */ Q_REQUIRED_RESULT int latestResponseCode() const; /** * Check if the job can be retried later. * * This will return true for transient errors, i.e. if the response code * is either zero and error() is set or if the HTTP response code hints * at a temporary error. * * The HTTP response codes considered retryable are: * - 401 * - 402 * - 407 * - 408 * - 423 * - 429 * - 501 to 504, inclusive * - 507 * - 511 */ Q_REQUIRED_RESULT bool canRetryLater() const; /** * Check if the job failed because of a conflict */ Q_REQUIRED_RESULT bool hasConflict() const; /** * Returns a instance of the KDAV:Error to be able to translate the error */ Q_REQUIRED_RESULT Error davError() const; protected: /** * Sets the latest response code received. * * Only really useful in case of error, though success codes can * also be set. * * @param code The code to set, should be a valid HTTP response code or zero. */ - void setLatestResponseCode(int code); + Q_DECL_HIDDEN void setLatestResponseCode(int code); - void setJobErrorText(const QString &errorText); - void setJobError(int jobErrorCode); - void setErrorTextFromDavError(); - void setDavError(const Error &error); + Q_DECL_HIDDEN void setJobErrorText(const QString &errorText); + Q_DECL_HIDDEN void setJobError(int jobErrorCode); + Q_DECL_HIDDEN void setErrorTextFromDavError(); + Q_DECL_HIDDEN void setDavError(const Error &error); - explicit DavJobBase(DavJobBasePrivate *dd, QObject *parent = nullptr); - QScopedPointer d_ptr; + Q_DECL_HIDDEN explicit DavJobBase(DavJobBasePrivate *dd, QObject *parent = nullptr); + std::unique_ptr d_ptr; private: Q_DECLARE_PRIVATE(DavJobBase) }; } #endif diff --git a/src/common/protocolinfo.cpp b/src/common/protocolinfo.cpp index 9ba6219..c31c686 100644 --- a/src/common/protocolinfo.cpp +++ b/src/common/protocolinfo.cpp @@ -1,76 +1,70 @@ /* SPDX-FileCopyrightText: 2010 Tobias Koenig SPDX-License-Identifier: LGPL-2.0-or-later */ #include "protocolinfo.h" #include "davmanager_p.h" #include "davprotocolbase_p.h" #include "libkdav_debug.h" using namespace KDAV; bool ProtocolInfo::useMultiget(KDAV::Protocol protocol) { return DavManager::davProtocol(protocol)->useMultiget(); } QString ProtocolInfo::principalHomeSet(KDAV::Protocol protocol) { return DavManager::davProtocol(protocol)->principalHomeSet(); } QString ProtocolInfo::principalHomeSetNS(KDAV::Protocol protocol) { return DavManager::davProtocol(protocol)->principalHomeSetNS(); } -QLatin1String ProtocolInfo::protocolName(KDAV::Protocol protocol) +QString ProtocolInfo::protocolName(KDAV::Protocol protocol) { - QLatin1String protocolName(""); - switch (protocol) { case KDAV::CalDav: - protocolName = QLatin1String("CalDav"); - break; + return QStringLiteral("CalDav"); case KDAV::CardDav: - protocolName = QLatin1String("CardDav"); - break; + return QStringLiteral("CardDav"); case KDAV::GroupDav: - protocolName = QLatin1String("GroupDav"); - break; + return QStringLiteral("GroupDav"); } - - return protocolName; + return {}; } KDAV::Protocol ProtocolInfo::protocolByName(const QString &name) { Protocol protocol = KDAV::CalDav; if (name == QLatin1String("CalDav")) { protocol = KDAV::CalDav; } else if (name == QLatin1String("CardDav")) { protocol = KDAV::CardDav; } else if (name == QLatin1String("GroupDav")) { protocol = KDAV::GroupDav; } else { qCCritical(KDAV_LOG) << "Unexpected protocol name : " << name; } return protocol; } QString ProtocolInfo::contactsMimeType(KDAV::Protocol protocol) { QString ret; if (protocol == KDAV::CardDav) { ret = QStringLiteral("text/vcard"); } else if (protocol == KDAV::GroupDav) { ret = QStringLiteral("text/x-vcard"); } return ret; } diff --git a/src/common/protocolinfo.h b/src/common/protocolinfo.h index d47de50..3426ec1 100644 --- a/src/common/protocolinfo.h +++ b/src/common/protocolinfo.h @@ -1,56 +1,56 @@ /* SPDX-FileCopyrightText: 2019 Volker Krause SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KDAV_PROTOCOLINFO_H #define KDAV_PROTOCOLINFO_H #include "kdav_export.h" #include "enums.h" class QLatin1String; namespace KDAV { /** Information about a DAV protocol. */ namespace ProtocolInfo { /** * Returns whether the @p protocol dialect supports the MULTIGET command. * * If MULTIGET is supported, the content of all dav resources * can be fetched in ResourceBase::retrieveItems() already and * there is no need to call ResourceBase::retrieveItem() for every single * dav resource. */ KDAV_EXPORT Q_REQUIRED_RESULT bool useMultiget(KDAV::Protocol protocol); /** Returns the principal home set of @p protocol. */ KDAV_EXPORT Q_REQUIRED_RESULT QString principalHomeSet(KDAV::Protocol protocol); /** Returns the principal home set namespace of @p protocol. */ KDAV_EXPORT Q_REQUIRED_RESULT QString principalHomeSetNS(KDAV::Protocol protocol); /** * Returns the untranslated name of the given DAV @p protocol dialect. */ - KDAV_EXPORT Q_REQUIRED_RESULT QLatin1String protocolName(KDAV::Protocol protocol); + KDAV_EXPORT Q_REQUIRED_RESULT QString protocolName(KDAV::Protocol protocol); /** * Returns the protocol matching the given name. This is the opposite of * Utils::protocolName(). */ KDAV_EXPORT Q_REQUIRED_RESULT KDAV::Protocol protocolByName(const QString &name); /** * Returns the mimetype that shall be used for contact DAV resources using @p protocol. */ KDAV_EXPORT Q_REQUIRED_RESULT QString contactsMimeType(KDAV::Protocol protocol); } } #endif // KDAV_PROTOCOLINFO_H