Akonadi

collectiondeletejob.cpp
1 /*
2  Copyright (c) 2006 Volker Krause <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "collectiondeletejob.h"
21 #include "collection.h"
22 #include "job_p.h"
23 #include "protocolhelper_p.h"
24 #include "private/protocol_p.h"
25 
26 #include <KLocalizedString>
27 
28 using namespace Akonadi;
29 
30 class Akonadi::CollectionDeleteJobPrivate : public JobPrivate
31 {
32 public:
33  CollectionDeleteJobPrivate(CollectionDeleteJob *parent)
34  : JobPrivate(parent)
35  {
36  }
37  QString jobDebuggingString() const override;
38 
39  Collection mCollection;
40 
41 };
42 
43 QString Akonadi::CollectionDeleteJobPrivate::jobDebuggingString() const
44 {
45  return QStringLiteral("Delete Collection id: %1").arg(mCollection.id());
46 }
47 
49  : Job(new CollectionDeleteJobPrivate(this), parent)
50 {
52 
53  d->mCollection = collection;
54 }
55 
57 {
58 }
59 
61 {
63 
64  if (!d->mCollection.isValid() && d->mCollection.remoteId().isEmpty()) {
66  setErrorText(i18n("Invalid collection"));
67  emitResult();
68  return;
69  }
70 
71  d->sendCommand(Protocol::DeleteCollectionCommandPtr::create(ProtocolHelper::entityToScope(d->mCollection)));
72 }
73 
75 {
76  if (!response->isResponse() || response->type() != Protocol::Command::DeleteCollection) {
77  return Job::doHandleResponse(tag, response);
78  }
79 
80  return true;
81 }
virtual bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response)
This method should be reimplemented in the concrete jobs in case you want to handle incoming data...
Definition: job.cpp:385
void emitResult()
Unknown error.
Definition: job.h:115
Represents a collection of PIM items.
Definition: collection.h:76
void setError(int errorCode)
Base class for all actions in the Akonadi storage.
Definition: job.h:93
CollectionDeleteJob(const Collection &collection, QObject *parent=nullptr)
Creates a new collection delete job.
~CollectionDeleteJob() override
Destroys the collection delete job.
void setErrorText(const QString &errorText)
Job that deletes a collection in the Akonadi storage.
void doStart() override
This method must be reimplemented in the concrete jobs.
QString i18n(const char *text, const TYPE &arg...)
Helper integration between Akonadi and Qt.
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override
This method should be reimplemented in the concrete jobs in case you want to handle incoming data...
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon May 25 2020 22:46:08 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.