KIMAP

session.h
1/*
2 SPDX-FileCopyrightText: 2009 Kevin Ottens <ervin@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "kimap_export.h"
10
11#include <QObject>
12
13#include "sessionuiproxy.h"
14
15namespace KIMAP
16{
17class SessionPrivate;
18class JobPrivate;
19struct Response;
20
21class KIMAP_EXPORT Session : public QObject
22{
23 Q_OBJECT
24
25 friend class JobPrivate;
26
27public:
28 enum State {
29 Disconnected = 0,
30 NotAuthenticated,
31 Authenticated,
32 Selected
33 };
34 Q_ENUM(State)
35 Session(const QString &hostName, quint16 port, QObject *parent = nullptr);
36 ~Session();
37
38 [[nodiscard]] QString hostName() const;
39 [[nodiscard]] quint16 port() const;
40 [[nodiscard]] State state() const;
41
42 /**
43 * Returns the name that has been set with LoginJob::setUserName()
44 * The user name is useful to uniquely identify an IMAP resource, in combination with the host name
45 * @note If the Session was pre-authenticated, userName() will return an empty string
46 * @since 4.7
47 */
48 [[nodiscard]] QString userName() const;
49
50 [[nodiscard]] QByteArray serverGreeting() const;
51
52 /**
53 * Sets an ui proxy that displays the error messages and waits for user feedback.
54 * @param proxy the ui proxy object
55 */
56 void setUiProxy(const SessionUiProxy::Ptr &proxy);
57
58 /**
59 * Sets an ui proxy that displays the error messages and waits for user feedback.
60 * @param proxy the ui proxy object
61 * @deprecated Use the shared pointer version instead
62 */
63 KIMAP_DEPRECATED void setUiProxy(SessionUiProxy *proxy);
64
65 /**
66 * Set the session timeout. The default is 30 seconds.
67 * @param timeout The socket timeout in seconds, negative values disable the timeout.
68 * @since 4.6
69 */
70 void setTimeout(int timeout);
71
72 /**
73 * Returns the session timeout.
74 * @since 4.12
75 */
76 [[nodiscard]] int timeout() const;
77
78 /**
79 * Returns the currently selected mailbox.
80 * @since 4.5
81 */
82 [[nodiscard]] QString selectedMailBox() const;
83
84 /**
85 * Sets whether the IMAP network connection should use the system proxy settings.
86 *
87 * @param useProxy @c true if the proxy is to be used
88 * The default is to not use the proxy.
89 * @since 5.11.41
90 *
91 * @note If the session is currently connected to the IMAP server, calling this
92 * function will disconnect and reconnect to it with the changed proxy setting.
93 */
94 void setUseNetworkProxy(bool useProxy);
95
96 [[nodiscard]] int jobQueueSize() const;
97
98 void close();
99
100Q_SIGNALS:
101 void jobQueueSizeChanged(int queueSize);
102
103 /**
104 Emitted when we lose a previously established connection
105
106 Likely reasons: server closed the connection, loss of internet connectivity, etc...
107 */
108 void connectionLost();
109
110 /**
111 Emitted when the Session couldn't connect to the host.
112
113 Likely reasons: invalid host address, no internet connectivity, firewall blocking rules,
114 etc...
115
116 Pending jobs in the queue will be deleted, and the first job in the queue will be failed. (ie:
117 it will have its result signal emitted with a non-zero error code.)
118
119 @since 4.7
120 */
121 void connectionFailed();
122
123 /**
124 Emitted when the session's state changes.
125
126 Not very useful after all... :-)
127
128 If you want to receive the stateChanged arguments in your slot, you must register the State
129 enum with @c Q_DECLARE_METATYPE(KIMAP::Session::State) and @c qRegisterMetaType<KIMAP::Session::State>();
130
131 @since 4.7
132 */
133 void stateChanged(KIMAP::Session::State newState, KIMAP::Session::State oldState);
134
135private:
136 friend class SessionPrivate;
137 SessionPrivate *const d;
138};
139
140}
const QList< QKeySequence > & close()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.