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 |