Libksieve

session.h
1 /*
2  Copyright (c) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
3  Author: Volker Krause <[email protected]>
4 
5  This library is free software; you can redistribute it and/or modify it
6  under the terms of the GNU Library General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or (at your
8  option) any later version.
9 
10  This library is distributed in the hope that it will be useful, but WITHOUT
11  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13  License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to the
17  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  02110-1301, USA.
19 */
20 
21 #ifndef KSIEVE_KMANAGESIEVE_SESSION_H
22 #define KSIEVE_KMANAGESIEVE_SESSION_H
23 
24 #include "response.h"
25 
26 #include <KJob>
27 #include <QUrl>
28 #include <QObject>
29 #include <QQueue>
30 #include <QStringList>
31 
32 class KSslErrorUiData;
33 
34 namespace KManageSieve {
35 class SieveJob;
36 class SessionThread;
37 
38 struct AuthDetails {
39  QString username;
40  QString password;
41  bool valid;
42 };
43 
47 class Session : public QObject
48 {
49  Q_OBJECT
50 
51 public:
52  explicit Session(QObject *parent = nullptr);
53  ~Session();
54 
55  void connectToHost(const QUrl &url);
56  void disconnectFromHost(bool sendLogout = true);
57 
58  void scheduleJob(SieveJob *job);
59  void killJob(SieveJob *job, KJob::KillVerbosity verbosity);
60  void sendData(const QByteArray &data);
61 
62  QStringList sieveExtensions() const;
63 
67  bool disconnected() const;
68 
69 private:
70  bool requestCapabilitiesAfterStartTls() const;
71 
72  QStringList requestedSaslMethod() const;
73  bool allowUnencrypted() const;
74 
75 private Q_SLOTS:
76  void setErrorMessage(int error, const QString &msg);
77  void processResponse(const KManageSieve::Response &response, const QByteArray &data);
78  KManageSieve::AuthDetails requestAuthDetails(const QUrl &url);
79  void authenticationDone();
80  void sslError(const KSslErrorUiData &data);
81  void sslDone();
82 
83  void executeNextJob();
84 
85 private:
86  Q_DISABLE_COPY(Session)
87  SessionThread *m_thread = nullptr;
88  QUrl m_url;
89  QQueue<SieveJob *> m_jobs;
90  SieveJob *m_currentJob = nullptr;
91  QStringList m_sieveExtensions;
92  QStringList m_saslMethods;
93  QString m_implementation;
94  enum State {
95  None,
96  PreTlsCapabilities,
97  PostTlsCapabilities,
98  StartTls,
99  Authenticating
100  };
101  State m_state;
102  bool m_supportsStartTls = false;
103  bool m_connected = false;
104  bool m_disconnected = false;
105 
106  friend class SessionThread;
107 };
108 }
109 
110 #endif
A response from a managesieve server.
Definition: response.h:30
A job to manage sieve scripts.
Definition: sievejob.h:41
A network session with a manage sieve server.
Definition: session.h:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 7 2020 23:06:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.