File indexing completed on 2024-05-12 05:21:35
0001 /* 0002 SPDX-FileCopyrightText: 2010 BetterInbox <contact@betterinbox.com> 0003 SPDX-FileContributor: Gregory Schlomoff <gregory.schlomoff@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.1-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include "session.h" 0011 0012 #include <QObject> 0013 #include <QQueue> 0014 #include <QStringList> 0015 #include <QTimer> 0016 0017 #include <QSslSocket> 0018 0019 class KJob; 0020 0021 namespace KSmtp 0022 { 0023 class Job; 0024 class SessionThread; 0025 class ServerResponse; 0026 0027 class KSMTP_EXPORT SessionPrivate : public QObject 0028 { 0029 Q_OBJECT 0030 0031 friend class Session; 0032 0033 public: 0034 explicit SessionPrivate(Session *session); 0035 ~SessionPrivate() override; 0036 0037 void addJob(Job *job); 0038 void sendData(const QByteArray &data); 0039 void setState(Session::State s); 0040 void startSsl(); 0041 0042 [[nodiscard]] QSsl::SslProtocol negotiatedEncryption() const; 0043 0044 public Q_SLOTS: 0045 void handleSslError(const KSslErrorUiData &data); 0046 0047 void socketDisconnected(); 0048 void encryptionNegotiationResult(bool encrypted, QSsl::SslProtocol version); 0049 void responseReceived(const KSmtp::ServerResponse &response); 0050 void socketConnected(); 0051 void setAuthenticationMethods(const QList<QByteArray> &authMethods); 0052 0053 private Q_SLOTS: 0054 void doStartNext(); 0055 void jobDone(KJob *job); 0056 void jobDestroyed(QObject *job); 0057 0058 void onSocketTimeout(); 0059 0060 private: 0061 void startHandshake(); 0062 void startNext(); 0063 void startSocketTimer(); 0064 void stopSocketTimer(); 0065 0066 Session *const q; 0067 0068 // Smtp session 0069 Session::State m_state = Session::Disconnected; 0070 Session::EncryptionMode m_encryptionMode = Session::Unencrypted; 0071 SessionThread *m_thread = nullptr; 0072 SessionUiProxy::Ptr m_uiProxy; 0073 int m_socketTimerInterval = 60000; 0074 QTimer m_socketTimer; 0075 QSsl::SslProtocol m_sslVersion = QSsl::UnknownProtocol; 0076 0077 // Jobs 0078 bool m_jobRunning = false; 0079 Job *m_currentJob = nullptr; 0080 QQueue<Job *> m_queue; 0081 0082 // Smtp info 0083 bool m_ehloRejected = false; 0084 int m_size = 0; 0085 bool m_allowsTls = false; 0086 bool m_starttlsSent = false; 0087 bool m_allowsDsn = false; 0088 QStringList m_authModes; 0089 QString m_customHostname; 0090 }; 0091 }