|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implements CNcdOperationManagerProxy class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdoperationmanagerproxy.h" |
|
20 |
|
21 #include <e32err.h> |
|
22 |
|
23 #include "ncdbaseoperationproxy.h" |
|
24 #include "ncdloadnodeoperationproxy.h" |
|
25 #include "ncddownloadoperationproxy.h" |
|
26 #include "ncdnodeproxy.h" |
|
27 #include "ncdnodeidentifier.h" |
|
28 #include "ncdloadnodeoperation.h" |
|
29 #include "catalogsclientserver.h" |
|
30 #include "ncdnodefunctionids.h" |
|
31 #include "ncdfiledownloadoperationproxy.h" |
|
32 #include "ncdpurchaseoperationproxy.h" |
|
33 #include "catalogsconstants.h" |
|
34 #include "catalogsutils.h" |
|
35 #include "ncdpurchaseoptionproxy.h" |
|
36 #include "ncdinstalloperationproxy.h" |
|
37 #include "ncdsilentinstalloperationproxy.h" |
|
38 #include "ncdrightsobjectoperationproxy.h" |
|
39 #include "ncdsubscriptionoperationproxy.h" |
|
40 #include "ncdnodemanagerproxy.h" |
|
41 #include "ncddeviceinteractionfactory.h" |
|
42 #include "ncdinstallationservice.h" |
|
43 #include "ncdnodemetadataproxy.h" |
|
44 #include "ncdcreateaccesspointoperationproxy.h" |
|
45 #include "ncdsendhttprequestoperationproxy.h" |
|
46 #include "ncdconnectionmethod.h" |
|
47 #include "ncdserverreportoperationproxy.h" |
|
48 #include "ncdproviderdefines.h" |
|
49 |
|
50 #include "catalogsdebug.h" |
|
51 |
|
52 CNcdOperationManagerProxy* CNcdOperationManagerProxy::NewL( MCatalogsClientServer& aSession, |
|
53 TInt aHandle ) |
|
54 { |
|
55 CNcdOperationManagerProxy* self = CNcdOperationManagerProxy::NewLC( aSession, aHandle ); |
|
56 CleanupStack::Pop( self ); |
|
57 return self; |
|
58 } |
|
59 |
|
60 CNcdOperationManagerProxy* CNcdOperationManagerProxy::NewLC( MCatalogsClientServer& aSession, |
|
61 TInt aHandle ) |
|
62 { |
|
63 CNcdOperationManagerProxy* self = |
|
64 new( ELeave ) CNcdOperationManagerProxy( aSession, aHandle ); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 return self; |
|
68 } |
|
69 |
|
70 |
|
71 CNcdOperationManagerProxy::~CNcdOperationManagerProxy() |
|
72 { |
|
73 DLTRACEIN(("")); |
|
74 iRemovingAllOperations = ETrue; |
|
75 |
|
76 DLTRACE(("All operations should have been released by now")); |
|
77 DASSERT( iOperationCache.Count() == 0 ); |
|
78 iOperationCache.Close(); |
|
79 delete iInstallationService; |
|
80 DLTRACEOUT(("")); |
|
81 } |
|
82 |
|
83 void CNcdOperationManagerProxy::SetClientLocalizer( |
|
84 MNcdClientLocalizer& aLocalizer ) |
|
85 { |
|
86 iClientLocalizer = &aLocalizer; |
|
87 } |
|
88 |
|
89 |
|
90 CNcdLoadNodeOperationProxy* CNcdOperationManagerProxy::CreateLoadNodeOperationL( |
|
91 CNcdNodeProxy& aNode, TBool aLoadChildren, TInt aPageSize, TInt aPageStart, TInt aDepth, |
|
92 TNcdChildLoadMode aMode, MNcdSearchFilter* aSearchFilter ) |
|
93 { |
|
94 DLTRACEIN(("")); |
|
95 |
|
96 CBufBase* buf = CBufFlat::NewL( KBufExpandSize ); |
|
97 CleanupStack::PushL( buf ); |
|
98 RBufWriteStream stream( *buf ); |
|
99 CleanupClosePushL( stream ); |
|
100 aNode.NodeIdentifier().ExternalizeL( stream ); |
|
101 stream.WriteInt32L( aLoadChildren ); |
|
102 stream.WriteInt32L( aPageSize ); |
|
103 stream.WriteInt32L( aPageStart ); |
|
104 stream.WriteInt32L( aDepth ); |
|
105 stream.WriteInt32L( aMode ); |
|
106 stream.WriteInt32L( aSearchFilter != NULL ); |
|
107 if ( aSearchFilter ) |
|
108 { |
|
109 stream.WriteUint32L( aSearchFilter->ContentPurposes() ); |
|
110 stream.WriteInt32L( aSearchFilter->Keywords().MdcaCount() ); |
|
111 for ( TInt i = 0 ; i < aSearchFilter->Keywords().MdcaCount() ; i++ ) |
|
112 { |
|
113 ExternalizeDesL( aSearchFilter->Keywords().MdcaPoint( i ), stream ); |
|
114 } |
|
115 ExternalizeEnumL( aSearchFilter->SearchMode(), stream ); |
|
116 stream.WriteUint32L( aSearchFilter->RecursionDepth() ); |
|
117 } |
|
118 |
|
119 CleanupStack::PopAndDestroy( &stream ); |
|
120 TPtrC8 ptr = buf->Ptr( 0 ); |
|
121 |
|
122 DLTRACE(("Create server side operation")); |
|
123 // Send message to server side operation manager to create the server side |
|
124 // operation and to get a handle to the operation. |
|
125 TInt operationHandle( 0 ); |
|
126 User::LeaveIfError( |
|
127 ClientServerSession(). |
|
128 SendSync( NcdNodeFunctionIds::ENcdOperationManagerCreateLoadNodeOperation, |
|
129 ptr, |
|
130 operationHandle, |
|
131 Handle() ) ); |
|
132 |
|
133 CleanupStack::PopAndDestroy( buf ); |
|
134 |
|
135 |
|
136 MNcdOperationProxyRemoveHandler* removeHandler( this ); |
|
137 |
|
138 DLINFO(("operation handle: %d", operationHandle )); |
|
139 |
|
140 // Create operation proxy |
|
141 CNcdLoadNodeOperationProxy* operation = |
|
142 CNcdLoadNodeOperationProxy::NewLC( |
|
143 ClientServerSession(), operationHandle, removeHandler, &aNode, |
|
144 iNodeManager, aSearchFilter != NULL, iClientLocalizer ); |
|
145 |
|
146 iOperationCache.AppendL( operation ); |
|
147 |
|
148 CleanupStack::Pop( operation ); |
|
149 DLTRACEOUT(("")); |
|
150 return operation; |
|
151 } |
|
152 |
|
153 CNcdLoadNodeOperationProxy* CNcdOperationManagerProxy::CreateLoadRootNodeOperationL( |
|
154 CNcdNodeProxy& aNode ) |
|
155 { |
|
156 DLTRACEIN(("")); |
|
157 |
|
158 MNcdOperationProxyRemoveHandler* removeHandler( this ); |
|
159 |
|
160 // Create operation on the server side |
|
161 TInt operationHandle = CreateOperationL( aNode, |
|
162 NcdNodeFunctionIds::ENcdOperationManagerCreateLoadRootNodeOperation, |
|
163 removeHandler ); |
|
164 |
|
165 // Create operation proxy |
|
166 CNcdLoadNodeOperationProxy* operation = |
|
167 CNcdLoadNodeOperationProxy::NewLC( |
|
168 ClientServerSession(), operationHandle, removeHandler, &aNode, |
|
169 iNodeManager, EFalse, iClientLocalizer ); |
|
170 |
|
171 iOperationCache.AppendL( operation ); |
|
172 |
|
173 CleanupStack::Pop( operation ); |
|
174 DLTRACEOUT(("")); |
|
175 return operation; |
|
176 } |
|
177 |
|
178 CNcdLoadNodeOperationProxy* CNcdOperationManagerProxy::CreateLoadBundleNodeOperationL( |
|
179 CNcdNodeProxy& aNode ) |
|
180 { |
|
181 DLTRACEIN(("")); |
|
182 |
|
183 MNcdOperationProxyRemoveHandler* removeHandler( this ); |
|
184 |
|
185 // Create operation on the server side |
|
186 TInt operationHandle = CreateOperationL( |
|
187 aNode, NcdNodeFunctionIds::ENcdOperationManagerCreateLoadBundleNodeOperation, |
|
188 removeHandler ); |
|
189 |
|
190 // Create operation proxy |
|
191 CNcdLoadNodeOperationProxy* operation = |
|
192 CNcdLoadNodeOperationProxy::NewLC( |
|
193 ClientServerSession(), operationHandle, removeHandler, &aNode, |
|
194 iNodeManager, EFalse, iClientLocalizer ); |
|
195 |
|
196 iOperationCache.AppendL( operation ); |
|
197 CleanupStack::Pop( operation ); |
|
198 return operation; |
|
199 } |
|
200 |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // Creates a new download operation |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 CNcdDownloadOperationProxy* CNcdOperationManagerProxy::CreateDownloadOperationL( |
|
207 TNcdDownloadDataType aType, CNcdNodeProxy& aNode, const TDesC& /* aDataId */, |
|
208 MNcdDownloadOperationObserver* aObserver, |
|
209 TInt aDownloadIndex ) |
|
210 { |
|
211 DLTRACEIN(("")); |
|
212 MNcdOperationProxyRemoveHandler* removeHandler( this ); |
|
213 |
|
214 // Use temporary node to create a download operation |
|
215 // http://jira.bothi.fi/jira/browse/PRECLI-1229 |
|
216 |
|
217 // Ownership is not transferred |
|
218 CNcdNodeMetadataProxy* metadataProxy = aNode.Metadata(); |
|
219 |
|
220 if ( !metadataProxy ) |
|
221 { |
|
222 DLERROR(( "CNcdNodeMetadataProxy was NULL!" )); |
|
223 User::Leave( KErrNotFound ); |
|
224 } |
|
225 |
|
226 CNcdNodeIdentifier& nodeIdentifier = metadataProxy->Identifier(); |
|
227 |
|
228 CNcdNodeProxy* node = NULL; |
|
229 if( aType == ENcdContentDownload ) |
|
230 { |
|
231 // Content download may be started from just purchase history data |
|
232 // even when chache is completely empty. |
|
233 // Always use temporary nodes in content downloads to prevent problems. |
|
234 node = &iNodeManager->CreateTemporaryOrSupplierNodeL( |
|
235 nodeIdentifier ); |
|
236 } |
|
237 else |
|
238 { |
|
239 node = &aNode; |
|
240 } |
|
241 |
|
242 // Create the server side download |
|
243 TInt operationHandle = CreateServerSideDownloadOperationL( aType, |
|
244 node->NodeIdentifier(), aDownloadIndex ); |
|
245 |
|
246 // Check if the download already exists, increases refcount if operation |
|
247 // is found |
|
248 CNcdDownloadOperationProxy* operation = FindExistingDownloadOperation( |
|
249 operationHandle ); |
|
250 if ( operation ) |
|
251 { |
|
252 DLTRACE(("Found existing download")); |
|
253 if ( aObserver ) |
|
254 { |
|
255 operation->AddObserverL( *aObserver ); |
|
256 } |
|
257 return operation; |
|
258 } |
|
259 |
|
260 |
|
261 // Create operation proxy |
|
262 operation = CNcdDownloadOperationProxy::NewLC( |
|
263 ClientServerSession(), aType, operationHandle, removeHandler, node, |
|
264 aObserver, iNodeManager, aDownloadIndex ); |
|
265 |
|
266 iOperationCache.AppendL( operation ); |
|
267 |
|
268 CleanupStack::Pop( operation ); |
|
269 DLTRACEOUT(("")); |
|
270 return operation; |
|
271 } |
|
272 |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // Creates a new file download operation |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 CNcdFileDownloadOperationProxy* CNcdOperationManagerProxy::CreateFileDownloadOperationL( |
|
279 TNcdDownloadDataType aType, |
|
280 CNcdNodeProxy& aNode, |
|
281 MNcdFileDownloadOperationObserver* aObserver, |
|
282 const TDesC& aTargetPath ) |
|
283 { |
|
284 DLTRACEIN(("")); |
|
285 if ( !aTargetPath.Length() ) |
|
286 { |
|
287 DLERROR(( "No target path, leaving with KErrArgument" )); |
|
288 User::Leave( KErrArgument ); |
|
289 } |
|
290 |
|
291 MNcdOperationProxyRemoveHandler* removeHandler( this ); |
|
292 |
|
293 // Create the server side download |
|
294 TInt operationHandle = CreateServerSideDownloadOperationL( aType, |
|
295 aNode.NodeIdentifier(), 0 ); |
|
296 |
|
297 // Create operation proxy |
|
298 CNcdFileDownloadOperationProxy* operation = |
|
299 CNcdFileDownloadOperationProxy::NewLC( |
|
300 ClientServerSession(), operationHandle, removeHandler, &aNode, |
|
301 iNodeManager, aTargetPath, aObserver, aType ); |
|
302 |
|
303 iOperationCache.AppendL( operation ); |
|
304 |
|
305 CleanupStack::Pop( operation ); |
|
306 |
|
307 return operation; |
|
308 } |
|
309 |
|
310 |
|
311 // --------------------------------------------------------------------------- |
|
312 // Creates a new file download operation |
|
313 // --------------------------------------------------------------------------- |
|
314 // |
|
315 CNcdFileDownloadOperationProxy* |
|
316 CNcdOperationManagerProxy::CreateFileDownloadOperationL( |
|
317 TNcdDownloadDataType aType, |
|
318 const TDesC& aUri, |
|
319 const TDesC& aTargetPath, |
|
320 MNcdFileDownloadOperationObserver* aObserver ) |
|
321 { |
|
322 DLTRACEIN(("")); |
|
323 |
|
324 if ( !aUri.Length() || !aTargetPath.Length() ) |
|
325 { |
|
326 DLERROR(( "No URI or target path, leaving with KErrArgument" )); |
|
327 User::Leave( KErrArgument ); |
|
328 } |
|
329 |
|
330 MNcdOperationProxyRemoveHandler* removeHandler( this ); |
|
331 |
|
332 // Use node id for transferring URI and targetpath to server-side |
|
333 CNcdNodeIdentifier* id = CNcdNodeIdentifier::NewLC( |
|
334 aUri, aTargetPath, TUid::Null() ); |
|
335 |
|
336 // Create the server side download |
|
337 TInt operationHandle = CreateServerSideDownloadOperationL( |
|
338 ENcdGenericFileDownload, |
|
339 *id, |
|
340 0 ); |
|
341 |
|
342 CleanupStack::PopAndDestroy( id ); |
|
343 |
|
344 // Create operation proxy |
|
345 CNcdFileDownloadOperationProxy* operation = |
|
346 CNcdFileDownloadOperationProxy::NewLC( |
|
347 ClientServerSession(), operationHandle, removeHandler, NULL, |
|
348 iNodeManager, aTargetPath, aObserver, aType ); |
|
349 |
|
350 iOperationCache.AppendL( operation ); |
|
351 |
|
352 CleanupStack::Pop( operation ); |
|
353 DLTRACEOUT(("")); |
|
354 return operation; |
|
355 } |
|
356 |
|
357 |
|
358 // --------------------------------------------------------------------------- |
|
359 // Creates a new purchase operation |
|
360 // --------------------------------------------------------------------------- |
|
361 // |
|
362 CNcdPurchaseOperationProxy* CNcdOperationManagerProxy::CreatePurchaseOperationL( |
|
363 CNcdNodeProxy& aNode, |
|
364 CNcdPurchaseOptionProxy& aSelectedPurchaseOption, |
|
365 MNcdPurchaseOperationObserver* aObserver ) |
|
366 { |
|
367 DLTRACEIN(("")); |
|
368 |
|
369 MNcdOperationProxyRemoveHandler* removeHandler( this ); |
|
370 |
|
371 // Create operation on the server side |
|
372 TInt operationHandle = CreateServerSidePurchaseOperationL( |
|
373 aNode, |
|
374 aSelectedPurchaseOption, |
|
375 NcdNodeFunctionIds::ENcdOperationManagerCreatePurchaseOperation, |
|
376 removeHandler ); |
|
377 |
|
378 CNcdSubscriptionManagerProxy* subscriptionManager( NULL ); |
|
379 if ( iNodeManager != NULL ) |
|
380 { |
|
381 subscriptionManager = &iNodeManager->SubscriptionManager(); |
|
382 } |
|
383 |
|
384 // Create operation proxy |
|
385 CNcdPurchaseOperationProxy* operation = |
|
386 CNcdPurchaseOperationProxy::NewLC( |
|
387 ClientServerSession(), |
|
388 operationHandle, |
|
389 removeHandler, |
|
390 &aNode, |
|
391 &aSelectedPurchaseOption, |
|
392 aObserver, |
|
393 subscriptionManager, |
|
394 iNodeManager, |
|
395 iClientLocalizer ); |
|
396 |
|
397 iOperationCache.AppendL( operation ); |
|
398 |
|
399 CleanupStack::Pop( operation ); |
|
400 |
|
401 return operation; |
|
402 } |
|
403 |
|
404 |
|
405 |
|
406 // --------------------------------------------------------------------------- |
|
407 // Creates a new install operation |
|
408 // --------------------------------------------------------------------------- |
|
409 // |
|
410 CNcdInstallOperationProxy* CNcdOperationManagerProxy::CreateInstallOperationL( |
|
411 CNcdNodeProxy& aNode, |
|
412 MNcdInstallOperationObserver* aObserver ) |
|
413 { |
|
414 DLTRACEIN(("")); |
|
415 // Should get the actual object for this pointer! |
|
416 MNcdOperationProxyRemoveHandler* removeHandler( this ); |
|
417 |
|
418 // Create operation on the server side |
|
419 TInt operationHandle = CreateOperationL( aNode, |
|
420 NcdNodeFunctionIds::ENcdOperationManagerCreateInstallOperation, |
|
421 removeHandler ); |
|
422 |
|
423 // Create operation proxy |
|
424 CNcdInstallOperationProxy* operation = |
|
425 CNcdInstallOperationProxy::NewLC( |
|
426 ClientServerSession(), operationHandle, |
|
427 removeHandler, &aNode, iNodeManager, aObserver, |
|
428 InstallationServiceL() ); |
|
429 |
|
430 iOperationCache.AppendL( operation ); |
|
431 |
|
432 CleanupStack::Pop( operation ); |
|
433 DLTRACEOUT(("")); |
|
434 return operation; |
|
435 } |
|
436 |
|
437 |
|
438 // --------------------------------------------------------------------------- |
|
439 // Creates a new install operation |
|
440 // --------------------------------------------------------------------------- |
|
441 // |
|
442 CNcdSilentInstallOperationProxy* CNcdOperationManagerProxy::CreateSilentInstallOperationL( |
|
443 CNcdNodeProxy& aNode, |
|
444 MNcdInstallOperationObserver* aObserver, |
|
445 const SwiUI::TInstallOptions& aInstallOptions ) |
|
446 { |
|
447 DLTRACEIN(("")); |
|
448 |
|
449 // Should get the actual object for this pointer! |
|
450 MNcdOperationProxyRemoveHandler* removeHandler( this ); |
|
451 |
|
452 // Create operation on the server side |
|
453 // Notice, that the installation is handled in the proxy side, and only some |
|
454 // basic functionality is in the server side. |
|
455 // Notice, that this leaves with KErrPermissionDenied if UI does not have enough |
|
456 // capabilites for silent install. |
|
457 TInt operationHandle = CreateOperationL( aNode, |
|
458 NcdNodeFunctionIds::ENcdOperationManagerCreateSilentInstallOperation, |
|
459 removeHandler ); |
|
460 |
|
461 // Create operation proxy |
|
462 CNcdSilentInstallOperationProxy* operation = |
|
463 CNcdSilentInstallOperationProxy::NewLC( |
|
464 ClientServerSession(), operationHandle, |
|
465 removeHandler, &aNode, iNodeManager, aObserver, |
|
466 InstallationServiceL(), |
|
467 aInstallOptions ); |
|
468 |
|
469 iOperationCache.AppendL( operation ); |
|
470 |
|
471 CleanupStack::Pop( operation ); |
|
472 DLTRACEOUT(("")); |
|
473 return operation; |
|
474 } |
|
475 |
|
476 |
|
477 // --------------------------------------------------------------------------- |
|
478 // Creates a DRM rights object download & install operation |
|
479 // --------------------------------------------------------------------------- |
|
480 // |
|
481 CNcdRightsObjectOperationProxy* |
|
482 CNcdOperationManagerProxy::CreateRightsObjectOperationL( |
|
483 const TDesC& aDownloadUri, |
|
484 const TDesC& aMimeType, |
|
485 const TNcdConnectionMethod& aConnectionMethod, |
|
486 MNcdRightsObjectOperationObserver& aObserver ) |
|
487 { |
|
488 DLTRACEIN(("")); |
|
489 |
|
490 // Calculate size of input data buffer. |
|
491 TInt bufferLen = sizeof( TUint32 ) + aDownloadUri.Size() + // URI length + text data |
|
492 sizeof( TUint32 ) + aMimeType.Size() + // mime type length + text data |
|
493 sizeof( TNcdConnectionMethod ); // access point id |
|
494 |
|
495 // Allocate and build the input data buffer. |
|
496 CBufFlat* buffer = CBufFlat::NewL( bufferLen ); |
|
497 CleanupStack::PushL( buffer ); |
|
498 |
|
499 RBufWriteStream stream( *buffer ); |
|
500 CleanupClosePushL( stream ); |
|
501 |
|
502 ExternalizeDesL( aDownloadUri, stream ); // Don't use << (would convert to 8-bit) |
|
503 ExternalizeDesL( aMimeType, stream ); |
|
504 aConnectionMethod.ExternalizeL( stream ); |
|
505 |
|
506 // Send the command for creating the server side operation object. |
|
507 TInt operationHandle; // communication handle to the created server side object |
|
508 User::LeaveIfError( ClientServerSession().SendSync( |
|
509 NcdNodeFunctionIds::ENcdOperationManagerCreateRightsObjectOperation, |
|
510 buffer->Ptr( 0 ), |
|
511 operationHandle, |
|
512 Handle() ) ); |
|
513 DLINFO(( "Got server side operation object comm handle %d", operationHandle )); |
|
514 |
|
515 CleanupStack::PopAndDestroy( 2, buffer ); // stream-close, buffer |
|
516 |
|
517 // Create operation proxy |
|
518 |
|
519 CNcdRightsObjectOperationProxy* operation = |
|
520 CNcdRightsObjectOperationProxy::NewLC( |
|
521 ClientServerSession(), iNodeManager, operationHandle, |
|
522 *this, aObserver ); |
|
523 |
|
524 iOperationCache.AppendL( operation ); |
|
525 |
|
526 CleanupStack::Pop( operation ); |
|
527 DLTRACEOUT(("")); |
|
528 return operation; |
|
529 } |
|
530 |
|
531 CNcdSubscriptionOperationProxy* |
|
532 CNcdOperationManagerProxy::CreateSubscriptionRefreshOperationL( |
|
533 MNcdSubscriptionOperationObserver& aObserver ) |
|
534 { |
|
535 DLTRACEIN(("")); |
|
536 |
|
537 CBufBase* buf = CBufFlat::NewL( KBufExpandSize ); |
|
538 CleanupStack::PushL( buf ); |
|
539 RBufWriteStream stream( *buf ); |
|
540 CleanupClosePushL( stream ); |
|
541 |
|
542 // Subscription operation doesn't need any parameters to refresh all |
|
543 // subscriptions. |
|
544 stream.WriteInt32L( MNcdSubscriptionOperation::ERefreshSubscriptions ); |
|
545 |
|
546 CleanupStack::PopAndDestroy( &stream ); |
|
547 TPtrC8 ptr = buf->Ptr( 0 ); |
|
548 |
|
549 DLTRACE(("Create server side operation")); |
|
550 // Send message to server side operation manager to create the server side |
|
551 // operation and to get a handle to the operation. |
|
552 TInt operationHandle( 0 ); |
|
553 User::LeaveIfError( |
|
554 ClientServerSession(). |
|
555 SendSync( |
|
556 NcdNodeFunctionIds::ENcdOperationManagerCreateSubscriptionOperation, |
|
557 ptr, |
|
558 operationHandle, |
|
559 Handle() ) ); |
|
560 |
|
561 CleanupStack::PopAndDestroy( buf ); |
|
562 |
|
563 MNcdOperationProxyRemoveHandler* removeHandler( this ); |
|
564 |
|
565 DLINFO(("operation handle: %d", operationHandle )); |
|
566 |
|
567 CNcdSubscriptionManagerProxy* subscriptionManager( NULL ); |
|
568 if ( iNodeManager != NULL ) |
|
569 { |
|
570 subscriptionManager = &iNodeManager->SubscriptionManager(); |
|
571 } |
|
572 |
|
573 CNcdSubscriptionOperationProxy* operation = |
|
574 CNcdSubscriptionOperationProxy::NewLC( |
|
575 ClientServerSession(), |
|
576 MNcdSubscriptionOperation::ERefreshSubscriptions, |
|
577 operationHandle, |
|
578 removeHandler, |
|
579 aObserver, |
|
580 subscriptionManager, |
|
581 iNodeManager, |
|
582 iClientLocalizer ); |
|
583 |
|
584 iOperationCache.AppendL( operation ); |
|
585 |
|
586 CleanupStack::Pop( operation ); |
|
587 DLTRACEOUT(("")); |
|
588 return operation; |
|
589 } |
|
590 |
|
591 |
|
592 |
|
593 CNcdSubscriptionOperationProxy* |
|
594 CNcdOperationManagerProxy::CreateSubscriptionUnsubscribeOperationL( |
|
595 const TDesC& aPurchaseOptionId, |
|
596 const TDesC& aEntityId, |
|
597 const TDesC& aNamespace, |
|
598 const TDesC& aServerUri, |
|
599 MNcdSubscriptionOperationObserver& aObserver ) |
|
600 { |
|
601 DLTRACEIN(("")); |
|
602 |
|
603 CBufBase* buf = CBufFlat::NewL( KBufExpandSize ); |
|
604 CleanupStack::PushL( buf ); |
|
605 RBufWriteStream stream( *buf ); |
|
606 CleanupClosePushL( stream ); |
|
607 |
|
608 // Write the type of subscription operation. |
|
609 stream.WriteInt32L( MNcdSubscriptionOperation::EUnsubscribe ); |
|
610 |
|
611 ExternalizeDesL( aPurchaseOptionId, stream ); |
|
612 ExternalizeDesL( aEntityId, stream ); |
|
613 ExternalizeDesL( aNamespace, stream ); |
|
614 ExternalizeDesL( aServerUri, stream ); |
|
615 |
|
616 CleanupStack::PopAndDestroy( &stream ); |
|
617 TPtrC8 ptr = buf->Ptr( 0 ); |
|
618 |
|
619 DLTRACE(("Create server side operation")); |
|
620 // Send message to server side operation manager to create the server side |
|
621 // operation and to get a handle to the operation. |
|
622 TInt operationHandle( 0 ); |
|
623 User::LeaveIfError( |
|
624 ClientServerSession(). |
|
625 SendSync( |
|
626 NcdNodeFunctionIds::ENcdOperationManagerCreateSubscriptionOperation, |
|
627 ptr, |
|
628 operationHandle, |
|
629 Handle() ) ); |
|
630 |
|
631 CleanupStack::PopAndDestroy( buf ); |
|
632 |
|
633 MNcdOperationProxyRemoveHandler* removeHandler( this ); |
|
634 |
|
635 DLINFO(("operation handle: %d", operationHandle )); |
|
636 |
|
637 CNcdSubscriptionManagerProxy* subscriptionManager( NULL ); |
|
638 if ( iNodeManager != NULL ) |
|
639 { |
|
640 subscriptionManager = &iNodeManager->SubscriptionManager(); |
|
641 } |
|
642 |
|
643 CNcdSubscriptionOperationProxy* operation = |
|
644 CNcdSubscriptionOperationProxy::NewLC( |
|
645 ClientServerSession(), |
|
646 MNcdSubscriptionOperation::EUnsubscribe, |
|
647 operationHandle, |
|
648 removeHandler, |
|
649 aObserver, |
|
650 subscriptionManager, |
|
651 iNodeManager, |
|
652 iClientLocalizer ); |
|
653 |
|
654 iOperationCache.AppendL( operation ); |
|
655 |
|
656 CleanupStack::Pop( operation ); |
|
657 DLTRACEOUT(("")); |
|
658 return operation; |
|
659 } |
|
660 |
|
661 |
|
662 // --------------------------------------------------------------------------- |
|
663 // Creates server report operation |
|
664 // --------------------------------------------------------------------------- |
|
665 // |
|
666 CNcdServerReportOperationProxy* |
|
667 CNcdOperationManagerProxy::CreateServerReportOperationL( |
|
668 MNcdServerReportOperationObserver& aObserver ) |
|
669 { |
|
670 DLTRACEIN(("")); |
|
671 // Send the command for creating the server side operation object. |
|
672 TInt operationHandle( 0 ); // communication handle to the created server side object |
|
673 TInt error( ClientServerSession().SendSync( |
|
674 NcdNodeFunctionIds::ENcdOperationManagerCreateServerReportOperation, |
|
675 KNullDesC, |
|
676 operationHandle, |
|
677 Handle() ) ); |
|
678 User::LeaveIfError( error ); |
|
679 DLINFO(( "Got server side operation object comm handle %d", operationHandle )); |
|
680 |
|
681 // Create operation proxy |
|
682 |
|
683 CNcdServerReportOperationProxy* operation = |
|
684 CNcdServerReportOperationProxy::NewLC( |
|
685 ClientServerSession(), iNodeManager, operationHandle, |
|
686 *this, aObserver ); |
|
687 |
|
688 iOperationCache.AppendL( operation ); |
|
689 |
|
690 CleanupStack::Pop( operation ); |
|
691 DLTRACEOUT(("")); |
|
692 return operation; |
|
693 } |
|
694 |
|
695 |
|
696 // --------------------------------------------------------------------------- |
|
697 // Creates an accesspoint creation operation |
|
698 // --------------------------------------------------------------------------- |
|
699 // |
|
700 CNcdCreateAccessPointOperationProxy* |
|
701 CNcdOperationManagerProxy::CreateCreateAccessPointOperationL( |
|
702 const TDesC& aAccessPointData, |
|
703 MNcdCreateAccessPointOperationObserver& aObserver ) |
|
704 { |
|
705 DLTRACEIN(("")); |
|
706 if ( !aAccessPointData.Size() ) |
|
707 { |
|
708 DLERROR(("Accesspoint data is empty")); |
|
709 User::Leave( KErrArgument ); |
|
710 } |
|
711 |
|
712 RCatalogsBufferWriter buffer; |
|
713 buffer.OpenLC(); |
|
714 |
|
715 ExternalizeDesL( aAccessPointData, buffer() ); |
|
716 |
|
717 // Send the command for creating the server side operation object. |
|
718 TInt operationHandle; // communication handle to the created server side object |
|
719 User::LeaveIfError( ClientServerSession().SendSync( |
|
720 NcdNodeFunctionIds::ENcdOperationManagerCreateCreateAccessPointOperation, |
|
721 buffer.PtrL(), |
|
722 operationHandle, |
|
723 Handle() ) ); |
|
724 DLINFO(( "Got server side operation object comm handle %d", operationHandle )); |
|
725 |
|
726 CleanupStack::PopAndDestroy( &buffer ); |
|
727 |
|
728 // Create operation proxy |
|
729 |
|
730 CNcdCreateAccessPointOperationProxy* operation = |
|
731 CNcdCreateAccessPointOperationProxy::NewLC( |
|
732 ClientServerSession(), |
|
733 iNodeManager, |
|
734 operationHandle, |
|
735 *this, |
|
736 aObserver ); |
|
737 |
|
738 iOperationCache.AppendL( operation ); |
|
739 |
|
740 CleanupStack::Pop( operation ); |
|
741 DLTRACEOUT(("")); |
|
742 return operation; |
|
743 |
|
744 } |
|
745 |
|
746 |
|
747 |
|
748 // --------------------------------------------------------------------------- |
|
749 // Creates a HTTP request sending operation |
|
750 // --------------------------------------------------------------------------- |
|
751 // |
|
752 CNcdSendHttpRequestOperationProxy* |
|
753 CNcdOperationManagerProxy::CreateSendHttpRequestOperationL( |
|
754 const TDesC8& aUri, |
|
755 const TDesC8& aRequest, |
|
756 const TNcdConnectionMethod& aConnectionMethod, |
|
757 MNcdSendHttpRequestOperationObserver& aObserver ) |
|
758 { |
|
759 DLTRACEIN(("")); |
|
760 if ( !aRequest.Size() ) |
|
761 { |
|
762 DLERROR(("Request is empty")); |
|
763 User::Leave( KErrArgument ); |
|
764 } |
|
765 |
|
766 RCatalogsBufferWriter buffer; |
|
767 buffer.OpenLC(); |
|
768 |
|
769 aConnectionMethod.ExternalizeL( buffer() ); |
|
770 ExternalizeDesL( aUri, buffer() ); |
|
771 ExternalizeDesL( aRequest, buffer() ); |
|
772 |
|
773 // Send the command for creating the server side operation object. |
|
774 TInt operationHandle; // communication handle to the created server side object |
|
775 User::LeaveIfError( ClientServerSession().SendSync( |
|
776 NcdNodeFunctionIds::ENcdOperationManagerCreateSendHttpRequestOperation, |
|
777 buffer.PtrL(), |
|
778 operationHandle, |
|
779 Handle() ) ); |
|
780 DLINFO(( "Got server side operation object comm handle %d", operationHandle )); |
|
781 |
|
782 CleanupStack::PopAndDestroy( &buffer ); |
|
783 |
|
784 // Create operation proxy |
|
785 |
|
786 CNcdSendHttpRequestOperationProxy* operation = |
|
787 CNcdSendHttpRequestOperationProxy::NewLC( |
|
788 ClientServerSession(), |
|
789 operationHandle, |
|
790 *this, |
|
791 *iNodeManager, |
|
792 aObserver ); |
|
793 |
|
794 iOperationCache.AppendL( operation ); |
|
795 |
|
796 CleanupStack::Pop( operation ); |
|
797 DLTRACEOUT(("")); |
|
798 return operation; |
|
799 |
|
800 } |
|
801 |
|
802 |
|
803 // --------------------------------------------------------------------------- |
|
804 // Restore content downloads |
|
805 // --------------------------------------------------------------------------- |
|
806 // |
|
807 void CNcdOperationManagerProxy::RestoreContentDownloadsL() |
|
808 { |
|
809 DLTRACEIN(("")); |
|
810 |
|
811 // Get operation handles from the server |
|
812 HBufC8* data = NULL; |
|
813 User::LeaveIfError( |
|
814 ClientServerSession(). |
|
815 SendSyncAlloc( |
|
816 NcdNodeFunctionIds::ENcdOperationManagerRestoreContentDownloads, |
|
817 KNullDesC8(), |
|
818 data, |
|
819 Handle(), |
|
820 0 ) ); |
|
821 |
|
822 MNcdOperationProxyRemoveHandler* removeHandler( this ); |
|
823 CleanupStack::PushL( data ); |
|
824 |
|
825 RDesReadStream reader( *data ); |
|
826 CleanupClosePushL( reader ); |
|
827 |
|
828 NcdProviderDefines::TNcdStreamDataState streamState = |
|
829 NcdProviderDefines::ENcdStreamDataEnd; |
|
830 do |
|
831 { |
|
832 InternalizeEnumL( streamState, reader ); |
|
833 |
|
834 if ( streamState == NcdProviderDefines::ENcdStreamDataObject ) |
|
835 { |
|
836 TInt32 operationHandle = reader.ReadInt32L(); |
|
837 DLINFO(("Operation handle: %d", operationHandle )); |
|
838 |
|
839 TNcdDownloadDataType type = static_cast<TNcdDownloadDataType>( |
|
840 reader.ReadInt32L() ); |
|
841 |
|
842 CNcdNodeIdentifier* metadataId = CNcdNodeIdentifier::NewLC( |
|
843 reader ); |
|
844 |
|
845 TInt dlIndex = reader.ReadInt32L(); |
|
846 |
|
847 // Use a temporary node |
|
848 CNcdNodeProxy* node = &iNodeManager->CreateTemporaryOrSupplierNodeL( |
|
849 *metadataId ); |
|
850 |
|
851 // Create operation proxy |
|
852 CNcdDownloadOperationProxy* operation = |
|
853 CNcdDownloadOperationProxy::NewLC( |
|
854 ClientServerSession(), type, |
|
855 operationHandle, removeHandler, node, |
|
856 NULL, iNodeManager, dlIndex, ETrue ); |
|
857 |
|
858 // Add operation manager as an observer so that the operation |
|
859 // is deleted correctly if it completes |
|
860 operation->AddObserverL( *this ); |
|
861 iOperationCache.AppendL( operation ); |
|
862 |
|
863 CleanupStack::Pop( operation ); |
|
864 CleanupStack::PopAndDestroy( metadataId ); |
|
865 } |
|
866 } |
|
867 while( streamState != NcdProviderDefines::ENcdStreamDataEnd ); |
|
868 |
|
869 CleanupStack::PopAndDestroy( 2, data ); // reader, data |
|
870 DLTRACEOUT(("Downloads created")); |
|
871 } |
|
872 |
|
873 |
|
874 // --------------------------------------------------------------------------- |
|
875 // Operations array getter |
|
876 // --------------------------------------------------------------------------- |
|
877 // |
|
878 const RPointerArray<MNcdOperation>& CNcdOperationManagerProxy::Operations() const |
|
879 { |
|
880 return iOperationCache; |
|
881 } |
|
882 |
|
883 |
|
884 // --------------------------------------------------------------------------- |
|
885 // Node manager setter |
|
886 // --------------------------------------------------------------------------- |
|
887 // |
|
888 void CNcdOperationManagerProxy::SetNodeManager(CNcdNodeManagerProxy* aNodeManager ) |
|
889 { |
|
890 iNodeManager = aNodeManager; |
|
891 } |
|
892 |
|
893 // --------------------------------------------------------------------------- |
|
894 // Node manager getter |
|
895 // --------------------------------------------------------------------------- |
|
896 // |
|
897 CNcdNodeManagerProxy* CNcdOperationManagerProxy::NodeManager() |
|
898 { |
|
899 return iNodeManager; |
|
900 } |
|
901 |
|
902 |
|
903 // --------------------------------------------------------------------------- |
|
904 // Installation service getter |
|
905 // --------------------------------------------------------------------------- |
|
906 // |
|
907 MNcdInstallationService& CNcdOperationManagerProxy::InstallationServiceL() |
|
908 { |
|
909 DLTRACEIN(("")); |
|
910 if ( !iInstallationService ) |
|
911 { |
|
912 iInstallationService = |
|
913 NcdDeviceInteractionFactory::CreateInstallationServiceL(); |
|
914 } |
|
915 return *iInstallationService; |
|
916 } |
|
917 |
|
918 |
|
919 // --------------------------------------------------------------------------- |
|
920 // Cancel all operations |
|
921 // --------------------------------------------------------------------------- |
|
922 // |
|
923 void CNcdOperationManagerProxy::CancelAllOperations() |
|
924 { |
|
925 DLTRACEIN(("")); |
|
926 |
|
927 for ( TInt i = iOperationCache.Count() - 1; i >= 0; --i ) |
|
928 { |
|
929 // Add reference so that the operation is not deleted in |
|
930 // CancelOperation's callbacks |
|
931 iOperationCache[i]->AddRef(); |
|
932 iOperationCache[i]->CancelOperation(); |
|
933 |
|
934 // This releases those operations that have 1 refcount such as |
|
935 // restored content downloads that the client hasn't obtained |
|
936 // from the manager |
|
937 while( iOperationCache[i]->Release() ) |
|
938 { |
|
939 // empty on purpose |
|
940 } |
|
941 } |
|
942 } |
|
943 |
|
944 |
|
945 // --------------------------------------------------------------------------- |
|
946 // Cancel all operations |
|
947 // --------------------------------------------------------------------------- |
|
948 // |
|
949 void CNcdOperationManagerProxy::ReleaseUnusedOperations() |
|
950 { |
|
951 DLTRACEIN(("")); |
|
952 |
|
953 for ( TInt i = iOperationCache.Count() - 1; i >= 0; --i ) |
|
954 { |
|
955 // This releases those operations that have 1 refcount such as |
|
956 // restored content downloads that the client hasn't obtained |
|
957 // from the manager |
|
958 iOperationCache[i]->Release(); |
|
959 } |
|
960 } |
|
961 |
|
962 |
|
963 // --------------------------------------------------------------------------- |
|
964 // Operation proxy remover |
|
965 // --------------------------------------------------------------------------- |
|
966 // |
|
967 void CNcdOperationManagerProxy::RemoveOperationProxy( |
|
968 CNcdBaseOperationProxy& aOperationProxy ) |
|
969 { |
|
970 DLTRACEIN(("")); |
|
971 |
|
972 // Releasing all operations so we don't want to mess with the operation cache |
|
973 if ( iRemovingAllOperations ) |
|
974 { |
|
975 DLTRACE(("Removing all operations")); |
|
976 return; |
|
977 } |
|
978 |
|
979 MNcdOperation* operation = NULL; |
|
980 TRAP_IGNORE( |
|
981 operation = aOperationProxy.QueryInterfaceLC< MNcdOperation >(); |
|
982 CleanupStack::Pop( operation ); |
|
983 ); // TRAP_IGNORE |
|
984 if( ! operation ) |
|
985 { |
|
986 DLINFO( ("!!!QueryInterfaceLC failed for operation! FATAL ERROR!")); |
|
987 DASSERT( 0 ); |
|
988 } |
|
989 |
|
990 // Remove operation from the cache because it will be deleted. |
|
991 for ( TInt i = 0; i < iOperationCache.Count(); ++i ) |
|
992 { |
|
993 if ( operation == iOperationCache[ i ] ) |
|
994 { |
|
995 DLTRACE(("Removed the proxy")); |
|
996 // Remove node from the array and delete it. |
|
997 iOperationCache.Remove( i ); |
|
998 break; |
|
999 } |
|
1000 } |
|
1001 |
|
1002 // RemoveOperationProxy MUST only be called from proxy's destructor |
|
1003 // and therefore the operation MUST NOT be released again |
|
1004 DLTRACEOUT(("")); |
|
1005 } |
|
1006 |
|
1007 |
|
1008 // --------------------------------------------------------------------------- |
|
1009 // Download operation observer interface implementation |
|
1010 // --------------------------------------------------------------------------- |
|
1011 // |
|
1012 void CNcdOperationManagerProxy::DownloadProgress( |
|
1013 MNcdDownloadOperation& /* aOperation */, |
|
1014 TNcdProgress /* aProgress */ ) |
|
1015 { |
|
1016 // Do nothing |
|
1017 } |
|
1018 |
|
1019 |
|
1020 void CNcdOperationManagerProxy::QueryReceived( |
|
1021 MNcdDownloadOperation& /* aOperation */, |
|
1022 MNcdQuery* /* aQuery */) |
|
1023 { |
|
1024 // Do nothing |
|
1025 } |
|
1026 |
|
1027 |
|
1028 void CNcdOperationManagerProxy::OperationComplete( |
|
1029 MNcdDownloadOperation& aOperation, |
|
1030 TInt aError ) |
|
1031 { |
|
1032 DLTRACEIN(("aOperation: %x, error: %d", &aOperation, aError )); |
|
1033 (void)aError; // suppresses compiler warning |
|
1034 // Just release the operation because operation manager had a |
|
1035 // reference to it |
|
1036 aOperation.Release(); |
|
1037 } |
|
1038 |
|
1039 |
|
1040 |
|
1041 CNcdOperationManagerProxy::CNcdOperationManagerProxy( MCatalogsClientServer& aSession, |
|
1042 TInt aHandle ) |
|
1043 : CNcdBaseProxy( aSession, aHandle ) |
|
1044 { |
|
1045 } |
|
1046 |
|
1047 void CNcdOperationManagerProxy::ConstructL() |
|
1048 { |
|
1049 // Nothing to be done here |
|
1050 } |
|
1051 |
|
1052 |
|
1053 // --------------------------------------------------------------------------- |
|
1054 // Creates the identification stream for the given node |
|
1055 // --------------------------------------------------------------------------- |
|
1056 // |
|
1057 HBufC8* CNcdOperationManagerProxy::CreateNodeIdentifierDataLC( CNcdNodeProxy& aNode ) |
|
1058 { |
|
1059 DLTRACEIN(("")); |
|
1060 HBufC8* nodeIdentifierData( aNode.NodeIdentifier().NodeIdentifierDataL() ); |
|
1061 if( nodeIdentifierData == NULL ) |
|
1062 { |
|
1063 DLTRACEIN(("Null identifier data")); |
|
1064 User::Leave( KErrNotFound ); |
|
1065 } |
|
1066 CleanupStack::PushL( nodeIdentifierData ); |
|
1067 DLTRACEOUT(("")); |
|
1068 return nodeIdentifierData; |
|
1069 } |
|
1070 |
|
1071 |
|
1072 |
|
1073 // --------------------------------------------------------------------------- |
|
1074 // Creates an operation on the server side |
|
1075 // --------------------------------------------------------------------------- |
|
1076 // |
|
1077 TInt CNcdOperationManagerProxy::CreateOperationL( CNcdNodeProxy& aNode, |
|
1078 NcdNodeFunctionIds::TNcdOperationManagerFunctionNumber aFunction, |
|
1079 MNcdOperationProxyRemoveHandler*& aRemoveHandler ) |
|
1080 { |
|
1081 DLTRACEIN(( _L("Node: %S::%S"), &aNode.NodeIdentifier().NodeNameSpace(), |
|
1082 &aNode.NodeIdentifier().NodeId() )); |
|
1083 // Create id stream |
|
1084 HBufC8* nodeIdentifierData = CreateNodeIdentifierDataLC( aNode ); |
|
1085 |
|
1086 // Send message to server side operation manager to create the server side |
|
1087 // operation and to get a handle to the operation. |
|
1088 TInt operationHandle( 0 ); |
|
1089 User::LeaveIfError( |
|
1090 ClientServerSession(). |
|
1091 SendSync( aFunction, |
|
1092 *nodeIdentifierData, |
|
1093 operationHandle, |
|
1094 Handle() ) ); |
|
1095 |
|
1096 DLINFO(("operation handle: %d", operationHandle )); |
|
1097 CleanupStack::PopAndDestroy( nodeIdentifierData ); |
|
1098 |
|
1099 aRemoveHandler = this; |
|
1100 DLTRACEOUT(("")); |
|
1101 return operationHandle; |
|
1102 } |
|
1103 |
|
1104 |
|
1105 // --------------------------------------------------------------------------- |
|
1106 // Creates a purchase operation on the server side |
|
1107 // --------------------------------------------------------------------------- |
|
1108 // |
|
1109 TInt CNcdOperationManagerProxy::CreateServerSidePurchaseOperationL( |
|
1110 CNcdNodeProxy& aNode, |
|
1111 const CNcdPurchaseOptionProxy& aSelectedPurchaseOption, |
|
1112 NcdNodeFunctionIds::TNcdOperationManagerFunctionNumber aFunction, |
|
1113 MNcdOperationProxyRemoveHandler*& /*aRemoveHandler*/ ) |
|
1114 { |
|
1115 DLTRACEIN(( _L("Node: %S::%S"), &aNode.NodeIdentifier().NodeNameSpace(), |
|
1116 &aNode.NodeIdentifier().NodeId() )); |
|
1117 |
|
1118 CBufBase* buf = CBufFlat::NewL( KBufExpandSize ); |
|
1119 CleanupStack::PushL( buf ); |
|
1120 RBufWriteStream stream( *buf ); |
|
1121 CleanupClosePushL( stream ); |
|
1122 |
|
1123 aNode.NodeIdentifier().ExternalizeL( stream ); |
|
1124 |
|
1125 ExternalizeDesL( aSelectedPurchaseOption.Id(), stream ); |
|
1126 |
|
1127 CleanupStack::PopAndDestroy( &stream ); |
|
1128 |
|
1129 TPtrC8 ptr = buf->Ptr( 0 ); |
|
1130 |
|
1131 // Send message to server side operation manager to create the server side |
|
1132 // operation and to get a handle to the operation. |
|
1133 TInt operationHandle( 0 ); |
|
1134 User::LeaveIfError( |
|
1135 ClientServerSession(). |
|
1136 SendSync( aFunction, |
|
1137 ptr, |
|
1138 operationHandle, |
|
1139 Handle() ) ); |
|
1140 |
|
1141 CleanupStack::PopAndDestroy( buf ); |
|
1142 |
|
1143 DLINFO(("operation handle: %d", operationHandle )); |
|
1144 |
|
1145 DLTRACEOUT(("")); |
|
1146 return operationHandle; |
|
1147 } |
|
1148 |
|
1149 // --------------------------------------------------------------------------- |
|
1150 // Creates an download operation on the server side |
|
1151 // --------------------------------------------------------------------------- |
|
1152 // |
|
1153 TInt CNcdOperationManagerProxy::CreateServerSideDownloadOperationL( |
|
1154 TNcdDownloadDataType aType, |
|
1155 const CNcdNodeIdentifier& aNodeId, |
|
1156 TInt aDownloadIndex ) |
|
1157 { |
|
1158 DLTRACEIN(("")); |
|
1159 // Create operation on the server side |
|
1160 |
|
1161 CBufBase* buf = CBufFlat::NewL( KBufExpandSize ); |
|
1162 CleanupStack::PushL( buf ); |
|
1163 |
|
1164 RBufWriteStream stream( *buf ); |
|
1165 CleanupClosePushL( stream ); |
|
1166 |
|
1167 // Write type |
|
1168 stream.WriteInt32L( aType ); |
|
1169 |
|
1170 // Write node ID |
|
1171 aNodeId.ExternalizeL( stream ); |
|
1172 |
|
1173 // Write download index |
|
1174 stream.WriteInt32L( aDownloadIndex ); |
|
1175 |
|
1176 CleanupStack::PopAndDestroy( &stream ); |
|
1177 |
|
1178 // Send message to server side operation manager to create the server side |
|
1179 // operation and to get a handle to the operation. |
|
1180 TInt operationHandle( 0 ); |
|
1181 User::LeaveIfError( ClientServerSession(). |
|
1182 SendSync( |
|
1183 NcdNodeFunctionIds::ENcdOperationManagerCreateDownloadOperation, |
|
1184 buf->Ptr( 0 ), operationHandle, Handle() ) ); |
|
1185 |
|
1186 DLINFO(("operation handle: %d", operationHandle )); |
|
1187 CleanupStack::PopAndDestroy( buf ); |
|
1188 DLTRACEOUT(("")); |
|
1189 return operationHandle; |
|
1190 } |
|
1191 |
|
1192 |
|
1193 |
|
1194 // --------------------------------------------------------------------------- |
|
1195 // Searches operations for a matching download operation |
|
1196 // --------------------------------------------------------------------------- |
|
1197 // |
|
1198 CNcdDownloadOperationProxy* |
|
1199 CNcdOperationManagerProxy::FindExistingDownloadOperation( |
|
1200 TInt aHandle ) const |
|
1201 { |
|
1202 DLTRACEIN(("")); |
|
1203 |
|
1204 for ( TInt i = 0; i < iOperationCache.Count(); ++i ) |
|
1205 { |
|
1206 if ( iOperationCache[i]->OperationType() == ENcdDownloadOperationUid ) |
|
1207 { |
|
1208 DLTRACE(("Querying for download interface")); |
|
1209 MNcdDownloadOperation* dl = |
|
1210 iOperationCache[i]->QueryInterfaceLC<MNcdDownloadOperation>(); |
|
1211 DASSERT( dl ); |
|
1212 |
|
1213 |
|
1214 CNcdDownloadOperationProxy* operation = |
|
1215 static_cast<CNcdDownloadOperationProxy*>( dl ); |
|
1216 |
|
1217 DLTRACE(("Checking download handle")); |
|
1218 if ( operation->Handle() == aHandle ) |
|
1219 { |
|
1220 DLTRACE(("Found a match")); |
|
1221 CleanupStack::Pop( dl ); |
|
1222 return operation; |
|
1223 } |
|
1224 |
|
1225 // QueryInterfaceLC increases the ref count |
|
1226 CleanupStack::PopAndDestroy( dl ); |
|
1227 } |
|
1228 |
|
1229 } |
|
1230 DLTRACEOUT(("")); |
|
1231 return NULL; |
|
1232 } |
|
1233 |
|
1234 |