Mailcommon

filteractioncopy.cpp
1/*
2 * SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <taferner@kde.org>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 *
6 */
7
8#include "filteractioncopy.h"
9
10#include "kernel/mailkernel.h"
11#include "util/mailutil.h"
12
13#include <Akonadi/ItemCopyJob>
14#include <KLocalizedString>
15
16using namespace MailCommon;
17
18FilterActionCopy::FilterActionCopy(QObject *parent)
19 : FilterActionWithFolder(QStringLiteral("copy"), i18n("Copy Into Folder"), parent)
20{
21}
22
23FilterAction::ReturnCode FilterActionCopy::process(ItemContext &context, bool) const
24{
25 // copy the message 1:1
26 auto job = new Akonadi::ItemCopyJob(context.item(), mFolder, nullptr);
27 connect(job, &Akonadi::ItemCopyJob::result, this, &FilterActionCopy::jobFinished);
28
29 return GoOn;
30}
31
32void FilterActionCopy::jobFinished(KJob *job)
33{
34 if (job->error()) {
35 qCritical() << "Error while moving mail: " << job->errorString();
36 }
37}
38
39SearchRule::RequiredPart FilterActionCopy::requiredPart() const
40{
42}
43
44FilterAction *FilterActionCopy::newAction()
45{
46 return new FilterActionCopy;
47}
48
49QString FilterActionCopy::sieveCode() const
50{
52 if (KernelIf->collectionModel()) {
53 path = MailCommon::Util::fullCollectionRemoveIdPath(mFolder);
54 } else {
55 path = QString::number(mFolder.id());
56 }
57 const QString result = QStringLiteral("fileinto :copy \"%1\";").arg(path);
58 return result;
59}
60
61QStringList FilterActionCopy::sieveRequires() const
62{
63 return QStringList() << QStringLiteral("fileinto") << QStringLiteral("copy");
64}
65
66QString FilterActionCopy::informationAboutNotValidAction() const
67{
68 return i18n("Folder destination was not defined.");
69}
70
71#include "moc_filteractioncopy.cpp"
virtual QString errorString() const
int error() const
void result(KJob *job)
Abstract base class for filter actions with a mail folder as parameter.
Abstract base class for mail filter actions.
ReturnCode
Describes the possible return codes of filter processing:
@ GoOn
Go on with applying filter actions.
A helper class for the filtering process.
Definition itemcontext.h:27
Akonadi::Item & item()
Returns the item of the context.
RequiredPart
Possible required parts.
Definition searchrule.h:68
QString i18n(const char *text, const TYPE &arg...)
QString path(const QString &relativePath)
The filter dialog.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString arg(Args &&... args) const const
QString number(double n, char format, int precision)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:12:19 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.