|
1 /* |
|
2 * Copyright (c) 2007-2009 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: This module contains the implementation of CIAUpdateBaseNode class |
|
15 * member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include <ncdprovider.h> |
|
22 #include <ncdnode.h> |
|
23 #include <ncdnodemetadata.h> |
|
24 #include <ncdnodepurchase.h> |
|
25 #include <ncdnodecontentinfo.h> |
|
26 #include <ncdpurchasehistory.h> |
|
27 #include <ncdutils.h> |
|
28 #include <catalogsutils.h> |
|
29 |
|
30 #include "iaupdatebasenodeimpl.h" |
|
31 #include "iaupdatenodedetails.h" |
|
32 #include "iaupdatecontrollerimpl.h" |
|
33 #include "iaupdatecontentoperationmanager.h" |
|
34 #include "iaupdateutils.h" |
|
35 #include "iaupdatectrlnodeconsts.h" |
|
36 #include "iaupdatedebug.h" |
|
37 #include "iaupdateprotocolconsts.h" |
|
38 |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CIAUpdateBaseNode::CIAUpdateBaseNode |
|
42 // C++ default constructor can NOT contain any code, that |
|
43 // might leave. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CIAUpdateBaseNode::CIAUpdateBaseNode( CIAUpdateController& aController ) |
|
47 : CBase(), |
|
48 iController( aController ) |
|
49 { |
|
50 } |
|
51 |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CIAUpdateBaseNode::ConstructL |
|
55 // Symbian 2nd phase constructor can leave. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 void CIAUpdateBaseNode::ConstructL( MNcdNode* aNode ) |
|
59 { |
|
60 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::ConstructL() begin"); |
|
61 |
|
62 if ( !aNode ) |
|
63 { |
|
64 // Do not accept NULL node. |
|
65 User::Leave( KErrArgument ); |
|
66 } |
|
67 |
|
68 // Here we initialize metadata, details and contentinfo. |
|
69 // The metadata, its details and content info should remain same even if |
|
70 // update related operations are done. So, they can be created here and there |
|
71 // is no need to update that information during the lifetime of this node. |
|
72 // If the node is updated from the net server, then this whole node should be |
|
73 // recreated. Or, these object should be updated in correct places. |
|
74 |
|
75 MNcdNodeMetadata* metaData = aNode->QueryInterfaceLC< MNcdNodeMetadata >(); |
|
76 if ( metaData ) |
|
77 { |
|
78 // Also update details information from the metadata. |
|
79 iMetaNamespace = metaData->Namespace().AllocL(); |
|
80 iMetaId = metaData->Id().AllocL(); |
|
81 SetNameL( *metaData ); |
|
82 iDescription = metaData->Description().AllocL(); |
|
83 IAUPDATE_TRACE_1("[IAUPDATE] description: %S", iDescription ); |
|
84 // Notice, that ownership of metadata is not transferred here. |
|
85 iDetails = CIAUpdateNodeDetails::NewL( metaData ); |
|
86 CleanupStack::PopAndDestroy( metaData ); |
|
87 metaData = NULL; |
|
88 } |
|
89 else |
|
90 { |
|
91 // Just leave, because important information is missing. |
|
92 // We should always have metadata when this node is created. |
|
93 User::Leave( KErrNotFound ); |
|
94 } |
|
95 |
|
96 // Get information from content info. |
|
97 // These we have to set here because we can not just pass this information |
|
98 // as it is given from the engine and we also take the ownership of the final |
|
99 // result. |
|
100 MNcdNodeContentInfo* contentInfo = aNode->QueryInterfaceLC< MNcdNodeContentInfo >(); |
|
101 if ( contentInfo ) |
|
102 { |
|
103 iMime = contentInfo->MimeType().AllocL(); |
|
104 iVersion.InternalizeL( contentInfo->Version() ); |
|
105 iUid = contentInfo->Uid(); |
|
106 // Release content info. |
|
107 // So, we can later check if it still exists and then get |
|
108 // new one if it exists. |
|
109 CleanupStack::PopAndDestroy( contentInfo ); |
|
110 contentInfo = NULL; |
|
111 } |
|
112 else |
|
113 { |
|
114 // Just leave, because important information is missing like |
|
115 // content UID. |
|
116 User::Leave( KErrNotFound ); |
|
117 } |
|
118 |
|
119 // Not, that this function can not leave any more it is safe to take the |
|
120 // ownership of the node. Now, the user that called this function can safely |
|
121 // pop the node from the cleanup stack. |
|
122 iNode = aNode; |
|
123 |
|
124 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::ConstructL() end"); |
|
125 } |
|
126 |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CIAUpdateBaseNode::~CIAUpdateBaseNode |
|
130 // Destructor |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 CIAUpdateBaseNode::~CIAUpdateBaseNode() |
|
134 { |
|
135 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::~CIAUpdateBaseNode() begin"); |
|
136 |
|
137 if ( iNode ) |
|
138 { |
|
139 iNode->Release(); |
|
140 } |
|
141 |
|
142 delete iMetaNamespace; |
|
143 delete iMetaId; |
|
144 delete iName; |
|
145 delete iDescription; |
|
146 delete iMime; |
|
147 delete iDetails; |
|
148 |
|
149 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::~CIAUpdateBaseNode() end"); |
|
150 } |
|
151 |
|
152 |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // MIAUpdateNode functions |
|
156 // --------------------------------------------------------------------------- |
|
157 |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CIAUpdateBaseNode::MetaNamespace |
|
161 // |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 const TDesC& CIAUpdateBaseNode::MetaNamespace() const |
|
165 { |
|
166 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateBaseNode::MetaNamespace() = %S", |
|
167 iMetaNamespace); |
|
168 return *iMetaNamespace; |
|
169 } |
|
170 |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // CIAUpdateBaseNode::MetaId |
|
174 // |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 const TDesC& CIAUpdateBaseNode::MetaId() const |
|
178 { |
|
179 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateBaseNode::MetaId() = %S", iMetaId); |
|
180 return *iMetaId; |
|
181 } |
|
182 |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // CIAUpdateBaseNode::Uid |
|
186 // |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 const TUid& CIAUpdateBaseNode::Uid() const |
|
190 { |
|
191 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateBaseNode::Uid() = %x", iUid); |
|
192 return iUid; |
|
193 } |
|
194 |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // CIAUpdateBaseNode::Name |
|
198 // |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 const TDesC &CIAUpdateBaseNode::Name() const |
|
202 { |
|
203 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateBaseNode::Name() = %S", iName); |
|
204 return *iName; |
|
205 } |
|
206 |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // CIAUpdateBaseNode::Description |
|
210 // |
|
211 // --------------------------------------------------------------------------- |
|
212 // |
|
213 const TDesC& CIAUpdateBaseNode::Description() const |
|
214 { |
|
215 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateBaseNode::Description() = %S", |
|
216 iDescription); |
|
217 return *iDescription; |
|
218 } |
|
219 |
|
220 |
|
221 // --------------------------------------------------------------------------- |
|
222 // CIAUpdateBaseNode::ContentSize |
|
223 // |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 TInt CIAUpdateBaseNode::ContentSizeL() const |
|
227 { |
|
228 // Notice, here we give the content size through the interface. |
|
229 // See OwnContentSizeL for the size that has been gotten from the server. |
|
230 // It will be given as a default, if child classes do not implement this. |
|
231 return OwnContentSizeL(); |
|
232 } |
|
233 |
|
234 |
|
235 // --------------------------------------------------------------------------- |
|
236 // CIAUpdateBaseNode::Version |
|
237 // |
|
238 // --------------------------------------------------------------------------- |
|
239 // |
|
240 const TIAUpdateVersion& CIAUpdateBaseNode::Version() const |
|
241 { |
|
242 return iVersion; |
|
243 } |
|
244 |
|
245 |
|
246 // --------------------------------------------------------------------------- |
|
247 // CIAUpdateBaseNode::Importance |
|
248 // |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 MIAUpdateBaseNode::TImportance CIAUpdateBaseNode::Importance() const |
|
252 { |
|
253 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateBaseNode::Importance() = %d", |
|
254 Details().Importance()); |
|
255 return Details().Importance(); |
|
256 } |
|
257 |
|
258 void CIAUpdateBaseNode::SetImportance( MIAUpdateBaseNode::TImportance aImportance ) |
|
259 { |
|
260 Details().SetImportance( aImportance ); |
|
261 } |
|
262 // --------------------------------------------------------------------------- |
|
263 // CIAUpdateBaseNode::SearchCriteria |
|
264 // |
|
265 // --------------------------------------------------------------------------- |
|
266 // |
|
267 const TDesC& CIAUpdateBaseNode::SearchCriteria() const |
|
268 { |
|
269 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateBaseNode::SearchCriteria() = %S", |
|
270 &Details().SearchCriteria()); |
|
271 return Details().SearchCriteria(); |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // CIAUpdateBaseNode::RebootAfterInstall |
|
276 // |
|
277 // --------------------------------------------------------------------------- |
|
278 // |
|
279 TBool CIAUpdateBaseNode::RebootAfterInstall() const |
|
280 { |
|
281 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateBaseNode::RebootAfterInstall() = %d", |
|
282 Details().RebootAfterInstall()); |
|
283 return Details().RebootAfterInstall(); |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // CIAUpdateBaseNode::Hidden |
|
288 // |
|
289 // --------------------------------------------------------------------------- |
|
290 // |
|
291 TBool CIAUpdateBaseNode::Hidden() const |
|
292 { |
|
293 TBool hidden( EFalse ); |
|
294 if ( iForcedHidden |
|
295 || Details().Importance() == MIAUpdateBaseNode::EHidden ) |
|
296 { |
|
297 hidden = ETrue; |
|
298 } |
|
299 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateBaseNode::Hidden() = %d", hidden); |
|
300 return hidden; |
|
301 } |
|
302 |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // CIAUpdateBaseNode::SetSelected |
|
306 // |
|
307 // --------------------------------------------------------------------------- |
|
308 // |
|
309 void CIAUpdateBaseNode::SetSelected( TBool aSelected ) |
|
310 { |
|
311 iSelected = aSelected; |
|
312 } |
|
313 |
|
314 |
|
315 // --------------------------------------------------------------------------- |
|
316 // CIAUpdateBaseNode::IsSelected |
|
317 // |
|
318 // --------------------------------------------------------------------------- |
|
319 // |
|
320 |
|
321 TBool CIAUpdateBaseNode::IsSelected() const |
|
322 { |
|
323 return iSelected; |
|
324 } |
|
325 |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // CIAUpdateBaseNode::LastUpdateErrorCodeL() |
|
329 // |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 TInt CIAUpdateBaseNode::LastUpdateErrorCodeL() const |
|
333 { |
|
334 return CIAUpdateContentOperationManager::CheckErrorCode( |
|
335 LastUpdateErrorCodeFromPurchaseHistoryL() ); |
|
336 } |
|
337 |
|
338 |
|
339 // --------------------------------------------------------------------------- |
|
340 // CIAUpdateBaseNode::SetIdleCancelToPurchaseHistoryL |
|
341 // |
|
342 // --------------------------------------------------------------------------- |
|
343 // |
|
344 void CIAUpdateBaseNode::SetIdleCancelToPurchaseHistoryL( |
|
345 TBool aForceVisibleInHistory ) |
|
346 { |
|
347 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::SetIdleCancelToPurchaseHistoryL() begin"); |
|
348 |
|
349 SetIdleErrorToPurchaseHistoryL( KErrCancel, aForceVisibleInHistory ); |
|
350 |
|
351 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::SetIdleCancelToPurchaseHistoryL() end"); |
|
352 } |
|
353 |
|
354 |
|
355 // --------------------------------------------------------------------------- |
|
356 // CIAUpdateBaseNode::SetInstallStatusToPurchaseHistoryL |
|
357 // |
|
358 // --------------------------------------------------------------------------- |
|
359 // |
|
360 void CIAUpdateBaseNode::SetInstallStatusToPurchaseHistoryL( |
|
361 TInt aErrorCode, TBool aForceVisibleInHistory ) |
|
362 { |
|
363 IAUPDATE_TRACE_2("[IAUPDATE] CIAUpdateBaseNode::SetInstallStatusToPurchaseHistoryL(): %d, %d", |
|
364 aErrorCode, aForceVisibleInHistory); |
|
365 (void)aErrorCode; |
|
366 (void)aForceVisibleInHistory; |
|
367 // Nothing to do here because install status is automatically set into the |
|
368 // purchase history when normal nodes are used. |
|
369 // Child classes may have their own implementation here. |
|
370 return; |
|
371 } |
|
372 |
|
373 |
|
374 // --------------------------------------------------------------------------- |
|
375 // Public functions |
|
376 // --------------------------------------------------------------------------- |
|
377 |
|
378 |
|
379 // --------------------------------------------------------------------------- |
|
380 // CIAUpdateBaseNode::SetIdleErrorToPurchaseHistoryL |
|
381 // |
|
382 // --------------------------------------------------------------------------- |
|
383 // |
|
384 void CIAUpdateBaseNode::SetIdleErrorToPurchaseHistoryL( |
|
385 TInt aError, TBool aForceVisibleInHistory ) |
|
386 { |
|
387 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::SetIdleErrorToPurchaseHistoryL() begin"); |
|
388 |
|
389 // Update the current node information to the purchase history. |
|
390 |
|
391 // Create a new purchase detail. |
|
392 CNcdPurchaseDetails* details( PurchaseDetailsLC() ); |
|
393 |
|
394 // Set the current universal time. |
|
395 // So, that item is the newest in the purhcase history list. |
|
396 details->SetLastUniversalOperationTime(); |
|
397 |
|
398 // The operation was cancelled. |
|
399 details->SetLastOperationErrorCode( aError ); |
|
400 |
|
401 // Because item should be forced as visible in history, |
|
402 // remove the hidden postfix if necessary. |
|
403 if ( aForceVisibleInHistory ) |
|
404 { |
|
405 IAUPDATE_TRACE("[IAUPDATE] Change purchase history MIME to visible"); |
|
406 TInt postfixIndex( |
|
407 iMime->Match( IAUpdateCtrlNodeConsts::KMimeHiddenPostfixPattern() ) ); |
|
408 if ( postfixIndex != KErrNotFound ) |
|
409 { |
|
410 IAUPDATE_TRACE("[IAUPDATE] Hidden postfix found. Omit it."); |
|
411 details->SetAttributeL( |
|
412 MNcdPurchaseDetails::EPurchaseAttributeContentMimeType, |
|
413 iMime->Left( postfixIndex ) ); |
|
414 } |
|
415 } |
|
416 |
|
417 // Get the purchase history and save the purchase detail information there. |
|
418 MNcdPurchaseHistory* history( iController.ProviderL().PurchaseHistoryL() ); |
|
419 CleanupReleasePushL( *history ); |
|
420 |
|
421 history->SavePurchaseL( *details ); |
|
422 |
|
423 CleanupStack::PopAndDestroy( history ); |
|
424 |
|
425 CleanupStack::PopAndDestroy( details ); |
|
426 |
|
427 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::SetIdleErrorToPurchaseHistoryL() end"); |
|
428 } |
|
429 |
|
430 |
|
431 // --------------------------------------------------------------------------- |
|
432 // CIAUpdateBaseNode::Equals |
|
433 // |
|
434 // --------------------------------------------------------------------------- |
|
435 // |
|
436 TBool CIAUpdateBaseNode::Equals( const CIAUpdateBaseNode& aNode ) const |
|
437 { |
|
438 if ( aNode.MetaNamespace() == MetaNamespace() |
|
439 && aNode.MetaId() == MetaId() |
|
440 || ( aNode.Uid() == Uid() |
|
441 && aNode.Version() == Version() |
|
442 && aNode.iMime->Match( IAUpdateProtocolConsts::KMimeServicePackPattern()) == KErrNotFound ) ) //MTA: Changed!!!!! |
|
443 { |
|
444 return ETrue; |
|
445 } |
|
446 else |
|
447 { |
|
448 return EFalse; |
|
449 } |
|
450 } |
|
451 |
|
452 |
|
453 // --------------------------------------------------------------------------- |
|
454 // CIAUpdateBaseNode::ForceHidden |
|
455 // |
|
456 // --------------------------------------------------------------------------- |
|
457 // |
|
458 void CIAUpdateBaseNode::ForceHidden( TBool aHidden ) |
|
459 { |
|
460 iForcedHidden = aHidden; |
|
461 } |
|
462 |
|
463 |
|
464 // --------------------------------------------------------------------------- |
|
465 // CIAUpdateBaseNode::OwnContentSizeL() |
|
466 // |
|
467 // --------------------------------------------------------------------------- |
|
468 // |
|
469 TInt CIAUpdateBaseNode::OwnContentSizeL() const |
|
470 { |
|
471 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::OwnContentSizeL() begin"); |
|
472 |
|
473 // Set the default size to zero. |
|
474 // We should always have content info and get the correct value |
|
475 // from there. But, if content info is not available, then |
|
476 // zero is only thing we can give here. |
|
477 TInt retSize( 0 ); |
|
478 |
|
479 // Get information from content info. |
|
480 MNcdNodeContentInfo* contentInfo( |
|
481 iNode->QueryInterfaceL< MNcdNodeContentInfo >() ); |
|
482 if ( contentInfo ) |
|
483 { |
|
484 IAUPDATE_TRACE("[IAUPDATE] Content info interface found"); |
|
485 // Content info existed. So, get the size info. |
|
486 retSize = contentInfo->Size(); |
|
487 // Release content info. |
|
488 // So, we can later check if it still exists and then get |
|
489 // new one if it exists. |
|
490 contentInfo->Release(); |
|
491 contentInfo = NULL; |
|
492 } |
|
493 |
|
494 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateBaseNode::OwnContentSizeL() end: %d", |
|
495 retSize); |
|
496 |
|
497 return retSize; |
|
498 } |
|
499 |
|
500 |
|
501 // --------------------------------------------------------------------------- |
|
502 // CIAUpdateBaseNode::Details |
|
503 // |
|
504 // --------------------------------------------------------------------------- |
|
505 // |
|
506 CIAUpdateNodeDetails& CIAUpdateBaseNode::Details() const |
|
507 { |
|
508 return *iDetails; |
|
509 } |
|
510 |
|
511 |
|
512 // --------------------------------------------------------------------------- |
|
513 // CIAUpdateBaseNode::Controller |
|
514 // |
|
515 // --------------------------------------------------------------------------- |
|
516 // |
|
517 CIAUpdateController& CIAUpdateBaseNode::Controller() const |
|
518 { |
|
519 return iController; |
|
520 } |
|
521 |
|
522 |
|
523 // --------------------------------------------------------------------------- |
|
524 // CIAUpdateBaseNode::Node |
|
525 // |
|
526 // --------------------------------------------------------------------------- |
|
527 // |
|
528 MNcdNode& CIAUpdateBaseNode::Node() const |
|
529 { |
|
530 return *iNode; |
|
531 } |
|
532 |
|
533 |
|
534 // --------------------------------------------------------------------------- |
|
535 // CIAUpdateBaseNode::LastUpdateErrorCodeFromPurchaseHistoryL |
|
536 // |
|
537 // --------------------------------------------------------------------------- |
|
538 // |
|
539 TInt CIAUpdateBaseNode::LastUpdateErrorCodeFromPurchaseHistoryL() const |
|
540 { |
|
541 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::LastUpdateErrorCodeFromPurchaseHistoryL() begin"); |
|
542 |
|
543 TInt errorCode( KErrNone ); |
|
544 |
|
545 // Get the error code of the last operation. |
|
546 // Purchase history provides a good place to get this. |
|
547 |
|
548 // Create filter. So, we will get |
|
549 // all the purchase history items. |
|
550 CNcdPurchaseHistoryFilter* filter = |
|
551 CNcdPurchaseHistoryFilter::NewLC(); |
|
552 filter->SetNamespaceL( MetaNamespace() ); |
|
553 filter->SetEntityIdL( MetaId() ); |
|
554 |
|
555 // Add family uid to the filter |
|
556 RArray< TUid > uids; |
|
557 CleanupClosePushL( uids ); |
|
558 uids.AppendL( iController.FamilyUid() ); |
|
559 filter->SetClientUids( uids.Array() ); |
|
560 CleanupStack::PopAndDestroy( &uids ); |
|
561 |
|
562 MNcdPurchaseHistory* history( iController.ProviderL().PurchaseHistoryL() ); |
|
563 CleanupReleasePushL( *history ); |
|
564 |
|
565 // Get the ids. So, we can next get all the corresponding |
|
566 // details. |
|
567 RArray< TUint > ids = history->PurchaseIdsL( *filter ); |
|
568 // Temporarily remove history from cleanup stack |
|
569 CleanupStack::Pop( history ); |
|
570 CleanupStack::PopAndDestroy( filter ); |
|
571 CleanupReleasePushL( *history ); |
|
572 CleanupClosePushL( ids ); |
|
573 |
|
574 if ( ids.Count() > 0 ) |
|
575 { |
|
576 CNcdPurchaseDetails* details( |
|
577 history->PurchaseDetailsL( ids[ 0 ] , EFalse ) ); |
|
578 if ( details ) |
|
579 { |
|
580 errorCode = details->LastOperationErrorCode(); |
|
581 delete details; |
|
582 details = NULL; |
|
583 } |
|
584 } |
|
585 |
|
586 CleanupStack::PopAndDestroy( &ids ); |
|
587 CleanupStack::PopAndDestroy( history ); |
|
588 |
|
589 IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", errorCode ); |
|
590 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::LastUpdateErrorCodeFromPurchaseHistoryL() end"); |
|
591 |
|
592 return errorCode; |
|
593 } |
|
594 |
|
595 |
|
596 // --------------------------------------------------------------------------- |
|
597 // Protected functions |
|
598 // |
|
599 // --------------------------------------------------------------------------- |
|
600 |
|
601 |
|
602 // --------------------------------------------------------------------------- |
|
603 // CIAUpdateBaseNode::PurchaseDetailsLC |
|
604 // |
|
605 // --------------------------------------------------------------------------- |
|
606 // |
|
607 CNcdPurchaseDetails* CIAUpdateBaseNode::PurchaseDetailsLC() |
|
608 { |
|
609 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::IdleCancelPurchaseDetailsLC begin"); |
|
610 |
|
611 // This will contain the correct details object. |
|
612 CNcdPurchaseDetails* details( NULL ); |
|
613 |
|
614 // Create filter. So, we will get |
|
615 // all the purchase history items. |
|
616 CNcdPurchaseHistoryFilter* filter = |
|
617 CNcdPurchaseHistoryFilter::NewLC(); |
|
618 filter->SetNamespaceL( MetaNamespace() ); |
|
619 filter->SetEntityIdL( MetaId() ); |
|
620 |
|
621 // Add family uid to the filter |
|
622 RArray< TUid > uids; |
|
623 CleanupClosePushL( uids ); |
|
624 uids.AppendL( iController.FamilyUid() ); |
|
625 filter->SetClientUids( uids.Array() ); |
|
626 CleanupStack::PopAndDestroy( &uids ); |
|
627 |
|
628 MNcdPurchaseHistory* history( iController.ProviderL().PurchaseHistoryL() ); |
|
629 CleanupReleasePushL( *history ); |
|
630 |
|
631 // Get the ids. So, we can next get all the corresponding |
|
632 // details. |
|
633 RArray< TUint > ids = history->PurchaseIdsL( *filter ); |
|
634 // Temporarily remove history from cleanup stack |
|
635 CleanupStack::Pop( history ); |
|
636 CleanupStack::PopAndDestroy( filter ); |
|
637 CleanupReleasePushL( *history ); |
|
638 CleanupClosePushL( ids ); |
|
639 |
|
640 if ( ids.Count() > 0 ) |
|
641 { |
|
642 // If purchase details exist, then use the most up-to-date one. |
|
643 // This may be a previous idle cancel or if the update flow has |
|
644 // proceeded for this node, then this is a real purchase detail. |
|
645 // In either case, this details will be updated with the cancel |
|
646 // error code and new time information. |
|
647 details = |
|
648 history->PurchaseDetailsL( ids[ 0 ], EFalse ); |
|
649 } |
|
650 |
|
651 CleanupStack::PopAndDestroy( &ids ); |
|
652 CleanupStack::PopAndDestroy( history ); |
|
653 |
|
654 if ( !details ) |
|
655 { |
|
656 // There was not corresponding purchase details in the history. |
|
657 // So, create new. |
|
658 details = CNcdPurchaseDetails::NewLC(); |
|
659 |
|
660 // Set the known details into the newly created object. |
|
661 |
|
662 // Set identifier information here. |
|
663 details->SetNamespaceL( MetaNamespace() ); |
|
664 details->SetEntityIdL( MetaId() ); |
|
665 // The client uid means here the family uid. |
|
666 details->SetClientUid( iController.FamilyUid() ); |
|
667 |
|
668 // This information we already have available in this class. |
|
669 details->SetItemNameL( Name() ); |
|
670 details->SetDescriptionL( Description() ); |
|
671 details->SetVersionL( Version().Name() ); |
|
672 |
|
673 // Notice, let the purchase time be zero because the purchase operation |
|
674 // has not been done to the node content yet. |
|
675 const TInt KDefaultPurchaseTime( 0 ); |
|
676 details->SetPurchaseTime( KDefaultPurchaseTime ); |
|
677 } |
|
678 else |
|
679 { |
|
680 // The details was created but not inserted into |
|
681 // the cleanup stack above. Insert it into the cleanupstack now. |
|
682 CleanupStack::PushL( details ); |
|
683 } |
|
684 |
|
685 // MIME type checking. |
|
686 // Make sure that the purchase history also contains the correct MIME. |
|
687 // In certain cases the MIME type depends on the node state or settings |
|
688 // and the purchase history may contain old value that has been gotten |
|
689 // from the server. |
|
690 // By setting it here, we can be sure that if the purchase details is |
|
691 // later saved into the history, the correct value will then be used. |
|
692 details->SetAttributeL( |
|
693 MNcdPurchaseDetails::EPurchaseAttributeContentMimeType, MimeL() ); |
|
694 |
|
695 |
|
696 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::IdleCancelPurchaseDetailsLC end"); |
|
697 |
|
698 return details; |
|
699 } |
|
700 |
|
701 |
|
702 // --------------------------------------------------------------------------- |
|
703 // CIAUpdateBaseNode::MimeL |
|
704 // |
|
705 // --------------------------------------------------------------------------- |
|
706 // |
|
707 const TDesC& CIAUpdateBaseNode::MimeL() |
|
708 { |
|
709 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::MimeL begin"); |
|
710 |
|
711 TInt postfixIndex( |
|
712 iMime->Match( IAUpdateCtrlNodeConsts::KMimeHiddenPostfixPattern() ) ); |
|
713 |
|
714 IAUPDATE_TRACE_1("[IAUPDATE] postfixIndex: %d", postfixIndex); |
|
715 |
|
716 if ( Hidden() ) |
|
717 { |
|
718 IAUPDATE_TRACE("Set as hidden"); |
|
719 |
|
720 // Node should be set as hidden. |
|
721 if ( postfixIndex == KErrNotFound ) |
|
722 { |
|
723 IAUPDATE_TRACE("[IAUPDATE] Was not hidden"); |
|
724 // The node is not already set as hidden. |
|
725 // So, set it now. |
|
726 // Expand the buffer size, so hidden postfix can be added. |
|
727 iMime = |
|
728 iMime->ReAllocL( |
|
729 iMime->Length() |
|
730 + IAUpdateCtrlNodeConsts::KMimeHiddenPostfix().Length() ); |
|
731 |
|
732 // Append the postfix into the mime variable. |
|
733 TPtr ptrMime( iMime->Des() ); |
|
734 ptrMime.Append( IAUpdateCtrlNodeConsts::KMimeHiddenPostfix() ); |
|
735 } |
|
736 } |
|
737 else |
|
738 { |
|
739 IAUPDATE_TRACE("Unset hidden"); |
|
740 |
|
741 // Node should be set as not a hidden. |
|
742 if ( postfixIndex != KErrNotFound ) |
|
743 { |
|
744 IAUPDATE_TRACE("[IAUPDATE] Was hidden"); |
|
745 // The node was actually hidden. |
|
746 // So, set the correct new value now. |
|
747 // Notice, that this sets the value into the purchase history and into |
|
748 // the member variable. |
|
749 HBufC* mime( iMime->Left( postfixIndex ).AllocL() ); |
|
750 delete iMime; |
|
751 iMime = mime; |
|
752 } |
|
753 } |
|
754 |
|
755 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateBaseNode::MimeL end: %S", |
|
756 iMime); |
|
757 |
|
758 return *iMime; |
|
759 } |
|
760 |
|
761 // --------------------------------------------------------------------------- |
|
762 // CIAUpdateBaseNode::SetNameL |
|
763 // |
|
764 // --------------------------------------------------------------------------- |
|
765 // |
|
766 void CIAUpdateBaseNode::SetNameL( const MNcdNodeMetadata& aMetaData ) |
|
767 { |
|
768 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::SetNameL begin"); |
|
769 delete iName; |
|
770 iName = NULL; |
|
771 iName = aMetaData.Name().AllocL(); |
|
772 IAUPDATE_TRACE_1("[IAUPDATE] name: %S", iName ); |
|
773 |
|
774 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateBaseNode::SetNameL end"); |
|
775 } |
|
776 |