idlehomescreen/widgetmanager/src/wmwidgetdata.cpp
branchRCL_3
changeset 19 79311d856354
parent 18 d05a55b217df
equal deleted inserted replaced
18:d05a55b217df 19:79311d856354
    34 #include "wmwidgetdata.h"
    34 #include "wmwidgetdata.h"
    35 #include "wmwidgetdataobserver.h"
    35 #include "wmwidgetdataobserver.h"
    36 #include "wmpersistentwidgetorder.h"
    36 #include "wmpersistentwidgetorder.h"
    37 #include "wmresourceloader.h"
    37 #include "wmresourceloader.h"
    38 #include "wmcommon.h"
    38 #include "wmcommon.h"
       
    39 #include "wmimageconverter.h"
    39 
    40 
    40 // ---------------------------------------------------------
    41 // ---------------------------------------------------------
    41 // CWmWidgetData::NewL
    42 // CWmWidgetData::NewL
    42 // ---------------------------------------------------------
    43 // ---------------------------------------------------------
    43 //
    44 //
    85     iWidgetType = CWmWidgetData::EUnknown;
    86     iWidgetType = CWmWidgetData::EUnknown;
    86     iWrtType = CWmWidgetData::EUnIdentified;
    87     iWrtType = CWmWidgetData::EUnIdentified;
    87     iPublisherUid = KNullUid;
    88     iPublisherUid = KNullUid;
    88     iLogoSize = aLogoSize;
    89     iLogoSize = aLogoSize;
    89     iAnimationTimer = NULL;
    90     iAnimationTimer = NULL;
    90     iTimeoutTimer = NULL;
       
    91     iAnimationIndex = 0;
    91     iAnimationIndex = 0;
    92     iAsyncUninstalling = EFalse;
    92     iAsyncUninstalling = EFalse;
    93     iFireLogoChanged = EFalse;
       
    94     iMdcaPoint = NULL;
    93     iMdcaPoint = NULL;
    95     iWidgetName = NULL;
       
    96     }
    94     }
    97 
    95 
    98 // ---------------------------------------------------------
    96 // ---------------------------------------------------------
    99 // CWmWidgetData::ConstructL
    97 // CWmWidgetData::ConstructL
   100 // ---------------------------------------------------------
    98 // ---------------------------------------------------------
   101 //
    99 //
   102 void CWmWidgetData::ConstructL( 
   100 void CWmWidgetData::ConstructL(         
   103         CHsContentInfo* aHsContentInfo,
   101         CHsContentInfo* aHsContentInfo,
   104         RWidgetRegistryClientSession* aRegistryClientSession )
   102         RWidgetRegistryClientSession* aRegistryClientSession )
   105     {
   103     {
   106     // start decoding the icon
   104     // start decoding the icon
   107     iImageConverter = CWmImageConverter::NewL( this );
   105 	iImageConverter = CWmImageConverter::NewL();
   108     iWait = new (ELeave) CActiveSchedulerWait();
       
   109     iAnimationTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   106     iAnimationTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   110     iTimeoutTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
   111 
   107 
   112     InitL( aHsContentInfo, aRegistryClientSession );
   108     InitL( aHsContentInfo, aRegistryClientSession );
   113     
   109     
   114     // start logo handling
   110     // start logo handling
   115     iImageConverter->SetLogoSize( iLogoSize );
       
   116     HandleIconString( HsContentInfo().IconPath() );
   111     HandleIconString( HsContentInfo().IconPath() );
   117     }
   112     }
   118 
   113 
   119 // ---------------------------------------------------------
   114 // ---------------------------------------------------------
   120 // CWmWidgetData::InitL
   115 // CWmWidgetData::InitL
   152 // CWmWidgetData::~CWmWidgetData
   147 // CWmWidgetData::~CWmWidgetData
   153 // ---------------------------------------------------------
   148 // ---------------------------------------------------------
   154 //
   149 //
   155 CWmWidgetData::~CWmWidgetData()
   150 CWmWidgetData::~CWmWidgetData()
   156     {
   151     {
   157     if ( iTimeoutTimer && 
       
   158         iTimeoutTimer->IsActive() )
       
   159         {
       
   160         iTimeoutTimer->Cancel();
       
   161         }
       
   162     delete iTimeoutTimer;
       
   163 
       
   164     delete iWidgetName;
       
   165     if ( iWait && iWait->IsStarted() )
       
   166         {
       
   167         iWait->AsyncStop();
       
   168         }
       
   169     delete iWait;
       
   170     SetObserver( NULL );
   152     SetObserver( NULL );
   171     DestroyAnimData();
   153     DestroyAnimData();
   172     delete iAnimationTimer;
   154     delete iAnimationTimer;
   173     delete iLogoImage;
   155     delete iLogoImage;
   174     delete iLogoImageMask;
   156     delete iLogoImageMask;
   241         }
   223         }
   242     return result;
   224     return result;
   243     }
   225     }
   244 
   226 
   245 // ---------------------------------------------------------
   227 // ---------------------------------------------------------
   246 // CWmWidgetData::NotifyCompletion
       
   247 // ---------------------------------------------------------
       
   248 //
       
   249 void CWmWidgetData::NotifyCompletion( TInt aError )
       
   250     {
       
   251     delete iLogoImage;
       
   252     iLogoImage = NULL;
       
   253     delete iLogoImageMask;
       
   254     iLogoImageMask = NULL;
       
   255     if ( KErrNone != aError )
       
   256         {
       
   257         // no image available. Do nothing.
       
   258         }
       
   259     else
       
   260         {
       
   261         iLogoImage = iImageConverter->Bitmap();
       
   262         iLogoImageMask = iImageConverter->Mask();
       
   263 
       
   264         if ( iWait && iWait->IsStarted() )
       
   265             {
       
   266             iWait->AsyncStop();
       
   267             }
       
   268         if ( iFireLogoChanged ) 
       
   269             {
       
   270             iFireLogoChanged = EFalse;
       
   271             FireDataChanged();
       
   272             }
       
   273         }
       
   274     }
       
   275 
       
   276 // ---------------------------------------------------------
       
   277 // CWmWidgetData::HandleIconString
   228 // CWmWidgetData::HandleIconString
   278 // ---------------------------------------------------------
   229 // ---------------------------------------------------------
   279 //
   230 //
   280 void CWmWidgetData::HandleIconString( const TDesC& aIconStr )
   231 void CWmWidgetData::HandleIconString( const TDesC& aIconStr )
   281     {
   232     {
   303     if ( size != iLogoSize &&
   254     if ( size != iLogoSize &&
   304         iLogoSize.iWidth > 0 && iLogoSize.iHeight > 0 )
   255         iLogoSize.iWidth > 0 && iLogoSize.iHeight > 0 )
   305         {
   256         {
   306         size = iLogoSize;
   257         size = iLogoSize;
   307         }
   258         }
   308     TInt err = iImageConverter->HandleIconString( 
   259     
   309             size.iWidth, size.iHeight, *iconStr );
   260     iImageConverter->HandleIconString( 
       
   261             size, 
       
   262             *iconStr, 
       
   263             iLogoImage, 
       
   264             iLogoImageMask );
   310     
   265     
   311     delete iconStr;
   266     delete iconStr;
   312     iconStr = NULL;
   267     iconStr = NULL;
   313     
   268     
   314     // handle result
   269     FireDataChanged(); // draw default icon
   315     if ( KErrNone == err && iWait &&
       
   316         IsPrepairingLogo() && iTimeoutTimer )
       
   317         {
       
   318         iTimeoutTimer->Cancel();
       
   319         const TInt tickInterval = 200000;        
       
   320         iTimeoutTimer->Start(
       
   321                 tickInterval,tickInterval,TCallBack(TimeoutTick, this));
       
   322         iWait->Start();
       
   323         }
       
   324     else if ( KErrNone != err && iFireLogoChanged )
       
   325         {
       
   326         FireDataChanged(); // draw default icon
       
   327         iFireLogoChanged = EFalse;
       
   328         }
       
   329     }
   270     }
   330 
   271 
   331 // ---------------------------------------------------------
   272 // ---------------------------------------------------------
   332 // CWmWidgetData::FireDataChanged
   273 // CWmWidgetData::FireDataChanged
   333 // ---------------------------------------------------------
   274 // ---------------------------------------------------------
   445 
   386 
   446 // ---------------------------------------------------------
   387 // ---------------------------------------------------------
   447 // CWmWidgetData::ReCreateLogo
   388 // CWmWidgetData::ReCreateLogo
   448 // ---------------------------------------------------------
   389 // ---------------------------------------------------------
   449 //
   390 //
   450 void CWmWidgetData::ReCreateLogo( const TSize& aSize )
   391 void CWmWidgetData::UpdateLogo( const TSize& aSize, TBool aReCreateLogo )
   451     {    
   392     {        
   452     delete iLogoImage;
       
   453     iLogoImage = NULL;
       
   454     delete iLogoImageMask;
       
   455     iLogoImageMask = NULL;
       
   456     
       
   457     if ( iWait && iWait->IsStarted() )
       
   458         {
       
   459         iWait->AsyncStop();
       
   460         }
       
   461 
       
   462     iFireLogoChanged = ETrue;
       
   463     iLogoSize = aSize;
   393     iLogoSize = aSize;
   464     HandleIconString( HsContentInfo().IconPath() );
   394     if ( aReCreateLogo )
       
   395         {
       
   396         delete iLogoImage;
       
   397         iLogoImage = NULL;
       
   398         delete iLogoImageMask;
       
   399         iLogoImageMask = NULL;
       
   400         HandleIconString( HsContentInfo().IconPath() );
       
   401         }
       
   402     else
       
   403         {
       
   404         iImageConverter->UpdateImageSize(
       
   405                 iLogoSize,
       
   406                 HsContentInfo().IconPath(),
       
   407                 *iLogoImage,
       
   408                 *iLogoImageMask );
       
   409         }
   465     }
   410     }
   466 
   411 
   467 // ---------------------------------------------------------
   412 // ---------------------------------------------------------
   468 // CWmWidgetData::ReplaceContentInfo
   413 // CWmWidgetData::ReplaceContentInfo
   469 // ---------------------------------------------------------
   414 // ---------------------------------------------------------
   498     
   443     
   499     if ( !sameLogo )
   444     if ( !sameLogo )
   500         {
   445         {
   501         // re-convert image
   446         // re-convert image
   502         // change event will be fired later when bitmap is ready
   447         // change event will be fired later when bitmap is ready
   503         ReCreateLogo( iLogoSize );
   448         UpdateLogo( iLogoSize, ETrue );
   504         }
   449         }
   505 
   450 
   506     return !( sameAppearance && sameLogo );
   451     return !( sameAppearance && sameLogo );
   507     }
       
   508 
       
   509 // ---------------------------------------------------------
       
   510 // CWmWidgetData::IsPrepairingLogo
       
   511 // ---------------------------------------------------------
       
   512 //
       
   513 TBool CWmWidgetData::IsPrepairingLogo()
       
   514     {
       
   515     TBool prepairing( EFalse );            
       
   516     if ( !iLogoImage )
       
   517         {
       
   518         prepairing = iImageConverter->IsProcessing();
       
   519         }
       
   520     return prepairing;
       
   521     }
   452     }
   522 
   453 
   523 // ---------------------------------------------------------
   454 // ---------------------------------------------------------
   524 // CWmWidgetData::VisualizeUninstall
   455 // CWmWidgetData::VisualizeUninstall
   525 // ---------------------------------------------------------
   456 // ---------------------------------------------------------
   604     self->FireDataChanged();
   535     self->FireDataChanged();
   605     return 1;
   536     return 1;
   606     }
   537     }
   607 
   538 
   608 // ---------------------------------------------------------
   539 // ---------------------------------------------------------
   609 // CWmWidgetData::TimeoutTick
       
   610 // ---------------------------------------------------------
       
   611 //
       
   612 TInt CWmWidgetData::TimeoutTick( TAny* aPtr )
       
   613     {
       
   614     CWmWidgetData* self = static_cast< CWmWidgetData* >( aPtr );
       
   615     self->iTimeoutTimer->Cancel();
       
   616     if ( self->iWait && self->iWait->IsStarted() )
       
   617         {
       
   618         self->iWait->AsyncStop();
       
   619         }
       
   620     return 1;
       
   621     }
       
   622 
       
   623 // ---------------------------------------------------------
       
   624 // CWmWidgetData::AnimationBitmap
   540 // CWmWidgetData::AnimationBitmap
   625 // ---------------------------------------------------------
   541 // ---------------------------------------------------------
   626 //
   542 //
   627 const CFbsBitmap* CWmWidgetData::AnimationBitmap( const TSize& aSize )
   543 const CFbsBitmap* CWmWidgetData::AnimationBitmap( const TSize& aSize )
   628     {
   544     {