36 #include "cmmmtpdpaccesssingleton.h" |
36 #include "cmmmtpdpaccesssingleton.h" |
37 #include "mmmtpdputility.h" |
37 #include "mmmtpdputility.h" |
38 #include "cabstractmediamtpdataproviderrenameobject.h" |
38 #include "cabstractmediamtpdataproviderrenameobject.h" |
39 #include "mmmtpdpdefs.h" |
39 #include "mmmtpdpdefs.h" |
40 #include "mmmtpdpfiledefs.h" |
40 #include "mmmtpdpfiledefs.h" |
|
41 #include "cabstractmediamtpdataproviderpropertysettingutility.h" |
|
42 #include "cabstractmediamtpdataproviderdescriptionutility.h" |
41 |
43 |
42 // Class constants. |
44 // Class constants. |
43 // Defines the number of MTP Active Processors allowed |
45 // Defines the number of MTP Active Processors allowed |
44 static const TInt KMTPAbstractMediaDpSessionGranularity = 3; |
46 static const TInt KMTPAbstractMediaDpSessionGranularity = 3; |
45 static const TInt KAbstractMediaMtpDpArrayGranularity = 2; |
47 static const TInt KAbstractMediaMtpDpArrayGranularity = 2; |
72 iAbstractMediaEnumerator( NULL ), |
74 iAbstractMediaEnumerator( NULL ), |
73 iPendingEnumerations ( KAbstractMediaMtpDpArrayGranularity ), |
75 iPendingEnumerations ( KAbstractMediaMtpDpArrayGranularity ), |
74 iActiveProcessor( -1 ), |
76 iActiveProcessor( -1 ), |
75 iRenameObject( NULL ), |
77 iRenameObject( NULL ), |
76 iSupportedFormat( KAbstractMediaMtpDpArrayGranularity ), |
78 iSupportedFormat( KAbstractMediaMtpDpArrayGranularity ), |
77 iSupportedProperties( KAbstractMediaMtpDpArrayGranularity ) |
79 #ifdef MMMTPDP_ABSTRACTAUDIOALBUM_SUPPORT |
78 { |
80 iSupportedPropAbstractAlbum( KAbstractMediaMtpDpArrayGranularity ), |
|
81 #endif |
|
82 iSupportedPropPlaylist( KAbstractMediaMtpDpArrayGranularity ), |
|
83 iSupportedPropAll( KAbstractMediaMtpDpArrayGranularity ) |
|
84 { |
|
85 // Do nothing |
79 } |
86 } |
80 |
87 |
81 // ----------------------------------------------------------------------------- |
88 // ----------------------------------------------------------------------------- |
82 // CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider |
89 // CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider |
83 // Destructor |
90 // Destructor |
84 // ----------------------------------------------------------------------------- |
91 // ----------------------------------------------------------------------------- |
85 // |
92 // |
86 CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider() |
93 CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider() |
87 { |
94 { |
88 PRINT( _L( "MM MTP => CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider" ) ); |
95 PRINT( _L( "MM MTP => CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider" ) ); |
|
96 |
|
97 delete iPropSettingUtility; |
|
98 delete iDescriptionUtility; |
89 |
99 |
90 iPendingEnumerations.Close(); |
100 iPendingEnumerations.Close(); |
91 TInt count = iActiveProcessors.Count(); |
101 TInt count = iActiveProcessors.Count(); |
92 for ( TInt i = 0; i < count; i++ ) |
102 for ( TInt i = 0; i < count; i++ ) |
93 { |
103 { |
121 { |
135 { |
122 PRINT( _L( "MM MTP => CAbstractMediaMtpDataProvider::ConstructL" ) ); |
136 PRINT( _L( "MM MTP => CAbstractMediaMtpDataProvider::ConstructL" ) ); |
123 |
137 |
124 iAbstractMediaEnumerator = CAbstractMediaMtpDataProviderEnumerator::NewL( Framework(), *this ); |
138 iAbstractMediaEnumerator = CAbstractMediaMtpDataProviderEnumerator::NewL( Framework(), *this ); |
125 |
139 |
126 CMmMtpDpAccessSingleton::CreateL( Framework().Fs(), Framework() ); |
140 CMmMtpDpAccessSingleton::CreateL( Framework() ); |
127 |
141 |
128 GetSupportedFormatL(); |
142 GetSupportedFormatL(); |
129 GetSupportedPropertiesL(); |
143 GetSupportedPropertiesL(); |
|
144 GetAllSupportedPropL(); |
|
145 |
|
146 iPropSettingUtility = CAbstractMediaMtpDataProviderPropertySettingUtility::NewL(); |
|
147 iDescriptionUtility = CAbstractMediaMtpDataProviderDescriptionUtility::NewL(); |
130 |
148 |
131 PRINT( _L( "MM MTP <= CAbstractMediaMtpDataProvider::ConstructL" ) ); |
149 PRINT( _L( "MM MTP <= CAbstractMediaMtpDataProvider::ConstructL" ) ); |
132 } |
150 } |
133 |
151 |
134 // ----------------------------------------------------------------------------- |
152 // ----------------------------------------------------------------------------- |
156 { |
174 { |
157 switch ( aNotification ) |
175 switch ( aNotification ) |
158 { |
176 { |
159 case EMTPSessionClosed: |
177 case EMTPSessionClosed: |
160 PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProvider::ProcessNotificationL EMTPSessionClosed event recvd" ) ); |
178 PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProvider::ProcessNotificationL EMTPSessionClosed event recvd" ) ); |
161 |
|
162 SessionClosedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) ); |
179 SessionClosedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) ); |
163 break; |
180 break; |
164 |
181 |
165 case EMTPSessionOpened: |
182 case EMTPSessionOpened: |
166 PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProvider::ProcessNotificationL EMTPSessionOpened event recvd" ) ); |
183 PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProvider::ProcessNotificationL EMTPSessionOpened event recvd" ) ); |
167 |
|
168 SessionOpenedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) ); |
184 SessionOpenedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) ); |
169 break; |
185 break; |
170 |
186 |
171 case EMTPStorageAdded: |
187 case EMTPStorageAdded: |
172 break; |
188 break; |
199 |
215 |
200 __ASSERT_DEBUG( index != KErrNotFound, Panic( EMmMTPDpNoMatchingProcessor ) ); |
216 __ASSERT_DEBUG( index != KErrNotFound, Panic( EMmMTPDpNoMatchingProcessor ) ); |
201 |
217 |
202 MMmRequestProcessor* processor = iActiveProcessors[index]; |
218 MMmRequestProcessor* processor = iActiveProcessors[index]; |
203 iActiveProcessor = index; |
219 iActiveProcessor = index; |
204 // iActiveProcessorRemoved = EFalse; |
220 iActiveProcessorRemoved = EFalse; |
205 TBool result = processor->HandleRequestL( aRequest, aPhase ); |
221 TBool result = processor->HandleRequestL( aRequest, aPhase ); |
206 if( !iIsSessionOpen ) |
222 if ( !iIsSessionOpen ) |
207 { |
223 { |
208 processor->Release(); |
224 processor->Release(); |
209 } |
225 } |
210 // iActiveProcessorRemoved will be set to ETrue in the above function |
226 // iActiveProcessorRemoved will be set to ETrue in the above function |
211 // HandleRequestL(),such as SessionClose() |
227 // HandleRequestL(), such as SessionClose() |
212 // else if ( iActiveProcessorRemoved ) |
228 else if ( iActiveProcessorRemoved ) |
213 // { |
229 { |
214 // processor->Release(); // destroy the processor |
230 processor->Release(); // destroy the processor |
215 // } |
231 } |
216 else if ( result ) // destroy the processor |
232 else if ( result ) // destroy the processor |
217 { |
233 { |
218 processor->Release(); |
234 processor->Release(); |
219 iActiveProcessors.Remove( index ); |
235 iActiveProcessors.Remove( index ); |
220 } |
236 } |
229 void CAbstractMediaMtpDataProvider::SessionClosedL( const TMTPNotificationParamsSessionChange& aSession ) |
245 void CAbstractMediaMtpDataProvider::SessionClosedL( const TMTPNotificationParamsSessionChange& aSession ) |
230 { |
246 { |
231 iIsSessionOpen = EFalse; |
247 iIsSessionOpen = EFalse; |
232 TInt count = iActiveProcessors.Count(); |
248 TInt count = iActiveProcessors.Count(); |
233 PRINT1( _L( "MM MTP => CAbstractMediaMtpDataProvider::SessionClosedL, total processor count = %d" ), count ); |
249 PRINT1( _L( "MM MTP => CAbstractMediaMtpDataProvider::SessionClosedL, total processor count = %d" ), count ); |
234 for( TInt i = 0; i < count; i++ ) |
250 while ( count-- ) |
235 { |
251 { |
236 MMmRequestProcessor* processor = iActiveProcessors[i]; |
252 MMmRequestProcessor* processor = iActiveProcessors[count]; |
237 |
253 |
238 // replaced for the Request() is invalid sometimes |
|
239 // TUint32 sessionId( processor->Request().Uint32( TMTPTypeRequest::ERequestSessionID ) ); |
|
240 TUint32 sessionId = processor->SessionId(); |
254 TUint32 sessionId = processor->SessionId(); |
241 |
255 |
242 if ( ( sessionId == aSession.iMTPId ) |
256 if ( ( sessionId == aSession.iMTPId ) |
243 && ( processor->Connection().ConnectionId() |
257 && ( processor->Connection().ConnectionId() |
244 == aSession.iConnection.ConnectionId() ) ) |
258 == aSession.iConnection.ConnectionId() ) ) |
245 { |
259 { |
246 processor->UsbDisconnect(); // Rollback |
260 processor->UsbDisconnect(); // Rollback |
247 |
261 |
248 iActiveProcessors.Remove( i ); |
262 iActiveProcessors.Remove( count ); |
249 // if ( i == iActiveProcessor ) |
263 if ( count == iActiveProcessor ) |
250 // { |
264 { |
251 // iActiveProcessorRemoved = ETrue; |
265 iActiveProcessorRemoved = ETrue; |
252 // } |
266 iActiveProcessor = -1; // update iActiveProcessor |
253 // else |
267 } |
|
268 else |
254 { |
269 { |
255 processor->Release(); |
270 processor->Release(); |
256 } |
271 } |
257 } |
272 } |
258 } |
273 } |
470 return index; |
487 return index; |
471 } |
488 } |
472 |
489 |
473 // ----------------------------------------------------------------------------- |
490 // ----------------------------------------------------------------------------- |
474 // CAbstractMediaMtpDataProvider::GetWrapper |
491 // CAbstractMediaMtpDataProvider::GetWrapper |
475 // return the reference of CMmMtpDpMetadataAccessWrapper to enumerator |
492 // return wrapper references |
476 // ----------------------------------------------------------------------------- |
493 // ----------------------------------------------------------------------------- |
477 // |
494 // |
478 CMmMtpDpMetadataAccessWrapper& CAbstractMediaMtpDataProvider::GetWrapperL() |
495 CMmMtpDpMetadataAccessWrapper& CAbstractMediaMtpDataProvider::GetWrapperL() |
479 { |
496 { |
480 return CMmMtpDpAccessSingleton::GetAccessWrapperL(); |
497 return CMmMtpDpAccessSingleton::GetAccessWrapperL(); |
|
498 } |
|
499 |
|
500 // ----------------------------------------------------------------------------- |
|
501 // CAbstractMediaMtpDataProvider::PropSettingUtility |
|
502 // return The utility to setting properties |
|
503 // ----------------------------------------------------------------------------- |
|
504 // |
|
505 CPropertySettingUtility* CAbstractMediaMtpDataProvider::PropSettingUtility() |
|
506 { |
|
507 return iPropSettingUtility; |
|
508 } |
|
509 |
|
510 // ----------------------------------------------------------------------------- |
|
511 // CAbstractMediaMtpDataProvider::DescriptionUtility |
|
512 // return The utiltiy to setting descriptions |
|
513 // ----------------------------------------------------------------------------- |
|
514 // |
|
515 CDescriptionUtility* CAbstractMediaMtpDataProvider::DescriptionUtility() |
|
516 { |
|
517 return iDescriptionUtility; |
481 } |
518 } |
482 |
519 |
483 // --------------------------------------------------------------------------- |
520 // --------------------------------------------------------------------------- |
484 // CAbstractMediaMtpDataProvider::GetSupportedFormat |
521 // CAbstractMediaMtpDataProvider::GetSupportedFormat |
485 // |
522 // |
501 } |
538 } |
502 } |
539 } |
503 |
540 |
504 const RArray<TUint>* CAbstractMediaMtpDataProvider::GetSupportedPropertiesL( TUint32 aFormatCode ) const |
541 const RArray<TUint>* CAbstractMediaMtpDataProvider::GetSupportedPropertiesL( TUint32 aFormatCode ) const |
505 { |
542 { |
506 return &iSupportedProperties; |
543 if ( ( aFormatCode == EMTPFormatCodeM3UPlaylist ) || ( aFormatCode == EMTPFormatCodeAbstractAudioVideoPlaylist ) ) |
|
544 { |
|
545 return &iSupportedPropPlaylist; |
|
546 } |
|
547 #ifdef MMMTPDP_ABSTRACTAUDIOALBUM_SUPPORT |
|
548 else if ( aFormatCode == EMTPFormatCodeAbstractAudioAlbum ) |
|
549 { |
|
550 return &iSupportedPropAbstractAlbum; |
|
551 } |
|
552 #endif |
|
553 else |
|
554 { |
|
555 User::Leave( KErrNotSupported ); |
|
556 } |
|
557 // should never run to this line, just for avoiding warning. |
|
558 return NULL; |
507 } |
559 } |
508 |
560 |
509 // --------------------------------------------------------------------------- |
561 // --------------------------------------------------------------------------- |
510 // CAbstractMediaMtpDataProvider::GetSupportedPropertiesL |
562 // CAbstractMediaMtpDataProvider::GetSupportedPropertiesL |
511 // |
563 // |
512 // --------------------------------------------------------------------------- |
564 // --------------------------------------------------------------------------- |
513 // |
565 // |
514 void CAbstractMediaMtpDataProvider::GetSupportedPropertiesL() |
566 void CAbstractMediaMtpDataProvider::GetSupportedPropertiesL() |
515 { |
567 { |
516 iSupportedProperties.Reset(); |
568 #ifdef MMMTPDP_ABSTRACTAUDIOALBUM_SUPPORT |
|
569 iSupportedPropAbstractAlbum.Reset(); |
|
570 #endif |
|
571 iSupportedPropPlaylist.Reset(); |
517 |
572 |
518 TInt count = 0, i = 0; |
573 TInt count = 0, i = 0; |
519 count = sizeof( KMmMtpDpSupportedPropMandatoryAll ) / sizeof( TUint16 ); |
574 count = sizeof( KMmMtpDpSupportedPropMandatoryAll ) / sizeof( TUint16 ); |
520 for ( i = 0; i < count; i++ ) |
575 for ( i = 0; i < count; i++ ) |
521 { |
576 { |
522 InsertL( iSupportedProperties, KMmMtpDpSupportedPropMandatoryAll[i] ); |
577 #ifdef MMMTPDP_ABSTRACTAUDIOALBUM_SUPPORT |
|
578 InsertL( iSupportedPropAbstractAlbum, KMmMtpDpSupportedPropMandatoryAll[i] ); |
|
579 #endif |
|
580 InsertL( iSupportedPropPlaylist, KMmMtpDpSupportedPropMandatoryAll[i] ); |
523 } |
581 } |
524 |
582 |
525 count = sizeof( KMmMtpDpSupportedPropAdditionalAll ) / sizeof( TUint16 ); |
583 count = sizeof( KMmMtpDpSupportedPropAdditionalAll ) / sizeof( TUint16 ); |
526 for ( i = 0; i < count; i++ ) |
584 for ( i = 0; i < count; i++ ) |
527 { |
585 { |
528 InsertL( iSupportedProperties, KMmMtpDpSupportedPropAdditionalAll[i] ); |
586 #ifdef MMMTPDP_ABSTRACTAUDIOALBUM_SUPPORT |
529 } |
587 InsertL( iSupportedPropAbstractAlbum, KMmMtpDpSupportedPropAdditionalAll[i] ); |
|
588 #endif |
|
589 InsertL( iSupportedPropPlaylist, KMmMtpDpSupportedPropAdditionalAll[i] ); |
|
590 } |
|
591 |
|
592 #ifdef MMMTPDP_ABSTRACTAUDIOALBUM_SUPPORT |
|
593 count = sizeof( KMmMtpDpSupportedPropMandatoryALB ) / sizeof( TUint16 ); |
|
594 for ( i = 0; i < count; i++ ) |
|
595 { |
|
596 InsertL( iSupportedPropAbstractAlbum, KMmMtpDpSupportedPropMandatoryALB[i] ); |
|
597 } |
|
598 #endif |
530 } |
599 } |
531 |
600 |
532 // --------------------------------------------------------------------------- |
601 // --------------------------------------------------------------------------- |
533 // CAbstractMediaMtpDataProvider::GetAllSupportedProperties |
602 // CAbstractMediaMtpDataProvider::GetAllSupportedProperties |
534 // |
603 // |
535 // --------------------------------------------------------------------------- |
604 // --------------------------------------------------------------------------- |
536 // |
605 // |
537 const RArray<TUint>* CAbstractMediaMtpDataProvider::GetAllSupportedProperties() const |
606 const RArray<TUint>* CAbstractMediaMtpDataProvider::GetAllSupportedProperties() const |
538 { |
607 { |
539 return &iSupportedProperties; |
608 return &iSupportedPropAll; |
|
609 } |
|
610 |
|
611 void CAbstractMediaMtpDataProvider::GetAllSupportedPropL() |
|
612 { |
|
613 iSupportedPropAll.Reset(); |
|
614 |
|
615 TInt count = 0, i = 0; |
|
616 count = sizeof( KMmMtpDpSupportedPropMandatoryAll ) / sizeof( TUint16 ); |
|
617 for ( i = 0; i < count; i++ ) |
|
618 { |
|
619 InsertL( iSupportedPropAll, KMmMtpDpSupportedPropMandatoryAll[i] ); |
|
620 } |
|
621 |
|
622 count = sizeof( KMmMtpDpSupportedPropAdditionalAll ) / sizeof( TUint16 ); |
|
623 for ( i = 0; i < count; i++ ) |
|
624 { |
|
625 InsertL( iSupportedPropAll, KMmMtpDpSupportedPropAdditionalAll[i] ); |
|
626 } |
|
627 |
|
628 count = sizeof( KMmMtpDpSupportedPropMandatoryALB ) / sizeof( TUint16 ); |
|
629 for ( i = 0; i < count; i++ ) |
|
630 { |
|
631 InsertL( iSupportedPropAll, KMmMtpDpSupportedPropMandatoryALB[i] ); |
|
632 } |
540 } |
633 } |
541 |
634 |
542 // --------------------------------------------------------------------------- |
635 // --------------------------------------------------------------------------- |
543 // CMediaMtpDataProvider::GetDefaultStorageIdL |
636 // CMediaMtpDataProvider::GetDefaultStorageIdL |
544 // |
637 // |
550 TInt err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNum ); |
643 TInt err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNum ); |
551 PRINT2( _L( "MM MTP <> GetDefaultDrive, driveNum = %d, err = %d" ), driveNum, err ); |
644 PRINT2( _L( "MM MTP <> GetDefaultDrive, driveNum = %d, err = %d" ), driveNum, err ); |
552 |
645 |
553 TDriveInfo driveInfo; |
646 TDriveInfo driveInfo; |
554 User::LeaveIfError( Framework().Fs().Drive( driveInfo, driveNum ) ); |
647 User::LeaveIfError( Framework().Fs().Drive( driveInfo, driveNum ) ); |
|
648 PRINT3( _L( "driveInfo.iType = 0x%x, driveInfo.iDriveAtt = 0x%x, driveInfo.iMediaAtt = 0x%x" ), |
|
649 driveInfo.iType, |
|
650 driveInfo.iDriveAtt, |
|
651 driveInfo.iMediaAtt ); |
555 if( driveInfo.iType == EMediaNotPresent || driveInfo.iType == EMediaUnknown ) |
652 if( driveInfo.iType == EMediaNotPresent || driveInfo.iType == EMediaUnknown ) |
556 { |
653 { |
557 err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, driveNum ); |
654 err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, driveNum ); |
558 PRINT( _L( "MM MTP <> Memory card doesn't exist, set PhoneMemory to default" ) ); |
655 User::LeaveIfError( Framework().Fs().Drive( driveInfo, driveNum ) ); |
|
656 if( driveInfo.iType == EMediaNotPresent || driveInfo.iType == EMediaUnknown ) |
|
657 { |
|
658 err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, driveNum ); |
|
659 PRINT( _L( "MM MTP <> Memory card doesn't exist, set PhoneMemory to default" ) ); |
|
660 } |
559 } |
661 } |
560 |
662 |
561 return Framework().StorageMgr().FrameworkStorageId( TDriveNumber( driveNum ) ); |
663 return Framework().StorageMgr().FrameworkStorageId( TDriveNumber( driveNum ) ); |
562 } |
664 } |
563 |
665 |