1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Copyright (C) 2016 Intel Corporation.
5** Contact: https://www.qt.io/licensing/
6**
7** This file is part of the QtDBus module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial License Usage
11** Licensees holding valid commercial Qt licenses may use this file in
12** accordance with the commercial license agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and The Qt Company. For licensing terms
15** and conditions see https://www.qt.io/terms-conditions. For further
16** information use the contact form at https://www.qt.io/contact-us.
17**
18** GNU Lesser General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU Lesser
20** General Public License version 3 as published by the Free Software
21** Foundation and appearing in the file LICENSE.LGPL3 included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU Lesser General Public License version 3 requirements
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25**
26** GNU General Public License Usage
27** Alternatively, this file may be used under the terms of the GNU
28** General Public License version 2.0 or (at your option) the GNU General
29** Public license version 3 or any later version approved by the KDE Free
30** Qt Foundation. The licenses are as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32** included in the packaging of this file. Please review the following
33** information to ensure the GNU General Public License requirements will
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35** https://www.gnu.org/licenses/gpl-3.0.html.
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41//
42// W A R N I N G
43// -------------
44//
45// This file is not part of the public API. This header file may
46// change from version to version without notice, or even be
47// removed.
48//
49// We mean it.
50//
51//
52
53#ifndef QDBUSINTEGRATOR_P_H
54#define QDBUSINTEGRATOR_P_H
55
56#include <QtDBus/private/qtdbusglobal_p.h>
57#include "qdbus_symbols_p.h"
58
59#include "qcoreevent.h"
60#include "qeventloop.h"
61#include "qobject.h"
62#include "private/qobject_p.h"
63#include "qlist.h"
64#include "qpointer.h"
65#include "qsemaphore.h"
66
67#include "qdbusconnection.h"
68#include "qdbusmessage.h"
69#include "qdbusconnection_p.h"
70
71#ifndef QT_NO_DBUS
72
73QT_BEGIN_NAMESPACE
74
75class QDBusConnectionPrivate;
76class QDBusMessage;
77
78// Really private structs used by qdbusintegrator.cpp
79// Things that aren't used by any other file
80
81struct QDBusSlotCache
82{
83 struct Data
84 {
85 int flags;
86 int slotIdx;
87 QVector<int> metaTypes;
88
89 void swap(Data &other) noexcept
90 {
91 qSwap(value1&: flags, value2&: other.flags);
92 qSwap(value1&: slotIdx, value2&: other.slotIdx);
93 qSwap(value1&: metaTypes, value2&: other.metaTypes);
94 }
95 };
96 typedef QMultiHash<QString, Data> Hash;
97 Hash hash;
98
99 void swap(QDBusSlotCache &other) noexcept { qSwap(value1&: hash, value2&: other.hash); }
100};
101Q_DECLARE_SHARED(QDBusSlotCache::Data)
102Q_DECLARE_SHARED(QDBusSlotCache)
103
104class QDBusCallDeliveryEvent: public QAbstractMetaCallEvent
105{
106public:
107 QDBusCallDeliveryEvent(const QDBusConnection &c, int id, QObject *sender,
108 const QDBusMessage &msg, const QVector<int> &types, int f = 0)
109 : QAbstractMetaCallEvent(sender, -1), connection(c), message(msg), metaTypes(types), id(id), flags(f)
110 { }
111
112 void placeMetaCall(QObject *object) override
113 {
114 QDBusConnectionPrivate::d(q: connection)->deliverCall(object, flags, msg: message, metaTypes, slotIdx: id);
115 }
116
117private:
118 QDBusConnection connection; // just for refcounting
119 QDBusMessage message;
120 QVector<int> metaTypes;
121 int id;
122 int flags;
123};
124
125class QDBusActivateObjectEvent: public QAbstractMetaCallEvent
126{
127public:
128 QDBusActivateObjectEvent(const QDBusConnection &c, QObject *sender,
129 const QDBusConnectionPrivate::ObjectTreeNode &n,
130 int p, const QDBusMessage &m, QSemaphore *s = nullptr)
131 : QAbstractMetaCallEvent(sender, -1, s), connection(c), node(n),
132 pathStartPos(p), message(m), handled(false)
133 { }
134 ~QDBusActivateObjectEvent() override;
135
136 void placeMetaCall(QObject *) override;
137
138private:
139 QDBusConnection connection; // just for refcounting
140 QDBusConnectionPrivate::ObjectTreeNode node;
141 int pathStartPos;
142 QDBusMessage message;
143 bool handled;
144};
145
146class QDBusSpyCallEvent : public QAbstractMetaCallEvent
147{
148public:
149 typedef void (*Hook)(const QDBusMessage&);
150 QDBusSpyCallEvent(QDBusConnectionPrivate *cp, const QDBusConnection &c, const QDBusMessage &msg,
151 const Hook *hooks, int count)
152 : QAbstractMetaCallEvent(cp, 0), conn(c), msg(msg), hooks(hooks), hookCount(count)
153 {}
154 ~QDBusSpyCallEvent() override;
155 void placeMetaCall(QObject *) override;
156 static inline void invokeSpyHooks(const QDBusMessage &msg, const Hook *hooks, int hookCount);
157
158 QDBusConnection conn; // keeps the refcount in QDBusConnectionPrivate up
159 QDBusMessage msg;
160 const Hook *hooks;
161 int hookCount;
162};
163
164QT_END_NAMESPACE
165
166Q_DECLARE_METATYPE(QDBusSlotCache)
167
168#endif // QT_NO_DBUS
169#endif
170

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