|
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: media mtp data provider |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <mtp/mmtpconnection.h> |
|
20 #include <mtp/mmtpdataproviderframework.h> |
|
21 #include <mtp/mmtpstoragemgr.h> |
|
22 #include <mtp/cmtpobjectmetadata.h> |
|
23 #include <mtp/mmtpobjectmgr.h> |
|
24 #include <barsc.h> |
|
25 #include <barsread.h> |
|
26 #include <driveinfo.h> |
|
27 |
|
28 #include "cmediamtpdataprovider.h" |
|
29 #include "mediamtpdataproviderconst.h" |
|
30 #include "cmediamtpdataproviderenumerator.h" |
|
31 #include "mmmtpdplogger.h" |
|
32 #include "tmmmtpdppanic.h" |
|
33 #include "cmmmtpdpaccesssingleton.h" |
|
34 #include "cmmmtpdpmetadataaccesswrapper.h" |
|
35 #include "mmmtpdputility.h" |
|
36 #include "crenameobject.h" |
|
37 #include "mmmtpdpdefs.h" |
|
38 #include "mmmtpdpfiledefs.h" |
|
39 |
|
40 // Class constants. |
|
41 // Defines the number of MTP Active Processors allowed |
|
42 static const TInt KMediaMtpDataProviderSessionGranularity = 3; |
|
43 static const TInt KMediaMtpDpArrayGranularity = 2; |
|
44 |
|
45 static const TInt KActiveEnumeration = 0; |
|
46 _LIT( KMediaMtpDataProviderExtension1, "microsoft.com/WMPPD: 11.0" ); |
|
47 _LIT( KMediaMtpDataProviderExtension2, "vodafone.com/omadrmv2: 1.0" ); |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CMediaMtpDataProvider::NewL |
|
51 // Two Phase Construction |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 TAny* CMediaMtpDataProvider::NewL( TAny* aParams ) |
|
55 { |
|
56 CMediaMtpDataProvider* self = new ( ELeave ) CMediaMtpDataProvider( aParams ); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop( self ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CMediaMtpDataProvider::CMediaMtpDataProvider |
|
65 // Standard C++ constructor |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CMediaMtpDataProvider::CMediaMtpDataProvider( TAny* aParams ) : |
|
69 CMTPDataProviderPlugin( aParams ), |
|
70 iActiveProcessors( KMediaMtpDataProviderSessionGranularity ), |
|
71 iMediaEnumerator( NULL ), |
|
72 iPendingEnumerations ( KMediaMtpDpArrayGranularity ), |
|
73 iActiveProcessor( -1 ), |
|
74 iRenameObject( NULL ), |
|
75 iSupportedFormat( KMediaMtpDpArrayGranularity ), |
|
76 iSupportedPropAudio( KMediaMtpDpArrayGranularity ), |
|
77 iSupportedPropVideo( KMediaMtpDpArrayGranularity ), |
|
78 iSupportedPropAll( KMediaMtpDpArrayGranularity ) |
|
79 { |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CMediaMtpDataProvider::~CMediaMtpDataProvider |
|
84 // Destructor |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 CMediaMtpDataProvider::~CMediaMtpDataProvider() |
|
88 { |
|
89 PRINT( _L( "MM MTP => CMediaMtpDataProvider::~CMediaMtpDataProvider" ) ); |
|
90 |
|
91 CMmMtpDpAccessSingleton::Release(); |
|
92 delete iMediaEnumerator; |
|
93 |
|
94 iPendingEnumerations.Close(); |
|
95 TInt count = iActiveProcessors.Count(); |
|
96 for ( TInt i = 0; i < count; i++ ) |
|
97 { |
|
98 iActiveProcessors[i]->Release(); |
|
99 } |
|
100 iActiveProcessors.Close(); |
|
101 |
|
102 if ( iRenameObject ) |
|
103 delete iRenameObject; |
|
104 |
|
105 iSupportedFormat.Close(); |
|
106 iSupportedPropAudio.Close(); |
|
107 iSupportedPropVideo.Close(); |
|
108 iSupportedPropAll.Close(); |
|
109 |
|
110 PRINT( _L( "MM MTP <= CMediaMtpDataProvider::~CMediaMtpDataProvider" ) ); |
|
111 } |
|
112 |
|
113 void CMediaMtpDataProvider::Cancel() |
|
114 { |
|
115 iMediaEnumerator->Cancel(); |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CMediaMtpDataProvider::ConstructL |
|
120 // Second-phase construction |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 void CMediaMtpDataProvider::ConstructL() |
|
124 { |
|
125 PRINT( _L( "MM MTP => CMediaMtpDataProvider::ConstructL" ) ); |
|
126 |
|
127 iMediaEnumerator = CMediaMtpDataProviderEnumerator::NewL( Framework(), *this ); |
|
128 |
|
129 CMmMtpDpAccessSingleton::CreateL( Framework().Fs(), Framework() ); |
|
130 |
|
131 GetSupportedFormatL(); |
|
132 GetSupportedPropL(); |
|
133 GetAllSupportedPropL(); |
|
134 |
|
135 PRINT( _L( "MM MTP <= CMediaMtpDataProvider::ConstructL" ) ); |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CMediaMtpDataProvider::ProcessEventL |
|
140 // Process event from initiator |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 void CMediaMtpDataProvider::ProcessEventL( const TMTPTypeEvent& aEvent, |
|
144 MMTPConnection& aConnection ) |
|
145 { |
|
146 TInt index = LocateRequestProcessorL( aEvent, aConnection ); |
|
147 if ( index != KErrNotFound ) |
|
148 { |
|
149 iActiveProcessors[index]->HandleEventL( aEvent ); |
|
150 } |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CMediaMtpDataProvider::ProcessNotificationL |
|
155 // Process notification from initiator |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CMediaMtpDataProvider::ProcessNotificationL( TMTPNotification aNotification, |
|
159 const TAny* aParams ) |
|
160 { |
|
161 switch ( aNotification ) |
|
162 { |
|
163 case EMTPSessionClosed: |
|
164 PRINT( _L( "MM MTP <> CMediaMtpDataProvider::ProcessNotificationL EMTPSessionClosed event recvd" ) ); |
|
165 |
|
166 SessionClosedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) ); |
|
167 break; |
|
168 |
|
169 case EMTPSessionOpened: |
|
170 PRINT( _L( "MM MTP <> CMediaMtpDataProvider::ProcessNotificationL EMTPSessionOpened event recvd" ) ); |
|
171 |
|
172 SessionOpenedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) ); |
|
173 break; |
|
174 |
|
175 case EMTPStorageAdded: |
|
176 break; |
|
177 |
|
178 case EMTPStorageRemoved: |
|
179 break; |
|
180 |
|
181 case EMTPRenameObject: |
|
182 PRINT( _L( "MM MTP <> CMediaMtpDataProvider::ProcessNotificationL EMTPRenameObject event recvd" ) ); |
|
183 RenameObjectL( *reinterpret_cast<const TMTPNotificationParamsHandle*> ( aParams ) ); |
|
184 break; |
|
185 |
|
186 default: |
|
187 PRINT( _L( "MM MTP <> CMediaMtpDataProvider::ProcessNotificationL default" ) ); |
|
188 // Ignore all other notifications. |
|
189 break; |
|
190 } |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CMediaMtpDataProvider::ProcessRequestPhaseL |
|
195 // Process the request from initiator |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 void CMediaMtpDataProvider::ProcessRequestPhaseL( TMTPTransactionPhase aPhase, |
|
199 const TMTPTypeRequest& aRequest, |
|
200 MMTPConnection& aConnection ) |
|
201 { |
|
202 TInt index = LocateRequestProcessorL( aRequest, aConnection ); |
|
203 |
|
204 __ASSERT_DEBUG( index != KErrNotFound, Panic(EMmMTPDpNoMatchingProcessor) ); |
|
205 |
|
206 MMmRequestProcessor* processor = iActiveProcessors[index]; |
|
207 iActiveProcessor = index; |
|
208 // iActiveProcessorRemoved = EFalse; |
|
209 TBool result = processor->HandleRequestL( aRequest, aPhase ); |
|
210 |
|
211 if( !iIsSessionOpen ) |
|
212 { |
|
213 processor->Release(); |
|
214 } |
|
215 |
|
216 else if ( result ) // destroy the processor |
|
217 { |
|
218 processor->Release(); |
|
219 iActiveProcessors.Remove( index ); |
|
220 } |
|
221 iActiveProcessor = -1; |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CMediaMtpDataProvider::SessionClosedL |
|
226 // Notify the data provider that the session has been closed |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 void CMediaMtpDataProvider::SessionClosedL( const TMTPNotificationParamsSessionChange& aSession ) |
|
230 { |
|
231 iIsSessionOpen = EFalse; |
|
232 TInt count = iActiveProcessors.Count(); |
|
233 PRINT1( _L( "MM MTP => CMediaMtpDataProvider::SessionClosedL, total processor count = %d" ), count ); |
|
234 for( TInt i = 0; i < count; i++ ) |
|
235 { |
|
236 MMmRequestProcessor* processor = iActiveProcessors[i]; |
|
237 |
|
238 // replaced for the Request() is invalid sometimes |
|
239 // TUint32 sessionId( processor->Request().Uint32( TMTPTypeRequest::ERequestSessionID ) ); |
|
240 TUint32 sessionId = processor->SessionId(); |
|
241 |
|
242 if ( ( sessionId == aSession.iMTPId ) |
|
243 && ( processor->Connection().ConnectionId() |
|
244 == aSession.iConnection.ConnectionId() ) ) |
|
245 { |
|
246 processor->UsbDisconnect(); // Rollback |
|
247 |
|
248 iActiveProcessors.Remove( i ); |
|
249 processor->Release(); |
|
250 } |
|
251 } |
|
252 |
|
253 // introduce to cleanup DBs at each close session |
|
254 iMediaEnumerator->SessionClosedL(); |
|
255 PRINT( _L( "MM MTP <= CMediaMtpDataProvider::SessionClosedL" ) ); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CMediaMtpDataProvider::SessionOpenedL |
|
260 // Open Session operation |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 void CMediaMtpDataProvider::SessionOpenedL( const TMTPNotificationParamsSessionChange& /*aSession*/) |
|
264 { |
|
265 CMmMtpDpAccessSingleton::OpenSessionL(); |
|
266 iIsSessionOpen = ETrue; |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // CMediaMtpDataProvider::RenameObjectL |
|
271 // Process the changed folder |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 void CMediaMtpDataProvider::RenameObjectL( const TMTPNotificationParamsHandle& aObject ) |
|
275 { |
|
276 PRINT2( _L( "MM MTP => CMediaMtpDataProvider::RenameObjectL folder handle=0x%x, modified name=%S" ), aObject.iHandleId, &(aObject.iFileName) ); |
|
277 |
|
278 if ( !iRenameObject ) |
|
279 { |
|
280 iRenameObject = CRenameObject::NewL( Framework(), GetWrapperL() ); |
|
281 } |
|
282 |
|
283 iRenameObject->StartL( aObject.iHandleId, aObject.iFileName ); |
|
284 |
|
285 PRINT( _L( "MM MTP <= CMediaMtpDataProvider::RenameObjectL" ) ); |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // CMediaMtpDataProvider::StartObjectEnumerationL |
|
290 // Start object enumeration |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 void CMediaMtpDataProvider::StartObjectEnumerationL( TUint32 aStorageId ) |
|
294 { |
|
295 iPendingEnumerations.AppendL( aStorageId ); |
|
296 |
|
297 if ( iPendingEnumerations.Count() > 0 ) |
|
298 { |
|
299 iMediaEnumerator->StartL( iPendingEnumerations[KActiveEnumeration] ); |
|
300 } |
|
301 } |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // CMediaMtpDataProvider::StartStorageEnumerationL |
|
305 // Start Storage enumeration |
|
306 // ----------------------------------------------------------------------------- |
|
307 // |
|
308 void CMediaMtpDataProvider::StartStorageEnumerationL() |
|
309 { |
|
310 Framework().StorageEnumerationCompleteL(); |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CMediaMtpDataProvider::Supported |
|
315 // Defines the supported operations and formats of the data provider |
|
316 // ----------------------------------------------------------------------------- |
|
317 // |
|
318 void CMediaMtpDataProvider::Supported( TMTPSupportCategory aCategory, |
|
319 RArray<TUint>& aArray ) const |
|
320 { |
|
321 switch ( aCategory ) |
|
322 { |
|
323 case EEvents: |
|
324 break; |
|
325 |
|
326 case EObjectCaptureFormats: |
|
327 case EObjectPlaybackFormats: |
|
328 { |
|
329 TInt count = sizeof( KMediaMtpDataProviderSupportedFormats ) / sizeof( TUint16 ); |
|
330 for ( TInt i = 0; i < count; i++ ) |
|
331 { |
|
332 aArray.Append( KMediaMtpDataProviderSupportedFormats[i] ); |
|
333 } |
|
334 PRINT1( _L( "MM MTP <> CMediaMtpDataProvider::Supported format count = %d" ), count ); |
|
335 } |
|
336 break; |
|
337 |
|
338 case EOperations: |
|
339 { |
|
340 TInt count = sizeof( KMediaMtpDataProviderSupportedOperations ) / sizeof( TUint16 ); |
|
341 |
|
342 for ( TInt i = 0; i < count; i++ ) |
|
343 { |
|
344 aArray.Append( KMediaMtpDataProviderSupportedOperations[i] ); |
|
345 } |
|
346 PRINT1( _L( "MM MTP <> CMediaMtpDataProvider::Supported operation count = %d" ), count ); |
|
347 } |
|
348 break; |
|
349 |
|
350 case EObjectProperties: |
|
351 { |
|
352 TInt count = iSupportedPropAll.Count(); |
|
353 |
|
354 for ( TInt i = 0; i < count; i++ ) |
|
355 { |
|
356 aArray.Append( iSupportedPropAll[i] ); |
|
357 } |
|
358 PRINT1( _L( "MM MTP <> CMediaMtpDataProvider::Supported properties count = %d" ), aArray.Count() ); |
|
359 } |
|
360 break; |
|
361 |
|
362 case EStorageSystemTypes: |
|
363 { |
|
364 aArray.Append( CMTPStorageMetaData::ESystemTypeDefaultFileSystem ); |
|
365 } |
|
366 break; |
|
367 |
|
368 default: |
|
369 // Unrecognised category, leave aArray unmodified. |
|
370 break; |
|
371 } |
|
372 } |
|
373 |
|
374 // ----------------------------------------------------------------------------- |
|
375 // CMediaMtpDataProvider::SupportedL |
|
376 // Defines the supported operations and formats of the data provider |
|
377 // ----------------------------------------------------------------------------- |
|
378 // |
|
379 void CMediaMtpDataProvider::SupportedL( TMTPSupportCategory aCategory, |
|
380 CDesCArray& aStrings ) const |
|
381 { |
|
382 if ( aCategory == EVendorExtensionSets ) |
|
383 { |
|
384 aStrings.AppendL( KMediaMtpDataProviderExtension1 ); |
|
385 aStrings.AppendL( KMediaMtpDataProviderExtension2 ); |
|
386 } |
|
387 else if( aCategory == EFormatExtensionSets ) |
|
388 { |
|
389 //EMTPFormatCodeMP3, |
|
390 aStrings.AppendL(KFormatExtensionMP3); |
|
391 |
|
392 #ifdef __WINDOWS_MEDIA |
|
393 //EMTPFormatCodeWMA, |
|
394 aStrings.AppendL(KFormatExtensionWMA); |
|
395 #endif |
|
396 |
|
397 //EMTPFormatCodeMP4Container, |
|
398 aStrings.AppendL(KFormatExtensionMP4); |
|
399 aStrings.AppendL(KFormatExtensionM4A); |
|
400 |
|
401 //EMTPFormatCode3GPContainer, |
|
402 aStrings.AppendL(KFormatExtension3GP); |
|
403 |
|
404 //EMTPFormatCodeAAC, |
|
405 aStrings.AppendL(KFormatExtensionAAC); |
|
406 |
|
407 //EMTPFormatCodeWAV, |
|
408 aStrings.AppendL(KFormatExtensionWAV); |
|
409 #ifdef __WINDOWS_MEDIA |
|
410 //EMTPFormatCodeWMV, |
|
411 aStrings.AppendL(KFormatExtensionWMV); |
|
412 |
|
413 //EMTPFormatCodeASF |
|
414 aStrings.AppendL(KFormatExtensionASF); |
|
415 #endif |
|
416 //ODF container |
|
417 aStrings.AppendL(KFormatExtensionODFAudio3GPP); |
|
418 aStrings.AppendL(KFormatExtensionODFAudioMP4); |
|
419 aStrings.AppendL(KFormatExtensionODFVideo3GPP); |
|
420 aStrings.AppendL(KFormatExtensionODFVideoMP4); |
|
421 |
|
422 aStrings.AppendL(KFormatExtensionO4A); |
|
423 aStrings.AppendL(KFormatExtensionO4V); |
|
424 |
|
425 } |
|
426 } |
|
427 |
|
428 // ----------------------------------------------------------------------------- |
|
429 // CMediaMtpDataProvider::NotifyEnumerationCompleteL |
|
430 // enumeration completed |
|
431 // ----------------------------------------------------------------------------- |
|
432 // |
|
433 void CMediaMtpDataProvider::NotifyEnumerationCompleteL( TUint32 /*aStorageId*/, |
|
434 TInt /*aError*/ ) |
|
435 { |
|
436 Framework().ObjectEnumerationCompleteL( iPendingEnumerations[KActiveEnumeration] ); |
|
437 iPendingEnumerations.Remove( KActiveEnumeration ); |
|
438 if ( iPendingEnumerations.Count() ) |
|
439 { |
|
440 iMediaEnumerator->StartL( iPendingEnumerations[KActiveEnumeration] ); |
|
441 } |
|
442 } |
|
443 |
|
444 // ----------------------------------------------------------------------------- |
|
445 // CMediaMtpDataProvider::LocateRequestProcessorL |
|
446 // Find or create a request processor that can process the request |
|
447 // ----------------------------------------------------------------------------- |
|
448 // |
|
449 TInt CMediaMtpDataProvider::LocateRequestProcessorL( const TMTPTypeRequest& aRequest, |
|
450 MMTPConnection& aConnection ) |
|
451 { |
|
452 TInt index = KErrNotFound; |
|
453 TInt count = iActiveProcessors.Count(); |
|
454 for ( TInt i = 0; i < count; i++ ) |
|
455 { |
|
456 if ( iActiveProcessors[i]->Match( aRequest, aConnection ) ) |
|
457 { |
|
458 index = i; |
|
459 break; |
|
460 } |
|
461 } |
|
462 if ( index == KErrNotFound ) |
|
463 { |
|
464 MMmRequestProcessor* processor = |
|
465 MediaMtpDataProviderProcessor::CreateL( Framework(), |
|
466 aRequest, |
|
467 aConnection, |
|
468 *this ); |
|
469 |
|
470 CleanupReleasePushL( *processor ); |
|
471 iActiveProcessors.AppendL( processor ); |
|
472 CleanupStack::Pop( processor ); |
|
473 index = count; |
|
474 } |
|
475 |
|
476 return index; |
|
477 } |
|
478 |
|
479 // ----------------------------------------------------------------------------- |
|
480 // CMediaMtpDataProvider::LocateRequestProcessorL |
|
481 // Find or create a request processor that can process the event |
|
482 // ----------------------------------------------------------------------------- |
|
483 // |
|
484 TInt CMediaMtpDataProvider::LocateRequestProcessorL( const TMTPTypeEvent& aEvent, |
|
485 MMTPConnection& aConnection ) |
|
486 { |
|
487 TInt index = KErrNotFound; |
|
488 TInt count = iActiveProcessors.Count(); |
|
489 for ( TInt i = 0; i < count; i++ ) |
|
490 { |
|
491 if ( iActiveProcessors[i]->Match( aEvent, aConnection ) ) |
|
492 { |
|
493 index = i; |
|
494 break; |
|
495 } |
|
496 } |
|
497 |
|
498 return index; |
|
499 } |
|
500 |
|
501 // ----------------------------------------------------------------------------- |
|
502 // CMediaMtpDataProvider::GetWrapper |
|
503 // return the reference of CMmMtpDpMetadataAccessWrapper to enumerator |
|
504 // ----------------------------------------------------------------------------- |
|
505 // |
|
506 CMmMtpDpMetadataAccessWrapper& CMediaMtpDataProvider::GetWrapperL() |
|
507 { |
|
508 return CMmMtpDpAccessSingleton::GetAccessWrapperL(); |
|
509 } |
|
510 |
|
511 // --------------------------------------------------------------------------- |
|
512 // CMediaMtpDataProvider::GetSupportedFormat |
|
513 // |
|
514 // --------------------------------------------------------------------------- |
|
515 // |
|
516 const RArray<TUint>* CMediaMtpDataProvider::GetSupportedFormat() const |
|
517 { |
|
518 PRINT1( _L( "MM MTP <> CMediaMtpDataProvider::GetSupportedFormat, count = %d" ), iSupportedFormat.Count() ); |
|
519 return &iSupportedFormat; |
|
520 } |
|
521 |
|
522 void CMediaMtpDataProvider::GetSupportedFormatL() |
|
523 { |
|
524 iSupportedFormat.Reset(); |
|
525 |
|
526 TInt count = sizeof ( KMediaMtpDataProviderSupportedFormats ) / sizeof( TUint16 ); |
|
527 for ( TInt i = 0; i < count; i++ ) |
|
528 { |
|
529 InsertL( iSupportedFormat, KMediaMtpDataProviderSupportedFormats[i] ); |
|
530 } |
|
531 } |
|
532 |
|
533 const RArray<TUint>* CMediaMtpDataProvider::GetSupportedPropertiesL( TUint32 aFormatCode ) const |
|
534 { |
|
535 switch ( aFormatCode ) |
|
536 { |
|
537 case EMTPFormatCodeWMA: |
|
538 case EMTPFormatCodeMP3: |
|
539 case EMTPFormatCodeAAC: |
|
540 case EMTPFormatCodeWAV: |
|
541 case EMTPFormatCodeMP4Container: |
|
542 case EMTPFormatCode3GPContainer: |
|
543 return &iSupportedPropAudio; |
|
544 |
|
545 case EMTPFormatCodeWMV: |
|
546 case EMTPFormatCodeASF: |
|
547 return &iSupportedPropVideo; |
|
548 |
|
549 default: |
|
550 { |
|
551 User::Leave( KErrNotSupported ); |
|
552 } |
|
553 } |
|
554 // should never run to this line, just for avoiding warning. |
|
555 return NULL; |
|
556 } |
|
557 |
|
558 // --------------------------------------------------------------------------- |
|
559 // CMediaMtpDataProvider::GetSupportedPropL |
|
560 // |
|
561 // --------------------------------------------------------------------------- |
|
562 // |
|
563 void CMediaMtpDataProvider::GetSupportedPropL() |
|
564 { |
|
565 iSupportedPropAudio.Reset(); |
|
566 iSupportedPropVideo.Reset(); |
|
567 |
|
568 TInt count = 0, i = 0; |
|
569 count = sizeof( KMmMtpDpSupportedPropMandatoryAll ) / sizeof( TUint16 ); |
|
570 for ( i = 0; i < count; i++ ) |
|
571 { |
|
572 InsertL( iSupportedPropAudio, KMmMtpDpSupportedPropMandatoryAll[i] ); |
|
573 InsertL( iSupportedPropVideo, KMmMtpDpSupportedPropMandatoryAll[i] ); |
|
574 |
|
575 } |
|
576 |
|
577 count = sizeof( KMmMtpDpSupportedPropAdditionalAll ) / sizeof( TUint16 ); |
|
578 for ( i = 0; i < count; i++ ) |
|
579 { |
|
580 InsertL( iSupportedPropAudio, KMmMtpDpSupportedPropAdditionalAll[i] ); |
|
581 InsertL( iSupportedPropVideo, KMmMtpDpSupportedPropAdditionalAll[i] ); |
|
582 } |
|
583 |
|
584 for ( TInt j = 0; j < iSupportedFormat.Count(); j++ ) |
|
585 { |
|
586 switch ( iSupportedFormat[j] ) |
|
587 { |
|
588 case EMTPFormatCodeWMA: |
|
589 case EMTPFormatCodeMP3: |
|
590 case EMTPFormatCodeAAC: |
|
591 case EMTPFormatCodeWAV: |
|
592 case EMTPFormatCodeMP4Container: |
|
593 case EMTPFormatCode3GPContainer: |
|
594 { |
|
595 count = sizeof ( KMmMtpDpSupportedPropMandatoryAudio ) / sizeof( TUint16 ); |
|
596 for ( i = 0; i < count; i++ ) |
|
597 { |
|
598 InsertL( iSupportedPropAudio, KMmMtpDpSupportedPropMandatoryAudio[i] ); |
|
599 } |
|
600 |
|
601 count = sizeof ( KMmMtpDpSupportedPropAdditionalAudio ) / sizeof(TUint16); |
|
602 for ( i = 0; i < count; i++ ) |
|
603 { |
|
604 InsertL( iSupportedPropAudio, KMmMtpDpSupportedPropAdditionalAudio[i] ); |
|
605 } |
|
606 } |
|
607 break; |
|
608 |
|
609 case EMTPFormatCodeWMV: |
|
610 case EMTPFormatCodeASF: |
|
611 { |
|
612 count = sizeof ( KMmMtpDpSupportedPropMandatoryWMV ) / sizeof(TUint16); |
|
613 for ( i = 0; i < count; i++ ) |
|
614 { |
|
615 InsertL( iSupportedPropVideo, KMmMtpDpSupportedPropMandatoryWMV[i] ); |
|
616 } |
|
617 |
|
618 count = sizeof ( KMmMtpDpSupportedPropAdditionalWMV ) / sizeof(TUint16); |
|
619 for ( i = 0; i < count; i++ ) |
|
620 { |
|
621 InsertL( iSupportedPropVideo, KMmMtpDpSupportedPropAdditionalWMV[i] ); |
|
622 } |
|
623 } |
|
624 break; |
|
625 |
|
626 default: |
|
627 { |
|
628 // shouldn't happen |
|
629 User::Leave( KErrNotSupported ); |
|
630 } |
|
631 break; |
|
632 } |
|
633 } |
|
634 } |
|
635 |
|
636 // --------------------------------------------------------------------------- |
|
637 // CMediaMtpDataProvider::GetAllSupportedProperties |
|
638 // |
|
639 // --------------------------------------------------------------------------- |
|
640 // |
|
641 const RArray<TUint>* CMediaMtpDataProvider::GetAllSupportedProperties() const |
|
642 { |
|
643 return &iSupportedPropAll; |
|
644 } |
|
645 |
|
646 void CMediaMtpDataProvider::GetAllSupportedPropL() |
|
647 { |
|
648 iSupportedPropAll.Reset(); |
|
649 |
|
650 TInt i = 0; |
|
651 TInt count = sizeof( KMmMtpDpSupportedPropMandatoryAll ) / sizeof( TUint16 ); |
|
652 for ( i = 0; i < count; i++ ) |
|
653 InsertL( iSupportedPropAll, KMmMtpDpSupportedPropMandatoryAll[i] ); |
|
654 |
|
655 count = sizeof ( KMmMtpDpSupportedPropAdditionalAll ) / sizeof(TUint16); |
|
656 for ( i = 0; i < count; i++ ) |
|
657 InsertL( iSupportedPropAll, KMmMtpDpSupportedPropAdditionalAll[i] ); |
|
658 |
|
659 count = sizeof ( KMmMtpDpSupportedPropMandatoryAudio ) / sizeof(TUint16); |
|
660 for ( i = 0; i < count; i++ ) |
|
661 InsertL( iSupportedPropAll, KMmMtpDpSupportedPropMandatoryAudio[i] ); |
|
662 |
|
663 count = sizeof ( KMmMtpDpSupportedPropAdditionalAudio ) / sizeof(TUint16); |
|
664 for ( i = 0; i < count; i++ ) |
|
665 InsertL( iSupportedPropAll, KMmMtpDpSupportedPropAdditionalAudio[i] ); |
|
666 |
|
667 count = sizeof ( KMmMtpDpSupportedPropMandatoryWMV ) / sizeof(TUint16); |
|
668 for ( i = 0; i < count; i++ ) |
|
669 InsertL( iSupportedPropAll, KMmMtpDpSupportedPropMandatoryWMV[i] ); |
|
670 |
|
671 count = sizeof ( KMmMtpDpSupportedPropAdditionalWMV ) / sizeof(TUint16); |
|
672 for ( i = 0; i < count; i++ ) |
|
673 InsertL( iSupportedPropAll, KMmMtpDpSupportedPropAdditionalWMV[i] ); |
|
674 } |
|
675 |
|
676 // --------------------------------------------------------------------------- |
|
677 // CMediaMtpDataProvider::GetDefaultStorageIdL |
|
678 // |
|
679 // --------------------------------------------------------------------------- |
|
680 // |
|
681 TUint32 CMediaMtpDataProvider::GetDefaultStorageIdL() const |
|
682 { |
|
683 TInt driveNum = -1; |
|
684 TInt err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNum ); |
|
685 PRINT2( _L( "MM MTP <> GetDefaultDrive, driveNum = %d, err = %d" ), driveNum, err ); |
|
686 |
|
687 TDriveInfo driveInfo; |
|
688 User::LeaveIfError( Framework().Fs().Drive( driveInfo, driveNum ) ); |
|
689 PRINT3( _L( "driveInfo.iType = 0x%x, driveInfo.iDriveAtt = 0x%x, driveInfo.iMediaAtt = 0x%x" ), |
|
690 driveInfo.iType, driveInfo.iDriveAtt, driveInfo.iMediaAtt ); |
|
691 if( driveInfo.iType == EMediaNotPresent || driveInfo.iType == EMediaUnknown ) |
|
692 { |
|
693 err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, driveNum ); |
|
694 User::LeaveIfError( Framework().Fs().Drive( driveInfo, driveNum ) ); |
|
695 if( driveInfo.iType == EMediaNotPresent || driveInfo.iType == EMediaUnknown ) |
|
696 { |
|
697 err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, driveNum ); |
|
698 PRINT( _L( "MM MTP <> Memory card doesn't exist, set PhoneMemory to default" ) ); |
|
699 } |
|
700 } |
|
701 |
|
702 return Framework().StorageMgr().FrameworkStorageId( TDriveNumber( driveNum ) ); |
|
703 } |
|
704 |
|
705 // --------------------------------------------------------------------------- |
|
706 // CMediaMtpDataProvider::Insert |
|
707 // |
|
708 // --------------------------------------------------------------------------- |
|
709 // |
|
710 void CMediaMtpDataProvider::InsertL( RArray<TUint>& aArray, const TUint aProperCode ) const |
|
711 { |
|
712 TInt err = KErrNone; |
|
713 err = aArray.Find( aProperCode ); |
|
714 if ( err == KErrNotFound ) |
|
715 err = aArray.Append( aProperCode ); |
|
716 |
|
717 User::LeaveIfError( err ); |
|
718 } |
|
719 |
|
720 // end of file |