27 #include <avkon.mbg> |
27 #include <avkon.mbg> |
28 #include <avkon.rsg> |
28 #include <avkon.rsg> |
29 #include <AknsDrawUtils.h> |
29 #include <AknsDrawUtils.h> |
30 #include <AknBitmapAnimation.h> |
30 #include <AknBitmapAnimation.h> |
31 #include <barsread.h> |
31 #include <barsread.h> |
|
32 #include <widgetmanagerview.rsg> |
32 |
33 |
33 #include "wmwidgetdata.h" |
34 #include "wmwidgetdata.h" |
34 #include "wmwidgetdataobserver.h" |
35 #include "wmwidgetdataobserver.h" |
35 #include "wmpersistentwidgetorder.h" |
36 #include "wmpersistentwidgetorder.h" |
36 #include "wmresourceloader.h" |
37 #include "wmresourceloader.h" |
37 #include "wmcommon.h" |
38 #include "wmcommon.h" |
38 |
39 |
39 // CONSTANTS |
|
40 _LIT8( KWrtMime, "application/x-nokia-widget"); |
|
41 |
|
42 // --------------------------------------------------------- |
40 // --------------------------------------------------------- |
43 // CWmWidgetData::NewL |
41 // CWmWidgetData::NewL |
44 // --------------------------------------------------------- |
42 // --------------------------------------------------------- |
45 // |
43 // |
46 CWmWidgetData* CWmWidgetData::NewL( |
44 CWmWidgetData* CWmWidgetData::NewL( |
77 // CWmWidgetData::CWmWidgetData |
75 // CWmWidgetData::CWmWidgetData |
78 // --------------------------------------------------------- |
76 // --------------------------------------------------------- |
79 // |
77 // |
80 CWmWidgetData::CWmWidgetData( const TSize& aLogoSize, |
78 CWmWidgetData::CWmWidgetData( const TSize& aLogoSize, |
81 CWmResourceLoader& aWmResourceLoader ) |
79 CWmResourceLoader& aWmResourceLoader ) |
82 : CActive( EPriorityStandard ), |
80 : iWmResourceLoader( aWmResourceLoader ) |
83 iWmResourceLoader( aWmResourceLoader ) |
81 { |
84 { |
|
85 iIdle = NULL; |
|
86 iLogoImage = NULL; |
82 iLogoImage = NULL; |
87 iLogoImageMask = NULL; |
83 iLogoImageMask = NULL; |
88 iHsContentInfo = NULL; |
84 iHsContentInfo = NULL; |
89 iWidgetType = CWmWidgetData::EUnknown; |
85 iWidgetType = CWmWidgetData::EUnknown; |
90 iPublisherUid = KNullUid; |
86 iPublisherUid = KNullUid; |
91 iLogoSize = aLogoSize; |
87 iLogoSize = aLogoSize; |
92 iPeriodic = NULL; |
88 iPeriodic = NULL; |
93 iAnimationIndex = 0; |
89 iAnimationIndex = 0; |
94 iAsyncUninstalling = EFalse; |
90 iAsyncUninstalling = EFalse; |
95 iFireLogoChanged = EFalse; |
91 iFireLogoChanged = EFalse; |
96 CActiveScheduler::Add( this ); |
|
97 } |
92 } |
98 |
93 |
99 // --------------------------------------------------------- |
94 // --------------------------------------------------------- |
100 // CWmWidgetData::ConstructL |
95 // CWmWidgetData::ConstructL |
101 // --------------------------------------------------------- |
96 // --------------------------------------------------------- |
106 { |
101 { |
107 InitL( aHsContentInfo, aRegistryClientSession ); |
102 InitL( aHsContentInfo, aRegistryClientSession ); |
108 |
103 |
109 // start decoding the icon |
104 // start decoding the icon |
110 iImageConverter = CWmImageConverter::NewL( this ); |
105 iImageConverter = CWmImageConverter::NewL( this ); |
111 iIdle = CIdle::NewL( CActive::EPriorityStandard ); |
|
112 iWait = new (ELeave) CActiveSchedulerWait(); |
106 iWait = new (ELeave) CActiveSchedulerWait(); |
113 iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard ); |
107 iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard ); |
114 |
108 |
115 // start logo handling |
109 // start logo handling |
116 iImageConverter->SetLogoSize( iLogoSize ); |
110 iImageConverter->SetLogoSize( iLogoSize ); |
464 } |
453 } |
465 return prepairing; |
454 return prepairing; |
466 } |
455 } |
467 |
456 |
468 // --------------------------------------------------------- |
457 // --------------------------------------------------------- |
469 // CWmWidgetData::UnInstallL |
458 // CWmWidgetData::VisualizeUninstall |
470 // --------------------------------------------------------- |
459 // --------------------------------------------------------- |
471 // |
460 // |
472 void CWmWidgetData::UnInstallL() |
461 void CWmWidgetData::VisualizeUninstallL() |
473 { |
462 { |
474 if ( IsUninstalling() || IsActive() ) |
|
475 { |
|
476 User::Leave( KErrInUse ); |
|
477 } |
|
478 |
|
479 DestroyAnimData(); |
463 DestroyAnimData(); |
|
464 PrepairAnimL(); |
480 |
465 |
481 TInt err = iInstaller.Connect(); |
466 iHsContentInfo->SetNameL( iWmResourceLoader.Uninstalling() ); |
482 if ( KErrNone == err ) |
|
483 { |
|
484 CleanupClosePushL( iInstaller ); |
|
485 PrepairAnimL(); |
|
486 CleanupStack::Pop( &iInstaller ); |
|
487 SwiUI::TUninstallOptions optionsUninstall; |
|
488 optionsUninstall.iBreakDependency = SwiUI::EPolicyAllowed; |
|
489 optionsUninstall.iKillApp = SwiUI::EPolicyAllowed; |
|
490 SwiUI::TUninstallOptionsPckg uninstallOptionsPkg( optionsUninstall ); |
|
491 iInstaller.SilentUninstall( iStatus, iPublisherUid, |
|
492 uninstallOptionsPkg, KWrtMime ); |
|
493 VisualizeUninstall(); |
|
494 SetActive(); |
|
495 } |
|
496 else |
|
497 { |
|
498 // do normal uninstall |
|
499 iAsyncUninstalling = EFalse; |
|
500 SwiUI::RSWInstLauncher installer; |
|
501 User::LeaveIfError( installer.Connect() ); |
|
502 CleanupClosePushL( installer ); |
|
503 User::LeaveIfError( installer.Uninstall( iPublisherUid, KWrtMime ) ); |
|
504 CleanupStack::PopAndDestroy( &installer ); |
|
505 } |
|
506 } |
|
507 |
|
508 // --------------------------------------------------------- |
|
509 // CWmWidgetData::VisualizeUninstall |
|
510 // --------------------------------------------------------- |
|
511 // |
|
512 void CWmWidgetData::VisualizeUninstall() |
|
513 { |
|
514 iAsyncUninstalling = ETrue; |
467 iAsyncUninstalling = ETrue; |
515 iAnimationIndex = 0; |
468 iAnimationIndex = 0; |
516 const TInt tickInterval = 400000; |
469 const TInt tickInterval = 400000; |
517 iPeriodic->Start( |
470 iPeriodic->Start( |
518 tickInterval,tickInterval,TCallBack(Tick, this)); |
471 tickInterval,tickInterval,TCallBack(Tick, this)); |
586 self->FireDataChanged(); |
539 self->FireDataChanged(); |
587 return 1; |
540 return 1; |
588 } |
541 } |
589 |
542 |
590 // --------------------------------------------------------- |
543 // --------------------------------------------------------- |
591 // CWmWidgetData::CloseSwiSession |
|
592 // --------------------------------------------------------- |
|
593 // |
|
594 TInt CWmWidgetData::CloseSwiSession( TAny* aPtr ) |
|
595 { |
|
596 CWmWidgetData* self = static_cast< CWmWidgetData* >( aPtr ); |
|
597 if ( self->iIdle->IsActive() ) |
|
598 { |
|
599 self->iIdle->Cancel(); |
|
600 } |
|
601 |
|
602 self->iInstaller.Close(); |
|
603 return KErrNone; |
|
604 } |
|
605 |
|
606 // --------------------------------------------------------- |
|
607 // CWmWidgetData::AnimationBitmap |
544 // CWmWidgetData::AnimationBitmap |
608 // --------------------------------------------------------- |
545 // --------------------------------------------------------- |
609 // |
546 // |
610 const CFbsBitmap* CWmWidgetData::AnimationBitmap( const TSize& aSize ) |
547 const CFbsBitmap* CWmWidgetData::AnimationBitmap( const TSize& aSize ) |
611 { |
548 { |
658 TBool CWmWidgetData::IsUninstalling() |
595 TBool CWmWidgetData::IsUninstalling() |
659 { |
596 { |
660 return iAsyncUninstalling; |
597 return iAsyncUninstalling; |
661 } |
598 } |
662 |
599 |
663 // --------------------------------------------------------- |
|
664 // CWmWidgetData::DoCancel |
|
665 // --------------------------------------------------------- |
|
666 // |
|
667 void CWmWidgetData::DoCancel() |
|
668 { |
|
669 if ( IsActive() && iAsyncUninstalling ) |
|
670 { |
|
671 iInstaller.CancelAsyncRequest( |
|
672 SwiUI::ERequestSilentUninstall ); |
|
673 |
|
674 // close session |
|
675 iInstaller.Close(); |
|
676 } |
|
677 iAsyncUninstalling = EFalse; |
|
678 iAnimationIndex = 0; |
|
679 } |
|
680 |
|
681 // --------------------------------------------------------- |
|
682 // CWmWidgetData::RunL |
|
683 // --------------------------------------------------------- |
|
684 // |
|
685 void CWmWidgetData::RunL() |
|
686 { |
|
687 iAsyncUninstalling = EFalse; |
|
688 iAnimationIndex = 0; |
|
689 |
|
690 DestroyAnimData(); |
|
691 FireDataChanged(); |
|
692 |
|
693 // close SWI session |
|
694 if ( iIdle && iIdle->IsActive() ) |
|
695 { |
|
696 iIdle->Cancel(); |
|
697 } |
|
698 iIdle->Start( TCallBack( CloseSwiSession, this ) ); |
|
699 } |
|
700 |
|
701 // --------------------------------------------------------- |
|
702 // CWmWidgetData::RunError |
|
703 // --------------------------------------------------------- |
|
704 // |
|
705 TInt CWmWidgetData::RunError(TInt /*aError*/) |
|
706 { |
|
707 iAsyncUninstalling = EFalse; |
|
708 iAnimationIndex = 0; |
|
709 DestroyAnimData(); |
|
710 FireDataChanged(); |
|
711 |
|
712 // close SWI session |
|
713 if ( iIdle && iIdle->IsActive() ) |
|
714 { |
|
715 iIdle->Cancel(); |
|
716 } |
|
717 iIdle->Start( TCallBack( CloseSwiSession, this ) ); |
|
718 |
|
719 return KErrNone; |
|
720 } |
|
721 |
|
722 // End of file |
600 // End of file |
723 |
601 |