39
|
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: Util methods for File Manager
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef CFILEMANAGERUTILS_H
|
|
21 |
#define CFILEMANAGERUTILS_H
|
|
22 |
|
|
23 |
|
|
24 |
// INCLUDES
|
|
25 |
#include <e32base.h>
|
|
26 |
#include <badesca.h>
|
|
27 |
#include <f32file.h>
|
|
28 |
|
|
29 |
|
|
30 |
// FORWARD DECLARATIONS
|
|
31 |
class CFileManagerMimeIconArray;
|
|
32 |
class CFileManagerFolderArray;
|
|
33 |
class CCommonContentPolicy;
|
|
34 |
class CGflmNavigatorModel;
|
|
35 |
class CGflmGroupItem;
|
|
36 |
#if defined( __KEEP_DRM_CONTENT_ON_PHONE ) && defined ( FILE_MANAGER_USE_DISTRIBUTABLECHECKER )
|
|
37 |
class CDistributableChecker;
|
|
38 |
#endif // __KEEP_DRM_CONTENT_ON_PHONE && FILE_MANAGER_USE_DISTRIBUTABLECHECKER
|
|
39 |
class CFileManagerFeatureManager;
|
|
40 |
|
|
41 |
|
|
42 |
/**
|
|
43 |
*
|
|
44 |
* Collection of utility functions for file manager
|
|
45 |
*
|
|
46 |
* @lib FileManagerEngine.lib
|
|
47 |
* @since 2.7
|
|
48 |
*/
|
|
49 |
NONSHARABLE_CLASS(CFileManagerUtils) : public CBase
|
|
50 |
{
|
|
51 |
public:
|
|
52 |
/**
|
|
53 |
* Two-phased constructors.
|
|
54 |
*/
|
|
55 |
static CFileManagerUtils* NewL(
|
|
56 |
RFs& aFs,
|
|
57 |
CGflmNavigatorModel& aNavigator,
|
|
58 |
CFileManagerFeatureManager& aFeatureManager );
|
|
59 |
|
|
60 |
/**
|
|
61 |
* Destructor.
|
|
62 |
*/
|
|
63 |
~CFileManagerUtils();
|
|
64 |
public: // New functions
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Gets the reference to open file server session
|
|
68 |
* @since 2.7
|
|
69 |
* @return reference to open file server session
|
|
70 |
*/
|
|
71 |
RFs& Fs() const;
|
|
72 |
|
|
73 |
/**
|
|
74 |
* Checks is given file forward locked
|
|
75 |
* @since 2.7
|
|
76 |
* @param aFullPath file name with full path
|
|
77 |
* @return ETrue if file is forward locked, EFalse if not.
|
|
78 |
*/
|
|
79 |
TBool IsForwardLockedFile( const TDesC& aFullPath );
|
|
80 |
|
|
81 |
/**
|
|
82 |
* Checks is given file drm protected
|
|
83 |
* @since 2.7
|
|
84 |
* @param aFullPath file name with full path
|
|
85 |
* @return ETrue if file is drm protected, EFalse if not.
|
|
86 |
*/
|
|
87 |
TBool IsDrmProtectedFileL( const TDesC& aFullPath ) const;
|
|
88 |
|
|
89 |
/**
|
|
90 |
* Gets the icon id of the item
|
|
91 |
* @since 2.7
|
|
92 |
* @param aFullPath Item with full path information
|
|
93 |
* @return Icon id of the item. If not found other icon id is used.
|
|
94 |
*/
|
|
95 |
TInt ResolveIconL( const TDesC& aFullPath ) const;
|
|
96 |
|
|
97 |
/**
|
|
98 |
* Checks is given folder a default folder
|
|
99 |
* @since 2.7
|
|
100 |
* @param aFullPath Item with full path information
|
|
101 |
* @return ETrue if folder is default folder, EFalse if not.
|
|
102 |
*/
|
|
103 |
TBool DefaultFolder( const TDesC& aFullPath ) const;
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Checks is given file drm local data file (LDF)
|
|
107 |
* @since 3.1
|
|
108 |
* @param aFullPath file name with full path
|
|
109 |
* @return ETrue if file is local data file, EFalse if not.
|
|
110 |
*/
|
|
111 |
TBool IsDrmLocalDataFile( const TDesC& aFullPath ) const;
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Checks given item that can it be deleted.
|
|
115 |
* @since 3.1
|
|
116 |
* @param aFullPath full path to item which is checked
|
|
117 |
* @returns ETrue if item can be deleted, EFalse if not
|
|
118 |
*/
|
|
119 |
TBool CanDelete( const TDesC& aFullPath ) const;
|
|
120 |
|
|
121 |
/**
|
|
122 |
* Returns the type of given item in CFileManagerItemProperties bitmask
|
|
123 |
* @since 3.1
|
|
124 |
* @param aFullPath full path to item
|
|
125 |
* @return CFileManagerItemProperties bitmask
|
|
126 |
*/
|
|
127 |
TUint32 FileTypeL( const TDesC& aFullPath );
|
|
128 |
|
|
129 |
/**
|
|
130 |
* Gets the icon id of the item
|
|
131 |
* @since 3.1
|
|
132 |
* @param aItem GFLM struct of the item
|
|
133 |
* @return Icon id of the item. If not found other icon id is returned.
|
|
134 |
*/
|
|
135 |
TInt ResolveIconL( CGflmGroupItem& aItem ) const;
|
|
136 |
|
|
137 |
/**
|
|
138 |
* Checks does given folder have any items with specified attributes
|
|
139 |
* @since 3.1
|
|
140 |
* @param aFs open file server session
|
|
141 |
* @param aFullPath folder name with full path
|
|
142 |
* @param aAttMask attribute mask
|
|
143 |
* @return ETrue if folder has any specified items, EFalse if not.
|
|
144 |
*/
|
|
145 |
static TBool HasAny(
|
|
146 |
RFs& aFs, const TDesC& aFullPath, TUint aAttMask );
|
|
147 |
|
|
148 |
/**
|
|
149 |
* Checks does given folder has any subfolder
|
|
150 |
* @since 3.1
|
|
151 |
* @param aFullPath folder name with full path
|
|
152 |
* @return ETrue if folder has any subfolders, EFalse if not.
|
|
153 |
*/
|
|
154 |
TBool HasSubFolders( const TDesC& aFullPath ) const;
|
|
155 |
|
|
156 |
/**
|
|
157 |
* Checks does given folder has any files
|
|
158 |
* @since 3.1
|
|
159 |
* @param aFullPath folder name with full path
|
|
160 |
* @return ETrue if folder has any files, EFalse if not.
|
|
161 |
*/
|
|
162 |
TBool HasFiles( const TDesC& aFullPath ) const;
|
|
163 |
|
|
164 |
/**
|
|
165 |
* Create default folders
|
|
166 |
* @since 3.2
|
|
167 |
* @param aDrive Drive which default folders are created
|
|
168 |
* @param aForced Selects forced or normal creation
|
|
169 |
*/
|
|
170 |
void CreateDefaultFolders(
|
|
171 |
const TInt aDrive, const TBool aForced = ETrue ) const;
|
|
172 |
|
|
173 |
/**
|
|
174 |
* Checks is path located in remote drive
|
|
175 |
* @since 3.1
|
|
176 |
* @param aPath path to check
|
|
177 |
* @return ETrue if remote drive. Otherwise EFalse.
|
|
178 |
*/
|
|
179 |
TBool IsRemoteDrive( const TDesC& aPath ) const;
|
|
180 |
|
|
181 |
/**
|
|
182 |
* Determine if given file must be protected (kept on the device)
|
|
183 |
* @since 3.1
|
|
184 |
* @param aFullPath file to check
|
|
185 |
* @param aIsProtected for storing result
|
|
186 |
* @return System wide error code
|
|
187 |
*/
|
|
188 |
TInt IsDistributableFile( const TDesC& aFullPath,
|
|
189 |
TBool& aIsProtected );
|
|
190 |
|
|
191 |
/**
|
|
192 |
* Gets MIME type of file
|
|
193 |
* @since 3.1
|
|
194 |
* @return MIME type
|
|
195 |
*/
|
|
196 |
TPtrC MimeTypeL( const TDesC& aFullPath ) const;
|
|
197 |
|
|
198 |
/**
|
|
199 |
* Gets drive id array with specified attribute mask
|
|
200 |
* @since 3.2
|
|
201 |
* @param aDrives array for ids
|
|
202 |
* @param aAttMask drive attribute match mask
|
|
203 |
*/
|
|
204 |
void DriveList(
|
|
205 |
RArray< TInt >& aDrives, const TInt aAttMask ) const;
|
|
206 |
|
|
207 |
/**
|
|
208 |
* Checks is drive removable
|
|
209 |
* @since 3.2
|
|
210 |
* @param aPath path to check
|
|
211 |
* @return ETrue if removable drive. Otherwise EFalse
|
|
212 |
*/
|
|
213 |
TBool IsRemovableDrive( const TDesC& aPath ) const;
|
|
214 |
|
|
215 |
/**
|
|
216 |
* Gets item full path
|
|
217 |
* @since 3.2
|
|
218 |
* @param aDir Parent directory path
|
|
219 |
* @param aEntry File system entry
|
|
220 |
* @param aFullPath Full path to item
|
|
221 |
*/
|
|
222 |
static void GetFullPath(
|
|
223 |
const TDesC& aDir, const TEntry& aEntry, TDes& aFullPath );
|
|
224 |
|
|
225 |
/**
|
|
226 |
* Removes final backslash if exists
|
|
227 |
* @since 3.2
|
|
228 |
* @param aPath Directory path
|
|
229 |
* @return Pointer without backslash
|
|
230 |
*/
|
|
231 |
IMPORT_C static TPtrC StripFinalBackslash( const TDesC& aPath );
|
|
232 |
|
|
233 |
/**
|
|
234 |
* Ensures final backslash exists
|
|
235 |
* @since 3.2
|
|
236 |
* @param aPath Directory path
|
|
237 |
*/
|
|
238 |
IMPORT_C static void EnsureFinalBackslash( TDes& aPath );
|
|
239 |
|
|
240 |
/**
|
|
241 |
* Removes all directional chars if exist
|
|
242 |
* @since 3.2
|
|
243 |
* @param aText The text
|
|
244 |
* @return Pointer to cleaned up text, ownership is transferred
|
|
245 |
*/
|
|
246 |
static HBufC* StripDirectionalCharsLC( const TDesC& aText );
|
|
247 |
|
|
248 |
/**
|
|
249 |
* Checks if final backslash exist
|
|
250 |
* @since 3.2
|
|
251 |
* @param aPath Directory path
|
|
252 |
*/
|
|
253 |
IMPORT_C static TBool HasFinalBackslash( const TDesC& aPath );
|
|
254 |
|
|
255 |
/**
|
|
256 |
* Checks if file is copied/moved from internal to removable drive
|
|
257 |
* @since 3.2
|
|
258 |
* @param aFs Open file server session
|
|
259 |
* @param aSrcPath Source directory path
|
|
260 |
* @param aDstPath Destination directory path
|
|
261 |
* @return ETrue if from internal to removable, otherwise EFalse
|
|
262 |
*/
|
|
263 |
IMPORT_C static TBool IsFromInternalToRemovableDrive(
|
|
264 |
RFs& aFs, const TDesC& aSrcPath, const TDesC& aDstPath );
|
|
265 |
|
|
266 |
/**
|
|
267 |
* Removes read only attribute if it is set for given item
|
|
268 |
* @since 3.2
|
|
269 |
* @param aFs Open file server session
|
|
270 |
* @param aFullPath Full path of the item
|
|
271 |
* @param aEntry Entry data of the item
|
|
272 |
* @return System wide error code
|
|
273 |
*/
|
|
274 |
static TInt RemoveReadOnlyAttribute(
|
|
275 |
RFs& aFs, const TDesC& aFullPath, const TEntry& aEntry );
|
|
276 |
|
|
277 |
/**
|
|
278 |
* Removes read only attribute if it is set for given item
|
|
279 |
* @since 3.2
|
|
280 |
* @param aFs Open file server session
|
|
281 |
* @param aFullPath Full path of the item
|
|
282 |
* @return System wide error code
|
|
283 |
*/
|
|
284 |
static TInt RemoveReadOnlyAttribute(
|
|
285 |
RFs& aFs, const TDesC& aFullPath );
|
|
286 |
|
|
287 |
/* Drive name layouts for selecting the most suitable text */
|
|
288 |
enum TDriveNameLayout
|
|
289 |
{
|
|
290 |
EMainLayout = 0,
|
|
291 |
ETitleLayout,
|
|
292 |
ELayoutCount // Must be the last
|
|
293 |
};
|
|
294 |
|
|
295 |
/**
|
|
296 |
* Gets drive name and letter as combined single text.
|
|
297 |
* @since 5.0
|
|
298 |
* @param aDrive Drive number EDriveA...EDriveZ
|
|
299 |
* @param aLayout Text layout. See TDriveNameLayout.
|
|
300 |
* @return Text containing drive letter and name
|
|
301 |
*/
|
|
302 |
HBufC* GetDriveNameL(
|
|
303 |
const TInt aDrive,
|
|
304 |
const TDriveNameLayout aLayout ) const;
|
|
305 |
|
|
306 |
/**
|
|
307 |
* Gets drive name and letter as combined formatted text.
|
|
308 |
* @since 5.0
|
|
309 |
* @param aDrive Drive number EDriveA...EDriveZ
|
|
310 |
* @param aTextIdForDefaultName TextId of default name format string
|
|
311 |
* @param aTextIdForName TextId of name format string
|
|
312 |
* @return Text containing drive letter and name
|
|
313 |
*/
|
|
314 |
HBufC* GetFormattedDriveNameLC(
|
|
315 |
const TInt aDrive,
|
|
316 |
const TInt aTextIdForDefaultName,
|
|
317 |
const TInt aTextIdForName ) const;
|
|
318 |
|
|
319 |
/**
|
|
320 |
* Checks is path located in remote drive
|
|
321 |
* @since 3.2
|
|
322 |
* @param aFs Open file server session
|
|
323 |
* @param aPath path to check
|
|
324 |
* @return ETrue if remote drive, otherwise EFalse
|
|
325 |
*/
|
|
326 |
IMPORT_C static TBool IsRemoteDrive( RFs& aFs, const TDesC& aPath );
|
|
327 |
|
|
328 |
/**
|
|
329 |
* Returns localized name of the given item
|
|
330 |
* @since 3.2
|
|
331 |
* @param aFullPath full path to item which is checked
|
|
332 |
* @returns TPtrC reference to localized name,
|
|
333 |
* KNullDesC if no localization is used
|
|
334 |
*/
|
|
335 |
TPtrC LocalizedName( const TDesC& aFullPath ) const;
|
|
336 |
|
|
337 |
/**
|
|
338 |
* Checks is name found, the comparison includes localized folder names
|
|
339 |
* @since 3.2
|
|
340 |
* @param aFullPath full path to item which is checked
|
|
341 |
* @returns ETrue if name is found, otherwise EFalse.
|
|
342 |
*/
|
|
343 |
TBool IsNameFoundL( const TDesC& aFullPath ) const;
|
|
344 |
|
|
345 |
/**
|
|
346 |
* Flush Cache
|
|
347 |
*/
|
|
348 |
void FlushCache() const;
|
|
349 |
|
|
350 |
private:
|
|
351 |
/**
|
|
352 |
* C++ default constructor.
|
|
353 |
*/
|
|
354 |
CFileManagerUtils(
|
|
355 |
RFs& aFs,
|
|
356 |
CGflmNavigatorModel& aNavigator,
|
|
357 |
CFileManagerFeatureManager& aFeatureManager );
|
|
358 |
|
|
359 |
void ConstructL();
|
|
360 |
|
|
361 |
static void IsFlkOrLdfFileL(
|
|
362 |
const TDesC& aFullPath, TBool& aIsFlk, TBool& aIsLdf );
|
|
363 |
|
|
364 |
static TBool IsInternalDrive( RFs& aFs, const TInt aDrive );
|
|
365 |
|
|
366 |
CDesCArray* GetDriveNameArrayLC(
|
|
367 |
const TInt aDrive,
|
|
368 |
TUint& aDriveStatus ) const;
|
|
369 |
|
|
370 |
static TBool IsDrive(
|
|
371 |
RFs& aFs, const TDesC& aPath, const TUint aAttMask );
|
|
372 |
|
|
373 |
static TBool IsDrive(
|
|
374 |
RFs& aFs, const TInt aDrive, const TUint aAttMask );
|
|
375 |
|
|
376 |
private:
|
|
377 |
|
|
378 |
// Ref: reference to open file server session
|
|
379 |
RFs& iFs;
|
|
380 |
|
|
381 |
//Own: List of default folders
|
|
382 |
CFileManagerFolderArray* iDefaultFolders;
|
|
383 |
|
|
384 |
// Own: Handle to common content policy service to find
|
|
385 |
// out is file in a Closed Content List or forward locked
|
|
386 |
CCommonContentPolicy* iCommonContentPolicy;
|
|
387 |
|
|
388 |
// Own: Mime icon mapper
|
|
389 |
CFileManagerMimeIconArray* iMimeIconMapper;
|
|
390 |
|
|
391 |
// Ref: GFLM navigator instance
|
|
392 |
CGflmNavigatorModel& iNavigator;
|
|
393 |
|
|
394 |
#if defined( __KEEP_DRM_CONTENT_ON_PHONE ) && defined ( FILE_MANAGER_USE_DISTRIBUTABLECHECKER )
|
|
395 |
// Own: content protection checking
|
|
396 |
CDistributableChecker* iDistributableChecker;
|
|
397 |
#endif // __KEEP_DRM_CONTENT_ON_PHONE && FILE_MANAGER_USE_DISTRIBUTABLECHECKER
|
|
398 |
|
|
399 |
// Flag to indicate if feature is supported
|
|
400 |
TBool iDrmFullSupported;
|
|
401 |
|
|
402 |
// Ref: reference to feature manager
|
|
403 |
CFileManagerFeatureManager& iFeatureManager;
|
|
404 |
|
|
405 |
};
|
|
406 |
|
|
407 |
#endif // CFILEMANAGERUTILS_H
|
|
408 |
|
|
409 |
// End of File
|