Akonadi Mime

dispatcherinterface.cpp
1 /*
2  SPDX-FileCopyrightText: 2009 Constantin Berzan <[email protected]>
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 
19 using namespace Akonadi;
20 
21 Q_GLOBAL_STATIC(DispatcherInterfacePrivate, sInstance)
22 
23 void 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"
Akonadi::Collection defaultCollection(Type type) const
Returns the special mail collection of given type in the default resource, or an invalid collection i...
void result(KJob *job)
DispatcherInterface()
Creates a new dispatcher interface.
Akonadi::AgentInstance dispatcherInstance() const
Returns the current instance of the mail dispatcher agent.
void dispatchManually()
Looks for messages in the outbox with DispatchMode::Manual and marks them DispatchMode::Automatic for...
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void dispatchManualTransport(int transportId)
Looks for messages in the outbox with DispatchMode::Manual and changes the Transport for them to the ...
Q_GLOBAL_STATIC(Internal::StaticControl, s_instance) class ControlPrivate
AgentInstance instance(const QString &identifier) const
static SpecialMailCollections * self()
Returns the global SpecialMailCollections instance.
static AgentManager * self()
void retryDispatching()
Looks for messages in the outbox with ErrorAttribute, and clears them and queues them again for sendi...
bool isValid() const
virtual QString errorString() const
int error() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Nov 29 2023 03:53:46 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.