author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 06 Jul 2010 15:10:48 +0300 | |
changeset 30 | 5dc02b23752f |
parent 18 | 2f34d5167611 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the plugins of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
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 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
49 |
#ifndef QT_NO_DBUS |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
50 |
|
0 | 51 |
class QDBusConnectionConstructor : public QObject, |
52 |
public QScriptable |
|
53 |
{ |
|
54 |
Q_OBJECT |
|
55 |
Q_PROPERTY(QScriptValue sessionBus READ sessionBus) |
|
56 |
Q_PROPERTY(QScriptValue systemBus READ systemBus) |
|
57 |
||
58 |
public: |
|
59 |
QDBusConnectionConstructor(QScriptEngine *engine, QScriptValue extensionObject); |
|
60 |
||
61 |
QScriptValue sessionBus() const; |
|
62 |
QScriptValue systemBus() const; |
|
63 |
||
64 |
public Q_SLOTS: |
|
65 |
QObject *qscript_call(const QString &name); |
|
66 |
||
67 |
void disconnectFromBus(const QString &name); |
|
68 |
QDBusConnection connectToBus(const QString &address, const QString &name); |
|
69 |
QDBusConnection connectToBus(QDBusConnection::BusType type, const QString &name); |
|
70 |
}; |
|
71 |
||
72 |
class QScriptDBusConnection : public QObject, |
|
73 |
public QScriptable |
|
74 |
{ |
|
75 |
Q_OBJECT |
|
76 |
Q_PROPERTY(QString baseService READ baseService) |
|
77 |
Q_PROPERTY(bool isConnected READ isConnected) |
|
78 |
Q_PROPERTY(QScriptValue dbusInterface READ dbusInterface) |
|
79 |
public: |
|
80 |
QScriptDBusConnection(const QDBusConnection &conn, QObject *parent); |
|
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 |
||
102 |
inline void unregisterObject(const QString &path, QDBusConnection::UnregisterMode mode = QDBusConnection::UnregisterNode) |
|
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: |
|
129 |
QDBusConnection connection; |
|
130 |
}; |
|
131 |
||
132 |
Q_DECLARE_METATYPE(QScriptDBusConnection*) |
|
133 |
||
134 |
class QScriptDBusInterfaceConstructor : public QObject, |
|
135 |
public QScriptable |
|
136 |
{ |
|
137 |
Q_OBJECT |
|
138 |
public: |
|
139 |
QScriptDBusInterfaceConstructor(QScriptEngine *engine, QScriptValue extensionObject); |
|
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 |
||
146 |
Q_DECLARE_METATYPE(QDBusMessage) |
|
147 |
||
148 |
class QScriptDBusMessageConstructor : public QObject, public QScriptable |
|
149 |
{ |
|
150 |
Q_OBJECT |
|
151 |
Q_ENUMS(MessageType) |
|
152 |
public: |
|
153 |
enum MessageType { |
|
154 |
InvalidMessage = QDBusMessage::InvalidMessage, |
|
155 |
MethodCallMessage = QDBusMessage::MethodCallMessage, |
|
156 |
ReplyMessage = QDBusMessage::ReplyMessage, |
|
157 |
ErrorMessage = QDBusMessage::ErrorMessage, |
|
158 |
SignalMessage = QDBusMessage::SignalMessage |
|
159 |
}; |
|
160 |
||
161 |
QScriptDBusMessageConstructor(QScriptEngine *engine, QScriptValue extensionObject); |
|
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: |
|
175 |
QScriptValue proto; |
|
176 |
}; |
|
177 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
178 |
#endif // QT_NO_DBUS |
0 | 179 |
#endif // QDBUSBINDING_H |