KIMAP

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

KDE's Doxygen guidelines are available online.