|
1 /* |
|
2 * Copyright (c) 2002-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 "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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CDOCSAVER_H |
|
20 #define CDOCSAVER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <StringLoader.h> // For loading resource strings |
|
24 #include <documenthandlerui.rsg> // Resource ids |
|
25 #include <AknWaitDialog.h> // CAknWaitDialog |
|
26 |
|
27 // CONSTANTS |
|
28 const TInt KDocNotDialogShowed = 1; |
|
29 const TInt KDocConfNoteMaxLen = 256; |
|
30 const TInt KDocWaitNoteMaxLen = 256; |
|
31 |
|
32 // MACROS |
|
33 |
|
34 // DATA TYPES |
|
35 |
|
36 // FUNCTION PROTOTYPES |
|
37 |
|
38 // FORWARD DECLARATIONS |
|
39 |
|
40 // CLASS DECLARATION |
|
41 |
|
42 NONSHARABLE_CLASS(CDocSaver) :public CBase |
|
43 { |
|
44 public: // Constructors and destructor |
|
45 |
|
46 /** |
|
47 * C++ default constructor. |
|
48 */ |
|
49 CDocSaver(); |
|
50 |
|
51 /** |
|
52 * Two-phased constructor. |
|
53 */ |
|
54 static CDocSaver* NewL(); |
|
55 |
|
56 /** |
|
57 * Destructor. |
|
58 */ |
|
59 virtual ~CDocSaver(); |
|
60 |
|
61 public: // New functions |
|
62 |
|
63 static void ConfNoteL( const TDesC& aText, TBool aWait ); |
|
64 |
|
65 private: |
|
66 |
|
67 /** |
|
68 * By default EPOC constructor is private. |
|
69 */ |
|
70 void ConstructL(); |
|
71 |
|
72 // By default, prohibit copy constructor |
|
73 CDocSaver( const CDocSaver& ); |
|
74 // Prohibit assigment operator |
|
75 CDocSaver& operator= ( const CDocSaver& ); |
|
76 }; |
|
77 |
|
78 |
|
79 |
|
80 /** |
|
81 * DocHandler's WaitDialog |
|
82 * Shows wait dialog if executed over 1 second, if not shows confirmation note |
|
83 */ |
|
84 class CDocWaitDialog :public CAknWaitDialog |
|
85 { |
|
86 public: // Constructors and destructor |
|
87 |
|
88 /** |
|
89 * C++ default constructor. |
|
90 * @param aNoteControlId Control id of the resource |
|
91 * @param aSelfPtr Pointer to itself. |
|
92 * @param aCaption Caption of the application |
|
93 */ |
|
94 CDocWaitDialog( |
|
95 CEikDialog** aSelfPtr, |
|
96 const TDesC& aText); |
|
97 |
|
98 |
|
99 |
|
100 public: // New functions |
|
101 |
|
102 /** |
|
103 * Delete the wait dialog and show confirmation note if |
|
104 * wait dialog hasn't been visible. |
|
105 */ |
|
106 TBool Finish(); |
|
107 |
|
108 /** |
|
109 * Execute the dialog. Sets the label |
|
110 * and calls CAknWaitDialog's RunDlgLD(). |
|
111 * @return ?description |
|
112 */ |
|
113 TInt ExecuteDlgLD(); |
|
114 |
|
115 private: |
|
116 |
|
117 // By default, prohibit copy constructor |
|
118 CDocWaitDialog( const CDocWaitDialog& ); |
|
119 // Prohibit assigment operator |
|
120 CDocWaitDialog& operator= ( const CDocWaitDialog& ); |
|
121 |
|
122 private: // Data |
|
123 TPtrC iText; |
|
124 TBool iFinished; |
|
125 }; |
|
126 |
|
127 |
|
128 /** |
|
129 * DocHandler's CDocAsyncSaver |
|
130 * Hides asynchronous saving and provides synchronous saving function |
|
131 */ |
|
132 NONSHARABLE_CLASS(CDocAsyncSaver) :public CActive |
|
133 { |
|
134 public: // Constructors and destructor |
|
135 |
|
136 /** |
|
137 * C++ default constructor. |
|
138 */ |
|
139 CDocAsyncSaver(); |
|
140 |
|
141 /** |
|
142 * Two-phased constructor. |
|
143 */ |
|
144 static CDocAsyncSaver* NewL(); |
|
145 static CDocAsyncSaver* NewLC(); |
|
146 |
|
147 /** |
|
148 * Destructor. |
|
149 */ |
|
150 virtual ~CDocAsyncSaver(); |
|
151 |
|
152 public: // New functions |
|
153 |
|
154 /** |
|
155 * Write aContent to the file. |
|
156 * @param aContent Content |
|
157 * @param aDestFile Destination file |
|
158 * @param aWaitNoteText Wait Note text |
|
159 */ |
|
160 void WriteToFileL(const TDesC8& aContent, |
|
161 RFile& aDestFile, |
|
162 const TDesC& aWaitNoteText ); |
|
163 |
|
164 /** |
|
165 * Copy aSourceFile to aDestFile |
|
166 * @param aSourceFile Source file |
|
167 * @param aDestFile Destination file |
|
168 * @param aSwitch Switch |
|
169 * @param aWaitNoteText Wait Note text |
|
170 */ |
|
171 void CopyFileL(CFileMan* aFileManager, |
|
172 const TFileName& aSourceFile, |
|
173 const TFileName& aDestFile, |
|
174 TUint aSwitch, |
|
175 const TDesC& aWaitNoteText ); |
|
176 |
|
177 /** |
|
178 * Copy aSourceFile to aDestFile |
|
179 * @param aSourceFile Filehandle of source file |
|
180 * @param aDestFile Destination file |
|
181 * @param aSwitch Switch |
|
182 * @param aWaitNoteText Wait Note text |
|
183 */ |
|
184 void CopyFileL(CFileMan* aFileManager, |
|
185 const RFile& aSourceFile, |
|
186 const TFileName& aDestFile, |
|
187 TUint aSwitch, |
|
188 const TDesC& aWaitNoteText ); |
|
189 |
|
190 |
|
191 /** |
|
192 * Move aSourceFile to aDestFile |
|
193 * @param aSourceFile Source file |
|
194 * @param aDestFile Destination file |
|
195 * @param aSwitch Switch |
|
196 * @param aWaitNoteText Wait Note text |
|
197 * @param aSilent True=silent operation (do not show waitdialog) |
|
198 */ |
|
199 void MoveFileL(CFileMan* aFileManager, |
|
200 const TFileName& aSourceFile, |
|
201 const TFileName& aDestFile, |
|
202 TUint aSwitch, |
|
203 const TDesC& aWaitNoteText, |
|
204 const TBool aSilent); |
|
205 |
|
206 /** |
|
207 * Returns status of the asynchronous operation |
|
208 * @return Status of the asynchronous operation |
|
209 */ |
|
210 TRequestStatus Status(); |
|
211 |
|
212 /** |
|
213 * Delete waitdialog and return status of the dialog. |
|
214 * @return ETrue if waitdialog is visible |
|
215 * EFalse if waitdialog isn't visible |
|
216 */ |
|
217 TBool ShowDialog(); |
|
218 |
|
219 protected: // Functions from base classes |
|
220 |
|
221 /** |
|
222 * From CActive Not implemented |
|
223 */ |
|
224 void DoCancel() ; |
|
225 /** |
|
226 * From CActive Delete wait dialog and stop CActiveSchedulerWait |
|
227 */ |
|
228 void RunL() ; |
|
229 |
|
230 private: |
|
231 |
|
232 /** |
|
233 * By default EPOC constructor is private. |
|
234 */ |
|
235 void ConstructL(); |
|
236 |
|
237 // By default, prohibit copy constructor |
|
238 CDocAsyncSaver( const CDocAsyncSaver& ); |
|
239 // Prohibit assigment operator |
|
240 CDocAsyncSaver& operator= ( const CDocAsyncSaver& ); |
|
241 |
|
242 private: // Data |
|
243 CDocWaitDialog* iDocWaitDialog; |
|
244 CActiveSchedulerWait iWait; // To make asychronous synchronous |
|
245 TBool iShowDialog; |
|
246 TBool iSilent; |
|
247 }; |
|
248 |
|
249 #endif // CDOCSAVER_H |
|
250 |
|
251 // End of File |