|
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 * Description: File manager for managing file copy op |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CMRFILEMANAGER_H |
|
19 #define CMRFILEMANAGER_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 #include <f32file.h> // RFs |
|
24 #include <s32file.h> // Streams |
|
25 #include <badesca.h> // CDesCArrayFlat |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class MDesC16Array; |
|
29 // CLASS DECLARATIONS |
|
30 |
|
31 /** |
|
32 * Notification interface for copy operation |
|
33 */ |
|
34 class MMRFileManObserver |
|
35 { |
|
36 public: |
|
37 virtual void NotifyStartL( const TDesC& aFilename ) = 0; |
|
38 virtual void NotifyProgress( TInt aBytesCopied ) = 0; |
|
39 virtual void NotifyEnd() = 0; |
|
40 virtual void NotifyError( TInt aError ) = 0; |
|
41 |
|
42 protected: |
|
43 virtual ~MMRFileManObserver(){} |
|
44 }; |
|
45 /** |
|
46 * Class for managing async file copy operations |
|
47 */ |
|
48 NONSHARABLE_CLASS( CMRFileManager ) : public CActive |
|
49 { |
|
50 public: // c'tor and d'tor |
|
51 static CMRFileManager* NewL( RFs& aFs ); |
|
52 |
|
53 ~CMRFileManager(); |
|
54 |
|
55 public: // Interface |
|
56 void CopyFilesL( MDesC16Array& aFilenameArray ); |
|
57 void CopyFileL( const TDesC& aSourceFilename, const TDesC& aDestFilename ); |
|
58 void CopyFileL( RFile& aSource, RFile& aDest ); |
|
59 void CancelOp(); |
|
60 |
|
61 void SetObserver( MMRFileManObserver& aObserver ); |
|
62 MDesC16Array& CopiedFiles() const; |
|
63 |
|
64 public: // From CActive |
|
65 void RunL(); |
|
66 TInt RunError( TInt aError ); |
|
67 void DoCancel(); |
|
68 |
|
69 private: // Impl |
|
70 CMRFileManager( RFs& aFs ); |
|
71 void ConstructL(); |
|
72 void AsyncOp(); |
|
73 void CopyFileL(); |
|
74 void PrepareNextFileL(); |
|
75 |
|
76 private: // Data |
|
77 enum TState |
|
78 { |
|
79 ECopyFile, |
|
80 ECancelled, |
|
81 EDone |
|
82 } iState; |
|
83 |
|
84 RFs& iFs; |
|
85 /// |
|
86 RFileReadStream iReadStream; |
|
87 /// |
|
88 RFileWriteStream iWriteStream; |
|
89 /// Own: |
|
90 CDesCArrayFlat* iFileArray; |
|
91 /// Own: |
|
92 CDesCArrayFlat* iOutputFileArray; |
|
93 /// Own: current file index |
|
94 TInt iFileIndex; |
|
95 /// Own: |
|
96 HBufC* iCurrentFilename; |
|
97 /// Own: |
|
98 HBufC* iTempFilename; |
|
99 /// Ref: |
|
100 MMRFileManObserver* iObserver; |
|
101 }; |
|
102 |
|
103 #endif // CMRFILEMANAGER_H |
|
104 // End of file |