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
5//
6// W A R N I N G
7// -------------
8//
9// This file is not part of the public API. This header file may
10// change from version to version without notice, or even be
11// removed.
12//
13// We mean it.
14//
15//
16
17#ifndef QDBUSINTEGRATOR_P_H
18#define QDBUSINTEGRATOR_P_H
19
20#include <QtDBus/private/qtdbusglobal_p.h>
21#include "qdbus_symbols_p.h"
22
23#include "qcoreevent.h"
24#include "qeventloop.h"
25#include "qobject.h"
26#include "private/qobject_p.h"
27#include "qlist.h"
28#include "qpointer.h"
29#include "qsemaphore.h"
30
31#include "qdbusconnection.h"
32#include "qdbusmessage.h"
33#include "qdbusconnection_p.h"
34
35#ifndef QT_NO_DBUS
36
37QT_BEGIN_NAMESPACE
38
39class QDBusConnectionPrivate;
40class QDBusMessage;
41
42// Really private structs used by qdbusintegrator.cpp
43// Things that aren't used by any other file
44
45struct QDBusSlotCache
46{
47 struct Data
48 {
49 int flags;
50 int slotIdx;
51 QList<QMetaType> metaTypes;
52
53 void swap(Data &other) noexcept
54 {
55 qSwap(value1&: flags, value2&: other.flags);
56 qSwap(value1&: slotIdx, value2&: other.slotIdx);
57 qSwap(value1&: metaTypes, value2&: other.metaTypes);
58 }
59 };
60 typedef QMultiHash<QString, Data> Hash;
61 Hash hash;
62
63 void swap(QDBusSlotCache &other) noexcept { qSwap(value1&: hash, value2&: other.hash); }
64};
65Q_DECLARE_SHARED(QDBusSlotCache::Data)
66Q_DECLARE_SHARED(QDBusSlotCache)
67
68class QDBusCallDeliveryEvent: public QAbstractMetaCallEvent
69{
70public:
71 QDBusCallDeliveryEvent(const QDBusConnection &c, int id, QObject *sender,
72 const QDBusMessage &msg, const QList<QMetaType> &types, int f = 0)
73 : QAbstractMetaCallEvent(sender, -1),
74 connection(c),
75 message(msg),
76 metaTypes(types),
77 id(id),
78 flags(f)
79 {
80 }
81
82 void placeMetaCall(QObject *object) override
83 {
84 QDBusConnectionPrivate::d(q: connection)->deliverCall(object, flags, msg: message, metaTypes, slotIdx: id);
85 }
86
87private:
88 QDBusConnection connection; // just for refcounting
89 QDBusMessage message;
90 QList<QMetaType> metaTypes;
91 int id;
92 int flags;
93};
94
95class QDBusActivateObjectEvent: public QAbstractMetaCallEvent
96{
97public:
98 QDBusActivateObjectEvent(const QDBusConnection &c, QObject *sender,
99 const QDBusConnectionPrivate::ObjectTreeNode &n,
100 int p, const QDBusMessage &m, QSemaphore *s = nullptr)
101 : QAbstractMetaCallEvent(sender, -1, s), connection(c), node(n),
102 pathStartPos(p), message(m), handled(false)
103 { }
104 ~QDBusActivateObjectEvent() override;
105
106 void placeMetaCall(QObject *) override;
107
108private:
109 QDBusConnection connection; // just for refcounting
110 QDBusConnectionPrivate::ObjectTreeNode node;
111 int pathStartPos;
112 QDBusMessage message;
113 bool handled;
114};
115
116class QDBusSpyCallEvent : public QAbstractMetaCallEvent
117{
118public:
119 typedef void (*Hook)(const QDBusMessage&);
120 QDBusSpyCallEvent(QDBusConnectionPrivate *cp, const QDBusConnection &c, const QDBusMessage &msg,
121 const Hook *hooks, int count)
122 : QAbstractMetaCallEvent(cp, 0), conn(c), msg(msg), hooks(hooks), hookCount(count)
123 {}
124 ~QDBusSpyCallEvent() override;
125 void placeMetaCall(QObject *) override;
126 static inline void invokeSpyHooks(const QDBusMessage &msg, const Hook *hooks, int hookCount);
127
128 QDBusConnection conn; // keeps the refcount in QDBusConnectionPrivate up
129 QDBusMessage msg;
130 const Hook *hooks;
131 int hookCount;
132};
133
134QT_END_NAMESPACE
135
136QT_DECL_METATYPE_EXTERN(QDBusSlotCache, Q_DBUS_EXPORT)
137
138#endif // QT_NO_DBUS
139#endif
140

source code of qtbase/src/dbus/qdbusintegrator_p.h