MailTransport

transportjob.h
1/*
2 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "mailtransport_export.h"
10
11#include <QStringList>
12
13#include <KCompositeJob>
14
15#include <memory>
16
17class QBuffer;
18
19namespace MailTransport
20{
21class Transport;
22class TransportJobPrivate;
23
24/**
25 Abstract base class for all mail transport jobs.
26 This is a job that is supposed to send exactly one mail.
27
28 @deprecated Use MessageQueueJob for sending e-mail.
29*/
30class MAILTRANSPORT_DEPRECATED_EXPORT TransportJob : public KCompositeJob
31{
32 Q_OBJECT
33 friend class TransportManager;
34
35public:
36 /**
37 Deletes this transport job.
38 */
39 ~TransportJob() override;
40
41 /**
42 Sets the sender of the mail.
43 @p sender must be the plain email address, not including display name.
44 */
45 void setSender(const QString &sender);
46
47 /**
48 Sets the "To" receiver(s) of the mail.
49 @p to must be the plain email address(es), not including display name.
50 */
51 void setTo(const QStringList &to);
52
53 /**
54 Sets the "Cc" receiver(s) of the mail.
55 @p cc must be the plain email address(es), not including display name.
56 */
57 void setCc(const QStringList &cc);
58
59 /**
60 Sets the "Bcc" receiver(s) of the mail.
61 @p bcc must be the plain email address(es), not including display name.
62 */
63 void setBcc(const QStringList &bcc);
64
65 /**
66 Sets the content of the mail.
67 */
68 void setData(const QByteArray &data);
69
70 /**
71 Starts this job. It is recommended to not call this method directly but use
72 TransportManager::schedule() to execute the job instead.
73
74 @see TransportManager::schedule()
75 */
76 void start() override;
77
78 /**
79 Returns the Transport object containing the mail transport settings.
80 */
81 Transport *transport() const;
82
83 /**
84 Sets the content of the mail.
85 */
86 void setDeliveryStatusNotification(bool enabled);
87
88protected:
89 /**
90 Creates a new mail transport job.
91 @param transport The transport configuration. This must be a deep copy of
92 a Transport object, the job takes the ownership of this object.
93 @param parent The parent object.
94 @see TransportManager::createTransportJob()
95 */
96 explicit TransportJob(Transport *transport, QObject *parent = nullptr);
97
98 /**
99 Returns the sender of the mail.
100 */
101 [[nodiscard]] QString sender() const;
102
103 /**
104 Returns the "To" receiver(s) of the mail.
105 */
106 [[nodiscard]] QStringList to() const;
107
108 /**
109 Returns the "Cc" receiver(s) of the mail.
110 */
111 [[nodiscard]] QStringList cc() const;
112
113 /**
114 Returns the "Bcc" receiver(s) of the mail.
115 */
116 [[nodiscard]] QStringList bcc() const;
117
118 /**
119 Returns the data of the mail.
120 */
121 [[nodiscard]] QByteArray data() const;
122
123 /**
124 Returns a QBuffer opened on the message data. This is useful for
125 processing the data in smaller chunks.
126 */
127 QBuffer *buffer();
128
129 /**
130 Do the actual work, implement in your subclass.
131 */
132 virtual void doStart() = 0;
133
134 /**
135 Returns true if DSN is enabled.
136 */
137 [[nodiscard]] bool deliveryStatusNotification() const;
138
139private:
140 //@cond PRIVATE
141 std::unique_ptr<TransportJobPrivate> const d;
142 //@endcond
143};
144} // namespace MailTransport
Abstract base class for all mail transport jobs.
virtual void doStart()=0
Do the actual work, implement in your subclass.
Central transport management interface.
Represents the settings of a specific mail transport.
Definition transport.h:33
Q_SCRIPTABLE Q_NOREPLY void start()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:12:37 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.