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; |
74 iActiveProcessor( -1 ), |
76 iActiveProcessor( -1 ), |
75 iRenameObject( NULL ), |
77 iRenameObject( NULL ), |
76 iSupportedFormat( KAbstractMediaMtpDpArrayGranularity ), |
78 iSupportedFormat( KAbstractMediaMtpDpArrayGranularity ), |
77 iSupportedProperties( KAbstractMediaMtpDpArrayGranularity ) |
79 iSupportedProperties( KAbstractMediaMtpDpArrayGranularity ) |
78 { |
80 { |
|
81 // Do nothing |
79 } |
82 } |
80 |
83 |
81 // ----------------------------------------------------------------------------- |
84 // ----------------------------------------------------------------------------- |
82 // CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider |
85 // CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider |
83 // Destructor |
86 // Destructor |
84 // ----------------------------------------------------------------------------- |
87 // ----------------------------------------------------------------------------- |
85 // |
88 // |
86 CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider() |
89 CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider() |
87 { |
90 { |
88 PRINT( _L( "MM MTP => CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider" ) ); |
91 PRINT( _L( "MM MTP => CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider" ) ); |
|
92 |
|
93 delete iPropSettingUtility; |
|
94 delete iDescriptionUtility; |
89 |
95 |
90 iPendingEnumerations.Close(); |
96 iPendingEnumerations.Close(); |
91 TInt count = iActiveProcessors.Count(); |
97 TInt count = iActiveProcessors.Count(); |
92 for ( TInt i = 0; i < count; i++ ) |
98 for ( TInt i = 0; i < count; i++ ) |
93 { |
99 { |
126 CMmMtpDpAccessSingleton::CreateL( Framework().Fs(), Framework() ); |
132 CMmMtpDpAccessSingleton::CreateL( Framework().Fs(), Framework() ); |
127 |
133 |
128 GetSupportedFormatL(); |
134 GetSupportedFormatL(); |
129 GetSupportedPropertiesL(); |
135 GetSupportedPropertiesL(); |
130 |
136 |
|
137 iPropSettingUtility = CAbstractMediaMtpDataProviderPropertySettingUtility::NewL(); |
|
138 iDescriptionUtility = CAbstractMediaMtpDataProviderDescriptionUtility::NewL(); |
|
139 |
131 PRINT( _L( "MM MTP <= CAbstractMediaMtpDataProvider::ConstructL" ) ); |
140 PRINT( _L( "MM MTP <= CAbstractMediaMtpDataProvider::ConstructL" ) ); |
132 } |
141 } |
133 |
142 |
134 // ----------------------------------------------------------------------------- |
143 // ----------------------------------------------------------------------------- |
135 // CAbstractMediaMtpDataProvider::ProcessEventL |
144 // CAbstractMediaMtpDataProvider::ProcessEventL |
156 { |
165 { |
157 switch ( aNotification ) |
166 switch ( aNotification ) |
158 { |
167 { |
159 case EMTPSessionClosed: |
168 case EMTPSessionClosed: |
160 PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProvider::ProcessNotificationL EMTPSessionClosed event recvd" ) ); |
169 PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProvider::ProcessNotificationL EMTPSessionClosed event recvd" ) ); |
161 |
|
162 SessionClosedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) ); |
170 SessionClosedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) ); |
163 break; |
171 break; |
164 |
172 |
165 case EMTPSessionOpened: |
173 case EMTPSessionOpened: |
166 PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProvider::ProcessNotificationL EMTPSessionOpened event recvd" ) ); |
174 PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProvider::ProcessNotificationL EMTPSessionOpened event recvd" ) ); |
167 |
|
168 SessionOpenedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) ); |
175 SessionOpenedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) ); |
169 break; |
176 break; |
170 |
177 |
171 case EMTPStorageAdded: |
178 case EMTPStorageAdded: |
172 break; |
179 break; |
199 |
206 |
200 __ASSERT_DEBUG( index != KErrNotFound, Panic( EMmMTPDpNoMatchingProcessor ) ); |
207 __ASSERT_DEBUG( index != KErrNotFound, Panic( EMmMTPDpNoMatchingProcessor ) ); |
201 |
208 |
202 MMmRequestProcessor* processor = iActiveProcessors[index]; |
209 MMmRequestProcessor* processor = iActiveProcessors[index]; |
203 iActiveProcessor = index; |
210 iActiveProcessor = index; |
204 // iActiveProcessorRemoved = EFalse; |
211 iActiveProcessorRemoved = EFalse; |
205 TBool result = processor->HandleRequestL( aRequest, aPhase ); |
212 TBool result = processor->HandleRequestL( aRequest, aPhase ); |
206 if( !iIsSessionOpen ) |
213 if ( !iIsSessionOpen ) |
207 { |
214 { |
208 processor->Release(); |
215 processor->Release(); |
209 } |
216 } |
210 // iActiveProcessorRemoved will be set to ETrue in the above function |
217 // iActiveProcessorRemoved will be set to ETrue in the above function |
211 // HandleRequestL(),such as SessionClose() |
218 // HandleRequestL(), such as SessionClose() |
212 // else if ( iActiveProcessorRemoved ) |
219 else if ( iActiveProcessorRemoved ) |
213 // { |
220 { |
214 // processor->Release(); // destroy the processor |
221 processor->Release(); // destroy the processor |
215 // } |
222 } |
216 else if ( result ) // destroy the processor |
223 else if ( result ) // destroy the processor |
217 { |
224 { |
218 processor->Release(); |
225 processor->Release(); |
219 iActiveProcessors.Remove( index ); |
226 iActiveProcessors.Remove( index ); |
220 } |
227 } |
229 void CAbstractMediaMtpDataProvider::SessionClosedL( const TMTPNotificationParamsSessionChange& aSession ) |
236 void CAbstractMediaMtpDataProvider::SessionClosedL( const TMTPNotificationParamsSessionChange& aSession ) |
230 { |
237 { |
231 iIsSessionOpen = EFalse; |
238 iIsSessionOpen = EFalse; |
232 TInt count = iActiveProcessors.Count(); |
239 TInt count = iActiveProcessors.Count(); |
233 PRINT1( _L( "MM MTP => CAbstractMediaMtpDataProvider::SessionClosedL, total processor count = %d" ), count ); |
240 PRINT1( _L( "MM MTP => CAbstractMediaMtpDataProvider::SessionClosedL, total processor count = %d" ), count ); |
234 for( TInt i = 0; i < count; i++ ) |
241 for ( TInt i = 0; i < count; i++ ) |
235 { |
242 { |
236 MMmRequestProcessor* processor = iActiveProcessors[i]; |
243 MMmRequestProcessor* processor = iActiveProcessors[i]; |
237 |
244 |
238 // replaced for the Request() is invalid sometimes |
245 // replaced for the Request() is invalid sometimes |
239 // TUint32 sessionId( processor->Request().Uint32( TMTPTypeRequest::ERequestSessionID ) ); |
246 // TUint32 sessionId( processor->Request().Uint32( TMTPTypeRequest::ERequestSessionID ) ); |
240 TUint32 sessionId = processor->SessionId(); |
247 TUint32 sessionId = processor->SessionId(); |
241 |
248 |
242 if ( ( sessionId == aSession.iMTPId ) |
249 if ( ( sessionId == aSession.iMTPId ) |
243 && ( processor->Connection().ConnectionId() |
250 && ( processor->Connection().ConnectionId() |
244 == aSession.iConnection.ConnectionId() ) ) |
251 == aSession.iConnection.ConnectionId() ) ) |
245 { |
252 { |
246 processor->UsbDisconnect(); // Rollback |
253 processor->UsbDisconnect(); // Rollback |
247 |
254 |
248 iActiveProcessors.Remove( i ); |
255 iActiveProcessors.Remove( i ); |
249 // if ( i == iActiveProcessor ) |
256 if ( i == iActiveProcessor ) |
250 // { |
257 { |
251 // iActiveProcessorRemoved = ETrue; |
258 iActiveProcessorRemoved = ETrue; |
252 // } |
259 } |
253 // else |
260 else |
254 { |
261 { |
255 processor->Release(); |
262 processor->Release(); |
256 } |
263 } |
257 } |
264 } |
258 } |
265 } |
470 return index; |
477 return index; |
471 } |
478 } |
472 |
479 |
473 // ----------------------------------------------------------------------------- |
480 // ----------------------------------------------------------------------------- |
474 // CAbstractMediaMtpDataProvider::GetWrapper |
481 // CAbstractMediaMtpDataProvider::GetWrapper |
475 // return the reference of CMmMtpDpMetadataAccessWrapper to enumerator |
482 // return wrapper references |
476 // ----------------------------------------------------------------------------- |
483 // ----------------------------------------------------------------------------- |
477 // |
484 // |
478 CMmMtpDpMetadataAccessWrapper& CAbstractMediaMtpDataProvider::GetWrapperL() |
485 CMmMtpDpMetadataAccessWrapper& CAbstractMediaMtpDataProvider::GetWrapperL() |
479 { |
486 { |
480 return CMmMtpDpAccessSingleton::GetAccessWrapperL(); |
487 return CMmMtpDpAccessSingleton::GetAccessWrapperL(); |
|
488 } |
|
489 |
|
490 // ----------------------------------------------------------------------------- |
|
491 // CAbstractMediaMtpDataProvider::PropSettingUtility |
|
492 // return The utility to setting properties |
|
493 // ----------------------------------------------------------------------------- |
|
494 // |
|
495 CPropertySettingUtility* CAbstractMediaMtpDataProvider::PropSettingUtility() |
|
496 { |
|
497 return iPropSettingUtility; |
|
498 } |
|
499 |
|
500 // ----------------------------------------------------------------------------- |
|
501 // CAbstractMediaMtpDataProvider::DescriptionUtility |
|
502 // return The utiltiy to setting descriptions |
|
503 // ----------------------------------------------------------------------------- |
|
504 // |
|
505 CDescriptionUtility* CAbstractMediaMtpDataProvider::DescriptionUtility() |
|
506 { |
|
507 return iDescriptionUtility; |
481 } |
508 } |
482 |
509 |
483 // --------------------------------------------------------------------------- |
510 // --------------------------------------------------------------------------- |
484 // CAbstractMediaMtpDataProvider::GetSupportedFormat |
511 // CAbstractMediaMtpDataProvider::GetSupportedFormat |
485 // |
512 // |
499 { |
526 { |
500 InsertL( iSupportedFormat, KAbstractMediaMtpDataProviderSupportedFormats[i] ); |
527 InsertL( iSupportedFormat, KAbstractMediaMtpDataProviderSupportedFormats[i] ); |
501 } |
528 } |
502 } |
529 } |
503 |
530 |
504 const RArray<TUint>* CAbstractMediaMtpDataProvider::GetSupportedPropertiesL( TUint32 aFormatCode ) const |
531 const RArray<TUint>* CAbstractMediaMtpDataProvider::GetSupportedPropertiesL( TUint32 /*aFormatCode*/ ) const |
505 { |
532 { |
|
533 // May need add more implementation here for further extension. |
506 return &iSupportedProperties; |
534 return &iSupportedProperties; |
507 } |
535 } |
508 |
536 |
509 // --------------------------------------------------------------------------- |
537 // --------------------------------------------------------------------------- |
510 // CAbstractMediaMtpDataProvider::GetSupportedPropertiesL |
538 // CAbstractMediaMtpDataProvider::GetSupportedPropertiesL |
550 TInt err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNum ); |
578 TInt err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNum ); |
551 PRINT2( _L( "MM MTP <> GetDefaultDrive, driveNum = %d, err = %d" ), driveNum, err ); |
579 PRINT2( _L( "MM MTP <> GetDefaultDrive, driveNum = %d, err = %d" ), driveNum, err ); |
552 |
580 |
553 TDriveInfo driveInfo; |
581 TDriveInfo driveInfo; |
554 User::LeaveIfError( Framework().Fs().Drive( driveInfo, driveNum ) ); |
582 User::LeaveIfError( Framework().Fs().Drive( driveInfo, driveNum ) ); |
|
583 PRINT3( _L( "driveInfo.iType = 0x%x, driveInfo.iDriveAtt = 0x%x, driveInfo.iMediaAtt = 0x%x" ), |
|
584 driveInfo.iType, |
|
585 driveInfo.iDriveAtt, |
|
586 driveInfo.iMediaAtt ); |
555 if( driveInfo.iType == EMediaNotPresent || driveInfo.iType == EMediaUnknown ) |
587 if( driveInfo.iType == EMediaNotPresent || driveInfo.iType == EMediaUnknown ) |
556 { |
588 { |
557 err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, driveNum ); |
589 err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, driveNum ); |
558 PRINT( _L( "MM MTP <> Memory card doesn't exist, set PhoneMemory to default" ) ); |
590 User::LeaveIfError( Framework().Fs().Drive( driveInfo, driveNum ) ); |
|
591 if( driveInfo.iType == EMediaNotPresent || driveInfo.iType == EMediaUnknown ) |
|
592 { |
|
593 err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, driveNum ); |
|
594 PRINT( _L( "MM MTP <> Memory card doesn't exist, set PhoneMemory to default" ) ); |
|
595 } |
559 } |
596 } |
560 |
597 |
561 return Framework().StorageMgr().FrameworkStorageId( TDriveNumber( driveNum ) ); |
598 return Framework().StorageMgr().FrameworkStorageId( TDriveNumber( driveNum ) ); |
562 } |
599 } |
563 |
600 |