QDBusPendingCallPrivate: save 8 bytes on 64-bit archs
[profile/ivi/qtbase.git] / src / dbus / qdbusconnection.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtDBus module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
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
50 QT_BEGIN_HEADER
51
52 QT_BEGIN_NAMESPACE
53
54
55 namespace QDBus
56 {
57     enum CallMode {
58         NoBlock,
59         Block,
60         BlockWithGui,
61         AutoDetect
62     };
63 }
64
65 class QDBusAbstractInterfacePrivate;
66 class QDBusInterface;
67 class QDBusError;
68 class QDBusMessage;
69 class QDBusPendingCall;
70 class QDBusConnectionInterface;
71 class QDBusVirtualObject;
72 class QObject;
73
74 class QDBusConnectionPrivate;
75 class Q_DBUS_EXPORT QDBusConnection
76 {
77     Q_GADGET
78     Q_ENUMS(BusType UnregisterMode)
79     Q_FLAGS(RegisterOptions)
80 public:
81     enum BusType { SessionBus, SystemBus, ActivationBus };
82     enum RegisterOption {
83         ExportAdaptors = 0x01,
84
85         ExportScriptableSlots = 0x10,
86         ExportScriptableSignals = 0x20,
87         ExportScriptableProperties = 0x40,
88         ExportScriptableInvokables = 0x80,
89         ExportScriptableContents = 0xf0,
90
91         ExportNonScriptableSlots = 0x100,
92         ExportNonScriptableSignals = 0x200,
93         ExportNonScriptableProperties = 0x400,
94         ExportNonScriptableInvokables = 0x800,
95         ExportNonScriptableContents = 0xf00,
96
97         ExportAllSlots = ExportScriptableSlots|ExportNonScriptableSlots,
98         ExportAllSignals = ExportScriptableSignals|ExportNonScriptableSignals,
99         ExportAllProperties = ExportScriptableProperties|ExportNonScriptableProperties,
100         ExportAllInvokables = ExportScriptableInvokables|ExportNonScriptableInvokables,
101         ExportAllContents = ExportScriptableContents|ExportNonScriptableContents,
102
103 #ifndef Q_QDOC
104         // Qt 4.2 had a misspelling here
105         ExportAllSignal = ExportAllSignals,
106 #endif
107         ExportChildObjects = 0x1000
108         // Reserved = 0xff000000
109     };
110     enum UnregisterMode {
111         UnregisterNode,
112         UnregisterTree
113     };
114     Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)
115
116     enum VirtualObjectRegisterOption {
117         SingleNode = 0x0,
118         SubPath = 0x1
119         // Reserved = 0xff000000
120     };
121 #ifndef Q_QDOC
122     Q_DECLARE_FLAGS(VirtualObjectRegisterOptions, VirtualObjectRegisterOption)
123 #endif
124
125     enum ConnectionCapability {
126         UnixFileDescriptorPassing = 0x0001
127     };
128     Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)
129
130     explicit QDBusConnection(const QString &name);
131     QDBusConnection(const QDBusConnection &other);
132     ~QDBusConnection();
133
134     QDBusConnection &operator=(const QDBusConnection &other);
135
136     bool isConnected() const;
137     QString baseService() const;
138     QDBusError lastError() const;
139     QString name() const;
140     ConnectionCapabilities connectionCapabilities() const;
141
142     bool send(const QDBusMessage &message) const;
143     bool callWithCallback(const QDBusMessage &message, QObject *receiver,
144                           const char *returnMethod, const char *errorMethod,
145                           int timeout = -1) const;
146     bool callWithCallback(const QDBusMessage &message, QObject *receiver,
147                           const char *slot, int timeout = -1) const;
148     QDBusMessage call(const QDBusMessage &message, QDBus::CallMode mode = QDBus::Block,
149                       int timeout = -1) const;
150     QDBusPendingCall asyncCall(const QDBusMessage &message, int timeout = -1) const;
151
152     bool connect(const QString &service, const QString &path, const QString &interface,
153                  const QString &name, QObject *receiver, const char *slot);
154     bool connect(const QString &service, const QString &path, const QString &interface,
155                  const QString &name, const QString& signature,
156                  QObject *receiver, const char *slot);
157     bool connect(const QString &service, const QString &path, const QString &interface,
158                  const QString &name, const QStringList &argumentMatch, const QString& signature,
159                  QObject *receiver, const char *slot);
160
161     bool disconnect(const QString &service, const QString &path, const QString &interface,
162                     const QString &name, QObject *receiver, const char *slot);
163     bool disconnect(const QString &service, const QString &path, const QString &interface,
164                     const QString &name, const QString& signature,
165                     QObject *receiver, const char *slot);
166     bool disconnect(const QString &service, const QString &path, const QString &interface,
167                     const QString &name, const QStringList &argumentMatch, const QString& signature,
168                     QObject *receiver, const char *slot);
169
170     bool registerObject(const QString &path, QObject *object,
171                         RegisterOptions options = ExportAdaptors);
172     void unregisterObject(const QString &path, UnregisterMode mode = UnregisterNode);
173     QObject *objectRegisteredAt(const QString &path) const;
174
175     bool registerVirtualObject(const QString &path, QDBusVirtualObject *object,
176                           VirtualObjectRegisterOption options = SingleNode);
177
178     bool registerService(const QString &serviceName);
179     bool unregisterService(const QString &serviceName);
180
181     QDBusConnectionInterface *interface() const;
182
183     void *internalPointer() const;
184
185     static QDBusConnection connectToBus(BusType type, const QString &name);
186     static QDBusConnection connectToBus(const QString &address, const QString &name);
187     static QDBusConnection connectToPeer(const QString &address, const QString &name);
188     static void disconnectFromBus(const QString &name);
189     static void disconnectFromPeer(const QString &name);
190
191     static QByteArray localMachineId();
192
193     static QDBusConnection sessionBus();
194     static QDBusConnection systemBus();
195
196     static QDBusConnection sender();
197
198 protected:
199     explicit QDBusConnection(QDBusConnectionPrivate *dd);
200
201 private:
202     friend class QDBusConnectionPrivate;
203     QDBusConnectionPrivate *d;
204 };
205
206 Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusConnection::RegisterOptions)
207 Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusConnection::VirtualObjectRegisterOptions)
208
209 QT_END_NAMESPACE
210
211 QT_END_HEADER
212
213 #endif // QT_NO_DBUS
214 #endif