27 #include "xqrequestutil.h" |
27 #include "xqrequestutil.h" |
28 |
28 |
29 namespace QtService |
29 namespace QtService |
30 { |
30 { |
31 /*! |
31 /*! |
32 \class ServiceIPCRequest |
32 \class ServiceIPCRequest |
33 Class to encapsulate a service request |
33 \brief Class to encapsulate a service request |
34 */ |
34 */ |
35 |
35 |
36 /*! |
36 /*! |
37 Constructor |
37 Constructor. |
38 @param aSession session associated with this request |
38 \param aSession Session associated with this request. |
39 @param aDataLength amount of data to be received in this request |
39 \param aDataLength Amount of data to be received in this request. |
40 @param aRequestOp operaion name |
40 \param aRequestOp Operation name. |
41 */ |
41 */ |
42 ServiceIPCRequest::ServiceIPCRequest(ServiceIPCSession* aSession, |
42 ServiceIPCRequest::ServiceIPCRequest(ServiceIPCSession* aSession, |
43 qint64 aDataLength, |
43 qint64 aDataLength, |
44 const QString& aRequestOp) : |
44 const QString& aRequestOp) : |
45 QObject(NULL), |
45 QObject(NULL), |
46 iSession(aSession), |
46 iSession(aSession), |
82 iRequestInfo = aRequest.requestInfo(); |
82 iRequestInfo = aRequest.requestInfo(); |
83 |
83 |
84 } |
84 } |
85 |
85 |
86 /*! |
86 /*! |
87 Destructor |
87 Destructor. |
88 */ |
88 */ |
89 ServiceIPCRequest::~ServiceIPCRequest() |
89 ServiceIPCRequest::~ServiceIPCRequest() |
90 { |
90 { |
91 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::~ServiceIPCRequest"); |
91 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::~ServiceIPCRequest"); |
92 delete iClientInfo; |
92 delete iClientInfo; |
93 } |
93 } |
94 |
94 |
95 /*! |
95 /*! |
96 Assignment operator |
96 Assignment operator. |
97 @param aRequest request to be assigned |
97 \param aRequest Request to be assigned. |
98 @return ServiceIPCRequest assigned request |
98 \return ServiceIPCRequest assigned request. |
99 */ |
99 */ |
100 ServiceIPCRequest& ServiceIPCRequest::operator=(ServiceIPCRequest& aRequest) |
100 ServiceIPCRequest& ServiceIPCRequest::operator=(ServiceIPCRequest& aRequest) |
101 { |
101 { |
102 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::operator="); |
102 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::operator="); |
103 if (this != &aRequest) { |
103 if (this != &aRequest) { |
104 //session |
104 //session |
125 } |
125 } |
126 return *this; |
126 return *this; |
127 } |
127 } |
128 |
128 |
129 /*! |
129 /*! |
130 Get the requested operation |
130 Get the requested operation. |
131 @return QString operation ID |
131 \return QString operation ID. |
132 */ |
132 */ |
133 const QString& ServiceIPCRequest::getOperation() |
133 const QString& ServiceIPCRequest::getOperation() |
134 { |
134 { |
135 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::getOperation"); |
135 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::getOperation"); |
136 XQSERVICE_DEBUG_PRINT("iRequestOp: %s", qPrintable(iRequestOp)); |
136 XQSERVICE_DEBUG_PRINT("iRequestOp: %s", qPrintable(iRequestOp)); |
137 return iRequestOp; |
137 return iRequestOp; |
138 } |
138 } |
139 |
139 |
140 /*! |
140 /*! |
141 Get the requested data |
141 Get the requested data. |
142 @return QByteArray data for this operation |
142 \return QByteArray data for this operation. |
143 */ |
143 */ |
144 const QByteArray& ServiceIPCRequest::getData() |
144 const QByteArray& ServiceIPCRequest::getData() |
145 { |
145 { |
146 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::getData"); |
146 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::getData"); |
147 XQSERVICE_DEBUG_PRINT("iRequestData: %s", iRequestData.constData()); |
147 XQSERVICE_DEBUG_PRINT("iRequestData: %s", iRequestData.constData()); |
148 return iRequestData; |
148 return iRequestData; |
149 } |
149 } |
150 |
150 |
151 /*! |
151 /*! |
152 Write some data to the request |
152 Write some data to the request. |
153 @param aData data to write to the socket |
153 \param aData Data to write to the socket. |
154 */ |
154 */ |
155 bool ServiceIPCRequest::write(const QByteArray& aData) |
155 bool ServiceIPCRequest::write(const QByteArray& aData) |
156 { |
156 { |
157 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::write"); |
157 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::write"); |
158 XQSERVICE_DEBUG_PRINT("aData: %s", aData.constData()); |
158 XQSERVICE_DEBUG_PRINT("aData: %s", aData.constData()); |
159 // Do we want to buffer the writes? |
159 // Do we want to buffer the writes? |
160 return iSession->write(aData); |
160 return iSession->write(aData); |
161 } |
161 } |
162 |
162 |
163 /*! |
163 /*! |
164 Complete the request |
164 Complete the request. |
165 @return true if request completed successfully |
165 \return true if request completed successfully. |
166 */ |
166 */ |
167 bool ServiceIPCRequest::completeRequest() |
167 bool ServiceIPCRequest::completeRequest() |
168 { |
168 { |
169 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::completeRequest"); |
169 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::completeRequest"); |
170 return iSession->completeRequest(); |
170 return iSession->completeRequest(); |
171 } |
171 } |
172 |
172 |
173 /*! |
173 /*! |
174 Append more data when creating the request |
174 Append more data when creating the request. |
175 @arg aMoreData data to be appended to the request |
175 \param aMoreData Data to be appended to the request. |
176 @return true if iDataLength now equals the full length |
176 \return true if iDataLength now equals the full length. |
177 */ |
177 */ |
178 bool ServiceIPCRequest::addRequestdata(const QByteArray& aMoreData) |
178 bool ServiceIPCRequest::addRequestdata(const QByteArray& aMoreData) |
179 { |
179 { |
180 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::addRequestdata"); |
180 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::addRequestdata"); |
181 XQSERVICE_DEBUG_PRINT("aMoreData: %s", aMoreData.constData()); |
181 XQSERVICE_DEBUG_PRINT("aMoreData: %s", aMoreData.constData()); |
182 iRequestData.append(aMoreData); |
182 iRequestData.append(aMoreData); |
183 return (iRequestData.length() == iDatalength); |
183 return (iRequestData.length() == iDatalength); |
184 } |
184 } |
185 |
185 |
186 /*! |
186 /*! |
187 Sets the client info. Onwership of the object is passed in. |
187 Sets the client info. Onwership of the object is passed in. |
188 @arg aClientInfo Client information |
188 \param aClientInfo Client information. |
189 */ |
189 */ |
190 void ServiceIPCRequest::setClientInfo(ClientInfo *aClientInfo) |
190 void ServiceIPCRequest::setClientInfo(ClientInfo *aClientInfo) |
191 { |
191 { |
192 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::setClientInfo"); |
192 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::setClientInfo"); |
193 delete iClientInfo; |
193 delete iClientInfo; |
194 iClientInfo = aClientInfo; |
194 iClientInfo = aClientInfo; |
199 iRequestInfo.setInfo(XQServiceUtils::InfoCap, iClientInfo->capabilities()); |
199 iRequestInfo.setInfo(XQServiceUtils::InfoCap, iClientInfo->capabilities()); |
200 |
200 |
201 } |
201 } |
202 |
202 |
203 /*! |
203 /*! |
204 Gets the client info. |
204 Gets the client info. |
205 @return Client Information object. NULL if none is available |
205 \return Client Information object, NULL if none is available. |
206 */ |
206 */ |
207 ClientInfo* ServiceIPCRequest::clientInfo() |
207 ClientInfo* ServiceIPCRequest::clientInfo() |
208 { |
208 { |
209 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::clientInfo"); |
209 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::clientInfo"); |
210 return iClientInfo; |
210 return iClientInfo; |
211 } |
211 } |
212 |
212 |
213 /*! |
213 /*! |
214 Gets the session. |
214 Gets the session. |
215 @return ServiceIPCSession. NULL if none is available |
215 \return ServiceIPCSession, NULL if none is available. |
216 */ |
216 */ |
217 ServiceIPCSession* ServiceIPCRequest::getSession() |
217 ServiceIPCSession* ServiceIPCRequest::getSession() |
218 { |
218 { |
219 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::getSession"); |
219 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::getSession"); |
220 return iSession; |
220 return iSession; |
221 } |
221 } |
222 |
222 |
223 /*! |
223 /*! |
224 Sets id of the request. |
224 Sets id of the request. |
225 @arg id Identifier of the request. |
225 \param aId Identifier of the request. |
226 */ |
226 */ |
227 void ServiceIPCRequest::setId(int aId) |
227 void ServiceIPCRequest::setId(int aId) |
228 { |
228 { |
229 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::setId"); |
229 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::setId"); |
230 XQSERVICE_DEBUG_PRINT("\t aId = %d", aId); |
230 XQSERVICE_DEBUG_PRINT("\t aId = %d", aId); |
231 iId = aId; |
231 iId = aId; |
232 } |
232 } |
233 |
233 |
234 /*! |
234 /*! |
235 Returns id of the request. |
235 Returns id of the request. |
236 @return Id of the request. |
236 \return Id of the request. |
237 */ |
237 */ |
238 int ServiceIPCRequest::id() const |
238 int ServiceIPCRequest::id() const |
239 { |
239 { |
240 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::id"); |
240 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::id"); |
241 XQSERVICE_DEBUG_PRINT("\t iId = %d", iId); |
241 XQSERVICE_DEBUG_PRINT("\t iId = %d", iId); |
242 return iId; |
242 return iId; |
243 } |
243 } |
244 |
244 |
245 /*! |
245 /*! |
246 Sets asynchcronous flag to true or false. |
246 Sets asynchcronous flag to true or false. |
247 @arg A value of the async flag. |
247 \param aAsync Value of the async flag. |
248 */ |
248 */ |
249 void ServiceIPCRequest::setAsync(bool aAsync) |
249 void ServiceIPCRequest::setAsync(bool aAsync) |
250 { |
250 { |
251 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::setAsync"); |
251 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::setAsync"); |
252 XQSERVICE_DEBUG_PRINT("\t iAsync = %d", aAsync); |
252 XQSERVICE_DEBUG_PRINT("\t iAsync = %d", aAsync); |
253 iAsync = aAsync; |
253 iAsync = aAsync; |
254 } |
254 } |
255 |
255 |
256 /*! |
256 /*! |
257 Returns asynch flag. |
257 Returns async flag. |
258 @return True if the request is asynchronous. False, if synchronous |
258 \return True if the request is asynchronous. False, if synchronous. |
259 */ |
259 */ |
260 bool ServiceIPCRequest::isAsync() const |
260 bool ServiceIPCRequest::isAsync() const |
261 { |
261 { |
262 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::getAsync"); |
262 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::getAsync"); |
263 XQSERVICE_DEBUG_PRINT("\t iAsync = %d", iAsync); |
263 XQSERVICE_DEBUG_PRINT("\t iAsync = %d", iAsync); |
264 return iAsync; |
264 return iAsync; |
265 } |
265 } |
266 |
266 |
267 |
267 /*! |
268 // Set request info passed alomg with the request |
268 Set request info passed along with the request. |
|
269 \param info Info to be passed with the request. |
|
270 */ |
269 void ServiceIPCRequest::setRequestInfo(XQRequestInfo *info) |
271 void ServiceIPCRequest::setRequestInfo(XQRequestInfo *info) |
270 { |
272 { |
271 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::setRequestInfo"); |
273 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::setRequestInfo"); |
272 if (info) |
274 if (info) |
273 { |
275 { |
283 iRequestInfo.setInfo(XQServiceUtils::InfoId, id()); |
285 iRequestInfo.setInfo(XQServiceUtils::InfoId, id()); |
284 } |
286 } |
285 } |
287 } |
286 } |
288 } |
287 |
289 |
|
290 /*! |
|
291 Get info added to the request. |
|
292 \return Info to be passed with the request. |
|
293 */ |
288 XQRequestInfo ServiceIPCRequest::requestInfo() const |
294 XQRequestInfo ServiceIPCRequest::requestInfo() const |
289 { |
295 { |
290 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::requestInfo"); |
296 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::requestInfo"); |
291 return iRequestInfo; |
297 return iRequestInfo; |
292 } |
298 } |
293 |
299 |
|
300 /*! |
|
301 Add sharable file to be passed with the request. |
|
302 \param file Sharable file to be added to the request. |
|
303 \param index Currently not used. |
|
304 */ |
294 void ServiceIPCRequest::addSharableFile(XQSharableFile *file, int index) |
305 void ServiceIPCRequest::addSharableFile(XQSharableFile *file, int index) |
295 { |
306 { |
296 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::setSharableFile"); |
307 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::setSharableFile"); |
297 if (file != NULL) |
308 if (file != NULL) |
298 iSharableFiles.append(*file); |
309 iSharableFiles.append(*file); |
299 } |
310 } |
300 |
311 |
|
312 /*! |
|
313 Get sharable file from request. |
|
314 \param index Index of the sharable file to get. |
|
315 */ |
301 XQSharableFile ServiceIPCRequest::sharableFile(int index) const |
316 XQSharableFile ServiceIPCRequest::sharableFile(int index) const |
302 { |
317 { |
303 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::setSharableFile"); |
318 XQSERVICE_DEBUG_PRINT("ServiceIPCRequest::setSharableFile"); |
304 if (index >= 0 && index < iSharableFiles.size()) |
319 if (index >= 0 && index < iSharableFiles.size()) |
305 { |
320 { |