|
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: Meta data access wrapper |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <bautils.h> |
|
20 #include <e32math.h> |
|
21 #include <mtp/mmtpdataproviderframework.h> |
|
22 #include <e32property.h> |
|
23 #include <MtpPrivatePSKeys.h> |
|
24 |
|
25 #include "cmmmtpdpmetadataaccesswrapper.h" |
|
26 #include "cmmmtpdpmetadatampxaccess.h" |
|
27 #include "cmmmtpdpmetadatavideoaccess.h" |
|
28 #include "mmmtpdputility.h" |
|
29 #include "mmmtpdplogger.h" |
|
30 |
|
31 const TInt KMMMTPDummyFileArrayGranularity = 5; |
|
32 |
|
33 CMmMtpDpMetadataAccessWrapper* CMmMtpDpMetadataAccessWrapper::NewL( RFs& aRfs, |
|
34 MMTPDataProviderFramework& aFramework ) |
|
35 { |
|
36 CMmMtpDpMetadataAccessWrapper* me = new (ELeave) CMmMtpDpMetadataAccessWrapper( aRfs, aFramework ); |
|
37 CleanupStack::PushL( me ); |
|
38 me->ConstructL(); |
|
39 CleanupStack::Pop( me ); |
|
40 |
|
41 return me; |
|
42 } |
|
43 |
|
44 CMmMtpDpMetadataAccessWrapper::CMmMtpDpMetadataAccessWrapper( RFs& aRfs, |
|
45 MMTPDataProviderFramework& aFramework ) : |
|
46 iRfs( aRfs ), |
|
47 iFramework( aFramework ) |
|
48 { |
|
49 |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CMmMtpDpMetadataAccessWrapper::ConstructL |
|
54 // Second-phase |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 void CMmMtpDpMetadataAccessWrapper::ConstructL() |
|
58 { |
|
59 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::ConstructL" ) ); |
|
60 |
|
61 iMmMtpDpMetadataMpxAccess = CMmMtpDpMetadataMpxAccess::NewL( iRfs, iFramework ); |
|
62 |
|
63 iMmMtpDpMetadataVideoAccess = CMmMtpDpMetadataVideoAccess::NewL( iRfs ); |
|
64 |
|
65 iPlaylistArray = new ( ELeave ) CDesCArrayFlat( KMMMTPDummyFileArrayGranularity ); |
|
66 |
|
67 // Create the PS key to notify subscribers that MTP mode is activated |
|
68 _LIT_SECURITY_POLICY_C1(KKeyReadPolicy, ECapabilityReadUserData); |
|
69 _LIT_SECURITY_POLICY_C1(KKeyWritePolicy, ECapabilityWriteUserData); |
|
70 RProperty::Define( KMtpPSUid, |
|
71 KMtpPSStatus, |
|
72 RProperty::EInt, |
|
73 KKeyReadPolicy, |
|
74 KKeyWritePolicy); |
|
75 |
|
76 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::ConstructL" ) ); |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper |
|
81 // Destructor |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper() |
|
85 { |
|
86 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper" ) ); |
|
87 RemoveDummyFiles(); |
|
88 |
|
89 delete iPlaylistArray; |
|
90 |
|
91 delete iMmMtpDpMetadataVideoAccess; |
|
92 delete iMmMtpDpMetadataMpxAccess; |
|
93 |
|
94 // unblock MPX |
|
95 RProperty::Set( KMtpPSUid, |
|
96 KMtpPSStatus, |
|
97 EMtpPSStatusUninitialized); |
|
98 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper" ) ); |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CMmMtpDpMetadataAccessWrapper::SetPlaylist |
|
103 // Set playlist to DB |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 EXPORT_C void CMmMtpDpMetadataAccessWrapper::SetPlaylistL( const TDesC& aPlaylistFileName, CDesCArray& aRefFileArray ) |
|
107 { |
|
108 PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::SetPlaylistL aPlaylistFileName = %S" ), &aPlaylistFileName ); |
|
109 |
|
110 if ( !MmMtpDpUtility::IsVideoL( aPlaylistFileName, iFramework ) ) |
|
111 { |
|
112 iMmMtpDpMetadataMpxAccess->SetPlaylistL( aPlaylistFileName, aRefFileArray ); |
|
113 } |
|
114 |
|
115 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetPlaylistL" ) ); |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // CMmMtpDpMetadataAccessWrapper::AddMediaL |
|
120 // Gets a piece of metadata from the collection |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL( const TUint16 aPropCode, |
|
124 MMTPType& aNewData, |
|
125 const CMTPObjectMetaData& aObjectMetaData ) |
|
126 { |
|
127 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL" ) ); |
|
128 |
|
129 TPtrC fullFileName( aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ) ); |
|
130 if ( !MmMtpDpUtility::IsVideoL( fullFileName, iFramework ) ) |
|
131 { |
|
132 iMmMtpDpMetadataMpxAccess->GetObjectMetadataValueL( aPropCode, |
|
133 aNewData, |
|
134 aObjectMetaData ); |
|
135 } |
|
136 else |
|
137 { |
|
138 iMmMtpDpMetadataVideoAccess->GetObjectMetadataValueL( aPropCode, |
|
139 aNewData, |
|
140 aObjectMetaData ); |
|
141 } |
|
142 |
|
143 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL" ) ); |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL |
|
148 // Sets a piece of metadata in the collection |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL( const TUint16 aPropCode, |
|
152 const MMTPType& aNewData, |
|
153 const CMTPObjectMetaData& aObjectMetaData ) |
|
154 { |
|
155 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL" ) ); |
|
156 |
|
157 TPtrC fullFileName( aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ) ); |
|
158 if ( MmMtpDpUtility::IsVideoL( fullFileName, iFramework ) ) |
|
159 { |
|
160 iMmMtpDpMetadataVideoAccess->SetObjectMetadataValueL( aPropCode, |
|
161 aNewData, |
|
162 aObjectMetaData ); |
|
163 } |
|
164 else |
|
165 { |
|
166 iMmMtpDpMetadataMpxAccess->SetObjectMetadataValueL( aPropCode, |
|
167 aNewData, |
|
168 aObjectMetaData ); |
|
169 } |
|
170 |
|
171 |
|
172 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL" ) ); |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL |
|
177 // Renames the file part of a record in the collection database |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 EXPORT_C void CMmMtpDpMetadataAccessWrapper::RenameObjectL( const TDesC& aOldFileName, |
|
181 const TDesC& aNewFileName ) |
|
182 { |
|
183 PRINT2( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::RenameObjectL old = %S, new = %S" ), |
|
184 &aOldFileName, |
|
185 &aNewFileName ); |
|
186 |
|
187 TMTPFormatCode formatCode = MmMtpDpUtility::FormatFromFilename( aOldFileName ); |
|
188 if ( formatCode == EMTPFormatCodeWMV ) |
|
189 { |
|
190 iMmMtpDpMetadataVideoAccess->RenameRecordL( aOldFileName, aNewFileName ); |
|
191 } |
|
192 else |
|
193 { |
|
194 if ( !MmMtpDpUtility::IsVideoL( aNewFileName , iFramework ) ) |
|
195 { |
|
196 iMmMtpDpMetadataMpxAccess->RenameObjectL( aOldFileName, aNewFileName, formatCode ); |
|
197 } |
|
198 else |
|
199 { |
|
200 iMmMtpDpMetadataVideoAccess->RenameRecordL( aOldFileName, aNewFileName ); |
|
201 } |
|
202 } |
|
203 |
|
204 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RenameObjectL" ) ); |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL |
|
209 // Deletes metadata information associated with the object |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 void CMmMtpDpMetadataAccessWrapper::DeleteObjectL( const TDesC& aFullFileName, |
|
213 const TUint aFormatCode ) |
|
214 { |
|
215 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::DeleteObjectL" ) ); |
|
216 |
|
217 TMPXGeneralCategory category = Category( aFormatCode ); |
|
218 |
|
219 // Have to do this. File might not be in file system anymore, have to |
|
220 // reply on ObjectManager |
|
221 if ( ( aFormatCode == EMTPFormatCodeMP4Container ) |
|
222 || ( aFormatCode == EMTPFormatCode3GPContainer ) |
|
223 || ( aFormatCode == EMTPFormatCodeASF ) ) |
|
224 { |
|
225 if ( MmMtpDpUtility::IsVideoL( aFullFileName, iFramework ) ) |
|
226 { |
|
227 category = EMPXVideo; |
|
228 } |
|
229 else |
|
230 { |
|
231 category = EMPXSong; |
|
232 } |
|
233 } |
|
234 |
|
235 switch ( category ) |
|
236 { |
|
237 case EMPXPlaylist: |
|
238 case EMPXSong: |
|
239 { |
|
240 iMmMtpDpMetadataMpxAccess->DeleteObjectL( aFullFileName, category ); |
|
241 } |
|
242 break; |
|
243 |
|
244 case EMPXVideo: |
|
245 { |
|
246 iMmMtpDpMetadataVideoAccess->DeleteRecordL( aFullFileName ); |
|
247 } |
|
248 break; |
|
249 |
|
250 default: |
|
251 PRINT( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::DeleteObjectL default" ) ); |
|
252 break; |
|
253 } |
|
254 |
|
255 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::DeleteObjectL" ) ); |
|
256 } |
|
257 |
|
258 // --------------------------------------------------------------------------- |
|
259 // CMmMtpDpMetadataAccessWrapper::SetStorageRootL |
|
260 // Sets current Drive info |
|
261 // --------------------------------------------------------------------------- |
|
262 // |
|
263 void CMmMtpDpMetadataAccessWrapper::SetStorageRootL( const TDesC& aStorageRoot ) |
|
264 { |
|
265 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::SetStorageRootL" ) ); |
|
266 |
|
267 iMmMtpDpMetadataVideoAccess->SetStorageRootL( aStorageRoot ); |
|
268 iMmMtpDpMetadataMpxAccess->SetStorageRootL( aStorageRoot ); |
|
269 |
|
270 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetStorageRootL" ) ); |
|
271 } |
|
272 // ----------------------------------------------------------------------------- |
|
273 // CMmMtpDpMetadataMpxAccess::SetImageObjPropL |
|
274 // set image specific properties specific to videos |
|
275 // ----------------------------------------------------------------------------- |
|
276 // |
|
277 void CMmMtpDpMetadataAccessWrapper::SetImageObjPropL( const TDesC& aFullFileName, |
|
278 const TUint32 aWidth, |
|
279 const TUint32 aHeight ) |
|
280 { |
|
281 if ( MmMtpDpUtility::IsVideoL( aFullFileName, iFramework ) ) |
|
282 { |
|
283 iMmMtpDpMetadataVideoAccess->SetStorageRootL( aFullFileName ); |
|
284 iMmMtpDpMetadataVideoAccess->SetImageObjPropL( aFullFileName, aWidth, aHeight ); |
|
285 } |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // CMmMtpDpMetadataMpxAccess::GetImageObjPropL |
|
290 // get image specific properties specific to videos |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 void CMmMtpDpMetadataAccessWrapper::GetImageObjPropL( const TDesC& aFullFileName, |
|
294 TUint32& aWidth, |
|
295 TUint32& aHeight ) |
|
296 { |
|
297 if ( MmMtpDpUtility::IsVideoL( aFullFileName, iFramework ) ) |
|
298 { |
|
299 iMmMtpDpMetadataVideoAccess->SetStorageRootL( aFullFileName ); |
|
300 iMmMtpDpMetadataVideoAccess->GetImageObjPropL( aFullFileName, aWidth, aHeight ); |
|
301 } |
|
302 } |
|
303 // ----------------------------------------------------------------------------- |
|
304 // CMmMtpDpMetadataAccessWrapper::OpenSessionL |
|
305 // Called when the MTP session is initialised |
|
306 // ----------------------------------------------------------------------------- |
|
307 // |
|
308 void CMmMtpDpMetadataAccessWrapper::OpenSessionL() |
|
309 { |
|
310 iOpenSession = ETrue; |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CMmMtpDpMetadataAccessWrapper::CloseSessionL |
|
315 // |
|
316 // ----------------------------------------------------------------------------- |
|
317 // |
|
318 void CMmMtpDpMetadataAccessWrapper::CloseSessionL() |
|
319 { |
|
320 if ( iOpenSession ) |
|
321 { |
|
322 PRINT( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CloseSessionL close" ) ); |
|
323 iMmMtpDpMetadataVideoAccess->CloseSessionL(); |
|
324 iOpenSession = EFalse; |
|
325 } |
|
326 else |
|
327 { |
|
328 PRINT( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CloseSessionL alreay close" ) ); |
|
329 } |
|
330 } |
|
331 |
|
332 // --------------------------------------------------------------------------- |
|
333 // CMmMtpDpMetadataAccessWrapper::Category |
|
334 // Get category according format code |
|
335 // --------------------------------------------------------------------------- |
|
336 // |
|
337 TMPXGeneralCategory CMmMtpDpMetadataAccessWrapper::Category( const TUint aFormatCode ) |
|
338 { |
|
339 TMPXGeneralCategory category = EMPXNoCategory; |
|
340 switch ( aFormatCode ) |
|
341 { |
|
342 case EMTPFormatCodeMP3: |
|
343 case EMTPFormatCodeWAV: |
|
344 case EMTPFormatCodeWMA: |
|
345 case EMTPFormatCodeAAC: |
|
346 case EMTPFormatCodeASF: |
|
347 case EMTPFormatCodeMP4Container: |
|
348 case EMTPFormatCode3GPContainer: |
|
349 { |
|
350 category = EMPXSong; |
|
351 } |
|
352 break; |
|
353 |
|
354 case EMTPFormatCodeAbstractAudioVideoPlaylist: |
|
355 { |
|
356 category = EMPXPlaylist; |
|
357 } |
|
358 break; |
|
359 |
|
360 case EMTPFormatCodeWMV: |
|
361 { |
|
362 category = EMPXVideo; |
|
363 } |
|
364 break; |
|
365 |
|
366 default: |
|
367 break; |
|
368 } |
|
369 return category; |
|
370 } |
|
371 |
|
372 // --------------------------------------------------------------------------- |
|
373 // CMmMtpDpMetadataAccessWrapper::GetAllPlaylistL |
|
374 // |
|
375 // --------------------------------------------------------------------------- |
|
376 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetAllPlaylistL( const TDesC& aStoreRoot, CMPXMediaArray** aPlaylists ) |
|
377 { |
|
378 iMmMtpDpMetadataMpxAccess->GetAllPlaylistL( aStoreRoot, aPlaylists ); |
|
379 } |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // CMmMtpDpMetadataAccessWrapper::GetAllReferenceL |
|
383 // |
|
384 // --------------------------------------------------------------------------- |
|
385 //s |
|
386 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetAllReferenceL( CMPXMedia* aPlaylist, CDesCArray& aReferences ) |
|
387 { |
|
388 iMmMtpDpMetadataMpxAccess->GetAllReferenceL( aPlaylist, aReferences ); |
|
389 } |
|
390 |
|
391 // --------------------------------------------------------------------------- |
|
392 // CMmMtpDpMetadataAccessWrapper::GetPlaylistNameL |
|
393 // |
|
394 // --------------------------------------------------------------------------- |
|
395 // |
|
396 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetPlaylistNameL( CMPXMedia* aPlaylist, TDes& aPlaylistName ) |
|
397 { |
|
398 iMmMtpDpMetadataMpxAccess->GetPlaylistNameL( aPlaylist, aPlaylistName ); |
|
399 } |
|
400 |
|
401 // ----------------------------------------------------------------------------- |
|
402 // CMmMtpDpMetadataAccessWrapper::AddObjectL |
|
403 // Add object (music, video and playlist) info to DB |
|
404 // ----------------------------------------------------------------------------- |
|
405 // |
|
406 void CMmMtpDpMetadataAccessWrapper::AddObjectL( const TDesC& aFullFileName, TBool aIsVideo /*= EFalse */ ) |
|
407 { |
|
408 PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL aFullFileName = %S" ), &aFullFileName ); |
|
409 |
|
410 if ( aFullFileName.Length() <= 0) |
|
411 { |
|
412 User::Leave( KErrArgument ); |
|
413 } |
|
414 if ( aIsVideo ) |
|
415 { |
|
416 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL Addvideo" ) ); |
|
417 iMmMtpDpMetadataVideoAccess->AddVideoL( aFullFileName ); |
|
418 } |
|
419 else |
|
420 { |
|
421 if ( MmMtpDpUtility::IsVideoL( aFullFileName, iFramework ) ) |
|
422 { |
|
423 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL Addvideo" ) ); |
|
424 iMmMtpDpMetadataVideoAccess->AddVideoL( aFullFileName ); |
|
425 } |
|
426 else |
|
427 { |
|
428 TMTPFormatCode formatCode = MmMtpDpUtility::FormatFromFilename( aFullFileName ); |
|
429 |
|
430 if ( formatCode == EMTPFormatCodeM3UPlaylist |
|
431 || formatCode == EMTPFormatCodeMPLPlaylist |
|
432 || formatCode == EMTPFormatCodeAbstractAudioVideoPlaylist |
|
433 || formatCode == EMTPFormatCodeAbstractAudioPlaylist |
|
434 || formatCode == EMTPFormatCodeAbstractVideoPlaylist |
|
435 || formatCode == EMTPFormatCodeASXPlaylist |
|
436 || formatCode == EMTPFormatCodePLSPlaylist ) |
|
437 { |
|
438 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL AddPlaylist" ) ); |
|
439 iMmMtpDpMetadataMpxAccess->AddPlaylistL( aFullFileName ); |
|
440 } |
|
441 else |
|
442 { |
|
443 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL AddSong" ) ); |
|
444 iMmMtpDpMetadataMpxAccess->AddSongL( aFullFileName ); |
|
445 } |
|
446 } |
|
447 } |
|
448 |
|
449 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::AddObjectL" ) ); |
|
450 } |
|
451 |
|
452 // --------------------------------------------------------------------------- |
|
453 // CMmMtpDpMetadataAccessWrapper::GetModifiedContentL |
|
454 // Get Modified content |
|
455 // --------------------------------------------------------------------------- |
|
456 // |
|
457 EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetModifiedContentL( const TDesC& aStorageRoot, |
|
458 TInt& arrayCount, |
|
459 CDesCArray& aModifiedcontent ) |
|
460 { |
|
461 iMmMtpDpMetadataMpxAccess->SetStorageRootL( aStorageRoot ); |
|
462 iMmMtpDpMetadataMpxAccess->GetModifiedContentL( arrayCount, aModifiedcontent ); |
|
463 } |
|
464 |
|
465 EXPORT_C void CMmMtpDpMetadataAccessWrapper::CleanupDatabaseL() |
|
466 { |
|
467 iMmMtpDpMetadataVideoAccess->CleanupDatabaseL(); |
|
468 } |
|
469 |
|
470 // --------------------------------------------------------------------------- |
|
471 // CMmMtpDpMetadataAccessWrapper::IsExistL |
|
472 // if the playlsit exist in the MPX DB |
|
473 // --------------------------------------------------------------------------- |
|
474 // |
|
475 TBool CMmMtpDpMetadataAccessWrapper::IsExistL( const TDesC& aSuid ) |
|
476 { |
|
477 TParsePtrC parse( aSuid ); |
|
478 iMmMtpDpMetadataMpxAccess->SetStorageRootL( parse.Drive() ); |
|
479 return iMmMtpDpMetadataMpxAccess->IsExistL( aSuid ); |
|
480 } |
|
481 |
|
482 // ----------------------------------------------------------------------------- |
|
483 // CMmMtpDpMetadataAccessWrapper::AddDummyFile |
|
484 // Add one dummy file to dummy files array |
|
485 // ----------------------------------------------------------------------------- |
|
486 // |
|
487 EXPORT_C void CMmMtpDpMetadataAccessWrapper::AddDummyFileL( const TDesC& aDummyFileName ) |
|
488 { |
|
489 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::AddDummyFile aDummyFileName(%S)" ), &aDummyFileName ); |
|
490 iPlaylistArray->AppendL( aDummyFileName ); |
|
491 } |
|
492 |
|
493 // ----------------------------------------------------------------------------- |
|
494 // CMmMtpDpMetadataAccessWrapper::DeleteDummyFile |
|
495 // Delete one dummy file from dummy files array |
|
496 // ----------------------------------------------------------------------------- |
|
497 // |
|
498 EXPORT_C void CMmMtpDpMetadataAccessWrapper::DeleteDummyFile( const TDesC& aDummyFileName ) |
|
499 { |
|
500 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::DeleteDummyFile aDummyFileName(%S)" ), &aDummyFileName ); |
|
501 TInt pos = 0; |
|
502 if ( iPlaylistArray->Count() > 0 ) |
|
503 { |
|
504 if ( 0 == iPlaylistArray->Find( aDummyFileName, pos ) ) |
|
505 { |
|
506 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::DeleteDummyFile pos = %d" ), pos ); |
|
507 iPlaylistArray->Delete( pos ); |
|
508 } |
|
509 } |
|
510 } |
|
511 |
|
512 // ----------------------------------------------------------------------------- |
|
513 // CMmMtpDpMetadataAccessWrapper::CreateDummyFile |
|
514 // Create a Dummy File from the virtual playlist URI |
|
515 // ----------------------------------------------------------------------------- |
|
516 // |
|
517 EXPORT_C void CMmMtpDpMetadataAccessWrapper::CreateDummyFile( const TDesC& aPlaylistName ) |
|
518 { |
|
519 PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::CreateDummyFile, filename = %S" ), &aPlaylistName ); |
|
520 |
|
521 if ( MmMtpDpUtility::FormatFromFilename( aPlaylistName ) == |
|
522 EMTPFormatCodeAbstractAudioVideoPlaylist ) |
|
523 { |
|
524 RFile newfile; |
|
525 TInt err = newfile.Replace( iFramework.Fs(), aPlaylistName, EFileWrite ); |
|
526 |
|
527 if ( err != KErrNone ) |
|
528 { |
|
529 newfile.Close(); |
|
530 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile err = %d" ), err ); |
|
531 } |
|
532 else // File created OK |
|
533 { |
|
534 err = newfile.Flush(); |
|
535 newfile.Close(); |
|
536 err = iFramework.Fs().SetAtt( aPlaylistName, KEntryAttSystem | KEntryAttHidden, |
|
537 KEntryAttReadOnly | KEntryAttNormal ); |
|
538 if ( err != KErrNone ) |
|
539 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile Dummy Playlist file created. err = %d" ), err ); |
|
540 } |
|
541 } |
|
542 } |
|
543 |
|
544 // ----------------------------------------------------------------------------- |
|
545 // CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles |
|
546 // Remove all dummy file of which format is "pla", and leave the "m3u" |
|
547 // ----------------------------------------------------------------------------- |
|
548 // |
|
549 void CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles() |
|
550 { |
|
551 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) ); |
|
552 |
|
553 TInt count = iPlaylistArray->Count(); |
|
554 // Check if playlist file is a dummy file or an imported file |
|
555 for ( TInt i = 0; i < count; i++ ) |
|
556 { |
|
557 if ( MmMtpDpUtility::FormatFromFilename( (*iPlaylistArray)[i] ) != |
|
558 EMTPFormatCodeM3UPlaylist ) |
|
559 { |
|
560 // delete the virtual playlist |
|
561 // iFramework has release don't use iFramework.FS() |
|
562 TInt err = iRfs.Delete( (*iPlaylistArray)[i] ); |
|
563 |
|
564 PRINT2( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d" ), |
|
565 &( (*iPlaylistArray)[i] ), |
|
566 err ); |
|
567 } |
|
568 else |
|
569 { |
|
570 // leave the Imported playlist in the file system |
|
571 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile, Don't delete m3u file [%S]" ), &( (*iPlaylistArray)[i] ) ); |
|
572 } |
|
573 } |
|
574 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) ); |
|
575 } |
|
576 |
|
577 // --------------------------------------------------------------------------- |
|
578 // CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL |
|
579 // Update Music collection |
|
580 // --------------------------------------------------------------------------- |
|
581 // |
|
582 EXPORT_C void CMmMtpDpMetadataAccessWrapper::UpdateMusicCollectionL() |
|
583 { |
|
584 iMmMtpDpMetadataMpxAccess->UpdateMusicCollectionL( ); |
|
585 } |
|
586 |
|
587 // end of file |