photosgallery/contentharvesterplugin/src/glxcontentharvesterpluginbase.cpp
branchRCL_3
changeset 18 bcb43dc84c44
parent 14 ce1c7ad1f18b
child 22 2dac0fdba72b
equal deleted inserted replaced
14:ce1c7ad1f18b 18:bcb43dc84c44
     1 /*
       
     2  * Copyright (c) 2008-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:    Updates CPS storage
       
    15  *
       
    16  */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32base.h>
       
    21 #include <featmgr.h>
       
    22 #include <apgtask.h>
       
    23 #include <mmf/common/mmfcontrollerpluginresolver.h>
       
    24 #include <liwservicehandler.h>
       
    25 #include <glxuistd.h>     // KGlxFetchontextPriorityNormal and KGlxIconsFilename  
       
    26 #include <AknIconUtils.h> 
       
    27 #include <data_caging_path_literals.hrh>
       
    28 
       
    29 #include <glxattributecontext.h>
       
    30 #include <glxtracer.h>
       
    31 #include <glxlog.h>
       
    32 #include <mglxmedialist.h>       // for MGlxMediaList
       
    33 #include <glxcollectiongeneraldefs.h>
       
    34 #include <glxgallery.hrh>               // for KGlxGalleryApplicationUid
       
    35 #include <glxfilterfactory.h>
       
    36 #include <glxuistd.h>
       
    37 #include <glxthumbnailcontext.h>
       
    38 #include <glxmedialistiterator.h>
       
    39 #include <mglxcache.h>
       
    40 #include <glxthumbnailattributeinfo.h>
       
    41 
       
    42 #include "glxcontentharvesterplugin.h"
       
    43 #include "glxcontentharvesterpluginbase.h"
       
    44 #include "glxcontentharvesterplugin.hrh"
       
    45 #include "glxmapconstants.h"
       
    46 #include "glxcontentharvesterpluginalbums.h"
       
    47 
       
    48 // Matrixmenu uid - needed to check if photo suite is in foreground
       
    49 const TInt KMatrixMenuUid = 0x101F4CD2;
       
    50 
       
    51 // ============================ MEMBER FUNCTIONS ==============================
       
    52 
       
    53 // ----------------------------------------------------------------------------
       
    54 // Constructor
       
    55 // ----------------------------------------------------------------------------
       
    56 //
       
    57 CGlxContentHarvesterPluginBase::CGlxContentHarvesterPluginBase( )
       
    58     {
       
    59     TRACER( "CGlxContentHarvesterPluginBase::CGlxContentHarvesterPluginBase" );
       
    60     // No Implementation
       
    61     }
       
    62 
       
    63 // ----------------------------------------------------------------------------
       
    64 // Symbian 2nd phase constructor.
       
    65 // ----------------------------------------------------------------------------
       
    66 //
       
    67 void CGlxContentHarvesterPluginBase::ConstructL(TInt aDefaultIconId )
       
    68     {
       
    69     SetGridIconSizeL();
       
    70     TSize gridIconSize = GetGridIconSize();
       
    71     TFileName resFile(KDC_APP_BITMAP_DIR);
       
    72     resFile.Append(KGlxIconsFilename);
       
    73     iBitmap = AknIconUtils::CreateIconL(resFile,aDefaultIconId);
       
    74     AknIconUtils::SetSize(iBitmap, gridIconSize);
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // Destructor
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 CGlxContentHarvesterPluginBase::~CGlxContentHarvesterPluginBase()
       
    82     {
       
    83     TRACER( "CGlxContentHarvesterPluginBase::~CGlxContentHarvesterPluginBase" );
       
    84     if ( iCPSNotificationInterface )
       
    85         {
       
    86         iCPSNotificationInterface->Close();
       
    87         }
       
    88   
       
    89     delete iServiceHandler;
       
    90     
       
    91     if(iBitmap)
       
    92         {
       
    93          delete iBitmap;
       
    94          iBitmap=NULL;
       
    95         }
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // SetGridIconSizeL
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void CGlxContentHarvesterPluginBase::SetGridIconSizeL()
       
   103     {
       
   104     TRACER("CGlxContentHarvesterPluginBase::SetGridIconSizeL()");
       
   105     // Sets up TLS, must be done before FeatureManager is used.
       
   106     FeatureManager::InitializeLibL();
       
   107 
       
   108     if(FeatureManager::FeatureSupported( KFeatureIdLayout640_360_Touch ) || FeatureManager::FeatureSupported( KFeatureIdLayout360_640_Touch ))
       
   109         {
       
   110         iGridIconSize = TSize(111,83);
       
   111         }
       
   112     else if(FeatureManager::FeatureSupported(KFeatureIdLayout640_480_Touch) || FeatureManager::FeatureSupported(KFeatureIdLayout480_640_Touch) || 
       
   113             FeatureManager::FeatureSupported(KFeatureIdLayout640_480) || FeatureManager::FeatureSupported(KFeatureIdLayout480_640))
       
   114         {
       
   115         iGridIconSize = TSize(146,110);
       
   116         }
       
   117     else
       
   118         {
       
   119         iGridIconSize = TSize(146,110);
       
   120         }
       
   121     // Frees the TLS. Must be done after FeatureManager is used.
       
   122     FeatureManager::UnInitializeLib(); 
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // GetGridIconSize
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 TSize CGlxContentHarvesterPluginBase::GetGridIconSize()
       
   130     {
       
   131     TRACER("CGlxContentHarvesterPluginBase::GetGridIconSize()");
       
   132     return iGridIconSize;
       
   133     }
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // GetBitmapHandle
       
   137 // ---------------------------------------------------------------------------
       
   138 //
       
   139 TInt CGlxContentHarvesterPluginBase::GetBitmapHandle() const
       
   140     {
       
   141     TRACER("CGlxContentHarvesterPluginBase::GetBitmapHandle");
       
   142     return iBitmap->Handle();
       
   143     }
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 // GetInterfaceForNotificationL
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 void CGlxContentHarvesterPluginBase::GetInterfaceForNotificationL()
       
   150     {
       
   151     TRACER( "CGlxContentHarvesterPluginBase::GetInterfaceForNotificationL" );
       
   152     // create Service Handler and keep as long as access to Service needed
       
   153     iServiceHandler = CLiwServiceHandler::NewL();
       
   154     //keep for convenience, not owned
       
   155     iInParamList = &iServiceHandler->InParamListL();
       
   156     iOutParamList = &iServiceHandler->OutParamListL();
       
   157 
       
   158     RCriteriaArray criteriaArray;
       
   159     CleanupResetAndDestroyPushL( criteriaArray );
       
   160 
       
   161     // create Liw criteria
       
   162     CLiwCriteriaItem* criterion = 
       
   163     CLiwCriteriaItem::NewLC( KLiwCmdAsStr, KCPInterface, KCPService ); 
       
   164     criterion->SetServiceClass( TUid::Uid( KLiwClassBase ) );
       
   165 
       
   166     criteriaArray.AppendL( criterion );
       
   167     CleanupStack::Pop( criterion );
       
   168 
       
   169     // attach Liw criteria
       
   170     iServiceHandler->AttachL( criteriaArray );
       
   171     // get Service interface
       
   172     iServiceHandler->ExecuteServiceCmdL( *criterion, 
       
   173             *iInParamList, 
       
   174             *iOutParamList );
       
   175 
       
   176     CleanupStack::PopAndDestroy( &criteriaArray );
       
   177 
       
   178     // extract interface from output params
       
   179     TInt pos( 0 );
       
   180     iOutParamList->FindFirst( pos, KCPInterface );
       
   181     if( pos != KErrNotFound )
       
   182         {
       
   183         iCPSNotificationInterface = 
       
   184         (*iOutParamList)[pos].Value().AsInterface();    
       
   185         }
       
   186 
       
   187     iInParamList->Reset();
       
   188     iOutParamList->Reset();
       
   189 
       
   190     if ( !iCPSNotificationInterface )
       
   191         {
       
   192         // handle no Service
       
   193         User::Leave( KErrNotFound );
       
   194         }
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // RequestCpsNotificationL
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 void CGlxContentHarvesterPluginBase::RequestCpsNotificationL(TInt aSuiteItem)
       
   202     {
       
   203     TRACER( "CGlxContentHarvesterPluginBase::RequestCpsNotificationL" );
       
   204 
       
   205     TLiwGenericParam cptype( KType, TLiwVariant( KPublisherId ));
       
   206     iInParamList->AppendL( cptype );
       
   207 
       
   208     //create filter
       
   209     CLiwDefaultMap* filterMap = CLiwDefaultMap::NewLC();
       
   210     filterMap->InsertL( KPublisherId, TLiwVariant( KSuitePublisher ));
       
   211 
       
   212     switch (aSuiteItem)
       
   213         {
       
   214         case KItemIndexMonths:
       
   215             filterMap->InsertL( KContentType, TLiwVariant( KContentActivationMonths ) );
       
   216             break;
       
   217         case KItemIndexAlbums:
       
   218             filterMap->InsertL( KContentType, TLiwVariant( KContentActivationAlbums ) );
       
   219             break;
       
   220         case KItemIndexTags:
       
   221             filterMap->InsertL( KContentType, TLiwVariant( KContentActivationTags ) );
       
   222             break;
       
   223         case KItemIndexAll:
       
   224             filterMap->InsertL( KContentType, TLiwVariant( KContentActivationAll ) );
       
   225             break;
       
   226         }
       
   227 
       
   228     filterMap->InsertL( KContentId, TLiwVariant( KContentDefault ) );
       
   229 
       
   230     //we are only interested in update events
       
   231     filterMap->InsertL( KOperation, TLiwVariant( KOperationUpdate ) );
       
   232 
       
   233     TLiwGenericParam filter( KFilter, TLiwVariant( filterMap ));          
       
   234     iInParamList->AppendL( filter );
       
   235 
       
   236     iCPSNotificationInterface->ExecuteCmdL( KRequestNotification, 
       
   237             *iInParamList, 
       
   238             *iOutParamList,
       
   239             KLiwOptASyncronous,
       
   240             this );
       
   241 
       
   242     CleanupStack::PopAndDestroy( filterMap );
       
   243     filter.Reset();
       
   244     cptype.Reset();
       
   245 
       
   246     iInParamList->Reset();
       
   247     iOutParamList->Reset();
       
   248     }
       
   249 
       
   250 // ---------------------------------------------------------------------------
       
   251 // SetupPublisherL
       
   252 // ---------------------------------------------------------------------------
       
   253 //
       
   254 void CGlxContentHarvesterPluginBase::SetupPublisherL(TInt aSuiteItem)
       
   255     {
       
   256     TRACER( "CGlxContentHarvesterPluginBase::SetupPublisherL" );
       
   257 
       
   258     //add mandatory type param
       
   259     TLiwGenericParam cptype( KType, TLiwVariant( KPublisherId ));
       
   260     iInParamList->AppendL( cptype );
       
   261 
       
   262     //create publisher definition
       
   263     CLiwDefaultMap* filterMap = CLiwDefaultMap::NewLC();
       
   264     filterMap->InsertL( KPublisherId, TLiwVariant( KSuitePublisher ));
       
   265     switch (aSuiteItem)
       
   266         {
       
   267         case KItemIndexMonths:
       
   268             filterMap->InsertL( KContentType, TLiwVariant( KContentActivationMonths ) );
       
   269             break;
       
   270         case KItemIndexAlbums:
       
   271             filterMap->InsertL( KContentType, TLiwVariant( KContentActivationAlbums ) );
       
   272             break;
       
   273         case KItemIndexTags:
       
   274             filterMap->InsertL( KContentType, TLiwVariant( KContentActivationTags ) );
       
   275             break;
       
   276         case KItemIndexAll:
       
   277             filterMap->InsertL( KContentType, TLiwVariant( KContentActivationAll ) );
       
   278             break;
       
   279         }
       
   280     filterMap->InsertL( KContentId, TLiwVariant( KContentDefault ) );
       
   281     // initial value for activation flag
       
   282     filterMap->InsertL( KFlag, TLiwVariant( TUint(0) ) );
       
   283 
       
   284 
       
   285     // prepare Access Control List for the publisher
       
   286     CLiwDefaultMap* cpsAclMap = CLiwDefaultMap::NewLC();
       
   287     CLiwDefaultMap* cpsAclWriteMap = CLiwDefaultMap::NewLC();
       
   288     CLiwDefaultMap* cpsAclReadMap = CLiwDefaultMap::NewLC();
       
   289 
       
   290     // write policy - allow only MatrixMenu,
       
   291     // Matrix has 2 UIDs:
       
   292     //     - 0x20012474 is used if it is compiled as a standalone application
       
   293     //     - 0x101F4CD2 is used if it should replace AppShell
       
   294     // add both for convenience
       
   295     cpsAclWriteMap->InsertL( KUIDs, TLiwVariant( _L("0x101F4CD2:0x20012474") ) );
       
   296 
       
   297     // read policy - allow only the Content Harvester plug-in,
       
   298     // this plug-in runs inside Content Harvester server - UID 0x10282E5A
       
   299     cpsAclReadMap->InsertL( KUIDs, TLiwVariant( _L("0x10282E5A") ) );
       
   300 
       
   301     cpsAclMap->InsertL( KACLWrite, TLiwVariant( cpsAclWriteMap ) );
       
   302     cpsAclMap->InsertL( KACLRead, TLiwVariant( cpsAclReadMap ) );
       
   303 
       
   304     filterMap->InsertL( KAccessList, TLiwVariant( cpsAclMap ) );
       
   305 
       
   306     // create a dummy data map,
       
   307     // mandatory for adding publisher data - can be left empty
       
   308     CLiwDefaultMap* cpsDummyDataMap = CLiwDefaultMap::NewLC();
       
   309     filterMap->InsertL( KDataMap, TLiwVariant( cpsDummyDataMap ) );
       
   310 
       
   311     TLiwGenericParam cpsItemParam( KItem, TLiwVariant( filterMap ) );       
       
   312     iInParamList->AppendL( cpsItemParam );
       
   313 
       
   314 
       
   315     iCPSNotificationInterface->ExecuteCmdL( KAdd, 
       
   316             *iInParamList, 
       
   317             *iOutParamList,
       
   318             0,
       
   319             NULL );
       
   320     CleanupStack::PopAndDestroy( cpsDummyDataMap );
       
   321     CleanupStack::PopAndDestroy( cpsAclReadMap );
       
   322     CleanupStack::PopAndDestroy( cpsAclWriteMap );
       
   323     CleanupStack::PopAndDestroy( cpsAclMap );
       
   324     CleanupStack::PopAndDestroy( filterMap );
       
   325     cpsItemParam.Reset();
       
   326     // filter.Reset();
       
   327     cptype.Reset();
       
   328 
       
   329     iInParamList->Reset();
       
   330     iOutParamList->Reset();
       
   331     }
       
   332 
       
   333 // ---------------------------------------------------------------------------
       
   334 // HandleStateChangeL
       
   335 // ---------------------------------------------------------------------------
       
   336 //
       
   337 void CGlxContentHarvesterPluginBase::HandleStateChangeL(TInt aSuiteItem)
       
   338     {
       
   339     TRACER( "CGlxContentHarvesterPluginBase::HandleStateChangeL" );
       
   340 
       
   341     TLiwGenericParam cptype( KType, TLiwVariant( KPublisher ));
       
   342     iInParamList->AppendL( cptype );
       
   343 
       
   344     CLiwDefaultMap* filterMap = CLiwDefaultMap::NewLC();
       
   345     filterMap->InsertL( KPublisherId, TLiwVariant( KSuitePublisher ));
       
   346     switch (aSuiteItem)
       
   347         {
       
   348         case KItemIndexMonths:
       
   349             filterMap->InsertL( KContentType, TLiwVariant( KContentActivationMonths ) );
       
   350             break;
       
   351 
       
   352         case KItemIndexAlbums:
       
   353             filterMap->InsertL( KContentType, TLiwVariant( KContentActivationAlbums ) );
       
   354             break;
       
   355 
       
   356         case KItemIndexTags:
       
   357             filterMap->InsertL( KContentType, TLiwVariant( KContentActivationTags ) );
       
   358             break;
       
   359 
       
   360         case KItemIndexAll:
       
   361             filterMap->InsertL( KContentType, TLiwVariant( KContentActivationAll ) );
       
   362             break;
       
   363         }
       
   364 
       
   365     TLiwGenericParam filter( KFilter, TLiwVariant( filterMap ));      
       
   366     iInParamList->AppendL( filter );
       
   367 
       
   368 
       
   369     iCPSNotificationInterface->ExecuteCmdL( KGetList, 
       
   370             *iInParamList, 
       
   371             *iOutParamList,
       
   372             0,
       
   373             NULL );
       
   374 
       
   375     CleanupStack::PopAndDestroy( filterMap );
       
   376 
       
   377     filter.Reset();
       
   378     cptype.Reset();
       
   379 
       
   380     TInt posStat( 0 );
       
   381     iOutParamList->FindFirst( posStat, KResults );
       
   382     if( posStat != KErrNotFound )
       
   383         {
       
   384         // status info present - extract and return
       
   385         CLiwIterable* results = (*iOutParamList)[posStat].Value().AsIterable();
       
   386         TLiwVariant cpdata;
       
   387         if ( results->NextL( cpdata ) )
       
   388             {
       
   389             const CLiwMap* map = cpdata.AsMap();
       
   390             TLiwVariant dataMapVar;
       
   391             if ( map->FindL( _L8("flag"), dataMapVar ) )
       
   392                 {
       
   393                 ActivateL(dataMapVar.AsTInt32());
       
   394                 }
       
   395             dataMapVar.Reset();
       
   396             }
       
   397         cpdata.Reset();
       
   398         }
       
   399     else
       
   400         {
       
   401         // no return value
       
   402         // this will happen if suite was never activated/deactivated before
       
   403         // handle gracefuly - ignore and wait for action ;]
       
   404         }
       
   405 
       
   406     iInParamList->Reset();
       
   407     iOutParamList->Reset();
       
   408 
       
   409     }
       
   410 
       
   411 
       
   412 // ----------------------------------------------------------------------------
       
   413 // CGlxContentHarvesterPluginBase::FillInputListWithDataL()
       
   414 // ----------------------------------------------------------------------------
       
   415 //
       
   416 void CGlxContentHarvesterPluginBase::FillInputListWithDataL( 
       
   417         CLiwGenericParamList* aInParamList,
       
   418         const TDesC& aPublisherId, const TDesC& aContentType, 
       
   419         const TDesC& aContentId, TInt aHandle)
       
   420     {
       
   421     TRACER( "CGlxContentHarvesterPluginBase::FillInputListWithDataL" );
       
   422 
       
   423     aInParamList->Reset();
       
   424 
       
   425     TLiwGenericParam cptype( KType, TLiwVariant( KCpData ));
       
   426     aInParamList->AppendL( cptype );
       
   427 
       
   428     CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC();
       
   429     CLiwDefaultMap* map = CLiwDefaultMap::NewLC();
       
   430 
       
   431     if(aHandle)
       
   432         {
       
   433         map->InsertL( KFirstIcon, TLiwVariant( (TInt32)aHandle) );
       
   434         }
       
   435 
       
   436     cpdatamap->InsertL( KPublisherId, TLiwVariant( aPublisherId ));
       
   437     cpdatamap->InsertL( KContentType, TLiwVariant( aContentType )); 
       
   438     cpdatamap->InsertL( KContentId, TLiwVariant( aContentId ));
       
   439     cpdatamap->InsertL( KDataMap, TLiwVariant(map) );
       
   440 
       
   441     TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ));        
       
   442     aInParamList->AppendL( item );
       
   443     CleanupStack::PopAndDestroy( map );
       
   444     CleanupStack::PopAndDestroy( cpdatamap );
       
   445     item.Reset();
       
   446     cptype.Reset(); 
       
   447 
       
   448     }
       
   449 
       
   450 // ---------------------------------------------------------------------------
       
   451 // CreateMedialistAndAttributeContextL
       
   452 // ---------------------------------------------------------------------------
       
   453 //
       
   454 MGlxMediaList* CGlxContentHarvesterPluginBase::CreateMedialistAndAttributeContextL(
       
   455 					const TGlxMediaId& aPluginId,
       
   456 					CGlxAttributeContext* aUriAttributeContext, 
       
   457 					CGlxAttributeContext* aThumbnailAttributeContext) const    		
       
   458     		{
       
   459             TRACER( "CGlxContentHarvesterPluginBase::CreateMedialistAndThumbnailContextL" );        
       
   460                  
       
   461             CMPXCollectionPath* path = CMPXCollectionPath::NewL();
       
   462             CleanupStack::PushL( path );
       
   463             path->AppendL( aPluginId.Value() );               
       
   464 
       
   465             CMPXFilter* filter = NULL;
       
   466             filter = TGlxFilterFactory::CreatePreviewFilterL(); 
       
   467             CleanupStack::PushL( filter );
       
   468 
       
   469             MGlxMediaList* mediaList = MGlxMediaList::InstanceL( *path, KGlxIdNone , filter);
       
   470             CleanupStack::PopAndDestroy( filter );
       
   471             CleanupStack::PopAndDestroy( path );  
       
   472             
       
   473             // Two different contexts are added. One for URI with high priority
       
   474             // and for Thumbnail with low priority. Because URI attribute should be
       
   475             // fetched first before placing thumbnail fetch request
       
   476             
       
   477             aUriAttributeContext->AddAttributeL(KMPXMediaGeneralUri);  
       
   478      
       
   479             TMPXAttribute attr( KGlxMediaIdThumbnail,
       
   480 								GlxFullThumbnailAttributeId(ETrue,
       
   481 									iGridIconSize.iWidth,iGridIconSize.iHeight) );
       
   482             
       
   483             aThumbnailAttributeContext->SetDefaultSpec(iGridIconSize.iWidth,
       
   484             											iGridIconSize.iHeight);
       
   485             
       
   486             aThumbnailAttributeContext->AddAttributeL(attr);    
       
   487          
       
   488             return mediaList;
       
   489             }
       
   490 
       
   491 
       
   492 // ---------------------------------------------------------------------------
       
   493 // CGlxContentHarvesterPluginBase::Focused
       
   494 // ---------------------------------------------------------------------------
       
   495 //
       
   496 TBool CGlxContentHarvesterPluginBase::Focused()
       
   497     {
       
   498     TRACER( "CGlxContentHarvesterPluginBase::Focused" );
       
   499     GLX_LOG_INFO1("CGlxContentHarvesterPluginBase::Focused(%d)", iIsFocused);
       
   500     return iIsFocused;
       
   501     }
       
   502 
       
   503 // ---------------------------------------------------------------------------
       
   504 // CGlxContentHarvesterPluginBase::SetFocus
       
   505 // ---------------------------------------------------------------------------
       
   506 //
       
   507 void CGlxContentHarvesterPluginBase::SetFocus(TBool aFocus )
       
   508     {
       
   509     TRACER( "CGlxContentHarvesterPluginBase::SetFocus" );
       
   510     iIsFocused=aFocus;
       
   511     }
       
   512 
       
   513 // ---------------------------------------------------------------------------
       
   514 // ContainerCacheCleanupL
       
   515 // ---------------------------------------------------------------------------
       
   516 //
       
   517 void CGlxContentHarvesterPluginBase::ContainerCacheCleanupL(MGlxMediaList* aMediaList)
       
   518     {
       
   519     TRACER( "CGlxContentHarvesterPluginBase::ContainerCacheCleanupL" ); 
       
   520       
       
   521     if ( IsMatrixMenuInForegroundL() )
       
   522         {
       
   523         MGlxCache* cacheManager = MGlxCache::InstanceL();   
       
   524         for(TInt i=0 ; i< aMediaList->Count();i++)
       
   525             {  
       
   526             GLX_LOG_INFO1("CGlxContentHarvesterPluginBase::ForceCleanupMedia(%d)", i);
       
   527             cacheManager->ForceCleanupMedia(aMediaList->IdSpaceId(i),
       
   528                                             aMediaList->Item(i).Id());
       
   529             }
       
   530         cacheManager->Close();  
       
   531         }    
       
   532     }
       
   533 
       
   534 // ---------------------------------------------------------------------------
       
   535 // IsMatrixMenuInForegroundL
       
   536 // ---------------------------------------------------------------------------
       
   537 //
       
   538 TBool CGlxContentHarvesterPluginBase::IsMatrixMenuInForegroundL()
       
   539     {
       
   540     TRACER( "CGlxContentHarvesterPluginBase::IsMatrixMenuInForegroundL" );
       
   541     
       
   542     RWsSession wssession;
       
   543     User::LeaveIfError(wssession.Connect());
       
   544     CleanupClosePushL(wssession);
       
   545         
       
   546     TApaTaskList taskList( wssession );       
       
   547     TApaTask task = taskList.FindApp( TUid::Uid( KMatrixMenuUid ) );
       
   548     // get fopreground app
       
   549     TApaTask taskForeGround = taskList.FindByPos(0); 
       
   550    
       
   551     if ( task.Exists() && task.ThreadId() == taskForeGround.ThreadId() )
       
   552         {
       
   553         CleanupStack::PopAndDestroy( &wssession ); 
       
   554         return ETrue;
       
   555         } 
       
   556     CleanupStack::PopAndDestroy( &wssession ); 
       
   557     return EFalse;
       
   558     }
       
   559 
       
   560 // ---------------------------------------------------------------------------
       
   561 // SetCHPlugin
       
   562 // ---------------------------------------------------------------------------
       
   563 //
       
   564 void CGlxContentHarvesterPluginBase::SetCHPlugin(MGlxContentHarvesterPlugin* aCHplugin)
       
   565 	{
       
   566 	iCHplugin = aCHplugin;
       
   567 	}
       
   568 
       
   569 // ---------------------------------------------------------------------------
       
   570 // GetCHPlugin
       
   571 // ---------------------------------------------------------------------------
       
   572 //
       
   573 MGlxContentHarvesterPlugin* CGlxContentHarvesterPluginBase::GetCHPlugin()
       
   574 	{
       
   575 	return iCHplugin;
       
   576 	}
       
   577 
       
   578 // EOF