Akonadi Mime

dispatcherinterface.cpp
1/*
2 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "dispatcherinterface.h"
8#include "dispatcherinterface_p.h"
9
10#include "outboxactions_p.h"
11
12#include "akonadi_mime_debug.h"
13
14#include "transportattribute.h"
15#include <Akonadi/AgentManager>
16#include <Akonadi/Collection>
17#include <Akonadi/SpecialMailCollections>
18
19using namespace Akonadi;
20
21Q_GLOBAL_STATIC(DispatcherInterfacePrivate, sInstance)
22
23void DispatcherInterfacePrivate::massModifyResult(KJob *job)
24{
25 // Nothing to do here, really. If the job fails, the user can retry it.
26 if (job->error()) {
27 qCDebug(AKONADIMIME_LOG) << "failed" << job->errorString();
28 } else {
29 qCDebug(AKONADIMIME_LOG) << "succeeded.";
30 }
31}
32
34
36{
37 AgentInstance a = AgentManager::self()->instance(QStringLiteral("akonadi_maildispatcher_agent"));
38 if (!a.isValid()) {
39 qCWarning(AKONADIMIME_LOG) << "Could not get MDA instance.";
40 }
41 return a;
42}
43
45{
47 if (!outbox.isValid()) {
48 // qCritical() << "Could not access Outbox.";
49 return;
50 }
51
52 auto mjob = new FilterActionJob(outbox, new SendQueuedAction, sInstance);
53 QObject::connect(mjob, &KJob::result, sInstance(), &DispatcherInterfacePrivate::massModifyResult);
54}
55
57{
59 if (!outbox.isValid()) {
60 // qCritical() << "Could not access Outbox.";
61 return;
62 }
63
64 auto mjob = new FilterActionJob(outbox, new ClearErrorAction, sInstance);
65 QObject::connect(mjob, &KJob::result, sInstance(), &DispatcherInterfacePrivate::massModifyResult);
66}
67
69{
71 if (!outbox.isValid()) {
72 // qCritical() << "Could not access Outbox.";
73 return;
74 }
75
76 auto mjob = new FilterActionJob(outbox, new DispatchManualTransportAction(transportId), sInstance);
77 QObject::connect(mjob, &KJob::result, sInstance(), &DispatcherInterfacePrivate::massModifyResult);
78}
79
80#include "moc_dispatcherinterface_p.cpp"
static AgentManager * self()
AgentInstance instance(const QString &identifier) const
bool isValid() const
DispatcherInterface()
Creates a new dispatcher interface.
void retryDispatching()
Looks for messages in the outbox with ErrorAttribute, and clears them and queues them again for sendi...
void dispatchManualTransport(int transportId)
Looks for messages in the outbox with DispatchMode::Manual and changes the Transport for them to the ...
void dispatchManually()
Looks for messages in the outbox with DispatchMode::Manual and marks them DispatchMode::Automatic for...
Akonadi::AgentInstance dispatcherInstance() const
Returns the current instance of the mail dispatcher agent.
static SpecialMailCollections * self()
Returns the global SpecialMailCollections instance.
Akonadi::Collection defaultCollection(Type type) const
Returns the special mail collection of given type in the default resource, or an invalid collection i...
virtual QString errorString() const
int error() const
void result(KJob *job)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:32:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.