| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2010 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 | QT_BEGIN_NAMESPACE | 
|---|
| 60 |  | 
|---|
| 61 | class QDBusMarshaller; | 
|---|
| 62 | class QDBusDemarshaller; | 
|---|
| 63 | class QDBusArgumentPrivate | 
|---|
| 64 | { | 
|---|
| 65 | public: | 
|---|
| 66 | inline QDBusArgumentPrivate() | 
|---|
| 67 | : message(0), ref(1) | 
|---|
| 68 | { } | 
|---|
| 69 | ~QDBusArgumentPrivate(); | 
|---|
| 70 |  | 
|---|
| 71 | static bool checkRead(QDBusArgumentPrivate *d); | 
|---|
| 72 | static bool checkReadAndDetach(QDBusArgumentPrivate *&d); | 
|---|
| 73 | static bool checkWrite(QDBusArgumentPrivate *&d); | 
|---|
| 74 |  | 
|---|
| 75 | QDBusMarshaller *marshaller(); | 
|---|
| 76 | QDBusDemarshaller *demarshaller(); | 
|---|
| 77 |  | 
|---|
| 78 | static QByteArray createSignature(int id); | 
|---|
| 79 | static inline QDBusArgument create(QDBusArgumentPrivate *d) | 
|---|
| 80 | { | 
|---|
| 81 | QDBusArgument q(d); | 
|---|
| 82 | return q; | 
|---|
| 83 | } | 
|---|
| 84 | static inline QDBusArgumentPrivate *d(QDBusArgument &q) | 
|---|
| 85 | { return q.d; } | 
|---|
| 86 |  | 
|---|
| 87 | public: | 
|---|
| 88 | DBusMessage *message; | 
|---|
| 89 | QAtomicInt ref; | 
|---|
| 90 | enum Direction { | 
|---|
| 91 | Marshalling, | 
|---|
| 92 | Demarshalling | 
|---|
| 93 | } direction; | 
|---|
| 94 | }; | 
|---|
| 95 |  | 
|---|
| 96 | class QDBusMarshaller: public QDBusArgumentPrivate | 
|---|
| 97 | { | 
|---|
| 98 | public: | 
|---|
| 99 | QDBusMarshaller() : parent(0), ba(0), closeCode(0), ok(true) | 
|---|
| 100 | { direction = Marshalling; } | 
|---|
| 101 | ~QDBusMarshaller(); | 
|---|
| 102 |  | 
|---|
| 103 | QString currentSignature(); | 
|---|
| 104 |  | 
|---|
| 105 | void append(uchar arg); | 
|---|
| 106 | void append(bool arg); | 
|---|
| 107 | void append(short arg); | 
|---|
| 108 | void append(ushort arg); | 
|---|
| 109 | void append(int arg); | 
|---|
| 110 | void append(uint arg); | 
|---|
| 111 | void append(qlonglong arg); | 
|---|
| 112 | void append(qulonglong arg); | 
|---|
| 113 | void append(double arg); | 
|---|
| 114 | void append(const QString &arg); | 
|---|
| 115 | void append(const QDBusObjectPath &arg); | 
|---|
| 116 | void append(const QDBusSignature &arg); | 
|---|
| 117 | void append(const QStringList &arg); | 
|---|
| 118 | void append(const QByteArray &arg); | 
|---|
| 119 | bool append(const QDBusVariant &arg); // this one can fail | 
|---|
| 120 |  | 
|---|
| 121 | QDBusMarshaller *beginStructure(); | 
|---|
| 122 | QDBusMarshaller *endStructure(); | 
|---|
| 123 | QDBusMarshaller *beginArray(int id); | 
|---|
| 124 | QDBusMarshaller *endArray(); | 
|---|
| 125 | QDBusMarshaller *beginMap(int kid, int vid); | 
|---|
| 126 | QDBusMarshaller *endMap(); | 
|---|
| 127 | QDBusMarshaller *beginMapEntry(); | 
|---|
| 128 | QDBusMarshaller *endMapEntry(); | 
|---|
| 129 | QDBusMarshaller *beginCommon(int code, const char *signature); | 
|---|
| 130 | QDBusMarshaller *endCommon(); | 
|---|
| 131 | void open(QDBusMarshaller &sub, int code, const char *signature); | 
|---|
| 132 | void close(); | 
|---|
| 133 | void error(const QString &message); | 
|---|
| 134 |  | 
|---|
| 135 | bool appendVariantInternal(const QVariant &arg); | 
|---|
| 136 | bool appendRegisteredType(const QVariant &arg); | 
|---|
| 137 | bool appendCrossMarshalling(QDBusDemarshaller *arg); | 
|---|
| 138 |  | 
|---|
| 139 | public: | 
|---|
| 140 | DBusMessageIter iterator; | 
|---|
| 141 | QDBusMarshaller *parent; | 
|---|
| 142 | QByteArray *ba; | 
|---|
| 143 | QString errorString; | 
|---|
| 144 | char closeCode; | 
|---|
| 145 | bool ok; | 
|---|
| 146 |  | 
|---|
| 147 | private: | 
|---|
| 148 | Q_DISABLE_COPY(QDBusMarshaller) | 
|---|
| 149 | }; | 
|---|
| 150 |  | 
|---|
| 151 | class QDBusDemarshaller: public QDBusArgumentPrivate | 
|---|
| 152 | { | 
|---|
| 153 | public: | 
|---|
| 154 | inline QDBusDemarshaller() : parent(0) { direction = Demarshalling; } | 
|---|
| 155 | ~QDBusDemarshaller(); | 
|---|
| 156 |  | 
|---|
| 157 | QString currentSignature(); | 
|---|
| 158 |  | 
|---|
| 159 | uchar toByte(); | 
|---|
| 160 | bool toBool(); | 
|---|
| 161 | ushort toUShort(); | 
|---|
| 162 | short toShort(); | 
|---|
| 163 | int toInt(); | 
|---|
| 164 | uint toUInt(); | 
|---|
| 165 | qlonglong toLongLong(); | 
|---|
| 166 | qulonglong toULongLong(); | 
|---|
| 167 | double toDouble(); | 
|---|
| 168 | QString toString(); | 
|---|
| 169 | QDBusObjectPath toObjectPath(); | 
|---|
| 170 | QDBusSignature toSignature(); | 
|---|
| 171 | QDBusVariant toVariant(); | 
|---|
| 172 | QStringList toStringList(); | 
|---|
| 173 | QByteArray toByteArray(); | 
|---|
| 174 |  | 
|---|
| 175 | QDBusDemarshaller *beginStructure(); | 
|---|
| 176 | QDBusDemarshaller *endStructure(); | 
|---|
| 177 | QDBusDemarshaller *beginArray(); | 
|---|
| 178 | QDBusDemarshaller *endArray(); | 
|---|
| 179 | QDBusDemarshaller *beginMap(); | 
|---|
| 180 | QDBusDemarshaller *endMap(); | 
|---|
| 181 | QDBusDemarshaller *beginMapEntry(); | 
|---|
| 182 | QDBusDemarshaller *endMapEntry(); | 
|---|
| 183 | QDBusDemarshaller *beginCommon(); | 
|---|
| 184 | QDBusDemarshaller *endCommon(); | 
|---|
| 185 | QDBusArgument duplicate(); | 
|---|
| 186 | inline void close() { } | 
|---|
| 187 |  | 
|---|
| 188 | bool atEnd(); | 
|---|
| 189 |  | 
|---|
| 190 | QVariant toVariantInternal(); | 
|---|
| 191 | QDBusArgument::ElementType currentType(); | 
|---|
| 192 |  | 
|---|
| 193 | public: | 
|---|
| 194 | DBusMessageIter iterator; | 
|---|
| 195 | QDBusDemarshaller *parent; | 
|---|
| 196 |  | 
|---|
| 197 | private: | 
|---|
| 198 | Q_DISABLE_COPY(QDBusDemarshaller) | 
|---|
| 199 | }; | 
|---|
| 200 |  | 
|---|
| 201 | inline QDBusMarshaller *QDBusArgumentPrivate::marshaller() | 
|---|
| 202 | { return static_cast<QDBusMarshaller *>(this); } | 
|---|
| 203 |  | 
|---|
| 204 | inline QDBusDemarshaller *QDBusArgumentPrivate::demarshaller() | 
|---|
| 205 | { return static_cast<QDBusDemarshaller *>(this); } | 
|---|
| 206 |  | 
|---|
| 207 | QT_END_NAMESPACE | 
|---|
| 208 |  | 
|---|
| 209 | #endif | 
|---|