83 iLogoImageMask = NULL; |
83 iLogoImageMask = NULL; |
84 iHsContentInfo = NULL; |
84 iHsContentInfo = NULL; |
85 iWidgetType = CWmWidgetData::EUnknown; |
85 iWidgetType = CWmWidgetData::EUnknown; |
86 iPublisherUid = KNullUid; |
86 iPublisherUid = KNullUid; |
87 iLogoSize = aLogoSize; |
87 iLogoSize = aLogoSize; |
88 iPeriodic = NULL; |
88 iAnimationTimer = NULL; |
|
89 iTimeoutTimer = NULL; |
89 iAnimationIndex = 0; |
90 iAnimationIndex = 0; |
90 iAsyncUninstalling = EFalse; |
91 iAsyncUninstalling = EFalse; |
91 iFireLogoChanged = EFalse; |
92 iFireLogoChanged = EFalse; |
92 iMdcaPoint = NULL; |
93 iMdcaPoint = NULL; |
|
94 iWidgetName = NULL; |
93 } |
95 } |
94 |
96 |
95 // --------------------------------------------------------- |
97 // --------------------------------------------------------- |
96 // CWmWidgetData::ConstructL |
98 // CWmWidgetData::ConstructL |
97 // --------------------------------------------------------- |
99 // --------------------------------------------------------- |
98 // |
100 // |
99 void CWmWidgetData::ConstructL( |
101 void CWmWidgetData::ConstructL( |
100 CHsContentInfo* aHsContentInfo, |
102 CHsContentInfo* aHsContentInfo, |
101 RWidgetRegistryClientSession* aRegistryClientSession ) |
103 RWidgetRegistryClientSession* aRegistryClientSession ) |
102 { |
104 { |
103 InitL( aHsContentInfo, aRegistryClientSession ); |
|
104 |
|
105 // start decoding the icon |
105 // start decoding the icon |
106 iImageConverter = CWmImageConverter::NewL( this ); |
106 iImageConverter = CWmImageConverter::NewL( this ); |
107 iWait = new (ELeave) CActiveSchedulerWait(); |
107 iWait = new (ELeave) CActiveSchedulerWait(); |
108 iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard ); |
108 iAnimationTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
109 |
109 iTimeoutTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
110 |
|
111 InitL( aHsContentInfo, aRegistryClientSession ); |
|
112 |
110 // start logo handling |
113 // start logo handling |
111 iImageConverter->SetLogoSize( iLogoSize ); |
114 iImageConverter->SetLogoSize( iLogoSize ); |
112 HandleIconString( HsContentInfo().IconPath() ); |
115 HandleIconString( HsContentInfo().IconPath() ); |
113 } |
116 } |
114 |
117 |
128 else if ( aHsContentInfo->Type() == KContentWidget ) |
131 else if ( aHsContentInfo->Type() == KContentWidget ) |
129 { |
132 { |
130 iWidgetType = CWmWidgetData::ENative; |
133 iWidgetType = CWmWidgetData::ENative; |
131 } |
134 } |
132 |
135 |
133 // take ownership of the content info |
136 // get publisher uid from widget registry |
134 iHsContentInfo = aHsContentInfo; |
137 FetchPublisherUidL( aHsContentInfo->PublisherId(), |
|
138 aRegistryClientSession ); |
135 |
139 |
136 // create iMdcaPoint for listbox |
140 // create iMdcaPoint for listbox |
137 _LIT( KFormatStr, "0\t%S"); |
141 _LIT( KFormatStr, "0\t%S"); |
138 iMdcaPoint = HBufC::NewL( |
142 iMdcaPoint = HBufC::NewL( |
139 iHsContentInfo->Name().Length() + KFormatStr().Length() ); |
143 aHsContentInfo->Name().Length() + KFormatStr().Length() ); |
140 iMdcaPoint->Des().Format( KFormatStr(), &iHsContentInfo->Name() ); |
144 iMdcaPoint->Des().Format( KFormatStr(), &aHsContentInfo->Name() ); |
141 // get publisher uid from widget registry |
145 |
142 FetchPublisherUidL( aRegistryClientSession ); |
146 // take ownership of the content info |
|
147 iHsContentInfo = aHsContentInfo; |
143 } |
148 } |
144 |
149 |
145 // --------------------------------------------------------- |
150 // --------------------------------------------------------- |
146 // CWmWidgetData::~CWmWidgetData |
151 // CWmWidgetData::~CWmWidgetData |
147 // --------------------------------------------------------- |
152 // --------------------------------------------------------- |
148 // |
153 // |
149 CWmWidgetData::~CWmWidgetData() |
154 CWmWidgetData::~CWmWidgetData() |
150 { |
155 { |
|
156 if ( iTimeoutTimer && |
|
157 iTimeoutTimer->IsActive() ) |
|
158 { |
|
159 iTimeoutTimer->Cancel(); |
|
160 } |
|
161 delete iTimeoutTimer; |
|
162 |
|
163 delete iWidgetName; |
151 if ( iWait && iWait->IsStarted() ) |
164 if ( iWait && iWait->IsStarted() ) |
152 { |
165 { |
153 iWait->AsyncStop(); |
166 iWait->AsyncStop(); |
154 } |
167 } |
155 delete iWait; |
168 delete iWait; |
156 SetObserver( NULL ); |
169 SetObserver( NULL ); |
157 DestroyAnimData(); |
170 DestroyAnimData(); |
158 delete iPeriodic; |
171 delete iAnimationTimer; |
159 delete iLogoImage; |
172 delete iLogoImage; |
160 delete iLogoImageMask; |
173 delete iLogoImageMask; |
161 delete iImageConverter; |
174 delete iImageConverter; |
162 delete iHsContentInfo; |
175 delete iHsContentInfo; |
163 delete iMdcaPoint; |
176 delete iMdcaPoint; |
297 delete iconStr; |
310 delete iconStr; |
298 iconStr = NULL; |
311 iconStr = NULL; |
299 |
312 |
300 // handle result |
313 // handle result |
301 if ( KErrNone == err && iWait && |
314 if ( KErrNone == err && iWait && |
302 IsPrepairingLogo() ) |
315 IsPrepairingLogo() && iTimeoutTimer ) |
303 { |
316 { |
|
317 iTimeoutTimer->Cancel(); |
|
318 const TInt tickInterval = 200000; |
|
319 iTimeoutTimer->Start( |
|
320 tickInterval,tickInterval,TCallBack(TimeoutTick, this)); |
304 iWait->Start(); |
321 iWait->Start(); |
305 } |
322 } |
306 else if ( KErrNone != err && iFireLogoChanged ) |
323 else if ( KErrNone != err && iFireLogoChanged ) |
307 { |
324 { |
308 FireDataChanged(); // draw default icon |
325 FireDataChanged(); // draw default icon |
354 // ---------------------------------------------------- |
371 // ---------------------------------------------------- |
355 // CWmWidgetData::FetchPublisherUidL |
372 // CWmWidgetData::FetchPublisherUidL |
356 // ---------------------------------------------------- |
373 // ---------------------------------------------------- |
357 // |
374 // |
358 void CWmWidgetData::FetchPublisherUidL( |
375 void CWmWidgetData::FetchPublisherUidL( |
|
376 const TDesC& aPublisherId, |
359 RWidgetRegistryClientSession* aRegistryClientSession ) |
377 RWidgetRegistryClientSession* aRegistryClientSession ) |
360 { |
378 { |
361 if ( iPublisherUid == KNullUid && |
379 if ( iPublisherUid == KNullUid && |
362 PublisherId() != KNullDesC && |
380 aPublisherId != KNullDesC && |
363 iWidgetType != CWmWidgetData::ENative && |
381 iWidgetType != CWmWidgetData::ENative && |
364 aRegistryClientSession ) |
382 aRegistryClientSession ) |
365 { |
383 { |
366 TInt widgetUid = aRegistryClientSession->GetWidgetUidL( PublisherId() ); |
384 TInt widgetUid = aRegistryClientSession->GetWidgetUidL( aPublisherId ); |
367 if ( widgetUid != 0 ) |
385 if ( widgetUid != 0 ) |
368 { |
386 { |
369 // WRT widget |
387 // WRT widget |
370 iPublisherUid = TUid::Uid( widgetUid ); |
388 iPublisherUid = TUid::Uid( widgetUid ); |
371 } |
389 } |
412 iLogoSize = aSize; |
430 iLogoSize = aSize; |
413 HandleIconString( HsContentInfo().IconPath() ); |
431 HandleIconString( HsContentInfo().IconPath() ); |
414 } |
432 } |
415 |
433 |
416 // --------------------------------------------------------- |
434 // --------------------------------------------------------- |
417 // CWmWidgetData::ReplaceContentInfoL |
435 // CWmWidgetData::ReplaceContentInfo |
418 // --------------------------------------------------------- |
436 // --------------------------------------------------------- |
419 // |
437 // |
420 TBool CWmWidgetData::ReplaceContentInfoL( |
438 TBool CWmWidgetData::ReplaceContentInfo( |
421 CHsContentInfo* aHsContentInfo ) |
439 CHsContentInfo* aHsContentInfo ) |
422 { |
440 { |
423 TBool sameAppearance = ( |
441 TBool sameAppearance = ( |
424 iHsContentInfo->Name() == aHsContentInfo->Name() && |
442 iHsContentInfo->Name() == aHsContentInfo->Name() && |
425 iHsContentInfo->Description() == aHsContentInfo->Description() && |
443 iHsContentInfo->Description() == aHsContentInfo->Description() && |
428 iHsContentInfo->IconPath() == aHsContentInfo->IconPath() ); |
446 iHsContentInfo->IconPath() == aHsContentInfo->IconPath() ); |
429 |
447 |
430 // delete the old content info |
448 // delete the old content info |
431 delete iHsContentInfo; |
449 delete iHsContentInfo; |
432 iHsContentInfo = NULL; |
450 iHsContentInfo = NULL; |
433 |
451 |
434 // re-init the object |
452 // re-init the object, take care about leave. |
435 InitL( aHsContentInfo, NULL ); |
453 TRAPD( err, InitL( aHsContentInfo, NULL ); ); |
436 |
454 if ( KErrNone != err ) |
|
455 { |
|
456 delete aHsContentInfo; |
|
457 aHsContentInfo = NULL; |
|
458 } |
|
459 |
437 if ( !sameAppearance ) |
460 if ( !sameAppearance ) |
438 { |
461 { |
439 // fire change event -> widget redrawn |
462 // fire change event -> widget redrawn |
440 FireDataChanged(); |
463 FireDataChanged(); |
441 } |
464 } |
471 void CWmWidgetData::VisualizeUninstallL() |
494 void CWmWidgetData::VisualizeUninstallL() |
472 { |
495 { |
473 DestroyAnimData(); |
496 DestroyAnimData(); |
474 PrepairAnimL(); |
497 PrepairAnimL(); |
475 |
498 |
476 iHsContentInfo->SetNameL( iWmResourceLoader.Uninstalling() ); |
499 // set copy of widget name for uninstallation error case. |
|
500 if ( iHsContentInfo->Name().Compare( iWmResourceLoader.Uninstalling() ) != |
|
501 KErrNone ) |
|
502 { |
|
503 iWidgetName = iHsContentInfo->Name().AllocL(); |
|
504 iHsContentInfo->SetNameL( iWmResourceLoader.Uninstalling() ); |
|
505 } |
|
506 |
477 iAsyncUninstalling = ETrue; |
507 iAsyncUninstalling = ETrue; |
478 iAnimationIndex = 0; |
508 iAnimationIndex = 0; |
479 const TInt tickInterval = 400000; |
509 const TInt tickInterval = 400000; |
480 iPeriodic->Start( |
510 iAnimationTimer->Start( |
481 tickInterval,tickInterval,TCallBack(Tick, this)); |
511 tickInterval,tickInterval,TCallBack(AnimationTick, this)); |
482 } |
512 } |
483 |
513 |
484 // --------------------------------------------------------- |
514 // --------------------------------------------------------- |
485 // CWmWidgetData::PrepairAnimL |
515 // CWmWidgetData::PrepairAnimL |
486 // --------------------------------------------------------- |
516 // --------------------------------------------------------- |
519 // CWmWidgetData::DestroyAnimData |
549 // CWmWidgetData::DestroyAnimData |
520 // --------------------------------------------------------- |
550 // --------------------------------------------------------- |
521 // |
551 // |
522 void CWmWidgetData::DestroyAnimData() |
552 void CWmWidgetData::DestroyAnimData() |
523 { |
553 { |
524 if ( iPeriodic && iPeriodic->IsActive() ) |
554 if ( iAnimationTimer && iAnimationTimer->IsActive() ) |
525 { |
555 { |
526 iPeriodic->Cancel(); |
556 iAnimationTimer->Cancel(); |
527 } |
557 } |
528 |
558 |
529 for( TInt i=0; i < iUninstallAnimIcons.Count(); i++ ) |
559 for( TInt i=0; i < iUninstallAnimIcons.Count(); i++ ) |
530 { |
560 { |
531 CFbsBitmap* bitmap = iUninstallAnimIcons[i]; |
561 CFbsBitmap* bitmap = iUninstallAnimIcons[i]; |
533 } |
563 } |
534 iUninstallAnimIcons.Close(); |
564 iUninstallAnimIcons.Close(); |
535 } |
565 } |
536 |
566 |
537 // --------------------------------------------------------- |
567 // --------------------------------------------------------- |
538 // CWmWidgetData::Tick |
568 // CWmWidgetData::AnimationTick |
539 // --------------------------------------------------------- |
569 // --------------------------------------------------------- |
540 // |
570 // |
541 TInt CWmWidgetData::Tick( TAny* aPtr ) |
571 TInt CWmWidgetData::AnimationTick( TAny* aPtr ) |
542 { |
572 { |
543 CWmWidgetData* self = static_cast< CWmWidgetData* >( aPtr ); |
573 CWmWidgetData* self = static_cast< CWmWidgetData* >( aPtr ); |
544 self->iAnimationIndex += 2; |
574 self->iAnimationIndex += 2; |
545 if ( self->iAnimationIndex >= self->iUninstallAnimIcons.Count() -1 ) |
575 if ( self->iAnimationIndex >= self->iUninstallAnimIcons.Count() -1 ) |
546 { |
576 { |
547 self->iAnimationIndex = 0; // restart from beginging |
577 self->iAnimationIndex = 0; // restart from beginging |
548 } |
578 } |
549 self->FireDataChanged(); |
579 self->FireDataChanged(); |
|
580 return 1; |
|
581 } |
|
582 |
|
583 // --------------------------------------------------------- |
|
584 // CWmWidgetData::TimeoutTick |
|
585 // --------------------------------------------------------- |
|
586 // |
|
587 TInt CWmWidgetData::TimeoutTick( TAny* aPtr ) |
|
588 { |
|
589 CWmWidgetData* self = static_cast< CWmWidgetData* >( aPtr ); |
|
590 self->iTimeoutTimer->Cancel(); |
|
591 if ( self->iWait && self->iWait->IsStarted() ) |
|
592 { |
|
593 self->iWait->AsyncStop(); |
|
594 } |
550 return 1; |
595 return 1; |
551 } |
596 } |
552 |
597 |
553 // --------------------------------------------------------- |
598 // --------------------------------------------------------- |
554 // CWmWidgetData::AnimationBitmap |
599 // CWmWidgetData::AnimationBitmap |