Qt 4.8
main.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "main.h"
43 #include <QDebug>
44 #include <QMetaMethod>
45 #include <QScriptExtensionPlugin>
46 
47 #ifndef QT_NO_DBUS
48 
50 
52 
54 {
55  int firstArgument = 0;
56  QString functionName = context->callee().property(QLatin1String("functionName")).toString();
57  if (functionName.isEmpty()) {
58  functionName = context->argument(0).toString();
59  ++firstArgument;
60  }
61 
62  QScriptValue thisObject = context->thisObject();
64  if (!iface)
65  return QScriptValue();
66 
68  iface->path(),
69  iface->interface(),
70  functionName);
71 
72  QList<QVariant> args;
73  for (int i = firstArgument; i < context->argumentCount(); ++i) {
74  args.append(context->argument(i).toVariant());
75  }
76  msg.setArguments(args);
77 
78  msg = iface->connection().call(msg);
79 
80  QScriptValue returnValue = engine->nullValue();
81  args = msg.arguments();
82  if (args.count() != 1)
83  return returnValue;
84 
85  QVariant variant = args.first();
86  if (variant.type() == QVariant::UserType
87  && variant.userType() == qMetaTypeId<QDBusObjectPath>()) {
89 
90  QDBusInterface *returnedIface = new QDBusInterface(iface->service(),
91  path.path(),
92  /*interface*/QString(),
93  iface->connection(),
94  engine);
95  returnValue = setupDBusInterface(engine, returnedIface);
96  } else {
97  returnValue = engine->newVariant(variant);
98  }
99 
100  return returnValue;
101 }
102 
104 {
105  QScriptValue v = engine->newQObject(iface);
106 
107  if (!qobject_cast<QDBusConnectionInterface *>(iface)) {
108  const QMetaObject *mo = iface->metaObject();
109  for (int i = 0; i < mo->methodCount(); ++i) {
110  const QMetaMethod method = mo->method(i);
111  const QByteArray signature = method.signature();
112  //qDebug() << "signature" << signature;
113  int parenIndex = signature.indexOf('(');
114  if (parenIndex == -1)
115  continue;
116  const QByteArray name = signature.left(parenIndex);
117  if (name.isEmpty())
118  continue;
119 
120  // don't try to override properties
121  if (mo->indexOfProperty(name) != -1)
122  continue;
123 
124  QScriptValue callWrapper = engine->newFunction(do_dbus_call);
125  const QString nameString = QString::fromAscii(name);
126  callWrapper.setProperty(QLatin1String("functionName"), QScriptValue(engine, nameString));
127  v.setProperty(nameString, callWrapper);
128  }
129  }
130 
131  v.setProperty(QLatin1String("service"), QScriptValue(engine, iface->service()), QScriptValue::ReadOnly);
132  v.setProperty(QLatin1String("path"), QScriptValue(engine, iface->path()), QScriptValue::ReadOnly);
133  v.setProperty(QLatin1String("interface"), QScriptValue(engine, iface->interface()), QScriptValue::ReadOnly);
134  v.setProperty(QLatin1String("isValid"), QScriptValue(engine, iface->isValid()), QScriptValue::ReadOnly);
135  v.setProperty(QLatin1String("connection"), engine->newQObject(new QScriptDBusConnection(iface->connection(), engine)), QScriptValue::ReadOnly);
136 
137  return v;
138 }
139 
141  : QObject(engine)
142 {
143  QScriptValue ctor = engine->newQObject(this);
144 
145  QScriptValue proto = engine->newQMetaObject(&QDBusConnection::staticMetaObject);
146  proto.setPrototype(engine->globalObject().property(QLatin1String("Function")).property(QLatin1String("prototype")));
147  ctor.setProperty(QLatin1String("prototype"), proto);
148 
149  extensionObject.setProperty(QLatin1String("QDBusConnection"), ctor);
150 }
151 
153 {
155 }
156 
158 {
160 }
161 
163 {
164  return new QScriptDBusConnection(QDBusConnection(name), this);
165 }
166 
168 {
170 }
171 
173 {
174  return QDBusConnection::connectToBus(address, name);
175 }
176 
178 {
179  return QDBusConnection::connectToBus(type, name);
180 }
181 
183  : QObject(parent), connection(conn)
184 {
185 }
186 
188 {
190  if (!iface)
191  return engine()->nullValue();
192  return setupDBusInterface(engine(), iface);
193 }
194 
196 {
197  QScriptValue ctorValue = engine->newQObject(this);
198  QScriptValue klass = engine->newQMetaObject(metaObject(), ctorValue);
199  extensionObject.setProperty(QLatin1String("QDBusInterface"), klass);
200 }
201 
203  const QScriptValue &conn)
204 {
206 
208  if (connWrapper)
209  connection = connWrapper->dbusConnection();
210 
211  return setupDBusInterface(engine(), new QDBusInterface(service, path, interface, connection, engine()));
212 }
213 
215  : QObject(engine)
216 {
217  proto = engine->newQMetaObject(metaObject(), engine->newQObject(this));
218 
219  proto.setProperty(QLatin1String("createReply"), engine->newFunction(createReply));
220  proto.setProperty(QLatin1String("createErrorReply"), engine->newFunction(createErrorReply));
221 
222  extensionObject.setProperty(QLatin1String("QDBusMessage"), proto);
223  engine->setDefaultPrototype(qMetaTypeId<QDBusMessage>(), proto);
224 }
225 
227 {
228  return QDBusMessage::createSignal(path, interface, name);
229 }
230 
231 QDBusMessage QScriptDBusMessageConstructor::createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method)
232 {
233  return QDBusMessage::createMethodCall(destination, path, interface, method);
234 }
235 
237 {
238  return QDBusMessage::createError(name, msg);
239 }
240 
242 {
243  QScriptValue v = engine->newVariant(QVariant::fromValue(message));
244  v.setProperty(QLatin1String("service"), QScriptValue(engine, message.service()), QScriptValue::ReadOnly);
245  v.setProperty(QLatin1String("path"), QScriptValue(engine, message.path()), QScriptValue::ReadOnly);
246  v.setProperty(QLatin1String("interface"), QScriptValue(engine, message.interface()), QScriptValue::ReadOnly);
247  v.setProperty(QLatin1String("member"), QScriptValue(engine, message.member()), QScriptValue::ReadOnly);
248  v.setProperty(QLatin1String("type"), QScriptValue(engine, message.type()), QScriptValue::ReadOnly);
249  v.setProperty(QLatin1String("signature"), QScriptValue(engine, message.signature()), QScriptValue::ReadOnly);
250  v.setProperty(QLatin1String("isReplyRequired"), QScriptValue(engine, message.isReplyRequired()), QScriptValue::ReadOnly);
251 
252  v.setProperty(QLatin1String("delayedReply"), QScriptValue(engine, message.isDelayedReply()));
253  QScriptValue argValue = engine->newArray();
254  const QList<QVariant> args = message.arguments();
255  for (int i = 0; i < args.count(); ++i)
256  argValue.setProperty(QScriptValue(engine, i).toString(),
257  engine->newVariant(args.at(i)));
258 
259  v.setProperty(QLatin1String("arguments"), argValue);
260 
261  return v;
262 }
263 
264 static void scriptValueToMessage(const QScriptValue &value, QDBusMessage &message)
265 {
266  QVariant v = value.toVariant();
267  message = qvariant_cast<QDBusMessage>(v);
268  message.setDelayedReply(value.property(QLatin1String("delayedReply")).toBoolean());
269 
270  QList<QVariant> args;
271  quint32 len = value.property(QLatin1String("length")).toUInt32();
272  for (quint32 i = 0; i < len; ++i) {
273  QScriptValue item = value.property(i);
274  args.append(item.toVariant());
275  }
276  message.setArguments(args);
277 }
278 
280 {
281  QDBusMessage msg;
282  scriptValueToMessage(context->thisObject(), msg);
283 
284  QList<QVariant> args;
285  for (int i = 0; i < context->argumentCount(); ++i) {
286  QScriptValue value = context->argument(i);
287  args.append(value.toVariant());
288  }
289 
290  return messageToScriptValue(engine, msg.createReply(args));
291 }
292 
294 {
295  if (context->argumentCount() != 2)
296  return engine->nullValue();
297 
298  QDBusMessage msg;
299  scriptValueToMessage(context->thisObject(), msg);
300 
301  QString name = context->argument(0).toString();
302  QString errMsg = context->argument(1).toString();
303  return messageToScriptValue(engine, msg.createErrorReply(name, errMsg));
304 }
305 
306 template <typename T>
308 {
309  return QScriptValue(eng, reply.value());
310 }
311 
312 template <>
314 {
315  QScriptValue v = eng->newArray();
316  const QStringList &lst = reply.value();
317  for (int i = 0; i < lst.count(); ++i)
318  v.setProperty(i, QScriptValue(eng, lst.at(i)));
319  return v;
320 }
321 
322 template <typename T>
324 {
325  // never called
326 }
327 
329 {
330  QScriptValue v = engine->newObject();
331  v.setProperty(QLatin1String("type"), QScriptValue(engine, error.type()), QScriptValue::ReadOnly);
332  v.setProperty(QLatin1String("name"), QScriptValue(engine, error.name()), QScriptValue::ReadOnly);
333  v.setProperty(QLatin1String("message"), QScriptValue(engine, error.message()), QScriptValue::ReadOnly);
334  v.setProperty(QLatin1String("isValid"), QScriptValue(engine, error.isValid()), QScriptValue::ReadOnly);
335  return v;
336 }
337 
339 {
340  Q_UNUSED(value)
341  Q_UNUSED(error)
342  // never called
343 }
344 
351 
353 {
354 public:
355  QStringList keys() const;
356  void initialize(const QString &key, QScriptEngine *engine);
357 };
358 
360 {
361  return QStringList(QLatin1String("qt.dbus"));
362 }
363 
365 {
366  if (key != QLatin1String("qt.dbus")) {
367  Q_ASSERT_X(false, "initialize", qPrintable(key));
368  return;
369  }
370 
371  QScriptValue extensionObject = engine->globalObject();
372 
373  qScriptRegisterMetaType<QDBusReply<QString> >(engine, qDBusReplyToScriptValue, qDBusReplyFromScriptValue);
374  qScriptRegisterMetaType<QDBusReply<QStringList> >(engine, qDBusReplyToScriptValue, qDBusReplyFromScriptValue);
375  qScriptRegisterMetaType<QDBusReply<uint> >(engine, qDBusReplyToScriptValue, qDBusReplyFromScriptValue);
376  qScriptRegisterMetaType<QDBusReply<bool> >(engine, qDBusReplyToScriptValue, qDBusReplyFromScriptValue);
377  qScriptRegisterMetaType<QDBusReply<QDBusConnectionInterface::RegisterServiceReply> >(engine, qDBusReplyToScriptValue, qDBusReplyFromScriptValue);
378  qScriptRegisterMetaType<QDBusMessage>(engine, messageToScriptValue, scriptValueToMessage);
379  qScriptRegisterMetaType<QDBusError>(engine, qDBusErrorToScriptValue, scriptValueToQDBusError);
380 
381  QScriptValue connIfaceProto = engine->newQMetaObject(&QDBusConnectionInterface::staticMetaObject, engine->nullValue());
382  extensionObject.setProperty(QLatin1String("QDBusConnectionInterface"), connIfaceProto);
383 
384  QScriptValue qdbus = engine->newObject();
385  qdbus.setProperty(QLatin1String("NoBlock"), QScriptValue(engine, QDBus::NoBlock));
386  qdbus.setProperty(QLatin1String("Block"), QScriptValue(engine, QDBus::Block));
387  qdbus.setProperty(QLatin1String("BlockWithGui"), QScriptValue(engine, QDBus::BlockWithGui));
388  qdbus.setProperty(QLatin1String("AutoDetect"), QScriptValue(engine, QDBus::AutoDetect));
389  engine->globalObject().setProperty(QLatin1String("QDBus"), qdbus);
390 
391  (void)new QDBusConnectionConstructor(engine, extensionObject);
392  (void)new QScriptDBusInterfaceConstructor(engine, extensionObject);
393  (void)new QScriptDBusMessageConstructor(engine, extensionObject);
394 }
395 
396 
399 
400 #endif // QT_NO_DBUS
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QScriptValue newFunction(FunctionSignature signature, int length=0)
Creates a QScriptValue that wraps a native (C++) function.
QDBusMessage createSignal(const QString &path, const QString &interface, const QString &name)
Definition: main.cpp:226
The QScriptContext class represents a Qt Script function invocation.
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
static QDBusMessage createError(const QString &name, const QString &msg)
Constructs a new DBus message representing an error, with the given name and msg. ...
The QDBusConnectionInterface class provides access to the D-Bus bus daemon service.
The QScriptExtensionPlugin class provides an abstract base for custom QScript extension plugins...
QScriptValue property(const QString &name, const ResolveFlags &mode=ResolvePrototype) const
Returns the value of this QScriptValue&#39;s property with the given name, using the given mode to resolv...
QDBusMessage createError(const QString &name, const QString &msg)
Definition: main.cpp:236
int type
Definition: qmetatype.cpp:239
QDBusConnectionInterface * interface() const
Returns a QDBusConnectionInterface object that represents the D-Bus server interface on this connecti...
QString path() const
Returns the object path that this interface is associated with.
bool isValid() const
Returns true if this is a valid error condition (i.e., if there was an error), otherwise false...
Definition: qdbuserror.cpp:356
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QScriptValue qDBusReplyToScriptValue(QScriptEngine *eng, const QDBusReply< T > &reply)
Definition: main.cpp:307
static QDBusMessage createSignal(const QString &path, const QString &interface, const QString &name)
Constructs a new DBus message with the given path, interface and name, representing a signal emission...
bool isValid() const
Returns true if this is a valid reference to a remote object.
QScriptValue callee() const
Returns the callee.
#define error(msg)
The QDBusReply class stores the reply for a method call to a remote object.
Definition: qdbusreply.h:65
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QDBusConnection connection() const
Returns the connection this interface is assocated with.
QString service() const
Returns the name of the service or the bus address of the remote method call.
QScriptDBusInterfaceConstructor(QScriptEngine *engine, QScriptValue extensionObject)
Definition: main.cpp:195
QStringList keys() const
Returns the list of keys this plugin supports.
Definition: main.cpp:359
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
The QDBusError class represents an error received from the D-Bus bus or from remote applications foun...
Definition: qdbuserror.h:60
QScriptValue globalObject() const
Returns this engine&#39;s Global Object.
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
QDBusMessage call(const QDBusMessage &message, QDBus::CallMode mode=QDBus::Block, int timeout=-1) const
Sends the message over this connection and blocks, waiting for a reply, for at most timeout milliseco...
The QDBusInterface class is a proxy for interfaces on remote objects.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QDBusConnection systemBus()
Returns a QDBusConnection object opened with the system bus.
QScriptEngine * engine() const
Returns a pointer to the QScriptEngine associated with the current Qt function call, or 0 if the Qt function was not invoked from script code.
void qDBusReplyFromScriptValue(const QScriptValue &, QDBusReply< T > &)
Definition: main.cpp:323
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QScriptValue qscript_call(const QString &service, const QString &path, const QString &interface=QString(), const QScriptValue &conn=QScriptValue())
Definition: main.cpp:202
QObject * toQObject() const
If this QScriptValue is a QObject, returns the QObject pointer that the QScriptValue represents; othe...
void setDelayedReply(bool enable) const
Sets whether the message will be replied later (if enable is true) or if an automatic reply should be...
QString interface() const
Returns the name of this interface.
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
int indexOfProperty(const char *name) const
Finds property name and returns its index; otherwise returns -1.
QDBusMessage createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method)
Definition: main.cpp:231
QStringList keys
QObject * qscript_call(const QString &name)
Definition: main.cpp:162
ErrorType type() const
Returns this error&#39;s ErrorType.
Definition: qdbuserror.cpp:323
QScriptValue sessionBus() const
QDBusMessage createErrorReply(const QString name, const QString &msg) const
Constructs a new DBus message representing an error reply message, with the given name and msg...
QString signature() const
Returns the signature of the signal that was received or for the output arguments of a method call...
static QString toString(Register *reg, int type, bool *ok=0)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QScriptEngine class provides an environment for evaluating Qt Script code.
The QDBusAbstractInterface class is the base class for all D-Bus interfaces in the QtDBus binding...
Q_EXPORT_PLUGIN2(qjpcodecs, JPTextCodecs)
Q_EXPORT_STATIC_PLUGIN(JPTextCodecs)
QList< QVariant > arguments() const
Returns the list of arguments that are going to be sent or were received from D-Bus.
static void disconnectFromBus(const QString &name)
Closes the bus connection of name name.
QString path() const
Returns the path of the object that this message is being sent to (in the case of a method call) or b...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QScriptValue createReply(QScriptContext *context, QScriptEngine *engine)
Definition: main.cpp:279
QDBusConnectionConstructor(QScriptEngine *engine, QScriptValue extensionObject)
Definition: main.cpp:140
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool isReplyRequired() const
Returns the flag that indicates if this message should see a reply or not.
QVariant toVariant() const
Returns the QVariant value of this QScriptValue, if it can be converted to a QVariant; otherwise retu...
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static QScriptValue createErrorReply(QScriptContext *context, QScriptEngine *engine)
Definition: main.cpp:293
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QScriptValue newObject()
Creates a QtScript object of class Object.
QString path() const
Returns this object path.
QString name() const
Returns this error&#39;s name.
Definition: qdbuserror.cpp:335
quint32 toUInt32() const
Returns the unsigned 32-bit integer value of this QScriptValue, using the conversion rules described ...
BusType
Specifies the type of the bus connection.
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
QString member() const
Returns the name of the signal that was emitted or the name of the method that was called...
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
bool toBoolean() const
Use toBool() instead.
bool isDelayedReply() const
Returns the delayed reply flag, as set by setDelayedReply().
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
#define Q_DECLARE_METATYPE(TYPE)
This macro makes the type Type known to QMetaType as long as it provides a public default constructor...
Definition: qmetatype.h:265
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
QScriptValue newQObject(QObject *object, ValueOwnership ownership=QtOwnership, const QObjectWrapOptions &options=0)
Creates a QtScript object that wraps the given QObject object, using the given ownership.
QDBusMessage createReply(const QList< QVariant > &arguments=QList< QVariant >()) const
Constructs a new DBus message representing a reply, with the given arguments.
QString interface() const
Returns the interface of the method being called (in the case of a method call) or of the signal bein...
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
void setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
Sets the value of this QScriptValue&#39;s property with the given name to the given value.
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
QScriptValue dbusInterface() const
void setPrototype(const QScriptValue &prototype)
If this QScriptValue is an object, sets the internal prototype (__proto__ property) of this object to...
QScriptContext * context() const
Returns a pointer to the QScriptContext associated with the current Qt function call, or 0 if the Qt function was not invoked from script code.
static QScriptValue messageToScriptValue(QScriptEngine *engine, const QDBusMessage &message)
Definition: main.cpp:241
The QDBusConnection class represents a connection to the D-Bus bus daemon.
QScriptDBusMessageConstructor(QScriptEngine *engine, QScriptValue extensionObject)
Definition: main.cpp:214
static QDBusMessage createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method)
Constructs a new DBus message representing a method call.
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
void initialize(const QString &key, QScriptEngine *engine)
Initializes the extension specified by key in the given engine.
Definition: main.cpp:364
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QScriptValue systemBus() const
QDBusConnection dbusConnection() const
Definition: main.h:86
int key
unsigned int quint32
Definition: qglobal.h:938
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...
static QDBusConnection connectToBus(BusType type, const QString &name)
Opens a connection of type type to one of the known busses and associate with it the connection name ...
QDBusConnection connectToBus(const QString &address, const QString &name)
Definition: main.cpp:172
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
QString service() const
Returns the name of the service this interface is associated with.
static QDBusConnection sessionBus()
Returns a QDBusConnection object opened with the session bus.
QScriptValue qDBusErrorToScriptValue(QScriptEngine *engine, const QDBusError &error)
Definition: main.cpp:328
#define QT_USE_NAMESPACE
This macro expands to using QT_NAMESPACE if QT_NAMESPACE is defined and nothing otherwise.
Definition: qglobal.h:88
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59
MessageType type() const
Returns the message type.
void disconnectFromBus(const QString &name)
Definition: main.cpp:167
void setArguments(const QList< QVariant > &arguments)
Sets the arguments that are going to be sent over D-Bus to arguments.
QScriptValue newQMetaObject(const QMetaObject *metaObject, const QScriptValue &ctor=QScriptValue())
Creates a QtScript object that represents a QObject class, using the the given metaObject and constru...
static QScriptValue setupDBusInterface(QScriptEngine *engine, QDBusAbstractInterface *iface)
Definition: main.cpp:103
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
static void scriptValueToMessage(const QScriptValue &value, QDBusMessage &message)
Definition: main.cpp:264
QDBusConnection connection
Definition: main.h:129
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).
const char * variant
QScriptValue newArray(uint length=0)
Creates a QtScript object of class Array with the given length.
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
#define class
static QScriptValue do_dbus_call(QScriptContext *context, QScriptEngine *engine)
Definition: main.cpp:53
void setDefaultPrototype(int metaTypeId, const QScriptValue &prototype)
Sets the default prototype of the C++ type identified by the given metaTypeId to prototype.
#define qPrintable(string)
Definition: qglobal.h:1750
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
int methodCount() const
Returns the number of methods known to the meta-object system in this class, including the number of ...
QScriptValue argument(int index) const
Returns the function argument at the given index.
Type value() const
Returns the remote function&#39;s calls return value.
Definition: qdbusreply.h:118
QScriptDBusConnection(const QDBusConnection &conn, QObject *parent)
Definition: main.cpp:182
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
QScriptValue newVariant(const QVariant &value)
Creates a QtScript object holding the given variant value.
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
void scriptValueToQDBusError(const QScriptValue &value, QDBusError &error)
Definition: main.cpp:338
T qvariant_cast(const QVariant &value)
Returns the given value converted to the template type T.
Definition: qvariant.h:571
QString message() const
Returns the message that the callee associated with this error.
Definition: qdbuserror.cpp:346