|
1 /* |
|
2 * Copyright (c) 2010 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 #ifndef FILEBROWSER_FILEUTILS_H |
|
19 #define FILEBROWSER_FILEUTILS_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 #include <f32file.h> |
|
24 #include <w32std.h> |
|
25 #include <badesca.h> |
|
26 #include <coedef.h> |
|
27 #include <msvapi.h> |
|
28 #include <tz.h> |
|
29 #include "FB.hrh" |
|
30 |
|
31 _LIT(KIRAppPath, "z:\\sys\\bin\\irapp.exe"); |
|
32 _LIT(KBTAppPath, "z:\\sys\\bin\\btui.exe"); |
|
33 _LIT(KUSBAppPath, "z:\\sys\\bin\\usbclasschangeui.exe"); |
|
34 _LIT(KErrRdPath, "c:\\resource\\ErrRd"); |
|
35 _LIT(KErrRdDir, "c:\\resource\\"); |
|
36 |
|
37 |
|
38 // FORWARD DECLARATIONS |
|
39 class CEngine; |
|
40 class CFileBrowserFileOps; |
|
41 class CDocumentHandler; |
|
42 class CEikProgressInfo; |
|
43 class CFBFileOpClient; |
|
44 class CEikProgressInfo; |
|
45 class CMessageDigest; |
|
46 |
|
47 // CLASS DECLARATIONS |
|
48 |
|
49 class TSearchAttributes |
|
50 { |
|
51 public: |
|
52 TFileName iSearchDir; |
|
53 TFileName iWildCards; |
|
54 TFileName iTextInFile; |
|
55 TUint iMinSize; |
|
56 TUint iMaxSize; |
|
57 TTime iMinDate; |
|
58 TTime iMaxDate; |
|
59 TBool iRecurse; |
|
60 TBool iDefaultWildCard; |
|
61 }; |
|
62 |
|
63 class TDriveEntry |
|
64 { |
|
65 public: |
|
66 TChar iLetter; |
|
67 TInt iNumber; |
|
68 TVolumeInfo iVolumeInfo; |
|
69 TBuf<64> iMediaTypeDesc; |
|
70 TBuf<128> iAttributesDesc; |
|
71 TInt iIconId; |
|
72 }; |
|
73 |
|
74 class TFileEntry |
|
75 { |
|
76 public: |
|
77 TFileName iFullName; |
|
78 TFileName iPath; |
|
79 TEntry iEntry; |
|
80 TInt iDirEntries; |
|
81 TInt iIconId; |
|
82 }; |
|
83 |
|
84 class TAppIcon |
|
85 { |
|
86 public: |
|
87 TInt iId; |
|
88 TUid iUid; |
|
89 }; |
|
90 |
|
91 typedef CArrayFixSeg<TDriveEntry> CDriveEntryList; |
|
92 typedef CArrayFixSeg<TFileEntry> CFileEntryList; |
|
93 typedef CArrayFixSeg<TAppIcon> CAppIconList; |
|
94 |
|
95 class TSearchResults |
|
96 { |
|
97 public: |
|
98 TInt iNumberOfFoundFiles; |
|
99 //CFileEntryList iFoundFilesList; |
|
100 }; |
|
101 |
|
102 class TOverwriteOptions |
|
103 { |
|
104 public: |
|
105 TBool iDoFileOperations/*(ETrue)*/; |
|
106 TInt iQueryIndex/*(0)*/; |
|
107 TFileName iPostFix; |
|
108 TInt iOverWriteFlags/* = CFileMan::EOverWrite*/; |
|
109 }; |
|
110 |
|
111 class CCommandParamsBase : public CBase |
|
112 { |
|
113 }; |
|
114 |
|
115 class CCommandParamsAttribs : public CCommandParamsBase |
|
116 { |
|
117 public: |
|
118 TFileEntry iSourceEntry; |
|
119 TUint iSetMask; |
|
120 TUint iClearMask; |
|
121 TTime iTime; |
|
122 TUint iSwitch; |
|
123 public: |
|
124 CCommandParamsAttribs(const TFileEntry& aSourceEntry, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) : iSourceEntry(aSourceEntry), iSetMask(aSetMask), iClearMask(aClearMask), iTime(aTime), iSwitch(aSwitch) {} |
|
125 }; |
|
126 |
|
127 class CCommandParamsCopyOrMove : public CCommandParamsBase |
|
128 { |
|
129 public: |
|
130 TFileEntry iSourceEntry; |
|
131 TFileName iTargetPath; |
|
132 TUint iSwitch; |
|
133 public: |
|
134 CCommandParamsCopyOrMove(const TFileEntry& aSourceEntry, const TDesC& aTargetPath, TUint aSwitch) : iSourceEntry(aSourceEntry), iTargetPath(aTargetPath), iSwitch(aSwitch) {} |
|
135 }; |
|
136 |
|
137 class CCommandParamsRename : public CCommandParamsBase |
|
138 { |
|
139 public: |
|
140 TFileEntry iSourceEntry; |
|
141 TFileName iTargetPath; |
|
142 TUint iSwitch; |
|
143 public: |
|
144 CCommandParamsRename(const TFileEntry& aSourceEntry, const TDesC& aTargetPath, TUint aSwitch) : iSourceEntry(aSourceEntry), iTargetPath(aTargetPath), iSwitch(aSwitch) {} |
|
145 }; |
|
146 |
|
147 class CCommandParamsDelete : public CCommandParamsBase |
|
148 { |
|
149 public: |
|
150 TFileEntry iSourceEntry; |
|
151 TUint iSwitch; |
|
152 public: |
|
153 CCommandParamsDelete(const TFileEntry& aSourceEntry, TUint aSwitch) : iSourceEntry(aSourceEntry), iSwitch(aSwitch) {} |
|
154 }; |
|
155 |
|
156 class CCommandParamsDriveSnapShot : public CCommandParamsBase |
|
157 { |
|
158 public: |
|
159 TInt iSourceDriveLetter; |
|
160 TInt iTargetDriveLetter; |
|
161 public: |
|
162 CCommandParamsDriveSnapShot(TChar aSourceDriveLetter, TChar aTargetDriveLetter) : iSourceDriveLetter(aSourceDriveLetter), iTargetDriveLetter(aTargetDriveLetter) {} |
|
163 }; |
|
164 |
|
165 class TCommand |
|
166 { |
|
167 public: |
|
168 TInt iCommandId; |
|
169 CCommandParamsBase* iParameters; |
|
170 public: |
|
171 TCommand(TInt aCommandId, CCommandParamsBase* aParameters) : iCommandId(aCommandId), iParameters(aParameters) {} |
|
172 }; |
|
173 |
|
174 typedef CArrayFixSeg<TCommand> CCommandArray; |
|
175 |
|
176 |
|
177 |
|
178 class CFileBrowserFileUtils : public CActive, public MMsvSessionObserver |
|
179 { |
|
180 private: |
|
181 enum TState // active object states |
|
182 { |
|
183 EIdle = 0, // do nothing |
|
184 }; |
|
185 |
|
186 // enum TClipBoardMode |
|
187 // { |
|
188 // EClipBoardModeCut = 0, |
|
189 // EClipBoardModeCopy |
|
190 // }; |
|
191 |
|
192 public: |
|
193 static CFileBrowserFileUtils* NewL(CEngine* aEngine); |
|
194 ~CFileBrowserFileUtils(); |
|
195 |
|
196 private: |
|
197 CFileBrowserFileUtils(CEngine* aEngine); |
|
198 void ConstructL(); |
|
199 |
|
200 private: // from CActive |
|
201 void RunL(); |
|
202 TInt RunError(TInt aError); |
|
203 void DoCancel(); |
|
204 |
|
205 private: // from MMsvSessionObserver |
|
206 void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); |
|
207 |
|
208 public: //from MProgressDialogCallback |
|
209 void DialogDismissedL(/*TInt aButtonId*/); |
|
210 |
|
211 public: // command handling |
|
212 void StartExecutingCommandsL(const TDesC& aLabel); |
|
213 private: // command handling |
|
214 void ExecuteCommand(); |
|
215 void CheckForMoreCommandsL(); |
|
216 void AppendToCommandArrayL(TInt aCommand, CCommandParamsBase* aParameters); |
|
217 TInt CommandArrayCount() const; |
|
218 void ResetCommandArray(); |
|
219 |
|
220 private: // misc functionality |
|
221 void GenerateDirectoryDataL(); |
|
222 void GetDriveListL(); |
|
223 void GetDirectoryListingL(); |
|
224 // CAknIconArray* GenerateIconArrayL(TBool aGenerateNewBasicIconArray=EFalse); |
|
225 // void AppendGulIconToIconArrayL(CAknIconArray* aIconArray, const TDesC& aIconFile, TInt aIconId, TInt aMaskId, const TAknsItemID aAknsItemId); |
|
226 TInt AppIconIdForUid(TUid aUid); |
|
227 TUid GetAppUid(const TFileEntry &aFileEntry); |
|
228 // CDesCArray* GenerateItemTextArrayL(); |
|
229 // TInt GetSelectedItemsOrCurrentItemL(CFileEntryList* aFileEntryList); |
|
230 TInt SetSelectedItemsOrCurrentItemL(const CArrayFix<TInt>* selectionIndexes, |
|
231 CFileEntryList* aFileEntryList); |
|
232 |
|
233 // TBool IsDestinationEntriesExists(const CFileEntryList* aEntryList, const TDesC& aTargetDir); |
|
234 void DoCopyToFolderL(CFileEntryList* aEntryList, const TDesC& aTargetDir, const TOverwriteOptions &aOverwriteOptions, 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(const TDesC& aWord, TDes8& aConverted) const; |
|
243 HBufC8* MessageDigestInHexLC(CMessageDigest* aMD, RFile& aFile); |
|
244 void OpenCommonFileActionQueryL(TInt aCurrentItemIndex); |
|
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 IsItemDirectory(TInt aCurrentItemIndex); |
|
254 void MoveUpOneLevelL(); |
|
255 void MoveDownToDirectoryL(TInt aIndex); |
|
256 TInt ClipboardCutL(const CArrayFix<TInt>* aSelectionIndices); |
|
257 TInt ClipboardCopyL(const CArrayFix<TInt>* aSelectionIndices); |
|
258 void ClipboardPasteL(const TOverwriteOptions &aOverwriteOptions); |
|
259 TInt SetCurrentSelection(const CArrayFix<TInt>* aSelectionIndices); |
|
260 void CopyToFolderL(const TFileName &, const TOverwriteOptions &, TBool aMove=EFalse); |
|
261 void DeleteL(); |
|
262 TBool SelectionHasDirs(); |
|
263 void TouchL(TBool aRecurse); |
|
264 void RenameL(const TInt aIndex, const TFileName &newName); |
|
265 void SetAttributesL(TUint &aSetAttMask, TUint &aClearAttMask, TBool &aRecurse); |
|
266 void SearchL(); |
|
267 void NewFileL(const TFileName &aNewFileName); |
|
268 void NewDirectoryL(const TFileName &aNewDirectoryName); |
|
269 void SendToL(); |
|
270 void CompressL(); |
|
271 void DecompressL(); |
|
272 TInt GetFilesCount(const TFileName &aDriveRoot); |
|
273 TInt GetFilesCountAndSize(const TFileName &aFullPath, TInt64 &aSize); |
|
274 TInt GetEntriesCount(const TFileName &aFullPath); |
|
275 TFileName GetMimeType(const TFileName &aFullPath); |
|
276 TFileName GetOpenWith(const TFileName &aFullPath); |
|
277 void OpenWithApparcL(const TFileName &); |
|
278 void OpenWithDocHandlerL(const TFileName &, TBool); |
|
279 void OpenWithFileServiceL(TInt aCurrentItemIndex); |
|
280 TBool FileExists(const TDesC& aPath); |
|
281 TInt LaunchProgramL(const TDesC& aPath); |
|
282 void MemoryInfoPopupL(); |
|
283 void ShowFileCheckSumsL(TInt aCurrentItemIndex, TInt aType); |
|
284 void SetErrRdL(TBool aEnable); |
|
285 // void EnableAvkonIconCacheL(TBool aEnable); |
|
286 void SimulateLeaveL(TInt aLeaveCode); |
|
287 void SimulatePanicL(const TDesC& aPanicCategory, TInt aPanicCode); |
|
288 void SimulateExceptionL(TInt aExceptionCode); |
|
289 TUint32 GetDebugMask(); |
|
290 void SetDebugMaskL(TUint32 aDbgMask); |
|
291 void WriteAllAppsL(); |
|
292 void WriteAllFilesL(); |
|
293 void ListOpenFilesL(); |
|
294 void ListMessageAttachmentsL(TInt aType); |
|
295 void WriteMsgStoreWalkL(); |
|
296 void FileEditorL(TInt aCurrentItemIndex, TInt aType); |
|
297 void SetDrivePasswordL(TInt aIndex, const TFileName &aOldPassword, const TFileName &aNewPassword); |
|
298 void UnlockDriveL(TInt aIndex, const TFileName &aOldPassword); |
|
299 void ClearDrivePasswordL(TInt aIndex, const TFileName &aOldPassword); |
|
300 void EraseDrivePasswordL(TInt aIndex); |
|
301 void FormatDriveL(TInt aIndex, TBool aQuickFormat); |
|
302 void CheckDiskL(TInt aIndex); |
|
303 void ScanDriveL(TInt aIndex); |
|
304 void SetDriveNameL(TInt aIndex, const TFileName &aDriveName); |
|
305 void SetDriveVolumeLabelL(TInt aIndex, const TFileName &aVolumeLabel); |
|
306 void EjectDriveL(TInt aIndex); |
|
307 void DismountFileSystemL(TInt aIndex); |
|
308 void EraseMBRL(TInt aIndex); |
|
309 void PartitionDriveL(TInt aIndex, TBool aEraseMBR, TInt aAmountOfPartitions); |
|
310 TBool DriveSnapShotPossible(); |
|
311 void DriveSnapShotL(); |
|
312 void EditDataTypesL(); |
|
313 void SecureBackupL(TInt aType); |
|
314 |
|
315 TBool IsDestinationEntriesExists(const TDesC& aTargetDir); |
|
316 TBool TargetExists(const TInt aIndex, const TFileName &newName); |
|
317 void GetDriveName(TInt aIndex, TFileName &aDriveName); |
|
318 void GetDriveVolumeLabel(TInt aIndex, TFileName &aVolumeLabel); |
|
319 |
|
320 CFileEntryList* FileEntries() const; |
|
321 CDriveEntryList* DriveEntries() const; |
|
322 |
|
323 TFileName ResolveErrorMessage(TInt aErrCode); |
|
324 |
|
325 public: |
|
326 inline TInt SortMode() { return iSortMode; } |
|
327 inline TInt OrderMode() { return iOrderMode; } |
|
328 inline CFileEntryList* ClipBoardList() { return iClipBoardList; } |
|
329 inline CFileEntryList* CurrentSelectionList() { return iCurrentSelectionList; } |
|
330 inline TBool IsDriveListViewActive() { return iCurrentPath==KNullDesC && iListingMode==ENormalEntries; } |
|
331 inline TBool IsNormalModeActive() { return iListingMode==ENormalEntries; } |
|
332 inline TListingMode ListingMode() { return iListingMode; } |
|
333 inline TFileName CurrentPath() { return iCurrentPath; } |
|
334 |
|
335 inline TSearchAttributes GetSearchAttributes(){ return iSearchAttributes; }; |
|
336 inline void ChangeAttributes(const TSearchAttributes &attributes) { iSearchAttributes = attributes; }; |
|
337 inline TSearchResults SearchResults(){ return iFileSearchResults; }; |
|
338 inline CFileEntryList* FoundFiles() { return iFileEntryList; }; |
|
339 inline void SetAllowProcessing(TBool aAllowProcessing) { iAllowProcessing = aAllowProcessing; } |
|
340 TClipBoardMode GetClipBoardMode() { return iClipBoardMode; } |
|
341 |
|
342 private: |
|
343 TState iState; |
|
344 CEngine* iEngine; |
|
345 CFileBrowserFileOps* iFileOps; |
|
346 |
|
347 TBool isWaitDialog; |
|
348 TBool isProgressDialog; |
|
349 |
|
350 //CEikProgressInfo* iProgressInfo; |
|
351 CCommandArray* iCommandArray; |
|
352 TInt iCurrentEntry; |
|
353 TInt iSucceededOperations; |
|
354 TInt iFailedOperations; |
|
355 TInt iLastError; |
|
356 RTimer iTimer; |
|
357 RFs iFs; |
|
358 TListingMode iListingMode; |
|
359 CFileMan* iFileMan; |
|
360 TInt iViewMode; |
|
361 TFileName iCurrentPath; |
|
362 TInt iSortMode; |
|
363 TInt iOrderMode; |
|
364 // TInt iClipboardMode; |
|
365 CDesCArray* iClipboardPaths; |
|
366 CDriveEntryList* iDriveEntryList; |
|
367 CFileEntryList* iFileEntryList; |
|
368 CFileEntryList* iFindFileEntryList; |
|
369 CAppIconList* iAppIconList; |
|
370 TClipBoardMode iClipBoardMode; |
|
371 CFileEntryList* iClipBoardList; |
|
372 CFileEntryList* iCurrentSelectionList; |
|
373 TSearchAttributes iSearchAttributes; |
|
374 CDocumentHandler* iDocHandler; |
|
375 |
|
376 RFile iMsgStoreWalkFile; |
|
377 TInt iPrevFolderIndex; |
|
378 TFileName iPrevFolderName; |
|
379 RTz iTz; |
|
380 TSearchResults iFileSearchResults; |
|
381 CDesCArray* iTextArray; |
|
382 TBool iAllowProcessing; |
|
383 }; |
|
384 |
|
385 |
|
386 // utility class for waiting for asychronous requests |
|
387 class CAsyncWaiter : public CActive |
|
388 { |
|
389 public: |
|
390 static CAsyncWaiter* NewL( TInt aPriority = EPriorityStandard ); |
|
391 static CAsyncWaiter* NewLC( TInt aPriority = EPriorityStandard ); |
|
392 ~CAsyncWaiter(); |
|
393 |
|
394 void StartAndWait(); |
|
395 TInt Result() const; |
|
396 |
|
397 private: |
|
398 CAsyncWaiter( TInt aPriority ); |
|
399 |
|
400 // from CActive |
|
401 void RunL(); |
|
402 void DoCancel(); |
|
403 |
|
404 private: |
|
405 CActiveSchedulerWait iWait; |
|
406 TInt iError; |
|
407 }; |
|
408 |
|
409 |
|
410 #endif |
|
411 |
|
412 // End of File |
|
413 |