21
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2008 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: Main class of the filemanagerengine
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include <StringLoader.h>
|
|
22 |
#include <barsread.h>
|
|
23 |
#include <sysutil.h>
|
|
24 |
#include <bautils.h>
|
|
25 |
//#include <cmgxfilemanager.h>
|
|
26 |
//#include <mgxfilemanagerfactory.h>
|
|
27 |
//#include <cmgalbummanager.h>
|
|
28 |
#include <pathinfo.h>
|
|
29 |
#include <AknServerApp.h>
|
|
30 |
#include <filemanagerengine.rsg>
|
|
31 |
#ifdef RD_MULTIPLE_DRIVE
|
|
32 |
#include <driveinfo.h>
|
|
33 |
#endif // RD_MULTIPLE_DRIVE
|
|
34 |
#include "CFileManagerEngine.h"
|
|
35 |
#include "CGflmNavigatorModel.h"
|
|
36 |
#include "CGflmGroupItem.h"
|
|
37 |
#include "CGflmFileSystemItem.h"
|
|
38 |
#include "CGflmDriveItem.h"
|
|
39 |
#include "CGflmGlobalActionItem.h"
|
|
40 |
#include "MGflmItemGroup.h"
|
|
41 |
#include "Cfilemanagerfolderarray.h"
|
|
42 |
#include "CFilemanagerMimeIconArray.h"
|
|
43 |
#include "CFileManagerActiveExecute.h"
|
|
44 |
#include "CFileManagerRefresher.h"
|
|
45 |
#include "Cfilemanagerfilesystemevent.h"
|
|
46 |
#include "Cfilemanageractivesize.h"
|
|
47 |
#include "Cfilemanageractivedelete.h"
|
|
48 |
#include "FileManagerEngine.hrh"
|
|
49 |
#include "CFileManagerCommonDefinitions.h"
|
|
50 |
#include "CFileManagerUtils.h"
|
|
51 |
#include "CFileManagerItemFilter.h"
|
|
52 |
#include "CFileManagerDocHandler.h"
|
|
53 |
#include "FileManagerDebug.h"
|
|
54 |
#include "CFileManagerItemProperties.h"
|
|
55 |
#include "CFileManagerRemovableDriveHandler.h"
|
|
56 |
#include "CFileManagerRemoteDriveHandler.h"
|
|
57 |
#include "CFileManagerBackupSettings.h"
|
|
58 |
#include "CFileManagerRestoreSettings.h"
|
|
59 |
#include "CFileManagerActiveRename.h"
|
|
60 |
#include "CFileManagerFeatureManager.h"
|
|
61 |
|
|
62 |
// CONSTANTS
|
|
63 |
const TUint16 KIllegalChars[] = {
|
|
64 |
'<', '>', '"', '/', '\\', '|', ':', '*', '?',
|
|
65 |
0xFF02, // Full width quote
|
|
66 |
0xFF0A, // Full width asterisk
|
|
67 |
0xFF0F, // Full width slash
|
|
68 |
0xFF1A, // Full width colon
|
|
69 |
0xFF1C, // Full width left arrow
|
|
70 |
0xFF1E, // Full width right arrow
|
|
71 |
0xFF1F, // Full width question mark
|
|
72 |
0xFF3C, // Full width back slash
|
|
73 |
0xFF5C, // Full width pipe
|
|
74 |
0x201C, // Left quote
|
|
75 |
0x201D, // Right quote
|
|
76 |
0x201F, // Reversed quote
|
|
77 |
0x21B2, // Downwards arrow with tip leftwards
|
|
78 |
0, // Array terminator
|
|
79 |
};
|
|
80 |
const TUint KDiskEventCheckInterval = 100000; // microseconds
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
// ============================ LOCAL FUNCTIONS ================================
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
// SearchMGAlbumIdL
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
/*static TInt SearchMGAlbumIdL(
|
|
90 |
CMGAlbumManager& aAlbumManager, const TDesC& aFilename )
|
|
91 |
{
|
|
92 |
CDesCArray* fileArray =
|
|
93 |
new ( ELeave ) CDesCArraySeg( KMGFileArrayGranularity );
|
|
94 |
CleanupStack::PushL( fileArray );
|
|
95 |
TInt albumCount( aAlbumManager.AlbumCount() );
|
|
96 |
TInt ret( KErrNotFound );
|
|
97 |
for( TInt i( 0 ); i < albumCount; ++i )
|
|
98 |
{
|
|
99 |
CMGAlbumInfo* albumInfo = aAlbumManager.AlbumInfoLC( i );
|
|
100 |
TInt albumId( albumInfo->Id() );
|
|
101 |
CleanupStack::PopAndDestroy( albumInfo );
|
|
102 |
fileArray->Reset();
|
|
103 |
aAlbumManager.GetAlbumFileArrayL( albumId, *fileArray );
|
|
104 |
TInt pos( 0 );
|
|
105 |
if( !fileArray->Find( aFilename, pos ) )
|
|
106 |
{
|
|
107 |
ret = albumId;
|
|
108 |
break;
|
|
109 |
}
|
|
110 |
}
|
|
111 |
CleanupStack::PopAndDestroy( fileArray );
|
|
112 |
return ret;
|
|
113 |
}
|
|
114 |
*/
|
|
115 |
|
|
116 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
117 |
|
|
118 |
// -----------------------------------------------------------------------------
|
|
119 |
// CFileManagerEngine::CFileManagerEngine
|
|
120 |
// C++ default constructor can NOT contain any code, that
|
|
121 |
// might leave.
|
|
122 |
// -----------------------------------------------------------------------------
|
|
123 |
//
|
|
124 |
CFileManagerEngine::CFileManagerEngine( RFs& aFs ) :
|
|
125 |
iFs( aFs ), iObserver( NULL ), iSisFile( EFalse ),iDelayedDiskEventNotify( NULL )
|
|
126 |
{
|
|
127 |
FUNC_LOG
|
|
128 |
}
|
|
129 |
|
|
130 |
// -----------------------------------------------------------------------------
|
|
131 |
// CFileManagerEngine::NewL
|
|
132 |
// Two-phased constructor.
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
//
|
|
135 |
EXPORT_C CFileManagerEngine* CFileManagerEngine::NewL( RFs& aFs )
|
|
136 |
{
|
|
137 |
CFileManagerEngine* self = new ( ELeave ) CFileManagerEngine( aFs );
|
|
138 |
|
|
139 |
CleanupStack::PushL( self );
|
|
140 |
self->ConstructL();
|
|
141 |
CleanupStack::Pop( self );
|
|
142 |
|
|
143 |
return self;
|
|
144 |
}
|
|
145 |
|
|
146 |
// -----------------------------------------------------------------------------
|
|
147 |
// CFileManagerEngine::ConstructL
|
|
148 |
// -----------------------------------------------------------------------------
|
|
149 |
//
|
|
150 |
void CFileManagerEngine::ConstructL()
|
|
151 |
{
|
|
152 |
FUNC_LOG
|
|
153 |
|
|
154 |
INFO_LOG( "CFileManagerEngine::ConstructL()-Create Feature Manager" )
|
|
155 |
iFeatureManager = CFileManagerFeatureManager::NewL();
|
|
156 |
|
|
157 |
iState = ENavigation;
|
|
158 |
|
|
159 |
INFO_LOG( "CFileManagerEngine::ConstructL()-Create navigator" )
|
|
160 |
iNavigator = CGflmNavigatorModel::NewL( iFs );
|
|
161 |
|
|
162 |
// Create drives group
|
|
163 |
MGflmItemGroup* newGroup = iNavigator->CreateGroupL(
|
|
164 |
EFileManagerDrivesGroup, EDrives );
|
|
165 |
#ifdef RD_FILE_MANAGER_BACKUP
|
|
166 |
// Set backup action
|
|
167 |
HBufC* actionCaption = StringLoader::LoadLC( R_QTN_FMGR_MAIN_BACKUP );
|
|
168 |
newGroup->AddActionItemL( EFileManagerBackupAction, *actionCaption );
|
|
169 |
CleanupStack::PopAndDestroy( actionCaption );
|
|
170 |
#endif // RD_FILE_MANAGER_BACKUP
|
|
171 |
|
|
172 |
// Create files and folders groups
|
|
173 |
iNavigator->CreateGroupL( EFileManagerFilesGroup, EDirectories | EFiles );
|
|
174 |
|
|
175 |
INFO_LOG( "CFileManagerEngine::ConstructL()-Create refresher" )
|
|
176 |
iRefresher = CFileManagerRefresher::NewL( *iNavigator );
|
|
177 |
|
|
178 |
INFO_LOG( "CFileManagerEngine::ConstructL()-Create utils" )
|
|
179 |
iUtils = CFileManagerUtils::NewL( iFs, *iNavigator, *iFeatureManager );
|
|
180 |
|
|
181 |
INFO_LOG( "CFileManagerEngine::ConstructL()-Create disk event" )
|
|
182 |
iDiskEvent = CFileManagerFileSystemEvent::NewL( iFs, *this, ENotifyDisk );
|
|
183 |
|
|
184 |
INFO_LOG( "CFileManagerEngine::ConstructL()-Create removable drive handler" )
|
|
185 |
iRemovableDrvHandler = CFileManagerRemovableDriveHandler::NewL(
|
|
186 |
iFs, *iUtils, *this );
|
|
187 |
INFO_LOG( "CFileManagerEngine::ConstructL()-Create remote drive handler" )
|
|
188 |
iRemoteDrvHandler = CFileManagerRemoteDriveHandler::NewL(
|
|
189 |
*this, *iUtils );
|
|
190 |
|
|
191 |
INFO_LOG( "CFileManagerEngine::ConstructL()-Create item filter" )
|
|
192 |
iItemFilter = CFileManagerItemFilter::NewL( *this );
|
|
193 |
iNavigator->SetCustomFilter( iItemFilter );
|
|
194 |
|
|
195 |
// Store new starting index
|
|
196 |
iNavigationIndices.AppendL( KErrNotFound );
|
|
197 |
}
|
|
198 |
|
|
199 |
// -----------------------------------------------------------------------------
|
|
200 |
// CFileManagerEngine::~CFileManagerEngine
|
|
201 |
// Destructor
|
|
202 |
// -----------------------------------------------------------------------------
|
|
203 |
//
|
|
204 |
EXPORT_C CFileManagerEngine::~CFileManagerEngine()
|
|
205 |
{
|
|
206 |
delete iActiveRename;
|
|
207 |
iNavigationIndices.Reset();
|
|
208 |
delete iRemoteDrvHandler;
|
|
209 |
delete iBackupSettings;
|
|
210 |
delete iRestoreSettings;
|
|
211 |
delete iRemovableDrvHandler;
|
|
212 |
delete iDocHandler;
|
|
213 |
//delete iMgxFileManager;
|
|
214 |
delete iFileSystemEvent;
|
|
215 |
delete iRefresher;
|
|
216 |
delete iNavigator;
|
|
217 |
delete iItemFilter;
|
|
218 |
delete iSearchString;
|
|
219 |
delete iSearchFolder;
|
|
220 |
delete iActiveSize;
|
|
221 |
delete iDiskEvent;
|
|
222 |
delete iUtils;
|
|
223 |
delete iDriveName;
|
|
224 |
delete iFeatureManager;
|
|
225 |
if( iDelayedDiskEventNotify != NULL )
|
|
226 |
{
|
|
227 |
iDelayedDiskEventNotify->Cancel();
|
|
228 |
delete iDelayedDiskEventNotify;
|
|
229 |
}
|
|
230 |
}
|
|
231 |
|
|
232 |
// -----------------------------------------------------------------------------
|
|
233 |
// CFileManagerEngine::SetFileSystemEventL
|
|
234 |
// -----------------------------------------------------------------------------
|
|
235 |
//
|
|
236 |
void CFileManagerEngine::SetFileSystemEventL( const TDesC& aFullPath )
|
|
237 |
{
|
|
238 |
delete iFileSystemEvent;
|
|
239 |
iFileSystemEvent = NULL;
|
|
240 |
if ( aFullPath != KNullDesC )
|
|
241 |
{
|
|
242 |
iFileSystemEvent = CFileManagerFileSystemEvent::NewL(
|
|
243 |
iFs, *this, ENotifyEntry, aFullPath );
|
|
244 |
}
|
|
245 |
else
|
|
246 |
{
|
|
247 |
iFileSystemEvent = CFileManagerFileSystemEvent::NewL(
|
|
248 |
iFs, *this, ENotifyEntry );
|
|
249 |
}
|
|
250 |
}
|
|
251 |
|
|
252 |
// -----------------------------------------------------------------------------
|
|
253 |
// CFileManagerEngine::IndexToFullPathL
|
|
254 |
// -----------------------------------------------------------------------------
|
|
255 |
//
|
|
256 |
EXPORT_C HBufC* CFileManagerEngine::IndexToFullPathL(
|
|
257 |
const TInt aIndex ) const
|
|
258 |
{
|
|
259 |
if ( aIndex < 0 || aIndex >= iNavigator->MdcaCount() )
|
|
260 |
{
|
|
261 |
User::Leave( KErrNotFound );
|
|
262 |
}
|
|
263 |
CGflmGroupItem* item = iNavigator->Item( aIndex );
|
|
264 |
HBufC* fullPath = NULL;
|
|
265 |
switch ( item->Type() )
|
|
266 |
{
|
|
267 |
case CGflmGroupItem::EFile: // Fall through
|
|
268 |
case CGflmGroupItem::EDirectory:
|
|
269 |
{
|
|
270 |
CGflmFileSystemItem* fsItem =
|
|
271 |
static_cast< CGflmFileSystemItem* >( item );
|
|
272 |
fullPath = fsItem->FullPathL();
|
|
273 |
break;
|
|
274 |
}
|
|
275 |
case CGflmGroupItem::EDrive:
|
|
276 |
{
|
|
277 |
CGflmDriveItem* drvItem =
|
|
278 |
static_cast< CGflmDriveItem* >( item );
|
|
279 |
fullPath = drvItem->RootDirectory().AllocL();
|
|
280 |
break;
|
|
281 |
}
|
|
282 |
default:
|
|
283 |
{
|
|
284 |
User::Leave( KErrNotFound );
|
|
285 |
break;
|
|
286 |
}
|
|
287 |
}
|
|
288 |
return fullPath;
|
|
289 |
}
|
|
290 |
|
|
291 |
// -----------------------------------------------------------------------------
|
|
292 |
// CFileManagerEngine::IndexToFullPathLC
|
|
293 |
// -----------------------------------------------------------------------------
|
|
294 |
//
|
|
295 |
EXPORT_C HBufC* CFileManagerEngine::IndexToFullPathLC(
|
|
296 |
const TInt aIndex ) const
|
|
297 |
{
|
|
298 |
HBufC* fullPath = IndexToFullPathL( aIndex );
|
|
299 |
CleanupStack::PushL( fullPath );
|
|
300 |
return fullPath;
|
|
301 |
}
|
|
302 |
|
|
303 |
// -----------------------------------------------------------------------------
|
|
304 |
// CFileManagerEngine::AddFullPathLC
|
|
305 |
// -----------------------------------------------------------------------------
|
|
306 |
//
|
|
307 |
HBufC* CFileManagerEngine::AddFullPathLC(
|
|
308 |
const TDesC& aName, const TBool aIsFolder )
|
|
309 |
{
|
|
310 |
TPtrC dir( iNavigator->CurrentDirectory() );
|
|
311 |
TInt len( dir.Length() + aName.Length() );
|
|
312 |
if ( aIsFolder )
|
|
313 |
{
|
|
314 |
++len; // Ensure space for backslash
|
|
315 |
}
|
|
316 |
HBufC* fullPath = HBufC::NewLC( len );
|
|
317 |
TPtr ptr( fullPath->Des() );
|
|
318 |
ptr.Append( dir );
|
|
319 |
ptr.Append( aName );
|
|
320 |
if ( aIsFolder )
|
|
321 |
{
|
|
322 |
CFileManagerUtils::EnsureFinalBackslash( ptr );
|
|
323 |
}
|
|
324 |
return fullPath;
|
|
325 |
}
|
|
326 |
|
|
327 |
// -----------------------------------------------------------------------------
|
|
328 |
// CFileManagerEngine::SetMemoryL
|
|
329 |
// -----------------------------------------------------------------------------
|
|
330 |
//
|
|
331 |
EXPORT_C TInt CFileManagerEngine::SetMemoryL( TFileManagerMemory /*aMemory*/ )
|
|
332 |
{
|
|
333 |
// Just check current drive avaibility, no matter what memory is set
|
|
334 |
iLastDriveAvailable = CurrentDriveAvailable();
|
|
335 |
return KErrNone;
|
|
336 |
}
|
|
337 |
|
|
338 |
// -----------------------------------------------------------------------------
|
|
339 |
// CFileManagerEngine::Memory
|
|
340 |
// -----------------------------------------------------------------------------
|
|
341 |
//
|
|
342 |
EXPORT_C TFileManagerMemory CFileManagerEngine::Memory() const
|
|
343 |
{
|
|
344 |
#ifdef RD_MULTIPLE_DRIVE
|
|
345 |
CGflmDriveItem* drvItem = iNavigator->CurrentDrive();
|
|
346 |
if ( drvItem )
|
|
347 |
{
|
|
348 |
TUint driveStatus( drvItem->DriveStatus() );
|
|
349 |
if ( driveStatus & DriveInfo::EDriveInternal )
|
|
350 |
{
|
|
351 |
if ( driveStatus & DriveInfo::EDriveExternallyMountable )
|
|
352 |
{
|
|
353 |
return EFmMassStorage;
|
|
354 |
}
|
|
355 |
return EFmPhoneMemory;
|
|
356 |
}
|
|
357 |
else if ( driveStatus & DriveInfo::EDriveUsbMemory )
|
|
358 |
{
|
|
359 |
return EFmUsbMemory;
|
|
360 |
}
|
|
361 |
else if ( driveStatus & DriveInfo::EDriveRemovable )
|
|
362 |
{
|
|
363 |
return EFmMemoryCard;
|
|
364 |
}
|
|
365 |
else if ( driveStatus & DriveInfo::EDriveRemote )
|
|
366 |
{
|
|
367 |
return EFmRemoteDrive;
|
|
368 |
}
|
|
369 |
}
|
|
370 |
return EFmPhoneMemory;
|
|
371 |
#else // RD_MULTIPLE_DRIVE
|
|
372 |
CGflmDriveItem* drvItem = iNavigator->CurrentDrive();
|
|
373 |
if ( drvItem )
|
|
374 |
{
|
|
375 |
const TVolumeInfo vol( drvItem->VolumeInfo() );
|
|
376 |
if ( vol.iDrive.iDriveAtt & KDriveAttInternal )
|
|
377 |
{
|
|
378 |
return EFmPhoneMemory;
|
|
379 |
}
|
|
380 |
else if ( vol.iDrive.iDriveAtt & KDriveAttRemovable )
|
|
381 |
{
|
|
382 |
return EFmMemoryCard;
|
|
383 |
}
|
|
384 |
else if ( vol.iDrive.iDriveAtt & KDriveAttRemote )
|
|
385 |
{
|
|
386 |
return EFmRemoteDrive;
|
|
387 |
}
|
|
388 |
}
|
|
389 |
return EFmPhoneMemory;
|
|
390 |
#endif // RD_MULTIPLE_DRIVE
|
|
391 |
}
|
|
392 |
|
|
393 |
// -----------------------------------------------------------------------------
|
|
394 |
// CFileManagerEngine::FileList
|
|
395 |
// -----------------------------------------------------------------------------
|
|
396 |
//
|
|
397 |
EXPORT_C MDesCArray* CFileManagerEngine::FileList() const
|
|
398 |
{
|
|
399 |
return iNavigator;
|
|
400 |
}
|
|
401 |
|
|
402 |
// -----------------------------------------------------------------------------
|
|
403 |
// CFileManagerEngine::OpenL
|
|
404 |
// -----------------------------------------------------------------------------
|
|
405 |
//
|
|
406 |
EXPORT_C void CFileManagerEngine::OpenL( const TInt aIndex )
|
|
407 |
{
|
|
408 |
// Store drive letter for current drive changed checking
|
|
409 |
TChar prevDrive( 0 );
|
|
410 |
TPtrC prevDir( iNavigator->CurrentDirectory() );
|
|
411 |
if ( prevDir.Length() )
|
|
412 |
{
|
|
413 |
prevDrive = prevDir[ 0 ];
|
|
414 |
}
|
|
415 |
|
|
416 |
if ( aIndex < 0 || aIndex >= iNavigator->MdcaCount() )
|
|
417 |
{
|
|
418 |
User::Leave( KErrNotFound );
|
|
419 |
}
|
|
420 |
CGflmGroupItem* item = iNavigator->Item( aIndex );
|
|
421 |
switch ( item->Type() )
|
|
422 |
{
|
|
423 |
case CGflmGroupItem::EFile: // Fall through
|
|
424 |
case CGflmGroupItem::EDirectory: // Fall through
|
|
425 |
case CGflmGroupItem::EDrive:
|
|
426 |
{
|
|
427 |
|
|
428 |
#ifdef RD_MULTIPLE_DRIVE
|
|
429 |
// Ensure that default folders exist
|
|
430 |
if ( item->Type() == CGflmGroupItem::EDrive )
|
|
431 |
{
|
|
432 |
CGflmDriveItem* drvItem =
|
|
433 |
static_cast< CGflmDriveItem* >( item );
|
|
434 |
iUtils->CreateDefaultFolders(
|
|
435 |
drvItem->Drive(), EFalse );
|
|
436 |
}
|
|
437 |
#endif // RD_MULTIPLE_DRIVE
|
|
438 |
|
|
439 |
// Store navigation position
|
|
440 |
SetCurrentIndex( aIndex );
|
|
441 |
|
|
442 |
HBufC* fullPath = IndexToFullPathLC( aIndex );
|
|
443 |
if ( item->Type() == CGflmGroupItem::EFile )
|
|
444 |
{
|
|
445 |
OpenFileL( *fullPath );
|
|
446 |
}
|
|
447 |
else
|
|
448 |
{
|
|
449 |
OpenDirectoryL( *fullPath );
|
|
450 |
|
|
451 |
// Setup new navigation position
|
|
452 |
iNavigationIndices.AppendL( 0 );
|
|
453 |
}
|
|
454 |
CleanupStack::PopAndDestroy( fullPath );
|
|
455 |
break;
|
|
456 |
}
|
|
457 |
case CGflmGroupItem::EGlobalActionItem:
|
|
458 |
{
|
|
459 |
CGflmGlobalActionItem* actItem =
|
|
460 |
static_cast< CGflmGlobalActionItem* >( item );
|
|
461 |
if ( iProcessObserver )
|
|
462 |
{
|
|
463 |
iProcessObserver->NotifyL(
|
|
464 |
MFileManagerProcessObserver::ENotifyActionSelected,
|
|
465 |
actItem->Id() );
|
|
466 |
}
|
|
467 |
break;
|
|
468 |
}
|
|
469 |
default:
|
|
470 |
{
|
|
471 |
break;
|
|
472 |
}
|
|
473 |
}
|
|
474 |
|
|
475 |
// Ensure that cached current drive info gets updated if drive was changed
|
|
476 |
TPtrC dir( iNavigator->CurrentDirectory() );
|
|
477 |
if ( dir.Length() )
|
|
478 |
{
|
|
479 |
if ( dir[ 0 ] != prevDrive )
|
|
480 |
{
|
|
481 |
iCurrentDriveInfoRefreshed = EFalse;
|
|
482 |
}
|
|
483 |
}
|
|
484 |
}
|
|
485 |
|
|
486 |
// -----------------------------------------------------------------------------
|
|
487 |
// CFileManagerEngine::SetObserver
|
|
488 |
// -----------------------------------------------------------------------------
|
|
489 |
//
|
|
490 |
EXPORT_C void CFileManagerEngine::SetObserver(
|
|
491 |
MFileManagerProcessObserver* aObserver )
|
|
492 |
{
|
|
493 |
iProcessObserver = aObserver;
|
|
494 |
iRefresher->SetObserver( aObserver );
|
|
495 |
iRemovableDrvHandler->SetObserver( aObserver );
|
|
496 |
}
|
|
497 |
|
|
498 |
// -----------------------------------------------------------------------------
|
|
499 |
// CFileManagerEngine::CurrentDirectory
|
|
500 |
// -----------------------------------------------------------------------------
|
|
501 |
//
|
|
502 |
EXPORT_C TPtrC CFileManagerEngine::CurrentDirectory() const
|
|
503 |
{
|
|
504 |
return iNavigator->CurrentDirectory();
|
|
505 |
}
|
|
506 |
|
|
507 |
// -----------------------------------------------------------------------------
|
|
508 |
// CFileManagerEngine::CurrentDirectory
|
|
509 |
// -----------------------------------------------------------------------------
|
|
510 |
//
|
|
511 |
EXPORT_C TPtrC CFileManagerEngine::LocalizedNameOfCurrentDirectory() const
|
|
512 |
{
|
|
513 |
return iNavigator->LocalizedNameOfCurrentDirectory();
|
|
514 |
}
|
|
515 |
|
|
516 |
// -----------------------------------------------------------------------------
|
|
517 |
// CFileManagerEngine::BackstepL
|
|
518 |
// -----------------------------------------------------------------------------
|
|
519 |
//
|
|
520 |
EXPORT_C void CFileManagerEngine::BackstepL()
|
|
521 |
{
|
|
522 |
// Store drive letter for current drive changed checking
|
|
523 |
TChar prevDrive( 0 );
|
|
524 |
// Note that prevDir gets invalid after BackstepL
|
|
525 |
TPtrC prevDir( iNavigator->CurrentDirectory() );
|
|
526 |
if ( prevDir.Length() )
|
|
527 |
{
|
|
528 |
prevDrive = prevDir[ 0 ];
|
|
529 |
}
|
|
530 |
|
|
531 |
// Setup backstep navigation index
|
|
532 |
if ( !iNavigator->NavigationLevel() )
|
|
533 |
{
|
|
534 |
// Always first for initial root level
|
|
535 |
iCurrentItemName.Zero();
|
|
536 |
}
|
|
537 |
else if( !iCurrentItemName.Length() )
|
|
538 |
{
|
|
539 |
// Otherwise previously opened folder
|
|
540 |
iCurrentItemName.Copy(
|
|
541 |
iNavigator->LocalizedNameOfCurrentDirectory() );
|
|
542 |
}
|
|
543 |
TInt pos( iNavigationIndices.Count() - 1 );
|
|
544 |
if ( pos >= 0 )
|
|
545 |
{
|
|
546 |
iNavigationIndices.Remove( pos );
|
|
547 |
}
|
|
548 |
|
|
549 |
iNavigator->BackstepL();
|
|
550 |
|
|
551 |
// Ensure that cached current drive info gets updated if drive was changed
|
|
552 |
TPtrC dir( iNavigator->CurrentDirectory() );
|
|
553 |
if ( dir.Length() )
|
|
554 |
{
|
|
555 |
if ( dir[ 0 ] != prevDrive )
|
|
556 |
{
|
|
557 |
iCurrentDriveInfoRefreshed = EFalse;
|
|
558 |
}
|
|
559 |
}
|
|
560 |
else
|
|
561 |
{
|
|
562 |
// Make sure that drive info is refreshed
|
|
563 |
ClearDriveInfo();
|
|
564 |
}
|
|
565 |
}
|
|
566 |
|
|
567 |
// -----------------------------------------------------------------------------
|
|
568 |
// CFileManagerEngine::FileTypeL
|
|
569 |
// -----------------------------------------------------------------------------
|
|
570 |
//
|
|
571 |
EXPORT_C TUint32 CFileManagerEngine::FileTypeL( const TInt aIndex ) const
|
|
572 |
{
|
|
573 |
TUint32 fileType( CFileManagerItemProperties::ENotDefined );
|
|
574 |
if ( aIndex >= 0 )
|
|
575 |
{
|
|
576 |
HBufC* fullPath = IndexToFullPathLC( aIndex );
|
|
577 |
fileType = FileTypeL( *fullPath );
|
|
578 |
CleanupStack::PopAndDestroy( fullPath );
|
|
579 |
}
|
|
580 |
return fileType;
|
|
581 |
}
|
|
582 |
|
|
583 |
// -----------------------------------------------------------------------------
|
|
584 |
// CFileManagerEngine::FileTypeL
|
|
585 |
// -----------------------------------------------------------------------------
|
|
586 |
//
|
|
587 |
EXPORT_C TUint32 CFileManagerEngine::FileTypeL( const TDesC& aFullPath ) const
|
|
588 |
{
|
|
589 |
return iUtils->FileTypeL( aFullPath );
|
|
590 |
}
|
|
591 |
|
|
592 |
// -----------------------------------------------------------------------------
|
|
593 |
// CFileManagerEngine::DeleteL
|
|
594 |
// -----------------------------------------------------------------------------
|
|
595 |
//
|
|
596 |
EXPORT_C CFileManagerActiveDelete* CFileManagerEngine::CreateActiveDeleteL(
|
|
597 |
CArrayFixFlat< TInt >& aIndexList )
|
|
598 |
{
|
|
599 |
|
|
600 |
CFileManagerActiveDelete* activeDelete =
|
|
601 |
CFileManagerActiveDelete::NewL( aIndexList, *this, *iUtils );
|
|
602 |
return activeDelete;
|
|
603 |
}
|
|
604 |
|
|
605 |
// -----------------------------------------------------------------------------
|
|
606 |
// CFileManagerEngine::NewFolder
|
|
607 |
// -----------------------------------------------------------------------------
|
|
608 |
//
|
|
609 |
EXPORT_C void CFileManagerEngine::NewFolderL( const TDesC& aFolderName )
|
|
610 |
{
|
|
611 |
// Add backslash to end so that MkDir realizes that it is directory
|
|
612 |
HBufC* fullPath = AddFullPathLC( aFolderName, ETrue );
|
|
613 |
TPtr ptr( fullPath->Des() );
|
|
614 |
|
|
615 |
if ( ptr.Length() <= KMaxFileName )
|
|
616 |
{
|
|
617 |
iCurrentItemName.Copy( aFolderName );
|
|
618 |
|
|
619 |
// Remove white spaces from end, file server also ignores those
|
|
620 |
iCurrentItemName.TrimRight();
|
|
621 |
|
|
622 |
User::LeaveIfError( iFs.MkDir( ptr ) );
|
|
623 |
}
|
|
624 |
else
|
|
625 |
{
|
|
626 |
User::Leave( KErrBadName );
|
|
627 |
}
|
|
628 |
|
|
629 |
CleanupStack::PopAndDestroy( fullPath );
|
|
630 |
}
|
|
631 |
|
|
632 |
// -----------------------------------------------------------------------------
|
|
633 |
// CFileManagerEngine::SetCurrentItemName
|
|
634 |
// -----------------------------------------------------------------------------
|
|
635 |
//
|
|
636 |
EXPORT_C void CFileManagerEngine::SetCurrentItemName( const TDesC& aFileName )
|
|
637 |
{
|
|
638 |
|
|
639 |
iCurrentItemName.Copy( aFileName );
|
|
640 |
|
|
641 |
// Remove white spaces from end, file server also ignores those
|
|
642 |
iCurrentItemName.TrimRight();
|
|
643 |
|
|
644 |
}
|
|
645 |
// -----------------------------------------------------------------------------
|
|
646 |
// CFileManagerEngine::RenameL
|
|
647 |
// -----------------------------------------------------------------------------
|
|
648 |
//
|
|
649 |
EXPORT_C void CFileManagerEngine::RenameL(
|
|
650 |
const TInt aIndex,
|
|
651 |
const TDesC& aNewFileName )
|
|
652 |
{
|
|
653 |
FUNC_LOG
|
|
654 |
|
|
655 |
// Make those given names as full paths
|
|
656 |
TBool isFolder( IsFolder( aIndex ) );
|
|
657 |
HBufC* fullPathOld = IndexToFullPathLC( aIndex );
|
|
658 |
HBufC* fullPathNew = AddFullPathLC( aNewFileName, isFolder );
|
|
659 |
|
|
660 |
if ( !fullPathOld->Compare( *fullPathNew ) )
|
|
661 |
{
|
|
662 |
// The name has not changed, rename is not required
|
|
663 |
CleanupStack::PopAndDestroy( fullPathNew );
|
|
664 |
CleanupStack::PopAndDestroy( fullPathOld );
|
|
665 |
return;
|
|
666 |
}
|
|
667 |
|
|
668 |
// Gallery notification is relevant only for local drives
|
|
669 |
TBool isRemoteDrive( iUtils->IsRemoteDrive( *fullPathOld ) );
|
|
670 |
|
|
671 |
// Media Gallery albums get easily messed up when files are renamed.
|
|
672 |
// Direct album editing seems a trick but it is seems to only way
|
|
673 |
// to update Gallery properly.
|
|
674 |
/*CMGAlbumManager* albumManager = MGAlbumManagerFactory::NewAlbumManagerL();
|
|
675 |
CleanupStack:: PushL( albumManager );
|
|
676 |
TInt albumId( KErrNotFound );
|
|
677 |
if ( !isFolder && !isRemoteDrive )
|
|
678 |
{
|
|
679 |
// Do album search for files only
|
|
680 |
TRAPD( err, albumId = SearchMGAlbumIdL( *albumManager, *fullPathOld ) );
|
|
681 |
if( err != KErrNone )
|
|
682 |
{
|
|
683 |
albumId = KErrNotFound;
|
|
684 |
}
|
|
685 |
}
|
|
686 |
*/
|
|
687 |
// Handle rename
|
|
688 |
delete iActiveRename;
|
|
689 |
iActiveRename = NULL;
|
|
690 |
iActiveRename = CFileManagerActiveRename::NewL(
|
|
691 |
*this, *iUtils, *fullPathOld, *fullPathNew );
|
|
692 |
ShowWaitDialogL( *iActiveRename );
|
|
693 |
User::LeaveIfError( iActiveRename->Result() );
|
|
694 |
|
|
695 |
// Update Media Gallery album if file exist in album
|
|
696 |
/*if( albumId != KErrNotFound )
|
|
697 |
{
|
|
698 |
TRAP_IGNORE( { albumManager->RemoveFromAlbumL( *fullPathOld, albumId );
|
|
699 |
albumManager->AddToAlbumL( *fullPathNew, albumId ); } );
|
|
700 |
}
|
|
701 |
CleanupStack::PopAndDestroy( albumManager );*/
|
|
702 |
|
|
703 |
iCurrentItemName.Copy( aNewFileName );
|
|
704 |
|
|
705 |
/*if ( !isRemoteDrive )
|
|
706 |
{
|
|
707 |
// Notify Media Gallery again
|
|
708 |
TRAP_IGNORE( MGXFileManagerL().UpdateL( *fullPathOld, *fullPathNew ) );
|
|
709 |
}*/
|
|
710 |
|
|
711 |
CleanupStack::PopAndDestroy( fullPathNew );
|
|
712 |
CleanupStack::PopAndDestroy( fullPathOld );
|
|
713 |
}
|
|
714 |
|
|
715 |
// -----------------------------------------------------------------------------
|
|
716 |
// CFileManagerEngine::FolderLevel
|
|
717 |
// -----------------------------------------------------------------------------
|
|
718 |
//
|
|
719 |
EXPORT_C TInt CFileManagerEngine::FolderLevel()
|
|
720 |
{
|
|
721 |
CGflmDriveItem* drvItem = iNavigator->CurrentDrive();
|
|
722 |
if ( !drvItem )
|
|
723 |
{
|
|
724 |
return KErrNotFound; // Main level
|
|
725 |
}
|
|
726 |
TPtrC dir( iNavigator->CurrentDirectory() );
|
|
727 |
TInt count( dir.Length() );
|
|
728 |
if ( !count )
|
|
729 |
{
|
|
730 |
return KErrNotFound; // Main level
|
|
731 |
}
|
|
732 |
// Count how many backslashes is in string to figure out the deepness
|
|
733 |
TInt min( drvItem->RootDirectory().Length() );
|
|
734 |
TInt bsCount( 0 );
|
|
735 |
while( count > min )
|
|
736 |
{
|
|
737 |
--count;
|
|
738 |
if ( dir[ count ] == KFmgrBackslash()[ 0 ] )
|
|
739 |
{
|
|
740 |
++bsCount;
|
|
741 |
}
|
|
742 |
}
|
|
743 |
return bsCount;
|
|
744 |
}
|
|
745 |
|
|
746 |
// -----------------------------------------------------------------------------
|
|
747 |
// CFileManagerEngine::IsNameFoundL
|
|
748 |
// -----------------------------------------------------------------------------
|
|
749 |
//
|
|
750 |
EXPORT_C TBool CFileManagerEngine::IsNameFoundL( const TDesC& aName )
|
|
751 |
{
|
|
752 |
return iUtils->IsNameFoundL( aName );
|
|
753 |
}
|
|
754 |
|
|
755 |
// -----------------------------------------------------------------------------
|
|
756 |
// CFileManagerEngine::CurrentDrive
|
|
757 |
// -----------------------------------------------------------------------------
|
|
758 |
//
|
|
759 |
EXPORT_C TInt CFileManagerEngine::CurrentDrive()
|
|
760 |
{
|
|
761 |
TInt ret( KErrNotFound );
|
|
762 |
TPtrC ptr( iNavigator->CurrentDirectory() );
|
|
763 |
if ( ptr.Length() )
|
|
764 |
{
|
|
765 |
if( RFs::CharToDrive( ptr[ 0 ], ret ) != KErrNone )
|
|
766 |
{
|
|
767 |
ret = KErrNotFound;
|
|
768 |
}
|
|
769 |
}
|
|
770 |
return ret;
|
|
771 |
}
|
|
772 |
|
|
773 |
// -----------------------------------------------------------------------------
|
|
774 |
// CFileManagerEngine::GetItemInfoL
|
|
775 |
// -----------------------------------------------------------------------------
|
|
776 |
//
|
|
777 |
EXPORT_C CFileManagerItemProperties* CFileManagerEngine::GetItemInfoL(
|
|
778 |
const TInt aIndex )
|
|
779 |
{
|
|
780 |
if ( aIndex < 0 || aIndex >= iNavigator->MdcaCount() )
|
|
781 |
{
|
|
782 |
User::Leave( KErrNotFound );
|
|
783 |
}
|
|
784 |
CGflmGroupItem* item = iNavigator->Item( aIndex );
|
|
785 |
return CFileManagerItemProperties::NewL( *item, *iUtils, *this );
|
|
786 |
}
|
|
787 |
|
|
788 |
// -----------------------------------------------------------------------------
|
|
789 |
// CFileManagerEngine::SetState
|
|
790 |
// -----------------------------------------------------------------------------
|
|
791 |
//
|
|
792 |
EXPORT_C void CFileManagerEngine::SetState( TState aState )
|
|
793 |
{
|
|
794 |
iState = aState;
|
|
795 |
iNavigator->EnableSearchMode( iState == ESearch );
|
|
796 |
}
|
|
797 |
|
|
798 |
// -----------------------------------------------------------------------------
|
|
799 |
// CFileManagerEngine::SetState
|
|
800 |
// -----------------------------------------------------------------------------
|
|
801 |
//
|
|
802 |
EXPORT_C CFileManagerEngine::TState CFileManagerEngine::State() const
|
|
803 |
{
|
|
804 |
return iState;
|
|
805 |
}
|
|
806 |
|
|
807 |
// -----------------------------------------------------------------------------
|
|
808 |
// CFileManagerEngine::RefreshDirectory
|
|
809 |
// -----------------------------------------------------------------------------
|
|
810 |
//
|
|
811 |
EXPORT_C void CFileManagerEngine::RefreshDirectory()
|
|
812 |
{
|
|
813 |
FUNC_LOG
|
|
814 |
|
|
815 |
#ifdef FILE_MANAGER_INFO_LOG_ENABLED
|
|
816 |
if ( iState == ENavigation )
|
|
817 |
{
|
|
818 |
TPtrC dir( iNavigator->CurrentDirectory() );
|
|
819 |
INFO_LOG1( "CFileManagerEngine::RefreshDirectory-dir=%S", &dir );
|
|
820 |
}
|
|
821 |
#endif // FILE_MANAGER_INFO_LOG_ENABLED
|
|
822 |
|
|
823 |
iRefresher->Refresh();
|
|
824 |
}
|
|
825 |
|
|
826 |
// -----------------------------------------------------------------------------
|
|
827 |
// CFileManagerEngine::GetMMCInfoL
|
|
828 |
// -----------------------------------------------------------------------------
|
|
829 |
//
|
|
830 |
EXPORT_C TFileManagerDriveInfo CFileManagerEngine::GetMMCInfoL() const
|
|
831 |
{
|
|
832 |
TFileManagerDriveInfo drvInfo;
|
|
833 |
GetDriveInfoL(
|
|
834 |
PathInfo::MemoryCardRootPath(), drvInfo );
|
|
835 |
return drvInfo;
|
|
836 |
}
|
|
837 |
|
|
838 |
// -----------------------------------------------------------------------------
|
|
839 |
// CFileManagerEngine::SearchString
|
|
840 |
// -----------------------------------------------------------------------------
|
|
841 |
//
|
|
842 |
EXPORT_C TPtrC CFileManagerEngine::SearchString() const
|
|
843 |
{
|
|
844 |
if ( iSearchString )
|
|
845 |
{
|
|
846 |
return iSearchString->Des();
|
|
847 |
}
|
|
848 |
return TPtrC( KNullDesC );
|
|
849 |
}
|
|
850 |
|
|
851 |
// -----------------------------------------------------------------------------
|
|
852 |
// CFileManagerEngine::IsValidName
|
|
853 |
// -----------------------------------------------------------------------------
|
|
854 |
//
|
|
855 |
EXPORT_C TBool CFileManagerEngine::IsValidName(
|
|
856 |
const TDesC& aDriveAndPath, const TDesC& aName, TBool aIsFolder ) const
|
|
857 |
{
|
|
858 |
// Check name for bad chars
|
|
859 |
const TUint16 KMinAllowedChar = 0x0020;
|
|
860 |
const TUint16 KParagraphSeparator = 0x2029;
|
|
861 |
const TUint16 KDot = '.';
|
|
862 |
TFileName nameAfterTrim( aName );
|
|
863 |
nameAfterTrim.TrimRight();
|
|
864 |
TInt nameLen( nameAfterTrim.Length() );
|
|
865 |
if ( !nameLen )
|
|
866 |
{
|
|
867 |
return EFalse;
|
|
868 |
}
|
|
869 |
for ( TInt i( 0 ); i < nameLen; i++ )
|
|
870 |
{
|
|
871 |
TUint16 ch( nameAfterTrim[ i ] );
|
|
872 |
if ( ch < KMinAllowedChar || ch == KParagraphSeparator )
|
|
873 |
{
|
|
874 |
return EFalse;
|
|
875 |
}
|
|
876 |
}
|
|
877 |
// File system ignores totally dot in the end of name, so
|
|
878 |
// we set here as not valid name, so that user gets correctly informed
|
|
879 |
if ( nameAfterTrim[ nameLen - 1 ] == KDot || IllegalChars( nameAfterTrim ) )
|
|
880 |
{
|
|
881 |
return EFalse;
|
|
882 |
}
|
|
883 |
// Get full path length
|
|
884 |
TPtrC pathPtr( aDriveAndPath.Length() ?
|
|
885 |
TPtrC( aDriveAndPath ) : TPtrC( iNavigator->CurrentDirectory() ) );
|
|
886 |
TInt pathLen( pathPtr.Length() );
|
|
887 |
if ( !pathLen )
|
|
888 |
{
|
|
889 |
return EFalse;
|
|
890 |
}
|
|
891 |
TInt fullPathLen( pathLen );
|
|
892 |
if ( !CFileManagerUtils::HasFinalBackslash( pathPtr ) )
|
|
893 |
{
|
|
894 |
++fullPathLen; // Add backslash before name
|
|
895 |
}
|
|
896 |
fullPathLen += nameLen;
|
|
897 |
if ( aIsFolder )
|
|
898 |
{
|
|
899 |
++fullPathLen; // Add folder final backslash
|
|
900 |
}
|
|
901 |
|
|
902 |
TBool ret( EFalse );
|
|
903 |
if ( fullPathLen <= KMaxFileName )
|
|
904 |
{
|
|
905 |
// Check full path
|
|
906 |
HBufC* fullPath = HBufC::New( KMaxFileName );
|
|
907 |
if ( fullPath )
|
|
908 |
{
|
|
909 |
TPtr ptr( fullPath->Des() );
|
|
910 |
ptr.Copy( pathPtr );
|
|
911 |
CFileManagerUtils::EnsureFinalBackslash( ptr ); // Add backslash before name
|
|
912 |
ptr.Append( nameAfterTrim );
|
|
913 |
ret = iFs.IsValidName( ptr );
|
|
914 |
delete fullPath;
|
|
915 |
}
|
|
916 |
}
|
|
917 |
return ret;
|
|
918 |
}
|
|
919 |
|
|
920 |
// -----------------------------------------------------------------------------
|
|
921 |
// CFileManagerEngine::IllegalChars
|
|
922 |
// -----------------------------------------------------------------------------
|
|
923 |
//
|
|
924 |
EXPORT_C TBool CFileManagerEngine::IllegalChars( const TDesC& aName ) const
|
|
925 |
{
|
|
926 |
for ( TInt i( 0 ); KIllegalChars[ i ]; i++ )
|
|
927 |
{
|
|
928 |
if ( aName.Locate( KIllegalChars[ i ] ) != KErrNotFound )
|
|
929 |
{
|
|
930 |
return ETrue;
|
|
931 |
}
|
|
932 |
}
|
|
933 |
return EFalse;
|
|
934 |
}
|
|
935 |
|
|
936 |
// -----------------------------------------------------------------------------
|
|
937 |
// CFileManagerEngine::EnoughSpaceL
|
|
938 |
// -----------------------------------------------------------------------------
|
|
939 |
//
|
|
940 |
EXPORT_C TBool CFileManagerEngine::EnoughSpaceL(
|
|
941 |
const TDesC& aToFolder,
|
|
942 |
TInt64 aSize,
|
|
943 |
MFileManagerProcessObserver::TFileManagerProcess aOperation ) const
|
|
944 |
{
|
|
945 |
TPtrC src( iNavigator->CurrentDirectory() );
|
|
946 |
TInt srcDrv( KErrNotFound );
|
|
947 |
if ( src.Length() )
|
|
948 |
{
|
|
949 |
User::LeaveIfError( RFs::CharToDrive( src[ 0 ], srcDrv ) );
|
|
950 |
}
|
|
951 |
TInt dstDrv( KErrNotFound );
|
|
952 |
if ( aToFolder.Length() )
|
|
953 |
{
|
|
954 |
User::LeaveIfError( RFs::CharToDrive( aToFolder[ 0 ], dstDrv ) );
|
|
955 |
}
|
|
956 |
else
|
|
957 |
{
|
|
958 |
return ETrue; // Invalid destination
|
|
959 |
}
|
|
960 |
|
|
961 |
TBool ret( EFalse );
|
|
962 |
|
|
963 |
// if operation is move and drive is same so there is always enough memory
|
|
964 |
if ( srcDrv == dstDrv &&
|
|
965 |
aOperation == MFileManagerProcessObserver::EMoveProcess )
|
|
966 |
{
|
|
967 |
ret = ETrue;
|
|
968 |
}
|
|
969 |
else
|
|
970 |
{
|
|
971 |
ret = !SysUtil::DiskSpaceBelowCriticalLevelL(
|
|
972 |
&iFs, aSize , dstDrv );
|
|
973 |
}
|
|
974 |
|
|
975 |
return ret;
|
|
976 |
}
|
|
977 |
|
|
978 |
// -----------------------------------------------------------------------------
|
|
979 |
// CFileManagerEngine::FileSystemEvent
|
|
980 |
// -----------------------------------------------------------------------------
|
|
981 |
//
|
|
982 |
EXPORT_C void CFileManagerEngine::FileSystemEvent( TBool aEventOn )
|
|
983 |
{
|
|
984 |
INFO_LOG2(
|
|
985 |
"CFileManagerEngine::FileSystemEvent-aEventOn=%d,iFileSystemEventEnabled=%d",
|
|
986 |
aEventOn, iFileSystemEventEnabled )
|
|
987 |
|
|
988 |
INFO_LOG2(
|
|
989 |
"CFileManagerEngine::FileSystemEvent-iDriveAddedOrChangedPostponed=%d,iEmbeddedApplicationOn=%d ",
|
|
990 |
iDriveAddedOrChangedPostponed, iEmbeddedApplicationOn )
|
|
991 |
|
|
992 |
if ( !iFileSystemEventEnabled && aEventOn )
|
|
993 |
{
|
|
994 |
iDriveAddedOrChangedPostponed = EFalse;
|
|
995 |
iFileSystemEventEnabled = ETrue;
|
|
996 |
}
|
|
997 |
else if ( iFileSystemEventEnabled && !aEventOn )
|
|
998 |
{
|
|
999 |
iFileSystemEventEnabled = EFalse;
|
|
1000 |
if ( iDriveAddedOrChangedPostponed )
|
|
1001 |
{
|
|
1002 |
iDriveAddedOrChangedPostponed = EFalse;
|
|
1003 |
TRAP_IGNORE( DriveAddedOrChangedL() );
|
|
1004 |
}
|
|
1005 |
}
|
|
1006 |
|
|
1007 |
if ( iUtils->IsRemoteDrive( iNavigator->CurrentDirectory() ) )
|
|
1008 |
{
|
|
1009 |
// At the moment no use to have event for remote drives
|
|
1010 |
delete iFileSystemEvent;
|
|
1011 |
iFileSystemEvent = NULL;
|
|
1012 |
return;
|
|
1013 |
}
|
|
1014 |
|
|
1015 |
// Set event on when there is no embedded app with event
|
|
1016 |
if ( aEventOn &&
|
|
1017 |
!( iEmbeddedApplicationOn && iFileSystemEvent ) )
|
|
1018 |
{
|
|
1019 |
TInt err( KErrNone );
|
|
1020 |
switch ( iState )
|
|
1021 |
{
|
|
1022 |
case ENavigation:
|
|
1023 |
{
|
|
1024 |
TRAP( err, SetFileSystemEventL( iNavigator->CurrentDirectory() ) );
|
|
1025 |
break;
|
|
1026 |
}
|
|
1027 |
case ESearch:
|
|
1028 |
{
|
|
1029 |
TRAP( err, SetFileSystemEventL() );
|
|
1030 |
break;
|
|
1031 |
}
|
|
1032 |
default:
|
|
1033 |
{
|
|
1034 |
break;
|
|
1035 |
}
|
|
1036 |
}
|
|
1037 |
if ( err != KErrNone && iProcessObserver )
|
|
1038 |
{
|
|
1039 |
iProcessObserver->Error( err );
|
|
1040 |
}
|
|
1041 |
}
|
|
1042 |
// Check event and set it off when there is no embedded app
|
|
1043 |
else if( !iEmbeddedApplicationOn && iFileSystemEvent )
|
|
1044 |
{
|
|
1045 |
iFileSystemEvent->CheckFileSystemEvent();
|
|
1046 |
delete iFileSystemEvent;
|
|
1047 |
iFileSystemEvent = NULL;
|
|
1048 |
}
|
|
1049 |
}
|
|
1050 |
|
|
1051 |
// ------------------------------------------------------------------------------
|
|
1052 |
// CFileManagerEngine::CurrentIndex
|
|
1053 |
//
|
|
1054 |
// ------------------------------------------------------------------------------
|
|
1055 |
//
|
|
1056 |
EXPORT_C TInt CFileManagerEngine::CurrentIndex()
|
|
1057 |
{
|
|
1058 |
if ( iCurrentItemName.Length() )
|
|
1059 |
{
|
|
1060 |
TInt count( iNavigator->MdcaCount() );
|
|
1061 |
for( TInt i( 0 ); i < count; ++i )
|
|
1062 |
{
|
|
1063 |
CGflmGroupItem* item = iNavigator->Item( i );
|
|
1064 |
if ( !item->Name().CompareF( iCurrentItemName ) )
|
|
1065 |
{
|
|
1066 |
iCurrentItemName.Zero();
|
|
1067 |
return i;
|
|
1068 |
}
|
|
1069 |
}
|
|
1070 |
iCurrentItemName.Zero();
|
|
1071 |
}
|
|
1072 |
|
|
1073 |
// Top navigation index
|
|
1074 |
TInt pos( iNavigationIndices.Count() - 1 );
|
|
1075 |
if ( pos >= 0 )
|
|
1076 |
{
|
|
1077 |
return iNavigationIndices[ pos ];
|
|
1078 |
}
|
|
1079 |
return KErrNotFound;
|
|
1080 |
}
|
|
1081 |
|
|
1082 |
// ------------------------------------------------------------------------------
|
|
1083 |
// CFileManagerEngine::CanDelete
|
|
1084 |
//
|
|
1085 |
// ------------------------------------------------------------------------------
|
|
1086 |
//
|
|
1087 |
TBool CFileManagerEngine::CanDelete( const TDesC& aFileName ) const
|
|
1088 |
{
|
|
1089 |
return iUtils->CanDelete( aFileName );
|
|
1090 |
}
|
|
1091 |
|
|
1092 |
// ------------------------------------------------------------------------------
|
|
1093 |
// CFileManagerEngine::LocalizedName
|
|
1094 |
//
|
|
1095 |
// ------------------------------------------------------------------------------
|
|
1096 |
//
|
|
1097 |
EXPORT_C TPtrC CFileManagerEngine::LocalizedName(
|
|
1098 |
const TDesC& aFullPath ) const
|
|
1099 |
{
|
|
1100 |
return iUtils->LocalizedName( aFullPath );
|
|
1101 |
}
|
|
1102 |
|
|
1103 |
// ------------------------------------------------------------------------------
|
|
1104 |
// CFileManagerEngine::FilesInFolderL
|
|
1105 |
//
|
|
1106 |
// ------------------------------------------------------------------------------
|
|
1107 |
//
|
|
1108 |
EXPORT_C TInt CFileManagerEngine::FilesInFolderL()
|
|
1109 |
{
|
|
1110 |
TInt ret( 0 );
|
|
1111 |
switch ( iState )
|
|
1112 |
{
|
|
1113 |
case ENavigation: // Fall through
|
|
1114 |
case ESearch:
|
|
1115 |
{
|
|
1116 |
TInt count( iNavigator->MdcaCount() );
|
|
1117 |
for( TInt i( 0 ); i < count; ++i )
|
|
1118 |
{
|
|
1119 |
CGflmGroupItem* item = iNavigator->Item( i );
|
|
1120 |
if ( item->Type() == CGflmGroupItem::EFile )
|
|
1121 |
{
|
|
1122 |
++ret;
|
|
1123 |
}
|
|
1124 |
}
|
|
1125 |
break;
|
|
1126 |
}
|
|
1127 |
default:
|
|
1128 |
{
|
|
1129 |
break;
|
|
1130 |
}
|
|
1131 |
}
|
|
1132 |
return ret;
|
|
1133 |
}
|
|
1134 |
|
|
1135 |
// ------------------------------------------------------------------------------
|
|
1136 |
// CFileManagerEngine::CancelRefresh
|
|
1137 |
//
|
|
1138 |
// ------------------------------------------------------------------------------
|
|
1139 |
//
|
|
1140 |
EXPORT_C TBool CFileManagerEngine::CancelRefresh()
|
|
1141 |
{
|
|
1142 |
switch ( iState )
|
|
1143 |
{
|
|
1144 |
case ENavigation:
|
|
1145 |
{
|
|
1146 |
CancelTransfer( iNavigator->CurrentDirectory() );
|
|
1147 |
break;
|
|
1148 |
}
|
|
1149 |
case ESearch:
|
|
1150 |
{
|
|
1151 |
if ( iSearchFolder )
|
|
1152 |
{
|
|
1153 |
CancelTransfer( *iSearchFolder );
|
|
1154 |
}
|
|
1155 |
break;
|
|
1156 |
}
|
|
1157 |
default:
|
|
1158 |
{
|
|
1159 |
break;
|
|
1160 |
}
|
|
1161 |
}
|
|
1162 |
return iRefresher->CancelRefresh();
|
|
1163 |
}
|
|
1164 |
|
|
1165 |
// ------------------------------------------------------------------------------
|
|
1166 |
// CFileManagerEngine::DriveAddedOrChangeAsyncL
|
|
1167 |
//
|
|
1168 |
// ------------------------------------------------------------------------------
|
|
1169 |
//
|
|
1170 |
TInt CFileManagerEngine::DriveAddedOrChangeAsyncL( TAny* aPtr )
|
|
1171 |
{
|
|
1172 |
static_cast<CFileManagerEngine*>( aPtr )->DriveAddedOrChangedL();
|
|
1173 |
|
|
1174 |
//return value will be ignored by CPeriodic that calls this function
|
|
1175 |
//following line keeps the compiler happy
|
|
1176 |
return 0;
|
|
1177 |
}
|
|
1178 |
|
|
1179 |
// ------------------------------------------------------------------------------
|
|
1180 |
// CFileManagerEngine::DriveAddedOrChangedL
|
|
1181 |
//
|
|
1182 |
// ------------------------------------------------------------------------------
|
|
1183 |
//
|
|
1184 |
void CFileManagerEngine::DriveAddedOrChangedL()
|
|
1185 |
{
|
|
1186 |
FUNC_LOG
|
|
1187 |
|
|
1188 |
if( iDiskEvent )
|
|
1189 |
{
|
|
1190 |
iDiskEvent->Setup();
|
|
1191 |
}
|
|
1192 |
|
|
1193 |
TBool processOngoing( iRemovableDrvHandler->IsProcessOngoing() );
|
|
1194 |
|
|
1195 |
INFO_LOG3( "CFileManagerEngine::DriveAddedOrChangedL-event=%d,process=%d,postponed=%d ",
|
|
1196 |
iFileSystemEventEnabled, processOngoing, iDriveAddedOrChangedPostponed )
|
|
1197 |
|
|
1198 |
if ( iFileSystemEventEnabled || processOngoing )
|
|
1199 |
{
|
|
1200 |
iDriveAddedOrChangedPostponed = ETrue;
|
|
1201 |
}
|
|
1202 |
else
|
|
1203 |
{
|
|
1204 |
iDriveAddedOrChangedPostponed = EFalse;
|
|
1205 |
ClearDriveInfo();
|
|
1206 |
if ( iProcessObserver &&
|
|
1207 |
!iEmbeddedApplicationOn &&
|
|
1208 |
!iWaitDialogOn &&
|
|
1209 |
!iRefresher->IsActive() )
|
|
1210 |
{
|
|
1211 |
StopDiskEventNotifyTimerAsync();
|
|
1212 |
TPtrC dir( iNavigator->CurrentDirectory() );
|
|
1213 |
if ( dir.Length() )
|
|
1214 |
{
|
|
1215 |
TBool isAvailable( CurrentDriveAvailable() );
|
|
1216 |
|
|
1217 |
if ( iUtils->IsRemoteDrive( dir ) )
|
|
1218 |
{
|
|
1219 |
// Notify whether remote drive has become available
|
|
1220 |
// So when receiving remote drive connection event,
|
|
1221 |
// View will be refreshed
|
|
1222 |
//if ( !iLastDriveAvailable && isAvailable )
|
|
1223 |
// {
|
|
1224 |
iProcessObserver->NotifyL(
|
|
1225 |
MFileManagerProcessObserver::ENotifyDisksChanged, 0 );
|
|
1226 |
// }
|
|
1227 |
}
|
|
1228 |
else
|
|
1229 |
{
|
|
1230 |
// Notify if drive has become unavailable or
|
|
1231 |
// avaibility has changed
|
|
1232 |
if ( !isAvailable ||
|
|
1233 |
isAvailable != iLastDriveAvailable )
|
|
1234 |
{
|
|
1235 |
iProcessObserver->NotifyL(
|
|
1236 |
MFileManagerProcessObserver::ENotifyDisksChanged, 0 );
|
|
1237 |
}
|
|
1238 |
}
|
|
1239 |
}
|
|
1240 |
else
|
|
1241 |
{
|
|
1242 |
// Notify always when no folder is opened
|
|
1243 |
iProcessObserver->NotifyL(
|
|
1244 |
MFileManagerProcessObserver::ENotifyDisksChanged, 0 );
|
|
1245 |
}
|
|
1246 |
}
|
|
1247 |
else
|
|
1248 |
{
|
|
1249 |
if( ( iProcessObserver == NULL ) || iEmbeddedApplicationOn )
|
|
1250 |
{
|
|
1251 |
//Do not refresh while embedded application is running or process observer is not set
|
|
1252 |
StopDiskEventNotifyTimerAsync();
|
|
1253 |
}
|
|
1254 |
else
|
|
1255 |
{
|
|
1256 |
if( iRefresher->IsActive() )
|
|
1257 |
{
|
|
1258 |
//start Timer and notify disk event until current disk refresh finishes
|
|
1259 |
StartDiskEventNotifyTimerAsyncL();
|
|
1260 |
}
|
|
1261 |
}
|
|
1262 |
}
|
|
1263 |
}
|
|
1264 |
}
|
|
1265 |
|
|
1266 |
// ------------------------------------------------------------------------------
|
|
1267 |
// CFileManagerEngine::FolderContentChangedL
|
|
1268 |
//
|
|
1269 |
// ------------------------------------------------------------------------------
|
|
1270 |
//
|
|
1271 |
void CFileManagerEngine::FolderContentChangedL()
|
|
1272 |
{
|
|
1273 |
if( iProcessObserver )
|
|
1274 |
{
|
|
1275 |
iProcessObserver->NotifyL(
|
|
1276 |
MFileManagerProcessObserver::ENotifyDisksChanged, 0 );
|
|
1277 |
}
|
|
1278 |
else
|
|
1279 |
{
|
|
1280 |
RefreshDirectory();
|
|
1281 |
}
|
|
1282 |
}
|
|
1283 |
|
|
1284 |
// ------------------------------------------------------------------------------
|
|
1285 |
// CFileManagerEngine::IsFolder
|
|
1286 |
//
|
|
1287 |
// ------------------------------------------------------------------------------
|
|
1288 |
//
|
|
1289 |
EXPORT_C TBool CFileManagerEngine::IsFolder( const TInt aIndex ) const
|
|
1290 |
{
|
|
1291 |
if ( aIndex < 0 || aIndex >= iNavigator->MdcaCount() )
|
|
1292 |
{
|
|
1293 |
return EFalse;
|
|
1294 |
}
|
|
1295 |
CGflmGroupItem* item = iNavigator->Item( aIndex );
|
|
1296 |
TBool ret( EFalse );
|
|
1297 |
switch ( item->Type() )
|
|
1298 |
{
|
|
1299 |
case CGflmGroupItem::EDirectory: // Fallthrough
|
|
1300 |
case CGflmGroupItem::EDrive: // Fallthrough
|
|
1301 |
case CGflmGroupItem::EGlobalActionItem:
|
|
1302 |
{
|
|
1303 |
ret = ETrue;
|
|
1304 |
break;
|
|
1305 |
}
|
|
1306 |
default:
|
|
1307 |
{
|
|
1308 |
break;
|
|
1309 |
}
|
|
1310 |
}
|
|
1311 |
return ret;
|
|
1312 |
}
|
|
1313 |
|
|
1314 |
// ------------------------------------------------------------------------------
|
|
1315 |
// CFileManagerEngine::IconIdL
|
|
1316 |
//
|
|
1317 |
// ------------------------------------------------------------------------------
|
|
1318 |
//
|
|
1319 |
EXPORT_C TInt CFileManagerEngine::IconIdL( const TInt aIndex ) const
|
|
1320 |
{
|
|
1321 |
if ( aIndex < 0 || aIndex >= iNavigator->MdcaCount() )
|
|
1322 |
{
|
|
1323 |
User::Leave( KErrNotFound );
|
|
1324 |
}
|
|
1325 |
CGflmGroupItem* item = iNavigator->Item( aIndex );
|
|
1326 |
return iUtils->ResolveIconL( *item );
|
|
1327 |
}
|
|
1328 |
|
|
1329 |
// -----------------------------------------------------------------------------
|
|
1330 |
// CFileManagerEngine::ShowWaitDialogL( MAknBackgroundProcess& aProcess )
|
|
1331 |
//
|
|
1332 |
// -----------------------------------------------------------------------------
|
|
1333 |
//
|
|
1334 |
void CFileManagerEngine::ShowWaitDialogL( MAknBackgroundProcess& aProcess )
|
|
1335 |
{
|
|
1336 |
iWaitDialogOn = ETrue;
|
|
1337 |
TRAPD( err, iProcessObserver->ShowWaitDialogL( aProcess ) );
|
|
1338 |
iWaitDialogOn = EFalse;
|
|
1339 |
User::LeaveIfError( err );
|
|
1340 |
}
|
|
1341 |
|
|
1342 |
// -----------------------------------------------------------------------------
|
|
1343 |
// CFileManagerEngine::EmbeddedAppStatus( TBool aStatus )
|
|
1344 |
//
|
|
1345 |
// -----------------------------------------------------------------------------
|
|
1346 |
//
|
|
1347 |
void CFileManagerEngine::EmbeddedAppStatus( TBool aStatus )
|
|
1348 |
{
|
|
1349 |
iEmbeddedApplicationOn = aStatus;
|
|
1350 |
FileSystemEvent( aStatus );
|
|
1351 |
}
|
|
1352 |
|
|
1353 |
// -----------------------------------------------------------------------------
|
|
1354 |
// CFileManagerEngine::IsSystemFolder
|
|
1355 |
//
|
|
1356 |
// -----------------------------------------------------------------------------
|
|
1357 |
//
|
|
1358 |
EXPORT_C TBool CFileManagerEngine::IsSystemFolder( const TDesC& aFullPath ) const
|
|
1359 |
{
|
|
1360 |
_LIT( KSystemFolder, "?:\\system\\*" );
|
|
1361 |
_LIT( KSysFolder, "?:\\sys\\*" );
|
|
1362 |
_LIT( KPrivateFolder, "?:\\private\\*" );
|
|
1363 |
_LIT( KResourceFolder, "?:\\resource\\*" );
|
|
1364 |
|
|
1365 |
if ( aFullPath.MatchF( KSystemFolder ) != KErrNotFound ||
|
|
1366 |
aFullPath.MatchF( KSysFolder ) != KErrNotFound ||
|
|
1367 |
aFullPath.MatchF( KResourceFolder ) != KErrNotFound ||
|
|
1368 |
aFullPath.MatchF( KPrivateFolder ) != KErrNotFound )
|
|
1369 |
{
|
|
1370 |
return ETrue;
|
|
1371 |
}
|
|
1372 |
return EFalse;
|
|
1373 |
}
|
|
1374 |
|
|
1375 |
// -----------------------------------------------------------------------------
|
|
1376 |
// CFileManagerEngine::CurrentDriveName()
|
|
1377 |
//
|
|
1378 |
// -----------------------------------------------------------------------------
|
|
1379 |
//
|
|
1380 |
EXPORT_C TPtrC CFileManagerEngine::CurrentDriveName()
|
|
1381 |
{
|
|
1382 |
#ifdef RD_MULTIPLE_DRIVE
|
|
1383 |
TPtrC dir( iNavigator->CurrentDirectory() );
|
|
1384 |
if ( dir.Length() )
|
|
1385 |
{
|
|
1386 |
TInt drive = TDriveUnit( dir );
|
|
1387 |
return DriveName( drive );
|
|
1388 |
}
|
|
1389 |
#else // RD_MULTIPLE_DRIVE
|
|
1390 |
CGflmDriveItem* drvItem = iNavigator->CurrentDrive();
|
|
1391 |
if ( drvItem )
|
|
1392 |
{
|
|
1393 |
return drvItem->Name();
|
|
1394 |
}
|
|
1395 |
#endif // RD_MULTIPLE_DRIVE
|
|
1396 |
return TPtrC( KNullDesC );
|
|
1397 |
}
|
|
1398 |
|
|
1399 |
// -----------------------------------------------------------------------------
|
|
1400 |
// CFileManagerEngine::GetDriveInfoL()
|
|
1401 |
//
|
|
1402 |
// -----------------------------------------------------------------------------
|
|
1403 |
//
|
|
1404 |
EXPORT_C void CFileManagerEngine::GetDriveInfoL(
|
|
1405 |
TFileManagerDriveInfo& aInfo )
|
|
1406 |
{
|
|
1407 |
if ( iCurrentDriveInfoRefreshed )
|
|
1408 |
{
|
|
1409 |
// Use cached info
|
|
1410 |
aInfo = iCurrentDriveInfo;
|
|
1411 |
return;
|
|
1412 |
}
|
|
1413 |
|
|
1414 |
CGflmDriveItem* drvItem = iNavigator->CurrentDrive();
|
|
1415 |
if ( drvItem )
|
|
1416 |
{
|
|
1417 |
GetDriveInfoL( drvItem->Drive(), aInfo );
|
|
1418 |
|
|
1419 |
// Store info for later use
|
|
1420 |
iCurrentDriveInfo = aInfo;
|
|
1421 |
iCurrentDriveInfoRefreshed = ETrue;
|
|
1422 |
}
|
|
1423 |
else
|
|
1424 |
{
|
|
1425 |
User::Leave( KErrNotFound );
|
|
1426 |
}
|
|
1427 |
}
|
|
1428 |
|
|
1429 |
// -----------------------------------------------------------------------------
|
|
1430 |
// CFileManagerEngine::IsDistributableFile()
|
|
1431 |
//
|
|
1432 |
// -----------------------------------------------------------------------------
|
|
1433 |
//
|
|
1434 |
EXPORT_C TInt CFileManagerEngine::IsDistributableFile(
|
|
1435 |
const TDesC& aFullPath, TBool& aIsProtected ) const
|
|
1436 |
{
|
|
1437 |
return iUtils->IsDistributableFile( aFullPath, aIsProtected );
|
|
1438 |
}
|
|
1439 |
|
|
1440 |
// -----------------------------------------------------------------------------
|
|
1441 |
// CFileManagerEngine::RenameDrive()
|
|
1442 |
//
|
|
1443 |
// -----------------------------------------------------------------------------
|
|
1444 |
//
|
|
1445 |
EXPORT_C TInt CFileManagerEngine::RenameDrive(
|
|
1446 |
const TInt aDrive,
|
|
1447 |
const TDesC& aName )
|
|
1448 |
{
|
|
1449 |
TInt len( aName.Length( ) );
|
|
1450 |
for( TInt i( 0 ); i < len; i++ )
|
|
1451 |
{
|
|
1452 |
TChar ch( aName[ i ] );
|
|
1453 |
// If not alphadigit or space, return error
|
|
1454 |
if( !ch.IsAlphaDigit() && !ch.IsSpace() )
|
|
1455 |
{
|
|
1456 |
return KErrBadName;
|
|
1457 |
}
|
|
1458 |
}
|
|
1459 |
TInt err( iFs.SetVolumeLabel( aName, aDrive ) );
|
|
1460 |
if ( err == KErrNone )
|
|
1461 |
{
|
|
1462 |
// Refresh drive info after rename
|
|
1463 |
ClearDriveInfo();
|
|
1464 |
}
|
|
1465 |
return err;
|
|
1466 |
}
|
|
1467 |
|
|
1468 |
// -----------------------------------------------------------------------------
|
|
1469 |
// CFileManagerEngine::SetDrivePassword()
|
|
1470 |
//
|
|
1471 |
// -----------------------------------------------------------------------------
|
|
1472 |
//
|
|
1473 |
EXPORT_C TInt CFileManagerEngine::SetDrivePassword(
|
|
1474 |
const TInt aDrive,
|
|
1475 |
const TMediaPassword& aOld,
|
|
1476 |
const TMediaPassword& aNew )
|
|
1477 |
{
|
|
1478 |
ClearDriveInfo();
|
|
1479 |
TInt err( iFs.LockDrive( aDrive, aOld, aNew, ETrue ) );
|
|
1480 |
INFO_LOG1( "CFileManagerEngine::SetDrivePassword err %d", err );
|
|
1481 |
return err;
|
|
1482 |
}
|
|
1483 |
|
|
1484 |
// -----------------------------------------------------------------------------
|
|
1485 |
// CFileManagerEngine::RemoveDrivePassword()
|
|
1486 |
//
|
|
1487 |
// -----------------------------------------------------------------------------
|
|
1488 |
//
|
|
1489 |
EXPORT_C TInt CFileManagerEngine::RemoveDrivePassword(
|
|
1490 |
const TInt aDrive,
|
|
1491 |
const TMediaPassword& aPwd )
|
|
1492 |
{
|
|
1493 |
ClearDriveInfo();
|
|
1494 |
TInt err( iFs.ClearPassword( aDrive, aPwd ) );
|
|
1495 |
INFO_LOG1( "CFileManagerEngine::RemoveDrivePassword err %d", err );
|
|
1496 |
return err;
|
|
1497 |
}
|
|
1498 |
|
|
1499 |
// -----------------------------------------------------------------------------
|
|
1500 |
// CFileManagerEngine::UnlockDrive()
|
|
1501 |
//
|
|
1502 |
// -----------------------------------------------------------------------------
|
|
1503 |
//
|
|
1504 |
EXPORT_C TInt CFileManagerEngine::UnlockDrive(
|
|
1505 |
const TInt aDrive,
|
|
1506 |
const TMediaPassword& aPwd )
|
|
1507 |
{
|
|
1508 |
ClearDriveInfo();
|
|
1509 |
TInt err( iFs.UnlockDrive( aDrive, aPwd, ETrue ) );
|
|
1510 |
INFO_LOG1( "CFileManagerEngine::UnlockDrive err %d", err );
|
|
1511 |
return err;
|
|
1512 |
}
|
|
1513 |
|
|
1514 |
// -----------------------------------------------------------------------------
|
|
1515 |
// CFileManagerEngine::StartFormatProcessL()
|
|
1516 |
//
|
|
1517 |
// -----------------------------------------------------------------------------
|
|
1518 |
//
|
|
1519 |
EXPORT_C void CFileManagerEngine::StartFormatProcessL(
|
|
1520 |
const TInt aDrive )
|
|
1521 |
{
|
|
1522 |
ClearDriveInfo();
|
|
1523 |
iRemovableDrvHandler->StartFormatL( aDrive );
|
|
1524 |
}
|
|
1525 |
|
|
1526 |
// -----------------------------------------------------------------------------
|
|
1527 |
// CFileManagerEngine::StartEjectProcessL()
|
|
1528 |
//
|
|
1529 |
// -----------------------------------------------------------------------------
|
|
1530 |
//
|
|
1531 |
EXPORT_C void CFileManagerEngine::StartEjectProcessL( const TInt /*aDrive*/ )
|
|
1532 |
{
|
|
1533 |
ClearDriveInfo();
|
|
1534 |
iRemovableDrvHandler->StartEjectL();
|
|
1535 |
}
|
|
1536 |
|
|
1537 |
// -----------------------------------------------------------------------------
|
|
1538 |
// CFileManagerEngine::StartBackupProcessL()
|
|
1539 |
//
|
|
1540 |
// -----------------------------------------------------------------------------
|
|
1541 |
//
|
|
1542 |
EXPORT_C void CFileManagerEngine::StartBackupProcessL(
|
|
1543 |
MFileManagerProcessObserver::TFileManagerProcess aProcess )
|
|
1544 |
{
|
|
1545 |
switch( aProcess )
|
|
1546 |
{
|
|
1547 |
case MFileManagerProcessObserver::EBackupProcess: // FALLTHROUGH
|
|
1548 |
case MFileManagerProcessObserver::ESchBackupProcess:
|
|
1549 |
{
|
|
1550 |
// Make sure that there is no embedded apps open
|
|
1551 |
delete iDocHandler;
|
|
1552 |
iDocHandler = NULL;
|
|
1553 |
|
|
1554 |
ClearDriveInfo();
|
|
1555 |
iRemovableDrvHandler->StartBackupL( aProcess );
|
|
1556 |
break;
|
|
1557 |
}
|
|
1558 |
case MFileManagerProcessObserver::ERestoreProcess:
|
|
1559 |
{
|
|
1560 |
ClearDriveInfo();
|
|
1561 |
iRemovableDrvHandler->StartRestoreL();
|
|
1562 |
break;
|
|
1563 |
}
|
|
1564 |
default:
|
|
1565 |
{
|
|
1566 |
User::Leave( KErrNotSupported );
|
|
1567 |
break;
|
|
1568 |
}
|
|
1569 |
}
|
|
1570 |
}
|
|
1571 |
|
|
1572 |
// -----------------------------------------------------------------------------
|
|
1573 |
// CFileManagerEngine::CancelProcess()
|
|
1574 |
//
|
|
1575 |
// -----------------------------------------------------------------------------
|
|
1576 |
//
|
|
1577 |
EXPORT_C void CFileManagerEngine::CancelProcess(
|
|
1578 |
MFileManagerProcessObserver::TFileManagerProcess aProcess )
|
|
1579 |
{
|
|
1580 |
switch( aProcess )
|
|
1581 |
{
|
|
1582 |
case MFileManagerProcessObserver::EFormatProcess:
|
|
1583 |
case MFileManagerProcessObserver::EBackupProcess: // FALLTHROUGH
|
|
1584 |
case MFileManagerProcessObserver::ERestoreProcess: // FALLTHROUGH
|
|
1585 |
case MFileManagerProcessObserver::ESchBackupProcess: // FALLTHROUGH
|
|
1586 |
{
|
|
1587 |
iRemovableDrvHandler->CancelProcess();
|
|
1588 |
break;
|
|
1589 |
}
|
|
1590 |
case MFileManagerProcessObserver::EFileOpenProcess:
|
|
1591 |
{
|
|
1592 |
if ( iDocHandler )
|
|
1593 |
{
|
|
1594 |
iDocHandler->CancelFileOpen();
|
|
1595 |
}
|
|
1596 |
break;
|
|
1597 |
}
|
|
1598 |
default:
|
|
1599 |
{
|
|
1600 |
break;
|
|
1601 |
}
|
|
1602 |
}
|
|
1603 |
}
|
|
1604 |
|
|
1605 |
// -----------------------------------------------------------------------------
|
|
1606 |
// CFileManagerEngine::GetDriveInfoL()
|
|
1607 |
//
|
|
1608 |
// -----------------------------------------------------------------------------
|
|
1609 |
//
|
|
1610 |
void CFileManagerEngine::GetDriveInfoL(
|
|
1611 |
const TDesC& aPath,
|
|
1612 |
TFileManagerDriveInfo& aInfo ) const
|
|
1613 |
{
|
|
1614 |
if ( !aPath.Length() )
|
|
1615 |
{
|
|
1616 |
User::Leave( KErrNotFound );
|
|
1617 |
}
|
|
1618 |
TInt drv( 0 );
|
|
1619 |
User::LeaveIfError( RFs::CharToDrive( aPath[ 0 ], drv ) );
|
|
1620 |
GetDriveInfoL( drv, aInfo );
|
|
1621 |
}
|
|
1622 |
|
|
1623 |
// -----------------------------------------------------------------------------
|
|
1624 |
// CFileManagerEngine::DriveState()
|
|
1625 |
//
|
|
1626 |
// -----------------------------------------------------------------------------
|
|
1627 |
//
|
|
1628 |
EXPORT_C TInt CFileManagerEngine::DriveState(
|
|
1629 |
TUint32& aState, const TDesC& aPath ) const
|
|
1630 |
{
|
|
1631 |
TFileManagerDriveInfo info;
|
|
1632 |
TRAPD( err, GetDriveInfoL( aPath, info ) );
|
|
1633 |
if ( err == KErrNone )
|
|
1634 |
{
|
|
1635 |
aState = info.iState;
|
|
1636 |
}
|
|
1637 |
else
|
|
1638 |
{
|
|
1639 |
aState = 0;
|
|
1640 |
}
|
|
1641 |
return err;
|
|
1642 |
}
|
|
1643 |
|
|
1644 |
// -----------------------------------------------------------------------------
|
|
1645 |
// CFileManagerEngine::DriveState()
|
|
1646 |
//
|
|
1647 |
// -----------------------------------------------------------------------------
|
|
1648 |
//
|
|
1649 |
EXPORT_C TInt CFileManagerEngine::DriveState(
|
|
1650 |
TUint32& aState, const TInt aDrive ) const
|
|
1651 |
{
|
|
1652 |
TFileManagerDriveInfo info;
|
|
1653 |
TRAPD( err, GetDriveInfoL( aDrive, info ) );
|
|
1654 |
if ( err == KErrNone )
|
|
1655 |
{
|
|
1656 |
aState = info.iState;
|
|
1657 |
}
|
|
1658 |
else
|
|
1659 |
{
|
|
1660 |
aState = 0;
|
|
1661 |
}
|
|
1662 |
return err;
|
|
1663 |
}
|
|
1664 |
|
|
1665 |
// -----------------------------------------------------------------------------
|
|
1666 |
// CFileManagerEngine::MGXFileManagerL()
|
|
1667 |
//
|
|
1668 |
// -----------------------------------------------------------------------------
|
|
1669 |
//
|
|
1670 |
/*CMGXFileManager& CFileManagerEngine::MGXFileManagerL()
|
|
1671 |
{
|
|
1672 |
// MG2 notification object
|
|
1673 |
if ( !iMgxFileManager )
|
|
1674 |
{
|
|
1675 |
INFO_LOG( "CFileManagerEngine::MGXFileManagerL()-Create" )
|
|
1676 |
iMgxFileManager = MGXFileManagerFactory::NewFileManagerL( iFs );
|
|
1677 |
}
|
|
1678 |
return *iMgxFileManager;
|
|
1679 |
}*/
|
|
1680 |
|
|
1681 |
// -----------------------------------------------------------------------------
|
|
1682 |
// CFileManagerEngine::Fs()
|
|
1683 |
//
|
|
1684 |
// -----------------------------------------------------------------------------
|
|
1685 |
//
|
|
1686 |
RFs& CFileManagerEngine::Fs() const
|
|
1687 |
{
|
|
1688 |
return iFs;
|
|
1689 |
}
|
|
1690 |
|
|
1691 |
// -----------------------------------------------------------------------------
|
|
1692 |
// CFileManagerEngine::IsRemoteDriveConnected()
|
|
1693 |
//
|
|
1694 |
// -----------------------------------------------------------------------------
|
|
1695 |
//
|
|
1696 |
TBool CFileManagerEngine::IsRemoteDriveConnected( const TInt aDrive ) const
|
|
1697 |
{
|
|
1698 |
return iRemoteDrvHandler->IsConnected( aDrive );
|
|
1699 |
}
|
|
1700 |
|
|
1701 |
// -----------------------------------------------------------------------------
|
|
1702 |
// CFileManagerEngine::SetRemoteDriveConnection()
|
|
1703 |
//
|
|
1704 |
// -----------------------------------------------------------------------------
|
|
1705 |
//
|
|
1706 |
EXPORT_C TInt CFileManagerEngine::SetRemoteDriveConnection(
|
|
1707 |
const TInt aDrive, TBool aConnect )
|
|
1708 |
{
|
|
1709 |
return iRemoteDrvHandler->SetConnection( aDrive, aConnect );
|
|
1710 |
}
|
|
1711 |
|
|
1712 |
// -----------------------------------------------------------------------------
|
|
1713 |
// CFileManagerEngine::DeleteRemoteDrive()
|
|
1714 |
//
|
|
1715 |
// -----------------------------------------------------------------------------
|
|
1716 |
//
|
|
1717 |
EXPORT_C TInt CFileManagerEngine::DeleteRemoteDrive( const TInt aDrive )
|
|
1718 |
{
|
|
1719 |
return iRemoteDrvHandler->DeleteSettings( aDrive );
|
|
1720 |
}
|
|
1721 |
|
|
1722 |
// -----------------------------------------------------------------------------
|
|
1723 |
// CFileManagerEngine::BackupFileExistsL()
|
|
1724 |
//
|
|
1725 |
// -----------------------------------------------------------------------------
|
|
1726 |
//
|
|
1727 |
#ifndef RD_FILE_MANAGER_BACKUP
|
|
1728 |
|
|
1729 |
TBool CFileManagerEngine::BackupFileExistsL( const TInt aDrive ) const
|
|
1730 |
{
|
|
1731 |
return iRemovableDrvHandler->BackupFileExistsL( aDrive );
|
|
1732 |
}
|
|
1733 |
|
|
1734 |
#endif // RD_FILE_MANAGER_BACKUP
|
|
1735 |
|
|
1736 |
// -----------------------------------------------------------------------------
|
|
1737 |
// CFileManagerEngine::OpenFileL()
|
|
1738 |
//
|
|
1739 |
// -----------------------------------------------------------------------------
|
|
1740 |
//
|
|
1741 |
void CFileManagerEngine::OpenFileL( const TDesC& aFullPath )
|
|
1742 |
{
|
|
1743 |
if ( !iDocHandler )
|
|
1744 |
{
|
|
1745 |
iDocHandler = CFileManagerDocHandler::NewL( *this, *iUtils );
|
|
1746 |
}
|
|
1747 |
iDocHandler->OpenFileL( aFullPath, iProcessObserver );
|
|
1748 |
}
|
|
1749 |
|
|
1750 |
// -----------------------------------------------------------------------------
|
|
1751 |
// CFileManagerEngine::OpenDirectoryL()
|
|
1752 |
//
|
|
1753 |
// -----------------------------------------------------------------------------
|
|
1754 |
//
|
|
1755 |
void CFileManagerEngine::OpenDirectoryL( const TDesC& aFullPath )
|
|
1756 |
{
|
|
1757 |
iNavigator->GoToDirectoryL( aFullPath, ETrue );
|
|
1758 |
}
|
|
1759 |
|
|
1760 |
// -----------------------------------------------------------------------------
|
|
1761 |
// CFileManagerEngine::DriveRootDirectory()
|
|
1762 |
//
|
|
1763 |
// -----------------------------------------------------------------------------
|
|
1764 |
//
|
|
1765 |
EXPORT_C TPtrC CFileManagerEngine::DriveRootDirectory( TInt aDrive ) const
|
|
1766 |
{
|
|
1767 |
CGflmDriveItem* drvItem = iNavigator->DriveFromId( aDrive );
|
|
1768 |
if ( drvItem )
|
|
1769 |
{
|
|
1770 |
return drvItem->RootDirectory();
|
|
1771 |
}
|
|
1772 |
return TPtrC( KNullDesC );
|
|
1773 |
}
|
|
1774 |
|
|
1775 |
// -----------------------------------------------------------------------------
|
|
1776 |
// CFileManagerEngine::BackupSettingsL()
|
|
1777 |
//
|
|
1778 |
// -----------------------------------------------------------------------------
|
|
1779 |
//
|
|
1780 |
EXPORT_C CFileManagerBackupSettings& CFileManagerEngine::BackupSettingsL()
|
|
1781 |
{
|
|
1782 |
if ( !iBackupSettings )
|
|
1783 |
{
|
|
1784 |
INFO_LOG( "CFileManagerEngine::BackupSettingsL()-Create" )
|
|
1785 |
iBackupSettings = CFileManagerBackupSettings::NewL( *this );
|
|
1786 |
}
|
|
1787 |
return *iBackupSettings;
|
|
1788 |
}
|
|
1789 |
|
|
1790 |
// -----------------------------------------------------------------------------
|
|
1791 |
// CFileManagerEngine::RestoreSettingsL()
|
|
1792 |
//
|
|
1793 |
// -----------------------------------------------------------------------------
|
|
1794 |
//
|
|
1795 |
EXPORT_C CFileManagerRestoreSettings& CFileManagerEngine::RestoreSettingsL()
|
|
1796 |
{
|
|
1797 |
if ( !iRestoreSettings )
|
|
1798 |
{
|
|
1799 |
INFO_LOG( "CFileManagerEngine::RestoreSettingsL()-Create" )
|
|
1800 |
iRestoreSettings = CFileManagerRestoreSettings::NewL( *this );
|
|
1801 |
}
|
|
1802 |
return *iRestoreSettings;
|
|
1803 |
}
|
|
1804 |
|
|
1805 |
// -----------------------------------------------------------------------------
|
|
1806 |
// CFileManagerEngine::GetRestoreInfoArrayL()
|
|
1807 |
//
|
|
1808 |
// -----------------------------------------------------------------------------
|
|
1809 |
//
|
|
1810 |
EXPORT_C void CFileManagerEngine::GetRestoreInfoArrayL(
|
|
1811 |
RArray< CFileManagerRestoreSettings::TInfo >& aArray,
|
|
1812 |
const TInt aDrive ) const
|
|
1813 |
{
|
|
1814 |
return iRemovableDrvHandler->GetRestoreInfoArrayL( aArray, aDrive );
|
|
1815 |
}
|
|
1816 |
|
|
1817 |
// -----------------------------------------------------------------------------
|
|
1818 |
// CFileManagerEngine::DriveName()
|
|
1819 |
//
|
|
1820 |
// -----------------------------------------------------------------------------
|
|
1821 |
//
|
|
1822 |
EXPORT_C TPtrC CFileManagerEngine::DriveName( const TInt aDrive )
|
|
1823 |
{
|
|
1824 |
CGflmDriveItem* drvItem = iNavigator->DriveFromId( aDrive );
|
|
1825 |
if ( drvItem )
|
|
1826 |
{
|
|
1827 |
#ifdef RD_MULTIPLE_DRIVE
|
|
1828 |
delete iDriveName;
|
|
1829 |
iDriveName = NULL;
|
|
1830 |
|
|
1831 |
TRAPD( err, iDriveName = iUtils->GetDriveNameL(
|
|
1832 |
drvItem->Drive(), CFileManagerUtils::ETitleLayout ) );
|
|
1833 |
if ( err == KErrNone )
|
|
1834 |
{
|
|
1835 |
return iDriveName->Des();
|
|
1836 |
}
|
|
1837 |
#else // RD_MULTIPLE_DRIVE
|
|
1838 |
return drvItem->Name();
|
|
1839 |
#endif // RD_MULTIPLE_DRIVE
|
|
1840 |
}
|
|
1841 |
return TPtrC( KNullDesC );
|
|
1842 |
}
|
|
1843 |
|
|
1844 |
// -----------------------------------------------------------------------------
|
|
1845 |
// CFileManagerEngine::GetDriveInfoL()
|
|
1846 |
//
|
|
1847 |
// -----------------------------------------------------------------------------
|
|
1848 |
//
|
|
1849 |
EXPORT_C void CFileManagerEngine::GetDriveInfoL(
|
|
1850 |
const TInt aDrive, TFileManagerDriveInfo& aInfo ) const
|
|
1851 |
{
|
|
1852 |
aInfo.GetInfoL( *this, aDrive );
|
|
1853 |
}
|
|
1854 |
|
|
1855 |
// -----------------------------------------------------------------------------
|
|
1856 |
// CFileManagerEngine::CurrentDriveAvailable()
|
|
1857 |
//
|
|
1858 |
// -----------------------------------------------------------------------------
|
|
1859 |
//
|
|
1860 |
TBool CFileManagerEngine::CurrentDriveAvailable()
|
|
1861 |
{
|
|
1862 |
TFileManagerDriveInfo info;
|
|
1863 |
TRAPD( err, GetDriveInfoL( info ) );
|
|
1864 |
if ( err != KErrNone )
|
|
1865 |
{
|
|
1866 |
return EFalse;
|
|
1867 |
}
|
|
1868 |
|
|
1869 |
TInt ret( ETrue );
|
|
1870 |
if ( info.iState & (
|
|
1871 |
TFileManagerDriveInfo::EDriveCorrupted |
|
|
1872 |
TFileManagerDriveInfo::EDriveLocked ) )
|
|
1873 |
{
|
|
1874 |
ret = EFalse;
|
|
1875 |
}
|
|
1876 |
else if ( !( info.iState & TFileManagerDriveInfo::EDrivePresent ) )
|
|
1877 |
{
|
|
1878 |
ret = EFalse;
|
|
1879 |
}
|
|
1880 |
|
|
1881 |
if ( ( info.iState & TFileManagerDriveInfo::EDriveRemote ) &&
|
|
1882 |
!( info.iState & TFileManagerDriveInfo::EDriveConnected ) )
|
|
1883 |
{
|
|
1884 |
ret = EFalse;
|
|
1885 |
}
|
|
1886 |
return ret;
|
|
1887 |
}
|
|
1888 |
|
|
1889 |
// -----------------------------------------------------------------------------
|
|
1890 |
// CFileManagerEngine::ClearDriveInfo()
|
|
1891 |
//
|
|
1892 |
// -----------------------------------------------------------------------------
|
|
1893 |
//
|
|
1894 |
void CFileManagerEngine::ClearDriveInfo()
|
|
1895 |
{
|
|
1896 |
iCurrentDriveInfoRefreshed = EFalse;
|
|
1897 |
iNavigator->ClearDriveInfo();
|
|
1898 |
}
|
|
1899 |
|
|
1900 |
// -----------------------------------------------------------------------------
|
|
1901 |
// CFileManagerEngine::AnyEjectableDrivePresent()
|
|
1902 |
//
|
|
1903 |
// -----------------------------------------------------------------------------
|
|
1904 |
//
|
|
1905 |
EXPORT_C TBool CFileManagerEngine::AnyEjectableDrivePresent() const
|
|
1906 |
{
|
|
1907 |
RArray< TInt > drives;
|
|
1908 |
iUtils->DriveList( drives, KDriveAttRemovable );
|
|
1909 |
TInt ret( EFalse );
|
|
1910 |
TInt count( drives.Count() );
|
|
1911 |
const TInt KPresentBits(
|
|
1912 |
TFileManagerDriveInfo::EDriveEjectable |
|
|
1913 |
TFileManagerDriveInfo::EDrivePresent );
|
|
1914 |
for( TInt i( 0 ); i < count; ++i )
|
|
1915 |
{
|
|
1916 |
TUint32 state( 0 );
|
|
1917 |
if ( DriveState( state, drives[ i ] ) == KErrNone )
|
|
1918 |
{
|
|
1919 |
if ( ( state & KPresentBits ) == KPresentBits )
|
|
1920 |
{
|
|
1921 |
ret = ETrue;
|
|
1922 |
break;
|
|
1923 |
}
|
|
1924 |
}
|
|
1925 |
}
|
|
1926 |
drives.Close();
|
|
1927 |
return ret;
|
|
1928 |
}
|
|
1929 |
|
|
1930 |
// -----------------------------------------------------------------------------
|
|
1931 |
// CFileManagerEngine::ForcedRefreshDirectory()
|
|
1932 |
//
|
|
1933 |
// -----------------------------------------------------------------------------
|
|
1934 |
//
|
|
1935 |
EXPORT_C void CFileManagerEngine::ForcedRefreshDirectory()
|
|
1936 |
{
|
|
1937 |
TPtrC ptr( iNavigator->CurrentDirectory() );
|
|
1938 |
if ( ptr.Length() && iUtils->IsRemoteDrive( ptr ) )
|
|
1939 |
{
|
|
1940 |
// Ensure that remote directory is reloaded
|
|
1941 |
iRemoteDrvHandler->RefreshDirectory( ptr );
|
|
1942 |
}
|
|
1943 |
RefreshDirectory();
|
|
1944 |
}
|
|
1945 |
|
|
1946 |
// -----------------------------------------------------------------------------
|
|
1947 |
// CFileManagerEngine::HasAppRemoteDriveSupport()
|
|
1948 |
//
|
|
1949 |
// -----------------------------------------------------------------------------
|
|
1950 |
//
|
|
1951 |
TBool CFileManagerEngine::HasAppRemoteDriveSupport( TUid aUid )
|
|
1952 |
{
|
|
1953 |
return iRemoteDrvHandler->HasAppRemoteDriveSupport( aUid );
|
|
1954 |
}
|
|
1955 |
|
|
1956 |
// -----------------------------------------------------------------------------
|
|
1957 |
// CFileManagerEngine::GetFileSizesL()
|
|
1958 |
//
|
|
1959 |
// -----------------------------------------------------------------------------
|
|
1960 |
//
|
|
1961 |
EXPORT_C TInt64 CFileManagerEngine::GetFileSizesL(
|
|
1962 |
const CArrayFixFlat<TInt>& aIndexList )
|
|
1963 |
{
|
|
1964 |
FUNC_LOG
|
|
1965 |
|
|
1966 |
TBool isCanceled( EFalse );
|
|
1967 |
TInt64 size( 0 );
|
|
1968 |
TInt count( aIndexList.Count() );
|
|
1969 |
|
|
1970 |
for( TInt i( 0 ); i < count; ++i )
|
|
1971 |
{
|
|
1972 |
CGflmGroupItem* item = iNavigator->Item( aIndexList.At( i ) );
|
|
1973 |
switch ( item->Type() )
|
|
1974 |
{
|
|
1975 |
case CGflmGroupItem::EFile:
|
|
1976 |
{
|
|
1977 |
CGflmFileSystemItem* fsItem =
|
|
1978 |
static_cast< CGflmFileSystemItem* >( item );
|
|
1979 |
size += fsItem->Entry().FileSize();
|
|
1980 |
break;
|
|
1981 |
}
|
|
1982 |
case CGflmGroupItem::EDirectory:
|
|
1983 |
{
|
|
1984 |
CGflmFileSystemItem* fsItem =
|
|
1985 |
static_cast< CGflmFileSystemItem* >( item );
|
|
1986 |
HBufC* fullPath = fsItem->FullPathLC();
|
|
1987 |
|
|
1988 |
delete iActiveSize;
|
|
1989 |
iActiveSize = NULL;
|
|
1990 |
|
|
1991 |
iActiveSize = CFileManagerActiveSize::NewL(
|
|
1992 |
iFs, *fullPath );
|
|
1993 |
|
|
1994 |
ShowWaitDialogL( *iActiveSize );
|
|
1995 |
|
|
1996 |
TInt64 folderSize( iActiveSize->GetFolderSize() );
|
|
1997 |
if ( folderSize == KErrNotFound )
|
|
1998 |
{
|
|
1999 |
// Calculation was canceled by the user
|
|
2000 |
isCanceled = ETrue;
|
|
2001 |
}
|
|
2002 |
else
|
|
2003 |
{
|
|
2004 |
size += folderSize;
|
|
2005 |
}
|
|
2006 |
|
|
2007 |
CleanupStack::PopAndDestroy( fullPath );
|
|
2008 |
break;
|
|
2009 |
}
|
|
2010 |
default:
|
|
2011 |
{
|
|
2012 |
break;
|
|
2013 |
}
|
|
2014 |
}
|
|
2015 |
|
|
2016 |
if ( isCanceled )
|
|
2017 |
{
|
|
2018 |
break;
|
|
2019 |
}
|
|
2020 |
}
|
|
2021 |
|
|
2022 |
if ( isCanceled )
|
|
2023 |
{
|
|
2024 |
return KErrNotFound;
|
|
2025 |
}
|
|
2026 |
return size;
|
|
2027 |
}
|
|
2028 |
|
|
2029 |
// -----------------------------------------------------------------------------
|
|
2030 |
// CFileManagerEngine::CancelTransfer()
|
|
2031 |
//
|
|
2032 |
// -----------------------------------------------------------------------------
|
|
2033 |
//
|
|
2034 |
void CFileManagerEngine::CancelTransfer( const TDesC& aFullPath )
|
|
2035 |
{
|
|
2036 |
if ( iUtils->IsRemoteDrive( aFullPath ) )
|
|
2037 |
{
|
|
2038 |
iRemoteDrvHandler->CancelTransfer( aFullPath );
|
|
2039 |
}
|
|
2040 |
}
|
|
2041 |
|
|
2042 |
// -----------------------------------------------------------------------------
|
|
2043 |
// CFileManagerEngine::NavigationLevel
|
|
2044 |
// -----------------------------------------------------------------------------
|
|
2045 |
//
|
|
2046 |
EXPORT_C TInt CFileManagerEngine::NavigationLevel() const
|
|
2047 |
{
|
|
2048 |
return iNavigator->NavigationLevel();
|
|
2049 |
}
|
|
2050 |
|
|
2051 |
#ifdef RD_MULTIPLE_DRIVE
|
|
2052 |
// -----------------------------------------------------------------------------
|
|
2053 |
// CFileManagerEngine::GetFormattedDriveNameLC
|
|
2054 |
// -----------------------------------------------------------------------------
|
|
2055 |
//
|
|
2056 |
EXPORT_C HBufC* CFileManagerEngine::GetFormattedDriveNameLC(
|
|
2057 |
const TInt aDrive,
|
|
2058 |
const TInt aTextIdForDefaultName,
|
|
2059 |
const TInt aTextIdForName ) const
|
|
2060 |
{
|
|
2061 |
return iUtils->GetFormattedDriveNameLC(
|
|
2062 |
aDrive, aTextIdForDefaultName, aTextIdForName );
|
|
2063 |
}
|
|
2064 |
#else // RD_MULTIPLE_DRIVE
|
|
2065 |
EXPORT_C HBufC* CFileManagerEngine::GetFormattedDriveNameLC(
|
|
2066 |
const TInt /*aDrive*/,
|
|
2067 |
const TInt /*aTextIdForDefaultName*/,
|
|
2068 |
const TInt /*aTextIdForName*/ ) const
|
|
2069 |
{
|
|
2070 |
User::Leave( KErrNotSupported );
|
|
2071 |
return NULL;
|
|
2072 |
}
|
|
2073 |
#endif // RD_MULTIPLE_DRIVE
|
|
2074 |
|
|
2075 |
// -----------------------------------------------------------------------------
|
|
2076 |
// CFileManagerEngine::GetItemInfoLC
|
|
2077 |
// -----------------------------------------------------------------------------
|
|
2078 |
//
|
|
2079 |
EXPORT_C CFileManagerItemProperties* CFileManagerEngine::GetItemInfoLC(
|
|
2080 |
const TInt aIndex )
|
|
2081 |
{
|
|
2082 |
CFileManagerItemProperties* ret = GetItemInfoL( aIndex );
|
|
2083 |
CleanupStack::PushL( ret );
|
|
2084 |
return ret;
|
|
2085 |
}
|
|
2086 |
|
|
2087 |
// -----------------------------------------------------------------------------
|
|
2088 |
// CFileManagerEngine::SetSearchStringL
|
|
2089 |
// -----------------------------------------------------------------------------
|
|
2090 |
//
|
|
2091 |
EXPORT_C void CFileManagerEngine::SetSearchStringL( const TDesC& aSearchString )
|
|
2092 |
{
|
|
2093 |
delete iSearchString;
|
|
2094 |
iSearchString = NULL;
|
|
2095 |
iSearchString = aSearchString.AllocL();
|
|
2096 |
iNavigator->SetSearchStringL( aSearchString );
|
|
2097 |
}
|
|
2098 |
|
|
2099 |
// -----------------------------------------------------------------------------
|
|
2100 |
// CFileManagerEngine::SetSearchFolderL
|
|
2101 |
// -----------------------------------------------------------------------------
|
|
2102 |
//
|
|
2103 |
EXPORT_C void CFileManagerEngine::SetSearchFolderL( const TDesC& aSearchFolder )
|
|
2104 |
{
|
|
2105 |
delete iSearchFolder;
|
|
2106 |
iSearchFolder = NULL;
|
|
2107 |
iSearchFolder = aSearchFolder.AllocL();
|
|
2108 |
iNavigator->SetSearchFolderL( aSearchFolder );
|
|
2109 |
}
|
|
2110 |
|
|
2111 |
// -----------------------------------------------------------------------------
|
|
2112 |
// CFileManagerEngine::SetDirectoryWithBackstepsL
|
|
2113 |
// -----------------------------------------------------------------------------
|
|
2114 |
//
|
|
2115 |
EXPORT_C void CFileManagerEngine::SetDirectoryWithBackstepsL(
|
|
2116 |
const TDesC& aDirectory )
|
|
2117 |
{
|
|
2118 |
CGflmDriveItem* drvItem = iNavigator->DriveFromPath( aDirectory );
|
|
2119 |
if ( !drvItem )
|
|
2120 |
{
|
|
2121 |
return;
|
|
2122 |
}
|
|
2123 |
// Build backsteps
|
|
2124 |
iNavigator->GoToDirectoryL( drvItem->RootDirectory(), aDirectory );
|
|
2125 |
|
|
2126 |
// Build navigation indices
|
|
2127 |
iNavigationIndices.Reset();
|
|
2128 |
iNavigationIndices.AppendL( KErrNotFound ); // Set initial
|
|
2129 |
TInt count( iNavigator->NavigationLevel() ); // Set backsteps
|
|
2130 |
for( TInt i( 0 ); i < count; ++i )
|
|
2131 |
{
|
|
2132 |
iNavigationIndices.AppendL( KErrNotFound );
|
|
2133 |
}
|
|
2134 |
iNavigationIndices.AppendL( KErrNotFound ); // Set current
|
|
2135 |
}
|
|
2136 |
|
|
2137 |
// -----------------------------------------------------------------------------
|
|
2138 |
// CFileManagerEngine::SetCurrentIndex
|
|
2139 |
// -----------------------------------------------------------------------------
|
|
2140 |
//
|
|
2141 |
EXPORT_C void CFileManagerEngine::SetCurrentIndex( const TInt aIndex )
|
|
2142 |
{
|
|
2143 |
TInt pos( iNavigationIndices.Count() - 1 );
|
|
2144 |
if ( pos >= 0 )
|
|
2145 |
{
|
|
2146 |
iNavigationIndices[ pos ] = aIndex;
|
|
2147 |
}
|
|
2148 |
}
|
|
2149 |
|
|
2150 |
// -----------------------------------------------------------------------------
|
|
2151 |
// CFileManagerEngine::SetSortMethod
|
|
2152 |
// -----------------------------------------------------------------------------
|
|
2153 |
//
|
|
2154 |
EXPORT_C void CFileManagerEngine::SetSortMethod( TSortMethod aSortMethod )
|
|
2155 |
{
|
|
2156 |
switch ( aSortMethod )
|
|
2157 |
{
|
|
2158 |
case EByName: // Fallthrough
|
|
2159 |
case EByType: // Fallthrough
|
|
2160 |
case EMostRecentFirst: // Fallthrough
|
|
2161 |
case ELargestFirst: // Fallthrough
|
|
2162 |
case EByMatch:
|
|
2163 |
{
|
|
2164 |
// Make sure that the enums do match
|
|
2165 |
iNavigator->SetSortMethod(
|
|
2166 |
static_cast< TGflmSortMethod >( aSortMethod ) );
|
|
2167 |
break;
|
|
2168 |
}
|
|
2169 |
default:
|
|
2170 |
{
|
|
2171 |
ERROR_LOG1(
|
|
2172 |
"CFileManagerEngine::SetSortMethod-InvalidMethod=%d",
|
|
2173 |
aSortMethod )
|
|
2174 |
break;
|
|
2175 |
}
|
|
2176 |
}
|
|
2177 |
}
|
|
2178 |
|
|
2179 |
// -----------------------------------------------------------------------------
|
|
2180 |
// CFileManagerEngine::SortMethod
|
|
2181 |
// -----------------------------------------------------------------------------
|
|
2182 |
//
|
|
2183 |
EXPORT_C CFileManagerEngine::TSortMethod CFileManagerEngine::SortMethod() const
|
|
2184 |
{
|
|
2185 |
// Make sure that the enums do match
|
|
2186 |
return static_cast< TSortMethod >( iNavigator->SortMethod() );
|
|
2187 |
}
|
|
2188 |
|
|
2189 |
// -----------------------------------------------------------------------------
|
|
2190 |
// CFileManagerEngine::RefreshSort
|
|
2191 |
// -----------------------------------------------------------------------------
|
|
2192 |
//
|
|
2193 |
EXPORT_C void CFileManagerEngine::RefreshSort()
|
|
2194 |
{
|
|
2195 |
iRefresher->Refresh( ERefreshSort );
|
|
2196 |
}
|
|
2197 |
|
|
2198 |
// -----------------------------------------------------------------------------
|
|
2199 |
// CFileManagerEngine::FeatureManager
|
|
2200 |
// -----------------------------------------------------------------------------
|
|
2201 |
//
|
|
2202 |
EXPORT_C CFileManagerFeatureManager& CFileManagerEngine::FeatureManager() const
|
|
2203 |
{
|
|
2204 |
return *iFeatureManager;
|
|
2205 |
}
|
|
2206 |
|
|
2207 |
// -----------------------------------------------------------------------------
|
|
2208 |
// CFileManagerEngine::SetAppExitOb
|
|
2209 |
// -----------------------------------------------------------------------------
|
|
2210 |
//
|
|
2211 |
EXPORT_C void CFileManagerEngine::SetAppExitOb( MAknServerAppExitObserver* aObserver )
|
|
2212 |
{
|
|
2213 |
iObserver = aObserver;
|
|
2214 |
}
|
|
2215 |
|
|
2216 |
// -----------------------------------------------------------------------------
|
|
2217 |
// CFileManagerEngine::NoticeServerAppExit
|
|
2218 |
// -----------------------------------------------------------------------------
|
|
2219 |
//
|
|
2220 |
void CFileManagerEngine::NoticeServerAppExit( TInt aReason )
|
|
2221 |
{
|
|
2222 |
if ( iObserver && iSisFile )
|
|
2223 |
{
|
|
2224 |
iUtils->FlushCache();
|
|
2225 |
iObserver->HandleServerAppExit( aReason );
|
|
2226 |
iSisFile = EFalse;
|
|
2227 |
}
|
|
2228 |
}
|
|
2229 |
|
|
2230 |
// -----------------------------------------------------------------------------
|
|
2231 |
// CFileManagerEngine::SetSisFile
|
|
2232 |
// -----------------------------------------------------------------------------
|
|
2233 |
//
|
|
2234 |
void CFileManagerEngine::SetSisFile( TBool aSisFile )
|
|
2235 |
{
|
|
2236 |
iSisFile = aSisFile;
|
|
2237 |
}
|
|
2238 |
|
|
2239 |
// ---------------------------------------------------------------------------
|
|
2240 |
// CFileManagerEngine::LatestBackupTimeL()
|
|
2241 |
// ---------------------------------------------------------------------------
|
|
2242 |
//
|
|
2243 |
TInt CFileManagerEngine::LatestBackupTime( TTime& aBackupTime )
|
|
2244 |
{
|
|
2245 |
TRAPD( err, iRemovableDrvHandler->LatestBackupTimeL( aBackupTime ) );
|
|
2246 |
return err;
|
|
2247 |
}
|
|
2248 |
|
|
2249 |
// ---------------------------------------------------------------------------
|
|
2250 |
// CFileManagerEngine::DeleteBackupsL()
|
|
2251 |
// ---------------------------------------------------------------------------
|
|
2252 |
//
|
|
2253 |
EXPORT_C void CFileManagerEngine::DeleteBackupsL()
|
|
2254 |
{
|
|
2255 |
iRemovableDrvHandler->DeleteBackupsL();
|
|
2256 |
}
|
|
2257 |
|
|
2258 |
// ---------------------------------------------------------------------------
|
|
2259 |
// CFileManagerEngine::StartDiskEventNotifyTimerAsyncL()
|
|
2260 |
// ---------------------------------------------------------------------------
|
|
2261 |
//
|
|
2262 |
void CFileManagerEngine::StartDiskEventNotifyTimerAsyncL()
|
|
2263 |
{
|
|
2264 |
if ( iDelayedDiskEventNotify == NULL )
|
|
2265 |
{
|
|
2266 |
iDelayedDiskEventNotify = CPeriodic::NewL( CActive::EPriorityStandard );
|
|
2267 |
}
|
|
2268 |
if ( !iDelayedDiskEventNotify->IsActive() )
|
|
2269 |
{
|
|
2270 |
//ignore disk event notification while timer is already active
|
|
2271 |
iDelayedDiskEventNotify->Start( KDiskEventCheckInterval,
|
|
2272 |
KDiskEventCheckInterval,
|
|
2273 |
TCallBack( DriveAddedOrChangeAsyncL, this ) );
|
|
2274 |
}
|
|
2275 |
}
|
|
2276 |
|
|
2277 |
// ---------------------------------------------------------------------------
|
|
2278 |
// CFileManagerEngine::StopDiskEventNotifyTimerAsync()
|
|
2279 |
// ---------------------------------------------------------------------------
|
|
2280 |
//
|
|
2281 |
void CFileManagerEngine::StopDiskEventNotifyTimerAsync()
|
|
2282 |
{
|
|
2283 |
if ( iDelayedDiskEventNotify != NULL )
|
|
2284 |
{
|
|
2285 |
iDelayedDiskEventNotify->Cancel();
|
|
2286 |
delete iDelayedDiskEventNotify;
|
|
2287 |
iDelayedDiskEventNotify = NULL;
|
|
2288 |
}
|
|
2289 |
}
|
|
2290 |
|
|
2291 |
// ---------------------------------------------------------------------------
|
|
2292 |
// CFileManagerEngine::IsDriverMounted()
|
|
2293 |
// ---------------------------------------------------------------------------
|
|
2294 |
//
|
|
2295 |
EXPORT_C TBool CFileManagerEngine::IsDriverMounted( TInt aDrive )
|
|
2296 |
{
|
|
2297 |
TVolumeInfo volInfo;
|
|
2298 |
return ( KErrNone == iFs.Volume( volInfo, aDrive ) );
|
|
2299 |
}
|
|
2300 |
|
|
2301 |
// End of File
|