|
1 /* |
|
2 * Copyright (c) 2009 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: Enumerator objects |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <mtp/mmtpdataproviderframework.h> |
|
20 #include <mtp/mmtpobjectmgr.h> |
|
21 #include <mtp/mmtpstoragemgr.h> |
|
22 #include <mtp/cmtpobjectmetadata.h> |
|
23 #include <hal.h> |
|
24 |
|
25 #include "mediamtpdataproviderconst.h" |
|
26 #include "cmediamtpdataproviderenumerator.h" |
|
27 #include "cmediamtpdataprovider.h" |
|
28 #include "mmmtpdplogger.h" |
|
29 #include "mmmtpdputility.h" |
|
30 #include "cmmmtpdpaccesssingleton.h" |
|
31 #include "cmmmtpdpmetadataaccesswrapper.h" |
|
32 |
|
33 // Unit: microsecond |
|
34 const TInt KThresholdOfEnumerationLoopDuration = 1000 * 1000; // microsecond |
|
35 |
|
36 const TInt KMTPDriveGranularity = 5; |
|
37 const TInt KMediaDpArrayGranularity = 2; |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CMediaMtpDataProviderEnumerator::NewL |
|
41 // Two phase constructor |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CMediaMtpDataProviderEnumerator* CMediaMtpDataProviderEnumerator::NewL( MMTPDataProviderFramework& aFramework, |
|
45 CMediaMtpDataProvider& aDataProvider ) |
|
46 { |
|
47 PRINT( _L( "MM MTP => CMediaMtpDataProviderEnumerator::NewL" ) ); |
|
48 |
|
49 CMediaMtpDataProviderEnumerator* self = new ( ELeave ) CMediaMtpDataProviderEnumerator( aFramework, aDataProvider ); |
|
50 |
|
51 CleanupStack::PushL( self ); |
|
52 self->ConstructL(); |
|
53 CleanupStack::Pop( self ); |
|
54 |
|
55 PRINT( _L( "MM MTP <= CMediaMtpDataProviderEnumerator::NewL" ) ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CMediaMtpDataProviderEnumerator::CMediaMtpDataProviderEnumerator |
|
61 // Standard C++ Constructor |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CMediaMtpDataProviderEnumerator::CMediaMtpDataProviderEnumerator( MMTPDataProviderFramework& aFramework, |
|
65 CMediaMtpDataProvider& aDataProvider ) : |
|
66 CActive( EPriorityLow ), // EPriorityStandard ? sure? |
|
67 iFramework( aFramework ), |
|
68 iObjectMgr( aFramework.ObjectMgr() ), |
|
69 iDataProviderId( aFramework.DataProviderId() ), |
|
70 iDataProvider( aDataProvider ), |
|
71 iDirStack( KMediaDpArrayGranularity ), |
|
72 iStorages( KMediaDpArrayGranularity ), |
|
73 iScanningDir( EFalse ) |
|
74 { |
|
75 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderEnumerator::CMediaMtpDataProviderEnumerator, iDataProviderId = %d" ), iDataProviderId ); |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CMediaMtpDataProviderEnumerator::~CMediaMtpDataProviderEnumerator |
|
80 // destructor |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CMediaMtpDataProviderEnumerator::~CMediaMtpDataProviderEnumerator() |
|
84 { |
|
85 PRINT( _L( "MM MTP => CMediaMtpDataProviderEnumerator::~CMediaMtpDataProviderEnumerator" ) ); |
|
86 Cancel(); |
|
87 iDir.Close(); |
|
88 iDirStack.Close(); |
|
89 iStorages.Close(); |
|
90 |
|
91 #if defined(_DEBUG) || defined(MMMTPDP_PERFLOG) |
|
92 delete iPerfLog; |
|
93 #endif |
|
94 PRINT( _L( "MM MTP <= CMediaMtpDataProviderEnumerator::~CMediaMtpDataProviderEnumerator" ) ); |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // MediaMtpDataProviderEnumerator::StartL |
|
99 // Kick off the enumeration on the specified storage |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CMediaMtpDataProviderEnumerator::StartL( TUint32 aStorageId ) |
|
103 { |
|
104 PRINT1( _L( "MM MTP => CMediaMtpDataProviderEnumerator::StartL aStorageId = 0x%x" ), aStorageId ); |
|
105 |
|
106 MMTPStorageMgr& storageMgr( iFramework.StorageMgr() ); |
|
107 if ( aStorageId == KMTPStorageAll ) |
|
108 { |
|
109 // Retrieve the available logical StorageIDs |
|
110 RPointerArray<const CMTPStorageMetaData> storages; |
|
111 CleanupClosePushL( storages ); // + storages |
|
112 TMTPStorageMgrQueryParams params( KNullDesC, |
|
113 CMTPStorageMetaData::ESystemTypeDefaultFileSystem ); |
|
114 |
|
115 storageMgr.GetLogicalStoragesL( params, storages ); |
|
116 |
|
117 // Construct the StorageIDs list. |
|
118 for ( TInt i = 0; i < storages.Count(); i++ ) |
|
119 { |
|
120 iStorages.AppendL( storages[i]->Uint( CMTPStorageMetaData::EStorageId ) ); |
|
121 } |
|
122 CleanupStack::PopAndDestroy( &storages ); // - storages |
|
123 } |
|
124 else if ( aStorageId != KMTPNotSpecified32 ) |
|
125 { |
|
126 __ASSERT_DEBUG( storageMgr.ValidStorageId( aStorageId ), User::Invariant() ); |
|
127 |
|
128 const CMTPStorageMetaData& storage( storageMgr.StorageL( aStorageId ) ); |
|
129 |
|
130 if ( storage.Uint( CMTPStorageMetaData::EStorageSystemType ) |
|
131 == CMTPStorageMetaData::ESystemTypeDefaultFileSystem ) |
|
132 { |
|
133 if ( storageMgr.LogicalStorageId( aStorageId ) ) |
|
134 { |
|
135 // Logical StorageID. |
|
136 iStorages.AppendL( aStorageId ); |
|
137 } |
|
138 else |
|
139 { |
|
140 // Physical StorageID. Enumerate all eligible logical storages. |
|
141 const RArray<TUint>& logicalIds( storage.UintArray( CMTPStorageMetaData::EStorageLogicalIds ) ); |
|
142 |
|
143 for ( TInt i = 0; i < logicalIds.Count(); i++ ) |
|
144 { |
|
145 iStorages.AppendL( logicalIds[i] ); |
|
146 } |
|
147 } |
|
148 } |
|
149 } |
|
150 |
|
151 iStorageId = aStorageId; |
|
152 |
|
153 if ( iStorages.Count() > 0 ) |
|
154 { |
|
155 ScanStorageL( iStorages[0] ); |
|
156 } |
|
157 else |
|
158 { |
|
159 SignalCompleteL( iDataProvider ); |
|
160 } |
|
161 |
|
162 PRINT( _L( "MM MTP <= CMediaMtpDataProviderEnumerator::StartL" ) ); |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CMediaMtpDataProviderEnumerator::DoCancel() |
|
167 // Cancel the enumeration process |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 void CMediaMtpDataProviderEnumerator::DoCancel() |
|
171 { |
|
172 iDir.Close(); |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CMediaMtpDataProviderEnumerator::ScanStorageL |
|
177 // |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 void CMediaMtpDataProviderEnumerator::ScanStorageL( TUint32 aStorageId ) |
|
181 { |
|
182 const CMTPStorageMetaData& storage( iFramework.StorageMgr().StorageL( aStorageId ) ); |
|
183 |
|
184 __ASSERT_DEBUG( ( storage.Uint( CMTPStorageMetaData::EStorageSystemType ) == CMTPStorageMetaData::ESystemTypeDefaultFileSystem ), |
|
185 User::Invariant() ); |
|
186 |
|
187 TFileName root( storage.DesC( CMTPStorageMetaData::EStorageSuid ) ); |
|
188 PRINT2( _L("MM MTP <> CMediaMtpDataProviderEnumerator::ScanStorageL aStorageId = 0x%x, StorageSuid = %S"), aStorageId, &root ); |
|
189 |
|
190 iParentHandle = KMTPHandleNone; |
|
191 iPath.Set( root, NULL, NULL); |
|
192 iDir.Close(); |
|
193 User::LeaveIfError( iDir.Open( iFramework.Fs(), |
|
194 iPath.DriveAndPath(), |
|
195 KEntryAttNormal | KEntryAttDir ) ); |
|
196 ScanDirL(); |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CMediaMtpDataProviderEnumerator::ScanNextStorageL |
|
201 // |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 void CMediaMtpDataProviderEnumerator::ScanNextStorageL() |
|
205 { |
|
206 // If there are one or more unscanned storages left |
|
207 // (the currently scanned one is still on the list) |
|
208 if ( iStorages.Count() > 1 ) |
|
209 { |
|
210 // Round trip suppport |
|
211 const CMTPStorageMetaData& storage( iFramework.StorageMgr().StorageL( iStorages[0] ) ); |
|
212 TFileName root( storage.DesC( CMTPStorageMetaData::EStorageSuid ) ); |
|
213 GetModifiedContentL( root ); |
|
214 iDataProvider.GetWrapperL().UpdateMusicCollectionL(); |
|
215 |
|
216 iStorages.Remove( 0 ); |
|
217 ScanStorageL( iStorages[0] ); |
|
218 } |
|
219 else |
|
220 { |
|
221 |
|
222 // Round trip suppport |
|
223 const CMTPStorageMetaData& storage( iFramework.StorageMgr().StorageL( iStorages[0] ) ); |
|
224 TFileName root( storage.DesC( CMTPStorageMetaData::EStorageSuid ) ); |
|
225 GetModifiedContentL( root ); |
|
226 |
|
227 // We are done |
|
228 iStorages.Reset(); |
|
229 |
|
230 SignalCompleteL( iDataProvider ); |
|
231 } |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CMediaMtpDataProviderEnumerator::ScanDirL |
|
236 // |
|
237 // ----------------------------------------------------------------------------- |
|
238 // |
|
239 void CMediaMtpDataProviderEnumerator::ScanDirL() |
|
240 { |
|
241 PRINT( _L( "MM MTP => CMediaMtpDataProviderEnumerator::ScanDirL" ) ); |
|
242 |
|
243 StartEnumerationCount(); |
|
244 |
|
245 iFirstUnprocessed = 0; |
|
246 |
|
247 iScanningDir = ETrue; |
|
248 PERFLOGSTART( KDirectoryScan ); |
|
249 iDir.Read( iEntries, iStatus ); |
|
250 SetActive(); |
|
251 |
|
252 PRINT( _L( "MM MTP <= CMediaMtpDataProviderEnumerator::ScanDirL" ) ); |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CMediaMtpDataProviderEnumerator::ScanNextDirL |
|
257 // Recurse into the next directory on the stack |
|
258 // and scan it for entries. |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 void CMediaMtpDataProviderEnumerator::ScanNextDirL() |
|
262 { |
|
263 TInt count = iDirStack.Count(); |
|
264 |
|
265 if ( count == 0 ) |
|
266 { |
|
267 // No more directories on the stack, try the next storage |
|
268 ScanNextStorageL(); |
|
269 } |
|
270 else |
|
271 { |
|
272 TEntry* entry = iDirStack[count - 1]; |
|
273 if ( entry != NULL ) |
|
274 { |
|
275 |
|
276 // Empty TEntry, no more subdirectories in |
|
277 // the current path |
|
278 if ( entry->iName == KNullDesC ) |
|
279 { |
|
280 // Remove current dir from path |
|
281 iPath.PopDir(); |
|
282 iDirStack.Remove( count - 1 ); |
|
283 delete entry; |
|
284 entry = NULL; |
|
285 iDir.Close(); |
|
286 |
|
287 // Scan the next directory of the parent |
|
288 ScanNextDirL(); |
|
289 } |
|
290 // Going into a subdirectory of current |
|
291 else |
|
292 { |
|
293 // Add directory to path |
|
294 iPath.AddDir( entry->iName ); |
|
295 // Remove directory so we don't think it's a subdirectory |
|
296 iDirStack.Remove( count - 1 ); |
|
297 delete entry; |
|
298 entry = NULL; |
|
299 ScanNextSubdirL(); |
|
300 } |
|
301 } |
|
302 } |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // CMediaMtpDataProviderEnumerator::ScanNextSubdirL |
|
307 // Scan next sub dir |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 void CMediaMtpDataProviderEnumerator::ScanNextSubdirL() |
|
311 { |
|
312 PRINT( _L( "MM MTP => CMediaMtpDataProviderEnumerator::ScanNextSubdirL" ) ); |
|
313 |
|
314 // A empty (non-constructed) TEntry is our marker telling us to pop a directory |
|
315 // from iPath when we see this |
|
316 TEntry* entry = new TEntry( TEntry() ); |
|
317 |
|
318 User::LeaveIfNull( entry ); |
|
319 |
|
320 iDirStack.AppendL( entry ); |
|
321 |
|
322 // Leave with KErrNotFound if we don't find the object handle since it shouldn't be on the |
|
323 // dirstack if the entry wasn't added |
|
324 TPtrC suid = iPath.DriveAndPath().Left( iPath.DriveAndPath().Length() ); |
|
325 // Update the current parenthandle with object of the directory |
|
326 PERFLOGSTART( KObjectManagerObjectUid ); |
|
327 iParentHandle = iFramework.ObjectMgr().HandleL( suid ); |
|
328 PERFLOGSTOP( KObjectManagerObjectUid ); |
|
329 PRINT1( _L( "MM MTP <> iParentHandle = 0x%Lx" ), iParentHandle ); |
|
330 |
|
331 // Kick-off a scan of the next directory |
|
332 iDir.Close(); |
|
333 |
|
334 TInt err = iDir.Open( iFramework.Fs(), |
|
335 iPath.DriveAndPath(), |
|
336 KEntryAttNormal | KEntryAttDir ); |
|
337 |
|
338 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderEnumerator::ScanNextSubdirL, RDir::Open err = %d" ), err ); |
|
339 |
|
340 if ( err == KErrNone ) |
|
341 ScanDirL(); |
|
342 else |
|
343 { |
|
344 iEntries = TEntryArray(); |
|
345 |
|
346 TRequestStatus* status = &iStatus; |
|
347 User::RequestComplete( status, iStatus.Int() ); |
|
348 SetActive(); |
|
349 } |
|
350 |
|
351 |
|
352 PRINT( _L( "MM MTP <= CMediaMtpDataProviderEnumerator::ScanNextSubdirL" ) ); |
|
353 } |
|
354 |
|
355 // ----------------------------------------------------------------------------- |
|
356 // CMediaMtpDataProviderEnumerator::RunL |
|
357 // |
|
358 // ----------------------------------------------------------------------------- |
|
359 // |
|
360 void CMediaMtpDataProviderEnumerator::RunL() |
|
361 { |
|
362 if ( iScanningDir ) |
|
363 { |
|
364 PERFLOGSTOP( KDirectoryScan ); |
|
365 } |
|
366 |
|
367 iScanningDir = EFalse; |
|
368 if ( iEntries.Count() == 0 ) |
|
369 { |
|
370 // No entries to process, scan next dir or storage |
|
371 ScanNextDirL(); |
|
372 } |
|
373 else if ( iFirstUnprocessed < iEntries.Count() ) |
|
374 { |
|
375 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderEnumerator::RunL iFirstUnprocessed = %d" ), iFirstUnprocessed); |
|
376 TRAPD( err, ProcessEntriesL();); |
|
377 if ( err != KErrNone ) |
|
378 { |
|
379 iFirstUnprocessed++; |
|
380 } |
|
381 |
|
382 // Complete ourselves with current TRequestStatus |
|
383 // since we need to run again to either scan a new dir or drive |
|
384 // or process more entries |
|
385 TRequestStatus* status = &iStatus; |
|
386 User::RequestComplete( status, iStatus.Int() ); |
|
387 SetActive(); |
|
388 } |
|
389 else |
|
390 { |
|
391 switch ( iStatus.Int() ) |
|
392 { |
|
393 case KErrNone: |
|
394 // There are still entries left to be read |
|
395 ScanDirL(); |
|
396 break; |
|
397 |
|
398 case KErrEof: |
|
399 // There are no more entries |
|
400 default: |
|
401 // Error, ignore and continue with next dir |
|
402 ScanNextDirL(); |
|
403 break; |
|
404 } |
|
405 } |
|
406 } |
|
407 |
|
408 // ----------------------------------------------------------------------------- |
|
409 // CMediaMtpDataProviderEnumerator::RunError |
|
410 // |
|
411 // ----------------------------------------------------------------------------- |
|
412 // |
|
413 TInt CMediaMtpDataProviderEnumerator::RunError( TInt aError ) |
|
414 { |
|
415 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderEnumerator::RunError with error %d" ), aError ); |
|
416 |
|
417 TRAP_IGNORE( SignalCompleteL( iDataProvider ) ); |
|
418 |
|
419 return KErrNone; |
|
420 } |
|
421 |
|
422 // ----------------------------------------------------------------------------- |
|
423 // CMediaMtpDataProviderEnumerator::ConstructL |
|
424 // |
|
425 // ----------------------------------------------------------------------------- |
|
426 // |
|
427 void CMediaMtpDataProviderEnumerator::ConstructL() |
|
428 { |
|
429 CActiveScheduler::Add( this ); |
|
430 |
|
431 TTimeIntervalMicroSeconds32 tickPeriod = 0; |
|
432 TInt err = UserHal::TickPeriod(tickPeriod); |
|
433 |
|
434 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderEnumerator::ConstructL, UserHal::TickPeriod err = %d" ), err); |
|
435 User::LeaveIfError( err ); |
|
436 iTickPeriod = tickPeriod.Int(); |
|
437 |
|
438 #if defined(_DEBUG) || defined(MMMTPDP_PERFLOG) |
|
439 iPerfLog = CMmMtpDpPerfLog::NewL( _L( "MediaMtpDataProviderEnumerator" ) ); |
|
440 #endif |
|
441 } |
|
442 |
|
443 // ----------------------------------------------------------------------------- |
|
444 // CMediaMtpDataProviderEnumerator::SignalCompleteL |
|
445 // Called when the enumeration is completed |
|
446 // ----------------------------------------------------------------------------- |
|
447 // |
|
448 void CMediaMtpDataProviderEnumerator::SignalCompleteL( MMTPEnumerationCallback& aCallback, |
|
449 TInt aError/* = KErrNone*/) |
|
450 { |
|
451 // Enumeration completed on this drive |
|
452 aCallback.NotifyEnumerationCompleteL( iStorageId, aError ); |
|
453 } |
|
454 |
|
455 // ----------------------------------------------------------------------------- |
|
456 // CMediaMtpDataProviderEnumerator::ProcessEntriesL |
|
457 // Iterates iEntries adding entries as needed to object manager and iDirStack. |
|
458 // ----------------------------------------------------------------------------- |
|
459 // |
|
460 void CMediaMtpDataProviderEnumerator::ProcessEntriesL() |
|
461 { |
|
462 PRINT( _L( "MM MTP => CMediaMtpDataProviderEnumerator::ProcessEntriesL" ) ); |
|
463 |
|
464 TBuf<KMaxFileName> path = iPath.DriveAndPath(); |
|
465 |
|
466 while ( !IsOverThreshold() && iFirstUnprocessed < iEntries.Count() ) |
|
467 { |
|
468 const TEntry& entry = iEntries[iFirstUnprocessed]; |
|
469 path.Append( entry.iName ); |
|
470 PRINT1( _L( "MM MTP <> path = %S" ), &path ); |
|
471 |
|
472 TInt len = entry.iName.Length(); |
|
473 |
|
474 if ( entry.IsDir() ) |
|
475 { |
|
476 path.Append( '\\' ); |
|
477 ++len; |
|
478 |
|
479 // we don't need to process folder, just remember |
|
480 // the folder |
|
481 TEntry* dirEntry = new TEntry( entry ); |
|
482 User::LeaveIfNull( dirEntry ); |
|
483 iDirStack.AppendL( dirEntry ); |
|
484 } |
|
485 else if ( IsFileAccepted( path ) ) |
|
486 { |
|
487 AddEntryL( path ); |
|
488 } |
|
489 |
|
490 // Remove filename part |
|
491 path.SetLength( path.Length() - len ); |
|
492 |
|
493 iFirstUnprocessed++; |
|
494 } |
|
495 |
|
496 StartEnumerationCount(); |
|
497 PRINT( _L( "MM MTP <= CMediaMtpDataProviderEnumerator::ProcessEntriesL" ) ); |
|
498 } |
|
499 |
|
500 // ----------------------------------------------------------------------------- |
|
501 // CMediaMtpDataProviderEnumerator::AddEntryL |
|
502 // Add a file entry to the object store |
|
503 // ----------------------------------------------------------------------------- |
|
504 // |
|
505 void CMediaMtpDataProviderEnumerator::AddEntryL( const TDesC& aFullFileName ) |
|
506 { |
|
507 PRINT1( _L( "MM MTP => CMediaDataProviderEnumerator::AddEntryL aFullFileName = %S" ), &aFullFileName ); |
|
508 |
|
509 CMTPObjectMetaData* object( CMTPObjectMetaData::NewLC( iDataProviderId, |
|
510 iFormatCode, |
|
511 iStorages[0], |
|
512 aFullFileName ) ); // + object |
|
513 |
|
514 object->SetUint( CMTPObjectMetaData::EParentHandle, iParentHandle ); |
|
515 |
|
516 if ( ( iFormatCode == EMTPFormatCodeMP4Container ) |
|
517 || ( iFormatCode == EMTPFormatCode3GPContainer ) |
|
518 || ( iFormatCode == EMTPFormatCodeASF ) ) |
|
519 { |
|
520 TMmMtpSubFormatCode subFormatCode; |
|
521 |
|
522 // Note: Delay the file parsing until external enumeration phase to avoid time-out |
|
523 subFormatCode = EMTPSubFormatCodeUnknown; |
|
524 |
|
525 object->SetUint( CMTPObjectMetaData::EFormatSubCode, (TUint)subFormatCode ); |
|
526 } |
|
527 |
|
528 PERFLOGSTART( KObjectManagerInsert ); |
|
529 iObjectMgr.InsertObjectL( *object ); |
|
530 PERFLOGSTOP( KObjectManagerInsert ); |
|
531 |
|
532 CleanupStack::PopAndDestroy( object ); // - object |
|
533 |
|
534 PRINT1( _L( "MM MTP <= CMediaMtpDataProviderEnumerator::AddEntryL, entry inserted, iFormatCode = 0x%x" ), iFormatCode); |
|
535 } |
|
536 |
|
537 // ----------------------------------------------------------------------------- |
|
538 // CMediaMtpDataProviderEnumerator::GetObjectFormatCode |
|
539 // Returns a TMTPFormatCode for the requested object |
|
540 // ----------------------------------------------------------------------------- |
|
541 // |
|
542 TMTPFormatCode CMediaMtpDataProviderEnumerator::GetObjectFormatCode( const TDesC& aFullFileName ) |
|
543 { |
|
544 PRINT1( _L("MM MTP <> CMediaMtpDataProviderEnumerator::GetObjectFormatCodeL aFullFileName = %S"), &aFullFileName ); |
|
545 TMTPFormatCode formatCode = MmMtpDpUtility::FormatFromFilename( aFullFileName ); |
|
546 return formatCode; |
|
547 } |
|
548 |
|
549 // ----------------------------------------------------------------------------- |
|
550 // CMediaMtpDataProviderEnumerator::IsFileAccepted |
|
551 // Is the file format is supported by this Dp |
|
552 // ----------------------------------------------------------------------------- |
|
553 // |
|
554 TBool CMediaMtpDataProviderEnumerator::IsFileAccepted( const TDesC& aFullFileName ) |
|
555 { |
|
556 PERFLOGSTART(KFormatFilter); |
|
557 iFormatCode = GetObjectFormatCode( aFullFileName ); |
|
558 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderEnumerator::IsFileAcceptedL formatCode = 0x%x" ), iFormatCode ); |
|
559 TBool accepted = EFalse; |
|
560 TInt count = sizeof( KMediaMtpDataProviderSupportedFormats ) / sizeof( TUint16 ); |
|
561 for ( TInt i = 0; i < count; i++ ) |
|
562 { |
|
563 if ( iFormatCode == KMediaMtpDataProviderSupportedFormats[i] ) |
|
564 { |
|
565 accepted = ETrue; |
|
566 break; |
|
567 } |
|
568 } |
|
569 |
|
570 PERFLOGSTOP(KFormatFilter); |
|
571 return accepted; |
|
572 } |
|
573 |
|
574 // ----------------------------------------------------------------------------- |
|
575 // CMediaDpMtpEnumerator::StartEnumerationCount |
|
576 // start record system tick |
|
577 // ----------------------------------------------------------------------------- |
|
578 // |
|
579 void CMediaMtpDataProviderEnumerator::StartEnumerationCount() |
|
580 { |
|
581 iTickCountBegin = User::TickCount(); |
|
582 } |
|
583 |
|
584 // ----------------------------------------------------------------------------- |
|
585 // CMediaDpMtpEnumerator::IsOverThreshold |
|
586 // Is system tick more than the predefined value? |
|
587 // ----------------------------------------------------------------------------- |
|
588 // |
|
589 TBool CMediaMtpDataProviderEnumerator::IsOverThreshold() |
|
590 { |
|
591 TUint tcNow = User::TickCount(); |
|
592 |
|
593 if ( ( tcNow - iTickCountBegin ) * iTickPeriod >= KThresholdOfEnumerationLoopDuration ) |
|
594 { |
|
595 return ETrue; |
|
596 } |
|
597 else |
|
598 { |
|
599 return EFalse; |
|
600 } |
|
601 } |
|
602 |
|
603 // ----------------------------------------------------------------------------- |
|
604 // CMediaDpMtpEnumerator::GetModifiedContentL() |
|
605 // Get Modified Content and report to Framework |
|
606 // ----------------------------------------------------------------------------- |
|
607 // |
|
608 void CMediaMtpDataProviderEnumerator::GetModifiedContentL( const TDesC& aStorageRoot ) |
|
609 { |
|
610 PRINT( _L( "MM MTP => CMediaMtpDataProviderEnumerator::GetModifiedContentL" ) ); |
|
611 TInt arrayCount = 0; |
|
612 CDesCArray* modifiedContents = new ( ELeave ) CDesCArrayFlat( KMTPDriveGranularity ); |
|
613 CleanupStack::PushL( modifiedContents ); // + modifiedContents |
|
614 |
|
615 iDataProvider.GetWrapperL().GetModifiedContentL( aStorageRoot, arrayCount, *modifiedContents ); |
|
616 |
|
617 if ( arrayCount > 0 ) |
|
618 { |
|
619 CMTPObjectMetaData* object = CMTPObjectMetaData::NewLC(); // + object |
|
620 for ( TInt i = 0; i < arrayCount; i++ ) |
|
621 { |
|
622 |
|
623 if ( iFramework.ObjectMgr().ObjectL( ( *modifiedContents )[i], *object ) ) |
|
624 { |
|
625 object->SetUint( CMTPObjectMetaData::EObjectMetaDataUpdate , 1 ); |
|
626 iFramework.ObjectMgr().ModifyObjectL( *object ); |
|
627 } |
|
628 } |
|
629 |
|
630 CleanupStack::PopAndDestroy( object ); // - object |
|
631 } |
|
632 |
|
633 CleanupStack::PopAndDestroy( modifiedContents ); // - modifiedContents |
|
634 |
|
635 PRINT( _L( "MM MTP <= CMediaMtpDataProviderEnumerator::GetModifiedContentL" ) ); |
|
636 } |
|
637 |
|
638 // ----------------------------------------------------------------------------- |
|
639 // CMediaMtpDataProviderEnumerator::SessionClosedL |
|
640 // |
|
641 // ----------------------------------------------------------------------------- |
|
642 // |
|
643 void CMediaMtpDataProviderEnumerator::SessionClosedL() |
|
644 { |
|
645 iDataProvider.GetWrapperL().UpdateMusicCollectionL(); |
|
646 iDataProvider.GetWrapperL().CleanupDatabaseL(); |
|
647 } |
|
648 |
|
649 //end of file |