[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the QtDBus module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 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 | **
|
---|
[561] | 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.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at qt-info@nokia.com.
|
---|
[2] | 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 |
|
---|
[846] | 48 | #ifndef QT_NO_DBUS
|
---|
| 49 |
|
---|
[2] | 50 | QT_BEGIN_HEADER
|
---|
| 51 |
|
---|
| 52 | QT_BEGIN_NAMESPACE
|
---|
| 53 |
|
---|
| 54 | QT_MODULE(DBus)
|
---|
| 55 |
|
---|
| 56 | namespace QDBus
|
---|
| 57 | {
|
---|
| 58 | enum CallMode {
|
---|
| 59 | NoBlock,
|
---|
| 60 | Block,
|
---|
| 61 | BlockWithGui,
|
---|
| 62 | AutoDetect
|
---|
| 63 | };
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | class QDBusAbstractInterfacePrivate;
|
---|
| 67 | class QDBusInterface;
|
---|
| 68 | class QDBusError;
|
---|
| 69 | class QDBusMessage;
|
---|
| 70 | class QDBusPendingCall;
|
---|
| 71 | class QDBusConnectionInterface;
|
---|
| 72 | class QObject;
|
---|
| 73 |
|
---|
| 74 | class QDBusConnectionPrivate;
|
---|
[846] | 75 | class Q_DBUS_EXPORT QDBusConnection
|
---|
[2] | 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,
|
---|
[846] | 88 | ExportScriptableInvokables = 0x80,
|
---|
[2] | 89 | ExportScriptableContents = 0xf0,
|
---|
| 90 |
|
---|
| 91 | ExportNonScriptableSlots = 0x100,
|
---|
| 92 | ExportNonScriptableSignals = 0x200,
|
---|
| 93 | ExportNonScriptableProperties = 0x400,
|
---|
[846] | 94 | ExportNonScriptableInvokables = 0x800,
|
---|
[2] | 95 | ExportNonScriptableContents = 0xf00,
|
---|
| 96 |
|
---|
| 97 | ExportAllSlots = ExportScriptableSlots|ExportNonScriptableSlots,
|
---|
| 98 | ExportAllSignals = ExportScriptableSignals|ExportNonScriptableSignals,
|
---|
| 99 | ExportAllProperties = ExportScriptableProperties|ExportNonScriptableProperties,
|
---|
[846] | 100 | ExportAllInvokables = ExportScriptableInvokables|ExportNonScriptableInvokables,
|
---|
[2] | 101 | ExportAllContents = ExportScriptableContents|ExportNonScriptableContents,
|
---|
| 102 |
|
---|
| 103 | #ifndef Q_QDOC
|
---|
| 104 | // Qt 4.2 had a misspelling here
|
---|
| 105 | ExportAllSignal = ExportAllSignals,
|
---|
| 106 | #endif
|
---|
| 107 |
|
---|
| 108 | ExportChildObjects = 0x1000
|
---|
| 109 | };
|
---|
| 110 | enum UnregisterMode {
|
---|
| 111 | UnregisterNode,
|
---|
| 112 | UnregisterTree
|
---|
| 113 | };
|
---|
| 114 |
|
---|
| 115 | Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)
|
---|
| 116 |
|
---|
| 117 | QDBusConnection(const QString &name);
|
---|
| 118 | QDBusConnection(const QDBusConnection &other);
|
---|
| 119 | ~QDBusConnection();
|
---|
| 120 |
|
---|
| 121 | QDBusConnection &operator=(const QDBusConnection &other);
|
---|
| 122 |
|
---|
| 123 | bool isConnected() const;
|
---|
| 124 | QString baseService() const;
|
---|
| 125 | QDBusError lastError() const;
|
---|
| 126 | QString name() const;
|
---|
| 127 |
|
---|
| 128 | bool send(const QDBusMessage &message) const;
|
---|
| 129 | bool callWithCallback(const QDBusMessage &message, QObject *receiver,
|
---|
| 130 | const char *returnMethod, const char *errorMethod,
|
---|
| 131 | int timeout = -1) const;
|
---|
| 132 | bool callWithCallback(const QDBusMessage &message, QObject *receiver,
|
---|
| 133 | const char *slot, int timeout = -1) const;
|
---|
| 134 | QDBusMessage call(const QDBusMessage &message, QDBus::CallMode mode = QDBus::Block,
|
---|
| 135 | int timeout = -1) const;
|
---|
| 136 | QDBusPendingCall asyncCall(const QDBusMessage &message, int timeout = -1) const;
|
---|
| 137 |
|
---|
| 138 | bool connect(const QString &service, const QString &path, const QString &interface,
|
---|
| 139 | const QString &name, QObject *receiver, const char *slot);
|
---|
| 140 | bool connect(const QString &service, const QString &path, const QString &interface,
|
---|
| 141 | const QString &name, const QString& signature,
|
---|
| 142 | QObject *receiver, const char *slot);
|
---|
[561] | 143 | bool connect(const QString &service, const QString &path, const QString &interface,
|
---|
| 144 | const QString &name, const QStringList &argumentMatch, const QString& signature,
|
---|
| 145 | QObject *receiver, const char *slot);
|
---|
| 146 |
|
---|
[2] | 147 | bool disconnect(const QString &service, const QString &path, const QString &interface,
|
---|
[561] | 148 | const QString &name, QObject *receiver, const char *slot);
|
---|
| 149 | bool disconnect(const QString &service, const QString &path, const QString &interface,
|
---|
[2] | 150 | const QString &name, const QString& signature,
|
---|
| 151 | QObject *receiver, const char *slot);
|
---|
[561] | 152 | bool disconnect(const QString &service, const QString &path, const QString &interface,
|
---|
| 153 | const QString &name, const QStringList &argumentMatch, const QString& signature,
|
---|
| 154 | QObject *receiver, const char *slot);
|
---|
[2] | 155 |
|
---|
| 156 | bool registerObject(const QString &path, QObject *object,
|
---|
| 157 | RegisterOptions options = ExportAdaptors);
|
---|
| 158 | void unregisterObject(const QString &path, UnregisterMode mode = UnregisterNode);
|
---|
| 159 | QObject *objectRegisteredAt(const QString &path) const;
|
---|
| 160 |
|
---|
| 161 | bool registerService(const QString &serviceName);
|
---|
| 162 | bool unregisterService(const QString &serviceName);
|
---|
| 163 |
|
---|
| 164 | QDBusConnectionInterface *interface() const;
|
---|
| 165 |
|
---|
| 166 | static QDBusConnection connectToBus(BusType type, const QString &name);
|
---|
| 167 | static QDBusConnection connectToBus(const QString &address, const QString &name);
|
---|
| 168 | static void disconnectFromBus(const QString &name);
|
---|
| 169 |
|
---|
| 170 | static QDBusConnection sessionBus();
|
---|
| 171 | static QDBusConnection systemBus();
|
---|
| 172 |
|
---|
| 173 | static QDBusConnection sender();
|
---|
| 174 |
|
---|
| 175 | protected:
|
---|
| 176 | explicit QDBusConnection(QDBusConnectionPrivate *dd);
|
---|
| 177 |
|
---|
| 178 | private:
|
---|
| 179 | friend class QDBusConnectionPrivate;
|
---|
| 180 | QDBusConnectionPrivate *d;
|
---|
| 181 | };
|
---|
| 182 |
|
---|
| 183 | Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusConnection::RegisterOptions)
|
---|
| 184 |
|
---|
| 185 | QT_END_NAMESPACE
|
---|
| 186 |
|
---|
| 187 | QT_END_HEADER
|
---|
| 188 |
|
---|
[846] | 189 | #endif // QT_NO_DBUS
|
---|
[2] | 190 | #endif
|
---|