diff -r d0791faffa3f -r f8e15b44d440 mtpfws/mtpfw/src/cmtpconnection.cpp --- a/mtpfws/mtpfw/src/cmtpconnection.cpp Tue Feb 02 01:11:40 2010 +0200 +++ b/mtpfws/mtpfw/src/cmtpconnection.cpp Fri Feb 19 23:40:44 2010 +0200 @@ -108,14 +108,6 @@ } /** -Unbinds the Transport Connection -*/ -void CMTPConnection::Unbind(MMTPTransportConnection& /*aConnection*/) - { - iTransportConnection = NULL; - } - -/** Initiates MTP transaction data phase processing for initiator-to-responder data flows. This method should only be invoked when the MTP transaction phase state is ERequestPhase. This is an asynchronous method. @@ -351,45 +343,43 @@ * Signals the connection is suspended, the connection state is set to EStateShutdown which * means that all the current transaction will not be able to send/receive any data via the * connection + * @return ETrue - there is an active transaction currently, and Connection will suspend when it finishes + * EFalse - No active transaction, connection suspends immediately. */ -void CMTPConnection::ConnectionSuspended() +TBool CMTPConnection::ConnectionSuspended() { __FLOG(_L8("ConnectionSuspended - Entry")); + TBool ret = EFalse; TUint currentState = State(); - if (currentState!=EStateShutdown && currentState!=EStateErrorShutdown) + if (currentState != EStateShutdown) { - SetState(EStateShutdown); - - if (iTransportConnection != NULL) - { - iTransportConnection->Unbind(*this); - iTransportConnection = NULL; - } - PublishConnState(EDisconnectedFromHost); - - if (ActiveSessions() == 0) + if (ActiveSessions() == 0 || currentState == EStateErrorShutdown) { - CloseAllSessions(); - iSessions.Reset(); - iSingletons.Close(); + CompleteCloseConnection(); + ret = ETrue; } - else - { - //some session may be in data or response phase, complete them and set transaction phase to ECompletingPhase. - const TUint count(iSessions.Count()); - for (TUint i(0); (i < count); i++) - { - if (iSessions[i]->TransactionPhase() & (EDataIToRPhase|EDataRToIPhase|EResponsePhase)) - { - iSessions[i]->SetTransactionPhase(ECompletingPhase); - iSessions[i]->CompletePendingRequest(KErrCancel); - } - } - } + + SetState(EStateShutdown); + PublishConnState(EDisconnectedFromHost); } __FLOG(_L8("ConnectionSuspended - Exit")); + return ret; + } + +void CMTPConnection::CompleteCloseConnection() + { + __FLOG(_L8("CompleteCloseConnection - Entry")); + + CloseAllSessions(); + iSessions.Reset(); + + //notify ConnectionMgr and corresponding transports of completion of connection close + iSingletons.ConnectionMgr().ConnectionCloseComplete(iConnectionId); + iSingletons.Close(); + + __FLOG(_L8("CompleteCloseConnection - Exit")); } /* @@ -439,24 +429,18 @@ if (ValidFrameworkRequest(&session, KValidPhases, NULL)) { session.SetTransactionPhase(EIdlePhase); - if (State() == EStateShutdown) - { - if (ActiveSessions() == 0) - { - CloseAllSessions(); - iSessions.Reset(); - iSingletons.Close(); - - // Move the log here because ShutdownComplete will delete this object. - __FLOG(_L8("TransactionCompleteL - Exit")); - } + + if (State() == EStateShutdown && ActiveSessions() == 0) + { + CompleteCloseConnection(); } - else + + if (iTransportConnection != NULL) { iTransportConnection->TransactionCompleteL(aRequest); - __FLOG(_L8("TransactionCompleteL - Exit")); } } + __FLOG(_L8("TransactionCompleteL - Exit")); } TUint CMTPConnection::ConnectionId() const @@ -700,6 +684,11 @@ __FLOG(_L8("SendResponseCompleteL - Exit")); } +void CMTPConnection::Unbind(MMTPTransportConnection& /*aConnection*/) + { + iTransportConnection = NULL; + } + TMTPTransactionPhase CMTPConnection::TransactionPhaseL(TUint32 aMTPId) const {