Qt Accessibility Client

dbusconnection.h
1/*
2 SPDX-FileCopyrightText: 2012 Frederik Gladhorn <gladhorn@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#ifndef DBUSCONNECTION_H
8#define DBUSCONNECTION_H
9
10#include <QObject>
11#include <QDBusConnection>
12#include <QDBusPendingCallWatcher>
13
14namespace QAccessibleClient {
15
16
17/**
18 Connection to the a11y dbus bus.
19 \internal
20 */
21class DBusConnection : public QObject
22{
24public:
25 /**
26 \brief Constructor.
27
28 When called, means the instance is created, we try instantly
29 to fetch the \a connection . When done the \a connectionFetched
30 will be emitted. If \a connection is called before it will
31 block till the connection was fetched and is ready for use.
32 */
34
35 /**
36 \brief Returns true if the \a connection is not ready yet.
37
38 The initial fetch of the comnnection happens over dbus and
39 as such can block for a longer time means may need longer.
40 To make it possible that users of this class do not block
41 while that happens it is possible to use this method to
42 determinate if fetching the connection is currently work
43 in progress and if so connect with the \a connectionFetched
44 signal to be called back when the connection is ready.
45 */
46 bool isFetchingConnection() const;
47
48 /**
49 \brief Returns the accessibility dbus connection.
50
51 This may either be the session bus or a referenced
52 accessibility bus. If the connection was not fetched
53 yet, means \a isFetchingConnection returns true, then
54 calling this method will block till the connection was
55 fetched.
56 */
58
59 enum Status {
60 Disconnected,
61 ConnectionError,
62 Connected
63 };
64
65 /**
66 \brief Returns the state the connection is in.
67
68 If Disconnected then we got not asked to connect yet or
69 connection is in progress but not finished yet (see
70 signal \a connectionFetched which will be emitted if the
71 connection is not Disconnected any longer.
72 If connection failed then the state is set to ConnectionError
73 otherwise, in the case everything went fine and we are
74 proper connected with tthe atspi daemon now Connected
75 is returned.
76 */
77 Status status() const;
78
80
81 /**
82 \brief Emitted when the \a connection was fetched.
83
84 This will happen exactly one time during the lifetime
85 of a DBusConnection instance at the very beginning when
86 the instance is created.
87 */
89
90private Q_SLOTS:
91 void initFinished();
92
93private:
94 void init();
95
96 QDBusConnection m_connection;
97 mutable Status m_status = Disconnected;
98 QDBusPendingCallWatcher *m_initWatcher = nullptr;
99};
100}
101
102#endif // DBUSCONNECTION_H
Connection to the a11y dbus bus.
QDBusConnection connection() const
Returns the accessibility dbus connection.
Status status() const
Returns the state the connection is in.
void connectionFetched()
Emitted when the connection was fetched.
bool isFetchingConnection() const
Returns true if the connection is not ready yet.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 11:57:08 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.