author | hgs |
Fri, 03 Sep 2010 20:07:59 -0500 | |
changeset 58 | c76ea6caa649 |
parent 27 | cbb1bfb7ebfb |
permissions | -rw-r--r-- |
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: Folder scanning class to scan files in the file system |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include <e32base.h> |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#include <mpxlog.h> |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
#include "mpxfolderscanner.h" |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include "mpxfileadditionobserver.h" |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#include "mpxfilescanstateobserver.h" |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include "mpxfhcommon.h" |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
// CONSTANTS |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
const TInt KFileNumBreakCount = 5; |
58 | 27 |
_LIT( KTxtBackSlash, "\\" ); |
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
// ======== LOCAL FUNCTIONS ======== |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
// RArray compare function to compare strings |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
static TInt CompareString(const TPath& aFirst, |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
const TPath& aSecond) |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
return aFirst.Compare( aSecond ); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
// ======== MEMBER FUNCTIONS ======== |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
44 |
// Constructor |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
47 |
CMPXFolderScanner::CMPXFolderScanner( MMPXFileAdditionObserver& aObserver, |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
MMPXFileScanStateObserver& aStateObs, |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
RFs& aFs ) : CActive(EPriorityNull), |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
iObserver( aObserver ), |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
iStateObserver( aStateObs ), |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
iFs( aFs ) |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
55 |
CActiveScheduler::Add(this); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
// 2nd Phase Constructor |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
void CMPXFolderScanner::ConstructL() |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
{ |
58 | 64 |
|
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
66 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
67 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
// Two Phased Constructor |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
70 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
CMPXFolderScanner* CMPXFolderScanner::NewL( MMPXFileAdditionObserver& aObserver, |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
MMPXFileScanStateObserver& aStateObs, |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
RFs& aFs ) |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
74 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
CMPXFolderScanner* self = new( ELeave ) CMPXFolderScanner( aObserver, |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
76 |
aStateObs, |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
aFs ); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
CleanupStack::PushL( self ); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
self->ConstructL(); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
CleanupStack::Pop( self ); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
81 |
return self; |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
82 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
83 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
84 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
85 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
86 |
// Destructor |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
87 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
88 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
89 |
CMPXFolderScanner::~CMPXFolderScanner() |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
90 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
Cancel(); |
58 | 92 |
iDirQueue.ResetAndDestroy(); |
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
93 |
iDrivesToScan.Close(); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
94 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
95 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
96 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
97 |
// Scans a list of drives for files |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
98 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
99 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
100 |
void CMPXFolderScanner::ScanL( RArray<TPath>& aDrives ) |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
101 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
102 |
MPX_DEBUG1("CMPXFolderScanner::ScanL <---"); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
103 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
104 |
// Copy all the other drives we want to scan |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
105 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
106 |
TInt count( aDrives.Count() ); |
58 | 107 |
MPX_DEBUG2("CMPXFolderScanner::ScanL aDrives %d",count); |
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
108 |
for( TInt i=0; i<count; ++i ) |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
109 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
110 |
// Check if we are already scanning this drive |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
111 |
TInt found( iDrivesToScan.FindInOrder( aDrives[i], CompareString ) ); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
112 |
if( found == KErrNotFound ) |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
113 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
114 |
iDrivesToScan.Append( aDrives[i] ); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
115 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
116 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
117 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
118 |
// If we were already scanning, don't do it again |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
119 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
120 |
if( !iScanning ) |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
121 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
122 |
// Setup the next drive to scan |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
123 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
124 |
if( !SetupNextDriveToScanL() ) |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
125 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
126 |
// Kick off the scanning |
58 | 127 |
iCurDirQueueEntry = iDirQueue[ 0 ]; |
128 |
iCurFullPath = iCurDirQueueEntry->iFullPath; |
|
129 |
ReadDirEntry(); |
|
130 |
||
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
131 |
// We've started scanning |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
132 |
iScanning = ETrue; |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
133 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
134 |
else |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
135 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
136 |
// Nothing to scan |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
137 |
DoScanCompleteL(KErrNone); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
138 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
139 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
140 |
MPX_DEBUG1("CMPXFolderScanner::ScanL --->"); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
141 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
142 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
143 |
// --------------------------------------------------------------------------- |
58 | 144 |
// Reads dir entries asynchronously |
145 |
// --------------------------------------------------------------------------- |
|
146 |
// |
|
147 |
void CMPXFolderScanner::ReadDirEntry() |
|
148 |
{ |
|
149 |
ASSERT( !IsActive() ); |
|
150 |
iCurDirQueueEntry->iDir.Read( iCurDirQueueEntry->iEntryArray, iStatus ); |
|
151 |
SetActive(); |
|
152 |
} |
|
153 |
||
154 |
// --------------------------------------------------------------------------- |
|
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
155 |
// Continue Scanning for more files |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
156 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
157 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
158 |
TBool CMPXFolderScanner::DoScanL() |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
159 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
160 |
MPX_DEBUG1("CMPXFolderScanner::DoScanL <---"); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
161 |
TBool done (EFalse); |
58 | 162 |
TBool blocked ( EFalse ); |
163 |
||
164 |
// read successfully |
|
165 |
if ( iStatus == KErrNone || iStatus == KErrEof ) |
|
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
166 |
{ |
58 | 167 |
TBuf<KMaxFileName> buffer; |
168 |
const TEntry* entry = NULL; |
|
169 |
TInt numEntries( iCurDirQueueEntry->iEntryArray.Count() ); |
|
170 |
||
171 |
// process the entry one by one |
|
172 |
while ( iCurDirQueueEntry->iPos < numEntries ) |
|
173 |
{ |
|
174 |
entry = iCurDirQueueEntry->NextEntry(); |
|
175 |
buffer.Zero(); |
|
176 |
||
177 |
// Generates the full name of the entry |
|
178 |
buffer.Append( *iCurFullPath ); |
|
179 |
buffer.Append( entry->iName ); |
|
180 |
||
181 |
if ( entry->IsDir() ) // entry is a directory |
|
182 |
{ |
|
183 |
buffer.Append( KTxtBackSlash ); |
|
184 |
||
185 |
blocked = iObserver.IsPathBlockedL( buffer ); |
|
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
186 |
|
58 | 187 |
if ( !blocked ) |
188 |
{ |
|
189 |
CDirQueueEntry* newEntry = CDirQueueEntry::NewL( buffer ); |
|
190 |
TInt err = newEntry->iDir.Open( iFs, |
|
191 |
buffer, |
|
192 |
KEntryAttNormal | KEntryAttDir ); |
|
193 |
if ( err == KErrNone ) |
|
194 |
{ |
|
195 |
CDirQueueEntry::PushL( iDirQueue, newEntry ); |
|
196 |
} |
|
197 |
else |
|
198 |
{ |
|
199 |
delete newEntry; |
|
200 |
} |
|
201 |
} |
|
202 |
} |
|
203 |
else // entry is a file |
|
204 |
{ |
|
205 |
TInt index = iObserver.IsMediaFileL( buffer ); |
|
206 |
if( KErrNotFound != index ) |
|
207 |
{ |
|
208 |
iObserver.HandleFileAdditionL( buffer, index ); |
|
209 |
} |
|
210 |
} |
|
211 |
if ( iCurDirQueueEntry->iPos % KFileNumBreakCount == 0 ) |
|
212 |
{ |
|
213 |
return done; |
|
214 |
} |
|
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
215 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
216 |
} |
58 | 217 |
|
218 |
// this dir has other entries to read |
|
219 |
if ( iStatus == KErrNone ) |
|
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
220 |
{ |
58 | 221 |
iCurDirQueueEntry->ResetPosition(); |
222 |
ReadDirEntry(); |
|
223 |
} |
|
224 |
||
225 |
// there is nothing to read or some error has occured during reading, |
|
226 |
// try to move to next dir |
|
227 |
else |
|
228 |
{ |
|
229 |
CDirQueueEntry::PopAndDestroy( iDirQueue ); |
|
230 |
if ( iDirQueue.Count() || !SetupNextDriveToScanL() ) |
|
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
231 |
{ |
58 | 232 |
iCurDirQueueEntry = iDirQueue[ 0 ]; |
233 |
iCurFullPath = iCurDirQueueEntry->iFullPath; |
|
234 |
ReadDirEntry(); |
|
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
235 |
} |
58 | 236 |
else // there is nothing to scan |
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
237 |
{ |
58 | 238 |
done = ETrue; |
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
239 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
240 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
241 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
242 |
MPX_DEBUG1("CMPXFolderScanner::DoScanL --->"); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
243 |
return done; |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
244 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
245 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
246 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
247 |
// Setup the object to scan the next directory |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
248 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
249 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
250 |
TBool CMPXFolderScanner::SetupNextDriveToScanL() |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
251 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
252 |
MPX_DEBUG1("CMPXFolderScanner::SetupNextDriveToScanL <---"); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
253 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
254 |
TBool done(EFalse); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
255 |
TBool blocked(EFalse); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
256 |
// Scan next drive |
58 | 257 |
while( iDrivesToScan.Count() && !iDirQueue.Count() ) |
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
258 |
{ |
58 | 259 |
TPath path = iDrivesToScan[0]; |
260 |
||
261 |
MPX_DEBUG1( "CMPXFolderScanner::SetupNextDriveToScanL path blocked?" ); |
|
262 |
blocked = iObserver.IsPathBlockedL( path ); |
|
263 |
MPX_DEBUG2( "CMPXFolderScanner::SetupNextDriveToScanL path blocked %i", |
|
264 |
blocked ); |
|
265 |
||
266 |
// If there was something to scan |
|
267 |
if( !blocked ) |
|
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
268 |
{ |
58 | 269 |
CDirQueueEntry* newEntry = CDirQueueEntry::NewL( path ); |
270 |
TInt err = newEntry->iDir.Open( iFs, |
|
271 |
path, |
|
272 |
KEntryAttNormal | KEntryAttDir ); |
|
273 |
if ( err == KErrNone ) |
|
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
274 |
{ |
58 | 275 |
CDirQueueEntry::PushL( iDirQueue, newEntry ); |
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
276 |
// Inform Observer of the new drive that we are scanning |
58 | 277 |
iObserver.HandleOpenDriveL( ::ExtractDrive(iDrivesToScan[0]), |
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
278 |
iDrivesToScan[0] ); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
279 |
} |
58 | 280 |
else |
281 |
{ |
|
282 |
delete newEntry; |
|
283 |
} |
|
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
284 |
} |
58 | 285 |
|
286 |
// Remove the 0th element |
|
287 |
iDrivesToScan.Remove(0); |
|
288 |
iDrivesToScan.Compress(); |
|
289 |
||
290 |
} |
|
291 |
||
292 |
if ( !iDirQueue.Count() ) |
|
293 |
{ |
|
294 |
done = ETrue; |
|
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
295 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
296 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
297 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
298 |
MPX_DEBUG1("CMPXFolderScanner::SetupNextDriveToScanL --->"); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
299 |
return done; |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
300 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
301 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
302 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
303 |
// Handle when scanning is complete |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
304 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
305 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
306 |
void CMPXFolderScanner::DoScanCompleteL( TInt aErr ) |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
307 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
308 |
MPX_DEBUG1("CMPXFolderScanner::DoScanCompleteL <---"); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
309 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
310 |
// Reset all arrays and data |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
311 |
iDrivesToScan.Reset(); |
58 | 312 |
iDirQueue.ResetAndDestroy(); |
313 |
||
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
314 |
// All done! |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
315 |
iScanning = EFalse; |
58 | 316 |
|
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
317 |
// Callback to observer |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
318 |
iStateObserver.HandleScanStateCompleteL( MMPXFileScanStateObserver::EScanFiles, |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
319 |
aErr ); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
320 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
321 |
MPX_DEBUG1("CMPXFolderScanner::DoScanCompleteL --->"); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
322 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
323 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
324 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
325 |
// From CActive |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
326 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
327 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
328 |
void CMPXFolderScanner::RunL() |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
329 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
330 |
MPX_DEBUG1("CMPXFolderScanner::RunL <---"); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
331 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
332 |
// Do more scanning |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
333 |
TBool done(EFalse); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
334 |
TRAPD( err, done = DoScanL() ); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
335 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
336 |
// We are all done |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
337 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
338 |
if( KErrNone != err || done ) |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
339 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
340 |
DoScanCompleteL( err ); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
341 |
} |
58 | 342 |
else if ( iCurDirQueueEntry->iPos ) // if( !done ) |
0
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
343 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
344 |
MPX_DEBUG1("CMPXFolderScanner::RunL -- Run again"); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
345 |
iStatus = KRequestPending; |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
346 |
SetActive(); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
347 |
TRequestStatus* status = &iStatus; |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
348 |
User::RequestComplete( status, KErrNone ); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
349 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
350 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
351 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
352 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
353 |
// From CActive |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
354 |
// --------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
355 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
356 |
void CMPXFolderScanner::DoCancel() |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
357 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
358 |
if( iScanning ) |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
359 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
360 |
// Callback to observer with the partial list? |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
361 |
TRAP_IGNORE( DoScanCompleteL( KErrCancel ) ); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
362 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
363 |
} |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
364 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
365 |
// ---------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
366 |
// Handles a leave occurring in the request completion event handler RunL() |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
367 |
// ---------------------------------------------------------------------------- |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
368 |
// |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
369 |
TInt CMPXFolderScanner::RunError(TInt aError) |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
370 |
{ |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
371 |
MPX_DEBUG2("CMPXFolderScanner::RunError(%d)", aError ); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
372 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
373 |
TRAP_IGNORE( DoScanCompleteL( aError ) ); |
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
374 |
|
a2952bb97e68
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
375 |
return KErrNone; |
58 | 376 |
} |
377 |
||
378 |
// --------------------------------------------------------------------------- |
|
379 |
// Two Phased Constructor |
|
380 |
// --------------------------------------------------------------------------- |
|
381 |
// |
|
382 |
CMPXFolderScanner::CDirQueueEntry* CMPXFolderScanner::CDirQueueEntry::NewL( |
|
383 |
const TDesC& aFullPath ) |
|
384 |
{ |
|
385 |
CDirQueueEntry* self = new ( ELeave ) CDirQueueEntry; |
|
386 |
CleanupStack::PushL( self ); |
|
387 |
self->ConstructL( aFullPath ); |
|
388 |
CleanupStack::Pop( self ); |
|
389 |
return self; |
|
390 |
} |
|
391 |
||
392 |
// --------------------------------------------------------------------------- |
|
393 |
// Destructor |
|
394 |
// --------------------------------------------------------------------------- |
|
395 |
// |
|
396 |
CMPXFolderScanner::CDirQueueEntry::~CDirQueueEntry() |
|
397 |
{ |
|
398 |
iDir.Close(); |
|
399 |
delete iFullPath; |
|
400 |
} |
|
401 |
||
402 |
// --------------------------------------------------------------------------- |
|
403 |
// Push a dir entry into a dir entry queue |
|
404 |
// --------------------------------------------------------------------------- |
|
405 |
// |
|
406 |
void CMPXFolderScanner::CDirQueueEntry::PushL( |
|
407 |
RPointerArray<CDirQueueEntry>& aDirQueue, |
|
408 |
CDirQueueEntry* aDirEntry ) |
|
409 |
{ |
|
410 |
aDirQueue.AppendL( aDirEntry ); |
|
411 |
} |
|
412 |
||
413 |
// --------------------------------------------------------------------------- |
|
414 |
// Pop and destroy a dir entry from a dir entry queue |
|
415 |
// --------------------------------------------------------------------------- |
|
416 |
// |
|
417 |
void CMPXFolderScanner::CDirQueueEntry::PopAndDestroy( |
|
418 |
RPointerArray< CDirQueueEntry >& aDirQueue ) |
|
419 |
{ |
|
420 |
CDirQueueEntry* entry = aDirQueue[ 0 ]; |
|
421 |
delete entry; |
|
422 |
aDirQueue.Remove( 0 ); |
|
423 |
} |
|
424 |
||
425 |
// --------------------------------------------------------------------------- |
|
426 |
// CMPXFolderScanner::CDirQueueEntry::NextEntry |
|
427 |
// --------------------------------------------------------------------------- |
|
428 |
// |
|
429 |
const TEntry* CMPXFolderScanner::CDirQueueEntry::NextEntry() |
|
430 |
{ |
|
431 |
const TEntry* entry = NULL; |
|
432 |
if ( iPos >= 0 && iPos < iEntryArray.Count() ) |
|
433 |
{ |
|
434 |
entry = &iEntryArray[ iPos++ ]; |
|
435 |
} |
|
436 |
return entry; |
|
437 |
} |
|
438 |
||
439 |
// --------------------------------------------------------------------------- |
|
440 |
// Reset the current position of entry array |
|
441 |
// --------------------------------------------------------------------------- |
|
442 |
// |
|
443 |
void CMPXFolderScanner::CDirQueueEntry::ResetPosition() |
|
444 |
{ |
|
445 |
iPos = 0; |
|
446 |
} |
|
447 |
||
448 |
// --------------------------------------------------------------------------- |
|
449 |
// Constructor |
|
450 |
// --------------------------------------------------------------------------- |
|
451 |
// |
|
452 |
CMPXFolderScanner::CDirQueueEntry::CDirQueueEntry() |
|
453 |
{ |
|
454 |
// Do nothing |
|
455 |
} |
|
456 |
||
457 |
// --------------------------------------------------------------------------- |
|
458 |
// 2nd Phase Contructor |
|
459 |
// --------------------------------------------------------------------------- |
|
460 |
// |
|
461 |
void CMPXFolderScanner::CDirQueueEntry::ConstructL( const TDesC& aFullPath ) |
|
462 |
{ |
|
463 |
iFullPath = aFullPath.AllocL(); |
|
464 |
} |