KIMAP2

loginjob.h
1/*
2 Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
3 Copyright (c) 2009 Andras Mantia <amantia@kde.org>
4 Copyright (c) 2017 Christian Mollekopf <mollekopf@kolabsys.com>
5
6 This library is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Library General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or (at your
9 option) any later version.
10
11 This library is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301, USA.
20*/
21
22#ifndef KIMAP2_LOGINJOB_H
23#define KIMAP2_LOGINJOB_H
24
25#include "kimap2_export.h"
26
27#include "job.h"
28#include <QtNetwork/QSsl>
29
30namespace KIMAP2
31{
32
33class Session;
34struct Message;
35class LoginJobPrivate;
36
37class KIMAP2_EXPORT LoginJob : public Job
38{
39 Q_OBJECT
40 Q_DECLARE_PRIVATE(LoginJob)
41
42 friend class SessionPrivate;
43
44public:
45
46 enum AuthenticationMode {
47 ClearText = 0,
48 Login,
49 Plain,
50 CramMD5,
51 DigestMD5,
52 NTLM,
53 GSSAPI,
54 Anonymous,
55 XOAuth2
56 };
57
58 explicit LoginJob(Session *session);
59 virtual ~LoginJob();
60
61 QString userName() const;
62 void setUserName(const QString &userName);
63
64 /**
65 * Get the authorization identity.
66 * @since 4.10
67 */
68 QString authorizationName() const;
69
70 /**
71 * Set the authorization identity.
72 *
73 * If set, proxy-authentication according to RFC4616 will be used.
74 *
75 * Note that this feature only works with the "PLAIN" AuthenticationMode.
76 *
77 * The @param authorizationName will be used together with the password() to get authenticated as userName() by the authorization of the provided credentials.
78 * This allows to login as a user using the admin credentials and the users name.
79 * @since 4.10
80 */
81 void setAuthorizationName(const QString &authorizationName);
82
83 QString password() const;
84 void setPassword(const QString &password);
85
86 /**
87 * Returns the server greeting, in case of a successful login.
88 * If the login wasn't successful, this method returns an empty string. Use errorString() to
89 * get the error message in this case.
90 *
91 * Note that the content of this response is not defined by the IMAP protocol and is
92 * implementation-dependent.
93 * @since 4.7
94 */
95 QString serverGreeting() const;
96
97 /**
98 * Set the encryption mode for the connection. In case an encryption mode is set, the caller
99 * MUST check the encryptionMode() result after executing the job, to see if the connection is
100 * encrypted or not (e.g handshaking failed).
101 * @param mode the encryption mode, see EncryptionModes
102 */
103 void setEncryptionMode(QSsl::SslProtocol mode, bool startTls = false);
104
105 /**
106 Get the encryption mode.
107 @return the currently active encryption mode
108 */
109 QSsl::SslProtocol encryptionMode();
110
111 void setAuthenticationMode(AuthenticationMode mode);
112
113protected:
114 void doStart() Q_DECL_OVERRIDE;
115 void handleResponse(const Message &response) Q_DECL_OVERRIDE;
116 void connectionLost() Q_DECL_OVERRIDE;
117
118private:
119 Q_PRIVATE_SLOT(d_func(), void sslResponse(bool))
120};
121
122}
123
124#endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:56:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.