Libksieve

session.h
1/*
2 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
3 SPDX-FileContributor: Volker Krause <volker.krause@kdab.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#pragma once
9
10#include "response.h"
11
12#include <KJob>
13#include <QObject>
14#include <QQueue>
15#include <QStringList>
16#include <QUrl>
17
18class KSslErrorUiData;
19
20namespace KManageSieve
21{
22class SieveJob;
23class SessionThread;
24
25struct AuthDetails {
26 QString username;
27 QString password;
28 bool valid;
29};
30
31/** A network session with a manage sieve server.
32 * @internal
33 */
34class Session : public QObject
35{
37
38public:
39 explicit Session(QObject *parent = nullptr);
40 ~Session() override;
41
42 void connectToHost(const QUrl &url);
43 void disconnectFromHost(bool sendLogout = true);
44
45 void scheduleJob(SieveJob *job);
46 void killJob(SieveJob *job, KJob::KillVerbosity verbosity);
47 void sendData(const QByteArray &data);
48
49 [[nodiscard]] QStringList sieveExtensions() const;
50
51 /**
52 * @return true if we are not connected nor currently connecting, i.e. it's ok to call connectToHost()
53 */
54 [[nodiscard]] bool disconnected() const;
55
56private:
57 [[nodiscard]] bool requestCapabilitiesAfterStartTls() const;
58
59 [[nodiscard]] QStringList requestedSaslMethod() const;
60 [[nodiscard]] bool allowUnencrypted() const;
61
62private Q_SLOTS:
63 void setErrorMessage(int error, const QString &msg);
64 void processResponse(const KManageSieve::Response &response, const QByteArray &data);
65 [[nodiscard]] KManageSieve::AuthDetails requestAuthDetails(const QUrl &url);
66 void authenticationDone();
67 void sslError(const KSslErrorUiData &data);
68 void sslDone();
69
70 void executeNextJob();
71
72private:
73 Q_DISABLE_COPY(Session)
74 SessionThread *const m_thread;
75 QUrl m_url;
76 QQueue<SieveJob *> m_jobs;
77 SieveJob *m_currentJob = nullptr;
78 QStringList m_sieveExtensions;
79 QStringList m_saslMethods;
80 QString m_implementation;
81 enum State {
82 None,
83 PreTlsCapabilities,
84 PostTlsCapabilities,
85 StartTls,
86 Authenticating
87 };
88 State m_state = None;
89 bool m_supportsStartTls = false;
90 bool m_connected = false;
91 bool m_disconnected = true;
92
93 friend class SessionThread;
94};
95}
A response from a managesieve server.
Definition response.h:18
A network session with a manage sieve server.
Definition session.h:35
bool disconnected() const
Definition session.cpp:206
A job to manage sieve scripts.
Definition sievejob.h:31
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.