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