|
1 /* |
|
2 * Copyright (c) 2000-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 * Description: Observer to signal memorycard mount/dismounts |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMAILDRIVEOBSERVER_H |
|
20 #define CMAILDRIVEOBSERVER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <f32file.h> |
|
25 |
|
26 //CLASS DECLARATION |
|
27 class MDriveObserver |
|
28 { |
|
29 public: |
|
30 |
|
31 /** |
|
32 * aState will be true if drive is mounted and false otherwise |
|
33 */ |
|
34 virtual void DriveStateChangedL( TBool aState ) = 0; |
|
35 }; |
|
36 |
|
37 /** |
|
38 * This active object waits for an indication that the media has changed |
|
39 */ |
|
40 NONSHARABLE_CLASS( CDriveObserver ) : public CActive |
|
41 { |
|
42 public: |
|
43 |
|
44 /** |
|
45 * Two-phased constructor. |
|
46 */ |
|
47 static CDriveObserver* NewL( MDriveObserver& aDriveObserver ); |
|
48 |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 */ |
|
52 static CDriveObserver* NewLC( MDriveObserver& aDriveObserver ); |
|
53 |
|
54 /** |
|
55 * Destructor |
|
56 */ |
|
57 ~CDriveObserver(); |
|
58 |
|
59 /** |
|
60 * Make notification request |
|
61 */ |
|
62 void WaitForChange(); |
|
63 |
|
64 /** |
|
65 * Return true if drive is present and false otherwise. |
|
66 */ |
|
67 TBool IsDrivePresent(); |
|
68 |
|
69 /** |
|
70 * Set drive to monitor. |
|
71 */ |
|
72 void SetDriveL( TDriveNumber aDrive ); |
|
73 |
|
74 |
|
75 private: |
|
76 |
|
77 /** |
|
78 * C++ default constructor |
|
79 */ |
|
80 CDriveObserver( MDriveObserver& aDriveObserver ); |
|
81 |
|
82 /** |
|
83 * By default Symbian OS constructor is private. |
|
84 */ |
|
85 void ConstructL(); |
|
86 |
|
87 /** |
|
88 * This method checks if the drive is mounted |
|
89 */ |
|
90 void MediaPresentL(); |
|
91 |
|
92 // from CActive |
|
93 |
|
94 /** |
|
95 * This method is used when cancelling request |
|
96 */ |
|
97 void DoCancel(); |
|
98 |
|
99 /** |
|
100 * This method is used when changes in drive happens |
|
101 */ |
|
102 void RunL(); |
|
103 |
|
104 /** |
|
105 * This is applied when a leave occur in RunL method. |
|
106 */ |
|
107 TInt RunError(TInt aError); |
|
108 |
|
109 private: |
|
110 |
|
111 /** |
|
112 * File server session. |
|
113 */ |
|
114 RFs iFs; |
|
115 |
|
116 /** |
|
117 * Drive state observer. |
|
118 */ |
|
119 MDriveObserver& iDriveObserver; |
|
120 |
|
121 /** |
|
122 * Drive to monitor. |
|
123 */ |
|
124 TDriveNumber iDrive; |
|
125 |
|
126 /** |
|
127 * Drive letter determined from drive number. |
|
128 */ |
|
129 HBufC* iDriveLetter; |
|
130 |
|
131 }; |
|
132 |
|
133 |
|
134 #endif // _C_DRIVE_MONITOR_H |
|
135 |