harvester/monitorplugins/mmcplugin/src/mmcscannerao.cpp
branchRCL_3
changeset 7 3cebc1a84278
parent 3 6752808b2036
child 19 b73252188534
equal deleted inserted replaced
6:646a02f170b9 7:3cebc1a84278
    29 const TUint32 KScanDelayKey = 0x00000001;
    29 const TUint32 KScanDelayKey = 0x00000001;
    30 
    30 
    31 CMmcScannerAO::CMmcScannerAO( TUint32 aMediaId, 
    31 CMmcScannerAO::CMmcScannerAO( TUint32 aMediaId, 
    32 		CMdEHarvesterSession* aMdEClient, MMonitorPluginObserver* aObserver, 
    32 		CMdEHarvesterSession* aMdEClient, MMonitorPluginObserver* aObserver, 
    33 		CHarvesterPluginFactory* aHarvesterPluginFactory, const TInt aPriority ) : 
    33 		CHarvesterPluginFactory* aHarvesterPluginFactory, const TInt aPriority ) : 
    34 		CTimer( aPriority ), iState( EUninitialized ), iMmcFileList( NULL )   
    34 		CActive( aPriority ), iState( EUninitialized ), iMmcFileList( NULL )   
    35 	{
    35 	{
    36 	iMediaId = aMediaId;
    36 	iMediaId = aMediaId;
    37 	iMdEClient = aMdEClient;
    37 	iMdEClient = aMdEClient;
    38 	iObserver = aObserver;
    38 	iObserver = aObserver;
    39 	iHarvesterPluginFactory = aHarvesterPluginFactory;
    39 	iHarvesterPluginFactory = aHarvesterPluginFactory;
    40 	}
    40 	}
    41 
    41 
    42 CMmcScannerAO* CMmcScannerAO::NewL( TUint32 aMediaId, CMdEHarvesterSession* aMdEClient,
    42 CMmcScannerAO* CMmcScannerAO::NewL( TUint32 aMediaId, CMdEHarvesterSession* aMdEClient,
    43 		MMonitorPluginObserver* aObserver, CHarvesterPluginFactory* aHarvesterPluginFactory, 
    43 		MMonitorPluginObserver* aObserver, CHarvesterPluginFactory* aHarvesterPluginFactory, 
    44 		const TInt aPriority, TBool aAlreadyWaited )
    44 		const TInt aPriority )
    45 	{
    45 	{
    46 	CMmcScannerAO* self = new ( ELeave ) CMmcScannerAO( aMediaId, aMdEClient, aObserver, 
    46 	CMmcScannerAO* self = new ( ELeave ) CMmcScannerAO( aMediaId, aMdEClient, aObserver, 
    47 			aHarvesterPluginFactory, aPriority );
    47 			aHarvesterPluginFactory, aPriority );
    48 	
    48 	
    49 	CleanupStack::PushL( self );
    49 	CleanupStack::PushL( self );
    50 	self->ConstructL( aAlreadyWaited );
    50 	self->ConstructL( );
    51 	CleanupStack::Pop( self );
    51 	CleanupStack::Pop( self );
    52 	return self;
    52 	return self;
    53 	}
    53 	}
    54 
    54 
    55 void CMmcScannerAO::ConstructL( TBool aAlreadyWaited )
    55 void CMmcScannerAO::ConstructL()
    56 	{
    56 	{
    57 	CTimer::ConstructL();
    57     CActiveScheduler::Add( this ); // Add to scheduler
    58 	CActiveScheduler::Add( this ); // Add to scheduler
    58 	iTimer.CreateLocal();
    59 	iState = EUninitialized;
    59 	iState = EUninitialized;
    60 	User::LeaveIfError( iFs.Connect() );
    60 	User::LeaveIfError( iFs.Connect() );
    61 	iMmcFileList = CMmcFileList::NewL();
    61 	iMmcFileList = CMmcFileList::NewL();
    62 	
    62 	
    63 	if( !aAlreadyWaited )
    63     TInt tmpDelay( KDefaultDelay );
    64 	    {
    64     TTimeIntervalMicroSeconds32 delay( tmpDelay * KMillion ); 
    65         TInt tmpDelay( KDefaultDelay );
    65     CRepository* repo = CRepository::NewLC( KRepositoryUid );
    66         TTimeIntervalMicroSeconds32 delay( tmpDelay * KMillion ); 
    66     const TInt err = repo->Get( KScanDelayKey, tmpDelay );
    67         CRepository* repo = CRepository::NewLC( KRepositoryUid );
    67     if ( err == KErrNone )
    68         const TInt err = repo->Get( KScanDelayKey, tmpDelay );
    68         {
    69         if ( err == KErrNone )
    69         delay = tmpDelay * KMillion;
    70             {
    70         }
    71             delay = tmpDelay * KMillion;
    71     CleanupStack::PopAndDestroy( repo );
    72             }
       
    73         CleanupStack::PopAndDestroy( repo );
       
    74         After( delay );
       
    75 	    }
       
    76 	else
       
    77 	    {
       
    78 	    TTimeIntervalMicroSeconds32 delay( 5 ); 
       
    79 	    After( delay );
       
    80 	    }
       
    81 	
    72 	
    82     iHEM = CHarvesterEventManager::GetInstanceL();
    73     iHEM = CHarvesterEventManager::GetInstanceL();
       
    74     
       
    75     iTimer.After( iStatus, delay );
       
    76     SetActive();
    83 	}
    77 	}
    84 
    78 
    85 CMmcScannerAO::~CMmcScannerAO()
    79 CMmcScannerAO::~CMmcScannerAO()
    86 	{
    80 	{
    87 	Cancel(); // Cancel any request, if outstanding
    81 	Cancel(); // Cancel any request, if outstanding
   205 			}
   199 			}
   206 		
   200 		
   207 		case( EDone ):
   201 		case( EDone ):
   208 			{
   202 			{
   209 			iFs.Close();
   203 			iFs.Close();
       
   204 			iTimer.Close();
   210 		    iHdArray.Reset();
   205 		    iHdArray.Reset();
   211 		    iHdArray.Compress();
   206 		    iHdArray.Compress();
   212 			iEntryArray.Compress();
   207 			iEntryArray.Compress();
   213 			iHarvestEntryArray.Compress();
   208 			iHarvestEntryArray.Compress();
       
   209 		    if (iHEM)
       
   210 		        {
       
   211 		        iHEM->ReleaseInstance();
       
   212 		        iHEM = NULL;
       
   213 		        }
   214 			break;
   214 			break;
   215 			}
   215 			}
   216 		
   216 		
   217 		default: 
   217 		default: 
   218 			break;
   218 			break;
   280 		TRequestStatus* ptrStatus = &iStatus;
   280 		TRequestStatus* ptrStatus = &iStatus;
   281 		User::RequestComplete( ptrStatus, KErrNone );
   281 		User::RequestComplete( ptrStatus, KErrNone );
   282 		SetActive();
   282 		SetActive();
   283 		}
   283 		}
   284 	}
   284 	}
       
   285 
       
   286 void CMmcScannerAO::DoCancel()
       
   287     {
       
   288     iTimer.Cancel();
       
   289     iTimer.Close();
       
   290     }
       
   291