File indexing completed on 2024-09-22 04:47:56
0001 /* 0002 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org> 0003 0004 Based on KMail code by: 0005 SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <taferner@kde.org> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include "transportjob.h" 0013 #include <KSMTP/Session> 0014 0015 #include <memory> 0016 0017 namespace KIO 0018 { 0019 class Job; 0020 class Slave; 0021 } 0022 0023 namespace KGAPI2 0024 { 0025 class AccountPromise; 0026 } 0027 0028 class SmtpJobPrivate; 0029 0030 namespace MailTransport 0031 { 0032 /** 0033 Mail transport job for SMTP. 0034 Internally, all jobs for a specific transport are queued to use the same 0035 KIO::Slave. This avoids multiple simultaneous connections to the server, 0036 which is not always allowed. Also, re-using an already existing connection 0037 avoids the login overhead and can improve performance. 0038 0039 Precommands are automatically executed, once per opening a connection to the 0040 server (not necessarily once per message). 0041 */ 0042 class SmtpJob : public TransportJob 0043 { 0044 Q_OBJECT 0045 public: 0046 /** 0047 Creates a SmtpJob. 0048 @param transport The transport settings. 0049 @param parent The parent object. 0050 */ 0051 explicit SmtpJob(Transport *transport, QObject *parent = nullptr); 0052 0053 /** 0054 Deletes this job. 0055 */ 0056 ~SmtpJob() override; 0057 0058 protected: 0059 void doStart() override; 0060 bool doKill() override; 0061 0062 protected Q_SLOTS: 0063 void slotResult(KJob *job) override; 0064 void sessionStateChanged(KSmtp::Session::State state); 0065 0066 private: 0067 void startPasswordRetrieval(bool forceRefresh = false); 0068 void onTokenRequestFinished(KGAPI2::AccountPromise *result); 0069 void startSmtpJob(); 0070 void startLoginJob(); 0071 void startSendJob(); 0072 0073 private: 0074 friend class ::SmtpJobPrivate; 0075 std::unique_ptr<SmtpJobPrivate> const d; 0076 }; 0077 } // namespace MailTransport