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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef FILEBROWSER_FILEUTILS_H |
|
20 #define FILEBROWSER_FILEUTILS_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <f32file.h> |
|
25 #include <w32std.h> |
|
26 #include <badesca.h> |
|
27 #include <coedef.h> |
|
28 #include <AknServerApp.h> |
|
29 #include <msvapi.h> |
|
30 #include <AknProgressDialog.h> |
|
31 #include <tz.h> |
|
32 |
|
33 _LIT(KIRAppPath, "z:\\sys\\bin\\irapp.exe"); |
|
34 _LIT(KBTAppPath, "z:\\sys\\bin\\btui.exe"); |
|
35 _LIT(KUSBAppPath, "z:\\sys\\bin\\usbclasschangeui.exe"); |
|
36 _LIT(KErrRdPath, "c:\\resource\\ErrRd"); |
|
37 _LIT(KErrRdDir, "c:\\resource\\"); |
|
38 |
|
39 |
|
40 // FORWARD DECLARATIONS |
|
41 class CFileBrowserModel; |
|
42 class CFileBrowserFileOps; |
|
43 class CAknIconArray; |
|
44 class TAknsItemID; |
|
45 class CDocumentHandler; |
|
46 class CAknWaitDialog; |
|
47 class CAknProgressDialog; |
|
48 class CEikProgressInfo; |
|
49 class CFBFileOpClient; |
|
50 class CAknProgressDialog; |
|
51 class CEikProgressInfo; |
|
52 class CAknOpenFileService; |
|
53 class CMessageDigest; |
|
54 |
|
55 // CLASS DECLARATIONS |
|
56 |
|
57 class TSearchAttributes |
|
58 { |
|
59 public: |
|
60 TFileName iSearchDir; |
|
61 TFileName iWildCards; |
|
62 TFileName iTextInFile; |
|
63 TUint iMinSize; |
|
64 TUint iMaxSize; |
|
65 TTime iMinDate; |
|
66 TTime iMaxDate; |
|
67 TBool iRecurse; |
|
68 }; |
|
69 |
|
70 class TDriveEntry |
|
71 { |
|
72 public: |
|
73 TChar iLetter; |
|
74 TInt iNumber; |
|
75 TVolumeInfo iVolumeInfo; |
|
76 TBuf<64> iMediaTypeDesc; |
|
77 TBuf<128> iAttributesDesc; |
|
78 TInt iIconId; |
|
79 }; |
|
80 |
|
81 class TFileEntry |
|
82 { |
|
83 public: |
|
84 TFileName iPath; |
|
85 TEntry iEntry; |
|
86 TInt iDirEntries; |
|
87 TInt iIconId; |
|
88 }; |
|
89 |
|
90 class TAppIcon |
|
91 { |
|
92 public: |
|
93 TInt iId; |
|
94 TUid iUid; |
|
95 }; |
|
96 |
|
97 typedef CArrayFixSeg<TDriveEntry> CDriveEntryList; |
|
98 typedef CArrayFixSeg<TFileEntry> CFileEntryList; |
|
99 typedef CArrayFixSeg<TAppIcon> CAppIconList; |
|
100 |
|
101 |
|
102 class CCommandParamsBase : public CBase |
|
103 { |
|
104 }; |
|
105 |
|
106 class CCommandParamsAttribs : public CCommandParamsBase |
|
107 { |
|
108 public: |
|
109 TFileEntry iSourceEntry; |
|
110 TUint iSetMask; |
|
111 TUint iClearMask; |
|
112 TTime iTime; |
|
113 TUint iSwitch; |
|
114 public: |
|
115 CCommandParamsAttribs(const TFileEntry& aSourceEntry, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) : iSourceEntry(aSourceEntry), iSetMask(aSetMask), iClearMask(aClearMask), iTime(aTime), iSwitch(aSwitch) {} |
|
116 }; |
|
117 |
|
118 class CCommandParamsCopyOrMove : public CCommandParamsBase |
|
119 { |
|
120 public: |
|
121 TFileEntry iSourceEntry; |
|
122 TFileName iTargetPath; |
|
123 TUint iSwitch; |
|
124 public: |
|
125 CCommandParamsCopyOrMove(const TFileEntry& aSourceEntry, const TDesC& aTargetPath, TUint aSwitch) : iSourceEntry(aSourceEntry), iTargetPath(aTargetPath), iSwitch(aSwitch) {} |
|
126 }; |
|
127 |
|
128 class CCommandParamsRename : public CCommandParamsBase |
|
129 { |
|
130 public: |
|
131 TFileEntry iSourceEntry; |
|
132 TFileName iTargetPath; |
|
133 TUint iSwitch; |
|
134 public: |
|
135 CCommandParamsRename(const TFileEntry& aSourceEntry, const TDesC& aTargetPath, TUint aSwitch) : iSourceEntry(aSourceEntry), iTargetPath(aTargetPath), iSwitch(aSwitch) {} |
|
136 }; |
|
137 |
|
138 class CCommandParamsDelete : public CCommandParamsBase |
|
139 { |
|
140 public: |
|
141 TFileEntry iSourceEntry; |
|
142 TUint iSwitch; |
|
143 public: |
|
144 CCommandParamsDelete(const TFileEntry& aSourceEntry, TUint aSwitch) : iSourceEntry(aSourceEntry), iSwitch(aSwitch) {} |
|
145 }; |
|
146 |
|
147 class CCommandParamsDriveSnapShot : public CCommandParamsBase |
|
148 { |
|
149 public: |
|
150 TInt iSourceDriveLetter; |
|
151 TInt iTargetDriveLetter; |
|
152 public: |
|
153 CCommandParamsDriveSnapShot(TChar aSourceDriveLetter, TChar aTargetDriveLetter) : iSourceDriveLetter(aSourceDriveLetter), iTargetDriveLetter(aTargetDriveLetter) {} |
|
154 }; |
|
155 |
|
156 class TCommand |
|
157 { |
|
158 public: |
|
159 TInt iCommandId; |
|
160 CCommandParamsBase* iParameters; |
|
161 public: |
|
162 TCommand(TInt aCommandId, CCommandParamsBase* aParameters) : iCommandId(aCommandId), iParameters(aParameters) {} |
|
163 }; |
|
164 |
|
165 typedef CArrayFixSeg<TCommand> CCommandArray; |
|
166 |
|
167 |
|
168 |
|
169 class CFileBrowserFileUtils : public CActive, public MAknServerAppExitObserver, public MMsvSessionObserver, public MProgressDialogCallback |
|
170 { |
|
171 private: |
|
172 enum TState // active object states |
|
173 { |
|
174 EIdle = 0, // do nothing |
|
175 }; |
|
176 |
|
177 enum TClipBoardMode |
|
178 { |
|
179 EClipBoardModeCut = 0, |
|
180 EClipBoardModeCopy |
|
181 }; |
|
182 |
|
183 enum TListingMode |
|
184 { |
|
185 ENormalEntries = 0, |
|
186 ESearchResults, |
|
187 EOpenFiles, |
|
188 EMsgAttachmentsInbox, |
|
189 EMsgAttachmentsDrafts, |
|
190 EMsgAttachmentsSentItems, |
|
191 EMsgAttachmentsOutbox |
|
192 }; |
|
193 |
|
194 public: |
|
195 static CFileBrowserFileUtils* NewL(CFileBrowserModel* aModel); |
|
196 ~CFileBrowserFileUtils(); |
|
197 |
|
198 private: |
|
199 CFileBrowserFileUtils(CFileBrowserModel* aModel); |
|
200 void ConstructL(); |
|
201 |
|
202 private: // from CActive |
|
203 void RunL(); |
|
204 TInt RunError(TInt aError); |
|
205 void DoCancel(); |
|
206 |
|
207 private: // from MAknServerAppExitObserver |
|
208 void HandleServerAppExit(TInt aReason); |
|
209 |
|
210 private: // from MMsvSessionObserver |
|
211 void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); |
|
212 |
|
213 private: //from MProgressDialogCallback |
|
214 void DialogDismissedL(TInt aButtonId); |
|
215 |
|
216 private: // command handling |
|
217 void StartExecutingCommandsL(const TDesC& aLabel); |
|
218 void ExecuteCommand(); |
|
219 void CheckForMoreCommandsL(); |
|
220 void AppendToCommandArrayL(TInt aCommand, CCommandParamsBase* aParameters); |
|
221 TInt CommandArrayCount() const; |
|
222 void ResetCommandArray(); |
|
223 |
|
224 private: // misc functionality |
|
225 void GenerateDirectoryDataL(); |
|
226 void GetDriveListL(); |
|
227 void GetDirectoryListingL(); |
|
228 CAknIconArray* GenerateIconArrayL(TBool aGenerateNewBasicIconArray=EFalse); |
|
229 void AppendGulIconToIconArrayL(CAknIconArray* aIconArray, const TDesC& aIconFile, TInt aIconId, TInt aMaskId, const TAknsItemID aAknsItemId); |
|
230 TInt AppIconIdForUid(TUid aUid); |
|
231 TUid GetAppUid(TFileEntry aFileEntry); |
|
232 CDesCArray* GenerateItemTextArrayL(); |
|
233 TInt GetSelectedItemsOrCurrentItemL(CFileEntryList* aFileEntryList); |
|
234 void DoCopyToFolderL(CFileEntryList* aEntryList, const TDesC& aTargetDir, TBool aDeleteSource); |
|
235 TInt DoSearchFiles(const TDesC& aFileName, const TDesC& aPath); |
|
236 TInt DoSearchFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath); |
|
237 TInt DoFindFiles(const TDesC& aFileName, const TDesC& aPath); |
|
238 TInt DoFindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath); |
|
239 void ReadAttachmentPathsRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, CDesCArray* aAttPaths); |
|
240 void WriteMessageEntryInfoRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, RFile& aFile, TInt& aLevel); |
|
241 void DoWriteMessageEntryInfoL(CMsvEntry* aContext, RFile& aFile, TInt aLevel); |
|
242 void ConvertCharsToPwd(TDesC& aWord, TDes8& aConverted) const; |
|
243 HBufC8* MessageDigestInHexLC(CMessageDigest* aMD, RFile& aFile); |
|
244 void OpenCommonFileActionQueryL(); |
|
245 |
|
246 public: // public interfaces |
|
247 TKeyResponse HandleOfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); |
|
248 void HandleSettingsChangeL(); |
|
249 void SetSortModeL(TInt aSortMode); |
|
250 void SetOrderModeL(TInt aOrderMode); |
|
251 void RefreshViewL(); |
|
252 TBool IsCurrentDriveReadOnly(); |
|
253 TBool IsCurrentItemDirectory(); |
|
254 void MoveUpOneLevelL(); |
|
255 void MoveDownToDirectoryL(); |
|
256 void ClipboardCutL(); |
|
257 void ClipboardCopyL(); |
|
258 void ClipboardPasteL(); |
|
259 void CopyToFolderL(TBool aMove=EFalse); |
|
260 void DeleteL(); |
|
261 void TouchL(); |
|
262 void RenameL(); |
|
263 void SetAttributesL(); |
|
264 void SearchL(); |
|
265 void NewFileL(); |
|
266 void NewDirectoryL(); |
|
267 void SendToL(); |
|
268 void CompressL(); |
|
269 void DecompressL(); |
|
270 void PropertiesL(); |
|
271 void OpenWithApparcL(); |
|
272 void OpenWithDocHandlerL(TBool aEmbed); |
|
273 void OpenWithFileServiceL(); |
|
274 TBool FileExists(const TDesC& aPath); |
|
275 TInt LaunchProgramL(const TDesC& aPath); |
|
276 void MemoryInfoPopupL(); |
|
277 void ShowFileCheckSumsL(TInt aType); |
|
278 void SetErrRdL(TBool aEnable); |
|
279 void EnableAvkonIconCacheL(TBool aEnable); |
|
280 void SimulateLeaveL(); |
|
281 void SimulatePanicL(); |
|
282 void SimulateExceptionL(); |
|
283 void SetDebugMaskL(); |
|
284 void WriteAllAppsL(); |
|
285 void WriteAllFilesL(); |
|
286 void ListOpenFilesL(); |
|
287 void ListMessageAttachmentsL(TInt aType); |
|
288 void WriteMsgStoreWalkL(); |
|
289 void FileEditorL(TInt aType); |
|
290 void SetDrivePasswordL(); |
|
291 void UnlockDriveL(); |
|
292 void ClearDrivePasswordL(); |
|
293 void EraseDrivePasswordL(); |
|
294 void FormatDriveL(TBool aQuickFormat); |
|
295 void CheckDiskL(); |
|
296 void ScanDriveL(); |
|
297 void SetDriveNameL(); |
|
298 void SetDriveVolumeLabelL(); |
|
299 void EjectDriveL(); |
|
300 void DismountFileSystemL(); |
|
301 void EraseMBRL(); |
|
302 void PartitionDriveL(); |
|
303 TBool DriveSnapShotPossible(); |
|
304 void DriveSnapShotL(); |
|
305 void EditDataTypesL(); |
|
306 void SecureBackupL(TInt aType); |
|
307 |
|
308 public: |
|
309 inline TInt SortMode() { return iSortMode; } |
|
310 inline TInt OrderMode() { return iOrderMode; } |
|
311 inline CFileEntryList* ClipBoardList() { return iClipBoardList; } |
|
312 inline TBool IsDriveListViewActive() { return iCurrentPath==KNullDesC && iListingMode==ENormalEntries; } |
|
313 inline TBool IsNormalModeActive() { return iListingMode==ENormalEntries; } |
|
314 |
|
315 private: |
|
316 TState iState; |
|
317 CFileBrowserModel* iModel; |
|
318 CFileBrowserFileOps* iFileOps; |
|
319 CAknWaitDialog* iWaitDialog; |
|
320 CAknProgressDialog* iProgressDialog; |
|
321 CEikProgressInfo* iProgressInfo; |
|
322 CCommandArray* iCommandArray; |
|
323 TInt iCurrentEntry; |
|
324 TInt iSucceededOperations; |
|
325 TInt iFailedOperations; |
|
326 TInt iLastError; |
|
327 RTimer iTimer; |
|
328 RFs iFs; |
|
329 TListingMode iListingMode; |
|
330 CFileMan* iFileMan; |
|
331 TInt iViewMode; |
|
332 TFileName iCurrentPath; |
|
333 TInt iSortMode; |
|
334 TInt iOrderMode; |
|
335 TInt iClipboardMode; |
|
336 CDesCArray* iClipboardPaths; |
|
337 CDriveEntryList* iDriveEntryList; |
|
338 CFileEntryList* iFileEntryList; |
|
339 CFileEntryList* iFindFileEntryList; |
|
340 CAppIconList* iAppIconList; |
|
341 TClipBoardMode iClipBoardMode; |
|
342 CFileEntryList* iClipBoardList; |
|
343 TSearchAttributes iSearchAttributes; |
|
344 CDocumentHandler* iDocHandler; |
|
345 CAknOpenFileService* iOpenFileService; |
|
346 RFile iMsgStoreWalkFile; |
|
347 TInt iPrevFolderIndex; |
|
348 TFileName iPrevFolderName; |
|
349 RTz iTz; |
|
350 }; |
|
351 |
|
352 |
|
353 // utility class for waiting for asychronous requests |
|
354 class CAsyncWaiter : public CActive |
|
355 { |
|
356 public: |
|
357 static CAsyncWaiter* NewL( TInt aPriority = EPriorityStandard ); |
|
358 static CAsyncWaiter* NewLC( TInt aPriority = EPriorityStandard ); |
|
359 ~CAsyncWaiter(); |
|
360 |
|
361 void StartAndWait(); |
|
362 TInt Result() const; |
|
363 |
|
364 private: |
|
365 CAsyncWaiter( TInt aPriority ); |
|
366 |
|
367 // from CActive |
|
368 void RunL(); |
|
369 void DoCancel(); |
|
370 |
|
371 private: |
|
372 CActiveSchedulerWait iWait; |
|
373 TInt iError; |
|
374 }; |
|
375 |
|
376 |
|
377 #endif |
|
378 |
|
379 // End of File |
|
380 |
|