|
1 /* |
|
2 * Copyright (c) 2008 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: Asynchronous file copy, implemented with several small sync block copies.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef VCXMYVIDEOSASYNCFILECOPY_H |
|
21 #define VCXMYVIDEOSASYNCFILECOPY_H |
|
22 |
|
23 // INCLUDES |
|
24 |
|
25 // FORWARD DECLARATIONS |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // CLASS DECLARATION |
|
30 |
|
31 /** |
|
32 * @lib mpxmyvideoscollectionplugin.lib |
|
33 */ |
|
34 NONSHARABLE_CLASS(CVcxMyVideosAsyncFileCopy) : |
|
35 public CBase |
|
36 { |
|
37 public: // Constructors and destructor |
|
38 |
|
39 /** |
|
40 * Two-phased constructor |
|
41 * @return object constructed |
|
42 */ |
|
43 static CVcxMyVideosAsyncFileCopy* NewL( RFs& aFs ); |
|
44 |
|
45 /** |
|
46 * Destructor |
|
47 */ |
|
48 virtual ~CVcxMyVideosAsyncFileCopy(); |
|
49 |
|
50 public: |
|
51 /** |
|
52 * Copies aSourceFileName to aSourceFileName. Leaves with KErrNotReady |
|
53 * if there is already copy operation going on. |
|
54 * |
|
55 * @param aSourceFileName Full path and name of the source file. |
|
56 * @param aTargetFileName Full path and name of the target file. |
|
57 * @return ETrue if copy was finished. If EFalse, then |
|
58 * user must do DoNextBlockCopyL calls to |
|
59 * continue copying. |
|
60 */ |
|
61 TBool CopyL( const TDesC& aSourceFileName, const TDesC& aTargetFileName ); |
|
62 |
|
63 /** |
|
64 * Checks if there is copy going on. |
|
65 * |
|
66 * @return ETrue if copy is going on, EFalse otherwise. |
|
67 */ |
|
68 TBool CopyIsOngoing(); |
|
69 |
|
70 /** |
|
71 * Copies next block from the current copy operation. |
|
72 * |
|
73 * @return System wide error code. |
|
74 */ |
|
75 TInt DoNextBlockCopy(); |
|
76 |
|
77 /** |
|
78 * Cancels current copy operation (if any). Does nothing if copy |
|
79 * operation is not going on. Cancel removes the possible target file |
|
80 * which has been created during the current copy operation. |
|
81 */ |
|
82 void Cancel(); |
|
83 |
|
84 private: |
|
85 /** |
|
86 * Constructor |
|
87 */ |
|
88 CVcxMyVideosAsyncFileCopy( RFs& aFs ); |
|
89 |
|
90 /** |
|
91 * Symbian 2nd phase constructor. |
|
92 */ |
|
93 void ConstructL (); |
|
94 |
|
95 /** |
|
96 * Allocates buffer from RAM (iFileBlockBuffer) for a file block. |
|
97 * |
|
98 * @param aFileSize Size of the file to be copied. |
|
99 */ |
|
100 void AllocateFileBlockBufferL( TInt aFileSize ); |
|
101 |
|
102 /** |
|
103 * Closes file handles and resets variables. |
|
104 * |
|
105 * @param aRemoveTargetFile If ETrue then the target file is removed. |
|
106 */ |
|
107 void EndCopy( TBool aRemoveTargetFile ); |
|
108 |
|
109 private: |
|
110 |
|
111 /** |
|
112 * File server session. |
|
113 */ |
|
114 RFs& iFs; |
|
115 |
|
116 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
117 |
|
118 /** |
|
119 * File in which we are copying from. |
|
120 */ |
|
121 RFile64 iSourceFile; |
|
122 |
|
123 /** |
|
124 * File which is being copied to. |
|
125 */ |
|
126 RFile64 iTargetFile; |
|
127 |
|
128 /** |
|
129 * How much data is left for copying. |
|
130 */ |
|
131 TInt64 iDataRemaining; |
|
132 |
|
133 /** |
|
134 * Current read position in source file. |
|
135 */ |
|
136 TInt64 iReadPos; |
|
137 #else |
|
138 |
|
139 /** |
|
140 * File in which we are copying from. |
|
141 */ |
|
142 RFile iSourceFile; |
|
143 |
|
144 /** |
|
145 * File which is being copied to. |
|
146 */ |
|
147 RFile iTargetFile; |
|
148 |
|
149 /** |
|
150 * How much data is left for copying. |
|
151 */ |
|
152 TInt iDataRemaining; |
|
153 |
|
154 /** |
|
155 * Current read position in source file. |
|
156 */ |
|
157 TInt iReadPos; |
|
158 |
|
159 #endif |
|
160 /** |
|
161 * Set to ETrue when copy starts and EFalse when copying ends. |
|
162 */ |
|
163 TBool iIsCopying; |
|
164 |
|
165 /** |
|
166 * Space for the one file block. Own |
|
167 */ |
|
168 HBufC8* iFileBlockBuffer; |
|
169 |
|
170 #ifdef _DEBUG |
|
171 /** |
|
172 * Used to calculate copying speed. |
|
173 */ |
|
174 TTime iStartTime; |
|
175 #endif |
|
176 }; |
|
177 |
|
178 #endif // VCXMYVIDEOSASYNCFILECOPY_H |
|
179 |
|
180 |