|
1 /* |
|
2 * Copyright (c) 2002 - 2006 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 * This class represents a voice memo. It is able to create new files, |
|
16 * rename and delete existing files, and to save them to permanent storage. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef __CVRMEMO_H__ |
|
22 #define __CVRMEMO_H__ |
|
23 |
|
24 // INCLUDES |
|
25 #include <f32file.h> |
|
26 #include "voicerecorder.hrh" |
|
27 #include "VRConsts.h" |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CAknWaitDialog; |
|
31 class CAknGlobalNote; |
|
32 |
|
33 // CLASS DEFINITION |
|
34 /** |
|
35 * This class represents a voice memo. It is able to create new files, |
|
36 * rename and delete existing files, and to save them to permanent storage. |
|
37 */ |
|
38 NONSHARABLE_CLASS( CVRMemo ) |
|
39 : public CBase |
|
40 { |
|
41 |
|
42 public: // enumerations |
|
43 |
|
44 /* |
|
45 * File format of voice recorder |
|
46 * Possible values = 0 (AMR). |
|
47 */ |
|
48 enum TVRFileFormat |
|
49 { |
|
50 EVRFormatAMR = 0 |
|
51 }; |
|
52 |
|
53 public: // constructors and destructor |
|
54 |
|
55 /** |
|
56 * Default constructor. |
|
57 */ |
|
58 CVRMemo(); |
|
59 |
|
60 /** |
|
61 * Destructor. |
|
62 */ |
|
63 ~CVRMemo(); |
|
64 |
|
65 /** |
|
66 * 2nd phase constructor. |
|
67 * @param aDefaultAudioFormat Default audio file format of VR |
|
68 * Is really defined as TVRFileFormat, but for legacy reasons |
|
69 * not used that way yet. |
|
70 */ |
|
71 void ConstructL(TInt aDefaultAudioFormat); |
|
72 |
|
73 public: // new methods |
|
74 |
|
75 /** |
|
76 * Changes the file name of this memo object. |
|
77 * @param aFilename New file name. |
|
78 */ |
|
79 void SetName( const TDesC& aFilename ); |
|
80 |
|
81 /** |
|
82 * Sets the file name to a non-existent, new, name. |
|
83 * @param aEmbedded is true if creating temporary name for embedded |
|
84 * recording (different path) |
|
85 */ |
|
86 void SetTemporaryNameL( TBool aEmbedded = EFalse ); |
|
87 |
|
88 /** |
|
89 * Shows a confirmation query and deletes the memo file |
|
90 * if user accepts. |
|
91 * @return ETrue if deletion was confirmed. |
|
92 */ |
|
93 TBool QueryAndDeleteL(); |
|
94 |
|
95 /** |
|
96 * Deletes the current memo file. |
|
97 * The memo file name is set to KNullDesC |
|
98 */ |
|
99 void DeleteL(); |
|
100 |
|
101 /** |
|
102 * Queries the user for a new name for the current memo file. |
|
103 * @return ETrue if rename was confirmed. |
|
104 */ |
|
105 TBool QueryAndRenameL(); |
|
106 |
|
107 /** |
|
108 * Saves this memo to permanent storage. Removes the original |
|
109 * copy from RAM unless otherwise requested. |
|
110 * @param aProduceCopy Specify ETrue if you want to leave the |
|
111 * original memo file intact. |
|
112 */ |
|
113 void SavePermanentlyL( CAknGlobalNote* aWaitNote, TInt& aNoteId, |
|
114 const TDesC& aLabel, TBool aProduceCopy = EFalse ); |
|
115 |
|
116 /** |
|
117 * Checks wether the memo file represented by this object exists or not |
|
118 * @return ETrue if the file exists |
|
119 */ |
|
120 TBool IsValid() const; |
|
121 |
|
122 /** |
|
123 * Re-reads the file modification timestamp. |
|
124 */ |
|
125 void UpdateModifiedDate(); |
|
126 |
|
127 /** |
|
128 * Returns the duration of the memo in microseconds. |
|
129 * @return Duration |
|
130 */ |
|
131 inline const TTimeIntervalMicroSeconds& Duration() const; |
|
132 |
|
133 /** |
|
134 * Sets the duration of the memo in microseconds. |
|
135 * This is for data storage only (does not affect playback). |
|
136 * @param aDuration The new duration. |
|
137 */ |
|
138 inline void SetDuration( const TTimeIntervalMicroSeconds& aDuration ); |
|
139 |
|
140 /** |
|
141 * Returns the current playing position of the memo in microseconds. |
|
142 * @return Playing position |
|
143 */ |
|
144 inline const TTimeIntervalMicroSeconds& Position() const; |
|
145 |
|
146 /** |
|
147 * Sets the current playing position of the memo in microseconds. |
|
148 * This is for data storage only (does not affect playback). |
|
149 * @param aPosition The new position |
|
150 */ |
|
151 inline void SetPosition( const TTimeIntervalMicroSeconds& aPosition ); |
|
152 |
|
153 /** |
|
154 * Returns the maximum duration of the memo in microseconds. |
|
155 * @return Maximum duration (for recording) |
|
156 */ |
|
157 const TTimeIntervalMicroSeconds& MaxDuration(); |
|
158 |
|
159 /** |
|
160 * Returns the complete file name (path and everything). |
|
161 * @return Reference to the memo name. |
|
162 */ |
|
163 inline const TDesC& Filename() const; |
|
164 |
|
165 /** |
|
166 * Returns the name portion of the complete file name. |
|
167 * @return Reference to the memo name. |
|
168 */ |
|
169 inline const TPtrC& Name() const; |
|
170 |
|
171 /** |
|
172 * Returns the creation date of this file. |
|
173 * @return Reference to the date. |
|
174 */ |
|
175 inline const TTime& DateCreated() const; |
|
176 |
|
177 void SetSavingLocationL( const TDesC& aPath ); |
|
178 |
|
179 /** |
|
180 * Returns the handle of the memo file. |
|
181 * You may have to check the SubSessionHandle() to |
|
182 * now if the file has been opened |
|
183 * @return Reference to the file handle |
|
184 */ |
|
185 inline RFile& File(); |
|
186 |
|
187 /** |
|
188 * Returns the active quality setting. |
|
189 * @return Quality setting of the active memo |
|
190 */ |
|
191 inline TVRQuality Quality() const; |
|
192 |
|
193 /** |
|
194 * Used to set the target file handle. |
|
195 * @param aFile File handle |
|
196 * @param aEmbedded True if recording for external application and |
|
197 * handle must be kept open all the time |
|
198 */ |
|
199 void SetFileHandle( RFile& aFile, const TBool aEmbedded = EFalse ); |
|
200 |
|
201 /** |
|
202 * Check if quality setting has changed and memo needs to be renamed. |
|
203 * Should be called at least before starting to record first memo |
|
204 * after application launch. |
|
205 */ |
|
206 void CheckQualityL(); |
|
207 |
|
208 /** |
|
209 * Sets the attribute iIsRecorded ETrue if recording is started. EFalse |
|
210 * if memo is attached but recording isn't started. |
|
211 * @param aRecorded ETrue when recording is started |
|
212 */ |
|
213 void SetRecorded( TBool aRecorded ); |
|
214 |
|
215 /** |
|
216 * Returns the current memo store. |
|
217 * . |
|
218 */ |
|
219 inline TVRMemoStore MemoStore() const; |
|
220 |
|
221 /** |
|
222 * Returns the creation date of this file. |
|
223 * @return Reference to the date. |
|
224 */ |
|
225 inline TInt StorageDrive() const; |
|
226 |
|
227 |
|
228 |
|
229 private: |
|
230 /** |
|
231 * Checks if iFile has an empty file open |
|
232 * and deletes it, leaving iFile closed |
|
233 * @return returns ETrue if file was deleted |
|
234 */ |
|
235 TBool DeleteEmptyFile(); |
|
236 |
|
237 /** |
|
238 * Checks if recording to the currently open memo is started |
|
239 * Returns ETrue if recording is started, EFalse if not |
|
240 */ |
|
241 TBool IsRecorded() const; |
|
242 |
|
243 private: // data |
|
244 |
|
245 /** |
|
246 * Length of this memo in microseconds. |
|
247 */ |
|
248 TTimeIntervalMicroSeconds iDuration; |
|
249 |
|
250 /** |
|
251 * Length of this memo in microseconds. |
|
252 */ |
|
253 TTimeIntervalMicroSeconds iPosition; |
|
254 |
|
255 /** |
|
256 * Maximum length for all memos. |
|
257 */ |
|
258 TTimeIntervalMicroSeconds iMaxDuration; |
|
259 |
|
260 /** |
|
261 * The final path and file name of the memo. |
|
262 * Memo is moved to this path from temp drive when |
|
263 * when it's saved |
|
264 */ |
|
265 TFileName iFilename; |
|
266 |
|
267 /** |
|
268 * Handle to actual file system file |
|
269 */ |
|
270 RFile iFile; |
|
271 |
|
272 /** |
|
273 * The name of this memo (the file name minus extension). |
|
274 * This is a ptr descriptor to the iFileName; |
|
275 */ |
|
276 TPtrC iNamePtr; |
|
277 |
|
278 /** |
|
279 * The creation time of this memo. |
|
280 */ |
|
281 TTime iDateCreated; |
|
282 |
|
283 /** |
|
284 * A reference to a connected file server session. |
|
285 * Used as a short cut. Not owned. |
|
286 */ |
|
287 RFs iFs; |
|
288 |
|
289 /** |
|
290 * Pointer to a file manager object. Owned. |
|
291 */ |
|
292 CFileMan* iFileMan; |
|
293 |
|
294 /** |
|
295 * The directory where memos will be saved. |
|
296 */ |
|
297 TFileName iSavingLocation; |
|
298 |
|
299 /** |
|
300 * Default audio format for recording audio clip |
|
301 */ |
|
302 TInt iVRAudioFormat; |
|
303 |
|
304 /** |
|
305 * Are we in embedded mode |
|
306 */ |
|
307 TBool iEmbedded; |
|
308 |
|
309 /** |
|
310 * Is the RFile received from outside or should we close it |
|
311 */ |
|
312 TBool iExternalFileHandle; |
|
313 |
|
314 /** |
|
315 * Cached quality setting |
|
316 */ |
|
317 TVRQuality iQuality; |
|
318 |
|
319 /** |
|
320 * Cached storage place setting |
|
321 */ |
|
322 TVRMemoStore iStoragePlace; |
|
323 |
|
324 /** |
|
325 * Cached storage drive setting |
|
326 */ |
|
327 TInt iStorageDrive; |
|
328 |
|
329 /** |
|
330 * Last time that the estimate was updated |
|
331 */ |
|
332 TTime iLastEstimate; |
|
333 |
|
334 /** |
|
335 * Tells if recording of current open memo is started. |
|
336 * EFalse: not recording started |
|
337 * ETrue: recording is started |
|
338 */ |
|
339 TBool iIsRecorded; |
|
340 }; |
|
341 |
|
342 #include "CVRMemo.inl" |
|
343 |
|
344 #endif // __CVRMEMO_H__ |