idlefw/plugins/mcsplugin/publisher/src/mcsplugin.cpp
branchRCL_3
changeset 12 502e5d91ad42
parent 11 bd874ee5e5e2
child 14 15e4dd19031c
equal deleted inserted replaced
11:bd874ee5e5e2 12:502e5d91ad42
    87 // Deletes all data created to heap
    87 // Deletes all data created to heap
    88 // ----------------------------------------------------------------------------
    88 // ----------------------------------------------------------------------------
    89 //
    89 //
    90 CMCSPlugin::~CMCSPlugin()
    90 CMCSPlugin::~CMCSPlugin()
    91     {
    91     {
    92     Release( iContent );
    92      Release( iContent );
    93     
    93 
    94     if ( iEngine )
       
    95         {
       
    96         TRAP_IGNORE( iEngine->CleanMCSItemsL() );
       
    97         }
       
    98     
       
    99     delete iEngine;
    94     delete iEngine;
   100     iObservers.Close();
    95     iObservers.Close();
   101     
    96     
   102     DeleteContentModel();
    97     DeleteContentModel();
   103     }
    98     }
   160     if( !aData.IsDirty() )
   155     if( !aData.IsDirty() )
   161         {
   156         {
   162         return;
   157         return;
   163         }
   158         }
   164 
   159 
   165     CMenuItem* item( iEngine->FetchMenuItemL( aData.MenuItem() ) );
   160     CMenuItem* item = NULL;
       
   161     TRAP_IGNORE ( item = iEngine->FetchMenuItemL( aData.MenuItem() ) );
       
   162     
   166     CleanupStack::PushL( item );
   163     CleanupStack::PushL( item );
   167     
   164     
   168     // One widget item has iDataCount number of elements
   165     // One widget item has iDataCount number of elements
   169     for ( TInt i = 0; i < iDataCount; i++ )
   166     for ( TInt i = 0; i < iDataCount; i++ )
   170         {
   167         {
   171         if ( iContentModel[i].type == KAiContentTypeBitmap )
   168         if ( iContentModel[i].type == KAiContentTypeBitmap )
   172             {
   169             {
   173             //Publish image
   170             //Publish image
   174             if ( aObserver.CanPublish( *this, i, aIndex ) )
   171             if ( aObserver.CanPublish( *this, i, aIndex ) )
   175                 {
   172                 {
   176                 CGulIcon* icon( iEngine->ItemIconL( *item, 
   173                 CGulIcon* icon( iEngine->ItemIconL( item, 
   177                     TPtrC16( ( const TText16* ) iContentModel[ i ].cid ) ) );
   174                     TPtrC16( ( const TText16* ) iContentModel[ i ].cid ) ) );
   178                 
   175                 
   179                 aObserver.PublishPtr( *this, i, icon , aIndex );
   176                 aObserver.PublishPtr( *this, i, icon , aIndex );
   180                 }
   177                 }
   181             }
   178             }
   182         else if ( iContentModel[i].type == KAiContentTypeText )
   179         else if ( iContentModel[i].type == KAiContentTypeText )
   183             {
   180             {
   184             //Publish  text
   181             //Publish  text
   185             if ( aObserver.CanPublish( *this, i, aIndex ) )
   182             if ( aObserver.CanPublish( *this, i, aIndex ) )
   186                 {
   183                 {
   187                 TPtrC name( iEngine->ItemTextL( *item, 
   184                 TPtrC name( iEngine->ItemTextL( item, 
   188                     TPtrC16( ( const TText16* ) iContentModel[ i ].cid ) ) );
   185                     TPtrC16( ( const TText16* ) iContentModel[ i ].cid ) ) );
   189                 
   186                 
   190                 aObserver.Publish( *this, i, name, aIndex );
   187                 aObserver.Publish( *this, i, name, aIndex );
   191                 }
   188                 }
   192             }
   189             }
   200 // 
   197 // 
   201 // ----------------------------------------------------------------------------
   198 // ----------------------------------------------------------------------------
   202 //
   199 //
   203 void CMCSPlugin::Start( TStartReason aReason )
   200 void CMCSPlugin::Start( TStartReason aReason )
   204     {
   201     {
   205     if( aReason == EPluginStartup )
   202     if ( aReason == EPluginStartup )
   206         {
   203         {
   207         TRAP_IGNORE( iEngine->CreateBkmMenuItemsL() );
   204         TRAP_IGNORE( iEngine->CreateRuntimeMenuItemsL() );
   208         }
   205         }    
   209     }
   206     }
   210 
   207 
   211 // ----------------------------------------------------------------------------
   208 // ----------------------------------------------------------------------------
   212 // CMCSPlugin::Stop
   209 // CMCSPlugin::Stop
   213 // 
   210 // 
   214 // ----------------------------------------------------------------------------
   211 // ----------------------------------------------------------------------------
   215 //
   212 //
   216 void CMCSPlugin::Stop( TStopReason /*aReason*/ )
   213 void CMCSPlugin::Stop( TStopReason aReason )
   217     {
   214     {
       
   215     if( aReason == EPluginShutdown )
       
   216         {
       
   217         TRAP_IGNORE( iEngine->CleanMCSItemsL() );
       
   218         }
   218     }
   219     }
   219 
   220 
   220 // ----------------------------------------------------------------------------
   221 // ----------------------------------------------------------------------------
   221 // CMCSPlugin::Resume
   222 // CMCSPlugin::Resume
   222 // 
   223 //