harvester/monitorplugins/mmcplugin/src/mmcscannerao.cpp
changeset 2 b73a2e62868f
parent 1 acef663c1218
child 3 6752808b2036
equal deleted inserted replaced
1:acef663c1218 2:b73a2e62868f
    15 */
    15 */
    16 
    16 
    17 #include "mmcscannerao.h"
    17 #include "mmcscannerao.h"
    18 #include "harvesterlog.h"
    18 #include "harvesterlog.h"
    19 #include "fsutil.h"
    19 #include "fsutil.h"
    20 #include <harvesterdata.h>
       
    21 #include <placeholderdata.h>
    20 #include <placeholderdata.h>
    22 #include <centralrepository.h>
    21 #include <centralrepository.h>
    23 
    22 
    24 _LIT( KColon, ":" );
    23 _LIT( KColon, ":" );
    25 
    24 
    26 const TInt KEntryBufferSize = 100;
       
    27 const TInt KDefaultDelay = 4;
    25 const TInt KDefaultDelay = 4;
    28 const TInt KMillion = 1000000;
    26 const TInt KMillion = 1000000;
    29 
    27 
    30 const TUid KRepositoryUid = { 0x20007183 };
    28 const TUid KRepositoryUid = { 0x20007183 };
    31 const TUint32 KScanDelayKey = 0x00000001;
    29 const TUint32 KScanDelayKey = 0x00000001;
    93 	iEntryArray.Close();
    91 	iEntryArray.Close();
    94 
    92 
    95 	iHarvestEntryArray.ResetAndDestroy();
    93 	iHarvestEntryArray.ResetAndDestroy();
    96 	iHarvestEntryArray.Close();
    94 	iHarvestEntryArray.Close();
    97 	
    95 	
       
    96     iHdArray.ResetAndDestroy();
       
    97 	iHdArray.Close();
       
    98 	
    98 	iFs.Close();
    99 	iFs.Close();
    99 	}
   100 	}
   100 
   101 
   101 
   102 
   102 void CMmcScannerAO::RunL()
   103 void CMmcScannerAO::RunL()
   163 				HandleReharvestL();
   164 				HandleReharvestL();
   164 				SetState( EHarvestFiles );
   165 				SetState( EHarvestFiles );
   165 				}
   166 				}
   166 			else
   167 			else
   167 				{
   168 				{
       
   169                 if ( iObserver )
       
   170                     {
       
   171                     if( iHdArray.Count() > 0)
       
   172                         {
       
   173                         iObserver->MonitorEvent( iHdArray );
       
   174                         }
       
   175                     }
       
   176                 iHdArray.Reset();
       
   177                 iHdArray.Compress();
   168 				SetState( ERemoveNPFiles );
   178 				SetState( ERemoveNPFiles );
   169 				}
   179 				}
   170 			break;
   180 			break;
   171 			}
   181 			}
   172 		
   182 		
   179 			}
   189 			}
   180 		
   190 		
   181 		case( EDone ):
   191 		case( EDone ):
   182 			{
   192 			{
   183 			iFs.Close();
   193 			iFs.Close();
       
   194 		    iHdArray.Reset();
       
   195 		    iHdArray.Compress();
   184 			iEntryArray.Compress();
   196 			iEntryArray.Compress();
   185 			iHarvestEntryArray.Compress();
   197 			iHarvestEntryArray.Compress();
   186 			break;
   198 			break;
   187 			}
   199 			}
   188 		
   200 		
   193 	}
   205 	}
   194 
   206 
   195 void CMmcScannerAO::HandleReharvestL()
   207 void CMmcScannerAO::HandleReharvestL()
   196 	{
   208 	{
   197 	WRITELOG("CMMCMountTaskAO::HandleReharvestL");
   209 	WRITELOG("CMMCMountTaskAO::HandleReharvestL");
   198 		
   210 
   199 	TInt batchSize( 0 );
   211     const TInt count( iHarvestEntryArray.Count() );
   200 	RPointerArray<CHarvesterData> hdArray;
   212     TInt batchSize( KMmcEntryBufferSize );
   201 	CleanupClosePushL( hdArray );
   213     if ( count < KMmcEntryBufferSize )
   202 	
       
   203     if ( iHarvestEntryArray.Count() >= KEntryBufferSize )
       
   204         {
   214         {
   205         batchSize = KEntryBufferSize;
   215         batchSize = count;
   206         }
   216         }
   207     else
   217 
       
   218     const TInt endIndex( count - batchSize );
       
   219         
       
   220     for ( TInt i = count; --i >= endIndex; )
   208         {
   221         {
   209         batchSize = iHarvestEntryArray.Count();
   222         CPlaceholderData* ei = iHarvestEntryArray[i];
   210         }
       
   211         
       
   212     for ( TInt i = 0; i < batchSize; i++ )
       
   213         {
       
   214         CPlaceholderData* ei = iHarvestEntryArray[0];
       
   215 
   223 
   216         HBufC* fileName = ei->Uri().AllocLC();
   224         HBufC* fileName = ei->Uri().AllocLC();
   217         CHarvesterData* hd = CHarvesterData::NewL( fileName );
   225         CHarvesterData* hd = CHarvesterData::NewL( fileName );
   218 		hd->SetOrigin( MdeConstants::Object::EOther );
   226 		hd->SetOrigin( MdeConstants::Object::EOther );
   219 		CleanupStack::Pop( fileName );
   227 		CleanupStack::Pop( fileName );
   229 			{
   237 			{
   230 			hd->SetEventType( EHarvesterAdd );
   238 			hd->SetEventType( EHarvesterAdd );
   231 			hd->SetObjectType( EPlaceholder );
   239 			hd->SetObjectType( EPlaceholder );
   232 			hd->SetClientData( ei );
   240 			hd->SetClientData( ei );
   233 			}
   241 			}
   234 		hdArray.Append( hd );
   242 		iHdArray.Append( hd );
   235         iHarvestEntryArray.Remove( 0 );
   243         iHarvestEntryArray.Remove( i );
   236         }
   244         }
   237 
   245 
   238     if( iHarvestEntryArray.Count() == 0 )
   246     if( iHarvestEntryArray.Count() == 0 )
   239     	{
   247     	{
   240     	iHarvestEntryArray.Compress();
   248     	iHarvestEntryArray.Compress();
   241     	}
   249     	}
   242     
       
   243 	if ( iObserver )
       
   244 		{
       
   245 		if( hdArray.Count() > 0)
       
   246 			{
       
   247 			iObserver->MonitorEvent( hdArray );
       
   248 			}
       
   249 		else
       
   250 			{
       
   251 			iObserver->MonitorEvent( hdArray[0] );
       
   252 			}
       
   253 		}
       
   254 	
       
   255 	CleanupStack::PopAndDestroy( &hdArray ); 
       
   256 	}
   250 	}
   257 	
   251 	
   258 
   252 
   259 TInt CMmcScannerAO::RunError( TInt /*aError*/ )
   253 TInt CMmcScannerAO::RunError( TInt /*aError*/ )
   260 	{
   254 	{