MailTransport

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 "kmailtransportakonadi/outboxactions_p.h"
11 
12 #include "mailtransportakonadi_debug.h"
13 
14 #include <agentmanager.h>
15 #include <collection.h>
16 #include <specialmailcollections.h>
17 #include "kmailtransportakonadi/transportattribute.h"
18 
19 using namespace Akonadi;
20 using namespace MailTransport;
21 
22 Q_GLOBAL_STATIC(DispatcherInterfacePrivate, sInstance)
23 
24 void DispatcherInterfacePrivate::massModifyResult(KJob *job)
25 {
26  // Nothing to do here, really. If the job fails, the user can retry it.
27  if (job->error()) {
28  qCDebug(MAILTRANSPORTAKONADI_LOG) << "failed" << job->errorString();
29  } else {
30  qCDebug(MAILTRANSPORTAKONADI_LOG) << "succeeded.";
31  }
32 }
33 
34 DispatcherInterface::DispatcherInterface()
35 {
36 }
37 
38 AgentInstance DispatcherInterface::dispatcherInstance() const
39 {
41  = AgentManager::self()->instance(QStringLiteral("akonadi_maildispatcher_agent"));
42  if (!a.isValid()) {
43  qCWarning(MAILTRANSPORTAKONADI_LOG) << "Could not get MDA instance.";
44  }
45  return a;
46 }
47 
48 void DispatcherInterface::dispatchManually()
49 {
50  Collection outbox
52  if (!outbox.isValid()) {
53 // qCritical() << "Could not access Outbox.";
54  return;
55  }
56 
57  FilterActionJob *mjob = new FilterActionJob(outbox, new SendQueuedAction, sInstance);
58  QObject::connect(mjob, &KJob::result, sInstance(), &DispatcherInterfacePrivate::massModifyResult);
59 }
60 
61 void DispatcherInterface::retryDispatching()
62 {
63  Collection outbox
65  if (!outbox.isValid()) {
66 // qCritical() << "Could not access Outbox.";
67  return;
68  }
69 
70  FilterActionJob *mjob = new FilterActionJob(outbox, new ClearErrorAction, sInstance);
71  QObject::connect(mjob, &KJob::result, sInstance(), &DispatcherInterfacePrivate::massModifyResult);
72 }
73 
74 void DispatcherInterface::dispatchManualTransport(int transportId)
75 {
76  Collection outbox
78  if (!outbox.isValid()) {
79 // qCritical() << "Could not access Outbox.";
80  return;
81  }
82 
83  FilterActionJob *mjob
84  = new FilterActionJob(outbox, new DispatchManualTransportAction(transportId), sInstance);
85  QObject::connect(mjob, &KJob::result, sInstance(), &DispatcherInterfacePrivate::massModifyResult);
86 }
87 
88 #include "moc_dispatcherinterface_p.cpp"
bool isValid() const
AgentInstance instance(const QString &identifier) const
bool isValid() const
static SpecialMailCollections * self()
static AgentManager * self()
Akonadi::Collection defaultCollection(Type type) const
void result(KJob *job)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Jul 5 2020 23:18:36 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.