1 | /* |
2 | Copyright (c) 2009 Kevin Ottens <ervin@kde.org> |
3 | Copyright (c) 2009 Andras Mantia <amantia@kde.org> |
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 KIMAP_LOGINJOB_H |
22 | #define KIMAP_LOGINJOB_H |
23 | |
24 | #include "kimap_export.h" |
25 | |
26 | #include "job.h" |
27 | |
28 | namespace KIMAP { |
29 | |
30 | class Session; |
31 | struct Message; |
32 | class LoginJobPrivate; |
33 | |
34 | class KIMAP_EXPORT LoginJob : public Job |
35 | { |
36 | Q_OBJECT |
37 | Q_DECLARE_PRIVATE( LoginJob ) |
38 | |
39 | friend class SessionPrivate; |
40 | |
41 | public: |
42 | enum EncryptionMode { |
43 | Unencrypted = 0, |
44 | TlsV1, |
45 | SslV2, |
46 | SslV3, |
47 | SslV3_1, |
48 | AnySslVersion |
49 | }; |
50 | |
51 | enum AuthenticationMode { |
52 | ClearText = 0, |
53 | Login, |
54 | Plain, |
55 | CramMD5, |
56 | DigestMD5, |
57 | NTLM, |
58 | GSSAPI, |
59 | Anonymous, |
60 | XOAuth2 |
61 | }; |
62 | |
63 | enum ErrorCode { |
64 | ERR_COULD_NOT_CONNECT = KJob::UserDefinedError + 23 // same as in kio |
65 | }; |
66 | |
67 | explicit LoginJob( Session *session ); |
68 | virtual ~LoginJob(); |
69 | |
70 | QString userName() const; |
71 | void setUserName( const QString &userName ); |
72 | |
73 | /** |
74 | * Get the authorization identity. |
75 | * @since 4.10 |
76 | */ |
77 | QString authorizationName() const; |
78 | |
79 | /** |
80 | * Set the authorization identity. |
81 | * |
82 | * If set, proxy-authentication according to RFC4616 will be used. |
83 | * |
84 | * Note that this feature only works with the "PLAIN" AuthenticationMode. |
85 | * |
86 | * The @param authorizationName will be used together with the password() to get authenticated as userName() by the authorization of the provided credentials. |
87 | * This allows to login as a user using the admin credentials and the users name. |
88 | * @since 4.10 |
89 | */ |
90 | void setAuthorizationName( const QString &authorizationName ); |
91 | |
92 | QString password() const; |
93 | void setPassword( const QString &password ); |
94 | |
95 | /** |
96 | * Returns the server greeting, in case of a successful login. |
97 | * If the login wasn't successful, this method returns an empty string. Use errorString() to |
98 | * get the error message in this case. |
99 | * |
100 | * Note that the content of this response is not defined by the IMAP protocol and is |
101 | * implementation-dependent. |
102 | * @since 4.7 |
103 | */ |
104 | QString serverGreeting() const; |
105 | |
106 | /** |
107 | * Set the encryption mode for the connection. In case an encryption mode is set, the caller |
108 | * MUST check the encryptionMode() result after executing the job, to see if the connection is |
109 | * encrypted or not (e.g handshaking failed). |
110 | * @param mode the encryption mode, see EncryptionModes |
111 | */ |
112 | void setEncryptionMode(EncryptionMode mode); |
113 | |
114 | /** |
115 | Get the encryption mode. |
116 | @return the currently active encryption mode |
117 | */ |
118 | EncryptionMode encryptionMode(); |
119 | |
120 | void setAuthenticationMode( AuthenticationMode mode ); |
121 | |
122 | protected: |
123 | virtual void doStart(); |
124 | virtual void handleResponse( const Message &response ); |
125 | virtual void connectionLost(); |
126 | |
127 | private: |
128 | Q_PRIVATE_SLOT( d_func(), void sslResponse(bool) ) |
129 | }; |
130 | |
131 | } |
132 | |
133 | #endif |
134 | |