KIMAP

loginjob.h
1/*
2 SPDX-FileCopyrightText: 2009 Kevin Ottens <ervin@kde.org>
3 SPDX-FileCopyrightText: 2009 Andras Mantia <amantia@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#pragma once
9
10#include "kimap_export.h"
11
12#include "job.h"
13
14namespace KIMAP
15{
16class Session;
17struct Response;
18class LoginJobPrivate;
19
20class KIMAP_EXPORT LoginJob : public Job
21{
22 Q_OBJECT
23 Q_DECLARE_PRIVATE(LoginJob)
24
25 friend class SessionPrivate;
26
27public:
28 enum EncryptionMode {
29 Unencrypted = 0,
30 SSLorTLS, /*!< Use SSL/TLS encryption, KIMAP will automatically negotiate
31 the best supported encryption protocol. */
32 STARTTLS /*!< Use STARTTLS to upgrade an initially plaintext connection to
33 encrypted connection. KIMAP will automatically negotiate
34 the best supported encryption protocol. */
35 };
36 Q_ENUM(EncryptionMode)
37
38 enum AuthenticationMode {
39 ClearText = 0,
40 Login,
41 Plain,
42 CramMD5,
43 DigestMD5,
44 NTLM,
45 GSSAPI,
46 Anonymous,
47 XOAuth2,
48 };
49 Q_ENUM(AuthenticationMode)
50
51 enum ErrorCode {
52 ERR_COULD_NOT_CONNECT = KJob::UserDefinedError + 23 // same as in kio
53 };
54
55 explicit LoginJob(Session *session);
56 ~LoginJob() override;
57
58 [[nodiscard]] QString userName() const;
59 void setUserName(const QString &userName);
60
61 /**
62 * Get the authorization identity.
63 * @since 4.10
64 */
65 [[nodiscard]] QString authorizationName() const;
66
67 /**
68 * Set the authorization identity.
69 *
70 * If set, proxy-authentication according to RFC4616 will be used.
71 *
72 * Note that this feature only works with the "PLAIN" AuthenticationMode.
73 *
74 * The @param authorizationName will be used together with the password() to get authenticated as userName() by the authorization of the provided
75 * credentials. This allows to login as a user using the admin credentials and the users name.
76 * @since 4.10
77 */
78 void setAuthorizationName(const QString &authorizationName);
79
80 [[nodiscard]] QString password() const;
81 void setPassword(const QString &password);
82
83 /**
84 * Returns the server greeting, in case of a successful login.
85 * If the login wasn't successful, this method returns an empty string. Use errorString() to
86 * get the error message in this case.
87 *
88 * Note that the content of this response is not defined by the IMAP protocol and is
89 * implementation-dependent.
90 * @since 4.7
91 */
92 [[nodiscard]] QString serverGreeting() const;
93
94 /**
95 * Set the encryption mode for the connection. In case an encryption mode is set, the caller
96 * MUST check the encryptionMode() result after executing the job, to see if the connection is
97 * encrypted or not (e.g handshaking failed).
98 * @param mode the encryption mode, see EncryptionModes
99 */
100 void setEncryptionMode(EncryptionMode mode);
101
102 /**
103 Get the encryption mode.
104 @return the currently active encryption mode
105 */
106 [[nodiscard]] EncryptionMode encryptionMode();
107
108 void setAuthenticationMode(AuthenticationMode mode);
109
110protected:
111 void doStart() override;
112 void handleResponse(const Response &response) override;
113 void connectionLost() override;
114
115private:
116 Q_PRIVATE_SLOT(d_func(), void sslResponse(bool))
117};
118
119}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:50:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.