/src/qtbase/src/dbus/qdbusintegrator_p.h
Line | Count | Source |
1 | | // Copyright (C) 2016 The Qt Company Ltd. |
2 | | // Copyright (C) 2016 Intel Corporation. |
3 | | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
4 | | // Qt-Security score:significant reason:default |
5 | | |
6 | | // |
7 | | // W A R N I N G |
8 | | // ------------- |
9 | | // |
10 | | // This file is not part of the public API. This header file may |
11 | | // change from version to version without notice, or even be |
12 | | // removed. |
13 | | // |
14 | | // We mean it. |
15 | | // |
16 | | // |
17 | | |
18 | | #ifndef QDBUSINTEGRATOR_P_H |
19 | | #define QDBUSINTEGRATOR_P_H |
20 | | |
21 | | #include <QtDBus/private/qtdbusglobal_p.h> |
22 | | #include "qdbus_symbols_p.h" |
23 | | |
24 | | #include "qcoreevent.h" |
25 | | #include "qeventloop.h" |
26 | | #include "qobject.h" |
27 | | #include "private/qobject_p.h" |
28 | | #include "qlist.h" |
29 | | #include "qpointer.h" |
30 | | #include "qsemaphore.h" |
31 | | |
32 | | #include "qdbusconnection.h" |
33 | | #include "qdbusmessage.h" |
34 | | #include "qdbusconnection_p.h" |
35 | | |
36 | | #ifndef QT_NO_DBUS |
37 | | |
38 | | QT_BEGIN_NAMESPACE |
39 | | |
40 | | class QDBusConnectionPrivate; |
41 | | class QDBusMessage; |
42 | | |
43 | | // Really private structs used by qdbusintegrator.cpp |
44 | | // Things that aren't used by any other file |
45 | | |
46 | | struct QDBusSlotCache |
47 | | { |
48 | | struct Data |
49 | | { |
50 | | int slotIdx; |
51 | | QList<QMetaType> metaTypes; |
52 | | |
53 | | void swap(Data &other) noexcept |
54 | 0 | { |
55 | 0 | std::swap(slotIdx, other.slotIdx); |
56 | 0 | metaTypes.swap(other.metaTypes); |
57 | 0 | } |
58 | | }; |
59 | | |
60 | | struct Key |
61 | | { |
62 | | QString memberWithSignature; |
63 | | QDBusConnection::RegisterOptions flags; |
64 | | |
65 | | friend bool operator==(const Key &lhs, const Key &rhs) noexcept |
66 | 0 | { |
67 | 0 | return lhs.memberWithSignature == rhs.memberWithSignature && lhs.flags == rhs.flags; |
68 | 0 | } |
69 | | |
70 | | friend size_t qHash(const QDBusSlotCache::Key &key, size_t seed = 0) noexcept |
71 | 0 | { |
72 | 0 | return qHashMulti(seed, key.memberWithSignature, key.flags); |
73 | 0 | } |
74 | | }; |
75 | | |
76 | | using Hash = QHash<Key, Data>; |
77 | | |
78 | | Hash hash; |
79 | | |
80 | 0 | void swap(QDBusSlotCache &other) noexcept { hash.swap(other.hash); } |
81 | | }; |
82 | 0 | Q_DECLARE_SHARED(QDBusSlotCache::Data) |
83 | 0 | Q_DECLARE_SHARED(QDBusSlotCache) |
84 | 0 |
|
85 | 0 | class QDBusCallDeliveryEvent: public QAbstractMetaCallEvent |
86 | 0 | { |
87 | 0 | public: |
88 | 0 | QDBusCallDeliveryEvent(const QDBusConnection &c, int id, QObject *sender, |
89 | 0 | const QDBusMessage &msg, const QList<QMetaType> &types) |
90 | 0 | : QAbstractMetaCallEvent(sender, -1), connection(c), message(msg), metaTypes(types), id(id) |
91 | 0 | { |
92 | 0 | } |
93 | | |
94 | | void placeMetaCall(QObject *object) override |
95 | 0 | { |
96 | 0 | QDBusConnectionPrivate::d(connection)->deliverCall(object, message, metaTypes, id); |
97 | 0 | } |
98 | | |
99 | | private: |
100 | | QDBusConnection connection; // just for refcounting |
101 | | QDBusMessage message; |
102 | | QList<QMetaType> metaTypes; |
103 | | int id; |
104 | | }; |
105 | | |
106 | | class QDBusActivateObjectEvent: public QAbstractMetaCallEvent |
107 | | { |
108 | | public: |
109 | | QDBusActivateObjectEvent(const QDBusConnection &c, QObject *sender, |
110 | | const QDBusConnectionPrivate::ObjectTreeNode &n, |
111 | | int p, const QDBusMessage &m, QLatch *l = nullptr) |
112 | 0 | : QAbstractMetaCallEvent(sender, -1, l), connection(c), node(n), |
113 | 0 | pathStartPos(p), message(m), handled(false) |
114 | 0 | { } |
115 | | ~QDBusActivateObjectEvent() override; |
116 | | |
117 | | void placeMetaCall(QObject *) override; |
118 | | |
119 | | private: |
120 | | QDBusConnection connection; // just for refcounting |
121 | | QDBusConnectionPrivate::ObjectTreeNode node; |
122 | | int pathStartPos; |
123 | | QDBusMessage message; |
124 | | bool handled; |
125 | | }; |
126 | | |
127 | | class QDBusSpyCallEvent : public QAbstractMetaCallEvent |
128 | | { |
129 | | public: |
130 | | typedef void (*Hook)(const QDBusMessage&); |
131 | | QDBusSpyCallEvent(QDBusConnectionPrivate *cp, const QDBusConnection &c, const QDBusMessage &msg) |
132 | 0 | : QAbstractMetaCallEvent(cp, 0), conn(c), msg(msg) |
133 | 0 | {} |
134 | | ~QDBusSpyCallEvent() override; |
135 | | void placeMetaCall(QObject *) override; |
136 | | static inline void invokeSpyHooks(const QDBusMessage &msg); |
137 | | |
138 | | QDBusConnection conn; // keeps the refcount in QDBusConnectionPrivate up |
139 | | QDBusMessage msg; |
140 | | }; |
141 | | |
142 | | QT_END_NAMESPACE |
143 | | |
144 | | QT_DECL_METATYPE_EXTERN(QDBusSlotCache, Q_DBUS_EXPORT) |
145 | | |
146 | | #endif // QT_NO_DBUS |
147 | | #endif |