92
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <driveinfo.h>
|
|
19 |
|
|
20 |
#include "cammcwatcher.h"
|
|
21 |
|
|
22 |
// ================= MEMBER FUNCTIONS =======================
|
|
23 |
|
119
|
24 |
// ----------------------------------------------------------------------------
|
|
25 |
//
|
|
26 |
// ----------------------------------------------------------------------------
|
92
|
27 |
//
|
|
28 |
EXPORT_C CCaMmcWatcher* CCaMmcWatcher::NewL( RFs& aFs,
|
|
29 |
MMmcWatcherCallback* aObserver )
|
|
30 |
{
|
|
31 |
CCaMmcWatcher* self = NewLC( aFs, aObserver );
|
|
32 |
CleanupStack::Pop( self );
|
|
33 |
return self;
|
|
34 |
}
|
|
35 |
|
119
|
36 |
// ----------------------------------------------------------------------------
|
|
37 |
//
|
|
38 |
// ----------------------------------------------------------------------------
|
92
|
39 |
//
|
|
40 |
EXPORT_C CCaMmcWatcher* CCaMmcWatcher::NewLC( RFs& aFs,
|
|
41 |
MMmcWatcherCallback* aObserver )
|
|
42 |
{
|
|
43 |
CCaMmcWatcher* self = new (ELeave) CCaMmcWatcher( aFs,
|
|
44 |
aObserver );
|
|
45 |
CleanupStack::PushL ( self );
|
|
46 |
self->ConstructL();
|
|
47 |
return self;
|
|
48 |
}
|
|
49 |
|
119
|
50 |
// ----------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
// ----------------------------------------------------------------------------
|
92
|
53 |
//
|
|
54 |
CCaMmcWatcher::~CCaMmcWatcher()
|
|
55 |
{
|
|
56 |
Cancel();
|
|
57 |
}
|
|
58 |
|
119
|
59 |
// ----------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
// ----------------------------------------------------------------------------
|
92
|
62 |
//
|
|
63 |
CCaMmcWatcher::CCaMmcWatcher( RFs& aFs,
|
|
64 |
MMmcWatcherCallback* aObserver )
|
|
65 |
: CActive( CActive::EPriorityStandard ),
|
|
66 |
iFs(aFs),
|
|
67 |
iObserver(aObserver)
|
|
68 |
{
|
|
69 |
CActiveScheduler::Add(this);
|
|
70 |
}
|
|
71 |
|
119
|
72 |
// ----------------------------------------------------------------------------
|
|
73 |
//
|
|
74 |
// ----------------------------------------------------------------------------
|
92
|
75 |
//
|
|
76 |
void CCaMmcWatcher::ConstructL()
|
|
77 |
{
|
|
78 |
WaitForChangeL();
|
|
79 |
}
|
|
80 |
|
119
|
81 |
// ----------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
// ----------------------------------------------------------------------------
|
92
|
84 |
//
|
|
85 |
void CCaMmcWatcher::WaitForChangeL()
|
|
86 |
{
|
|
87 |
TInt mmcDrive;
|
|
88 |
User::LeaveIfError( DriveInfo::GetDefaultDrive(
|
|
89 |
DriveInfo::EDefaultRemovableMassStorage, mmcDrive ) );
|
|
90 |
TDriveName mmcDriveName( TDriveUnit( mmcDrive ).Name() );
|
|
91 |
iFs.NotifyChange( ENotifyEntry, iStatus, mmcDriveName );
|
|
92 |
SetActive();
|
|
93 |
}
|
|
94 |
|
119
|
95 |
// ----------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
// ----------------------------------------------------------------------------
|
92
|
98 |
//
|
|
99 |
void CCaMmcWatcher::DoCancel()
|
|
100 |
{
|
|
101 |
iFs.NotifyChangeCancel();
|
|
102 |
}
|
|
103 |
|
98
|
104 |
#ifdef COVERAGE_MEASUREMENT
|
|
105 |
#pragma CTC SKIP
|
|
106 |
#endif //COVERAGE_MEASUREMENT (error is ignored)
|
92
|
107 |
// ---------------------------------------------------------------------------
|
119
|
108 |
//
|
92
|
109 |
// ---------------------------------------------------------------------------
|
|
110 |
//
|
|
111 |
TInt CCaMmcWatcher::RunError( TInt /*aError*/ )
|
|
112 |
{
|
|
113 |
// No need to do anything
|
|
114 |
return KErrNone;
|
|
115 |
}
|
98
|
116 |
#ifdef COVERAGE_MEASUREMENT
|
|
117 |
#pragma CTC ENDSKIP
|
|
118 |
#endif //COVERAGE_MEASUREMENT
|
92
|
119 |
|
98
|
120 |
#ifdef COVERAGE_MEASUREMENT
|
|
121 |
#pragma CTC SKIP
|
|
122 |
#endif //COVERAGE_MEASUREMENT (memory card removal)
|
119
|
123 |
// ---------------------------------------------------------------------------
|
|
124 |
//
|
|
125 |
// ---------------------------------------------------------------------------
|
92
|
126 |
//
|
|
127 |
void CCaMmcWatcher::RunL()
|
|
128 |
{
|
|
129 |
TInt status( iStatus.Int() );
|
|
130 |
WaitForChangeL();
|
|
131 |
if ( status >= KErrNone )
|
|
132 |
{
|
|
133 |
iObserver->MmcChangeL();
|
|
134 |
}
|
|
135 |
}
|
98
|
136 |
#ifdef COVERAGE_MEASUREMENT
|
|
137 |
#pragma CTC ENDSKIP
|
|
138 |
#endif //COVERAGE_MEASUREMENT
|