Akonadi

collectioncopyjob.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "collectioncopyjob.h"
8#include "collection.h"
9#include "job_p.h"
10#include "private/protocol_p.h"
11
12#include <KLocalizedString>
13
14using namespace Akonadi;
15
16class Akonadi::CollectionCopyJobPrivate : public JobPrivate
17{
18public:
19 explicit CollectionCopyJobPrivate(CollectionCopyJob *parent)
20 : JobPrivate(parent)
21 {
22 }
23
24 Collection mSource;
25 Collection mTarget;
26
27 QString jobDebuggingString() const override;
28};
29
30QString Akonadi::CollectionCopyJobPrivate::jobDebuggingString() const
31{
32 return QStringLiteral("copy collection from %1 to %2").arg(mSource.id()).arg(mTarget.id());
33}
34
36 : Job(new CollectionCopyJobPrivate(this), parent)
37{
39
40 d->mSource = source;
41 d->mTarget = target;
42}
43
47
49{
51
52 if (!d->mSource.isValid() && d->mSource.remoteId().isEmpty()) {
54 setErrorText(i18n("Invalid collection to copy"));
55 emitResult();
56 return;
57 }
58 if (!d->mTarget.isValid() && d->mTarget.remoteId().isEmpty()) {
60 setErrorText(i18n("Invalid destination collection"));
61 emitResult();
62 return;
63 }
64 d->sendCommand(Protocol::CopyCollectionCommandPtr::create(d->mSource.id(), d->mTarget.id()));
65}
66
68{
69 if (!response->isResponse() || response->type() != Protocol::Command::CopyCollection) {
70 return Job::doHandleResponse(tag, response);
71 }
72
73 return true;
74}
75
76#include "moc_collectioncopyjob.cpp"
Job that copies a collection into another collection in the Akonadi storage.
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.
CollectionCopyJob(const Collection &source, const Collection &target, QObject *parent=nullptr)
Creates a new collection copy job to copy the given source collection into target.
void doStart() override
This method must be reimplemented in the concrete jobs.
~CollectionCopyJob() override
Destroys the collection copy job.
Represents a collection of PIM items.
Definition collection.h:62
Base class for all actions in the Akonadi storage.
Definition job.h: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:381
@ Unknown
Unknown error.
Definition job.h:102
void setErrorText(const QString &errorText)
void emitResult()
void setError(int errorCode)
QString i18n(const char *text, const TYPE &arg...)
Helper integration between Akonadi and Qt.
QString arg(Args &&... args) const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.