| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** All rights reserved. | 
|---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com) | 
|---|
| 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 | ** | 
|---|
| 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 | ** 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 | ** | 
|---|
| 36 | ** If you have questions regarding the use of this file, please contact | 
|---|
| 37 | ** Nokia at qt-info@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | #ifndef QDBUSARGUMENT_P_H | 
|---|
| 43 | #define QDBUSARGUMENT_P_H | 
|---|
| 44 |  | 
|---|
| 45 | // | 
|---|
| 46 | //  W A R N I N G | 
|---|
| 47 | //  ------------- | 
|---|
| 48 | // | 
|---|
| 49 | // This file is not part of the Qt API.  It exists for the convenience | 
|---|
| 50 | // of the QLibrary class.  This header file may change from | 
|---|
| 51 | // version to version without notice, or even be removed. | 
|---|
| 52 | // | 
|---|
| 53 | // We mean it. | 
|---|
| 54 | // | 
|---|
| 55 |  | 
|---|
| 56 | #include <qdbusargument.h> | 
|---|
| 57 | #include "qdbus_symbols_p.h" | 
|---|
| 58 |  | 
|---|
| 59 | #ifndef QT_NO_DBUS | 
|---|
| 60 |  | 
|---|
| 61 | QT_BEGIN_NAMESPACE | 
|---|
| 62 |  | 
|---|
| 63 | class QDBusMarshaller; | 
|---|
| 64 | class QDBusDemarshaller; | 
|---|
| 65 | class QDBusArgumentPrivate | 
|---|
| 66 | { | 
|---|
| 67 | public: | 
|---|
| 68 | inline QDBusArgumentPrivate() | 
|---|
| 69 | : message(0), ref(1) | 
|---|
| 70 | { } | 
|---|
| 71 | ~QDBusArgumentPrivate(); | 
|---|
| 72 |  | 
|---|
| 73 | static bool checkRead(QDBusArgumentPrivate *d); | 
|---|
| 74 | static bool checkReadAndDetach(QDBusArgumentPrivate *&d); | 
|---|
| 75 | static bool checkWrite(QDBusArgumentPrivate *&d); | 
|---|
| 76 |  | 
|---|
| 77 | QDBusMarshaller *marshaller(); | 
|---|
| 78 | QDBusDemarshaller *demarshaller(); | 
|---|
| 79 |  | 
|---|
| 80 | static QByteArray createSignature(int id); | 
|---|
| 81 | static inline QDBusArgument create(QDBusArgumentPrivate *d) | 
|---|
| 82 | { | 
|---|
| 83 | QDBusArgument q(d); | 
|---|
| 84 | return q; | 
|---|
| 85 | } | 
|---|
| 86 | static inline QDBusArgumentPrivate *d(QDBusArgument &q) | 
|---|
| 87 | { return q.d; } | 
|---|
| 88 |  | 
|---|
| 89 | public: | 
|---|
| 90 | DBusMessage *message; | 
|---|
| 91 | QAtomicInt ref; | 
|---|
| 92 | enum Direction { | 
|---|
| 93 | Marshalling, | 
|---|
| 94 | Demarshalling | 
|---|
| 95 | } direction; | 
|---|
| 96 | }; | 
|---|
| 97 |  | 
|---|
| 98 | class QDBusMarshaller: public QDBusArgumentPrivate | 
|---|
| 99 | { | 
|---|
| 100 | public: | 
|---|
| 101 | QDBusMarshaller() : parent(0), ba(0), closeCode(0), ok(true) | 
|---|
| 102 | { direction = Marshalling; } | 
|---|
| 103 | ~QDBusMarshaller(); | 
|---|
| 104 |  | 
|---|
| 105 | QString currentSignature(); | 
|---|
| 106 |  | 
|---|
| 107 | void append(uchar arg); | 
|---|
| 108 | void append(bool arg); | 
|---|
| 109 | void append(short arg); | 
|---|
| 110 | void append(ushort arg); | 
|---|
| 111 | void append(int arg); | 
|---|
| 112 | void append(uint arg); | 
|---|
| 113 | void append(qlonglong arg); | 
|---|
| 114 | void append(qulonglong arg); | 
|---|
| 115 | void append(double arg); | 
|---|
| 116 | void append(const QString &arg); | 
|---|
| 117 | void append(const QDBusObjectPath &arg); | 
|---|
| 118 | void append(const QDBusSignature &arg); | 
|---|
| 119 | void append(const QStringList &arg); | 
|---|
| 120 | void append(const QByteArray &arg); | 
|---|
| 121 | bool append(const QDBusVariant &arg); // this one can fail | 
|---|
| 122 |  | 
|---|
| 123 | QDBusMarshaller *beginStructure(); | 
|---|
| 124 | QDBusMarshaller *endStructure(); | 
|---|
| 125 | QDBusMarshaller *beginArray(int id); | 
|---|
| 126 | QDBusMarshaller *endArray(); | 
|---|
| 127 | QDBusMarshaller *beginMap(int kid, int vid); | 
|---|
| 128 | QDBusMarshaller *endMap(); | 
|---|
| 129 | QDBusMarshaller *beginMapEntry(); | 
|---|
| 130 | QDBusMarshaller *endMapEntry(); | 
|---|
| 131 | QDBusMarshaller *beginCommon(int code, const char *signature); | 
|---|
| 132 | QDBusMarshaller *endCommon(); | 
|---|
| 133 | void open(QDBusMarshaller &sub, int code, const char *signature); | 
|---|
| 134 | void close(); | 
|---|
| 135 | void error(const QString &message); | 
|---|
| 136 |  | 
|---|
| 137 | bool appendVariantInternal(const QVariant &arg); | 
|---|
| 138 | bool appendRegisteredType(const QVariant &arg); | 
|---|
| 139 | bool appendCrossMarshalling(QDBusDemarshaller *arg); | 
|---|
| 140 |  | 
|---|
| 141 | public: | 
|---|
| 142 | DBusMessageIter iterator; | 
|---|
| 143 | QDBusMarshaller *parent; | 
|---|
| 144 | QByteArray *ba; | 
|---|
| 145 | QString errorString; | 
|---|
| 146 | char closeCode; | 
|---|
| 147 | bool ok; | 
|---|
| 148 |  | 
|---|
| 149 | private: | 
|---|
| 150 | Q_DISABLE_COPY(QDBusMarshaller) | 
|---|
| 151 | }; | 
|---|
| 152 |  | 
|---|
| 153 | class QDBusDemarshaller: public QDBusArgumentPrivate | 
|---|
| 154 | { | 
|---|
| 155 | public: | 
|---|
| 156 | inline QDBusDemarshaller() : parent(0) { direction = Demarshalling; } | 
|---|
| 157 | ~QDBusDemarshaller(); | 
|---|
| 158 |  | 
|---|
| 159 | QString currentSignature(); | 
|---|
| 160 |  | 
|---|
| 161 | uchar toByte(); | 
|---|
| 162 | bool toBool(); | 
|---|
| 163 | ushort toUShort(); | 
|---|
| 164 | short toShort(); | 
|---|
| 165 | int toInt(); | 
|---|
| 166 | uint toUInt(); | 
|---|
| 167 | qlonglong toLongLong(); | 
|---|
| 168 | qulonglong toULongLong(); | 
|---|
| 169 | double toDouble(); | 
|---|
| 170 | QString toString(); | 
|---|
| 171 | QDBusObjectPath toObjectPath(); | 
|---|
| 172 | QDBusSignature toSignature(); | 
|---|
| 173 | QDBusVariant toVariant(); | 
|---|
| 174 | QStringList toStringList(); | 
|---|
| 175 | QByteArray toByteArray(); | 
|---|
| 176 |  | 
|---|
| 177 | QDBusDemarshaller *beginStructure(); | 
|---|
| 178 | QDBusDemarshaller *endStructure(); | 
|---|
| 179 | QDBusDemarshaller *beginArray(); | 
|---|
| 180 | QDBusDemarshaller *endArray(); | 
|---|
| 181 | QDBusDemarshaller *beginMap(); | 
|---|
| 182 | QDBusDemarshaller *endMap(); | 
|---|
| 183 | QDBusDemarshaller *beginMapEntry(); | 
|---|
| 184 | QDBusDemarshaller *endMapEntry(); | 
|---|
| 185 | QDBusDemarshaller *beginCommon(); | 
|---|
| 186 | QDBusDemarshaller *endCommon(); | 
|---|
| 187 | QDBusArgument duplicate(); | 
|---|
| 188 | inline void close() { } | 
|---|
| 189 |  | 
|---|
| 190 | bool atEnd(); | 
|---|
| 191 |  | 
|---|
| 192 | QVariant toVariantInternal(); | 
|---|
| 193 | QDBusArgument::ElementType currentType(); | 
|---|
| 194 |  | 
|---|
| 195 | public: | 
|---|
| 196 | DBusMessageIter iterator; | 
|---|
| 197 | QDBusDemarshaller *parent; | 
|---|
| 198 |  | 
|---|
| 199 | private: | 
|---|
| 200 | Q_DISABLE_COPY(QDBusDemarshaller) | 
|---|
| 201 | }; | 
|---|
| 202 |  | 
|---|
| 203 | inline QDBusMarshaller *QDBusArgumentPrivate::marshaller() | 
|---|
| 204 | { return static_cast<QDBusMarshaller *>(this); } | 
|---|
| 205 |  | 
|---|
| 206 | inline QDBusDemarshaller *QDBusArgumentPrivate::demarshaller() | 
|---|
| 207 | { return static_cast<QDBusDemarshaller *>(this); } | 
|---|
| 208 |  | 
|---|
| 209 | QT_END_NAMESPACE | 
|---|
| 210 |  | 
|---|
| 211 | #endif // QT_NO_DBUS | 
|---|
| 212 | #endif | 
|---|