1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 |
|
22 #ifndef XQSERVICEREQUEST_H |
|
23 #define XQSERVICEREQUEST_H |
|
24 |
|
25 #include <xqserviceglobal.h> |
|
26 #include <qdatastream.h> |
|
27 #include <qbuffer.h> |
|
28 #include <QVariant> |
|
29 #include <xqserviceipcmarshal.h> |
|
30 #include <xqaiwinterfacedescriptor.h> |
|
31 #include <xqrequestinfo.h> |
|
32 |
|
33 class XQServiceRequest_Private; |
|
34 |
|
35 class XQSERVICE_EXPORT XQServiceRequest : public QObject |
|
36 { |
|
37 friend bool operator==( const XQServiceRequest &m1, const XQServiceRequest &m2 ); |
|
38 friend class XQServiceRequest_Private; |
|
39 |
|
40 Q_OBJECT |
|
41 |
|
42 public: |
|
43 |
|
44 XQServiceRequest(); |
|
45 XQServiceRequest(const QString& fullServiceName, const QString& message, const bool& synchronous = true); |
|
46 XQServiceRequest(const XQServiceRequest& orig); |
|
47 XQServiceRequest(const XQAiwInterfaceDescriptor &descriptor, const QString& message, const bool& synchronous = true); |
|
48 |
|
49 ~XQServiceRequest(); |
|
50 |
|
51 bool send(); |
|
52 bool send(QVariant& retValue) ; |
|
53 |
|
54 template <typename T> |
|
55 inline bool send(T& retValue) |
|
56 { |
|
57 QVariant retData; |
|
58 bool ret=send(retData); |
|
59 retValue = qVariantValue<T>(retData); |
|
60 return ret; |
|
61 } |
|
62 |
|
63 bool isNull() const; |
|
64 |
|
65 void setSynchronous(const bool &synchronous); |
|
66 bool isSynchronous() const; |
|
67 |
|
68 void setService(const QString &fullServiceName); |
|
69 QString service() const; |
|
70 void setMessage(const QString& message); |
|
71 QString message() const; |
|
72 |
|
73 const QList<QVariant> &arguments() const; |
|
74 void setArguments(const QList<QVariant> &arguments); |
|
75 |
|
76 int latestError(); |
|
77 |
|
78 void setInfo(const XQRequestInfo &info); |
|
79 XQRequestInfo info() const; |
|
80 |
|
81 XQServiceRequest& operator=(const XQServiceRequest& orig); |
|
82 |
|
83 template<typename T> |
|
84 inline XQServiceRequest &operator<< (const T &var) |
|
85 { |
|
86 QVariant v = qVariantFromValue(var); |
|
87 addArg(v); |
|
88 return *this; |
|
89 } |
|
90 |
|
91 inline XQServiceRequest &operator<< (const char *var) |
|
92 { |
|
93 QVariant v = QVariant(QString(var)); |
|
94 addArg(v); |
|
95 return *this; |
|
96 } |
|
97 |
|
98 inline void addVariantArg(const QVariant& var) |
|
99 { |
|
100 addArg(var); |
|
101 } |
|
102 |
|
103 static QByteArray serializeArguments(const XQServiceRequest &action); |
|
104 static void deserializeArguments(XQServiceRequest &action, const QByteArray &data); |
|
105 |
|
106 template <typename Stream> void serialize(Stream &stream) const; |
|
107 template <typename Stream> void deserialize(Stream &stream); |
|
108 |
|
109 signals: |
|
110 void requestCompleted(const QVariant& value) ; |
|
111 void requestError(int err); |
|
112 |
|
113 private: |
|
114 void addArg(const QVariant& v); |
|
115 bool handleSharableFileArgs(); |
|
116 |
|
117 private: |
|
118 XQServiceRequest_Private *mData; |
|
119 }; |
|
120 |
|
121 inline bool operator==( const XQServiceRequest &m1, const XQServiceRequest &m2 ) |
|
122 { |
|
123 return (m1.service() == m2.service()) && (m1.message() == m2.message()) |
|
124 && (m1.arguments() == m2.arguments()); |
|
125 } |
|
126 |
|
127 Q_DECLARE_USER_METATYPE(XQServiceRequest) |
|
128 |
|
129 #endif |
|