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

KDE's Doxygen guidelines are available online.