Qt 4.8
main.h
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 #ifndef QDBUSBINDING_H
43 #define QDBUSBINDING_H
44 
45 #include <QtDBus/QtDBus>
46 #include <QtScript/qscriptable.h>
47 #include <QtScript/qscriptengine.h>
48 
49 #ifndef QT_NO_DBUS
50 
52  public QScriptable
53 {
54  Q_OBJECT
57 
58 public:
60 
61  QScriptValue sessionBus() const;
62  QScriptValue systemBus() const;
63 
64 public Q_SLOTS:
66 
67  void disconnectFromBus(const QString &name);
68  QDBusConnection connectToBus(const QString &address, const QString &name);
70 };
71 
73  public QScriptable
74 {
75  Q_OBJECT
79 public:
81 
82  inline QString baseService() const { return connection.baseService(); }
83  inline bool isConnected() const { return connection.isConnected(); }
84  QScriptValue dbusInterface() const;
85 
86  inline QDBusConnection dbusConnection() const { return connection; }
87 
88 public Q_SLOTS:
89  inline bool send(const QDBusMessage &message) const
90  { return connection.send(message); }
91  inline QDBusMessage call(const QDBusMessage &message, int callMode = QDBus::Block, int timeout = -1) const
92  { return connection.call(message, QDBus::CallMode(callMode), timeout); }
93 
94  inline bool registerService(const QString &serviceName)
95  { return connection.registerService(serviceName); }
96  inline bool unregisterService(const QString &serviceName)
97  { return connection.unregisterService(serviceName); }
98 
99  inline QDBusError lastError() const
100  { return connection.lastError(); }
101 
103  { return connection.unregisterObject(path, mode); }
104  inline QObject *objectRegisteredAt(const QString &path) const
105  { return connection.objectRegisteredAt(path); }
106 
107 #if 0
108  bool callWithCallback(const QDBusMessage &message, QObject *receiver,
109  const char *slot, int timeout = -1) const;
110 
111  bool connect(const QString &service, const QString &path, const QString &interface,
112  const QString &name, QObject *receiver, const char *slot);
113  bool disconnect(const QString &service, const QString &path, const QString &interface,
114  const QString &name, QObject *receiver, const char *slot);
115 
116  bool connect(const QString &service, const QString &path, const QString &interface,
117  const QString &name, const QString& signature,
118  QObject *receiver, const char *slot);
119  bool disconnect(const QString &service, const QString &path, const QString &interface,
120  const QString &name, const QString& signature,
121  QObject *receiver, const char *slot);
122 
123  bool registerObject(const QString &path, QObject *object,
124  RegisterOptions options = ExportAdaptors);
125 
126 #endif
127 
128 private:
130 };
131 
133 
135  public QScriptable
136 {
137  Q_OBJECT
138 public:
140 
141 public Q_SLOTS:
142  QScriptValue qscript_call(const QString &service, const QString &path, const QString &interface = QString(),
143  const QScriptValue &conn = QScriptValue());
144 };
145 
147 
149 {
150  Q_OBJECT
152 public:
153  enum MessageType {
155  MethodCallMessage = QDBusMessage::MethodCallMessage,
159  };
160 
162 
163  QScriptValue protoType() const { return proto; }
164 
165 public Q_SLOTS:
166  QDBusMessage createSignal(const QString &path, const QString &interface, const QString &name);
167  QDBusMessage createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method);
168  QDBusMessage createError(const QString &name, const QString &msg);
169 
170 public:
171  static QScriptValue createReply(QScriptContext *context, QScriptEngine *engine);
172  static QScriptValue createErrorReply(QScriptContext *context, QScriptEngine *engine);
173 
174 private:
176 };
177 
178 #endif // QT_NO_DBUS
179 #endif // QDBUSBINDING_H
UnregisterMode
The mode for unregistering an object path:
void unregisterObject(const QString &path, QDBusConnection::UnregisterMode mode=QDBusConnection::UnregisterNode)
Definition: main.h:102
The QScriptContext class represents a Qt Script function invocation.
QDBusError lastError() const
Definition: main.h:99
int type
Definition: qmetatype.cpp:239
QString baseService
Definition: main.h:76
QObject * objectRegisteredAt(const QString &path) const
Definition: main.h:104
CallMode
This enum describes the various ways of placing a function call.
The QDBusError class represents an error received from the D-Bus bus or from remote applications foun...
Definition: qdbuserror.h:60
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.
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QObject * qscript_call(const QString &name)
Definition: main.cpp:162
bool send(const QDBusMessage &message) const
Definition: main.h:89
bool registerService(const QString &serviceName)
Definition: main.h:94
QScriptValue sessionBus() const
The QScriptable class provides access to the Qt Script environment from Qt C++ member functions...
Definition: qscriptable.h:45
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
QScriptValue sessionBus
Definition: main.h:55
The QScriptEngine class provides an environment for evaluating Qt Script code.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QDBusConnectionConstructor(QScriptEngine *engine, QScriptValue extensionObject)
Definition: main.cpp:140
const char * name
QString baseService() const
Definition: main.h:82
bool unregisterService(const QString &serviceName)
Definition: main.h:96
BusType
Specifies the type of the bus connection.
QScriptValue protoType() const
Definition: main.h:163
#define Q_OBJECT
Definition: qobjectdefs.h:157
#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
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
bool isConnected() const
Definition: main.h:83
QDBusMessage call(const QDBusMessage &message, int callMode=QDBus::Block, int timeout=-1) const
Definition: main.h:91
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.
QScriptValue systemBus
Definition: main.h:56
The QDBusConnection class represents a connection to the D-Bus bus daemon.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QScriptValue systemBus() const
QDBusConnection dbusConnection() const
Definition: main.h:86
QDBusConnection connectToBus(const QString &address, const QString &name)
Definition: main.cpp:172
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59
void disconnectFromBus(const QString &name)
Definition: main.cpp:167
QScriptValue dbusInterface
Definition: main.h:78
QDBusConnection connection
Definition: main.h:129
#define class
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57