ui/uiengine/medialists/src/glxcachemanager.cpp
changeset 23 74c9f037fd5d
child 24 99ad1390cd33
equal deleted inserted replaced
5:f7f0874bfe7d 23:74c9f037fd5d
       
     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:    Manager of media item cache
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "glxcachemanager.h"
       
    22 
       
    23 #include <mpxcollectionutility.h>
       
    24 #include <glxtracer.h>
       
    25 #include <glxthumbnailattributeinfo.h>
       
    26 #include <glxthumbnail.h>
       
    27 #include <glxsingletonstore.h>
       
    28 #include <glximageviewermanager.h>
       
    29 
       
    30 #include "glxcache.h"
       
    31 #include "glxerrormanager.h"
       
    32 #include "glxgarbagecollector.h"
       
    33 #include "glxmedialist.h"
       
    34 #include <hal.h>
       
    35 #include <glxcollectionpluginimageviewer.hrh>
       
    36 #include <mpxmediacollectiondetaildefs.h>
       
    37 #include <mpxmediadrmdefs.h>
       
    38 #include <f32file.h>
       
    39 #include <lbsposition.h>
       
    40 #include <apgcli.h>
       
    41 #include <caf/content.h>
       
    42 #include <caf/attributeset.h>
       
    43 #include <DRMHelper.h>
       
    44 
       
    45 #ifdef USE_S60_TNM
       
    46 #include <thumbnaildata.h>
       
    47 const TInt KMaxGridThumbnailWidth = 200;
       
    48 _LIT(KFileIdentifier, ":\\");
       
    49 #endif
       
    50 
       
    51 _LIT(KDefaultType, "image/jpg");
       
    52 /// How long to wait before rechecking for cleared temporary errors
       
    53 /// @todo Find optimal value for this
       
    54 const TInt KGlxTemporaryErrorRecheckPeriodInSeconds = 5;
       
    55 
       
    56 const TInt KGlxLowerMemoryLimitForCleanUp = 15000000;
       
    57 
       
    58 const TInt KGlxUpperMemoryLimitForCleanUp = 25000000;
       
    59 
       
    60 //Defining number of pages to be flushed in critical low memory conditions.
       
    61 const TInt KGlxNoOfPagesToFlushInCriticalLowMemory = 4;
       
    62 // -----------------------------------------------------------------------------
       
    63 // InstanceL
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CGlxCacheManager* CGlxCacheManager::InstanceL()
       
    67 	{
       
    68 	TRACER("CGlxCacheManager::InstanceL");
       
    69 	
       
    70 	return CGlxSingletonStore::InstanceL(&NewL);
       
    71 	}
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // NewL
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 CGlxCacheManager* CGlxCacheManager::NewL()
       
    78     {
       
    79     TRACER("CGlxCacheManager::NewL");
       
    80     
       
    81     CGlxCacheManager* self = new( ELeave ) CGlxCacheManager();
       
    82     CleanupStack::PushL( self );
       
    83     self->ConstructL();
       
    84     CleanupStack::Pop(self);
       
    85     return self;
       
    86     }
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // Close
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CGlxCacheManager::Close()
       
    93 	{
       
    94 	TRACER("CGlxCacheManager::Close");
       
    95 	
       
    96 	CGlxSingletonStore::Close(this);
       
    97 	}
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // Constructor
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 CGlxCacheManager::CGlxCacheManager()
       
   104     {
       
   105     TRACER("CGlxCacheManager::Default Constructor");
       
   106     
       
   107     }
       
   108     
       
   109 // -----------------------------------------------------------------------------
       
   110 // ConstructL
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 void CGlxCacheManager::ConstructL()
       
   114     {
       
   115     TRACER("CGlxCacheManager::ConstructL");
       
   116     
       
   117     iGarbageCollector = CGlxGarbageCollector::NewL( iCaches );
       
   118     iTempErrorTimer = CPeriodic::NewL(CActive::EPriorityStandard);
       
   119     iSchedulerWait = new (ELeave) CActiveSchedulerWait();
       
   120     iMaintainCacheCallback = new ( ELeave )
       
   121 	    CAsyncCallBack( TCallBack( MaintainCacheL, this ), CActive::EPriorityStandard );
       
   122 	    
       
   123 #ifdef USE_S60_TNM
       
   124     iTnEngine = CThumbnailManager::NewL( *this);
       
   125     iTnEngine->SetDisplayModeL( EColor64K );
       
   126 #endif
       
   127     }
       
   128         
       
   129 // -----------------------------------------------------------------------------
       
   130 // Destructor
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 CGlxCacheManager::~CGlxCacheManager()
       
   134 	{
       
   135 	TRACER("CGlxCacheManager::Destructor");
       
   136 	
       
   137     delete iSchedulerWait;
       
   138  	iObserverList.ResetAndDestroy();
       
   139  	iCaches.ResetAndDestroy();
       
   140  	delete iTempThumbnail;
       
   141  	iRequestedItemIds.Reset();
       
   142  	iRequestedAttrs.Reset();
       
   143  	iRequestedItemIndexes.Reset();
       
   144     if(iReader)
       
   145         {
       
   146         delete iReader;
       
   147         }
       
   148 
       
   149  	delete iGarbageCollector;
       
   150 
       
   151     if (iTempErrorTimer)
       
   152         {
       
   153 		iTempErrorTimer->Cancel();	
       
   154 		delete iTempErrorTimer;
       
   155         }
       
   156 
       
   157 #ifdef USE_S60_TNM
       
   158     GLX_DEBUG2("CGlxCacheManager::~CGlxCacheManager() TN Ids count()=%d",
       
   159 										 iThumbnailRequestIds.Count());
       
   160     for (TInt i = 0; i < iThumbnailRequestIds.Count(); i++)
       
   161         {
       
   162         iTnEngine->CancelRequest(iThumbnailRequestIds[i].iId);
       
   163         }
       
   164 	iThumbnailRequestIds.Reset();
       
   165     delete iTnEngine;
       
   166     delete iMPXMedia;
       
   167 #endif
       
   168     
       
   169     delete iMaintainCacheCallback;
       
   170 	}
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // HandleWindowChangedL
       
   174 // From MVieMediaItemListManager
       
   175 // The list calls this function to hint the list manager, that the items 
       
   176 // the list contains might not all be loaded, and it would be nice if the list
       
   177 // manager could load the missing items to the cache.
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 void CGlxCacheManager::HandleWindowChangedL(CGlxMediaList* /*aList*/) 
       
   181 	{
       
   182 	TRACER("CGlxCacheManager::HandleWindowChangedL");
       
   183 	
       
   184 	GLX_LOG_INFO("---- MGallery - CGlxCacheManager::HandleWindowChangedL()---- ");
       
   185     
       
   186     iMaintainCacheCallback->CallBack();
       
   187     // Its Better if we are not Cleaning Cache here; Instaed Can Do inside MainTainCache
       
   188     //MaintainCacheL();
       
   189     //iGarbageCollector->Cleanup();
       
   190     }
       
   191 
       
   192 // -----------------------------------------------------------------------------
       
   193 // CancelPreviousRequest
       
   194 // This API cancels the pending attributes and thumbnail request  
       
   195 // when the media item in focus is NULL
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 void CGlxCacheManager::CancelPreviousRequest()
       
   199 	{
       
   200 	TRACER("CGlxCacheManager::CancelPreviousRequest");		
       
   201 	
       
   202 	// iRequestOwner is NULL, if there are no pending attribute/thumbnail request
       
   203 	// If no pending request, do nothing, else cancel the the pending requests
       
   204 	if(iRequestOwner)
       
   205 		{		
       
   206 		MMPXCollection& collection = iRequestOwner->Collection();
       
   207 		// Cancel the pending attribute request
       
   208 		collection.CancelRequest();	
       
   209 		
       
   210 #ifdef USE_S60_TNM
       
   211 		GLX_DEBUG2("CGlxCacheManager::CancelPreviousRequest() iThumbnailRequestIds.Count() %d", iThumbnailRequestIds.Count());
       
   212 		
       
   213 		// Check if any thumbnail requests are pending and cancel the requests.		
       
   214 		for (TInt i = 0; i < iThumbnailRequestIds.Count(); i++)
       
   215 			{ 			
       
   216 			iTnEngine->CancelRequest(iThumbnailRequestIds[i].iId);									
       
   217 			}
       
   218 		iThumbnailRequestIds.Reset();		
       
   219 #endif
       
   220 		iRequestOwner = NULL;
       
   221 		}
       
   222 	}
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // HandleGarbageCollection
       
   226 // Garbage Collection Quick or with Timer
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 void CGlxCacheManager::HandleGarbageCollectionL(TBool aStart)
       
   230     {
       
   231     TRACER("CGlxCacheManager::HandleGarbageCollection");
       
   232     TInt freeMemory = 0;
       
   233     
       
   234     HAL::Get( HALData::EMemoryRAMFree, freeMemory );
       
   235         
       
   236     if(aStart)
       
   237         {
       
   238            if(freeMemory < KGlxLowerMemoryLimitForCleanUp)
       
   239                {
       
   240                // 2 page - 30 Items for Flush
       
   241                TInt count = 2;  
       
   242                if(freeMemory < (KGlxLowerMemoryLimitForCleanUp/2))
       
   243                    {
       
   244                    // If Memory is below this limit it's ok i can wait for 60 items to clean-up
       
   245                    count = KGlxNoOfPagesToFlushInCriticalLowMemory;
       
   246                    }
       
   247                // Cancel Clean-up before Flush Page; Clean-up will be starting just after Flush page
       
   248                iGarbageCollector->CancelCleanup(); 
       
   249                iGarbageCollector->FlushPagesL(count);
       
   250                iGarbageCollector->CleanupL();
       
   251                iCleanUpOnGoing = ETrue;         // Clean up is Started now i can call CancelClean-up to Stop Clean Up
       
   252                }
       
   253            else if((freeMemory < KGlxUpperMemoryLimitForCleanUp) && !iCleanUpOnGoing)
       
   254                {
       
   255                iGarbageCollector->CleanupL();
       
   256                iCleanUpOnGoing = ETrue;         // Clean up is Started now i can call CancelClean-up to Stop Clean Up
       
   257                }
       
   258            // This is Added to Keep Assure Clean-up is not going to Disturb normal Flow if there is Enough Memory
       
   259            // We Remove this Code After Evaluation of Use of this Code
       
   260            else if(iCleanUpOnGoing)
       
   261                {
       
   262                iGarbageCollector->CancelCleanup();
       
   263                iCleanUpOnGoing = EFalse;
       
   264                }
       
   265                
       
   266            }
       
   267        else if(freeMemory < KGlxLowerMemoryLimitForCleanUp)
       
   268            {
       
   269            // 2 page - 30 Items for Flush
       
   270            TInt count = 2;
       
   271            if(freeMemory < (KGlxLowerMemoryLimitForCleanUp/2))
       
   272                {
       
   273                // If Memory is below this limit it's ok i can wait for 60 items to clean-up
       
   274                count = KGlxNoOfPagesToFlushInCriticalLowMemory;
       
   275                }
       
   276            // Cancel Clean-up before Flush Page; Clean-up will be starting just after Flush page
       
   277            iGarbageCollector->CancelCleanup();
       
   278            iGarbageCollector->FlushPagesL(count);
       
   279         iGarbageCollector->CleanupL();
       
   280         iCleanUpOnGoing = ETrue;         // Clean up is Started now i can call CancelClean-up to Stop Clean Up
       
   281         }
       
   282     else if(iCleanUpOnGoing)
       
   283         {
       
   284         iGarbageCollector->CancelCleanup();
       
   285         iCleanUpOnGoing = EFalse;
       
   286         }
       
   287     }
       
   288 		
       
   289 // -----------------------------------------------------------------------------
       
   290 // Match
       
   291 // return ETrue if path levels match
       
   292 // -----------------------------------------------------------------------------
       
   293 //
       
   294 TBool CGlxCacheManager::Match(const CMPXCollectionPath& aPath1, 
       
   295 		const CMPXCollectionPath& aPath2)
       
   296 	{
       
   297 	TRACER("CGlxCacheManager::Match");
       
   298 	
       
   299 	TInt levels1 = aPath1.Levels();
       
   300 	TInt levels2 = aPath2.Levels();
       
   301 	
       
   302 	// Paths must be as deep to match
       
   303 	if (levels1 != levels2) 
       
   304 		{
       
   305 		return EFalse; 
       
   306 		}
       
   307 		
       
   308 	// Check if all levels match
       
   309 	for (TInt i = 0; i < levels1; i++) 
       
   310 		{
       
   311 		if (aPath1.Index(i) != aPath2.Index(i))
       
   312 			{
       
   313 			return EFalse;
       
   314 			}
       
   315 		}
       
   316 		
       
   317 	return ETrue;
       
   318 	}
       
   319 	
       
   320 // -----------------------------------------------------------------------------
       
   321 // HandleCollectionMediaL
       
   322 // -----------------------------------------------------------------------------
       
   323 //
       
   324 void CGlxCacheManager::HandleCollectionMediaL(const TGlxIdSpaceId& aIdSpaceId, const CMPXMedia& aMedia, TInt aError)
       
   325     {
       
   326     TRACER("CGlxCacheManager::HandleCollectionMediaL");
       
   327     
       
   328     iRequestOwner = NULL;
       
   329 
       
   330     if ( KErrNone == aError )
       
   331         {
       
   332         // Update the cache
       
   333         CGlxCache* cache = FindCacheForceCreateL(aIdSpaceId);
       
   334         cache->MediaUpdatedL(aMedia);
       
   335         }
       
   336     else
       
   337         {
       
   338         RPointerArray< MGlxMediaUser > users;
       
   339         CleanupClosePushL( users );
       
   340         
       
   341         // Record the error on all requested attributes
       
   342         TInt idCount = iRequestedItemIds.Count();
       
   343         
       
   344         for( TInt idIndex = 0; idIndex < idCount; idIndex++ )
       
   345             {
       
   346             CGlxMedia* item = MediaForceCreateL(aIdSpaceId, iRequestedItemIds[idIndex]);
       
   347             GlxErrorManager::SetAttributeErrorL(item, iRequestedAttrs, aError);
       
   348             
       
   349             // Keep track of media lists to notify later
       
   350             TInt userCount = item->UserCount();
       
   351             for ( TInt userIndex = 0; userIndex < userCount; userIndex++ )
       
   352                 {
       
   353                 users.InsertInAddressOrder( &item->User( userIndex ) );
       
   354                 }
       
   355             }
       
   356 
       
   357         // Notify all affected users of error
       
   358         TInt userCount = users.Count();
       
   359         for ( TInt i = 0; i < userCount; i++ )
       
   360             {
       
   361             users[ i ]->HandleError( aError );
       
   362             }
       
   363 
       
   364         CleanupStack::PopAndDestroy( &users );
       
   365         }
       
   366     
       
   367     MaintainCacheL();
       
   368     }
       
   369 
       
   370 // -----------------------------------------------------------------------------
       
   371 // FindCacheForceCreateL
       
   372 // -----------------------------------------------------------------------------
       
   373 //
       
   374 CGlxCache* CGlxCacheManager::FindCacheForceCreateL(const TGlxIdSpaceId& aIdSpaceId)
       
   375     {
       
   376     TRACER("CGlxCacheManager::FindCacheForceCreateL");
       
   377     
       
   378     CGlxCache* cache = NULL;
       
   379 
       
   380     // Look for existing cache
       
   381     TInt index = iCaches.FindInOrder(aIdSpaceId, (&CacheOrderByKey));
       
   382     if ( KErrNotFound == index )
       
   383         {
       
   384         // Not found: create one
       
   385     	TLinearOrder<CGlxCache> orderer (&CacheOrderById);
       
   386         cache = new (ELeave) CGlxCache(aIdSpaceId, this);
       
   387 
       
   388         CleanupStack::PushL(cache);
       
   389         iCaches.InsertInOrderL(cache, orderer);
       
   390         CleanupStack::Pop(cache);
       
   391         }
       
   392     else
       
   393         {
       
   394         cache = iCaches[index];
       
   395         }
       
   396 
       
   397     return cache;
       
   398     }
       
   399     
       
   400 // -----------------------------------------------------------------------------
       
   401 // Media
       
   402 // -----------------------------------------------------------------------------
       
   403 //
       
   404 CGlxMedia* CGlxCacheManager::Media( const TGlxIdSpaceId& aIdSpaceId, 
       
   405         const TGlxMediaId& aMediaId ) const
       
   406     {
       
   407     TRACER("CGlxCacheManager::Media");
       
   408     
       
   409     // Look for the correct subcache
       
   410     TInt index = iCaches.FindInOrder( aIdSpaceId, &CacheOrderByKey );
       
   411     
       
   412     if ( KErrNotFound == index )
       
   413         {
       
   414         // No caches exist with this space id
       
   415         return NULL;
       
   416         }
       
   417     else
       
   418         {
       
   419         return iCaches[index]->Media( aMediaId );
       
   420         }
       
   421     }
       
   422     
       
   423 // -----------------------------------------------------------------------------
       
   424 // MediaForceCreateL
       
   425 // -----------------------------------------------------------------------------
       
   426 //
       
   427 CGlxMedia* CGlxCacheManager::MediaForceCreateL(const TGlxIdSpaceId& aIdSpaceId, const TGlxMediaId& aMediaId)
       
   428     {
       
   429     TRACER("CGlxCacheManager::MediaForceCreateL");
       
   430     
       
   431     CGlxCache* cache = FindCacheForceCreateL(aIdSpaceId);
       
   432     return cache->FindItemForceCreateL(aMediaId);
       
   433     }
       
   434     
       
   435 // -----------------------------------------------------------------------------
       
   436 // AddObserverL
       
   437 // -----------------------------------------------------------------------------
       
   438 //
       
   439 void CGlxCacheManager::AddObserverL(MGlxCacheObserver* aObserver)
       
   440     {
       
   441     TRACER("CGlxCacheManager::AddObserverL");
       
   442     
       
   443     if ( aObserver )
       
   444         {
       
   445         if ( KErrNotFound == iObserverList.Find( aObserver ))
       
   446             {
       
   447             iObserverList.AppendL(aObserver);
       
   448             }
       
   449         }
       
   450     }
       
   451     
       
   452 // -----------------------------------------------------------------------------
       
   453 // RemoveObserver
       
   454 // -----------------------------------------------------------------------------
       
   455 //
       
   456 void CGlxCacheManager::RemoveObserver(MGlxCacheObserver* aObserver)
       
   457     {
       
   458     TRACER("CGlxCacheManager::RemoveObserver");
       
   459     
       
   460     if ( aObserver )
       
   461         {
       
   462         TInt index = iObserverList.Find( aObserver );
       
   463         if ( KErrNotFound != index )
       
   464             {
       
   465             iObserverList.Remove(index);
       
   466             }
       
   467         }
       
   468     }
       
   469 
       
   470 // ---------------------------------------------------------------------------
       
   471 // Refresh
       
   472 // ---------------------------------------------------------------------------
       
   473 //
       
   474 void CGlxCacheManager::RefreshL()
       
   475     {
       
   476     TRACER("CGlxCacheManager::Refresh");
       
   477     
       
   478     if ( !iRequestOwner )
       
   479         {
       
   480         // Currently idle, so trigger timer immediately to begin refresh
       
   481         iTempErrorTimer->Cancel();
       
   482         iTempErrorTimer->Start( 0, 0,
       
   483                             TCallBack( TempErrorTimerCallbackL, this ) );
       
   484         
       
   485         HandleGarbageCollectionL(ETrue);  // Clean-up is needed here; Considering Current Memory Condition
       
   486         }
       
   487     }
       
   488 
       
   489 // -----------------------------------------------------------------------------
       
   490 // MaintainCache
       
   491 // -----------------------------------------------------------------------------
       
   492 //
       
   493 TInt CGlxCacheManager::MaintainCacheL(TAny* aPtr)
       
   494     {
       
   495     TRACER("CGlxCacheManager::MaintainCache");
       
   496     
       
   497     CGlxCacheManager* self
       
   498                     = reinterpret_cast<CGlxCacheManager*>( aPtr );
       
   499     self->MaintainCacheL();
       
   500     
       
   501     // Clean-up is needed here; Considering Current Memory Condition
       
   502     // For Every HandleWindowChangedL; We Should not do Clean-up 
       
   503     self->HandleGarbageCollectionL(ETrue);  
       
   504     return 0;
       
   505     }
       
   506     
       
   507 // -----------------------------------------------------------------------------
       
   508 // MaintainCacheL
       
   509 // -----------------------------------------------------------------------------
       
   510 //
       
   511 void CGlxCacheManager::MaintainCacheL() 
       
   512     {
       
   513     TRACER("CGlxCacheManager::MaintainCacheL");
       
   514     
       
   515 	// Handle lists in priority order: all data for the highest priority list 
       
   516 	// is retrieved before the data for a lower priority list. NOTE: This
       
   517 	// may need to be changed, since it might not always lead to the best
       
   518 	// user experienced. (It may be sensible to retrieve item properties
       
   519 	// for a lower priority list before all thumbnails for a higher priority 
       
   520 	// list, but this probably depends on the speed of the data sources.
       
   521 	// It might be wise to decouple the contexts from the media lists
       
   522 
       
   523     if (!iRequestOwner)
       
   524         {
       
   525         iTempError = EFalse;
       
   526         iTempErrorTimer->Cancel();
       
   527 
       
   528     	RPointerArray<CGlxMediaList>& mediaLists = CGlxMediaList::MediaListsL();
       
   529      	iRequestedItemIds.Reset();
       
   530      	iRequestedAttrs.Reset();
       
   531     	iRequestedItemIndexes.Reset();
       
   532     	
       
   533     	TInt listCount = mediaLists.Count();
       
   534 
       
   535     	// Request attributes in the fetch contexts
       
   536         for (TInt listIndex = 0; listIndex < listCount && !iRequestOwner; listIndex++)      
       
   537             {
       
   538             CGlxMediaList* list = mediaLists[listIndex];
       
   539 
       
   540     		CMPXAttributeSpecs* attrSpecs = NULL;
       
   541 
       
   542     		list->AttributeRequestL(iRequestedItemIndexes, iRequestedItemIds, iRequestedAttrs, attrSpecs );
       
   543     		CleanupStack::PushL(attrSpecs);
       
   544 
       
   545             TInt itemIdsCount = iRequestedItemIds.Count();
       
   546             if (itemIdsCount > 0)
       
   547                 {
       
   548                 if (attrSpecs)
       
   549                     {
       
   550                     GLX_DEBUG2("CGlxCacheManager::MaintainCacheL() attrSpecs->Count() %d", attrSpecs->Count());
       
   551                     }
       
   552                 
       
   553                 TGlxMediaId itemId = iRequestedItemIds[0];
       
   554 
       
   555                 CMPXCollectionPath* path = RequestAsPathLC( *list );
       
   556 
       
   557                 // Add request for id, if does not exist already. Id is used to 
       
   558                 // identify which media object the attribute belongs to when
       
   559                 // it is returned
       
   560                 TIdentityRelation<TMPXAttribute> match (&TMPXAttribute::Match);
       
   561                 if (iRequestedAttrs.Find(KMPXMediaGeneralId, match) == KErrNotFound) 
       
   562                     {
       
   563                     iRequestedAttrs.AppendL(KMPXMediaGeneralId);
       
   564                     }
       
   565 
       
   566                 // Create the empty bitmap, if the request is for a bitmap
       
   567                 TIdentityRelation<TMPXAttribute> matchContent(&TMPXAttribute::MatchContentId);
       
   568                 TMPXAttribute tnAttr(KGlxMediaIdThumbnail, 0);
       
   569                 if (iRequestedAttrs.Find(tnAttr, matchContent) != KErrNotFound) 
       
   570                     {
       
   571 #ifdef USE_S60_TNM
       
   572 					if (iRequestedItemIndexes.Count())
       
   573 						{
       
   574                         // Cancel Clean-up is needed here;
       
   575                         HandleGarbageCollectionL(EFalse);                           
       
   576 						
       
   577 			            TSize tnSize;
       
   578 						const TMPXAttributeData sizeAttrib = { KGlxMediaIdThumbnail , KGlxAttribSpecThumbnailSize };
       
   579       					if (attrSpecs && attrSpecs->IsSupported(sizeAttrib))
       
   580                         	{
       
   581 				    		tnSize = attrSpecs->ValueTObjectL<TSize>(sizeAttrib);
       
   582                         	}
       
   583 
       
   584 						const TGlxMedia& item = list->Item( iRequestedItemIndexes[0] );
       
   585       					TBool priority = ETrue;
       
   586       					const TMPXAttributeData priorityAttrib = { KGlxMediaIdThumbnail , KGlxAttribSpecThumbnailQualityOverSpeed };
       
   587       					if (attrSpecs && attrSpecs->IsSupported(priorityAttrib))
       
   588       					    {
       
   589       					    priority = attrSpecs->ValueTObjectL<TBool>(priorityAttrib);
       
   590       					    }
       
   591       					
       
   592 						TGlxIdSpaceId spaceId = list->IdSpaceId(iRequestedItemIndexes[0]);	
       
   593 #ifdef MEDIA_ID_BASED_TN_FETCH_ENABLED
       
   594 	               	 	GLX_DEBUG2("CGlxCacheManager::MaintainCacheL() requesting TN attribute (Medialist) itemId %d", itemId.Value());
       
   595 						if (item.Uri().Find(KFileIdentifier) != KErrNotFound ||
       
   596 						    item.Uri().Length() && itemId.Value())
       
   597 #else
       
   598 	               	 	GLX_DEBUG1("CGlxCacheManager::MaintainCacheL() requesting TN attribute (Medialist) Uri");
       
   599 						if (item.Uri().Find(KFileIdentifier) != KErrNotFound)
       
   600 #endif
       
   601 							{
       
   602 #ifdef _DEBUG
       
   603 							iStartTime.HomeTime(); // Get home time
       
   604 #endif							
       
   605 						    if (tnSize.iWidth < KMaxGridThumbnailWidth)
       
   606 						    	{
       
   607 						    	iTnEngine->SetFlagsL(CThumbnailManager::ECropToAspectRatio);
       
   608 							    iTnEngine->SetThumbnailSizeL(EGridThumbnailSize);
       
   609 							    GLX_DEBUG1("MaintainCacheL() - Fetch TN attrib - EGridThumbnailSize");
       
   610 						    	}
       
   611 						    else
       
   612 							    {
       
   613 							    iTnEngine->SetFlagsL(CThumbnailManager::EDefaultFlags);
       
   614 							    iTnEngine->SetThumbnailSizeL(EFullScreenThumbnailSize);
       
   615                                 GLX_DEBUG1("MaintainCacheL() - Fetch TN attrib - EFullScreenThumbnailSize");							    
       
   616 							    }
       
   617 						    
       
   618 						    if (priority)
       
   619 						        {
       
   620 						        iTnEngine->SetQualityPreferenceL(CThumbnailManager::EOptimizeForQuality);
       
   621                                 GLX_DEBUG1("MaintainCacheL() - Fetch TN attrib - EOptimizeForQuality");                                
       
   622 						        }
       
   623 						    else
       
   624 						        {
       
   625 						        iTnEngine->SetQualityPreferenceL(CThumbnailManager::EOptimizeForQualityWithPreview);
       
   626                                 GLX_DEBUG1("MaintainCacheL() - Fetch TN attrib - EOptimizeForQualityWithPreview");                                
       
   627                                 }
       
   628                             
       
   629                             if (list->Collection().UidL().iUid == KGlxCollectionPluginImageViewerImplementationUid)
       
   630                                 {
       
   631                                 GLX_DEBUG1("void CGlxCacheManager::MaintainCacheL:Imageviewer TN");
       
   632                                 _LIT( KPrivateFolder, "\\Private\\" );    // Platsec private folder  
       
   633                                 TParsePtrC parse( item.Uri() );
       
   634                                 if( parse.PathPresent() &&
       
   635                                     parse.Path().Length() > KPrivateFolder().Length() &&
       
   636                                     parse.Path().Left( KPrivateFolder().Length() ).CompareF( KPrivateFolder ) == 0 )
       
   637                                     {
       
   638                                     CGlxImageViewerManager *imageVwrMgr = CGlxImageViewerManager::InstanceL();
       
   639 									CleanupClosePushL(*imageVwrMgr);
       
   640                                     GLX_DEBUG1("KGlxCollectionPluginImageViewerImplementationUid - Fetch (Private) TN!");
       
   641                                     if ( &(imageVwrMgr->ImageFileHandle()) != NULL )
       
   642                                         {
       
   643                                         //CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(imageVwrMgr->ImageFileHandle());
       
   644                                         CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(imageVwrMgr->ImageUri()->Des(), 0);
       
   645                                         iThumbnailRequestIds.AppendL(TLoadingTN(iTnEngine->GetThumbnailL(*source), spaceId, tnSize, itemId));
       
   646                                         CleanupStack::PopAndDestroy(source);
       
   647                                         }
       
   648                                     CleanupStack::PopAndDestroy(imageVwrMgr);	
       
   649                                     }
       
   650                                 else
       
   651                                     {
       
   652                                     GLX_DEBUG1("void CGlxCacheManager::MaintainCacheL:Imageviewer In else");
       
   653                                     GLX_DEBUG2("CGlxCacheManager::MaintainCacheL: uri %S", &item.Uri());	
       
   654                                     CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(item.Uri(), 0);
       
   655                                     iThumbnailRequestIds.AppendL(TLoadingTN(iTnEngine->GetThumbnailL(*source), spaceId, tnSize, itemId));
       
   656                                     CleanupStack::PopAndDestroy(source);
       
   657                                     }
       
   658                                 }
       
   659                             else
       
   660                                 {
       
   661 #ifdef MEDIA_ID_BASED_TN_FETCH_ENABLED
       
   662 						    iThumbnailRequestIds.AppendL(TLoadingTN(iTnEngine->GetThumbnailL(itemId.Value()), spaceId, tnSize, itemId));
       
   663 #else
       
   664 						    CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(item.Uri(), 0);
       
   665 						    iThumbnailRequestIds.AppendL(TLoadingTN(iTnEngine->GetThumbnailL(*source), spaceId, tnSize, itemId));
       
   666 						    CleanupStack::PopAndDestroy(source);
       
   667 #endif
       
   668                                 }
       
   669 		                    iThumbnailId = itemId;
       
   670 							}
       
   671 						else
       
   672 							{
       
   673 		                    delete iTempThumbnail;
       
   674 		                    iTempThumbnail = NULL;
       
   675 		                    iTempThumbnail = new (ELeave) CFbsBitmap;
       
   676 		                    User::LeaveIfError(iTempThumbnail->Create(TSize(), KGlxThumbnailDisplayMode));
       
   677 		                    iThumbnailId = itemId;
       
   678 	               		 	GLX_DEBUG2("CGlxCacheManager::MaintainCacheL() requesting TN (DataSourceMde) attribute itemId %d", itemId.Value());
       
   679 
       
   680 		                    // Set bitmap handle in attribute spec
       
   681 		                    if (attrSpecs)
       
   682 		                        {
       
   683 		                        TMPXAttribute thHandleAttrSpec(KGlxMediaIdThumbnail, KGlxAttribSpecThumbnailBitmapHandle);
       
   684 		                        attrSpecs->SetTObjectValueL<TInt>(thHandleAttrSpec, iTempThumbnail->Handle());
       
   685 		                        }
       
   686 
       
   687 		                    // Cancel Clean-up is needed here;
       
   688 		                    // This is Going to Highly Used Call
       
   689 		                    // Can Think about an Ulternative.
       
   690 		                    HandleGarbageCollectionL(EFalse);
       
   691 
       
   692 			                GLX_DEBUG3("MGallery - CGlxCacheManager::MaintainCacheL() requesting attribute for list %x and item %d", list, itemId.Value());
       
   693 
       
   694 			                // Use list's isolated collection
       
   695 			                MMPXCollection& collection = list->Collection();
       
   696 
       
   697 			    			// Issue the request
       
   698 			    			collection.MediaL(*path, iRequestedAttrs.Array(), attrSpecs);
       
   699 							}
       
   700 						}
       
   701                     }
       
   702                 else
       
   703                 	{
       
   704 	                GLX_DEBUG3("MGallery - CGlxCacheManager::MaintainCacheL() requesting attribute for list %x and item %d", list, itemId.Value());
       
   705 
       
   706 	                // Use list's isolated collection
       
   707 	                MMPXCollection& collection = list->Collection();
       
   708                     if (collection.UidL().iUid == KGlxCollectionPluginImageViewerImplementationUid)
       
   709                         {
       
   710                         CGlxImageViewerManager *imageVwrMgr = CGlxImageViewerManager::InstanceL();
       
   711 						CleanupClosePushL(*imageVwrMgr);
       
   712                         TInt mediaCnt = list->Count();
       
   713                         TInt errInImage = KErrNone;
       
   714  
       
   715                         
       
   716                         GLX_DEBUG3("Image Viewer Collection - Attrib population! mediaCnt=%d, Media Id=%d",
       
   717                                 mediaCnt, itemId.Value());
       
   718                         
       
   719                         delete iMPXMedia;
       
   720                         iMPXMedia = NULL;
       
   721 
       
   722                         TFileName fileName(KNullDesC);
       
   723                         //retrieve the filename as per the caller app.
       
   724                         if(imageVwrMgr->IsPrivate())
       
   725                             {
       
   726                             const TGlxMedia& item = list->Item( iRequestedItemIndexes[0] );
       
   727                             // If there is an URI available, then the request is due to EPathChanged message 
       
   728                             // due to a file save from Image Viewer, and attribs needs to be re-populated. 
       
   729                             // So, use the same URI; Oherwise getting fullname from handle might result in a crash.
       
   730                             if (item.Uri().Length())
       
   731                                 {
       
   732                                 fileName.Append(item.Uri());
       
   733                                 }
       
   734                             else
       
   735                                 {
       
   736                                 // private path
       
   737                                 RFile64& imageHandle = imageVwrMgr->ImageFileHandle();
       
   738                                 if ( &imageHandle != NULL )
       
   739                                     {
       
   740                                     fileName.Append(imageHandle.FullName(fileName));
       
   741                                     }
       
   742                                 else
       
   743                                     {
       
   744                                     errInImage = KErrArgument;
       
   745                                     }   
       
   746                                 }
       
   747                             }
       
   748                         else
       
   749                             {
       
   750                             // user data path
       
   751                             if(  imageVwrMgr->ImageUri() != NULL  )
       
   752                                 {
       
   753                                 fileName.Append(imageVwrMgr->ImageUri()->Des());
       
   754                                 RFs fs;
       
   755                                 CleanupClosePushL(fs);
       
   756                                 TInt err = fs.Connect();   
       
   757                                 errInImage = KErrArgument;
       
   758                                 if(err == KErrNone)
       
   759                                     {
       
   760                                     if (fs.IsValidName(fileName))
       
   761                                         {
       
   762                                         errInImage = KErrNone;
       
   763                                         }
       
   764                                     }
       
   765                                 CleanupStack::PopAndDestroy(&fs);
       
   766                                 }
       
   767                             else
       
   768                                 {
       
   769                                 errInImage = KErrArgument;
       
   770                                 }
       
   771                             }
       
   772 
       
   773                         iMPXMedia = CMPXMedia::NewL();
       
   774 
       
   775                         if (errInImage != KErrNone)
       
   776                             {
       
   777                             HandleGarbageCollectionL(EFalse);
       
   778                             CleanupStack::PopAndDestroy(path);
       
   779                             iRequestOwner = list;
       
   780                             CleanupStack::PopAndDestroy(attrSpecs); 
       
   781                             TGlxIdSpaceId spaceId = list->IdSpaceId(iRequestedItemIndexes[0]);
       
   782                             HandleCollectionMediaL(spaceId, *iMPXMedia, KErrArgument);
       
   783                             CleanupStack::PopAndDestroy(imageVwrMgr);
       
   784                             return;
       
   785                             }
       
   786 
       
   787                         if(!iReader)
       
   788                             {
       
   789                             TRAP(errInImage,iReader = CGlxImageReader::NewL(*this));
       
   790                             if(errInImage == KErrNone)
       
   791                                 {
       
   792                                 iSchedulerWait->Start();
       
   793                                 }
       
   794                             }
       
   795                     
       
   796                         for ( TInt i = 0; i < iRequestedAttrs.Count(); i++ )
       
   797                             {
       
   798                             if ( iRequestedAttrs[i] == KMPXMediaGeneralId )
       
   799                                 {
       
   800                                 iMPXMedia->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, 
       
   801                                         (TMPXItemId)itemId.Value());
       
   802                                 }
       
   803                             else if ( iRequestedAttrs[i] == KMPXMediaGeneralType )
       
   804                                 {
       
   805                                 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralType, EMPXItem);
       
   806                                 }
       
   807                             else if ( iRequestedAttrs[i] == KMPXMediaGeneralCategory )
       
   808                                 {
       
   809                                 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralCategory, EMPXImage);
       
   810                                 }                           
       
   811                             else if ( iRequestedAttrs[i] == KMPXMediaGeneralUri )
       
   812                                 {
       
   813                                 iMPXMedia->SetTextValueL(KMPXMediaGeneralUri, fileName);
       
   814                                 }
       
   815                             else if ( iRequestedAttrs[i] == KMPXMediaGeneralTitle )
       
   816                                 {
       
   817                                 TParsePtrC parser(fileName);
       
   818                                 iMPXMedia->SetTextValueL(KMPXMediaGeneralTitle, parser.Name());
       
   819                                 }
       
   820                             else if ( iRequestedAttrs[i] == KMPXMediaGeneralDate )
       
   821                                 {
       
   822                                 TTime time;
       
   823                                 time.HomeTime();
       
   824                                 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralDate, time.Int64());
       
   825                                 }
       
   826                             else if ( iRequestedAttrs[i] == KGlxMediaGeneralLastModifiedDate )
       
   827                                 {
       
   828                                 if(errInImage == KErrNone)
       
   829                                     {
       
   830                                     RFs fs;
       
   831                                     CleanupClosePushL(fs);
       
   832                                     TInt err = fs.Connect();   
       
   833                                     if(err == KErrNone)
       
   834                                         {                                    
       
   835                                         TEntry entry;   
       
   836                                         fs.Entry(fileName,entry);    
       
   837                                         TTime time = entry.iModified;   
       
   838                                         iMPXMedia->SetTObjectValueL(
       
   839                                                 KGlxMediaGeneralLastModifiedDate, 
       
   840                                                 time.Int64());
       
   841                                         }
       
   842                                     else
       
   843                                         {
       
   844                                         TTime time;
       
   845                                         time.HomeTime();
       
   846                                         iMPXMedia->SetTObjectValueL(
       
   847                                                 KGlxMediaGeneralLastModifiedDate, 
       
   848                                                 time.Int64());
       
   849                                         }
       
   850                                     CleanupStack::PopAndDestroy(&fs);                                    
       
   851                                     }
       
   852                                 else
       
   853                                     {
       
   854                                     TTime time;
       
   855                                     time.HomeTime();
       
   856                                     iMPXMedia->SetTObjectValueL(KGlxMediaGeneralLastModifiedDate, time.Int64());
       
   857                                     }
       
   858                                 }
       
   859                             else if ( iRequestedAttrs[i] == KMPXMediaGeneralSize )
       
   860                                 {
       
   861                                 if(errInImage == KErrNone)
       
   862                                     {
       
   863                                     if(imageVwrMgr->IsPrivate())
       
   864                                         {
       
   865                                         TInt64 sz = 0;
       
   866                                         TInt err = KErrNotFound;                                      
       
   867                                         RFile64& imageHandle = imageVwrMgr->ImageFileHandle();
       
   868                                         if ( imageHandle.SubSessionHandle() != KNullHandle )
       
   869                                             {
       
   870                                             err = imageHandle.Size(sz);
       
   871                                             }
       
   872                                         if(err == KErrNone)
       
   873                                             {
       
   874                                             iMPXMedia->SetTObjectValueL(KMPXMediaGeneralSize, sz);
       
   875                                             }
       
   876                                         else
       
   877                                             {
       
   878                                             iMPXMedia->SetTObjectValueL(KMPXMediaGeneralSize, 0);                                            
       
   879                                             }
       
   880                                         }
       
   881                                     else
       
   882                                         {
       
   883                                         RFs fs;
       
   884                                         CleanupClosePushL(fs);
       
   885                                         TInt err = fs.Connect();   
       
   886                                         if(err == KErrNone)
       
   887                                             {
       
   888                                             TEntry entry;   
       
   889                                             fs.Entry(fileName,entry);    
       
   890                                             TInt sz = (TUint)entry.iSize;                                      
       
   891                                             iMPXMedia->SetTObjectValueL(KMPXMediaGeneralSize, sz);
       
   892                                             }
       
   893                                         else
       
   894                                             {
       
   895                                             iMPXMedia->SetTObjectValueL(KMPXMediaGeneralSize, 0);
       
   896                                             }
       
   897                                         CleanupStack::PopAndDestroy(&fs);
       
   898                                         }
       
   899                                     }
       
   900                                 // If any error while image is being decoded by image decorder, Need to set
       
   901                                 // default vaule for that image. Typical case is corrupted image.
       
   902                                 else
       
   903                                     {
       
   904                                     iMPXMedia->SetTObjectValueL(KMPXMediaGeneralSize, 0);
       
   905                                     }
       
   906                                 }
       
   907                             else if ( iRequestedAttrs[i] == KMPXMediaGeneralDrive )
       
   908                                 {
       
   909                                 TParsePtrC parser(fileName);
       
   910                                 iMPXMedia->SetTextValueL(KMPXMediaGeneralDrive, parser.Drive());
       
   911                                 }
       
   912                             else if ( iRequestedAttrs[i] == KMPXMediaGeneralMimeType )
       
   913                                 {
       
   914                                 if(errInImage == KErrNone)
       
   915                                     {
       
   916                                     TDataType dataType;
       
   917                                     GetMimeTypeL(fileName, dataType);
       
   918                                     iMPXMedia->SetTextValueL(KMPXMediaGeneralMimeType, dataType.Des());
       
   919                                     }
       
   920                                 else
       
   921                                     {
       
   922                                     iMPXMedia->SetTextValueL(KMPXMediaGeneralMimeType, KDefaultType);
       
   923                                     }                                
       
   924                                 }
       
   925                             else if ( iRequestedAttrs[i] == KMPXMediaGeneralDuration )
       
   926                                 {
       
   927                                 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralDuration, 0);
       
   928                                 }
       
   929                             else if ( iRequestedAttrs[i] == KGlxMediaGeneralSystemItem)
       
   930                                 {
       
   931                                 iMPXMedia->SetTObjectValueL(KGlxMediaGeneralSystemItem, EFalse);
       
   932                                 }
       
   933                             else if ( iRequestedAttrs[i] == KGlxMediaGeneralDimensions )
       
   934                                 {
       
   935                                 if(errInImage == KErrNone)
       
   936                                     {
       
   937                                     //need to fetch the original file dimensions
       
   938                                     TSize dimensions(iImgSz.iWidth,iImgSz.iHeight);
       
   939                                     iMPXMedia->SetTObjectValueL(KGlxMediaGeneralDimensions, dimensions);
       
   940                                     }
       
   941                                 else
       
   942                                     {
       
   943                                     TSize dimensions(0,0);
       
   944                                     iMPXMedia->SetTObjectValueL(KGlxMediaGeneralDimensions, dimensions);
       
   945                                     }
       
   946                                 }
       
   947                             else if ( iRequestedAttrs[i] == KGlxMediaGeneralFramecount )
       
   948                                 {
       
   949                                 TInt fcount = 1;
       
   950                                 iMPXMedia->SetTObjectValueL(KGlxMediaGeneralFramecount, fcount);
       
   951                                 }
       
   952                             else if ( iRequestedAttrs[i] == KMPXMediaGeneralComment )
       
   953                                 {
       
   954                                 iMPXMedia->SetTextValueL(KMPXMediaGeneralComment, KNullDesC); 
       
   955                                 }
       
   956                             else if (iRequestedAttrs[i] == KMPXMediaDrmProtected )
       
   957                                 {
       
   958                                 TBool protection = EFalse;
       
   959                                 if(errInImage == KErrNone)
       
   960                                     {
       
   961                                     protection = iReader->GetDRMRightsL
       
   962                                     (ContentAccess::EIsProtected);
       
   963                                     }
       
   964                                 iMPXMedia->SetTObjectValueL(KMPXMediaDrmProtected, protection);
       
   965                                 }
       
   966                             else if ( iRequestedAttrs[i] == KGlxMediaGeneralDRMRightsValid )
       
   967                                 {
       
   968                                 TInt rightsValid = EGlxDrmRightsValidityUnknown;
       
   969                                 if(errInImage == KErrNone)
       
   970                                     {
       
   971                                     TBool canView = iReader->GetDRMRightsL(ContentAccess::ECanView);
       
   972                                     rightsValid = canView ? 
       
   973                                         EGlxDrmRightsValid : EGlxDrmRightsInvalid;
       
   974                                     }
       
   975                                 iMPXMedia->SetTObjectValueL(KGlxMediaGeneralDRMRightsValid,
       
   976                                                              rightsValid); 
       
   977                                 }
       
   978                             else if ( iRequestedAttrs[i] == KMPXMediaGeneralCount )
       
   979                                 {
       
   980                                 iMPXMedia->SetTObjectValueL(KMPXMediaGeneralCount, 1);
       
   981                                 }
       
   982                             else if ( iRequestedAttrs[i] == KMPXMediaColDetailSpaceId )
       
   983                                 {
       
   984                                 TGlxIdSpaceId spaceId = list->IdSpaceId(iRequestedItemIndexes[0]);
       
   985                                 iMPXMedia->SetTObjectValueL(KMPXMediaColDetailSpaceId,
       
   986                                 		 spaceId.Value());
       
   987                                 }
       
   988                             else if ( iRequestedAttrs[i] == KGlxMediaGeneralSlideshowableContent )
       
   989                                 {
       
   990                                 iMPXMedia->SetTObjectValueL(KGlxMediaGeneralSlideshowableContent, -1);
       
   991                                 }
       
   992                             else if ( iRequestedAttrs[i] == KGlxMediaGeneralLocation)
       
   993                                 {
       
   994                                 // Set the attribute to a TCoordinate initialised to NaN. 
       
   995                                 iMPXMedia->SetTObjectValueL(KGlxMediaGeneralLocation, TCoordinate());
       
   996                                 }
       
   997                             else
       
   998                                 {
       
   999                                 User::Leave(KErrNotSupported);
       
  1000                                 }
       
  1001                             }
       
  1002                         
       
  1003                         HandleGarbageCollectionL(EFalse);
       
  1004                         CleanupStack::PopAndDestroy(imageVwrMgr);
       
  1005                         CleanupStack::PopAndDestroy(path);
       
  1006                         iRequestOwner = list;
       
  1007                         CleanupStack::PopAndDestroy(attrSpecs); 
       
  1008                         TGlxIdSpaceId spaceId = list->IdSpaceId(iRequestedItemIndexes[0]);
       
  1009                         HandleCollectionMediaL(spaceId, *iMPXMedia, KErrNone);
       
  1010                         return;
       
  1011                         }
       
  1012                     else
       
  1013                         {
       
  1014                     // Issue the request
       
  1015                     collection.MediaL(*path, iRequestedAttrs.Array(), attrSpecs);
       
  1016                         }
       
  1017                     }
       
  1018 #else // USE_S60_TNM
       
  1019                     delete iTempThumbnail;
       
  1020                     iTempThumbnail = NULL;
       
  1021                     iTempThumbnail = new (ELeave) CFbsBitmap;
       
  1022                     User::LeaveIfError(iTempThumbnail->Create(TSize(), KGlxThumbnailDisplayMode));
       
  1023                     iThumbnailId = itemId;
       
  1024 
       
  1025                     // Set bitmap handle in attribute spec
       
  1026                     if (attrSpecs)
       
  1027                         {
       
  1028                         TMPXAttribute thHandleAttrSpec(KGlxMediaIdThumbnail, KGlxAttribSpecThumbnailBitmapHandle);
       
  1029                         attrSpecs->SetTObjectValueL<TInt>(thHandleAttrSpec, iTempThumbnail->Handle());
       
  1030                         }
       
  1031                     // Cancel Clean-up is needed here;
       
  1032                     // This is Going to Highly Used Call
       
  1033                     // Can Think about an Ulternative.
       
  1034                     HandleGarbageCollectionL(EFalse);
       
  1035                     }
       
  1036 
       
  1037                 GLX_DEBUG3("MGallery - CGlxCacheManager::MaintainCacheL() requesting attribute for list %x and item %d", list, itemId.Value());
       
  1038 
       
  1039                 // Use list's isolated collection
       
  1040                 MMPXCollection& collection = list->Collection();
       
  1041 
       
  1042     			// Issue the request
       
  1043     			collection.MediaL(*path, iRequestedAttrs.Array(), attrSpecs);
       
  1044 #endif
       
  1045     			CleanupStack::PopAndDestroy(path);
       
  1046     			
       
  1047     			iRequestOwner = list;
       
  1048     			}		
       
  1049     			
       
  1050     		CleanupStack::PopAndDestroy(attrSpecs);	
       
  1051     		}
       
  1052     		
       
  1053         if ( !iRequestOwner )
       
  1054             {
       
  1055             if ( iTempError )
       
  1056                 {
       
  1057                 // Reawaken in a while to check again
       
  1058                 StartTempErrorTimer();
       
  1059                 }
       
  1060             }
       
  1061     	}
       
  1062     }
       
  1063 
       
  1064 // -----------------------------------------------------------------------------
       
  1065 // BroadcastAttributesAvailableL
       
  1066 // -----------------------------------------------------------------------------
       
  1067 //
       
  1068 void CGlxCacheManager::BroadcastAttributesAvailableL(const TGlxIdSpaceId& aIdSpaceId, 
       
  1069                     const TGlxMediaId& aMediaId, 
       
  1070                     const RArray<TMPXAttribute>& aAttributes, 
       
  1071                     const CGlxMedia* aMedia)
       
  1072    {
       
  1073    TRACER("CGlxCacheManager::BroadcastAttributesAvailableL");
       
  1074    
       
  1075     TInt count = iObserverList.Count();
       
  1076     TInt i;
       
  1077     for ( i = 0; i < count; i++ )
       
  1078         {
       
  1079         iObserverList[i]->HandleAttributesAvailableL(aIdSpaceId, aMediaId, aAttributes, aMedia);
       
  1080         }
       
  1081    }
       
  1082 
       
  1083 /**
       
  1084  * Cleanup the media of the given media id: broadcast this to all observers
       
  1085  * @param aMediaId The media id of the item
       
  1086  */ 
       
  1087 void CGlxCacheManager::CleanupMedia(const TGlxMediaId& aMediaId)
       
  1088 	{
       
  1089 	TRACER("CGlxCacheManager::CleanupMedia");
       
  1090     TInt count = iObserverList.Count();
       
  1091     GLX_DEBUG2("CGlxCacheManager::CleanupMedia -  aMediaId = %d", aMediaId.Value());
       
  1092     TInt i;
       
  1093     for ( i = 0; i < count; i++ )
       
  1094         {
       
  1095         iObserverList[i]->CleanupMedia(aMediaId);
       
  1096         }
       
  1097    }
       
  1098 
       
  1099 // -----------------------------------------------------------------------------
       
  1100 // Handles modification of item in a cache
       
  1101 // -----------------------------------------------------------------------------
       
  1102 void CGlxCacheManager::HandleItemModified(const TGlxIdSpaceId& aIdSpaceId, const TGlxMediaId& aMediaId, const RArray<TMPXAttribute>& aAttributes)
       
  1103 	{
       
  1104 	TRACER("CGlxCacheManager::HandleItemModified");
       
  1105 	
       
  1106 	// Look for the correct subcache
       
  1107 	TInt index = iCaches.FindInOrder(aIdSpaceId, (&CacheOrderByKey));
       
  1108 	if (index != KErrNotFound)
       
  1109 		{
       
  1110 		iCaches[index]->HandleItemModified(aMediaId, aAttributes);
       
  1111 		}
       
  1112 	}
       
  1113 
       
  1114 // -----------------------------------------------------------------------------
       
  1115 // CacheOrderById
       
  1116 // -----------------------------------------------------------------------------
       
  1117 //
       
  1118 TInt CGlxCacheManager::CacheOrderById(const CGlxCache& aItem1, const CGlxCache& aItem2) 
       
  1119 	{
       
  1120 	TRACER("CGlxCacheManager::CacheOrderById");
       
  1121 	
       
  1122 	// Cannot do aItem1.IdSpaceId() - aItem2.IdSpaceId(), since IdSpaceId().Value() returns an unsigned value
       
  1123 	TGlxIdSpaceId id1 = aItem1.IdSpaceId();
       
  1124 	TGlxIdSpaceId id2 = aItem2.IdSpaceId();
       
  1125 	if (id1 < id2) 
       
  1126 		{
       
  1127 		return -1;
       
  1128 		}
       
  1129 		
       
  1130 	if (id1 > id2) 
       
  1131 		{
       
  1132 		return 1;
       
  1133 		}
       
  1134 
       
  1135 	return 0;
       
  1136 	}
       
  1137 
       
  1138 // -----------------------------------------------------------------------------
       
  1139 // CacheOrderByKey
       
  1140 // -----------------------------------------------------------------------------
       
  1141 //
       
  1142 TInt CGlxCacheManager::CacheOrderByKey(const TGlxIdSpaceId* aIdSpaceId, const CGlxCache& aItem2) 
       
  1143 	{
       
  1144 	TRACER("CGlxCacheManager::CacheOrderByKey");
       
  1145 	
       
  1146 	TGlxIdSpaceId id2 = aItem2.IdSpaceId();
       
  1147 	if (*aIdSpaceId < id2) 
       
  1148 		{
       
  1149 		return -1;
       
  1150 		}
       
  1151 		
       
  1152 	if (*aIdSpaceId > id2) 
       
  1153 		{
       
  1154 		return 1;
       
  1155 		}
       
  1156 
       
  1157 	return 0;
       
  1158 	}
       
  1159 
       
  1160 // -----------------------------------------------------------------------------
       
  1161 // TempThumbnail
       
  1162 // -----------------------------------------------------------------------------
       
  1163 //
       
  1164 CFbsBitmap* CGlxCacheManager::TempThumbnail()
       
  1165     {
       
  1166     TRACER("CGlxCacheManager::TempThumbnail");
       
  1167     
       
  1168     return iTempThumbnail;
       
  1169     }
       
  1170     
       
  1171 // -----------------------------------------------------------------------------
       
  1172 // TempThumbnailId
       
  1173 // -----------------------------------------------------------------------------
       
  1174 //
       
  1175 TGlxMediaId CGlxCacheManager::TempThumbnailId()
       
  1176     {
       
  1177     TRACER("CGlxCacheManager::TempThumbnailId");
       
  1178     
       
  1179     return iThumbnailId;
       
  1180     }
       
  1181 
       
  1182 // -----------------------------------------------------------------------------
       
  1183 // SetTempThumbnail
       
  1184 // -----------------------------------------------------------------------------
       
  1185 //
       
  1186 void CGlxCacheManager::SetTempThumbnailToNull()
       
  1187     {
       
  1188     TRACER("CGlxCacheManager::SetTempThumbnailToNull");
       
  1189     
       
  1190     iTempThumbnail = NULL;
       
  1191     }
       
  1192 
       
  1193 // -----------------------------------------------------------------------------
       
  1194 // ErrorsOnRequestedItemsL
       
  1195 // -----------------------------------------------------------------------------
       
  1196 //
       
  1197 TBool CGlxCacheManager::ErrorsOnRequestedItemsL()
       
  1198     {
       
  1199     TRACER("CGlxCacheManager::ErrorsOnRequestedItemsL");
       
  1200     
       
  1201     TBool errorFound = EFalse;
       
  1202     
       
  1203     TInt itemCount = iRequestedItemIds.Count();
       
  1204     TInt attrCount = iRequestedAttrs.Count();
       
  1205     
       
  1206     for ( TInt itemIndex = 0; itemIndex < itemCount && !errorFound; itemIndex++ )
       
  1207         {
       
  1208         CGlxMedia* media = Media(iRequestedItemsIdSpace, iRequestedItemIds[itemIndex]);
       
  1209         
       
  1210         if ( media )
       
  1211             {
       
  1212             for ( TInt attrIndex = 0; attrIndex < attrCount && !errorFound; attrIndex++ )
       
  1213                 {
       
  1214                 errorFound = (KErrNone != GlxErrorManager::HasAttributeErrorL(media, iRequestedAttrs[attrIndex]));
       
  1215                 }
       
  1216             }
       
  1217         }
       
  1218     
       
  1219     return errorFound;
       
  1220     }
       
  1221     
       
  1222 // -----------------------------------------------------------------------------
       
  1223 // Caches
       
  1224 // -----------------------------------------------------------------------------
       
  1225 //
       
  1226 const RPointerArray<CGlxCache>& CGlxCacheManager::Caches()
       
  1227     {
       
  1228     TRACER("CGlxCacheManager::Caches");
       
  1229     
       
  1230     return iCaches;
       
  1231     }
       
  1232 
       
  1233 // -----------------------------------------------------------------------------
       
  1234 // SetTemporaryErrorFlag
       
  1235 // -----------------------------------------------------------------------------
       
  1236 //
       
  1237 void CGlxCacheManager::SetTemporaryErrorFlag()
       
  1238     {
       
  1239     TRACER("CGlxCacheManager::SetTemporaryErrorFlag");
       
  1240     
       
  1241     iTempError = ETrue;
       
  1242     }
       
  1243     
       
  1244 // -----------------------------------------------------------------------------
       
  1245 // StartTempErrorTimer
       
  1246 // -----------------------------------------------------------------------------
       
  1247 //
       
  1248 void CGlxCacheManager::StartTempErrorTimer()
       
  1249     {
       
  1250     TRACER("CGlxCacheManager::StartTempErrorTimer");
       
  1251     
       
  1252     iTempErrorTimer->Cancel();
       
  1253 	iTempErrorTimer->Start(
       
  1254 		TTimeIntervalMicroSeconds32(KGlxTemporaryErrorRecheckPeriodInSeconds * 1000000),
       
  1255 		TTimeIntervalMicroSeconds32(KGlxTemporaryErrorRecheckPeriodInSeconds * 1000000),
       
  1256 		TCallBack(&CGlxCacheManager::TempErrorTimerCallbackL,(TAny *)this));
       
  1257 	}
       
  1258 
       
  1259 // -----------------------------------------------------------------------------
       
  1260 // TempErrorTimerCallbackL
       
  1261 // -----------------------------------------------------------------------------
       
  1262 //
       
  1263 TInt CGlxCacheManager::TempErrorTimerCallbackL(TAny* aPtr)
       
  1264     {
       
  1265     TRACER("CGlxCacheManager::TempErrorTimerCallback");
       
  1266     
       
  1267 	CGlxCacheManager* self = (CGlxCacheManager*) aPtr;
       
  1268 	
       
  1269 	if ( self )
       
  1270 	    {
       
  1271     	self->TempErrorTimerCompleteL();
       
  1272     	}
       
  1273 
       
  1274     return 0;
       
  1275     }
       
  1276 
       
  1277 // -----------------------------------------------------------------------------
       
  1278 // TempErrorTimerComplete
       
  1279 // -----------------------------------------------------------------------------
       
  1280 //
       
  1281 void CGlxCacheManager::TempErrorTimerCompleteL()
       
  1282     {
       
  1283     TRACER("CGlxCacheManager::TempErrorTimerComplete");
       
  1284     
       
  1285     iTempErrorTimer->Cancel();
       
  1286     TRAPD(err, MaintainCacheL());
       
  1287     
       
  1288     // If MaintainCacheL leaves, force gabage collection to start and restart timer
       
  1289     if ( KErrNone != err )
       
  1290         {
       
  1291         if ( KErrNoMemory == err )
       
  1292             {
       
  1293             //iGarbageCollector->Cleanup();
       
  1294             HandleGarbageCollectionL(ETrue);
       
  1295             }
       
  1296             
       
  1297         if ( !iRequestOwner )
       
  1298             {
       
  1299             StartTempErrorTimer();
       
  1300             }
       
  1301         }
       
  1302     }
       
  1303     
       
  1304 // -----------------------------------------------------------------------------
       
  1305 // Create a path with the request items
       
  1306 // -----------------------------------------------------------------------------
       
  1307 //
       
  1308 inline CMPXCollectionPath* CGlxCacheManager::RequestAsPathLC(const CGlxMediaList& aList)
       
  1309     {
       
  1310     TRACER("CGlxCacheManager::RequestAsPathLC");
       
  1311     
       
  1312     CMPXCollectionPath* path = aList.PathLC( NGlxListDefs::EPathParent );
       
  1313 
       
  1314     RArray<TMPXItemId> mpxIds;
       
  1315     CleanupClosePushL( mpxIds );
       
  1316 
       
  1317     TInt itemIdsCount = iRequestedItemIds.Count();
       
  1318 
       
  1319     // Reserve space for all items
       
  1320     mpxIds.ReserveL( itemIdsCount );
       
  1321 
       
  1322     for (TInt i = 0; i < itemIdsCount; ++i)
       
  1323         {
       
  1324         mpxIds.AppendL( iRequestedItemIds[ i ].Value() );
       
  1325         }
       
  1326 
       
  1327     path->AppendL( mpxIds.Array() );
       
  1328     path->SelectAllL();
       
  1329 
       
  1330     CleanupStack::PopAndDestroy( &mpxIds );
       
  1331 
       
  1332     return path;
       
  1333     }
       
  1334 
       
  1335 // -----------------------------------------------------------------------------
       
  1336 // HandleListDeleted
       
  1337 // -----------------------------------------------------------------------------
       
  1338 void CGlxCacheManager::HandleListDeleted(CGlxMediaList* aList)
       
  1339     {
       
  1340     TRACER("CGlxCacheManager::HandleListDeleted");
       
  1341     
       
  1342     if (iRequestOwner == aList)
       
  1343         {
       
  1344         iRequestOwner = NULL;
       
  1345 
       
  1346         TRAP_IGNORE( MaintainCacheL() );
       
  1347         }
       
  1348     }
       
  1349 
       
  1350 // -----------------------------------------------------------------------------
       
  1351 // Inform cache manager to reserve users for an item, for a particular cache
       
  1352 // -----------------------------------------------------------------------------
       
  1353 //
       
  1354 void CGlxCacheManager::ReserveUsersL(const TGlxIdSpaceId& aIdSpaceId, TInt aCount)
       
  1355     {
       
  1356     TRACER("CGlxCacheManager::ReserveUsersL");
       
  1357     
       
  1358     // Look for existing cache
       
  1359     TInt index = iCaches.FindInOrder( aIdSpaceId, ( &CacheOrderByKey ) );
       
  1360     if (index != KErrNotFound)
       
  1361         {
       
  1362         iCaches[index]->ReserveUsersL( aCount );
       
  1363         }
       
  1364     }
       
  1365 //OOM 
       
  1366 // -----------------------------------------------------------------------------
       
  1367 // Start cache cleanup on Low memory event from OOM
       
  1368 // -----------------------------------------------------------------------------
       
  1369 //   
       
  1370 void CGlxCacheManager::ReleaseRAML(TBool aFlushOnRequest)
       
  1371 {
       
  1372     TRACER("CGlxCacheManager::ReleaseRAM");
       
  1373     if(aFlushOnRequest)
       
  1374         {
       
  1375         HandleGarbageCollectionL(aFlushOnRequest);        
       
  1376         }
       
  1377 	else
       
  1378 	{
       
  1379 		iGarbageCollector->CleanupL(); 	 				
       
  1380 	} 	
       
  1381 }
       
  1382 // -----------------------------------------------------------------------------
       
  1383 // Force a cleanup on particular media id : remove all attributes
       
  1384 // -----------------------------------------------------------------------------
       
  1385 // 
       
  1386 void CGlxCacheManager::ForceCleanupMedia(TGlxIdSpaceId aSpaceId, 
       
  1387                                           TGlxMediaId aMediaId)
       
  1388     {
       
  1389     TRACER("CGlxCacheManager::ForceCleanupMedia");  
       
  1390     TInt spaceIdIndex = iCaches.FindInOrder( aSpaceId, &CacheOrderByKey );
       
  1391     if ( KErrNotFound != spaceIdIndex )
       
  1392         {
       
  1393         if ( iCaches[spaceIdIndex]->Media( aMediaId ) )
       
  1394             {            
       
  1395             TInt mediaIdIndex = iCaches[spaceIdIndex]->FindMediaIndexInCache(aMediaId);
       
  1396             if ( KErrNotFound != mediaIdIndex )
       
  1397             	{
       
  1398             	iCaches[spaceIdIndex]->Delete(mediaIdIndex);
       
  1399             	}
       
  1400             }
       
  1401         }
       
  1402     }
       
  1403 
       
  1404 // -----------------------------------------------------------------------------
       
  1405 // Stop cache cleanup on good memory event from OOM
       
  1406 // -----------------------------------------------------------------------------
       
  1407 //
       
  1408 void CGlxCacheManager::StopRAMReleaseL()
       
  1409 {
       
  1410     TRACER("CGlxCacheManager::StopRAMRelease");
       
  1411     iGarbageCollector->CancelCleanup(); 		
       
  1412 
       
  1413 }
       
  1414 //OOM
       
  1415 
       
  1416 #ifdef USE_S60_TNM
       
  1417 // -----------------------------------------------------------------------------
       
  1418 // CGlxCacheManager::FindLoadingById()
       
  1419 // -----------------------------------------------------------------------------
       
  1420 //
       
  1421 TInt CGlxCacheManager::FindLoadingById(TThumbnailRequestId aId, TBool aRemove)
       
  1422     {
       
  1423     TRACER("CGlxCacheManager::FindLoadingById");
       
  1424     TInt index = KErrNotFound;
       
  1425     for(TInt i = 0; i < iThumbnailRequestIds.Count(); ++i)
       
  1426         {
       
  1427         if(iThumbnailRequestIds[i].iId == aId)
       
  1428             {
       
  1429             index = i;
       
  1430             if(aRemove)
       
  1431                 {
       
  1432                 iThumbnailRequestIds.Remove(i);
       
  1433                 }
       
  1434             break;
       
  1435             }
       
  1436         }
       
  1437     return index;
       
  1438     }
       
  1439 
       
  1440 // -----------------------------------------------------------------------------
       
  1441 // CGlxCacheManager::ThumbnailPreviewReady()
       
  1442 // -----------------------------------------------------------------------------
       
  1443 //
       
  1444 void CGlxCacheManager::ThumbnailPreviewReady(MThumbnailData& aThumbnail,
       
  1445         TThumbnailRequestId aId)
       
  1446     {
       
  1447     TRACER("CGlxCacheManager::ThumbnailPreviewReady");
       
  1448     TInt error = KErrNotSupported;
       
  1449     if (aThumbnail.Bitmap() != NULL)
       
  1450          {
       
  1451 		 GLX_DEBUG1("CGlxCacheManager::ThumbnailPreviewReady preview aval");
       
  1452          error = KErrNone;
       
  1453          }
       
  1454     ThumbnailReadyL(error, aThumbnail, aId, EFalse);
       
  1455     }
       
  1456 
       
  1457 // -----------------------------------------------------------------------------
       
  1458 // CGlxCacheManager::ThumbnailReady()
       
  1459 // -----------------------------------------------------------------------------
       
  1460 //
       
  1461 void CGlxCacheManager::ThumbnailReady(TInt aError,
       
  1462         MThumbnailData& aThumbnail, TThumbnailRequestId aId)
       
  1463     {
       
  1464     TRACER("CGlxCacheManager::ThumbnailReady");
       
  1465     GLX_DEBUG2("CGlxCacheManager::ThumbnailReady aError=%d", aError);
       
  1466     ThumbnailReadyL(aError, aThumbnail, aId, ETrue);
       
  1467     }
       
  1468 
       
  1469 // -----------------------------------------------------------------------------
       
  1470 // CGlxCacheManager::ThumbnailReadyL()
       
  1471 // -----------------------------------------------------------------------------
       
  1472 //
       
  1473 void CGlxCacheManager::ThumbnailReadyL(TInt aError, MThumbnailData& aThumbnail, 
       
  1474                                        TThumbnailRequestId aId, TBool aQuality)
       
  1475     {
       
  1476     TRACER("CGlxCacheManager::ThumbnailReadyL");
       
  1477     GLX_DEBUG3("CGlxCacheManager::ThumbnailReadyL aError=%d, aQuality=%d",
       
  1478                                 aError, aQuality);
       
  1479 
       
  1480 #ifdef _DEBUG
       
  1481     iStopTime.HomeTime(); // Get home time
       
  1482     GLX_DEBUG2("=>CGlxCacheManager::ThumbnailReadyL - TN Fetch took <%d> us", 
       
  1483                     (TInt)iStopTime.MicroSecondsFrom(iStartTime).Int64());
       
  1484 #endif
       
  1485     
       
  1486 	TInt reqIndex = FindLoadingById(aId, EFalse);
       
  1487 		
       
  1488     if (reqIndex == KErrNotFound)
       
  1489         {
       
  1490 		return;
       
  1491         }
       
  1492 
       
  1493     delete iMPXMedia;
       
  1494     iMPXMedia = NULL;
       
  1495         
       
  1496     iMPXMedia = CMPXMedia::NewL();
       
  1497     if (aError == KErrNone)
       
  1498         {
       
  1499         delete iTempThumbnail;
       
  1500         iTempThumbnail = NULL;
       
  1501         iTempThumbnail = aThumbnail.DetachBitmap();
       
  1502 
       
  1503         CGlxThumbnailAttribute* tnAttribute = new (ELeave) CGlxThumbnailAttribute;
       
  1504         CleanupStack::PushL(tnAttribute);
       
  1505         tnAttribute->iDimensions = iThumbnailRequestIds[reqIndex].iSize;
       
  1506 	    tnAttribute->iThumbnailQuality = aQuality;
       
  1507                 
       
  1508         iMPXMedia->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, 
       
  1509 						iThumbnailRequestIds[reqIndex].iThumbnailId.Value());
       
  1510         TUint attributeId = GlxFullThumbnailAttributeId(aQuality, 
       
  1511 								iThumbnailRequestIds[reqIndex].iSize.iWidth, 
       
  1512 								iThumbnailRequestIds[reqIndex].iSize.iHeight);
       
  1513         iMPXMedia->SetNoNewLCObjectL(
       
  1514                TMPXAttribute(KGlxMediaIdThumbnail, attributeId), tnAttribute);
       
  1515         CleanupStack::PopAndDestroy(tnAttribute);
       
  1516 
       
  1517         HandleCollectionMediaL(iThumbnailRequestIds[reqIndex].iSpaceId,
       
  1518                                                     *iMPXMedia, aError);
       
  1519         }
       
  1520     else
       
  1521         {
       
  1522         HandleCollectionMediaL(iThumbnailRequestIds[reqIndex].iSpaceId, 
       
  1523 													*iMPXMedia, aError);
       
  1524         }
       
  1525     
       
  1526     if (aQuality)
       
  1527         {
       
  1528         FindLoadingById(aId, ETrue);
       
  1529         }   
       
  1530     }
       
  1531 #endif
       
  1532 
       
  1533 // -----------------------------------------------------------------------------
       
  1534 // GetMimeTypeL()
       
  1535 // -----------------------------------------------------------------------------
       
  1536 //
       
  1537 void CGlxCacheManager::GetMimeTypeL(TFileName& aFileName, TDataType& aMimeType)
       
  1538     {
       
  1539     TRACER("CGlxCacheManager::GetMimeTypeL");
       
  1540     RApaLsSession session;
       
  1541     User::LeaveIfError( session.Connect() );
       
  1542     CleanupClosePushL( session );
       
  1543 
       
  1544     TUid uid;
       
  1545     User::LeaveIfError( session.AppForDocument( aFileName, uid, aMimeType ) );
       
  1546     CleanupStack::PopAndDestroy(&session);
       
  1547     }
       
  1548 
       
  1549 // -----------------------------------------------------------------------------
       
  1550 // ImageSizeReady()
       
  1551 // -----------------------------------------------------------------------------
       
  1552 //
       
  1553 void CGlxCacheManager::ImageSizeReady(TInt aError, const TSize aSz)
       
  1554     {
       
  1555     TRACER("CGlxCacheManager::ImageSizeReady");
       
  1556     GLX_DEBUG2("CGlxCacheManager::ImageSizeReady aError=%d", aError);
       
  1557     iImgSz = TSize();
       
  1558     if(iSchedulerWait)
       
  1559         {
       
  1560         iSchedulerWait->AsyncStop();    
       
  1561         }    
       
  1562 
       
  1563     iImgSz = aSz;
       
  1564     GLX_DEBUG3("CGlxCacheManager::ImageSizeReady() iImgSz w(%d) h(%d)", 
       
  1565             iImgSz.iWidth, iImgSz.iHeight);    
       
  1566     }
       
  1567 
       
  1568 //End of file