|
1 /* |
|
2 * Copyright (c) 2006-2008 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: Contains CNcdProviderProxy class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdproviderproxy.h" |
|
20 #include "catalogsclientserver.h" |
|
21 #include "ncdnodemanagerproxy.h" |
|
22 #include "ncdpurchasehistoryproxy.h" |
|
23 #include "ncdoperationmanagerproxy.h" |
|
24 #include "ncdproviderimpl.h" |
|
25 #include "ncdnodefolderproxy.h" |
|
26 #include "ncdoperation.h" |
|
27 #include "ncdnodeidentifier.h" |
|
28 #include "catalogsdebug.h" |
|
29 #include "ncdkeyvaluepair.h" |
|
30 #include "ncdkeyvaluemap.h" |
|
31 #include "catalogsutils.h" |
|
32 #include "catalogsinterfaceidentifier.h" |
|
33 #include "ncdrootnodeproxy.h" |
|
34 #include "ncdutils.h" |
|
35 #include "ncdfiledownloadoperationproxy.h" |
|
36 #include "ncdsubscriptionmanagerproxy.h" |
|
37 #include "ncdoperationdatatypes.h" |
|
38 #include "ncdrightsobjectoperationproxy.h" |
|
39 #include "ncdproviderdefines.h" |
|
40 #include "ncdproviderobserver.h" |
|
41 #include "ncdfavoritemanagerproxy.h" |
|
42 #include "ncdschemenodetype.h" |
|
43 #include "ncdpanics.h" |
|
44 #include "catalogsasyncmediator.h" |
|
45 #include "ncdcreateaccesspointoperationproxy.h" |
|
46 #include "ncdsendhttprequestoperationproxy.h" |
|
47 #include "ncdconnectionmethod.h" |
|
48 #include "ncdserverreportmanagerproxy.h" |
|
49 #include "catalogsconstants.h" |
|
50 |
|
51 |
|
52 // ======== MEMBER FUNCTIONS ======== |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // NewL |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CNcdProviderProxy* CNcdProviderProxy::NewL( MCatalogsClientServer& aSession, |
|
59 TInt aHandle ) |
|
60 { |
|
61 CNcdProviderProxy* self = |
|
62 CNcdProviderProxy::NewLC( aSession, aHandle ); |
|
63 CleanupStack::Pop( self ); |
|
64 return self; |
|
65 } |
|
66 |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // NewLC |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CNcdProviderProxy* CNcdProviderProxy::NewLC( MCatalogsClientServer& aSession, |
|
73 TInt aHandle ) |
|
74 { |
|
75 CNcdProviderProxy* self = |
|
76 new( ELeave ) CNcdProviderProxy( aSession, aHandle ); |
|
77 CleanupStack::PushL( self ); |
|
78 self->ConstructL(); |
|
79 return self; |
|
80 } |
|
81 |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // Destructor |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 CNcdProviderProxy::~CNcdProviderProxy() |
|
88 { |
|
89 DLTRACEIN(("")); |
|
90 |
|
91 |
|
92 if ( iOperationManager ) |
|
93 { |
|
94 // Release downloads that had been restored |
|
95 // from a previous session but not used by any clients. |
|
96 // |
|
97 // This has to be done before the Node manager is deleted because |
|
98 // operations can have references to nodes which have to be released |
|
99 // first |
|
100 iOperationManager->ReleaseUnusedOperations(); |
|
101 } |
|
102 |
|
103 // Remove interfaces implemented by this class from the interface list. |
|
104 // So, the interface list is up to date when this class object is deleted. |
|
105 RemoveInterface( MNcdProvider::KInterfaceUid ); |
|
106 |
|
107 DLTRACE(("Observers reset")); |
|
108 |
|
109 // Delete managers |
|
110 delete iServerReportManager; |
|
111 iServerReportManager = NULL; |
|
112 |
|
113 delete iNodeManager; |
|
114 iNodeManager = NULL; |
|
115 |
|
116 delete iPurchaseHistory; |
|
117 iPurchaseHistory = NULL; |
|
118 |
|
119 delete iOperationManager; |
|
120 iOperationManager = NULL; |
|
121 |
|
122 delete iSubscriptionManager; |
|
123 iSubscriptionManager = NULL; |
|
124 |
|
125 delete iFavoriteManager; |
|
126 iFavoriteManager = NULL; |
|
127 |
|
128 delete iAsyncMediator; |
|
129 iAsyncMediator = NULL; |
|
130 // Do not delete observers here. |
|
131 |
|
132 DLTRACEOUT(("Operation manager released")); |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // ExpirationCallback |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 void CNcdProviderProxy::ExpirationCallback( RCatalogsArray< MNcdNode >& aExpiredNodes ) |
|
140 { |
|
141 DLTRACEIN(("")); |
|
142 if( iObserver ) |
|
143 { |
|
144 iObserver->ForceExpirationInformationReceived( aExpiredNodes ); |
|
145 } |
|
146 } |
|
147 |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // OperationManager |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 CNcdOperationManagerProxy& CNcdProviderProxy::OperationManager() |
|
154 { |
|
155 return *iOperationManager; |
|
156 } |
|
157 |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // ServerReportManager |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 CNcdServerReportManagerProxy& CNcdProviderProxy::ServerReportManager() |
|
164 { |
|
165 return *iServerReportManager; |
|
166 } |
|
167 |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // SetObserver |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 void CNcdProviderProxy::SetObserver( MNcdProviderObserver* aObserver ) |
|
174 { |
|
175 // No need to delete old observer. It is owned elsewhere. |
|
176 iObserver = aObserver; |
|
177 } |
|
178 |
|
179 |
|
180 // --------------------------------------------------------------------------- |
|
181 // RootNodeL |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 MNcdNode* CNcdProviderProxy::RootNodeL() |
|
185 { |
|
186 DLTRACEIN( ("") ); |
|
187 |
|
188 DASSERT( iNodeManager ); |
|
189 |
|
190 DLTRACE( ("Getting root node from the node manager") ); |
|
191 |
|
192 // Node manager will handle the creation of the root. |
|
193 CNcdRootNodeProxy* root( &iNodeManager->RootNodeL() ); |
|
194 |
|
195 DLTRACE(("Root: %X", root)); |
|
196 |
|
197 // Increase also the reference counter by one here. |
|
198 // So, the root ref count is at least one when the user |
|
199 // gets it. |
|
200 root->AddRef(); |
|
201 |
|
202 DLTRACEOUT(("")); |
|
203 |
|
204 return root; |
|
205 } |
|
206 |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // OperationsL |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 RCatalogsArray<MNcdOperation> CNcdProviderProxy::OperationsL() const |
|
213 { |
|
214 DLTRACEIN( ( "" ) ); |
|
215 DASSERT( iOperationManager ); |
|
216 |
|
217 RCatalogsArray<MNcdOperation> operations; |
|
218 CleanupClosePushL( operations ); |
|
219 |
|
220 // Get the original array and insert its content to catalogs array. |
|
221 // Also, increase the reference counter for the items. |
|
222 const RPointerArray<MNcdOperation>& origArray = iOperationManager->Operations(); |
|
223 MNcdOperation* oper( NULL ); |
|
224 operations.ReserveL( origArray.Count() ); |
|
225 for ( TInt i = 0; i < origArray.Count(); ++i ) |
|
226 { |
|
227 oper = origArray[ i ]; |
|
228 operations.AppendL( oper ); |
|
229 oper->AddRef(); |
|
230 } |
|
231 |
|
232 DLTRACEOUT( ( "" ) ); |
|
233 |
|
234 CleanupStack::Pop( &operations ); |
|
235 |
|
236 return operations; |
|
237 } |
|
238 |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // PurchaseHistoryL |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 MNcdPurchaseHistory* CNcdProviderProxy::PurchaseHistoryL() const |
|
245 { |
|
246 DLTRACEIN( ("") ); |
|
247 DASSERT( iPurchaseHistory ); |
|
248 |
|
249 DLTRACE( ("Getting purchase history") ); |
|
250 // Get purchase history interface. |
|
251 MNcdPurchaseHistory* history( iPurchaseHistory ); |
|
252 |
|
253 // Increase also the reference counter by one here. |
|
254 history->AddRef(); |
|
255 |
|
256 |
|
257 DLTRACEOUT( ("Purchase history: %X", history ) ); |
|
258 return history; |
|
259 } |
|
260 |
|
261 // --------------------------------------------------------------------------- |
|
262 // SubscriptionsL |
|
263 // --------------------------------------------------------------------------- |
|
264 // |
|
265 MNcdSubscriptionManager* CNcdProviderProxy::SubscriptionsL() const |
|
266 { |
|
267 DLTRACEIN( ( "" ) ); |
|
268 DASSERT( iSubscriptionManager ); |
|
269 |
|
270 iSubscriptionManager->AddRef(); |
|
271 return iSubscriptionManager; |
|
272 } |
|
273 |
|
274 |
|
275 // --------------------------------------------------------------------------- |
|
276 // AddConfigurationL |
|
277 // --------------------------------------------------------------------------- |
|
278 // |
|
279 void CNcdProviderProxy::AddConfigurationL( const MNcdKeyValuePair& aConfiguration ) |
|
280 { |
|
281 DLTRACEIN(( _L("Key: %S, value: %S"), &aConfiguration.Key(), |
|
282 &aConfiguration.Value() )); |
|
283 |
|
284 // Externalize the config. |
|
285 CNcdKeyValuePair* config = CNcdKeyValuePair::NewLC( aConfiguration ); |
|
286 HBufC8* data = config->ExternalizeToDesLC(); |
|
287 |
|
288 TBuf8<1> err; |
|
289 |
|
290 // Send the config |
|
291 User::LeaveIfError( ClientServerSession().SendSync( |
|
292 CNcdProvider::ENcdProviderAddConfiguration, |
|
293 *data, |
|
294 err, |
|
295 Handle() ) ); |
|
296 |
|
297 CleanupStack::PopAndDestroy( data ); |
|
298 CleanupStack::PopAndDestroy( config ); |
|
299 |
|
300 DLTRACEOUT(("")); |
|
301 } |
|
302 |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // RemoveConfigurationL |
|
306 // --------------------------------------------------------------------------- |
|
307 // |
|
308 void CNcdProviderProxy::RemoveConfigurationL( const TDesC& aKey ) |
|
309 { |
|
310 DLTRACEIN(( _L("Key: %S"), &aKey ) ); |
|
311 |
|
312 RCatalogsBufferWriter source; |
|
313 source.OpenLC(); |
|
314 ExternalizeDesL( aKey, source() ); |
|
315 |
|
316 |
|
317 TBuf8<1> buf; |
|
318 |
|
319 // Send the config |
|
320 User::LeaveIfError( |
|
321 ClientServerSession(). |
|
322 SendSync( CNcdProvider::ENcdProviderRemoveConfiguration, |
|
323 source.PtrL(), |
|
324 buf, |
|
325 Handle() ) ); |
|
326 |
|
327 CleanupStack::PopAndDestroy( &source ); |
|
328 TInt err = buf[0]; |
|
329 |
|
330 DLTRACEOUT( ( "Provider returned err: %d", err ) ); |
|
331 |
|
332 User::LeaveIfError( err ); |
|
333 } |
|
334 |
|
335 |
|
336 // --------------------------------------------------------------------------- |
|
337 // ConfigurationsL |
|
338 // --------------------------------------------------------------------------- |
|
339 // |
|
340 RPointerArray<CNcdKeyValuePair> CNcdProviderProxy::ConfigurationsL() const |
|
341 { |
|
342 DLTRACEIN( ( "" ) ); |
|
343 |
|
344 HBufC8* buf = NULL; |
|
345 |
|
346 // Ask for the configs |
|
347 User::LeaveIfError( |
|
348 ClientServerSession(). |
|
349 SendSyncAlloc( CNcdProvider::ENcdProviderRetrieveConfigurations, |
|
350 KNullDesC8, |
|
351 buf, |
|
352 Handle(), |
|
353 0 ) ); |
|
354 |
|
355 User::LeaveIfNull( buf ); |
|
356 DLINFO(("Received %d bytes", buf->Length() )); |
|
357 |
|
358 CleanupStack::PushL( buf ); |
|
359 RDesReadStream stream( *buf ); |
|
360 CleanupClosePushL( stream ); |
|
361 CNcdKeyValueMap* map = CNcdKeyValueMap::NewLC(); |
|
362 map->InternalizeL( stream ); |
|
363 |
|
364 |
|
365 // Copy the pointers. RPointerArray's copy constructor doesn't |
|
366 // work correctly |
|
367 RPointerArray<CNcdKeyValuePair> pairs; |
|
368 pairs.ReserveL( map->Pairs().Count() ); |
|
369 for ( TInt i = 0; i < map->Pairs().Count(); ++i ) |
|
370 { |
|
371 pairs.Append( map->Pairs()[i] ); |
|
372 } |
|
373 |
|
374 // Reset the map so that the actual pairs are not deleted with |
|
375 // the map |
|
376 map->Reset(); |
|
377 CleanupStack::PopAndDestroy( 3 ); // map, stream, buf |
|
378 |
|
379 DLTRACEOUT(("Config count: %d", pairs.Count() )); |
|
380 return pairs; |
|
381 } |
|
382 |
|
383 |
|
384 // --------------------------------------------------------------------------- |
|
385 // NodeL |
|
386 // --------------------------------------------------------------------------- |
|
387 // |
|
388 MNcdNode* CNcdProviderProxy::NodeL( const TDesC& aNameSpaceId, |
|
389 const TDesC& aNodeId ) const |
|
390 { |
|
391 DLTRACEIN( ( "namespace: %S, id: %S", &aNameSpaceId, &aNodeId ) ); |
|
392 |
|
393 DASSERT( iNodeManager ); |
|
394 |
|
395 DLTRACE( ( "Getting node from the node manager" ) ); |
|
396 |
|
397 // NOTE!!! That the identifier is set here NULL! This is because |
|
398 // we do not know the actual UID here. But this uid value will be |
|
399 // replaced by the correct value when the server actually creates the |
|
400 // node. |
|
401 // NOTE ALSO!!! The server uri has not been set here for the node. So, |
|
402 // the server side should not use the uri when comparing nodes in this case. |
|
403 CNcdNodeIdentifier* identifier( |
|
404 CNcdNodeIdentifier::NewLC( aNameSpaceId, aNodeId, TUid::Null() ) ); |
|
405 |
|
406 // Node manager will handle the creation of the root. |
|
407 MNcdNode* node( &iNodeManager->NodeL( *identifier ) ); |
|
408 |
|
409 CleanupStack::PopAndDestroy( identifier ); |
|
410 |
|
411 // Increase also the reference counter by one here. |
|
412 // So, the root ref count is at least one when the user |
|
413 // gets it. |
|
414 DASSERT( node ); |
|
415 node->AddRef(); |
|
416 |
|
417 DLTRACEOUT( ( "" ) ); |
|
418 return node; |
|
419 } |
|
420 |
|
421 |
|
422 // --------------------------------------------------------------------------- |
|
423 // NodeL |
|
424 // --------------------------------------------------------------------------- |
|
425 // |
|
426 MNcdNode* CNcdProviderProxy::NodeL( const MNcdPurchaseDetails& aDetails ) const |
|
427 { |
|
428 DLTRACEIN(("")); |
|
429 |
|
430 // This function call will create the temporary node according to the |
|
431 // purchase details. Even if the node and its metadata does not exist |
|
432 // in the RAM cache or in the db, the server will create a metadata and |
|
433 // a temporary node according to the info gotten from the purchase details. |
|
434 MNcdNode* node( &iNodeManager->CreateTemporaryNodeL( aDetails ) ); |
|
435 |
|
436 // Increase also the reference counter by one here. |
|
437 // So, the root ref count is at least one when the user |
|
438 // gets it. |
|
439 DASSERT( node ); |
|
440 node->AddRef(); |
|
441 |
|
442 DLTRACEOUT(("")); |
|
443 |
|
444 return node; |
|
445 } |
|
446 |
|
447 |
|
448 // --------------------------------------------------------------------------- |
|
449 // SchemeNodeL |
|
450 // --------------------------------------------------------------------------- |
|
451 // |
|
452 MNcdNode* CNcdProviderProxy::SchemeNodeL( const TDesC& aNameSpaceId, |
|
453 const TDesC& aEntityId, |
|
454 const TDesC& aServerUri, |
|
455 TNcdSchemeNodeType aType, |
|
456 TBool aRemoveOnDisconnect, |
|
457 TBool aForceCreate ) const |
|
458 { |
|
459 DLTRACEIN((_L("namespace: %S, id: %S"), &aNameSpaceId, &aEntityId)); |
|
460 |
|
461 DASSERT( iNodeManager ); |
|
462 |
|
463 DLTRACE( ( "Getting node from the node manager" ) ); |
|
464 |
|
465 // NOTE!!! That the identifier is set here NULL! This is because |
|
466 // we do not know the actual UID here. But this uid value will be |
|
467 // replaced by the correct value when the server actually creates the |
|
468 // node. |
|
469 |
|
470 CNcdNodeIdentifier* identifier( |
|
471 CNcdNodeIdentifier::NewLC( |
|
472 aNameSpaceId, |
|
473 aEntityId, |
|
474 aServerUri, |
|
475 TUid::Null() ) ); |
|
476 |
|
477 if ( identifier->ContainsEmptyFields( ETrue, ETrue, ETrue, EFalse ) ) |
|
478 { |
|
479 DLINFO(("Empty identifier fields, leave KErrArgument")); |
|
480 User::Leave( KErrArgument ); |
|
481 } |
|
482 |
|
483 // Node manager will handle the creation of the scheme node. |
|
484 MNcdNode* node( NULL ); |
|
485 node = &iNodeManager->CreateSchemeNodeL( |
|
486 *identifier, aType, aRemoveOnDisconnect, aForceCreate ); |
|
487 |
|
488 CleanupStack::PopAndDestroy( identifier ); |
|
489 |
|
490 // Increase also the reference counter by one here. |
|
491 // So, the root ref count is at least one when the user |
|
492 // gets it. |
|
493 DASSERT( node ); |
|
494 |
|
495 node->AddRef(); |
|
496 DLINFO(("node state: %d", node->State() )); |
|
497 |
|
498 DLTRACEOUT(("")); |
|
499 return node; |
|
500 } |
|
501 |
|
502 |
|
503 // --------------------------------------------------------------------------- |
|
504 // SetStringLocalizer |
|
505 // --------------------------------------------------------------------------- |
|
506 // |
|
507 void CNcdProviderProxy::SetStringLocalizer( MNcdClientLocalizer& aLocalizer ) |
|
508 { |
|
509 iClientLocalizer = &aLocalizer; |
|
510 iOperationManager->SetClientLocalizer( aLocalizer ); |
|
511 } |
|
512 |
|
513 |
|
514 // --------------------------------------------------------------------------- |
|
515 // File download creator |
|
516 // --------------------------------------------------------------------------- |
|
517 // |
|
518 MNcdFileDownloadOperation* CNcdProviderProxy::DownloadFileL( const TDesC& aUri, |
|
519 const TDesC& aTargetFileName, |
|
520 MNcdFileDownloadOperationObserver& aObserver ) |
|
521 { |
|
522 DLTRACEIN(("")); |
|
523 DASSERT( iOperationManager ); |
|
524 |
|
525 MNcdFileDownloadOperation* dl = |
|
526 iOperationManager->CreateFileDownloadOperationL( |
|
527 ENcdGenericFileDownload, |
|
528 aUri, |
|
529 aTargetFileName, |
|
530 &aObserver ); |
|
531 |
|
532 DLTRACEOUT(("")); |
|
533 return dl; |
|
534 } |
|
535 |
|
536 |
|
537 // --------------------------------------------------------------------------- |
|
538 // Default access point setter |
|
539 // --------------------------------------------------------------------------- |
|
540 // |
|
541 void CNcdProviderProxy::SetDefaultConnectionMethodL( |
|
542 const TNcdConnectionMethod& aAccessPointId ) |
|
543 { |
|
544 DLTRACEIN(( "aAccessPointId type=%u, id=%u", |
|
545 aAccessPointId.iType, |
|
546 aAccessPointId.iId )); |
|
547 |
|
548 #ifdef __SERIES60_31__ |
|
549 if ( aAccessPointId.iType == ENcdConnectionMethodTypeDestination ) |
|
550 { |
|
551 DLERROR(("SNAPs are not supported in 3.1")); |
|
552 User::Leave( KErrNotSupported ); |
|
553 } |
|
554 #endif |
|
555 |
|
556 TPtrC8 input( reinterpret_cast< const TUint8*>( &aAccessPointId ), |
|
557 sizeof( aAccessPointId ) ); |
|
558 TInt err; // note: not used? |
|
559 |
|
560 // Send the config |
|
561 User::LeaveIfError( ClientServerSession().SendSync( |
|
562 CNcdProvider::ENcdProviderSetDefaultAccessPoint, |
|
563 input, |
|
564 err, |
|
565 Handle() ) ); |
|
566 |
|
567 DLTRACEOUT(("")); |
|
568 } |
|
569 |
|
570 |
|
571 // --------------------------------------------------------------------------- |
|
572 // Clears search results |
|
573 // --------------------------------------------------------------------------- |
|
574 // |
|
575 void CNcdProviderProxy::ClearSearchResultsL() |
|
576 { |
|
577 iNodeManager->ClearSearchResultsL(); |
|
578 } |
|
579 |
|
580 |
|
581 // --------------------------------------------------------------------------- |
|
582 // Clears client cache |
|
583 // --------------------------------------------------------------------------- |
|
584 // |
|
585 void CNcdProviderProxy::ClearCacheL( TRequestStatus& aStatus ) |
|
586 { |
|
587 DLTRACEIN(("")); |
|
588 |
|
589 iOperationManager->CancelAllOperations(); |
|
590 |
|
591 // AsyncMediator is used to internalize favorites after cache cleanup |
|
592 // because they may have changed due to database corruption |
|
593 delete iAsyncMediator; |
|
594 iAsyncMediator = NULL; |
|
595 |
|
596 iAsyncMediator = new( ELeave ) CCatalogsAsyncMediator( |
|
597 aStatus, |
|
598 TCallBack( &CNcdProviderProxy::InternalizeFavoriteManager, this ) ); |
|
599 |
|
600 // Notice that the proxy side node ram cache should be automatically cleared |
|
601 // when the UI has released the nodes. |
|
602 // This function is meant for the db cache clearing. |
|
603 ClientServerSession().SendAsync( |
|
604 CNcdProvider::ENcdProviderClearCache, |
|
605 KNullDesC8, |
|
606 iReturnBuf, |
|
607 Handle(), |
|
608 iAsyncMediator->iStatus ); |
|
609 |
|
610 iAsyncMediator->Activate(); |
|
611 DLTRACEOUT(("")); |
|
612 } |
|
613 |
|
614 |
|
615 // --------------------------------------------------------------------------- |
|
616 // Tells whether the SIM was changed since previous startup |
|
617 // --------------------------------------------------------------------------- |
|
618 // |
|
619 TBool CNcdProviderProxy::IsSimChangedL() |
|
620 { |
|
621 DLTRACEIN(("")); |
|
622 |
|
623 TInt isChanged; |
|
624 User::LeaveIfError( ClientServerSession().SendSync( |
|
625 CNcdProvider::ENcdProviderIsSimChanged, |
|
626 KNullDesC8, |
|
627 isChanged, |
|
628 Handle())); |
|
629 |
|
630 return isChanged; |
|
631 } |
|
632 |
|
633 |
|
634 // --------------------------------------------------------------------------- |
|
635 // Tells whether engine uses fixed access point |
|
636 // --------------------------------------------------------------------------- |
|
637 // |
|
638 TBool CNcdProviderProxy::IsFixedApL() |
|
639 { |
|
640 DLTRACEIN(("")); |
|
641 |
|
642 TInt isFixedAp; |
|
643 User::LeaveIfError( ClientServerSession().SendSync( |
|
644 CNcdProvider::ENcdProviderIsFixedAp, |
|
645 KNullDesC8, |
|
646 isFixedAp, |
|
647 Handle() ) ); |
|
648 |
|
649 return isFixedAp; |
|
650 } |
|
651 |
|
652 |
|
653 // --------------------------------------------------------------------------- |
|
654 // Downloads and installa a rights object |
|
655 // --------------------------------------------------------------------------- |
|
656 // |
|
657 MNcdRightsObjectOperation* CNcdProviderProxy::DownloadAndInstallRightsObjectL( |
|
658 MNcdRightsObjectOperationObserver& aObserver, |
|
659 const TDesC& aDownloadUri, |
|
660 const TDesC& aMimeType, |
|
661 const TNcdConnectionMethod& aConnectionMethod ) |
|
662 { |
|
663 DLTRACEIN(( _L("aDownloadUri=%S, aMimeType=%S"), |
|
664 &aDownloadUri, &aMimeType )); |
|
665 DASSERT( iOperationManager ); |
|
666 |
|
667 CNcdRightsObjectOperationProxy* op = |
|
668 iOperationManager->CreateRightsObjectOperationL( |
|
669 aDownloadUri, aMimeType, aConnectionMethod, aObserver ); |
|
670 |
|
671 return op; |
|
672 } |
|
673 |
|
674 |
|
675 // --------------------------------------------------------------------------- |
|
676 // Creates a new accesspoint |
|
677 // --------------------------------------------------------------------------- |
|
678 // |
|
679 MNcdCreateAccessPointOperation* CNcdProviderProxy::CreateAccessPointL( |
|
680 const TDesC& aAccessPointData, |
|
681 MNcdCreateAccessPointOperationObserver& aObserver ) |
|
682 { |
|
683 DLTRACEIN(("")); |
|
684 |
|
685 CNcdCreateAccessPointOperationProxy* op = |
|
686 iOperationManager->CreateCreateAccessPointOperationL( |
|
687 aAccessPointData, |
|
688 aObserver ); |
|
689 |
|
690 return op; |
|
691 } |
|
692 |
|
693 |
|
694 // --------------------------------------------------------------------------- |
|
695 // Send a HTTP request |
|
696 // --------------------------------------------------------------------------- |
|
697 // |
|
698 MNcdSendHttpRequestOperation* CNcdProviderProxy::SendHttpRequestL( |
|
699 const TDesC8& aUri, |
|
700 const TDesC8& aRequest, |
|
701 const TNcdConnectionMethod& aConnectionMethod, |
|
702 MNcdSendHttpRequestOperationObserver& aObserver ) |
|
703 { |
|
704 DLTRACEIN(("")); |
|
705 CNcdSendHttpRequestOperationProxy* op = |
|
706 iOperationManager->CreateSendHttpRequestOperationL( |
|
707 aUri, |
|
708 aRequest, |
|
709 aConnectionMethod, |
|
710 aObserver ); |
|
711 return op; |
|
712 |
|
713 } |
|
714 |
|
715 |
|
716 // --------------------------------------------------------------------------- |
|
717 // Cliend ID getter |
|
718 // --------------------------------------------------------------------------- |
|
719 // |
|
720 HBufC* CNcdProviderProxy::ClientIdL() |
|
721 { |
|
722 DLTRACEIN(("")); |
|
723 |
|
724 |
|
725 RBuf clientId; |
|
726 clientId.CleanupClosePushL(); |
|
727 clientId.CreateL( NcdProviderDefines::KClientIdMaxLength ); |
|
728 User::LeaveIfError( ClientServerSession().SendSync( |
|
729 CNcdProvider::ENcdProviderClientId, |
|
730 KNullDesC, |
|
731 clientId, |
|
732 Handle() ) ); |
|
733 |
|
734 HBufC* copy = clientId.AllocL(); |
|
735 CleanupStack::PopAndDestroy( &clientId ); |
|
736 return copy; |
|
737 } |
|
738 |
|
739 |
|
740 // --------------------------------------------------------------------------- |
|
741 // Engine type getter |
|
742 // --------------------------------------------------------------------------- |
|
743 // |
|
744 HBufC* CNcdProviderProxy::EngineTypeL() |
|
745 { |
|
746 return GetInfoFromProviderL( CNcdProvider::ENcdProviderInfoType ); |
|
747 } |
|
748 |
|
749 // --------------------------------------------------------------------------- |
|
750 // Engine version getter |
|
751 // --------------------------------------------------------------------------- |
|
752 // |
|
753 HBufC* CNcdProviderProxy::EngineVersionL() |
|
754 { |
|
755 return GetInfoFromProviderL( CNcdProvider::ENcdProviderInfoVersion ); |
|
756 } |
|
757 |
|
758 |
|
759 // --------------------------------------------------------------------------- |
|
760 // Engine provisioning getter |
|
761 // --------------------------------------------------------------------------- |
|
762 // |
|
763 HBufC* CNcdProviderProxy::EngineProvisioningL() |
|
764 { |
|
765 return GetInfoFromProviderL( CNcdProvider::ENcdProviderInfoProvisioning ); |
|
766 } |
|
767 |
|
768 |
|
769 // --------------------------------------------------------------------------- |
|
770 // Engine UID getter |
|
771 // --------------------------------------------------------------------------- |
|
772 // |
|
773 HBufC* CNcdProviderProxy::EngineUidL() |
|
774 { |
|
775 return GetInfoFromProviderL( CNcdProvider::ENcdProviderInfoUid ); |
|
776 } |
|
777 |
|
778 |
|
779 // --------------------------------------------------------------------------- |
|
780 // Constructor |
|
781 // --------------------------------------------------------------------------- |
|
782 // |
|
783 CNcdProviderProxy::CNcdProviderProxy( MCatalogsClientServer& aSession, |
|
784 TInt aHandle ) |
|
785 : CNcdInterfaceBaseProxy( aSession, aHandle, NULL ) |
|
786 { |
|
787 SetReleaseId( CNcdProvider::ENcdProviderRelease ); |
|
788 } |
|
789 |
|
790 |
|
791 // --------------------------------------------------------------------------- |
|
792 // ConstructL |
|
793 // --------------------------------------------------------------------------- |
|
794 // |
|
795 void CNcdProviderProxy::ConstructL() |
|
796 { |
|
797 DLTRACEIN(("")); |
|
798 |
|
799 // Register the interfaces |
|
800 MNcdProvider* provider( this ); |
|
801 AddInterfaceL( |
|
802 CCatalogsInterfaceIdentifier::NewL( provider, this, |
|
803 MNcdProvider::KInterfaceUid ) ); |
|
804 |
|
805 MNcdProviderPcClientSupport* support( this ); |
|
806 AddInterfaceL( |
|
807 CCatalogsInterfaceIdentifier::NewL( support, this, |
|
808 MNcdProviderPcClientSupport::KInterfaceUid ) ); |
|
809 |
|
810 MNcdDebugInformation* debugInfo( this ); |
|
811 AddInterfaceL( |
|
812 CCatalogsInterfaceIdentifier::NewL( debugInfo, this, |
|
813 MNcdDebugInformation::KInterfaceUid ) ); |
|
814 |
|
815 DLTRACE(("Base construct done")); |
|
816 |
|
817 // Create managers |
|
818 // First operation manager because node manager uses it. |
|
819 CreateOperationManagerL(); |
|
820 |
|
821 DLTRACE(("Operationmanager done")); |
|
822 |
|
823 CreateSubscriptionManagerL(); |
|
824 |
|
825 CreateNodeManagerL(); |
|
826 |
|
827 DLTRACE(("Nodemanager done")); |
|
828 |
|
829 iSubscriptionManager->SetNodeManager( iNodeManager ); |
|
830 DLTRACE(("Subscriptionmanager done")); |
|
831 |
|
832 CreatePurchaseHistoryL(); |
|
833 |
|
834 DLTRACE(("Purchase history done")); |
|
835 |
|
836 CreateFavoriteManagerL(); |
|
837 |
|
838 iNodeManager->SetFavoriteManager( *iFavoriteManager ); |
|
839 |
|
840 CreateServerReportManagerL(); |
|
841 |
|
842 DLTRACE(("Favoritemanager done")); |
|
843 |
|
844 // This restores downloads from previous sessions |
|
845 // NOTE: loads nodes and does other crazy stuff so keep it last |
|
846 iOperationManager->RestoreContentDownloadsL(); |
|
847 |
|
848 } |
|
849 |
|
850 |
|
851 // --------------------------------------------------------------------------- |
|
852 // CreateNodeManagerL |
|
853 // --------------------------------------------------------------------------- |
|
854 // |
|
855 void CNcdProviderProxy::CreateNodeManagerL() |
|
856 { |
|
857 DLTRACEIN(("")); |
|
858 // Get the handle for the manager from the provider |
|
859 TInt nodeManagerHandle( 0 ); |
|
860 User::LeaveIfError( |
|
861 ClientServerSession(). |
|
862 SendSync( CNcdProvider::ENcdProviderNodeManagerHandle, |
|
863 KNullDesC, |
|
864 nodeManagerHandle, |
|
865 Handle() ) ); |
|
866 |
|
867 // Use the same session for the manager as for the provider |
|
868 iNodeManager = |
|
869 CNcdNodeManagerProxy::NewL( ClientServerSession(), |
|
870 nodeManagerHandle, |
|
871 *iOperationManager, |
|
872 *iSubscriptionManager, |
|
873 *this ); |
|
874 DLTRACEOUT(("")); |
|
875 } |
|
876 |
|
877 |
|
878 // --------------------------------------------------------------------------- |
|
879 // CreatePurchaseHistoryL |
|
880 // --------------------------------------------------------------------------- |
|
881 // |
|
882 void CNcdProviderProxy::CreatePurchaseHistoryL() |
|
883 { |
|
884 DLTRACEIN(("")); |
|
885 // Get the handle for the manager from the provider |
|
886 TInt purchaseHistoryHandle( 0 ); |
|
887 User::LeaveIfError( |
|
888 ClientServerSession().SendSync( |
|
889 CNcdProvider::ENcdProviderPurchaseHistoryHandle, |
|
890 KNullDesC, |
|
891 purchaseHistoryHandle, |
|
892 Handle() ) ); |
|
893 |
|
894 // Use the same session for the manager as for the provider |
|
895 iPurchaseHistory = |
|
896 CNcdPurchaseHistoryProxy::NewL( |
|
897 ClientServerSession(), |
|
898 purchaseHistoryHandle, |
|
899 this, |
|
900 *iOperationManager ); |
|
901 DLTRACEOUT(("")); |
|
902 } |
|
903 |
|
904 |
|
905 // --------------------------------------------------------------------------- |
|
906 // CreateOperationManagerL |
|
907 // --------------------------------------------------------------------------- |
|
908 // |
|
909 void CNcdProviderProxy::CreateOperationManagerL() |
|
910 { |
|
911 |
|
912 DLTRACEIN(("")); |
|
913 |
|
914 // Get the handle for the manager from the provider |
|
915 TInt operationManagerHandle( 0 ); |
|
916 |
|
917 DLTRACE(("Before session")); |
|
918 MCatalogsClientServer& session = ClientServerSession(); |
|
919 DLTRACE(("After session: %X", &session)); |
|
920 |
|
921 User::LeaveIfError( |
|
922 ClientServerSession(). |
|
923 SendSync( CNcdProvider::ENcdProviderOperationManagerHandle, |
|
924 KNullDesC, |
|
925 operationManagerHandle, |
|
926 Handle() ) ); |
|
927 |
|
928 DLTRACE(("Send done")); |
|
929 |
|
930 // Use the same session for the manager as for the provider |
|
931 iOperationManager = |
|
932 CNcdOperationManagerProxy::NewL( ClientServerSession(), |
|
933 operationManagerHandle ); |
|
934 DLTRACE(("Opmanager done")); |
|
935 |
|
936 } |
|
937 |
|
938 // --------------------------------------------------------------------------- |
|
939 // CreateSubscriptionManagerL |
|
940 // --------------------------------------------------------------------------- |
|
941 // |
|
942 void CNcdProviderProxy::CreateSubscriptionManagerL() |
|
943 { |
|
944 DLTRACEIN(("")); |
|
945 // Get the handle for the manager from the provider |
|
946 TInt subscriptionManagerHandle( 0 ); |
|
947 User::LeaveIfError( |
|
948 ClientServerSession(). |
|
949 SendSync( |
|
950 CNcdProvider::ENcdProviderSubscriptionManagerHandle, |
|
951 KNullDesC, |
|
952 subscriptionManagerHandle, |
|
953 Handle() ) ); |
|
954 |
|
955 // Use the same session for the manager as for the provider |
|
956 iSubscriptionManager = |
|
957 CNcdSubscriptionManagerProxy::NewL( ClientServerSession(), |
|
958 subscriptionManagerHandle, |
|
959 this, |
|
960 *iOperationManager ); |
|
961 DLTRACEOUT(("")); |
|
962 } |
|
963 |
|
964 |
|
965 // --------------------------------------------------------------------------- |
|
966 // CreateFavoriteManagerL |
|
967 // --------------------------------------------------------------------------- |
|
968 // |
|
969 void CNcdProviderProxy::CreateFavoriteManagerL() |
|
970 { |
|
971 DLTRACEIN(("")); |
|
972 // Get the handle for the manager from the provider |
|
973 TInt favoriteManagerHandle( 0 ); |
|
974 User::LeaveIfError( |
|
975 ClientServerSession(). |
|
976 SendSync( |
|
977 CNcdProvider::ENcdProviderFavoriteManagerHandle, |
|
978 KNullDesC, |
|
979 favoriteManagerHandle, |
|
980 Handle() ) ); |
|
981 |
|
982 // Use the same session for the manager as for the provider |
|
983 iFavoriteManager = |
|
984 CNcdFavoriteManagerProxy::NewL( ClientServerSession(), |
|
985 favoriteManagerHandle, |
|
986 this, |
|
987 *iNodeManager ); |
|
988 DLTRACEOUT(("")); |
|
989 } |
|
990 |
|
991 |
|
992 // --------------------------------------------------------------------------- |
|
993 // |
|
994 // --------------------------------------------------------------------------- |
|
995 // |
|
996 void CNcdProviderProxy::CreateServerReportManagerL() |
|
997 { |
|
998 DLTRACEIN(("")); |
|
999 // Get the handle for the manager from the provider |
|
1000 TInt managerHandle( 0 ); |
|
1001 User::LeaveIfError( |
|
1002 ClientServerSession(). |
|
1003 SendSync( |
|
1004 CNcdProvider::ENcdProviderServerReportManagerHandle, |
|
1005 KNullDesC, |
|
1006 managerHandle, |
|
1007 Handle() ) ); |
|
1008 |
|
1009 // Use the same session for the manager as for the provider |
|
1010 iServerReportManager = |
|
1011 CNcdServerReportManagerProxy::NewL( ClientServerSession(), |
|
1012 managerHandle, |
|
1013 *this ); |
|
1014 DLTRACEOUT(("")); |
|
1015 } |
|
1016 |
|
1017 |
|
1018 // --------------------------------------------------------------------------- |
|
1019 // |
|
1020 // --------------------------------------------------------------------------- |
|
1021 // |
|
1022 HBufC* CNcdProviderProxy::GetInfoFromProviderL( |
|
1023 TInt aInfoIndex ) |
|
1024 { |
|
1025 // Write aInfo to a descriptor |
|
1026 TBuf<1> info; |
|
1027 info.SetLength( 1 ); |
|
1028 info[0] = aInfoIndex; |
|
1029 |
|
1030 HBufC* data( NULL ); |
|
1031 // Because we do not know the exact size of the data, use |
|
1032 // the alloc method, which creates the buffer of the right size |
|
1033 // and sets the pointer to point to the created buffer. |
|
1034 User::LeaveIfError( |
|
1035 ClientServerSession(). |
|
1036 SendSyncAlloc( CNcdProvider::ENcdGetProviderInfo, |
|
1037 info, |
|
1038 data, |
|
1039 Handle(), |
|
1040 0 ) ); |
|
1041 |
|
1042 if ( data == NULL ) |
|
1043 { |
|
1044 User::Leave( KErrNotFound ); |
|
1045 } |
|
1046 return data; |
|
1047 } |
|
1048 |
|
1049 |
|
1050 // --------------------------------------------------------------------------- |
|
1051 // |
|
1052 // --------------------------------------------------------------------------- |
|
1053 // |
|
1054 void CNcdProviderProxy::InternalizeFavoriteManagerL() |
|
1055 { |
|
1056 DLTRACEIN(("")); |
|
1057 iFavoriteManager->InternalizeL(); |
|
1058 } |
|
1059 |
|
1060 |
|
1061 // --------------------------------------------------------------------------- |
|
1062 // Given to TCallBack when clearing cache |
|
1063 // --------------------------------------------------------------------------- |
|
1064 // |
|
1065 TInt CNcdProviderProxy::InternalizeFavoriteManager( TAny* aProvider ) |
|
1066 { |
|
1067 DLTRACEIN(("")); |
|
1068 CNcdProviderProxy* provider = |
|
1069 static_cast<CNcdProviderProxy*>( aProvider ); |
|
1070 DASSERT( provider ); |
|
1071 TRAPD( err, provider->InternalizeFavoriteManagerL() ); |
|
1072 return err; |
|
1073 } |