From kde-commits Sun May 31 22:59:50 2015 From: =?utf-8?q?Dan_Vr=C3=A1til?= Date: Sun, 31 May 2015 22:59:50 +0000 To: kde-commits Subject: [akonadi/dev/binary-protocol] src/server: Remove handler/fetchscope - use Protocol::FetchScope every Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=143311320502502 Git commit cca890c5680b1f7fb7e291fd7f404d2d09a19ac3 by Dan Vr=C3=A1til. Committed on 31/05/2015 at 22:57. Pushed by dvratil into branch 'dev/binary-protocol'. Remove handler/fetchscope - use Protocol::FetchScope everywhere instead M +0 -1 src/server/CMakeLists.txt D +0 -429 src/server/handler/fetchscope.cpp D +0 -96 src/server/handler/fetchscope.h http://commits.kde.org/akonadi/cca890c5680b1f7fb7e291fd7f404d2d09a19ac3 diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index 963eb43..109fa78 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -59,7 +59,6 @@ set(libakonadiserver_SRCS handler/delete.cpp handler/fetch.cpp handler/fetchhelper.cpp - handler/fetchscope.cpp handler/link.cpp handler/list.cpp handler/login.cpp diff --git a/src/server/handler/fetchscope.cpp b/src/server/handler/fetchsc= ope.cpp deleted file mode 100644 index 713515c..0000000 --- a/src/server/handler/fetchscope.cpp +++ /dev/null @@ -1,429 +0,0 @@ -/* - Copyright (c) 2013 Daniel Vr=C3=A1til - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published= by - the Free Software Foundation; either version 2 of the License, or (at = your - option) any later version. - - This library is distributed in the hope that it will be useful, but WI= THOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public Lice= nse - along with this library; see the file COPYING.LIB. If not, write to t= he - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Bosto= n, MA - 02110-1301, USA. -*/ - -#include "fetchscope.h" -#include "imapstreamparser.h" -#include "handlerhelper.h" -#include "handler.h" - -#include - -using namespace Akonadi::Server; - -class FetchScope::Private : public QSharedData -{ -public: - Private(); - Private(const Private &other); - - void parseCommandStream(); - void parsePartList(); - - ImapStreamParser *mStreamParser; - - QVector mRequestedParts; - QStringList mRequestedPayloads; - QDateTime mChangedSince; - - int mAncestorDepth; - uint mCacheOnly : 1; - uint mCheckCachedPayloadPartsOnly : 1; - uint mFullPayload : 1; - uint mAllAttrs : 1; - uint mSizeRequested : 1; - uint mMTimeRequested : 1; - uint mExternalPayloadSupported : 1; - uint mRemoteRevisionRequested : 1; - uint mIgnoreErrors : 1; - uint mFlagsRequested : 1; - uint mRemoteIdRequested : 1; - uint mGidRequested : 1; - uint mTagsRequested : 1; - uint mRelationsRequested : 1; - uint mVirtRefRequested: 1; - QVector mTagFetchScope; -}; - -FetchScope::Private::Private() - : QSharedData() - , mStreamParser(0) - , mAncestorDepth(0) - , mCacheOnly(false) - , mCheckCachedPayloadPartsOnly(false) - , mFullPayload(false) - , mAllAttrs(false) - , mSizeRequested(false) - , mMTimeRequested(false) - , mExternalPayloadSupported(false) - , mRemoteRevisionRequested(false) - , mIgnoreErrors(false) - , mFlagsRequested(false) - , mRemoteIdRequested(false) - , mGidRequested(false) - , mTagsRequested(false) - , mRelationsRequested(false) - , mVirtRefRequested( false ) -{ -} - -FetchScope::Private::Private(const Private &other) - : QSharedData(other) - , mStreamParser(other.mStreamParser) - , mRequestedParts(other.mRequestedParts) - , mRequestedPayloads(other.mRequestedPayloads) - , mChangedSince(other.mChangedSince) - , mAncestorDepth(other.mAncestorDepth) - , mCacheOnly(other.mCacheOnly) - , mCheckCachedPayloadPartsOnly(other.mCheckCachedPayloadPartsOnly) - , mFullPayload(other.mFullPayload) - , mAllAttrs(other.mAllAttrs) - , mSizeRequested(other.mSizeRequested) - , mMTimeRequested(other.mMTimeRequested) - , mExternalPayloadSupported(other.mExternalPayloadSupported) - , mRemoteRevisionRequested(other.mRemoteRevisionRequested) - , mIgnoreErrors(other.mIgnoreErrors) - , mFlagsRequested(other.mFlagsRequested) - , mRemoteIdRequested(other.mRemoteIdRequested) - , mGidRequested(other.mGidRequested) - , mTagsRequested(other.mTagsRequested) - , mRelationsRequested(other.mRelationsRequested) - , mVirtRefRequested( other.mVirtRefRequested ) - , mTagFetchScope( other.mTagFetchScope ) -{ -} - -void FetchScope::Private::parseCommandStream() -{ - Q_ASSERT(mStreamParser); - - // macro vs. attribute list - Q_FOREVER { - if (mStreamParser->atCommandEnd()) { - break; - } - if (mStreamParser->hasList()) { - parsePartList(); - break; - } else { - const QByteArray buffer =3D mStreamParser->readString(); - if (buffer =3D=3D AKONADI_PARAM_CACHEONLY) { - mCacheOnly =3D true; - } else if (buffer =3D=3D AKONADI_PARAM_CHECKCACHEDPARTSONLY) { - mCheckCachedPayloadPartsOnly =3D true; - } else if (buffer =3D=3D AKONADI_PARAM_ALLATTRIBUTES) { - mAllAttrs =3D true; - } else if (buffer =3D=3D AKONADI_PARAM_EXTERNALPAYLOAD) { - mExternalPayloadSupported =3D true; - } else if (buffer =3D=3D AKONADI_PARAM_FULLPAYLOAD) { - mRequestedParts << AKONADI_PARAM_PLD_RFC822; // HACK: temp= orary workaround until we have support for detecting the availability of th= e full payload in the server - mFullPayload =3D true; - } else if (buffer =3D=3D AKONADI_PARAM_ANCESTORS) { - mAncestorDepth =3D HandlerHelper::parseDepth(mStreamParser= ->readString()); - } else if (buffer =3D=3D AKONADI_PARAM_IGNOREERRORS) { - mIgnoreErrors =3D true; - } else if (buffer =3D=3D AKONADI_PARAM_CHANGEDSINCE) { - bool ok =3D false; - mChangedSince =3D QDateTime::fromTime_t(mStreamParser->rea= dNumber(&ok)); - if (!ok) { - throw HandlerException("Invalid CHANGEDSINCE timestamp= "); - } - } else { - throw HandlerException("Invalid command argument"); - } - } - } -} - -void FetchScope::Private::parsePartList() -{ - mStreamParser->beginList(); - while (!mStreamParser->atListEnd()) { - const QByteArray b =3D mStreamParser->readString(); - // filter out non-part attributes we send all the time - if (b =3D=3D AKONADI_PARAM_REVISION || b =3D=3D AKONADI_PARAM_UID)= { - continue; - } else if (b =3D=3D AKONADI_PARAM_REMOTEID) { - mRemoteIdRequested =3D true; - } else if (b =3D=3D AKONADI_PARAM_FLAGS) { - mFlagsRequested =3D true; - } else if (b =3D=3D AKONADI_PARAM_SIZE) { - mSizeRequested =3D true; - } else if (b =3D=3D AKONADI_PARAM_MTIME) { - mMTimeRequested =3D true; - } else if (b =3D=3D AKONADI_PARAM_REMOTEREVISION) { - mRemoteRevisionRequested =3D true; - } else if (b =3D=3D AKONADI_PARAM_GID) { - mGidRequested =3D true; - } else if (b =3D=3D AKONADI_PARAM_TAGS) { - mTagsRequested =3D true; - if (mStreamParser->hasList()) { - mStreamParser->beginList(); - while (!mStreamParser->atListEnd()) { - mTagFetchScope << mStreamParser->readString(); - } - } - } else if (b =3D=3D AKONADI_PARAM_RELATIONS) { - mRelationsRequested =3D true; - } else if (b =3D=3D AKONADI_PARAM_COLLECTIONID) { - // we always return collection IDs anyway - } else if (b =3D=3D AKONADI_PARAM_VIRTREF) { - mVirtRefRequested =3D true; - } else { - mRequestedParts.push_back(b); - if (b.startsWith(AKONADI_PARAM_PLD)) { - mRequestedPayloads.push_back(QString::fromLatin1(b)); - } - } - } -} - -FetchScope::FetchScope() - : d(new Private) -{ -} - -FetchScope::FetchScope(ImapStreamParser *streamParser) - : d(new Private) -{ - d->mStreamParser =3D streamParser; - d->parseCommandStream(); -} - -FetchScope::FetchScope(const FetchScope &other) - : d(other.d) -{ -} - -FetchScope::~FetchScope() -{ -} - -FetchScope &FetchScope::operator=3D(const FetchScope &other) -{ - if (this !=3D &other) { - d =3D other.d; - } - - return *this; -} - -bool FetchScope::isValid() const -{ - return d->mStreamParser !=3D 0; -} - -ImapStreamParser *FetchScope::streamParser() const -{ - return d->mStreamParser; -} - -void FetchScope::setRequestedParts(const QVector &requestedPar= ts) -{ - d->mRequestedParts =3D requestedParts; -} - -QVector FetchScope::requestedParts() const -{ - return d->mRequestedParts; -} - -void FetchScope::setRequestedPayloads(const QStringList &payloads) -{ - d->mRequestedPayloads =3D payloads; -} - -QStringList FetchScope::requestedPayloads() const -{ - return d->mRequestedPayloads; -} - -void FetchScope::setChangedSince(const QDateTime &dt) -{ - d->mChangedSince =3D dt; -} - -QDateTime FetchScope::changedSince() const -{ - return d->mChangedSince; -} - -void FetchScope::setAncestorDepth(int depth) -{ - d->mAncestorDepth =3D depth; -} - -int FetchScope::ancestorDepth() const -{ - return d->mAncestorDepth; -} - -void FetchScope::setCacheOnly(bool cacheOnly) -{ - d->mCacheOnly =3D cacheOnly; -} - -bool FetchScope::cacheOnly() const -{ - return d->mCacheOnly; -} - -void FetchScope::setCheckCachedPayloadPartsOnly(bool checkCachedPayloadPar= tsOnly) -{ - d->mCheckCachedPayloadPartsOnly =3D checkCachedPayloadPartsOnly; -} - -bool FetchScope::checkCachedPayloadPartsOnly() const -{ - return d->mCheckCachedPayloadPartsOnly; -} - -void FetchScope::setFullPayload(bool fullPayload) -{ - d->mFullPayload =3D fullPayload; -} - -bool FetchScope::fullPayload() const -{ - return d->mFullPayload; -} - -void FetchScope::setAllAttributes(bool allAttributes) -{ - d->mAllAttrs =3D allAttributes; -} - -bool FetchScope::allAttributes() const -{ - return d->mAllAttrs; -} - -void FetchScope::setSizeRequested(bool sizeRequested) -{ - d->mSizeRequested =3D sizeRequested; -} - -bool FetchScope::sizeRequested() const -{ - return d->mSizeRequested; -} - -void FetchScope::setMTimeRequested(bool mTimeRequested) -{ - d->mMTimeRequested =3D mTimeRequested; -} - -bool FetchScope::mTimeRequested() const -{ - return d->mMTimeRequested; -} - -void FetchScope::setExternalPayloadSupported(bool externalPayloadSupported) -{ - d->mExternalPayloadSupported =3D externalPayloadSupported; -} - -bool FetchScope::externalPayloadSupported() const -{ - return d->mExternalPayloadSupported; -} - -void FetchScope::setRemoteRevisionRequested(bool remoteRevisionRequested) -{ - d->mRemoteRevisionRequested =3D remoteRevisionRequested; -} - -bool FetchScope::remoteRevisionRequested() const -{ - return d->mRemoteRevisionRequested; -} - -void FetchScope::setIgnoreErrors(bool ignoreErrors) -{ - d->mIgnoreErrors =3D ignoreErrors; -} - -bool FetchScope::ignoreErrors() const -{ - return d->mIgnoreErrors; -} - -void FetchScope::setFlagsRequested(bool flagsRequested) -{ - d->mFlagsRequested =3D flagsRequested; -} - -bool FetchScope::flagsRequested() const -{ - return d->mFlagsRequested; -} - -void FetchScope::setRemoteIdRequested(bool remoteIdRequested) -{ - d->mRemoteIdRequested =3D remoteIdRequested; -} - -bool FetchScope::remoteIdRequested() const -{ - return d->mRemoteIdRequested; -} - -void FetchScope::setGidRequested(bool gidRequested) -{ - d->mGidRequested =3D gidRequested; -} - -bool FetchScope::gidRequested() const -{ - return d->mGidRequested; -} - -void FetchScope::setTagsRequested(bool tagsRequested) -{ - d->mTagsRequested =3D tagsRequested; -} - -bool FetchScope::tagsRequested() const -{ - return d->mTagsRequested; -} - -QVector FetchScope::tagFetchScope() const -{ - return d->mTagFetchScope; -} - -void FetchScope::setRelationsRequested(bool relationsRequested) -{ - d->mRelationsRequested =3D relationsRequested; -} - -bool FetchScope::relationsRequested() const -{ - return d->mRelationsRequested; -} - -void FetchScope::setVirtualReferencesRequested(bool vRefRequested) -{ - d->mVirtRefRequested =3D vRefRequested; -} - -bool FetchScope::virtualReferencesRequested() const -{ - return d->mVirtRefRequested; -} diff --git a/src/server/handler/fetchscope.h b/src/server/handler/fetchscop= e.h deleted file mode 100644 index c1c6901..0000000 --- a/src/server/handler/fetchscope.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright (c) 2013 Daniel Vr=C3=A1til - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published= by - the Free Software Foundation; either version 2 of the License, or (at = your - option) any later version. - - This library is distributed in the hope that it will be useful, but WI= THOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public Lice= nse - along with this library; see the file COPYING.LIB. If not, write to t= he - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Bosto= n, MA - 02110-1301, USA. -*/ - -#ifndef AKONADI_FETCHSCOPE_H -#define AKONADI_FETCHSCOPE_H - -#include -#include -#include -#include - -namespace Akonadi { -namespace Server { - -class ImapStreamParser; - -class FetchScope -{ -public: - FetchScope(); - FetchScope(ImapStreamParser *streamParser); - FetchScope(const FetchScope &other); - ~FetchScope(); - - FetchScope &operator=3D(const FetchScope &other); - - bool isValid() const; - - ImapStreamParser *streamParser() const; - - void setRequestedParts(const QVector &requestedParts); - QVector requestedParts() const; - void setRequestedPayloads(const QStringList &payloads); - QStringList requestedPayloads() const; - void setChangedSince(const QDateTime &dt); - QDateTime changedSince() const; - void setAncestorDepth(int depth); - int ancestorDepth() const; - void setCacheOnly(bool cacheOnly); - bool cacheOnly() const; - void setCheckCachedPayloadPartsOnly(bool checkCachedPayloadPartsOnly); - bool checkCachedPayloadPartsOnly() const; - void setFullPayload(bool fullPayload); - bool fullPayload() const; - void setAllAttributes(bool allAttributes); - bool allAttributes() const; - void setSizeRequested(bool sizeRequested); - bool sizeRequested() const; - void setMTimeRequested(bool mTimeRequested); - bool mTimeRequested() const; - void setExternalPayloadSupported(bool externalPayloadSupported); - bool externalPayloadSupported() const; - void setRemoteRevisionRequested(bool remoteRevisionRequested); - bool remoteRevisionRequested() const; - void setIgnoreErrors(bool ignoreErrors); - bool ignoreErrors() const; - void setFlagsRequested(bool flagsRequested); - bool flagsRequested() const; - void setRemoteIdRequested(bool remoteIdRequested); - bool remoteIdRequested() const; - void setGidRequested(bool gidRequested); - bool gidRequested() const; - void setTagsRequested(bool tagsRequested); - bool tagsRequested() const; - QVector tagFetchScope() const; - void setRelationsRequested(bool relationsRequested); - bool relationsRequested() const; - void setVirtualReferencesRequested(bool vRefRequested); - bool virtualReferencesRequested() const; - -private: - class Private; - QSharedDataPointer d; - -}; - -} // namespace Server -} // namespace Akonadi - -#endif //AKONADI_FETCHSCOPE_H