Qt 4.8
qdbusconnection.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 QtDBus module 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 QDBUSCONNECTION_H
43 #define QDBUSCONNECTION_H
44 
45 #include <QtDBus/qdbusmacros.h>
46 #include <QtCore/qstring.h>
47 
48 #ifndef QT_NO_DBUS
49 
51 
53 
54 QT_MODULE(DBus)
55 
56 namespace QDBus
57 {
58  enum CallMode {
63  };
64 }
65 
67 class QDBusInterface;
68 class QDBusError;
69 class QDBusMessage;
70 class QDBusPendingCall;
72 class QDBusVirtualObject;
73 class QObject;
74 
77 {
78  Q_GADGET
80  Q_FLAGS(RegisterOptions)
81 public:
82  enum BusType { SessionBus, SystemBus, ActivationBus };
84  ExportAdaptors = 0x01,
85 
86  ExportScriptableSlots = 0x10,
87  ExportScriptableSignals = 0x20,
88  ExportScriptableProperties = 0x40,
89  ExportScriptableInvokables = 0x80,
90  ExportScriptableContents = 0xf0,
91 
92  ExportNonScriptableSlots = 0x100,
93  ExportNonScriptableSignals = 0x200,
94  ExportNonScriptableProperties = 0x400,
95  ExportNonScriptableInvokables = 0x800,
96  ExportNonScriptableContents = 0xf00,
97 
98  ExportAllSlots = ExportScriptableSlots|ExportNonScriptableSlots,
99  ExportAllSignals = ExportScriptableSignals|ExportNonScriptableSignals,
100  ExportAllProperties = ExportScriptableProperties|ExportNonScriptableProperties,
101  ExportAllInvokables = ExportScriptableInvokables|ExportNonScriptableInvokables,
102  ExportAllContents = ExportScriptableContents|ExportNonScriptableContents,
103 
104 #ifndef Q_QDOC
105  // Qt 4.2 had a misspelling here
106  ExportAllSignal = ExportAllSignals,
107 #endif
108  ExportChildObjects = 0x1000
109  // Reserved = 0xff000000
110  };
111  enum UnregisterMode {
113  UnregisterTree
114  };
115  Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)
116 
118  SingleNode = 0x0,
119  SubPath = 0x1
120  // Reserved = 0xff000000
121  };
122 #ifndef Q_QDOC
123  Q_DECLARE_FLAGS(VirtualObjectRegisterOptions, VirtualObjectRegisterOption)
124 #endif
125 
127  UnixFileDescriptorPassing = 0x0001
128  };
129  Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)
130 
131  QDBusConnection(const QString &name);
132  QDBusConnection(const QDBusConnection &other);
133  ~QDBusConnection();
134 
135  QDBusConnection &operator=(const QDBusConnection &other);
136 
137  bool isConnected() const;
138  QString baseService() const;
139  QDBusError lastError() const;
140  QString name() const;
141  ConnectionCapabilities connectionCapabilities() const;
142 
143  bool send(const QDBusMessage &message) const;
144  bool callWithCallback(const QDBusMessage &message, QObject *receiver,
145  const char *returnMethod, const char *errorMethod,
146  int timeout = -1) const;
147  bool callWithCallback(const QDBusMessage &message, QObject *receiver,
148  const char *slot, int timeout = -1) const;
149  QDBusMessage call(const QDBusMessage &message, QDBus::CallMode mode = QDBus::Block,
150  int timeout = -1) const;
151  QDBusPendingCall asyncCall(const QDBusMessage &message, int timeout = -1) const;
152 
153  bool connect(const QString &service, const QString &path, const QString &interface,
154  const QString &name, QObject *receiver, const char *slot);
155  bool connect(const QString &service, const QString &path, const QString &interface,
156  const QString &name, const QString& signature,
157  QObject *receiver, const char *slot);
158  bool connect(const QString &service, const QString &path, const QString &interface,
159  const QString &name, const QStringList &argumentMatch, const QString& signature,
160  QObject *receiver, const char *slot);
161 
162  bool disconnect(const QString &service, const QString &path, const QString &interface,
163  const QString &name, QObject *receiver, const char *slot);
164  bool disconnect(const QString &service, const QString &path, const QString &interface,
165  const QString &name, const QString& signature,
166  QObject *receiver, const char *slot);
167  bool disconnect(const QString &service, const QString &path, const QString &interface,
168  const QString &name, const QStringList &argumentMatch, const QString& signature,
169  QObject *receiver, const char *slot);
170 
171  bool registerObject(const QString &path, QObject *object,
172  RegisterOptions options = ExportAdaptors);
173  void unregisterObject(const QString &path, UnregisterMode mode = UnregisterNode);
174  QObject *objectRegisteredAt(const QString &path) const;
175 
176  bool registerVirtualObject(const QString &path, QDBusVirtualObject *object,
177  VirtualObjectRegisterOption options = SingleNode);
178 
179  bool registerService(const QString &serviceName);
180  bool unregisterService(const QString &serviceName);
181 
182  QDBusConnectionInterface *interface() const;
183 
184  void *internalPointer() const;
185 
186  static QDBusConnection connectToBus(BusType type, const QString &name);
187  static QDBusConnection connectToBus(const QString &address, const QString &name);
188  static QDBusConnection connectToPeer(const QString &address, const QString &name);
189  static void disconnectFromBus(const QString &name);
190  static void disconnectFromPeer(const QString &name);
191 
192  static QByteArray localMachineId();
193 
194  static QDBusConnection sessionBus();
195  static QDBusConnection systemBus();
196 
197  static QDBusConnection sender();
198 
199 protected:
201 
202 private:
205 };
206 
207 Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusConnection::RegisterOptions)
208 Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusConnection::VirtualObjectRegisterOptions)
209 
211 
213 
214 #endif // QT_NO_DBUS
215 #endif
UnregisterMode
The mode for unregistering an object path:
The QDBusConnectionInterface class provides access to the D-Bus bus daemon service.
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
CallMode
This enum describes the various ways of placing a function call.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QDBusError class represents an error received from the D-Bus bus or from remote applications foun...
Definition: qdbuserror.h:60
The QDBusPendingCall class refers to one pending asynchronous call.
The QDBusInterface class is a proxy for interfaces on remote objects.
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
ConnectionCapability
This enum describes the available capabilities for a D-Bus connection.
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
The QDBus namespace contains miscellaneous identifiers used throughout the QtDBus library...
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
const char * name
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
BusType
Specifies the type of the bus connection.
The QDBusVirtualObject class is used to handle several DBus paths with one class. ...
QDBusConnectionPrivate * d
#define Q_GADGET
Definition: qobjectdefs.h:173
The QDBusConnection class represents a connection to the D-Bus bus daemon.
#define Q_DBUS_EXPORT
Definition: qglobal.h:1463
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59
#define Q_FLAGS(x)
Definition: qobjectdefs.h:85
RegisterOption
Specifies the options for registering objects with the connection.
VirtualObjectRegisterOption
Specifies the options for registering virtual objects with the connection.
#define QT_END_HEADER
Definition: qglobal.h:137