QtBase
v6.3.1
tests
auto
dbus
qdbusinterface
myobject.h
Go to the documentation of this file.
1
/****************************************************************************
2
**
3
** Copyright (C) 2016 The Qt Company Ltd.
4
** Contact: https://www.qt.io/licensing/
5
**
6
** This file is part of the test suite of the Qt Toolkit.
7
**
8
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and The Qt Company. For licensing terms
14
** and conditions see https://www.qt.io/terms-conditions. For further
15
** information use the contact form at https://www.qt.io/contact-us.
16
**
17
** GNU General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU
19
** General Public License version 3 as published by the Free Software
20
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21
** included in the packaging of this file. Please review the following
22
** information to ensure the GNU General Public License requirements will
23
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24
**
25
** $QT_END_LICENSE$
26
**
27
****************************************************************************/
28
29
#ifndef MYOBJECT_H
30
#define MYOBJECT_H
31
32
#include <QObject>
33
#include <QDBusMessage>
34
#include <QDBusContext>
35
#include <QDBusConnection>
36
37
class
MyObject
:
public
QObject
,
protected
QDBusContext
38
{
39
Q_OBJECT
40
Q_CLASSINFO
(
"D-Bus Interface"
,
"org.qtproject.QtDBus.MyObject"
)
41
Q_CLASSINFO
("
D
-Bus Introspection", ""
42
" <
interface
name
=\"org.qtproject.QtDBus.
MyObject
\" >\
n
"
43
" <
property
access
=\"readwrite\"
type
=\"
i
\"
name
=\"prop1\" />\
n
"
44
" <
property
name
=\"complexProp\"
type
=\"ai\"
access
=\"readwrite\">\
n
"
45
" <annotation
name
=\"org.qtproject.QtDBus.QtTypeName\"
value
=\"
QList
<
int
>\"/>\
n
"
46
" </
property
>\
n
"
47
" <
signal
name
=\"somethingHappened\" >\
n
"
48
" <
arg
direction
=\"
out
\"
type
=\"
s
\" />\
n
"
49
" </
signal
>\
n
"
50
" <
method
name
=\"
ping
\" >\
n
"
51
" <
arg
direction
=\"
in
\"
type
=\"
v
\"
name
=\"
ping
\" />\
n
"
52
" <
arg
direction
=\"
out
\"
type
=\"
v
\"
name
=\"
ping
\" />\
n
"
53
" </
method
>\
n
"
54
" <
method
name
=\"ping_invokable\" >\
n
"
55
" <
arg
direction
=\"
in
\"
type
=\"
v
\"
name
=\"ping_invokable\" />\
n
"
56
" <
arg
direction
=\"
out
\"
type
=\"
v
\"
name
=\"ping_invokable\" />\
n
"
57
" </
method
>\
n
"
58
" <
method
name
=\"
ping
\" >\
n
"
59
" <
arg
direction
=\"
in
\"
type
=\"
v
\"
name
=\"ping1\" />\
n
"
60
" <
arg
direction
=\"
in
\"
type
=\"
v
\"
name
=\"ping2\" />\
n
"
61
" <
arg
direction
=\"
out
\"
type
=\"
v
\"
name
=\"pong1\" />\
n
"
62
" <
arg
direction
=\"
out
\"
type
=\"
v
\"
name
=\"pong2\" />\
n
"
63
" </
method
>\
n
"
64
" <
method
name
=\"ping_invokable\" >\
n
"
65
" <
arg
direction
=\"
in
\"
type
=\"
v
\"
name
=\"ping1_invokable\" />\
n
"
66
" <
arg
direction
=\"
in
\"
type
=\"
v
\"
name
=\"ping2_invokable\" />\
n
"
67
" <
arg
direction
=\"
out
\"
type
=\"
v
\"
name
=\"pong1_invokable\" />\
n
"
68
" <
arg
direction
=\"
out
\"
type
=\"
v
\"
name
=\"pong2_invokable\" />\
n
"
69
" </
method
>\
n
"
70
" <
method
name
=\"
ping
\" >\
n
"
71
" <
arg
direction
=\"
in
\"
type
=\"ai\"
name
=\"
ping
\" />\
n
"
72
" <
arg
direction
=\"
out
\"
type
=\"ai\"
name
=\"
ping
\" />\
n
"
73
" <annotation
name
=\"org.qtproject.QtDBus.QtTypeName.In0\"
value
=\"
QList
<
int
>\"/>\
n
"
74
" <annotation
name
=\"org.qtproject.QtDBus.QtTypeName.Out0\"
value
=\"
QList
<
int
>\"/>\
n
"
75
" </
method
>\
n
"
76
" <
method
name
=\"ping_invokable\" >\
n
"
77
" <
arg
direction
=\"
in
\"
type
=\"ai\"
name
=\"ping_invokable\" />\
n
"
78
" <
arg
direction
=\"
out
\"
type
=\"ai\"
name
=\"ping_invokable\" />\
n
"
79
" <annotation
name
=\"org.qtproject.QtDBus.QtTypeName.In0\"
value
=\"
QList
<
int
>\"/>\
n
"
80
" <annotation
name
=\"org.qtproject.QtDBus.QtTypeName.Out0\"
value
=\"
QList
<
int
>\"/>\
n
"
81
" </
method
>\
n
"
82
" </
interface
>\
n
"
83
"")
84
Q_PROPERTY
(
int
prop1 READ prop1 WRITE setProp1)
85
Q_PROPERTY
(
QList
<
int
> complexProp READ complexProp WRITE setComplexProp)
86
87
public:
88
static
int
callCount
;
89
static
QVariantList
callArgs;
90
MyObject
()
91
{
92
QObject
*subObject =
new
QObject
(
this
);
93
subObject->
setObjectName
(
"subObject"
);
94
}
95
96
int
m_prop1;
97
int
prop1()
const
98
{
99
++
callCount
;
100
return
m_prop1;
101
}
102
void
setProp1(
int
value
)
103
{
104
++
callCount
;
105
m_prop1 =
value
;
106
}
107
108
QList<int>
m_complexProp;
109
QList<int>
complexProp()
const
110
{
111
++
callCount
;
112
return
m_complexProp;
113
}
114
void
setComplexProp(
const
QList<int>
&
value
)
115
{
116
++
callCount
;
117
m_complexProp =
value
;
118
}
119
120
Q_INVOKABLE
void
ping_invokable(
QDBusMessage
msg)
121
{
122
Q_ASSERT
(
QDBusContext::calledFromDBus
());
123
++
callCount
;
124
callArgs =
msg
.arguments();
125
126
msg
.setDelayedReply(
true
);
127
if
(!
QDBusContext::connection
().send(
msg
.createReply(callArgs)))
128
exit(1);
129
}
130
131
public
slots
:
132
133
void
ping
(
QDBusMessage
msg)
134
{
135
Q_ASSERT
(
QDBusContext::calledFromDBus
());
136
++
callCount
;
137
callArgs =
msg
.arguments();
138
139
msg
.setDelayedReply(
true
);
140
if
(!
QDBusContext::connection
().send(
msg
.createReply(callArgs)))
141
exit(1);
142
}
143
};
144
145
#endif
// INTERFACE_H
i
small capitals from c petite p scientific i
[1]
Definition:
afcover.h:80
msg
const char msg[]
Definition:
arch.cpp:46
value
#define value
[5]
Definition:
src_corelib_global_qglobal.cpp:107
MyObject
[0]
Definition:
myobject.h:58
MyObject::ping
void ping(QDBusMessage msg)
Definition:
myobject.h:133
MyObject::method
void method(const QDBusMessage &msg)
Definition:
tst_qdbusconnection.cpp:46
MyObject::callCount
int callCount
Definition:
tst_qdbusconnection.h:59
QDBusContext
The QDBusContext class allows slots to determine the D-Bus context of the calls.
Definition:
qdbuscontext.h:57
QDBusContext::calledFromDBus
bool calledFromDBus() const
Definition:
qdbuscontext.cpp:126
QDBusContext::connection
QDBusConnection connection() const
Definition:
qdbuscontext.cpp:134
QDBusMessage
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition:
qdbusmessage.h:58
QList
Definition:
qlist.h:108
QObject
The QObject class is the base class of all Qt objects.
Definition:
qobject.h:125
QObject::QObject
Q_INVOKABLE QObject(QObject *parent=nullptr)
Definition:
qobject.cpp:913
QObject::property
QVariant property(const char *name) const
Definition:
qobject.cpp:4118
QObject::setObjectName
void setObjectName(const QString &name)
Definition:
qobject.cpp:1261
signal
auto signal
Definition:
doc_src_qsignalspy.cpp:105
direction
direction
Definition:
doc_src_styles.cpp:89
D
#define D
Definition:
hb-ot-shape-complex-arabic-table.hh:23
interface
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char * interface
Definition:
qdbus_symbols_p.h:383
value
EGLOutputLayerEXT EGLint EGLAttrib value
Definition:
qeglstreamconvenience_p.h:82
type
GLenum type
Definition:
qopengl.h:270
v
GLsizei const GLfloat * v
[13]
Definition:
qopengles2ext.h:788
access
GLenum access
Definition:
qopengles2ext.h:2467
name
GLuint name
Definition:
qopengles2ext.h:156
n
GLfloat n
Definition:
qopengles2ext.h:795
in
GLuint in
Definition:
qopenglext.h:8870
s
GLdouble s
[6]
Definition:
qopenglext.h:235
Q_ASSERT
#define Q_ASSERT(cond)
Definition:
qrandom.cpp:84
arg
SSL_CTX int(*) void arg)
Definition:
qsslsocket_openssl_symbols.cpp:438
Q_PROPERTY
#define Q_PROPERTY(...)
Definition:
qtmetamacros.h:92
Q_OBJECT
#define Q_OBJECT
Definition:
qtmetamacros.h:158
Q_CLASSINFO
#define Q_CLASSINFO(name, value)
Definition:
qtmetamacros.h:88
Q_INVOKABLE
#define Q_INVOKABLE
Definition:
qtmetamacros.h:112
slots
#define slots
Definition:
qtmetamacros.h:76
out
QTextStream out(stdout)
[7]
Definition:
src_corelib_kernel_qvariant.cpp:62
Generated by
1.9.1