1/*
2 Copyright (c) 2007 Volker Krause <vkrause@kde.org>
3
4 Based on KMail code by:
5 Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
6
7 This library is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Library General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
11
12 This library is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15 License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to the
19 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301, USA.
21*/
22
23#ifndef MAILTRANSPORT_SMTPJOB_H
24#define MAILTRANSPORT_SMTPJOB_H
25
26#include <mailtransport/transportjob.h>
27
28namespace KIO {
29 class Job;
30 class Slave;
31}
32
33class SmtpJobPrivate;
34
35namespace MailTransport {
36
37class SmtpSession;
38
39/**
40 Mail transport job for SMTP.
41 Internally, all jobs for a specific transport are queued to use the same
42 KIO::Slave. This avoids multiple simultaneous connections to the server,
43 which is not always allowed. Also, re-using an already existing connection
44 avoids the login overhead and can improve performance.
45
46 Precommands are automatically executed, once per opening a connection to the
47 server (not necessarily once per message).
48
49 @deprecated Use MessageQueueJob for sending e-mail.
50*/
51class MAILTRANSPORT_DEPRECATED_EXPORT SmtpJob : public TransportJob
52{
53 Q_OBJECT
54 public:
55 /**
56 Creates a SmtpJob.
57 @param transport The transport settings.
58 @param parent The parent object.
59 */
60 explicit SmtpJob( Transport *transport, QObject *parent = 0 );
61
62 /**
63 Deletes this job.
64 */
65 virtual ~SmtpJob();
66
67 protected:
68 virtual void doStart();
69 virtual bool doKill();
70
71 protected Q_SLOTS:
72 virtual void slotResult( KJob *job );
73 void slaveError( KIO::Slave *slave, int errorCode, const QString &errorMsg );
74
75 private:
76 void startSmtpJob();
77
78 private Q_SLOTS:
79 void dataRequest( KIO::Job *job, QByteArray &data );
80
81 private:
82 friend class ::SmtpJobPrivate;
83 SmtpJobPrivate *const d;
84 Q_PRIVATE_SLOT( d, void smtpSessionResult( MailTransport::SmtpSession* ) )
85};
86
87} // namespace MailTransport
88
89#endif // MAILTRANSPORT_SMTPJOB_H
90