80 iExtnPluginMapArray.Close(); |
85 iExtnPluginMapArray.Close(); |
81 iEvent.Reset(); |
86 iEvent.Reset(); |
82 |
87 |
83 delete iDeviceInfoTimer; |
88 delete iDeviceInfoTimer; |
84 iFrameWork.Close(); |
89 iFrameWork.Close(); |
85 __FLOG(_L8("~CMTPDeviceDataProvider - Exit")); |
90 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_CMTPDEVICEDATAPROVIDER_DES_EXIT ); |
86 __FLOG_CLOSE; |
|
87 } |
91 } |
88 |
92 |
89 void CMTPDeviceDataProvider::Cancel() |
93 void CMTPDeviceDataProvider::Cancel() |
90 { |
94 { |
91 |
95 |
92 } |
96 } |
93 |
97 |
94 void CMTPDeviceDataProvider::ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) |
98 void CMTPDeviceDataProvider::ProcessEventL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) |
95 { |
99 { |
96 __FLOG(_L8("ProcessEventL - Entry")); |
100 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_PROCESSEVENTL_ENTRY ); |
97 TInt index = LocateRequestProcessorL(aEvent, aConnection); |
101 TInt index = LocateRequestProcessorL(aEvent, aConnection); |
98 if(index != KErrNotFound) |
102 if(index != KErrNotFound) |
99 { |
103 { |
100 iActiveProcessors[index]->HandleEventL(aEvent); |
104 iActiveProcessors[index]->HandleEventL(aEvent); |
101 } |
105 } |
102 __FLOG(_L8("ProcessEventL - Exit")); |
106 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_PROCESSEVENTL_EXIT ); |
103 } |
107 } |
104 |
108 |
105 void CMTPDeviceDataProvider::ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams) |
109 void CMTPDeviceDataProvider::ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams) |
106 { |
110 { |
107 __FLOG(_L8("ProcessNotificationL - Entry")); |
111 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_PROCESSNOTIFICATIONL_ENTRY ); |
108 switch (aNotification) |
112 switch (aNotification) |
109 { |
113 { |
110 case EMTPSessionClosed: |
114 case EMTPSessionClosed: |
111 SessionClosedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams)); |
115 SessionClosedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams)); |
112 break; |
116 break; |
119 break; |
123 break; |
120 default: |
124 default: |
121 // Ignore all other notifications. |
125 // Ignore all other notifications. |
122 break; |
126 break; |
123 } |
127 } |
124 __FLOG(_L8("ProcessNotificationL - Exit")); |
128 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_PROCESSNOTIFICATIONL_EXIT ); |
125 } |
129 } |
126 |
130 |
127 void CMTPDeviceDataProvider::ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
131 void CMTPDeviceDataProvider::ProcessRequestPhaseL(TMTPTransactionPhase aPhase, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
128 { |
132 { |
129 __FLOG(_L8("ProcessRequestPhaseL - Entry")); |
133 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_PROCESSREQUESTPHASEL_ENTRY ); |
130 TUint16 opCode( aRequest.Uint16( TMTPTypeRequest::ERequestOperationCode ) ); |
134 TUint16 opCode( aRequest.Uint16( TMTPTypeRequest::ERequestOperationCode ) ); |
131 TInt index = LocateRequestProcessorL(aRequest, aConnection); |
135 TInt index = LocateRequestProcessorL(aRequest, aConnection); |
132 __ASSERT_DEBUG(index != KErrNotFound, Panic(EMTPDevDpNoMatchingProcessor)); |
136 __ASSERT_DEBUG(index != KErrNotFound, Panic(EMTPDevDpNoMatchingProcessor)); |
133 MMTPRequestProcessor* processor = iActiveProcessors[index]; |
137 MMTPRequestProcessor* processor = iActiveProcessors[index]; |
134 iActiveProcessor = index; |
138 iActiveProcessor = index; |
143 processor->Release(); |
147 processor->Release(); |
144 iActiveProcessors.Remove(index); |
148 iActiveProcessors.Remove(index); |
145 } |
149 } |
146 iActiveProcessor = -1; |
150 iActiveProcessor = -1; |
147 |
151 |
148 __FLOG_VA((_L8("opCode = 0x%x"), opCode)); |
152 OstTrace1(TRACE_NORMAL, CMTPDEVICEDATAPROVIDER_PROCESSREQUESTPHASEL, "opCode = 0x%x", opCode); |
149 __FLOG_VA((_L8("TranPort UID = 0x%x"), iFrameWork.ConnectionMgr().TransportUid().iUid)); |
153 OstTrace1(TRACE_NORMAL, DUP1_CMTPDEVICEDATAPROVIDER_PROCESSREQUESTPHASEL, |
150 __FLOG_VA((_L8("CommandState = 0x%x"), iCommandState)); |
154 "TranPort UID = 0x%x", iFrameWork.ConnectionMgr().TransportUid().iUid); |
|
155 OstTrace1(TRACE_NORMAL, DUP2_CMTPDEVICEDATAPROVIDER_PROCESSREQUESTPHASEL, "CommandState = 0x%x", iCommandState); |
151 const static TInt32 KMTPUsbTransportUid = 0x102827B2; |
156 const static TInt32 KMTPUsbTransportUid = 0x102827B2; |
152 |
157 |
153 if((EMTPOpCodeGetDeviceInfo == opCode)&&(KMTPUsbTransportUid == iFrameWork.ConnectionMgr().TransportUid().iUid)) |
158 if((EMTPOpCodeGetDeviceInfo == opCode)&&(KMTPUsbTransportUid == iFrameWork.ConnectionMgr().TransportUid().iUid)) |
154 { |
159 { |
155 __FLOG(_L8("EMTPOpCodeGetDeviceInfo == opCode")); |
160 OstTrace0(TRACE_NORMAL, DUP3_CMTPDEVICEDATAPROVIDER_PROCESSREQUESTPHASEL, "EMTPOpCodeGetDeviceInfo == opCode"); |
156 //If GetDeviceInfo comes and there is no OpenSession before, the timer will start. And tread the host as Mac. |
161 //If GetDeviceInfo comes and there is no OpenSession before, the timer will start. And tread the host as Mac. |
157 //Only the first GetDeviceInfo in one session will start the timer. |
162 //Only the first GetDeviceInfo in one session will start the timer. |
158 if((EIdle == iCommandState)&&(NULL == iDeviceInfoTimer)) |
163 if((EIdle == iCommandState)&&(NULL == iDeviceInfoTimer)) |
159 { |
164 { |
160 __FLOG(_L8("EMTPOpCodeGetDeviceInfo == opCode, start timer")); |
165 OstTrace0(TRACE_NORMAL, DUP4_CMTPDEVICEDATAPROVIDER_PROCESSREQUESTPHASEL, |
|
166 "EMTPOpCodeGetDeviceInfo == opCode, start timer"); |
|
167 |
161 iCommandState = EStartDeviceInfoTimer; |
168 iCommandState = EStartDeviceInfoTimer; |
162 iDeviceInfoTimer = CMTPDeviceInfoTimer::NewL(*this); |
169 iDeviceInfoTimer = CMTPDeviceInfoTimer::NewL(*this); |
163 iDeviceInfoTimer->Start(); |
170 iDeviceInfoTimer->Start(); |
164 } |
171 } |
165 else |
172 else |
166 { |
173 { |
167 __FLOG(_L8("EMTPOpCodeGetDeviceInfo == opCode, Not start timer")); |
174 OstTrace0(TRACE_NORMAL, DUP5_CMTPDEVICEDATAPROVIDER_PROCESSREQUESTPHASEL, |
|
175 "EMTPOpCodeGetDeviceInfo == opCode, Not start timer"); |
168 } |
176 } |
169 } |
177 } |
170 else |
178 else |
171 { |
179 { |
172 __FLOG(_L8("EMTPOpCodeGetDeviceInfo != opCode")); |
180 OstTrace0(TRACE_NORMAL, DUP6_CMTPDEVICEDATAPROVIDER_PROCESSREQUESTPHASEL, |
|
181 "EMTPOpCodeGetDeviceInfo != opCode"); |
173 if((EMTPOpCodeOpenSession == opCode)&&(EIdle == iCommandState)) |
182 if((EMTPOpCodeOpenSession == opCode)&&(EIdle == iCommandState)) |
174 { |
183 { |
175 __FLOG(_L8("EMTPOpCodeGetDeviceInfo == opCode, set CommandState to be EOpenSession")); |
184 OstTrace0(TRACE_NORMAL, DUP7_CMTPDEVICEDATAPROVIDER_PROCESSREQUESTPHASEL, |
|
185 "EMTPOpCodeGetDeviceInfo == opCode, set CommandState to be EOpenSession"); |
176 iCommandState = EOpenSession; |
186 iCommandState = EOpenSession; |
177 } |
187 } |
178 |
188 |
179 if(iDeviceInfoTimer) |
189 if(iDeviceInfoTimer) |
180 { |
190 { |
181 __FLOG(_L8("iDeviceInfoTimer != NULL, stop timer")); |
191 OstTrace0(TRACE_NORMAL, DUP8_CMTPDEVICEDATAPROVIDER_PROCESSREQUESTPHASEL, |
|
192 "iDeviceInfoTimer != NULL, stop timer"); |
182 delete iDeviceInfoTimer; |
193 delete iDeviceInfoTimer; |
183 iDeviceInfoTimer = NULL; |
194 iDeviceInfoTimer = NULL; |
184 } |
195 } |
185 else |
196 else |
186 { |
197 { |
187 __FLOG(_L8("iDeviceInfoTimer == NULL, NOT stop timer")); |
198 OstTrace0(TRACE_NORMAL, DUP9_CMTPDEVICEDATAPROVIDER_PROCESSREQUESTPHASEL, |
|
199 "iDeviceInfoTimer == NULL, NOT stop timer"); |
188 } |
200 } |
189 } |
201 } |
190 __FLOG(_L8("ProcessRequestPhaseL - Exit")); |
202 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_PROCESSREQUESTPHASEL_EXIT ); |
191 } |
203 } |
192 |
204 |
193 void CMTPDeviceDataProvider::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/) |
205 void CMTPDeviceDataProvider::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/) |
194 { |
206 { |
195 __FLOG(_L8("StartObjectEnumerationL - Entry")); |
207 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_STARTOBJECTENUMERATIONL_ENTRY ); |
196 iPendingEnumerations.AppendL(aStorageId); |
208 iPendingEnumerations.AppendL(aStorageId); |
197 if (iEnumeratingState == EUndefined) |
209 if (iEnumeratingState == EUndefined) |
198 { |
210 { |
199 iDevDpSingletons.DeviceDataStore().StartEnumerationL(aStorageId, *this); |
211 iDevDpSingletons.DeviceDataStore().StartEnumerationL(aStorageId, *this); |
200 iEnumeratingState = EEnumeratingDeviceDataStore; |
212 iEnumeratingState = EEnumeratingDeviceDataStore; |
203 else |
215 else |
204 { |
216 { |
205 iEnumeratingState = EEnumeratingFolders; |
217 iEnumeratingState = EEnumeratingFolders; |
206 NotifyEnumerationCompleteL(aStorageId, KErrNone); |
218 NotifyEnumerationCompleteL(aStorageId, KErrNone); |
207 } |
219 } |
208 __FLOG(_L8("StartObjectEnumerationL - Exit")); |
220 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_STARTOBJECTENUMERATIONL_EXIT ); |
209 } |
221 } |
210 |
222 |
211 void CMTPDeviceDataProvider::StartStorageEnumerationL() |
223 void CMTPDeviceDataProvider::StartStorageEnumerationL() |
212 { |
224 { |
213 __FLOG(_L8("StartStorageEnumerationL - Entry")); |
225 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_STARTSTORAGEENUMERATIONL_ENTRY ); |
214 iStorageWatcher->EnumerateStoragesL(); |
226 iStorageWatcher->EnumerateStoragesL(); |
215 Framework().StorageEnumerationCompleteL(); |
227 Framework().StorageEnumerationCompleteL(); |
216 __FLOG(_L8("StartStorageEnumerationL - Exit")); |
228 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_STARTSTORAGEENUMERATIONL_EXIT ); |
217 } |
229 } |
218 |
230 |
219 void CMTPDeviceDataProvider::Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const |
231 void CMTPDeviceDataProvider::Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const |
220 { |
232 { |
221 __FLOG(_L8("Supported - Entry")); |
233 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_SUPPORTED_ENTRY ); |
222 TInt mode = Framework().Mode(); |
234 TInt mode = Framework().Mode(); |
223 switch (aCategory) |
235 switch (aCategory) |
224 { |
236 { |
225 case EAssociationTypes: |
237 case EAssociationTypes: |
226 aArray.Append(EMTPAssociationTypeGenericFolder); |
238 aArray.Append(EMTPAssociationTypeGenericFolder); |
397 CleanupStack::PopAndDestroy(&extnUidArray); |
408 CleanupStack::PopAndDestroy(&extnUidArray); |
398 } |
409 } |
399 |
410 |
400 void CMTPDeviceDataProvider::AddFolderRecursiveL( const TMTPNotificationParamsFolderChange& aFolder ) |
411 void CMTPDeviceDataProvider::AddFolderRecursiveL( const TMTPNotificationParamsFolderChange& aFolder ) |
401 { |
412 { |
402 __FLOG(_L8("AddFolderRecursiveL - Entry")); |
413 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL_ENTRY ); |
403 |
414 |
404 TPtrC folderRight( aFolder.iFolderChanged ); |
415 TPtrC folderRight( aFolder.iFolderChanged ); |
405 __FLOG_VA((_L16("Folder Addition - DriveAndFullPath:%S"), &folderRight )); |
416 OstTraceExt1(TRACE_NORMAL, CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL, |
|
417 "Folder Addition - DriveAndFullPath:%S", folderRight); |
406 |
418 |
407 if ( !BaflUtils::FolderExists( Framework().Fs(), folderRight )) |
419 if ( !BaflUtils::FolderExists( Framework().Fs(), folderRight )) |
408 { |
420 { |
409 __FLOG(_L8("Folder not exist in file system")); |
421 OstTrace0(TRACE_NORMAL, DUP1_CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL, |
|
422 "Folder not exist in file system"); |
410 User::Leave( KErrArgument ); |
423 User::Leave( KErrArgument ); |
411 } |
424 } |
412 |
425 |
413 TUint32 parentHandle( KMTPHandleNoParent ); |
426 TUint32 parentHandle( KMTPHandleNoParent ); |
414 TUint32 handle( KMTPHandleNoParent ); |
427 TUint32 handle( KMTPHandleNoParent ); |
415 TInt pos( KErrNotFound ); |
428 TInt pos( KErrNotFound ); |
416 TInt lengthOfRight( folderRight.Length()); |
429 TInt lengthOfRight( folderRight.Length()); |
417 TFileName folderLeft; |
430 TFileName folderLeft; |
418 |
431 |
419 _LIT( KRootFolder, "?:\\"); |
432 // get root path of storage |
|
433 TInt driveNumber; |
|
434 User::LeaveIfError(Framework().Fs().CharToDrive(folderRight[0], driveNumber)); |
|
435 RBuf rootDirPath; |
|
436 rootDirPath.CreateL(KMaxFileName); |
|
437 rootDirPath.CleanupClosePushL(); |
|
438 iDevDpSingletons.ConfigMgr().GetRootDirPathL(driveNumber, rootDirPath); |
|
439 rootDirPath.Insert(0, folderRight.Mid(0, 2));// get drive: |
420 |
440 |
421 /* |
441 /* |
422 Go through from beginning. |
442 Go through from beginning. |
423 when this while end, folderLeft keeps the top |
443 when this while end, folderLeft keeps the top |
424 layer folder which has no handle |
444 layer folder which has no handle |
432 } |
452 } |
433 folderLeft.Append( folderRight.Left( pos + 1 )); |
453 folderLeft.Append( folderRight.Left( pos + 1 )); |
434 lengthOfRight = folderRight.Length()-pos -1; |
454 lengthOfRight = folderRight.Length()-pos -1; |
435 folderRight.Set( folderRight.Right( lengthOfRight )); |
455 folderRight.Set( folderRight.Right( lengthOfRight )); |
436 |
456 |
437 if ( KErrNotFound != folderLeft.Match( KRootFolder )) |
457 if ( rootDirPath.FindF(folderLeft) != KErrNotFound) |
438 { |
458 { |
439 //first time, root folder |
459 //first time, root folder |
440 //continue |
460 //continue |
441 continue; |
461 continue; |
442 } |
462 } |
443 parentHandle = handle; |
463 parentHandle = handle; |
444 handle = Framework().ObjectMgr().HandleL( folderLeft ); |
464 handle = Framework().ObjectMgr().HandleL( folderLeft ); |
445 } |
465 } |
446 while( KMTPHandleNone != handle ); |
466 while( KMTPHandleNone != handle ); |
447 |
467 CleanupStack::PopAndDestroy(&rootDirPath); |
448 |
468 |
449 if ( KMTPHandleNone == handle ) |
469 if ( KMTPHandleNone == handle ) |
450 { |
470 { |
451 __FLOG(_L8("need to add entry into mtp database")); |
471 OstTrace0(TRACE_NORMAL, DUP2_CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL, |
|
472 "need to add entry into mtp database"); |
452 |
473 |
453 CMTPObjectMetaData* folderObject = CMTPObjectMetaData::NewL(); |
474 CMTPObjectMetaData* folderObject = CMTPObjectMetaData::NewL(); |
454 TUint32 storageId = GetStorageIdL( folderLeft ); |
475 TUint32 storageId = GetStorageIdL( folderLeft ); |
455 |
476 |
456 while( 1 ) |
477 while( 1 ) |
469 } |
490 } |
470 |
491 |
471 delete folderObject; |
492 delete folderObject; |
472 } |
493 } |
473 |
494 |
474 __FLOG(_L8("AddFolderRecursiveL - Exit")); |
495 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL_EXIT ); |
475 } |
496 } |
476 |
497 |
477 TUint32 CMTPDeviceDataProvider::AddEntryL( const TDesC& aPath, TUint32 aParentHandle, TUint32 aStorageId, CMTPObjectMetaData& aObjectInfo ) |
498 TUint32 CMTPDeviceDataProvider::AddEntryL( const TDesC& aPath, TUint32 aParentHandle, TUint32 aStorageId, CMTPObjectMetaData& aObjectInfo ) |
478 { |
499 { |
479 __FLOG(_L8("AddEntryL - Entry")); |
500 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_ADDENTRYL_ENTRY ); |
480 |
501 |
481 TBool isFolder( EFalse ); |
502 TBool isFolder( EFalse ); |
482 BaflUtils::IsFolder( Framework().Fs(), aPath, isFolder ); |
503 BaflUtils::IsFolder( Framework().Fs(), aPath, isFolder ); |
483 |
504 |
484 __ASSERT_ALWAYS( isFolder, User::Leave( KErrArgument )); |
505 __ASSERT_ALWAYS( isFolder, User::Leave( KErrArgument )); |
485 __ASSERT_ALWAYS( aParentHandle != KMTPHandleNone, User::Leave( KErrArgument )); |
506 __ASSERT_ALWAYS( aParentHandle != KMTPHandleNone, User::Leave( KErrArgument )); |
486 __ASSERT_ALWAYS( Framework().StorageMgr().ValidStorageId( aStorageId ), User::Leave( KErrArgument )); |
507 __ASSERT_ALWAYS( Framework().StorageMgr().ValidStorageId( aStorageId ), User::Leave( KErrArgument )); |
487 |
508 |
488 __FLOG_VA((_L16("Add Entry for Path:%S"), &aPath )); |
509 OstTraceExt1(TRACE_NORMAL, CMTPDEVICEDATAPROVIDER_ADDENTRYL, "Add Entry for Path:%S", aPath); |
489 aObjectInfo.SetUint( CMTPObjectMetaData::EDataProviderId, Framework().DataProviderId() ); |
510 aObjectInfo.SetUint( CMTPObjectMetaData::EDataProviderId, Framework().DataProviderId() ); |
490 aObjectInfo.SetUint( CMTPObjectMetaData::EFormatCode, EMTPFormatCodeAssociation ); |
511 aObjectInfo.SetUint( CMTPObjectMetaData::EFormatCode, EMTPFormatCodeAssociation ); |
491 aObjectInfo.SetUint( CMTPObjectMetaData::EStorageId, aStorageId ); |
512 aObjectInfo.SetUint( CMTPObjectMetaData::EStorageId, aStorageId ); |
492 aObjectInfo.SetDesCL( CMTPObjectMetaData::ESuid, aPath ); |
513 aObjectInfo.SetDesCL( CMTPObjectMetaData::ESuid, aPath ); |
493 aObjectInfo.SetUint( CMTPObjectMetaData::EFormatSubCode, EMTPAssociationTypeGenericFolder ); |
514 aObjectInfo.SetUint( CMTPObjectMetaData::EFormatSubCode, EMTPAssociationTypeGenericFolder ); |
503 tailFolder.Set( tailFolder.Right(length - pos)); |
524 tailFolder.Set( tailFolder.Right(length - pos)); |
504 |
525 |
505 aObjectInfo.SetDesCL( CMTPObjectMetaData::EName, tailFolder ); |
526 aObjectInfo.SetDesCL( CMTPObjectMetaData::EName, tailFolder ); |
506 |
527 |
507 Framework().ObjectMgr().InsertObjectL( aObjectInfo ); |
528 Framework().ObjectMgr().InsertObjectL( aObjectInfo ); |
508 __FLOG(_L8("AddEntryL - Exit")); |
529 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_ADDENTRYL_EXIT ); |
509 |
|
510 return aObjectInfo.Uint( CMTPObjectMetaData::EHandle ); |
530 return aObjectInfo.Uint( CMTPObjectMetaData::EHandle ); |
511 } |
531 } |
512 |
532 |
513 TUint32 CMTPDeviceDataProvider::GetStorageIdL( const TDesC& aPath ) |
533 TUint32 CMTPDeviceDataProvider::GetStorageIdL( const TDesC& aPath ) |
514 { |
534 { |
515 __FLOG(_L8("GetStorageId - Entry")); |
535 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_GETSTORAGEIDL_ENTRY ); |
516 |
536 |
517 TChar driveLetter = aPath[0]; |
537 TChar driveLetter = aPath[0]; |
518 TInt drive; |
538 TInt drive; |
519 User::LeaveIfError( Framework().Fs().CharToDrive( driveLetter, drive )); |
539 LEAVEIFERROR( Framework().Fs().CharToDrive( driveLetter, drive ), |
520 |
540 OstTraceExt1( TRACE_ERROR, CMTPDEVICEDATAPROVIDER_GETSTORAGEIDL, "can't convert driver letter %c to drive!", driveLetter)); |
521 __FLOG(_L8("GetStorageId - Exit")); |
541 |
|
542 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_GETSTORAGEIDL_EXIT ); |
522 |
543 |
523 return Framework().StorageMgr().FrameworkStorageId( static_cast<TDriveNumber>( drive )); |
544 return Framework().StorageMgr().FrameworkStorageId( static_cast<TDriveNumber>( drive )); |
524 } |
545 } |
525 |
546 |
526 void CMTPDeviceDataProvider::OnDeviceFolderChangedL( TMTPEventCode aEventCode, CMTPObjectMetaData& aObjectInfo ) |
547 void CMTPDeviceDataProvider::OnDeviceFolderChangedL( TMTPEventCode aEventCode, CMTPObjectMetaData& aObjectInfo ) |
527 { |
548 { |
528 __FLOG(_L8("OnDeviceFolderChangedL - Entry")); |
549 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_ONDEVICEFOLDERCHANGEDL_ENTRY ); |
529 |
550 |
530 iEvent.Reset(); |
551 iEvent.Reset(); |
531 |
552 |
532 switch( aEventCode ) |
553 switch( aEventCode ) |
533 { |
554 { |
534 case EMTPEventCodeObjectAdded: |
555 case EMTPEventCodeObjectAdded: |
535 { |
556 { |
536 __FLOG(_L8("Send event for object add")); |
557 OstTrace0(TRACE_NORMAL, CMTPDEVICEDATAPROVIDER_ONDEVICEFOLDERCHANGEDL, "Send event for object add"); |
537 iEvent.SetUint16( TMTPTypeEvent::EEventCode, EMTPEventCodeObjectAdded ); |
558 iEvent.SetUint16( TMTPTypeEvent::EEventCode, EMTPEventCodeObjectAdded ); |
538 iEvent.SetUint32( TMTPTypeEvent::EEventSessionID, KMTPSessionAll ); |
559 iEvent.SetUint32( TMTPTypeEvent::EEventSessionID, KMTPSessionAll ); |
539 iEvent.SetUint32( TMTPTypeEvent::EEventTransactionID, KMTPTransactionIdNone ); |
560 iEvent.SetUint32( TMTPTypeEvent::EEventTransactionID, KMTPTransactionIdNone ); |
540 TUint32 handle = aObjectInfo.Uint( CMTPObjectMetaData::EHandle ); |
561 TUint32 handle = aObjectInfo.Uint( CMTPObjectMetaData::EHandle ); |
541 iEvent.SetUint32( TMTPTypeEvent::EEventParameter1, handle ); |
562 iEvent.SetUint32( TMTPTypeEvent::EEventParameter1, handle ); |
545 break; |
566 break; |
546 } |
567 } |
547 |
568 |
548 Framework().SendEventL(iEvent); |
569 Framework().SendEventL(iEvent); |
549 |
570 |
550 __FLOG(_L8("OnDeviceFolderChangedL - Exit")); |
571 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_ONDEVICEFOLDERCHANGEDL_EXIT ); |
551 } |
572 } |
552 |
573 |
553 /** |
574 /** |
554 Second phase constructor. |
575 Second phase constructor. |
555 */ |
576 */ |
556 void CMTPDeviceDataProvider::ConstructL() |
577 void CMTPDeviceDataProvider::ConstructL() |
557 { |
578 { |
558 __FLOG_OPEN(KMTPSubsystem, KComponent); |
579 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_CONSTRUCTL_ENTRY ); |
559 __FLOG(_L8("ConstructL - Entry")); |
|
560 iDevDpSingletons.OpenL(Framework()); |
580 iDevDpSingletons.OpenL(Framework()); |
561 iPtrDataStore = &(iDevDpSingletons.DeviceDataStore()); |
581 iPtrDataStore = &(iDevDpSingletons.DeviceDataStore()); |
562 iDpSingletons.OpenL(Framework()); |
582 iDpSingletons.OpenL(Framework()); |
563 |
583 |
564 iExclusionMgr = CMTPDevDpExclusionMgr::NewL(Framework()); |
584 iExclusionMgr = CMTPDevDpExclusionMgr::NewL(Framework()); |
570 |
590 |
571 TRAPD(err, LoadExtnPluginsL()); |
591 TRAPD(err, LoadExtnPluginsL()); |
572 // __ASSERT_DEBUG((err == KErrNone), Panic(_L("Invalid resource file "))); |
592 // __ASSERT_DEBUG((err == KErrNone), Panic(_L("Invalid resource file "))); |
573 if(KErrNone != err) |
593 if(KErrNone != err) |
574 { |
594 { |
575 __FLOG(_L8("\nTere is an issue in loading the plugin !!!!!\n")); |
595 OstTrace0(TRACE_ERROR, CMTPDEVICEDATAPROVIDER_CONSTRUCTL, |
|
596 "\nTere is an issue in loading the plugin !!!!!\n"); |
576 } |
597 } |
577 |
598 |
578 iEnumerator = CMTPFSEnumerator::NewL(Framework(), iDpSingletons.ExclusionMgrL(), *this, KProcessLimit); |
599 iEnumerator = CMTPFSEnumerator::NewL(Framework(), iDpSingletons.ExclusionMgrL(), *this, KProcessLimit); |
579 iFrameWork.OpenL(); |
600 iFrameWork.OpenL(); |
580 |
601 |
581 __FLOG(_L8("ConstructL - Exit")); |
602 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_CONSTRUCTL_EXIT ); |
582 |
|
583 } |
603 } |
584 |
604 |
585 void CMTPDeviceDataProvider::OnDevicePropertyChangedL (TMTPDevicePropertyCode& aPropCode) |
605 void CMTPDeviceDataProvider::OnDevicePropertyChangedL (TMTPDevicePropertyCode& aPropCode) |
586 { |
606 { |
587 iEvent.Reset(); |
607 iEvent.Reset(); |
618 @param aConnection The connection from which the request comes |
638 @param aConnection The connection from which the request comes |
619 @return the index of the found/created request processor |
639 @return the index of the found/created request processor |
620 */ |
640 */ |
621 TInt CMTPDeviceDataProvider::LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
641 TInt CMTPDeviceDataProvider::LocateRequestProcessorL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
622 { |
642 { |
623 __FLOG(_L8("LocateRequestProcessorL - Entry")); |
643 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_LOCATEREQUESTPROCESSORL_TMTPTYPEREQUEST_ENTRY ); |
624 TInt index = KErrNotFound; |
644 TInt index = KErrNotFound; |
625 TInt count = iActiveProcessors.Count(); |
645 TInt count = iActiveProcessors.Count(); |
626 for(TInt i = 0; i < count; i++) |
646 for(TInt i = 0; i < count; i++) |
627 { |
647 { |
628 if(iActiveProcessors[i]->Match(aRequest, aConnection)) |
648 if(iActiveProcessors[i]->Match(aRequest, aConnection)) |
661 @param aConnection The connection from which the request comes |
681 @param aConnection The connection from which the request comes |
662 @return the index of the found request processor, KErrNotFound if not found |
682 @return the index of the found request processor, KErrNotFound if not found |
663 */ |
683 */ |
664 TInt CMTPDeviceDataProvider::LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) |
684 TInt CMTPDeviceDataProvider::LocateRequestProcessorL(const TMTPTypeEvent& aEvent, MMTPConnection& aConnection) |
665 { |
685 { |
666 __FLOG(_L8("LocateRequestProcessorL - Entry")); |
686 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_LOCATEREQUESTPROCESSORL_TMTPTYPEEVENT_ENTRY ); |
667 TInt index = KErrNotFound; |
687 TInt index = KErrNotFound; |
668 TInt count = iActiveProcessors.Count(); |
688 TInt count = iActiveProcessors.Count(); |
669 for(TInt i = 0; i < count; i++) |
689 for(TInt i = 0; i < count; i++) |
670 { |
690 { |
671 if(iActiveProcessors[i]->Match(aEvent, aConnection)) |
691 if(iActiveProcessors[i]->Match(aEvent, aConnection)) |
672 { |
692 { |
673 index = i; |
693 index = i; |
674 break; |
694 break; |
675 } |
695 } |
676 } |
696 } |
677 __FLOG(_L8("LocateRequestProcessorL - Exit")); |
697 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_LOCATEREQUESTPROCESSORL_TMTPTYPEEVENT_EXIT ); |
678 return index; |
698 return index; |
679 } |
699 } |
680 |
700 |
681 /** |
701 /** |
682 Cleans up outstanding request processors when a session is closed. |
702 Cleans up outstanding request processors when a session is closed. |
683 @param aSession notification parameter block |
703 @param aSession notification parameter block |
684 */ |
704 */ |
685 void CMTPDeviceDataProvider::SessionClosedL(const TMTPNotificationParamsSessionChange& aSession) |
705 void CMTPDeviceDataProvider::SessionClosedL(const TMTPNotificationParamsSessionChange& aSession) |
686 { |
706 { |
687 __FLOG(_L8("SessionClosedL - Entry")); |
707 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_SESSIONCLOSEDL_ENTRY ); |
688 TInt count = iActiveProcessors.Count(); |
708 TInt count = iActiveProcessors.Count(); |
689 while(count--) |
709 while(count--) |
690 { |
710 { |
691 MMTPRequestProcessor* processor = iActiveProcessors[count]; |
711 MMTPRequestProcessor* processor = iActiveProcessors[count]; |
692 TUint32 sessionId = processor->SessionId(); |
712 TUint32 sessionId = processor->SessionId(); |
700 else |
720 else |
701 { |
721 { |
702 processor->Release(); |
722 processor->Release(); |
703 } |
723 } |
704 } |
724 } |
705 } |
725 } |
706 __FLOG_VA((_L8("current state is =%d"), iCommandState)); |
726 OstTrace1(TRACE_NORMAL, CMTPDEVICEDATAPROVIDER_SESSIONCLOSEDL, |
|
727 "current state is =%d", iCommandState); |
707 if(iCommandState != EIdle) |
728 if(iCommandState != EIdle) |
708 { |
729 { |
709 if(iDeviceInfoTimer) |
730 if(iDeviceInfoTimer) |
710 { |
731 { |
711 delete iDeviceInfoTimer; |
732 delete iDeviceInfoTimer; |
712 iDeviceInfoTimer = NULL; |
733 iDeviceInfoTimer = NULL; |
713 } |
734 } |
714 iCommandState = EIdle; |
735 iCommandState = EIdle; |
715 iDevDpSingletons.DeviceDataStore().SetConnectMac(EFalse); |
736 iDevDpSingletons.DeviceDataStore().SetConnectMac(EFalse); |
716 } |
737 } |
717 __FLOG(_L8("SessionClosedL - Exit")); |
738 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_SESSIONCLOSEDL_EXIT ); |
718 } |
739 } |
719 |
740 |
720 /** |
741 /** |
721 Prepares for a newly-opened session. |
742 Prepares for a newly-opened session. |
722 @param aSession notification parameter block |
743 @param aSession notification parameter block |
723 */ |
744 */ |
724 #ifdef __FLOG_ACTIVE |
745 #ifdef OST_TRACE_COMPILER_IN_USE |
725 void CMTPDeviceDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession) |
746 void CMTPDeviceDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession) |
726 #else |
747 #else |
727 void CMTPDeviceDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& /*aSession*/) |
748 void CMTPDeviceDataProvider::SessionOpenedL(const TMTPNotificationParamsSessionChange& /*aSession*/) |
728 #endif |
749 #endif |
729 { |
750 { |
730 __FLOG(_L8("SessionOpenedL - Entry")); |
751 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_SESSIONOPENEDL_ENTRY ); |
731 __FLOG_VA((_L8("SessionID = %d"), aSession.iMTPId)); |
752 OstTrace1(TRACE_NORMAL, CMTPDEVICEDATAPROVIDER_SESSIONOPENEDL, "SessionID = %d", aSession.iMTPId); |
732 __FLOG(_L8("SessionOpenedL - Exit")); |
753 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_SESSIONOPENEDL_EXIT); |
733 } |
754 } |
734 |
755 |
735 void CMTPDeviceDataProvider::SetConnectMac() |
756 void CMTPDeviceDataProvider::SetConnectMac() |
736 { |
757 { |
737 __FLOG(_L8("SetConnectMac - Entry")); |
758 OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_SETCONNECTMAC_ENTRY ); |
738 iDevDpSingletons.DeviceDataStore().SetConnectMac(ETrue); |
759 iDevDpSingletons.DeviceDataStore().SetConnectMac(ETrue); |
739 __FLOG_VA((_L8("previous state = %d, current is ESetIsMac"), iCommandState)); |
760 OstTrace1(TRACE_NORMAL, CMTPDEVICEDATAPROVIDER_SETCONNECTMAC, |
740 iCommandState = ESetIsMac; |
761 "previous state = %d, current is ESetIsMac", iCommandState); |
741 __FLOG(_L8("SetConnectMac - Exit")); |
762 iCommandState = ESetIsMac; |
|
763 OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_SETCONNECTMAC_EXIT ); |
742 } |
764 } |
743 |
765 |
744 /** |
766 /** |
745 CMTPDeviceInfoTimer factory method. |
767 CMTPDeviceInfoTimer factory method. |
746 @return A pointer to a new CMTPDeviceInfoTimer instance. Ownership IS transfered. |
768 @return A pointer to a new CMTPDeviceInfoTimer instance. Ownership IS transfered. |
760 */ |
782 */ |
761 CMTPDeviceInfoTimer::~CMTPDeviceInfoTimer() |
783 CMTPDeviceInfoTimer::~CMTPDeviceInfoTimer() |
762 { |
784 { |
763 Cancel(); |
785 Cancel(); |
764 iLdd.Close(); |
786 iLdd.Close(); |
765 __FLOG_CLOSE; |
|
766 } |
787 } |
767 |
788 |
768 /** |
789 /** |
769 Starts the deviceinfo timer. |
790 Starts the deviceinfo timer. |
770 */ |
791 */ |
771 // DeviceInfo delay, in microseconds. 5s |
792 // DeviceInfo delay, in microseconds. 5s |
772 const TUint KMTPDeviceInfoDelay = (1000000 * 5); |
793 const TUint KMTPDeviceInfoDelay = (1000000 * 5); |
773 void CMTPDeviceInfoTimer::Start() |
794 void CMTPDeviceInfoTimer::Start() |
774 { |
795 { |
775 __FLOG(_L8("CMTPDeviceInfoTimer::Start - Entry")); |
796 OstTraceFunctionEntry0( CMTPDEVICEINFOTIMER_START_ENTRY ); |
776 |
797 |
777 After(KMTPDeviceInfoDelay); |
798 After(KMTPDeviceInfoDelay); |
778 iState = EStartTimer; |
799 iState = EStartTimer; |
779 __FLOG(_L8("CMTPDeviceInfoTimer::Start - Exit")); |
800 OstTraceFunctionExit0( CMTPDEVICEINFOTIMER_START_EXIT ); |
780 } |
801 } |
781 |
802 |
782 void CMTPDeviceInfoTimer::RunL() |
803 void CMTPDeviceInfoTimer::RunL() |
783 { |
804 { |
784 __FLOG(_L8("CMTPDeviceInfoTimer::RunL - Entry")); |
805 OstTraceFunctionEntry0( CMTPDEVICEINFOTIMER_RUNL_ENTRY ); |
785 __FLOG_VA((_L8("iStatus == %d"), iStatus.Int())); |
806 OstTrace1(TRACE_NORMAL, CMTPDEVICEINFOTIMER_RUNL, |
|
807 "iStatus == %d", iStatus.Int()); |
786 |
808 |
787 switch(iState) |
809 switch(iState) |
788 { |
810 { |
789 case EStartTimer: |
811 case EStartTimer: |
790 __FLOG(_L8("CMTPDeviceInfoTimer::RunL - EStartTimer")); |
812 OstTrace0(TRACE_NORMAL, DUP1_CMTPDEVICEINFOTIMER_RUNL, "CMTPDeviceInfoTimer::RunL - EStartTimer"); |
791 // Open the USB device interface. |
813 // Open the USB device interface. |
792 User::LeaveIfError(iLdd.Open(0)); |
814 LEAVEIFERROR(iLdd.Open(0), |
|
815 OstTrace0( TRACE_ERROR, DUP4_CMTPDEVICEINFOTIMER_RUNL, "Open the USB device interface error!" )); |
793 iLdd.ReEnumerate(iStatus); |
816 iLdd.ReEnumerate(iStatus); |
794 iDeviceProvider.SetConnectMac(); |
817 iDeviceProvider.SetConnectMac(); |
795 iState = EUSBReEnumerate; |
818 iState = EUSBReEnumerate; |
796 SetActive(); |
819 SetActive(); |
797 break; |
820 break; |
798 case EUSBReEnumerate: |
821 case EUSBReEnumerate: |
799 __FLOG(_L8("CMTPDeviceInfoTimer::RunL - EUSBReEnumerate")); |
822 OstTrace0(TRACE_NORMAL, DUP2_CMTPDEVICEINFOTIMER_RUNL, "CMTPDeviceInfoTimer::RunL - EUSBReEnumerate"); |
800 break; |
823 break; |
801 default: |
824 default: |
802 __FLOG(_L8("CMTPDeviceInfoTimer::RunL - default")); |
825 OstTrace0(TRACE_NORMAL, DUP3_CMTPDEVICEINFOTIMER_RUNL, "CMTPDeviceInfoTimer::RunL - default"); |
803 break; |
826 break; |
804 } |
827 } |
805 __FLOG(_L8("CMTPDeviceInfoTimer::RunL - Exit")); |
828 OstTraceFunctionExit0( CMTPDEVICEINFOTIMER_RUNL_EXIT ); |
806 } |
829 } |
807 |
830 |
808 /** |
831 /** |
809 Constructor |
832 Constructor |
810 */ |
833 */ |