Akonadi

transportresourcebase.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 "transportresourcebase.h"
8#include "transportresourcebase_p.h"
9
10#include "transportadaptor.h"
11#include <QDBusConnection>
12
13#include "itemfetchjob.h"
14#include "itemfetchscope.h"
15
16#include <QDBusConnection>
17
18using namespace Akonadi;
19
20TransportResourceBasePrivate::TransportResourceBasePrivate(TransportResourceBase *qq)
21 : q(qq)
22{
23 new Akonadi__TransportAdaptor(this);
25}
26
27void TransportResourceBasePrivate::send(Item::Id id)
28{
29 auto job = new ItemFetchJob(Item(id));
30 job->fetchScope().fetchFullPayload();
31 job->setProperty("id", QVariant(id));
32 connect(job, &KJob::result, this, &TransportResourceBasePrivate::fetchResult);
33}
34
35void TransportResourceBasePrivate::fetchResult(KJob *job)
36{
37 if (job->error()) {
38 const Item::Id id = job->property("id").toLongLong();
39 Q_EMIT transportResult(id, static_cast<int>(TransportResourceBase::TransportFailed), job->errorText());
40 return;
41 }
42
43 auto fetchJob = qobject_cast<ItemFetchJob *>(job);
44 Q_ASSERT(fetchJob);
45
46 const Item item = fetchJob->items().at(0);
47 q->sendItem(item);
48}
49
51 : d(new TransportResourceBasePrivate(this))
52{
53}
54
56
57void TransportResourceBase::itemSent(const Item &item, TransportResult result, const QString &message)
58{
59 Q_EMIT d->transportResult(item.id(), static_cast<int>(result), message);
60}
61
62#include "moc_transportresourcebase_p.cpp"
Job that fetches items from the Akonadi storage.
Represents a PIM item stored in Akonadi storage.
Definition item.h:100
qint64 Id
Describes the unique id type.
Definition item.h:105
Id id() const
Returns the unique identifier of the item.
Definition item.cpp:63
Resource implementing mail transport capability.
TransportResult
Describes the result of the transport process.
@ TransportFailed
The transport process failed.
virtual ~TransportResourceBase()
Destroys the transport resource base.
void itemSent(const Akonadi::Item &item, TransportResult result, const QString &message=QString())
This method marks the sending of the passed item as finished.
TransportResourceBase()
Creates a new transport resource base.
int error() const
void result(KJob *job)
QString errorText() const
Helper integration between Akonadi and Qt.
bool registerObject(const QString &path, QObject *object, RegisterOptions options)
QDBusConnection sessionBus()
QVariant property(const char *name) const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
qlonglong toLongLong(bool *ok) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:31:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.