Qt Accessibility Client

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

KDE's Doxygen guidelines are available online.