Akonadi

core/session.h
1/*
2 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "akonadicore_export.h"
10#include <QObject>
11
12#include <memory>
13
14class KJob;
15class FakeSession;
16class FakeNotificationConnection;
17
18namespace Akonadi
19{
20namespace Protocol
21{
22class Command;
23using CommandPtr = QSharedPointer<Command>;
24}
25
26class Job;
27class SessionPrivate;
28class ChangeNotificationDependenciesFactory;
29
30/**
31 * @short A communication session with the Akonadi storage.
32 *
33 * Every Job object has to be associated with a Session.
34 * The session is responsible of scheduling its jobs.
35 * For now only a simple serial execution is implemented (the IMAP-like
36 * protocol to communicate with the storage backend is capable of parallel
37 * execution on a single session though).
38 *
39 * @code
40 *
41 * using namespace Akonadi;
42 *
43 * Session *session = new Session( "mySession" );
44 *
45 * CollectionFetchJob *job = new CollectionFetchJob( Collection::root(),
46 * CollectionFetchJob::Recursive,
47 * session );
48 *
49 * connect( job, SIGNAL(result(KJob*)), this, SLOT(slotResult(KJob*)) );
50 *
51 * @endcode
52 *
53 * @author Volker Krause <vkrause@kde.org>
54 */
55class AKONADICORE_EXPORT Session : public QObject
56{
57 Q_OBJECT
58
59 friend class Job;
60 friend class JobPrivate;
61 friend class SessionPrivate;
62
63public:
64 /**
65 * Creates a new session.
66 *
67 * @param sessionId The identifier for this session, will be a
68 * random value if empty.
69 * @param parent The parent object.
70 *
71 * @see defaultSession()
72 */
73 explicit Session(const QByteArray &sessionId = QByteArray(), QObject *parent = nullptr);
74
75 /**
76 * Destroys the session.
77 */
78 ~Session() override;
79
80 /**
81 * Returns the session identifier.
82 */
83 [[nodiscard]] QByteArray sessionId() const;
84
85 /**
86 * Returns the default session for this thread.
87 */
88 static Session *defaultSession();
89
90 /**
91 * Stops all jobs queued for execution.
92 */
93 void clear();
94
95Q_SIGNALS:
96 /**
97 * This signal is emitted whenever the session has been reconnected
98 * to the server (e.g. after a server crash).
99 *
100 * @since 4.6
101 */
103
104protected:
105 /**
106 * Creates a new session with shared private object.
107 *
108 * @param d The private object.
109 * @param sessionId The identifier for this session, will be a
110 * random value if empty.
111 * @param parent The parent object.
112 *
113 * @note This constructor is needed for unit testing only.
114 */
115 explicit Session(SessionPrivate *d, const QByteArray &sessionId = QByteArray(), QObject *parent = nullptr);
116
117private:
118 /// @cond PRIVATE
119 std::unique_ptr<SessionPrivate> const d;
120 friend class ::FakeSession;
121 friend class ::FakeNotificationConnection;
122 friend class ChangeNotificationDependenciesFactory;
123
124 Q_PRIVATE_SLOT(d, bool handleCommands())
125 /// @endcond
126};
127
128}
Base class for all actions in the Akonadi storage.
Definition job.h:81
A communication session with the Akonadi storage.
~Session() override
Destroys the session.
Session(SessionPrivate *d, const QByteArray &sessionId=QByteArray(), QObject *parent=nullptr)
Creates a new session with shared private object.
void reconnected()
This signal is emitted whenever the session has been reconnected to the server (e....
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.