MailTransport

smtpjob.h
1 /*
2  SPDX-FileCopyrightText: 2007 Volker Krause <[email protected]>
3 
4  Based on KMail code by:
5  SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #pragma once
11 
12 #include <KSMTP/Session>
13 #include <transportjob.h>
14 
15 #include <memory>
16 
17 namespace KIO
18 {
19 class Job;
20 class Slave;
21 }
22 
23 namespace KGAPI2
24 {
25 class AccountPromise;
26 }
27 
28 class SmtpJobPrivate;
29 
30 namespace MailTransport
31 {
32 /**
33  Mail transport job for SMTP.
34  Internally, all jobs for a specific transport are queued to use the same
35  KIO::Slave. This avoids multiple simultaneous connections to the server,
36  which is not always allowed. Also, re-using an already existing connection
37  avoids the login overhead and can improve performance.
38 
39  Precommands are automatically executed, once per opening a connection to the
40  server (not necessarily once per message).
41 */
42 class SmtpJob : public TransportJob
43 {
44  Q_OBJECT
45 public:
46  /**
47  Creates a SmtpJob.
48  @param transport The transport settings.
49  @param parent The parent object.
50  */
51  explicit SmtpJob(Transport *transport, QObject *parent = nullptr);
52 
53  /**
54  Deletes this job.
55  */
56  ~SmtpJob() override;
57 
58 protected:
59  void doStart() override;
60  bool doKill() override;
61 
62 protected Q_SLOTS:
63  void slotResult(KJob *job) override;
64  void sessionStateChanged(KSmtp::Session::State state);
65 
66 private:
67  void startPasswordRetrieval(bool forceRefresh = false);
68  void onTokenRequestFinished(KGAPI2::AccountPromise *result);
69  void startSmtpJob();
70  void startLoginJob();
71  void startSendJob();
72 
73 private:
74  friend class ::SmtpJobPrivate;
75  std::unique_ptr<SmtpJobPrivate> const d;
76 };
77 } // namespace MailTransport
Q_OBJECTQ_OBJECT
Abstract base class for all mail transport jobs.
Definition: transportjob.h:30
Q_SLOTSQ_SLOTS
void result(KJob *job)
Transport * transport() const
Returns the Transport object containing the mail transport settings.
void doStart() override
Do the actual work, implement in your subclass.
Definition: smtpjob.cpp:107
Represents the settings of a specific mail transport.
Definition: transport.h:32
Mail transport job for SMTP.
Definition: smtpjob.h:42
SmtpJob(Transport *transport, QObject *parent=nullptr)
Creates a SmtpJob.
Definition: smtpjob.cpp:81
~SmtpJob() override
Deletes this job.
Definition: smtpjob.cpp:94
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Sep 26 2023 03:50:25 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.