1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the public API. This header file may
9// change from version to version without notice, or even be
10// removed.
11//
12// We mean it.
13//
14//
15
16#ifndef QDBUSABSTRACTADAPTOR_P_H
17#define QDBUSABSTRACTADAPTOR_P_H
18
19#include <QtDBus/private/qtdbusglobal_p.h>
20#include <qdbusabstractadaptor.h>
21
22#include <QtCore/qlist.h>
23#include <QtCore/qmap.h>
24#include <QtCore/qobject.h>
25#include <QtCore/qvariant.h>
26#include "private/qobject_p.h"
27
28#define QCLASSINFO_DBUS_INTERFACE "D-Bus Interface"
29#define QCLASSINFO_DBUS_INTROSPECTION "D-Bus Introspection"
30
31#ifndef QT_NO_DBUS
32
33#ifdef interface
34# undef interface
35#endif
36
37QT_BEGIN_NAMESPACE
38
39class QDBusAbstractAdaptor;
40class QDBusAdaptorConnector;
41class QDBusAdaptorManager;
42class QDBusConnectionPrivate;
43
44class QDBusAbstractAdaptorPrivate: public QObjectPrivate
45{
46 Q_DECLARE_PUBLIC(QDBusAbstractAdaptor)
47public:
48 QDBusAbstractAdaptorPrivate() : autoRelaySignals(false) {}
49 QString xml;
50 bool autoRelaySignals;
51
52 static QString retrieveIntrospectionXml(QDBusAbstractAdaptor *adaptor);
53 static void saveIntrospectionXml(QDBusAbstractAdaptor *adaptor, const QString &xml);
54};
55
56class QDBusAdaptorConnector: public QObject
57{
58 Q_OBJECT
59
60public: // typedefs
61 struct AdaptorData
62 {
63 const char *interface;
64 QDBusAbstractAdaptor *adaptor;
65
66 inline bool operator<(const AdaptorData &other) const
67 { return QByteArray(interface) < other.interface; }
68 inline bool operator<(const QString &other) const
69 { return QLatin1StringView(interface) < other; }
70 inline bool operator<(const QByteArray &other) const
71 { return interface < other; }
72 };
73 typedef QList<AdaptorData> AdaptorMap;
74
75public: // methods
76 explicit QDBusAdaptorConnector(QObject *parent);
77 ~QDBusAdaptorConnector();
78
79 void addAdaptor(QDBusAbstractAdaptor *adaptor);
80 void connectAllSignals(QObject *object);
81 void disconnectAllSignals(QObject *object);
82 void relay(QObject *sender, int id, void **);
83
84public Q_SLOTS:
85 void relaySlot(QMethodRawArguments a);
86 void polish();
87
88Q_SIGNALS:
89 void relaySignal(QObject *obj, const QMetaObject *metaObject, int sid, const QVariantList &args);
90
91public: // member variables
92 AdaptorMap adaptors;
93 bool waitingForPolish : 1;
94
95private:
96 static int relaySlotMethodIndex();
97};
98Q_DECLARE_TYPEINFO(QDBusAdaptorConnector::AdaptorData, Q_PRIMITIVE_TYPE);
99
100extern QDBusAdaptorConnector *qDBusFindAdaptorConnector(QObject *object);
101extern QDBusAdaptorConnector *qDBusCreateAdaptorConnector(QObject *object);
102
103QT_END_NAMESPACE
104
105#endif // QT_NO_DBUS
106#endif // QDBUSABSTRACTADAPTOR_P_H
107

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