1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtDBus module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** 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 are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QDBUSPENDINGREPLY_H
|
---|
43 | #define QDBUSPENDINGREPLY_H
|
---|
44 |
|
---|
45 | #include <QtCore/qglobal.h>
|
---|
46 | #include <QtDBus/qdbusmacros.h>
|
---|
47 | #include <QtDBus/qdbusargument.h>
|
---|
48 | #include <QtDBus/qdbuspendingcall.h>
|
---|
49 |
|
---|
50 | QT_BEGIN_HEADER
|
---|
51 |
|
---|
52 | QT_BEGIN_NAMESPACE
|
---|
53 |
|
---|
54 | QT_MODULE(DBus)
|
---|
55 |
|
---|
56 | class QDBUS_EXPORT QDBusPendingReplyData: public QDBusPendingCall
|
---|
57 | {
|
---|
58 | protected:
|
---|
59 | QDBusPendingReplyData();
|
---|
60 | ~QDBusPendingReplyData();
|
---|
61 | void assign(const QDBusPendingCall &call);
|
---|
62 | void assign(const QDBusMessage &message);
|
---|
63 |
|
---|
64 | QVariant argumentAt(int index) const;
|
---|
65 | void setMetaTypes(int count, const int *metaTypes);
|
---|
66 | };
|
---|
67 |
|
---|
68 | namespace QDBusPendingReplyTypes {
|
---|
69 | template<int Index,
|
---|
70 | typename T1, typename T2, typename T3, typename T4,
|
---|
71 | typename T5, typename T6, typename T7, typename T8>
|
---|
72 | struct Select
|
---|
73 | {
|
---|
74 | typedef Select<Index - 1, T2, T3, T4, T5, T6, T7, T8, void> Next;
|
---|
75 | typedef typename Next::Type Type;
|
---|
76 | };
|
---|
77 | template<typename T1, typename T2, typename T3, typename T4,
|
---|
78 | typename T5, typename T6, typename T7, typename T8>
|
---|
79 | struct Select<0, T1, T2, T3, T4, T5, T6, T7, T8>
|
---|
80 | {
|
---|
81 | typedef T1 Type;
|
---|
82 | };
|
---|
83 |
|
---|
84 | template<typename T1> inline int metaTypeFor(T1 * = 0)
|
---|
85 | { return qMetaTypeId<T1>(); }
|
---|
86 | // specialise for QVariant, allowing it to be used in place of QDBusVariant
|
---|
87 | template<> inline int metaTypeFor<QVariant>(QVariant *)
|
---|
88 | { return qMetaTypeId<QDBusVariant>(); }
|
---|
89 |
|
---|
90 | template<typename T1, typename T2, typename T3, typename T4,
|
---|
91 | typename T5, typename T6, typename T7, typename T8>
|
---|
92 | struct ForEach
|
---|
93 | {
|
---|
94 | typedef ForEach<T2, T3, T4, T5, T6, T7, T8, void> Next;
|
---|
95 | enum { Total = Next::Total + 1 };
|
---|
96 | static inline void fillMetaTypes(int *p)
|
---|
97 | {
|
---|
98 | *p = metaTypeFor<T1>(0);
|
---|
99 | Next::fillMetaTypes(++p);
|
---|
100 | }
|
---|
101 | };
|
---|
102 | template<>
|
---|
103 | struct ForEach<void, void, void, void, void, void, void, void>
|
---|
104 | {
|
---|
105 | enum { Total = 0 };
|
---|
106 | static inline void fillMetaTypes(int *)
|
---|
107 | { }
|
---|
108 | };
|
---|
109 | } // namespace QDBusPendingReplyTypes
|
---|
110 |
|
---|
111 | template<typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
|
---|
112 | typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
|
---|
113 | class QDBusPendingReply:
|
---|
114 | #ifdef Q_QDOC
|
---|
115 | public QDBusPendingCall
|
---|
116 | #else
|
---|
117 | public QDBusPendingReplyData
|
---|
118 | #endif
|
---|
119 | {
|
---|
120 | typedef QDBusPendingReplyTypes::ForEach<T1, T2, T3, T4, T5, T6, T7, T8> ForEach;
|
---|
121 | template<int Index> struct Select :
|
---|
122 | QDBusPendingReplyTypes::Select<Index, T1, T2, T3, T4, T5, T6, T7, T8>
|
---|
123 | {
|
---|
124 | };
|
---|
125 |
|
---|
126 | public:
|
---|
127 | enum { Count = ForEach::Total };
|
---|
128 |
|
---|
129 | inline QDBusPendingReply()
|
---|
130 | { }
|
---|
131 | inline QDBusPendingReply(const QDBusPendingReply &other)
|
---|
132 | : QDBusPendingReplyData(other)
|
---|
133 | { }
|
---|
134 | inline QDBusPendingReply(const QDBusPendingCall &call)
|
---|
135 | { *this = call; }
|
---|
136 | inline QDBusPendingReply(const QDBusMessage &message)
|
---|
137 | { *this = message; }
|
---|
138 | inline QDBusPendingReply &operator=(const QDBusPendingReply &other)
|
---|
139 | { assign(other); return *this; }
|
---|
140 | inline QDBusPendingReply &operator=(const QDBusPendingCall &call)
|
---|
141 | { assign(call); return *this; }
|
---|
142 | inline QDBusPendingReply &operator=(const QDBusMessage &message)
|
---|
143 | { assign(message); return *this; }
|
---|
144 |
|
---|
145 | inline int count() const { return Count; }
|
---|
146 |
|
---|
147 | #if defined(Q_QDOC) || defined(Q_NO_USING_KEYWORD)
|
---|
148 | inline QVariant argumentAt(int index) const
|
---|
149 | { return QDBusPendingReplyData::argumentAt(index); }
|
---|
150 | #else
|
---|
151 | using QDBusPendingReplyData::argumentAt;
|
---|
152 | #endif
|
---|
153 |
|
---|
154 | #if defined(Q_QDOC)
|
---|
155 | bool isFinished() const;
|
---|
156 | void waitForFinished();
|
---|
157 |
|
---|
158 | bool isValid() const;
|
---|
159 | bool isError() const;
|
---|
160 | QDBusError error() const;
|
---|
161 | QDBusMessage reply() const;
|
---|
|
---|