MailTransport

transportjob.cpp
1/*
2 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "transportjob.h"
8#include "transport.h"
9
10#include <QBuffer>
11
12#include <KLocalizedString>
13
14using namespace MailTransport;
15
16class MailTransport::TransportJobPrivate
17{
18public:
19 QString sender;
20 QStringList to;
21 QStringList cc;
22 QStringList bcc;
23 QByteArray data;
24 bool dsn = false;
25 Transport *transport = nullptr;
26 QBuffer *buffer = nullptr;
27};
28
30 : KCompositeJob(parent)
31 , d(new TransportJobPrivate)
32{
33 d->transport = transport;
34 d->buffer = nullptr;
35}
36
38{
39 delete d->transport;
40}
41
43{
44 d->sender = sender;
45}
46
48{
49 d->to = to;
50}
51
53{
54 d->cc = cc;
55}
56
58{
59 d->bcc = bcc;
60}
61
63{
64 d->data = data;
65}
66
68{
69 return d->transport;
70}
71
73{
74 d->dsn = enabled;
75}
76
78{
79 return d->sender;
80}
81
83{
84 return d->to;
85}
86
88{
89 return d->cc;
90}
91
93{
94 return d->bcc;
95}
96
98{
99 return d->data;
100}
101
103{
104 if (!d->buffer) {
105 d->buffer = new QBuffer(this);
106 d->buffer->setData(d->data);
107 d->buffer->open(QIODevice::ReadOnly);
108 Q_ASSERT(d->buffer->isOpen());
109 }
110 return d->buffer;
111}
112
114{
115 return d->dsn;
116}
117
119{
120 if (!transport()->isValid()) {
121 setError(UserDefinedError);
122 setErrorText(i18n("The outgoing account \"%1\" is not correctly configured.", transport()->name()));
123 emitResult();
124 return;
125 }
126 doStart();
127}
128
129#include "moc_transportjob.cpp"
void setErrorText(const QString &errorText)
void emitResult()
void setError(int errorCode)
TransportJob(Transport *transport, QObject *parent=nullptr)
Creates a new mail transport job.
Transport * transport() const
Returns the Transport object containing the mail transport settings.
void setData(const QByteArray &data)
Sets the content of the mail.
QBuffer * buffer()
Returns a QBuffer opened on the message data.
virtual void doStart()=0
Do the actual work, implement in your subclass.
void setBcc(const QStringList &bcc)
Sets the "Bcc" receiver(s) of the mail.
QByteArray data() const
Returns the data of the mail.
~TransportJob() override
Deletes this transport job.
QString sender() const
Returns the sender of the mail.
QStringList bcc() const
Returns the "Bcc" receiver(s) of the mail.
void setSender(const QString &sender)
Sets the sender of the mail.
void setTo(const QStringList &to)
Sets the "To" receiver(s) of the mail.
bool deliveryStatusNotification() const
Returns true if DSN is enabled.
QStringList to() const
Returns the "To" receiver(s) of the mail.
void setDeliveryStatusNotification(bool enabled)
Sets the content of the mail.
void start() override
Starts this job.
QStringList cc() const
Returns the "Cc" receiver(s) of the mail.
void setCc(const QStringList &cc)
Sets the "Cc" receiver(s) of the mail.
Represents the settings of a specific mail transport.
Definition transport.h:33
QString i18n(const char *text, const TYPE &arg...)
QByteArray & buffer()
char * data()
pointer data()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:17 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.