1 /*
2 Copyright (c) 2007 Volker Krause <vkrause@kde.org>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#ifndef MAILTRANSPORT_TRANSPORTJOB_H
21#define MAILTRANSPORT_TRANSPORTJOB_H
22
23#include <mailtransport/mailtransport_export.h>
24
25#include <QtCore/QStringList>
26
27#include <KDE/KCompositeJob>
28
29class QBuffer;
30
31namespace MailTransport {
32
33class Transport;
34
35/**
36 Abstract base class for all mail transport jobs.
37 This is a job that is supposed to send exactly one mail.
38
39 @deprecated Use MessageQueueJob for sending e-mail.
40*/
41class MAILTRANSPORT_DEPRECATED_EXPORT TransportJob : public KCompositeJob
42{
43 friend class TransportManager;
44
45 public:
46 /**
47 Deletes this transport job.
48 */
49 virtual ~TransportJob();
50
51 /**
52 Sets the sender of the mail.
53 @p sender must be the plain email address, not including display name.
54 */
55 void setSender( const QString &sender );
56
57 /**
58 Sets the "To" receiver(s) of the mail.
59 @p to must be the plain email address(es), not including display name.
60 */
61 void setTo( const QStringList &to );
62
63 /**
64 Sets the "Cc" receiver(s) of the mail.
65 @p cc must be the plain email address(es), not including display name.
66 */
67 void setCc( const QStringList &cc );
68
69 /**
70 Sets the "Bcc" receiver(s) of the mail.
71 @p bcc must be the plain email address(es), not including display name.
72 */
73 void setBcc( const QStringList &bcc );
74
75 /**
76 Sets the content of the mail.
77 */
78 void setData( const QByteArray &data );
79
80 /**
81 Starts this job. It is recommended to not call this method directly but use
82 TransportManager::schedule() to execute the job instead.
83
84 @see TransportManager::schedule()
85 */
86 virtual void start();
87
88 /**
89 Returns the Transport object containing the mail transport settings.
90 */
91 Transport *transport() const;
92
93 protected:
94 /**
95 Creates a new mail transport job.
96 @param transport The transport configuration. This must be a deep copy of
97 a Transport object, the job takes the ownership of this object.
98 @param parent The parent object.
99 @see TransportManager::createTransportJob()
100 */
101 explicit TransportJob( Transport *transport, QObject *parent = 0 );
102
103 /**
104 Returns the sender of the mail.
105 */
106 QString sender() const;
107
108 /**
109 Returns the "To" receiver(s) of the mail.
110 */
111 QStringList to() const;
112
113 /**
114 Returns the "Cc" receiver(s) of the mail.
115 */
116 QStringList cc() const;
117
118 /**
119 Returns the "Bcc" receiver(s) of the mail.
120 */
121 QStringList bcc() const;
122
123 /**
124 Returns the data of the mail.
125 */
126 QByteArray data() const;
127
128 /**
129 Returns a QBuffer opened on the message data. This is useful for
130 processing the data in smaller chunks.
131 */
132 QBuffer *buffer();
133
134 /**
135 Do the actual work, implement in your subclass.
136 */
137 virtual void doStart() = 0;
138
139 private:
140 //@cond PRIVATE
141 class Private;
142 Private *const d;
143 //@endcond
144};
145
146} // namespace MailTransport
147
148#endif // MAILTRANSPORT_TRANSPORTJOB_H
149