|
1 /* |
|
2 * Copyright (c) 2005-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: Filter GFLM items |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CFileManagerItemFilter.h" |
|
22 #include "CFileManagerEngine.h" |
|
23 #include "CGflmGroupItem.h" |
|
24 #include "CGflmFileSystemItem.h" |
|
25 #include "CGflmDriveItem.h" |
|
26 #include "CGflmGlobalActionItem.h" |
|
27 #include "CFileManagerCommonDefinitions.h" |
|
28 #include "FileManagerDebug.h" |
|
29 #include "TFileManagerDriveInfo.h" |
|
30 #include "CFileManagerFeatureManager.h" |
|
31 #include <filemanagerengine.rsg> |
|
32 #include <StringLoader.h> |
|
33 #include <pathinfo.h> |
|
34 #ifdef RD_MULTIPLE_DRIVE |
|
35 #include <driveinfo.h> |
|
36 #endif // RD_MULTIPLE_DRIVE |
|
37 |
|
38 |
|
39 // ======== MEMBER FUNCTIONS ======== |
|
40 |
|
41 // ---------------------------------------------------------------------------- |
|
42 // CFileManagerItemFilter::CFileManagerItemFilter |
|
43 // ---------------------------------------------------------------------------- |
|
44 // |
|
45 CFileManagerItemFilter::CFileManagerItemFilter( CFileManagerEngine& aEngine ) |
|
46 : iEngine( aEngine ) |
|
47 { |
|
48 } |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // CFileManagerItemFilter::ConstructL |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 void CFileManagerItemFilter::ConstructL() |
|
55 { |
|
56 // Phone memory root path |
|
57 iPhoneMemoryRootPath = PathInfo::PhoneMemoryRootPath().AllocL(); |
|
58 iInternalDefaultName = |
|
59 StringLoader::LoadL( R_TEXT_PHONE_MEMORY ); |
|
60 iRemovableDefaultName = |
|
61 StringLoader::LoadL( R_TEXT_MEMORY_CARD_DEFAULT ); |
|
62 } |
|
63 |
|
64 // ---------------------------------------------------------------------------- |
|
65 // CFileManagerItemFilter::NewL |
|
66 // ---------------------------------------------------------------------------- |
|
67 // |
|
68 CFileManagerItemFilter* CFileManagerItemFilter::NewL( |
|
69 CFileManagerEngine& aEngine ) |
|
70 { |
|
71 CFileManagerItemFilter* self = new( ELeave ) CFileManagerItemFilter( |
|
72 aEngine ); |
|
73 |
|
74 CleanupStack::PushL( self ); |
|
75 self->ConstructL(); |
|
76 CleanupStack::Pop( self ); |
|
77 |
|
78 return self; |
|
79 } |
|
80 |
|
81 // ---------------------------------------------------------------------------- |
|
82 // CFileManagerItemFilter::~CFileManagerItemFilter |
|
83 // ---------------------------------------------------------------------------- |
|
84 // |
|
85 CFileManagerItemFilter::~CFileManagerItemFilter() |
|
86 { |
|
87 delete iPhoneMemoryRootPath; |
|
88 delete iInternalDefaultName; |
|
89 delete iRemovableDefaultName; |
|
90 } |
|
91 |
|
92 // ---------------------------------------------------------------------------- |
|
93 // CFileManagerItemFilter::FilterItemL |
|
94 // ---------------------------------------------------------------------------- |
|
95 // |
|
96 TBool CFileManagerItemFilter::FilterItemL( |
|
97 CGflmGroupItem* aItem, |
|
98 TInt /*aGroupId*/, |
|
99 CGflmDriveItem* /*aDrive*/ ) |
|
100 { |
|
101 switch( aItem->Type() ) |
|
102 { |
|
103 case CGflmGroupItem::EGlobalActionItem: |
|
104 { |
|
105 CGflmGlobalActionItem* actItem = |
|
106 static_cast< CGflmGlobalActionItem* >( aItem ); |
|
107 switch( actItem->Id() ) |
|
108 { |
|
109 case EFileManagerBackupAction: |
|
110 { |
|
111 // Disable backup in embedded mode, because it messes up |
|
112 // backup and restore operations since embedded apps are closed. |
|
113 if ( iEngine.FeatureManager().IsEmbedded() ) |
|
114 { |
|
115 return EFalse; |
|
116 } |
|
117 actItem->SetIconId( EFileManagerBackupMainIcon ); |
|
118 break; |
|
119 } |
|
120 default: |
|
121 { |
|
122 break; |
|
123 } |
|
124 } |
|
125 break; |
|
126 } |
|
127 case CGflmGroupItem::EDirectory: |
|
128 { |
|
129 CGflmFileSystemItem* fsItem = |
|
130 static_cast< CGflmFileSystemItem* >( aItem ); |
|
131 fsItem->GetFullPath( iFileNameBuffer ); |
|
132 return !iEngine.IsSystemFolder( iFileNameBuffer ); |
|
133 } |
|
134 case CGflmGroupItem::EDrive: |
|
135 { |
|
136 CGflmDriveItem* drvItem = static_cast< CGflmDriveItem* >( aItem ); |
|
137 |
|
138 #ifndef RD_MULTIPLE_DRIVE |
|
139 const TVolumeInfo& vol( drvItem->VolumeInfo() ); |
|
140 TInt drive( drvItem->Drive() ); |
|
141 #endif // RD_MULTIPLE_DRIVE |
|
142 |
|
143 INFO_LOG1( "CFileManagerItemFilter::FilterItemL()-drive=%d", |
|
144 drvItem->Drive() ) |
|
145 |
|
146 INFO_LOG1( "CFileManagerItemFilter::FilterItemL()-driveAtt=%d", |
|
147 drvItem->VolumeInfo().iDrive.iDriveAtt ) |
|
148 |
|
149 INFO_LOG1( "CFileManagerItemFilter::FilterItemL()-mediaAtt=%d", |
|
150 drvItem->VolumeInfo().iDrive.iMediaAtt ) |
|
151 |
|
152 INFO_LOG1( "CFileManagerItemFilter::FilterItemL()-driveUniqueId=%u", |
|
153 drvItem->VolumeInfo().iUniqueID ) |
|
154 |
|
155 INFO_LOG1( "CFileManagerItemFilter::FilterItemL()-driveSize=%lu", |
|
156 drvItem->VolumeInfo().iSize ) |
|
157 |
|
158 INFO_LOG1( "CFileManagerItemFilter::FilterItemL()-VolumeStatus=%d", |
|
159 drvItem->VolumeStatus() ) |
|
160 |
|
161 INFO_LOG1( "CFileManagerItemFilter::FilterItemL()-DriveStatus=%d", |
|
162 drvItem->DriveStatus() ) |
|
163 |
|
164 #ifdef RD_MULTIPLE_DRIVE |
|
165 // Setup drive icon |
|
166 TUint driveStatus( drvItem->DriveStatus() ); |
|
167 if ( !( driveStatus & DriveInfo::EDriveUserVisible ) ) |
|
168 { |
|
169 ERROR_LOG( "CFileManagerItemFilter::FilterItemL()-Hidden-1" ) |
|
170 return EFalse; |
|
171 } |
|
172 TInt icon( 0 ); |
|
173 if ( driveStatus & DriveInfo::EDriveInternal ) |
|
174 { |
|
175 icon = EFileManagerPhoneMemoryMainIcon; |
|
176 if ( driveStatus & DriveInfo::EDriveExternallyMountable ) |
|
177 { |
|
178 icon = EFileManagerMassStorageMainIcon; |
|
179 } |
|
180 } |
|
181 else if ( driveStatus & DriveInfo::EDriveUsbMemory ) |
|
182 { |
|
183 icon = EFileManagerUsbMemoryMainIcon; |
|
184 } |
|
185 else if ( driveStatus & DriveInfo::EDriveRemovable ) |
|
186 { |
|
187 icon = EFileManagerMemoryCardNotPresentMainIcon; |
|
188 if ( driveStatus & DriveInfo::EDrivePresent ) |
|
189 { |
|
190 icon = EFileManagerMemoryCardPresentMainIcon; |
|
191 } |
|
192 } |
|
193 else if ( driveStatus & DriveInfo::EDriveRemote ) |
|
194 { |
|
195 icon = EFileManagerRemoteDriveMainIcon; |
|
196 } |
|
197 else |
|
198 { |
|
199 ERROR_LOG( "CFileManagerItemFilter::FilterItemL()-Hidden-2" ) |
|
200 return EFalse; |
|
201 } |
|
202 drvItem->SetIconId( icon ); |
|
203 // Setup root directory |
|
204 if ( PathInfo::GetRootPath( iFileNameBuffer, drvItem->Drive() ) != KErrNone ) |
|
205 { |
|
206 ERROR_LOG( "CFileManagerItemFilter::FilterItemL()-Hidden-3" ) |
|
207 return EFalse; |
|
208 } |
|
209 drvItem->SetRootDirectoryL( iFileNameBuffer ); |
|
210 INFO_LOG( "CFileManagerItemFilter::FilterItemL()-Visible" ) |
|
211 |
|
212 #else // RD_MULTIPLE_DRIVE |
|
213 |
|
214 TBool isPhoneMem( EFalse ); |
|
215 TPtrC root( drvItem->RootDirectory() ); |
|
216 TPtrC phoneMemRoot( *iPhoneMemoryRootPath ); |
|
217 TInt len( Min( root.Length(), phoneMemRoot.Length() ) ); |
|
218 if ( !root.CompareF( phoneMemRoot.Left( len ) ) ) |
|
219 { |
|
220 // Drive is defined to phone memory |
|
221 isPhoneMem = ETrue; |
|
222 drvItem->SetRootDirectoryL( *iPhoneMemoryRootPath ); |
|
223 } |
|
224 else if ( vol.iDrive.iDriveAtt & KDriveAttInternal ) |
|
225 { |
|
226 if ( drive == KFmgrRamDrive || drive == KFmgrRomDrive ) |
|
227 { |
|
228 // Drive is not allowed internal drive |
|
229 return EFalse; |
|
230 } |
|
231 } |
|
232 if ( vol.iDrive.iDriveAtt & KDriveAttSubsted ) |
|
233 { |
|
234 // Substed drives are not allowed |
|
235 return EFalse; |
|
236 } |
|
237 // Setup drive name |
|
238 if ( !drvItem->Name().Length() ) |
|
239 { |
|
240 if ( isPhoneMem ) |
|
241 { |
|
242 drvItem->SetLocalizedNameL( *iInternalDefaultName ); |
|
243 } |
|
244 else if ( ( vol.iDrive.iDriveAtt & KDriveAttRemovable ) || |
|
245 drive == KFmgrMemoryCardDrive ) |
|
246 { |
|
247 drvItem->SetLocalizedNameL( *iRemovableDefaultName ); |
|
248 } |
|
249 else |
|
250 { |
|
251 drvItem->SetLocalizedNameL( drvItem->RootDirectory() ); |
|
252 } |
|
253 } |
|
254 // Setup drive icon |
|
255 if ( isPhoneMem ) |
|
256 { |
|
257 drvItem->SetIconId( EFileManagerPhoneMemoryMainIcon ); |
|
258 } |
|
259 else if ( ( vol.iDrive.iDriveAtt & KDriveAttRemovable ) || |
|
260 drive == KFmgrMemoryCardDrive ) |
|
261 { |
|
262 if ( vol.iDrive.iType == EMediaNotPresent ) |
|
263 { |
|
264 drvItem->SetIconId( EFileManagerMemoryCardNotPresentMainIcon ); |
|
265 } |
|
266 else |
|
267 { |
|
268 drvItem->SetIconId( EFileManagerMemoryCardPresentMainIcon ); |
|
269 } |
|
270 } |
|
271 else if ( vol.iDrive.iDriveAtt & KDriveAttRemote ) |
|
272 { |
|
273 drvItem->SetIconId( EFileManagerRemoteDriveMainIcon ); |
|
274 } |
|
275 else |
|
276 { |
|
277 return EFalse; |
|
278 } |
|
279 INFO_LOG( "CFileManagerItemFilter::FilterItemL()-driveAllowed" ) |
|
280 |
|
281 #endif // RD_MULTIPLE_DRIVE |
|
282 break; |
|
283 } |
|
284 default: |
|
285 { |
|
286 break; |
|
287 } |
|
288 } |
|
289 return ETrue; |
|
290 } |
|
291 |
|
292 // End of File |