|
1 /* |
|
2 * Copyright (c) 2007 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: Base class for disk watchers. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include <e32base.h> |
|
22 #include "diskwatcherbase.h" |
|
23 #include "disknotifyhandler.h" |
|
24 #include "disknotifyhandlerdebug.h" |
|
25 |
|
26 |
|
27 // ======== MEMBER FUNCTIONS ======== |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CDiskWatcherBase::CDiskWatcherBase |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CDiskWatcherBase::CDiskWatcherBase( |
|
34 MDiskNotifyHandlerCallback& aCallback, |
|
35 RFs& aFs ) : |
|
36 CActive( CActive::EPriorityStandard ), |
|
37 iCallback( aCallback ), |
|
38 iFs( aFs ) |
|
39 { |
|
40 FUNC_LOG |
|
41 |
|
42 CActiveScheduler::Add( this ); |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CDiskWatcherBase::~CDiskWatcherBase |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CDiskWatcherBase::~CDiskWatcherBase() |
|
50 { |
|
51 FUNC_LOG |
|
52 |
|
53 if ( iKilled ) |
|
54 { |
|
55 *iKilled = ETrue; |
|
56 } |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CDiskWatcherBase::RunL |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 void CDiskWatcherBase::RunL() |
|
64 { |
|
65 FUNC_LOG_WITH_CLIENT_NAME |
|
66 |
|
67 TInt err( iStatus.Int() ); |
|
68 if ( err == KErrCancel ) |
|
69 { |
|
70 INFO_LOG( "CDiskWatcherBase::RunL-CANCELED" ) |
|
71 return; // Supress cancel |
|
72 } |
|
73 |
|
74 TBool killed( EFalse ); |
|
75 iKilled = &killed; |
|
76 if( err != KErrNone ) |
|
77 { |
|
78 // Nofity error |
|
79 ERROR_LOG1( "CDiskWatcherBase::RunL-err=%d", err ) |
|
80 WatcherError( err, killed ); |
|
81 } |
|
82 else |
|
83 { |
|
84 // Notify event |
|
85 ReactivateWatcher(); |
|
86 RunWatcher( killed ); |
|
87 } |
|
88 |
|
89 if ( killed ) |
|
90 { |
|
91 INFO_LOG( "CDiskWatcherBase::RunL-KILLED" ) |
|
92 return; |
|
93 } |
|
94 iKilled = NULL; |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CDiskWatcherBase::RunError |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 TInt CDiskWatcherBase::RunError( TInt /*aError*/ ) |
|
102 { |
|
103 FUNC_LOG |
|
104 |
|
105 return KErrNone; |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CDiskWatcherBase::DoCancel |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 void CDiskWatcherBase::DoCancel() |
|
113 { |
|
114 FUNC_LOG |
|
115 |
|
116 CancelWatcher(); |
|
117 } |
|
118 |
|
119 // End of File |