|
1 /* |
|
2 * Copyright (c) 2009 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 * |
|
15 * Description: |
|
16 * The source file of drive event watcher |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "fmdriveevent.h" |
|
22 #include <e32std.h> |
|
23 #include "fmcommon.h" |
|
24 |
|
25 #include <aknnotewrappers.h> |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CFileManagerFileSystemEvent::CFileManagerFileSystemEvent |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 |
|
36 CFmDriveEvent::CFmDriveEvent( |
|
37 RFs& aFs, |
|
38 MFmDriveEventObserver *aObserver ) : |
|
39 CActive( CActive::EPriorityLow ), |
|
40 iFs( aFs ), |
|
41 iObserver( aObserver ) |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CFmDriveEvent::ConstructL |
|
47 // Symbian 2nd phase constructor can leave. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void CFmDriveEvent::ConstructL() |
|
51 { |
|
52 CActiveScheduler::Add( this ); |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CFmDriveEvent::NewL |
|
57 // Two-phased constructor. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CFmDriveEvent* CFmDriveEvent::NewL( |
|
61 RFs& aFs, |
|
62 MFmDriveEventObserver *aObserver ) |
|
63 { |
|
64 CFmDriveEvent* self = |
|
65 new( ELeave ) CFmDriveEvent( |
|
66 aFs, |
|
67 aObserver ); |
|
68 |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop( self ); |
|
72 |
|
73 return self; |
|
74 } |
|
75 |
|
76 // ------------------------------------------------------------------------------ |
|
77 // CFmDriveEvent::~CFmDriveEvent |
|
78 // |
|
79 // ------------------------------------------------------------------------------ |
|
80 CFmDriveEvent::~CFmDriveEvent() |
|
81 { |
|
82 Cancel(); |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CFmDriveEvent::RunError |
|
87 // From CActive. Called when error occurred in asynchronous request |
|
88 // Notifies the observer |
|
89 // (other items were commented in a header). |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 TInt CFmDriveEvent::RunError( TInt /*aError*/ ) |
|
93 { |
|
94 return KErrNone; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CFmDriveEvent::DoCancel |
|
99 // From CActive. Called when asynchronous request is canceled |
|
100 // (other items were commented in a header). |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CFmDriveEvent::DoCancel() |
|
104 { |
|
105 iFs.NotifyChangeCancel( iStatus ); |
|
106 } |
|
107 |
|
108 // ------------------------------------------------------------------------------ |
|
109 // CFmDriveEvent::Setup |
|
110 // |
|
111 // ------------------------------------------------------------------------------ |
|
112 // |
|
113 void CFmDriveEvent::Setup() |
|
114 { |
|
115 FM_LOG( QString( "CFmDriveEvent::Setup start" ) ); |
|
116 if( IsActive() ) |
|
117 { |
|
118 return; |
|
119 } |
|
120 |
|
121 iFs.NotifyChange( ENotifyDisk, iStatus ); |
|
122 SetActive(); |
|
123 FM_LOG( QString( "CFmDriveEvent::Setup end" ) ); |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CFmDriveEvent::RunL |
|
128 // From CActive. Called when asynchronous request is completed. |
|
129 // Notifies the observer |
|
130 // (other items were commented in a header). |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void CFmDriveEvent::RunL() |
|
134 { |
|
135 if( iStatus == KErrNone ){ |
|
136 if( iObserver ){ |
|
137 iObserver->OnDriveAddedOrChangedL(); |
|
138 } |
|
139 |
|
140 Setup(); |
|
141 } |
|
142 |
|
143 /* |
|
144 CAknInformationNote* informationNote; |
|
145 informationNote = new ( ELeave ) CAknInformationNote; |
|
146 informationNote->ExecuteLD( _L( "driveChanged!")); |
|
147 */ |
|
148 } |
|
149 |
|
150 // End of File |