MailTransport

transportjob.h
1 /*
2  SPDX-FileCopyrightText: 2007 Volker Krause <[email protected]>
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 
17 class QBuffer;
18 
19 namespace MailTransport
20 {
21 class Transport;
22 class 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 */
30 class MAILTRANSPORT_DEPRECATED_EXPORT TransportJob : public KCompositeJob
31 {
32  Q_OBJECT
33  friend class TransportManager;
34 
35 public:
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 
88 protected:
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  Q_REQUIRED_RESULT QString sender() const;
102 
103  /**
104  Returns the "To" receiver(s) of the mail.
105  */
106  Q_REQUIRED_RESULT QStringList to() const;
107 
108  /**
109  Returns the "Cc" receiver(s) of the mail.
110  */
111  Q_REQUIRED_RESULT QStringList cc() const;
112 
113  /**
114  Returns the "Bcc" receiver(s) of the mail.
115  */
116  Q_REQUIRED_RESULT QStringList bcc() const;
117 
118  /**
119  Returns the data of the mail.
120  */
121  Q_REQUIRED_RESULT 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  Q_REQUIRED_RESULT bool deliveryStatusNotification() const;
138 
139 private:
140  //@cond PRIVATE
141  std::unique_ptr<TransportJobPrivate> const d;
142  //@endcond
143 };
144 } // namespace MailTransport
Central transport management interface.
Abstract base class for all mail transport jobs.
Definition: transportjob.h:30
Q_SCRIPTABLE Q_NOREPLY void start()
Represents the settings of a specific mail transport.
Definition: transport.h:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 6 2023 03:57:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.