114 connection. |
117 connection. |
115 @panic CMTPConnection 2 If the MTP transaction phase is invalid. |
118 @panic CMTPConnection 2 If the MTP transaction phase is invalid. |
116 */ |
119 */ |
117 void CMTPConnection::ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, TRequestStatus& aStatus) |
120 void CMTPConnection::ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest, TRequestStatus& aStatus) |
118 { |
121 { |
119 __FLOG(_L8("ReceiveDataL - Entry")); |
122 OstTraceFunctionEntry0( CMTPCONNECTION_RECEIVEDATAL_ENTRY ); |
|
123 |
120 iDataReceiveResult = KErrNone; |
124 iDataReceiveResult = KErrNone; |
121 const TUint KValidPhases(ERequestPhase); |
125 const TUint KValidPhases(ERequestPhase); |
122 CMTPSession& session(SessionL(aRequest, TMTPTypeRequest::ERequestSessionID)); |
126 CMTPSession& session(SessionL(aRequest, TMTPTypeRequest::ERequestSessionID)); |
123 |
127 |
124 if (ValidFrameworkRequest(&session, KValidPhases, &aStatus)) |
128 if (ValidFrameworkRequest(&session, KValidPhases, &aStatus)) |
168 //publish the connection state info to the subscriber. |
172 //publish the connection state info to the subscriber. |
169 ValidateAndPublishConnState(session, State()); |
173 ValidateAndPublishConnState(session, State()); |
170 } |
174 } |
171 iTransportConnection->SendDataL(aData, aRequest); |
175 iTransportConnection->SendDataL(aData, aRequest); |
172 } |
176 } |
173 __FLOG(_L8("SendDataL - Exit")); |
177 OstTraceFunctionExit0( CMTPCONNECTION_SENDDATAL_EXIT ); |
174 } |
178 } |
175 |
179 |
176 /** |
180 /** |
177 Sends an MTP event dataset. |
181 Sends an MTP event dataset. |
178 @param aEvent The MTP event dataset source. |
182 @param aEvent The MTP event dataset source. |
179 @leave KErrNotFound If the MTP event dataset specifies an invalid SessionID. |
183 @leave KErrNotFound If the MTP event dataset specifies an invalid SessionID. |
180 */ |
184 */ |
181 void CMTPConnection::SendEventL(const TMTPTypeEvent& aEvent) |
185 void CMTPConnection::SendEventL(const TMTPTypeEvent& aEvent) |
182 { |
186 { |
183 __FLOG(_L8("SendEventL - Entry")); |
187 OstTraceFunctionEntry0( CMTPCONNECTION_SENDEVENTL_ENTRY ); |
184 const TUint KValidPhases(EIdlePhase | ERequestPhase | EDataIToRPhase| EDataRToIPhase | EResponsePhase | ECompletingPhase); |
188 const TUint KValidPhases(EIdlePhase | ERequestPhase | EDataIToRPhase| EDataRToIPhase | EResponsePhase | ECompletingPhase); |
185 if (ValidFrameworkRequest(NULL, KValidPhases, NULL)) |
189 if (ValidFrameworkRequest(NULL, KValidPhases, NULL)) |
186 { |
190 { |
187 // Validate the SessionID |
191 // Validate the SessionID |
188 TUint32 sessionId(aEvent.Uint32(TMTPTypeEvent::EEventSessionID)); |
192 TUint32 sessionId(aEvent.Uint32(TMTPTypeEvent::EEventSessionID)); |
189 if (sessionId != KMTPSessionAll) |
193 if (sessionId != KMTPSessionAll) |
190 { |
194 { |
191 User::LeaveIfError(iSessions.FindInOrder(sessionId, SessionOrder)); |
195 TInt ret = iSessions.FindInOrder(sessionId, SessionOrder); |
|
196 LEAVEIFERROR(ret, |
|
197 OstTrace1(TRACE_ERROR, CMTPCONNECTION_SENDEVENTL, "can't find according to session_id %d", sessionId)); |
192 } |
198 } |
193 |
199 |
194 |
200 |
195 EnqueueEvent(new (ELeave) CMTPEventLink(aEvent)); |
201 EnqueueEvent(new (ELeave) CMTPEventLink(aEvent)); |
196 if (iPendingEventCount == 1) |
202 if (iPendingEventCount == 1) |
197 { |
203 { |
198 // Forward the event to the transport connection layer. |
204 // Forward the event to the transport connection layer. |
199 iTransportConnection->SendEventL(iEventQ.First()->iEvent); |
205 iTransportConnection->SendEventL(iEventQ.First()->iEvent); |
200 } |
206 } |
201 } |
207 } |
202 __FLOG(_L8("SendEventL - Exit")); |
208 OstTraceFunctionExit0( CMTPCONNECTION_SENDEVENTL_EXIT ); |
203 } |
209 } |
204 |
210 |
205 /** |
211 /** |
206 Initiates MTP transaction response phase processing. This method should only |
212 Initiates MTP transaction response phase processing. This method should only |
207 be invoked when the MTP transaction phase state is either ERequestPhase, or |
213 be invoked when the MTP transaction phase state is either ERequestPhase, or |
309 @leave One of the system wide error codes, if a general processing failure |
316 @leave One of the system wide error codes, if a general processing failure |
310 occurs. |
317 occurs. |
311 */ |
318 */ |
312 EXPORT_C void CMTPConnection::SessionOpenedL(TUint32 aMTPId) |
319 EXPORT_C void CMTPConnection::SessionOpenedL(TUint32 aMTPId) |
313 { |
320 { |
314 __FLOG(_L8("SessionOpenedL - Entry")); |
321 OstTraceFunctionEntry0( CMTPCONNECTION_SESSIONOPENEDL_ENTRY ); |
315 // Validate the SessionID |
322 // Validate the SessionID |
316 if (SessionWithMTPIdExists(aMTPId)) |
323 if (SessionWithMTPIdExists(aMTPId)) |
317 { |
324 { |
318 User::Leave(KErrAlreadyExists); |
325 OstTrace1(TRACE_ERROR, CMTPCONNECTION_SESSIONOPENEDL, "session %d alreay exist", aMTPId); |
|
326 User::Leave(KErrAlreadyExists); |
319 } |
327 } |
320 |
328 |
321 // Create a new session object |
329 // Create a new session object |
322 CMTPSession* session = CMTPSession::NewLC(aMTPId, aMTPId); |
330 CMTPSession* session = CMTPSession::NewLC(aMTPId, aMTPId); |
323 session->SetTransactionPhase(EIdlePhase); |
331 session->SetTransactionPhase(EIdlePhase); |
330 // OpenSession Command coming and now it is really connected to host. |
338 // OpenSession Command coming and now it is really connected to host. |
331 PublishConnState(EConnectedToHost); |
339 PublishConnState(EConnectedToHost); |
332 TMTPNotificationParamsSessionChange params = {aMTPId, *this}; |
340 TMTPNotificationParamsSessionChange params = {aMTPId, *this}; |
333 iSingletons.DpController().NotifyDataProvidersL(EMTPSessionOpened, ¶ms); |
341 iSingletons.DpController().NotifyDataProvidersL(EMTPSessionOpened, ¶ms); |
334 } |
342 } |
335 __FLOG(_L8("SessionOpenedL - Exit")); |
343 OstTraceFunctionExit0( CMTPCONNECTION_SESSIONOPENEDL_EXIT ); |
336 } |
344 } |
337 |
345 |
338 /* |
346 /* |
339 * Signals the connection is suspended, the connection state is set to EStateShutdown which |
347 * Signals the connection is suspended, the connection state is set to EStateShutdown which |
340 * means that all the current transaction will not be able to send/receive any data via the |
348 * means that all the current transaction will not be able to send/receive any data via the |
358 |
366 |
359 SetState(EStateShutdown); |
367 SetState(EStateShutdown); |
360 PublishConnState(EDisconnectedFromHost); |
368 PublishConnState(EDisconnectedFromHost); |
361 } |
369 } |
362 |
370 |
363 __FLOG(_L8("ConnectionSuspended - Exit")); |
371 OstTraceFunctionExit0( CMTPCONNECTION_CONNECTIONSUSPENDED_EXIT ); |
364 return ret; |
372 return ret; |
365 } |
373 } |
366 |
374 |
367 void CMTPConnection::CompleteCloseConnection() |
375 void CMTPConnection::CompleteCloseConnection() |
368 { |
376 { |
369 __FLOG(_L8("CompleteCloseConnection - Entry")); |
377 OstTraceFunctionEntry0( CMTPCONNECTION_COMPLETECLOSECONNECTION_ENTRY ); |
370 |
378 |
371 CloseAllSessions(); |
379 CloseAllSessions(); |
372 iSessions.Reset(); |
380 iSessions.Reset(); |
373 |
381 |
374 //notify ConnectionMgr and corresponding transports of completion of connection close |
382 //notify ConnectionMgr and corresponding transports of completion of connection close |
375 iSingletons.ConnectionMgr().ConnectionCloseComplete(iConnectionId); |
383 iSingletons.ConnectionMgr().ConnectionCloseComplete(iConnectionId); |
376 iSingletons.Close(); |
384 iSingletons.Close(); |
377 |
385 |
378 __FLOG(_L8("CompleteCloseConnection - Exit")); |
386 OstTraceFunctionExit0( CMTPCONNECTION_COMPLETECLOSECONNECTION_EXIT ); |
379 } |
387 } |
380 |
388 |
381 /* |
389 /* |
382 * Signals that the connection is resumed to EStateOpen state which means that data providers |
390 * Signals that the connection is resumed to EStateOpen state which means that data providers |
383 * can receive requests from host again. |
391 * can receive requests from host again. |
384 * @aTransportConnection The new transport connection object |
392 * @aTransportConnection The new transport connection object |
385 * @leave One of the system wide error codes, if a processing failure occurs. |
393 * @leave One of the system wide error codes, if a processing failure occurs. |
386 */ |
394 */ |
387 void CMTPConnection::ConnectionResumedL(MMTPTransportConnection& aTransportConnection) |
395 void CMTPConnection::ConnectionResumedL(MMTPTransportConnection& aTransportConnection) |
388 { |
396 { |
389 __FLOG(_L8("ConnectionResumed - Entry")); |
397 OstTraceFunctionEntry0( CMTPCONNECTION_CONNECTIONRESUMEDL_ENTRY ); |
390 |
398 |
391 TUint currentState = State(); |
399 TUint currentState = State(); |
392 if (currentState != EStateOpen && currentState != EStateErrorRecovery) |
400 if (currentState != EStateOpen && currentState != EStateErrorRecovery) |
393 { |
401 { |
394 iSingletons.OpenL(); |
402 iSingletons.OpenL(); |
420 @leave KErrNotFound If the MTP request dataset specifies an invalid SessionID. |
428 @leave KErrNotFound If the MTP request dataset specifies an invalid SessionID. |
421 @panic CMTPConnection 2 If the MTP transaction phase is invalid. |
429 @panic CMTPConnection 2 If the MTP transaction phase is invalid. |
422 */ |
430 */ |
423 void CMTPConnection::TransactionCompleteL(const TMTPTypeRequest& aRequest) |
431 void CMTPConnection::TransactionCompleteL(const TMTPTypeRequest& aRequest) |
424 { |
432 { |
425 __FLOG(_L8("TransactionCompleteL - Entry")); |
433 OstTraceFunctionEntry0( CMTPCONNECTION_TRANSACTIONCOMPLETEL_ENTRY ); |
|
434 |
426 const TUint KValidPhases(ECompletingPhase); |
435 const TUint KValidPhases(ECompletingPhase); |
427 CMTPSession& session(SessionL(aRequest, TMTPTypeRequest::ERequestSessionID)); |
436 CMTPSession& session(SessionL(aRequest, TMTPTypeRequest::ERequestSessionID)); |
428 |
437 |
429 if (ValidFrameworkRequest(&session, KValidPhases, NULL)) |
438 if (ValidFrameworkRequest(&session, KValidPhases, NULL)) |
430 { |
439 { |
475 return SessionWithMTPIdL(aUniqueId); |
486 return SessionWithMTPIdL(aUniqueId); |
476 } |
487 } |
477 |
488 |
478 void CMTPConnection::ReceivedEventL(const TMTPTypeEvent& aEvent) |
489 void CMTPConnection::ReceivedEventL(const TMTPTypeEvent& aEvent) |
479 { |
490 { |
480 __FLOG(_L8("ReceivedEventL - Entry")); |
491 OstTraceFunctionEntry0( CMTPCONNECTION_RECEIVEDEVENTL_ENTRY ); |
|
492 |
481 TInt idx(KErrNotFound); |
493 TInt idx(KErrNotFound); |
482 |
494 |
483 // Validate the SessionID. |
495 // Validate the SessionID. |
484 TUint32 sessionId(aEvent.Uint32(TMTPTypeEvent::EEventSessionID)); |
496 TUint32 sessionId(aEvent.Uint32(TMTPTypeEvent::EEventSessionID)); |
485 if (sessionId != KMTPSessionAll) |
497 if (sessionId != KMTPSessionAll) |
486 { |
498 { |
487 idx = iSessions.FindInOrder(sessionId, SessionOrder); |
499 idx = iSessions.FindInOrder(sessionId, SessionOrder); |
488 User::LeaveIfError(idx); |
500 LEAVEIFERROR(idx, |
|
501 OstTrace1(TRACE_ERROR, CMTPCONNECTION_RECEIVEDEVENTL, "can't find according to session_id %d", sessionId)); |
489 } |
502 } |
490 |
503 |
491 // Check that this event is valid. |
504 // Check that this event is valid. |
492 CMTPSession& session(*iSessions[idx]); |
505 CMTPSession& session(*iSessions[idx]); |
493 |
506 |
499 { |
512 { |
500 session.StorePendingEventL(aEvent); |
513 session.StorePendingEventL(aEvent); |
501 } |
514 } |
502 else |
515 else |
503 { |
516 { |
504 if (request.Uint32(TMTPTypeRequest::ERequestTransactionID) > |
517 TUint32 requestTransactionId = request.Uint32(TMTPTypeRequest::ERequestTransactionID); |
505 aEvent.Uint32(TMTPTypeEvent::EEventTransactionID) ) |
518 TUint32 eventTransactionId = aEvent.Uint32(TMTPTypeEvent::EEventTransactionID); |
|
519 if (eventTransactionId > requestTransactionId) |
506 { |
520 { |
507 // Event to be queued for future use, we can only queue one event at a time |
521 // Event to be queued for future use, we can only queue one event at a time |
508 session.StorePendingEventL(aEvent); |
522 session.StorePendingEventL(aEvent); |
509 } |
523 } |
510 |
524 else if (eventTransactionId == requestTransactionId) |
511 if (request.Uint32(TMTPTypeRequest::ERequestTransactionID) == |
|
512 aEvent.Uint32(TMTPTypeEvent::EEventTransactionID) ) |
|
513 { |
525 { |
514 // Event is valid |
526 // Event is valid |
515 // Perform transport layer processing. |
527 // Perform transport layer processing. |
516 if (aEvent.Uint16(TMTPTypeEvent::EEventCode) == EMTPEventCodeCancelTransaction) |
528 if (aEvent.Uint16(TMTPTypeEvent::EEventCode) == EMTPEventCodeCancelTransaction) |
517 { |
529 { |
527 { |
539 { |
528 InitiateTransactionCancelL(idx); |
540 InitiateTransactionCancelL(idx); |
529 } |
541 } |
530 } |
542 } |
531 |
543 |
532 // Forward the event to the DP framework layer. |
544 // Forward the event to the DP framework layer. |
533 iSingletons.Router().ProcessEventL(aEvent, *this); |
545 iSingletons.Router().ProcessEventL(aEvent, *this); |
534 } |
546 } |
|
547 |
|
548 //discard the event if the event transaction id < requestion transaction id |
|
549 |
535 } |
550 } |
536 __FLOG(_L8("ReceivedEventL - Exit")); |
551 |
|
552 OstTraceFunctionExit0( CMTPCONNECTION_RECEIVEDEVENTL_EXIT ); |
537 } |
553 } |
538 |
554 |
539 void CMTPConnection::ReceivedRequestL(const TMTPTypeRequest& aRequest) |
555 void CMTPConnection::ReceivedRequestL(const TMTPTypeRequest& aRequest) |
540 { |
556 { |
541 __FLOG(_L8("ReceivedRequestL - Entry")); |
557 OstTraceFunctionEntry0( CMTPCONNECTION_RECEIVEDREQUESTL_ENTRY ); |
|
558 |
542 #ifdef MTP_CAPTURE_TEST_DATA |
559 #ifdef MTP_CAPTURE_TEST_DATA |
543 // Running under debug capture mode save this request off to disk. |
560 // Running under debug capture mode save this request off to disk. |
544 iRequestLogger->LogRequestL(aRequest); |
561 iRequestLogger->LogRequestL(aRequest); |
545 #endif |
562 #endif |
546 |
563 |
572 // Forward the request to the DP framework layer. |
589 // Forward the request to the DP framework layer. |
573 TRAPD(err,iSingletons.Router().ProcessRequestL(session.ActiveRequestL(), *this)); |
590 TRAPD(err,iSingletons.Router().ProcessRequestL(session.ActiveRequestL(), *this)); |
574 if(err!=KErrNone) |
591 if(err!=KErrNone) |
575 { |
592 { |
576 session.SetTransactionPhase(EIdlePhase); |
593 session.SetTransactionPhase(EIdlePhase); |
|
594 OstTrace1(TRACE_ERROR, CMTPCONNECTION_RECEIVEDREQUESTL, "router process request error! error code %d", err); |
577 User::Leave(err); |
595 User::Leave(err); |
578 } |
596 } |
579 } |
597 } |
580 } |
598 } |
581 __FLOG(_L8("ReceivedRequestL - Exit")); |
599 OstTraceFunctionExit0( CMTPCONNECTION_RECEIVEDREQUESTL_EXIT ); |
582 } |
600 } |
583 |
601 |
584 #ifdef MTP_CAPTURE_TEST_DATA |
602 #ifdef MTP_CAPTURE_TEST_DATA |
585 void CMTPConnection::ReceiveDataCompleteL(TInt aErr, const MMTPType& aData, const TMTPTypeRequest& aRequest) |
603 void CMTPConnection::ReceiveDataCompleteL(TInt aErr, const MMTPType& aData, const TMTPTypeRequest& aRequest) |
586 #else |
604 #else |
587 void CMTPConnection::ReceiveDataCompleteL(TInt aErr, const MMTPType& aData, const TMTPTypeRequest& aRequest) |
605 void CMTPConnection::ReceiveDataCompleteL(TInt aErr, const MMTPType& aData, const TMTPTypeRequest& aRequest) |
588 #endif |
606 #endif |
589 { |
607 { |
590 __FLOG(_L8("ReceiveDataCompleteL - Entry")); |
608 OstTraceFunctionEntry0( CMTPCONNECTION_RECEIVEDATACOMPLETEL_ENTRY ); |
|
609 |
591 CMTPSession& session(SessionL(aRequest, TMTPTypeRequest::ERequestSessionID)); |
610 CMTPSession& session(SessionL(aRequest, TMTPTypeRequest::ERequestSessionID)); |
592 __ASSERT_DEBUG((session.TransactionPhase() == EDataIToRPhase), Panic(EMTPPanicInvalidState)); |
611 __ASSERT_DEBUG((session.TransactionPhase() == EDataIToRPhase), Panic(EMTPPanicInvalidState)); |
593 |
612 |
594 if(EMTPTypeFile == aData.Type()) |
613 if(EMTPTypeFile == aData.Type()) |
595 { |
614 { |
602 #endif |
621 #endif |
603 |
622 |
604 session.SetTransactionPhase(EResponsePhase); |
623 session.SetTransactionPhase(EResponsePhase); |
605 iDataReceiveResult = aErr; |
624 iDataReceiveResult = aErr; |
606 session.CompletePendingRequest(aErr); |
625 session.CompletePendingRequest(aErr); |
607 |
626 OstTraceFunctionExit0( CMTPCONNECTION_RECEIVEDATACOMPLETEL_EXIT ); |
608 __FLOG(_L8("ReceiveDataCompleteL - Exit")); |
|
609 } |
627 } |
610 |
628 |
611 void CMTPConnection::SendDataCompleteL(TInt aErr, const MMTPType& aData, const TMTPTypeRequest& aRequest) |
629 void CMTPConnection::SendDataCompleteL(TInt aErr, const MMTPType& aData, const TMTPTypeRequest& aRequest) |
612 { |
630 { |
613 __FLOG(_L8("SendDataCompleteL - Entry")); |
631 OstTraceFunctionEntry0( CMTPCONNECTION_SENDDATACOMPLETEL_ENTRY ); |
614 CMTPSession& session(SessionL(aRequest, TMTPTypeRequest::ERequestSessionID)); |
632 CMTPSession& session(SessionL(aRequest, TMTPTypeRequest::ERequestSessionID)); |
615 __ASSERT_DEBUG((session.TransactionPhase() == EDataRToIPhase), Panic(EMTPPanicInvalidState)); |
633 __ASSERT_DEBUG((session.TransactionPhase() == EDataRToIPhase), Panic(EMTPPanicInvalidState)); |
616 |
634 |
617 session.SetTransactionPhase(EResponsePhase); |
635 session.SetTransactionPhase(EResponsePhase); |
618 |
636 |
660 if (iPendingEventCount > 0) |
678 if (iPendingEventCount > 0) |
661 { |
679 { |
662 if (NULL != iTransportConnection) |
680 if (NULL != iTransportConnection) |
663 { |
681 { |
664 // Forward the event to the transport connection layer. |
682 // Forward the event to the transport connection layer. |
665 __FLOG(_L8("Sending queued event")); |
683 OstTrace0( TRACE_NORMAL, CMTPCONNECTION_SENDEVENTCOMPLETEL, "Sending queued event"); |
666 iTransportConnection->SendEventL(iEventQ.First()->iEvent); |
684 iTransportConnection->SendEventL(iEventQ.First()->iEvent); |
667 } |
685 } |
668 else |
686 else |
669 { |
687 { |
670 DequeueAllEvents(); |
688 DequeueAllEvents(); |
671 } |
689 } |
672 } |
690 } |
673 |
691 |
674 __FLOG(_L8("SendEventCompleteL - Exit")); |
692 OstTraceFunctionExit0( CMTPCONNECTION_SENDEVENTCOMPLETEL_EXIT ); |
675 } |
693 } |
676 |
694 |
677 void CMTPConnection::SendResponseCompleteL(TInt aErr, const TMTPTypeResponse& /*aResponse*/, const TMTPTypeRequest& aRequest) |
695 void CMTPConnection::SendResponseCompleteL(TInt aErr, const TMTPTypeResponse& /*aResponse*/, const TMTPTypeRequest& aRequest) |
678 { |
696 { |
679 __FLOG(_L8("SendResponseCompleteL - Entry")); |
697 OstTraceFunctionEntry0( CMTPCONNECTION_SENDRESPONSECOMPLETEL_ENTRY ); |
|
698 |
680 if(iState == EStateErrorRecovery) |
699 if(iState == EStateErrorRecovery) |
681 { |
700 { |
682 MTPErrorRecoveryComplete(); |
701 MTPErrorRecoveryComplete(); |
683 iTransportConnection->TransactionCompleteL(aRequest); |
702 iTransportConnection->TransactionCompleteL(aRequest); |
684 } |
703 } |
719 Second phase constructor. |
739 Second phase constructor. |
720 @leave One of the system wide error code, if a processing failure occurs. |
740 @leave One of the system wide error code, if a processing failure occurs. |
721 */ |
741 */ |
722 void CMTPConnection::ConstructL() |
742 void CMTPConnection::ConstructL() |
723 { |
743 { |
724 __FLOG_OPEN(KMTPSubsystem, KComponent); |
744 OstTraceFunctionEntry0( CMTPCONNECTION_CONSTRUCTL_ENTRY ); |
725 __FLOG(_L8("ConstructL - Entry")); |
|
726 //define the property for publishing connection state. |
745 //define the property for publishing connection state. |
727 DefineConnStatePropertyL(); |
746 DefineConnStatePropertyL(); |
728 PublishConnState(EDisconnectedFromHost); |
747 PublishConnState(EDisconnectedFromHost); |
729 #ifdef MTP_CAPTURE_TEST_DATA |
748 #ifdef MTP_CAPTURE_TEST_DATA |
730 // Running under debug capture mode save this request off to disk. |
749 // Running under debug capture mode save this request off to disk. |
731 iRequestLogger = CMTPRequestLogger::NewL(); |
750 iRequestLogger = CMTPRequestLogger::NewL(); |
732 #endif |
751 #endif |
733 __FLOG(_L8("ConstructL - Exit")); |
752 OstTraceFunctionExit0( CMTPCONNECTION_CONSTRUCTL_EXIT ); |
734 } |
753 } |
735 |
754 |
736 /** |
755 /** |
737 Initiates an MTP connection level protocol error recovery sequence. This |
756 Initiates an MTP connection level protocol error recovery sequence. This |
738 sequence is invoked when a recoverable protocol error is detected that cannot |
757 sequence is invoked when a recoverable protocol error is detected that cannot |
748 @leave One of the system wide error codes, if a processing failure occurs. |
767 @leave One of the system wide error codes, if a processing failure occurs. |
749 @see MTPErrorRecoveryComplete |
768 @see MTPErrorRecoveryComplete |
750 */ |
769 */ |
751 void CMTPConnection::InitiateMTPErrorRecoveryL(const TMTPTypeRequest& aRequest, TUint16 aResponseCode) |
770 void CMTPConnection::InitiateMTPErrorRecoveryL(const TMTPTypeRequest& aRequest, TUint16 aResponseCode) |
752 { |
771 { |
753 __FLOG(_L8("InitiateMTPErrorRecoveryL - Entry")); |
772 OstTraceFunctionEntry0( CMTPCONNECTION_INITIATEMTPERRORRECOVERYL_ENTRY ); |
754 // Populate error response. |
773 // Populate error response. |
755 iResponse.Reset(); |
774 iResponse.Reset(); |
756 iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aResponseCode); |
775 iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aResponseCode); |
757 iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, aRequest.Uint32(TMTPTypeRequest::ERequestSessionID)); |
776 iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, aRequest.Uint32(TMTPTypeRequest::ERequestSessionID)); |
758 iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, aRequest.Uint32(TMTPTypeRequest::ERequestTransactionID)); |
777 iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, aRequest.Uint32(TMTPTypeRequest::ERequestTransactionID)); |
759 |
778 |
760 // Set the connection state pending completion, and send the response. |
779 // Set the connection state pending completion, and send the response. |
761 SetState(EStateErrorRecovery); |
780 SetState(EStateErrorRecovery); |
762 iTransportConnection->SendResponseL(iResponse, aRequest); |
781 iTransportConnection->SendResponseL(iResponse, aRequest); |
763 __FLOG(_L8("InitiateMTPErrorRecoveryL - Exit")); |
782 OstTraceFunctionExit0( CMTPCONNECTION_INITIATEMTPERRORRECOVERYL_EXIT ); |
764 } |
783 } |
765 |
784 |
766 /** |
785 /** |
767 Concludes an MTP connection level protocol error recovery sequence. |
786 Concludes an MTP connection level protocol error recovery sequence. |
768 @see InitiateMTPErrorRecoveryL |
787 @see InitiateMTPErrorRecoveryL |
769 */ |
788 */ |
770 void CMTPConnection::MTPErrorRecoveryComplete() |
789 void CMTPConnection::MTPErrorRecoveryComplete() |
771 { |
790 { |
772 __FLOG(_L8("MTPErrorRecoveryComplete - Entry")); |
791 OstTraceFunctionEntry0( CMTPCONNECTION_MTPERRORRECOVERYCOMPLETE_ENTRY ); |
773 SetState(EStateOpen); |
792 SetState(EStateOpen); |
774 PublishConnState(EConnectedToHost); |
793 PublishConnState(EConnectedToHost); |
775 __FLOG(_L8("MTPErrorRecoveryComplete - Exit")); |
794 OstTraceFunctionExit0( CMTPCONNECTION_MTPERRORRECOVERYCOMPLETE_EXIT ); |
776 } |
795 } |
777 |
796 |
778 /** |
797 /** |
779 Forces the immediate shutdown of the MTP connection. This is invoked when a |
798 Forces the immediate shutdown of the MTP connection. This is invoked when a |
780 protocol error is detected that cannot be recovered from, e.g. if an attempt |
799 protocol error is detected that cannot be recovered from, e.g. if an attempt |
781 is detected to initiate an MTP transaction before a previous transaction has |
800 is detected to initiate an MTP transaction before a previous transaction has |
782 concluded. |
801 concluded. |
783 */ |
802 */ |
784 void CMTPConnection::UnrecoverableMTPError() |
803 void CMTPConnection::UnrecoverableMTPError() |
785 { |
804 { |
786 __FLOG(_L8("UnrecoverableMTPError - Entry")); |
805 OstTraceFunctionEntry0( CMTPCONNECTION_UNRECOVERABLEMTPERROR_ENTRY ); |
787 SetState(EStateErrorShutdown); |
806 SetState(EStateErrorShutdown); |
788 PublishConnState(EDisconnectedFromHost); |
807 PublishConnState(EDisconnectedFromHost); |
789 iTransportConnection->CloseConnection(); |
808 iTransportConnection->CloseConnection(); |
790 __FLOG(_L8("UnrecoverableMTPError - Exit")); |
809 OstTraceFunctionExit0( CMTPCONNECTION_UNRECOVERABLEMTPERROR_EXIT ); |
791 } |
810 } |
792 |
811 |
793 /** |
812 /** |
794 Signals the MTP connection transport to terminate any in-progress data phase |
813 Signals the MTP connection transport to terminate any in-progress data phase |
795 processing on the specified session. |
814 processing on the specified session. |
796 @param aidx The sessions table index of the required session. |
815 @param aidx The sessions table index of the required session. |
797 @leave One of the system wide error codes, if a processing failure occurs. |
816 @leave One of the system wide error codes, if a processing failure occurs. |
798 */ |
817 */ |
799 void CMTPConnection::InitiateTransactionCancelL(TInt aIdx) |
818 void CMTPConnection::InitiateTransactionCancelL(TInt aIdx) |
800 { |
819 { |
801 __FLOG(_L8("InitiateTransactionCancelL - Entry")); |
820 OstTraceFunctionEntry0( CMTPCONNECTION_INITIATETRANSACTIONCANCELL_ENTRY ); |
802 // Initiate transport connection level termination of the active data phase. |
821 // Initiate transport connection level termination of the active data phase. |
803 CMTPSession& session(*iSessions[aIdx]); |
822 CMTPSession& session(*iSessions[aIdx]); |
804 |
823 |
805 switch (session.TransactionPhase()) |
824 switch (session.TransactionPhase()) |
806 { |
825 { |
816 case EResponsePhase: |
835 case EResponsePhase: |
817 case EDataRToIPhase: |
836 case EDataRToIPhase: |
818 iTransportConnection->SendDataCancelL(session.ActiveRequestL()); |
837 iTransportConnection->SendDataCancelL(session.ActiveRequestL()); |
819 break; |
838 break; |
820 } |
839 } |
821 __FLOG(_L8("InitiateTransactionCancelL - Exit")); |
840 OstTraceFunctionExit0( CMTPCONNECTION_INITIATETRANSACTIONCANCELL_EXIT ); |
822 } |
841 } |
823 |
842 |
824 /** |
843 /** |
825 Provides a count of the number of sessions with transactions in-progress. |
844 Provides a count of the number of sessions with transactions in-progress. |
826 */ |
845 */ |
827 TUint CMTPConnection::ActiveSessions() const |
846 TUint CMTPConnection::ActiveSessions() const |
828 { |
847 { |
829 __FLOG(_L8("ActiveSessions - Entry")); |
848 OstTraceFunctionEntry0( CMTPCONNECTION_ACTIVESESSIONS_ENTRY ); |
830 TUint active(0); |
849 TUint active(0); |
831 const TUint count(iSessions.Count()); |
850 const TUint count(iSessions.Count()); |
832 for (TUint i(0); (i < count); i++) |
851 for (TUint i(0); (i < count); i++) |
833 { |
852 { |
834 if (iSessions[i]->TransactionPhase() > EIdlePhase) |
853 if (iSessions[i]->TransactionPhase() > EIdlePhase) |
835 { |
854 { |
836 active++; |
855 active++; |
837 } |
856 } |
838 } |
857 } |
839 __FLOG_VA((_L8("Active sessions = %d"), active)); |
858 OstTrace1( TRACE_NORMAL, CMTPCONNECTION_ACTIVESESSIONS, "Active sessions = %d", active ); |
840 __FLOG(_L8("ActiveSessions - Exit")); |
859 OstTraceFunctionExit0( CMTPCONNECTION_ACTIVESESSIONS_EXIT ); |
841 return active; |
860 return active; |
842 } |
861 } |
843 |
862 |
844 /** |
863 /** |
845 Closes all sessions which have been opened on the connection. |
864 Closes all sessions which have been opened on the connection. |
846 */ |
865 */ |
847 void CMTPConnection::CloseAllSessions() |
866 void CMTPConnection::CloseAllSessions() |
848 { |
867 { |
849 __FLOG(_L8("CloseAllSessions - Entry")); |
868 OstTraceFunctionEntry0( CMTPCONNECTION_CLOSEALLSESSIONS_ENTRY ); |
850 |
869 |
851 TInt count = iSessions.Count(); |
870 TInt count = iSessions.Count(); |
852 __FLOG_VA((_L8("Sessions number to be closed = %d"), count)); |
871 OstTrace1( TRACE_NORMAL, CMTPCONNECTION_CLOSEALLSESSIONS, "Sessions number to be closed = %d", count ); |
853 for (TInt i(count - 1); i>=0; i--) |
872 for (TInt i(count - 1); i>=0; i--) |
854 { |
873 { |
855 CloseSession(i); |
874 CloseSession(i); |
856 } |
875 } |
857 |
876 |
858 __FLOG(_L8("CloseAllSessions - Exit")); |
877 OstTraceFunctionExit0( CMTPCONNECTION_CLOSEALLSESSIONS_EXIT ); |
859 } |
878 } |
860 |
879 |
861 /** |
880 /** |
862 Closes the sessions with the specified session index. |
881 Closes the sessions with the specified session index. |
863 @param aIdx The session index. |
882 @param aIdx The session index. |
864 */ |
883 */ |
865 void CMTPConnection::CloseSession(TUint aIdx) |
884 void CMTPConnection::CloseSession(TUint aIdx) |
866 { |
885 { |
867 __FLOG(_L8("CloseSession - Entry")); |
886 OstTraceFunctionEntry0( CMTPCONNECTION_CLOSESESSION_ENTRY ); |
868 |
887 |
869 __FLOG_VA((_L8("Session index to be closed = %d"), aIdx)); |
888 OstTrace1(TRACE_NORMAL, CMTPCONNECTION_CLOSESESSION, "Session index to be closed = %d", aIdx); |
870 CMTPSession* session(iSessions[aIdx]); |
889 CMTPSession* session(iSessions[aIdx]); |
871 |
890 |
872 TUint id(session->SessionMTPId()); |
891 TUint id(session->SessionMTPId()); |
873 if (id != KMTPSessionNone) |
892 if (id != KMTPSessionNone) |
874 { |
893 { |
936 Get the data receive result. |
955 Get the data receive result. |
937 @return the data recevice result. |
956 @return the data recevice result. |
938 */ |
957 */ |
939 EXPORT_C TInt CMTPConnection::GetDataReceiveResult() const |
958 EXPORT_C TInt CMTPConnection::GetDataReceiveResult() const |
940 { |
959 { |
941 __FLOG(_L8("GetDataReceiveResult - Entry")); |
960 OstTraceFunctionEntry0( CMTPCONNECTION_GETDATARECEIVERESULT_ENTRY ); |
942 __FLOG_VA((_L8("Data receive result = %d"), iDataReceiveResult)); |
961 OstTrace1( TRACE_NORMAL, CMTPCONNECTION_GETDATARECEIVERESULT, "Data receive result = %d", iDataReceiveResult); |
943 __FLOG(_L8("GetDataReceiveResult - Exit")); |
962 OstTraceFunctionExit0( CMTPCONNECTION_GETDATARECEIVERESULT_EXIT ); |
944 return iDataReceiveResult; |
963 return iDataReceiveResult; |
945 } |
964 } |
946 |
965 |
947 /** |
966 /** |
948 Sets the MTP connection state variable. |
967 Sets the MTP connection state variable. |
949 @param aState The new MTP connection state value. |
968 @param aState The new MTP connection state value. |
950 */ |
969 */ |
951 void CMTPConnection::SetState(TUint aState) |
970 void CMTPConnection::SetState(TUint aState) |
952 { |
971 { |
953 __FLOG(_L8("SetState - Entry")); |
972 OstTraceFunctionEntry0( CMTPCONNECTION_SETSTATE_ENTRY ); |
954 __FLOG_VA((_L8("Setting state = %d"), aState)); |
973 OstTrace1( TRACE_NORMAL, CMTPCONNECTION_SETSTATE, "CMTPConnection::SetState;aState=%d", aState ); |
955 iState = aState; |
974 iState = aState; |
956 __FLOG(_L8("SetState - Exit")); |
975 OstTraceFunctionExit0( CMTPCONNECTION_SETSTATE_EXIT ); |
957 } |
976 } |
958 |
977 |
959 |
978 |
960 /** |
979 /** |
961 Provide the current MTP connection state. |
980 Provide the current MTP connection state. |
962 @return The current MTP connection state. |
981 @return The current MTP connection state. |
963 */ |
982 */ |
964 TUint CMTPConnection::State() const |
983 TUint CMTPConnection::State() const |
965 { |
984 { |
966 __FLOG(_L8("State - Entry")); |
985 OstTraceFunctionEntry0( CMTPCONNECTION_STATE_ENTRY ); |
967 __FLOG_VA((_L8("State = %d"), iState)); |
986 OstTrace1( TRACE_NORMAL, CMTPCONNECTION_STATE, "State = %d", iState); |
968 __FLOG(_L8("State - Exit")); |
987 OstTraceFunctionExit0( CMTPCONNECTION_STATE_EXIT ); |
969 return iState; |
988 return iState; |
970 } |
989 } |
971 |
990 |
972 /** |
991 /** |
973 Performs common validation processing for requests initiated from the data |
992 Performs common validation processing for requests initiated from the data |
1080 * This method define and attach the property for publishing connection state |
1099 * This method define and attach the property for publishing connection state |
1081 * events. |
1100 * events. |
1082 */ |
1101 */ |
1083 void CMTPConnection::DefineConnStatePropertyL() |
1102 void CMTPConnection::DefineConnStatePropertyL() |
1084 { |
1103 { |
1085 |
1104 OstTraceFunctionEntry0( CMTPCONNECTION_DEFINECONNSTATEPROPERTYL_ENTRY ); |
1086 __FLOG(_L8("DefineConnStatePropertyL - Entry")); |
|
1087 RProcess process; |
1105 RProcess process; |
1088 TUid tSid = process.SecureId(); |
1106 TUid tSid = process.SecureId(); |
1089 //Property can read by anyone who subscribe for it. |
1107 //Property can read by anyone who subscribe for it. |
1090 _LIT_SECURITY_POLICY_PASS(KAllowReadAll); |
1108 _LIT_SECURITY_POLICY_PASS(KAllowReadAll); |
1091 _LIT_SECURITY_POLICY_S0(KAllowWrite, (TSecureId )KMTPPublishConnStateCat); |
1109 _LIT_SECURITY_POLICY_S0(KAllowWrite, (TSecureId )KMTPPublishConnStateCat); |
1092 |
1110 |
1093 TInt error = RProperty::Define(tSid, EMTPConnStateKey, RProperty::EInt, KAllowReadAll, KAllowReadAll); |
1111 TInt error = RProperty::Define(tSid, EMTPConnStateKey, RProperty::EInt, KAllowReadAll, KAllowReadAll); |
1094 if (KErrAlreadyExists != error) |
1112 if (KErrAlreadyExists != error) |
1095 { |
1113 { |
1096 User::LeaveIfError(error); |
1114 LEAVEIFERROR(error, OstTrace1(TRACE_ERROR, CMTPCONNECTION_DEFINECONNSTATEPROPERTYL, "property define error! error code %d", error)); |
1097 } |
1115 } |
1098 User::LeaveIfError(iProperty.Attach(tSid, EMTPConnStateKey, EOwnerThread)); |
1116 LEAVEIFERROR(iProperty.Attach(tSid, EMTPConnStateKey, EOwnerThread), |
1099 __FLOG(_L8("DefineConnStatePropertyL - Exit")); |
1117 OstTrace0(TRACE_ERROR, DUP1_CMTPCONNECTION_DEFINECONNSTATEPROPERTYL, "property attach error")); |
|
1118 OstTraceFunctionExit0( CMTPCONNECTION_DEFINECONNSTATEPROPERTYL_EXIT ); |
1100 } |
1119 } |
1101 |
1120 |
1102 /** |
1121 /** |
1103 * This method is to publish various connection state. |
1122 * This method is to publish various connection state. |
1104 */ |
1123 */ |
1105 void CMTPConnection::PublishConnState(TMTPConnStateType aConnState) |
1124 void CMTPConnection::PublishConnState(TMTPConnStateType aConnState) |
1106 { |
1125 { |
1107 __FLOG_VA((_L8("PublishConnState - Entry \n publishing state = %d"), (TInt)aConnState)); |
1126 OstTraceFunctionEntry0( CMTPCONNECTION_PUBLISHCONNSTATE_ENTRY); |
|
1127 OstTrace1( TRACE_NORMAL, CMTPCONNECTION_PUBLISHCONNSTATE, "publishing state = %d", (TInt)aConnState ); |
|
1128 |
1108 RProcess process; |
1129 RProcess process; |
1109 TInt error = iProperty.Set(process.SecureId(), EMTPConnStateKey, (TInt)aConnState); |
1130 TInt error = iProperty.Set(process.SecureId(), EMTPConnStateKey, (TInt)aConnState); |
1110 __ASSERT_DEBUG((error == KErrNone), Panic(EMTPPanicPublishEvent));; |
1131 __ASSERT_DEBUG((error == KErrNone), Panic(EMTPPanicPublishEvent));; |
1111 __FLOG(_L8("PublishConnState - Exit")); |
1132 OstTraceFunctionExit0( CMTPCONNECTION_PUBLISHCONNSTATE_EXIT); |
1112 } |
1133 } |
1113 |
1134 |
1114 /** |
1135 /** |
1115 * This method is used to publish the events based on the TransactionPhase. |
1136 * This method is used to publish the events based on the TransactionPhase. |
1116 * |
1137 * |
1117 */ |
1138 */ |
1118 void CMTPConnection::ValidateAndPublishConnState(CMTPSession& aSession, TInt aState) |
1139 void CMTPConnection::ValidateAndPublishConnState(CMTPSession& aSession, TInt aState) |
1119 { |
1140 { |
1120 __FLOG_VA((_L8("ValidateAndPublishConnState - Entry \n publishing state = %d"), aState)); |
1141 OstTraceFunctionEntry0(CMTPCONNECTION_VALIDATEANDPUBLISHCONNSTATE_ENTRY); |
1121 |
1142 OstTrace1( TRACE_NORMAL, CMTPCONNECTION_VALIDATEANDPUBLISHCONNSTATE, "publishing state = %d", aState ); |
|
1143 |
1122 TMTPConnStateType conState = EConnectedToHost; |
1144 TMTPConnStateType conState = EConnectedToHost; |
1123 switch((TStates)aState) |
1145 switch((TStates)aState) |
1124 { |
1146 { |
1125 case EStateOpen: |
1147 case EStateOpen: |
1126 { |
1148 { |