|
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 the License "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: Helper class for Video Center for drive operations/monitoring.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CVIDEOSETTINGSDRIVEMONITOR_H |
|
21 #define CVIDEOSETTINGSDRIVEMONITOR_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <f32file.h> |
|
26 #include "tvideosettingsdriveinfo.h" |
|
27 #include "tvideosettingsdrivemonitorevent.h" |
|
28 #include "mvideosettingsdrivemonitorobserver.h" |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // MACROS |
|
33 |
|
34 // DATA TYPES |
|
35 |
|
36 // FUNCTION PROTOTYPES |
|
37 |
|
38 // FORWARD DECLARATIONS |
|
39 |
|
40 // CLASS DECLARATION |
|
41 |
|
42 /** |
|
43 * Helper class for Video Center for drive operations/monitoring. |
|
44 * User can get available drives (through iAvailableDrives public member) |
|
45 * and be notified when drives change (through MIptvDriveMonitorObserver interface). |
|
46 */ |
|
47 class CVideoSettingsDriveMonitor : public CActive |
|
48 { |
|
49 public: // Constructors and destructor |
|
50 |
|
51 /** |
|
52 * Two-phased constructor. |
|
53 */ |
|
54 IMPORT_C static CVideoSettingsDriveMonitor* NewL(); |
|
55 |
|
56 /** |
|
57 * Two-phased constructor. Use this is owner object already has a file session open. |
|
58 * |
|
59 * @param aFileSession file session. |
|
60 */ |
|
61 IMPORT_C static CVideoSettingsDriveMonitor* NewL( const RFs& aFileSession ); |
|
62 |
|
63 /** |
|
64 * Destructor. |
|
65 */ |
|
66 IMPORT_C virtual ~CVideoSettingsDriveMonitor(); |
|
67 |
|
68 public: |
|
69 |
|
70 /** |
|
71 * Registers observer for drive events. |
|
72 * iAvailableDrives is updated automatically if there are any |
|
73 * observers registered, ie there is no need to call RefreshAvailableDrivesL |
|
74 * when observing. |
|
75 * Don't keep observers around if they do not need events. Observing should be used |
|
76 * when user needs to know immedetially about memory card insertion/removed events, |
|
77 * or drive locked/unlocked events. |
|
78 * |
|
79 * @param aObserver observer, ownership does not move. |
|
80 */ |
|
81 IMPORT_C void RegisterObserverL( MIptvDriveMonitorObserver* aObserver ); |
|
82 |
|
83 /** |
|
84 * Removes observer, ownership does not move. |
|
85 * @param aObserver observer to be removed from observers list. |
|
86 */ |
|
87 IMPORT_C void RemoveObserverL( MIptvDriveMonitorObserver* aObserver ); |
|
88 |
|
89 /** |
|
90 * Updates iAvailableDrives member variable from File server. |
|
91 * This is called in ConstructL() also. |
|
92 */ |
|
93 IMPORT_C void RefreshAvailableDrivesL(); |
|
94 |
|
95 /** |
|
96 * Returns the position index of aDrive in iAvailableDrives. |
|
97 * |
|
98 * @param aDrive drive to search. |
|
99 * @return Position index of aDrive in iAvailableDrives. If not found, |
|
100 * KErrNotFound is returned. |
|
101 */ |
|
102 IMPORT_C TInt ArrayPos( TInt aDrive ); |
|
103 |
|
104 /** |
|
105 * Returns the position index of aDrive in iAvailableDrives. If not |
|
106 * found, leaves with KErrNotFound code. |
|
107 * |
|
108 * @param aDrive drive to search. |
|
109 * @return Position index of aDrive in iAvailableDrives. |
|
110 */ |
|
111 IMPORT_C TInt ArrayPosL( TInt aDrive ); |
|
112 |
|
113 /** |
|
114 * Returns the first removable drive (= memory card drive) from iAvailableDrives |
|
115 * array. Leaves with KErrNotFound if not found. |
|
116 */ |
|
117 IMPORT_C TInt MemoryCardDriveL(); |
|
118 |
|
119 /** |
|
120 * Returns the first removable drive (= memory card drive) from iAvailableDrives |
|
121 * array. Returns KErrNotFound if not found. |
|
122 * |
|
123 * @return drive number, or KErrNotFound if not found. |
|
124 */ |
|
125 IMPORT_C TInt MemoryCardDrive(); |
|
126 |
|
127 /** |
|
128 * Returns the first mass storage drive from iAvailableDrives array. |
|
129 * Mass storege drive means the drive which is preferred for storing large |
|
130 * files in the device, the drive itself can be anything, usually not c though. |
|
131 * Leaves with KErrNotFound if not found. |
|
132 * |
|
133 * @return Drive number. |
|
134 */ |
|
135 IMPORT_C TInt MassStorageDriveL(); |
|
136 |
|
137 /** |
|
138 * Returns the first mass storage drive from iAvailableDrives array. |
|
139 * Mass storege drive means the drive which is preferred for storing large |
|
140 * files in the device, the drive itself can be anything except c-drive. |
|
141 * Returns KErrNotFound if not found. |
|
142 * |
|
143 * @return Drive number, or KErrNotFound if not found. |
|
144 */ |
|
145 IMPORT_C TInt MassStorageDrive(); |
|
146 |
|
147 /** |
|
148 * Returns the phone memory drive from iAvailableDrives array. |
|
149 * Leaves with KErrNotFound if not found. |
|
150 * |
|
151 * @return Drive number. |
|
152 */ |
|
153 IMPORT_C TInt PhoneMemoryDriveL(); |
|
154 |
|
155 /** |
|
156 * Returns the PhoneMemory drive from iAvailableDrives array. |
|
157 * Returns KErrNotFound if not found. |
|
158 * |
|
159 * @return Drive number, or KErrNotFound if not found. |
|
160 */ |
|
161 IMPORT_C TInt PhoneMemoryDrive(); |
|
162 |
|
163 /** |
|
164 * Returns the first fixed (= non removable) drive from iAvailableDrives array. |
|
165 * Leaves with KErrNotFound if not found. |
|
166 * |
|
167 * @param aExcludeCDrive If ETrue, then C-drive is excluded. |
|
168 * @return Drive number. |
|
169 */ |
|
170 IMPORT_C TInt FixedDriveL( TBool aExcludeCDrive ); |
|
171 |
|
172 /** |
|
173 * Returns the first fixed (= non removable) drive from iAvailableDrives array. |
|
174 * Returns KErrNotFound if not found. |
|
175 * |
|
176 * @param aExcludeCDrive If ETrue, then C-drive is excluded. |
|
177 * @return Drive number, or KErrNotFound if not found. |
|
178 */ |
|
179 IMPORT_C TInt FixedDrive( TBool aExcludeCDrive ); |
|
180 |
|
181 /** |
|
182 * Finds out if memory card is inserted and not locked. |
|
183 * |
|
184 * @return Returns ETrue is memory card is inserted and usable (not locked), EFalse otherwise. |
|
185 */ |
|
186 IMPORT_C TBool IsMmcInserted(); |
|
187 |
|
188 /** |
|
189 * Gets the used memory from cenrep. If cenrep contains invalid drive or value is not found, |
|
190 * chooses the preferred drive in the following order: 1. mass storage 2. memory card |
|
191 * 3. EDriveC. If cenrep value was not usable, the chosen drive is written to cenrep. |
|
192 * Leaves with system-wide error code if wasn't able to get the used memory. |
|
193 * |
|
194 * @param aUsedMemory The used memory drive is written here. |
|
195 */ |
|
196 IMPORT_C void GetUsedMemoryL( TInt& aUsedMemory ); |
|
197 |
|
198 |
|
199 protected: // Functions from base classes |
|
200 |
|
201 /** |
|
202 * From CActive, RunL. |
|
203 * Called when operation completes. |
|
204 */ |
|
205 IMPORT_C void RunL(); |
|
206 |
|
207 /** |
|
208 * From CActive, cancels request. |
|
209 */ |
|
210 void DoCancel(); |
|
211 |
|
212 /** |
|
213 * From CActive, handles leaves from RunL. |
|
214 */ |
|
215 TInt RunError( TInt aError ); |
|
216 |
|
217 private: |
|
218 |
|
219 /** |
|
220 * C++ default constructor. |
|
221 */ |
|
222 CVideoSettingsDriveMonitor(); |
|
223 |
|
224 /** |
|
225 * By default Symbian 2nd phase constructor is private. |
|
226 */ |
|
227 void ConstructL(); |
|
228 |
|
229 /** |
|
230 * By default Symbian 2nd phase constructor is private. |
|
231 * |
|
232 * @param aFileSession |
|
233 */ |
|
234 void ConstructL( const RFs& aFileSession ); |
|
235 |
|
236 /** |
|
237 * Sends event to observers. |
|
238 * |
|
239 * @param aEvent event to send. |
|
240 * @param aDrive drive which caused the event. |
|
241 */ |
|
242 void SendEvent( TIptvDriveMonitorEvent::TEvent aEvent, TInt aDrive ); |
|
243 |
|
244 /** |
|
245 * Compares iPreviousAvailableDrives and iAvailableDrives arrays and |
|
246 * sends appropriate events if they differ. |
|
247 */ |
|
248 void CompareOldAndNewAvailableDrives(); |
|
249 |
|
250 /** |
|
251 * Returns drive type as a descriptor. For debugging only. |
|
252 * @param aType Drive type, see valid values from e32const.h TMediaType enum. |
|
253 */ |
|
254 const TDesC& DriveTypeDes( TInt aType ); |
|
255 |
|
256 /** |
|
257 * Prints available drives. For debugging only. |
|
258 */ |
|
259 void PrintAvailableDrives(); |
|
260 |
|
261 public: |
|
262 |
|
263 /** |
|
264 * Array of currently available drives. These are updated |
|
265 * with RefreshAvailableDrivesL -method or from file |
|
266 * server event. RefreshAvailableDrivesL is also called upon creation |
|
267 * of this object. |
|
268 * iAvailableDrives array contains drives which are available for mass |
|
269 * storaging videos. If there is hard disk and memory card |
|
270 * available(both e and f-drives), then c-drive is excluded from the array. |
|
271 */ |
|
272 RArray<TIptvDriveInfo> iAvailableDrives; |
|
273 |
|
274 |
|
275 private: |
|
276 |
|
277 /** |
|
278 * Used to detect if refresh had any effect. |
|
279 */ |
|
280 RArray<TIptvDriveInfo> iPreviousAvailableDrives; |
|
281 |
|
282 /** |
|
283 * Array of observers. Pointers not owned. |
|
284 */ |
|
285 RArray<MIptvDriveMonitorObserver*> iObservers; |
|
286 |
|
287 /** |
|
288 * Session to file server. |
|
289 */ |
|
290 RFs iFs; |
|
291 |
|
292 /** |
|
293 * ETrue if iFs is provided by the user of this class. |
|
294 */ |
|
295 TBool iIfsIsProvidedByUser; |
|
296 |
|
297 }; |
|
298 |
|
299 #endif // CVIDEOSETTINGSDRIVEMONITOR_H |
|
300 |
|
301 // End of File |