Libksieve

session.h
1 /*
2  SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
3  SPDX-FileContributor: Volker Krause <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KSIEVE_KMANAGESIEVE_SESSION_H
9 #define KSIEVE_KMANAGESIEVE_SESSION_H
10 
11 #include "response.h"
12 
13 #include <KJob>
14 #include <QUrl>
15 #include <QObject>
16 #include <QQueue>
17 #include <QStringList>
18 
19 class KSslErrorUiData;
20 
21 namespace KManageSieve {
22 class SieveJob;
23 class SessionThread;
24 
25 struct AuthDetails {
26  QString username;
27  QString password;
28  bool valid;
29 };
30 
34 class Session : public QObject
35 {
36  Q_OBJECT
37 
38 public:
39  explicit Session(QObject *parent = nullptr);
40  ~Session();
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  Q_REQUIRED_RESULT QStringList sieveExtensions() const;
50 
54  bool disconnected() const;
55 
56 private:
57  Q_REQUIRED_RESULT bool requestCapabilitiesAfterStartTls() const;
58 
59  Q_REQUIRED_RESULT QStringList requestedSaslMethod() const;
60  Q_REQUIRED_RESULT bool allowUnencrypted() const;
61 
62 private Q_SLOTS:
63  void setErrorMessage(int error, const QString &msg);
64  void processResponse(const KManageSieve::Response &response, const QByteArray &data);
65  Q_REQUIRED_RESULT KManageSieve::AuthDetails requestAuthDetails(const QUrl &url);
66  void authenticationDone();
67  void sslError(const KSslErrorUiData &data);
68  void sslDone();
69 
70  void executeNextJob();
71 
72 private:
73  Q_DISABLE_COPY(Session)
74  SessionThread *m_thread = nullptr;
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 }
96 
97 #endif
A response from a managesieve server.
Definition: response.h:17
A job to manage sieve scripts.
Definition: sievejob.h:36
A network session with a manage sieve server.
Definition: session.h:34
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Dec 3 2020 23:10:36 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.