CMTPConnection Class Reference

class CMTPConnection : public CBase

Implements the connection level portion of the MTP communication model and associated transport layer protocol binding. This class Implements the API portion ( MMTPConnectionProtocol ) of the transport layer API/SPI interface pair by which MTP framework and transport protocol connections ( MMTPTransportConnection ) interact. A unique CMTPConnection instance is created and bound to each MMTPTransportConnection instance that is loaded.It also implements the data provider layer MTP connection interface ( MMTPConnection ) which represents the virtual circuit between data provider and the transport layer.

Inherits from

Nested Classes and Structures

Public Member Functions
~CMTPConnection ()
TUint ConnectionId ()
void ConnectionResumedL ( MMTPTransportConnection &)
TBool ConnectionSuspended ()
void DisconnectionNotifyL ()
IMPORT_C TInt GetDataReceiveResult ()
CMTPConnection * NewLC ( TUint , MMTPTransportConnection &)
void ReceiveDataL ( MMTPType &, const TMTPTypeRequest &, TRequestStatus &)
void SendDataL (const MMTPType &, const TMTPTypeRequest &, TRequestStatus &)
void SendEventL (const TMTPTypeEvent &)
void SendResponseL (const TMTPTypeResponse &, const TMTPTypeRequest &, TRequestStatus &)
IMPORT_C void SessionClosedL ( TUint32 )
TUint SessionCount ()
IMPORT_C void SessionOpenedL ( TUint32 )
TBool SessionWithMTPIdExists ( TUint32 )
MMTPSession & SessionWithMTPIdL ( TUint32 )
TBool SessionWithUniqueIdExists ( TUint32 )
MMTPSession & SessionWithUniqueIdL ( TUint32 )
void TransactionCompleteL (const TMTPTypeRequest &)
TMTPTransactionPhase TransactionPhaseL ( TUint32 )
Private Member Functions
CMTPConnection ( TUint , MMTPTransportConnection &)
TUint ActiveSessions ()
void CloseAllSessions ()
void CloseSession ( TUint )
void CompleteCloseConnection ()
void ConstructL ()
void DefineConnStatePropertyL ()
void DequeueEvent ( CMTPEventLink *)
void EnqueueEvent ( CMTPEventLink *)
void InitiateMTPErrorRecoveryL (const TMTPTypeRequest &, TUint16 )
void InitiateTransactionCancelL ( TInt )
void MTPErrorRecoveryComplete ()
void PublishConnState ( TMTPConnStateType )
void ReceiveDataCompleteL ( TInt , const MMTPType &, const TMTPTypeRequest &)
void ReceivedEventL (const TMTPTypeEvent &)
void ReceivedRequestL (const TMTPTypeRequest &)
void RemoveEventsForSession ( TUint32 )
void SendDataCompleteL ( TInt , const MMTPType &, const TMTPTypeRequest &)
void SendEventCompleteL ( TInt , const TMTPTypeEvent &)
void SendResponseCompleteL ( TInt , const TMTPTypeResponse &, const TMTPTypeRequest &)
CMTPSession & SessionL (const TMTPTypeFlatBase &, TInt )
TInt SessionOrder (const TUint32 *, const CMTPSession &)
TInt SessionOrder (const CMTPSession &, const CMTPSession &)
void SetState ( TUint )
TUint State ()
void Unbind ( MMTPTransportConnection &)
void UnrecoverableMTPError ()
TBool ValidFrameworkRequest ( CMTPSession *, TUint , TRequestStatus *)
void ValidateAndPublishConnState ( CMTPSession &, TInt )
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Private Member Enumerations
enum TStates { EStateUnknown , EStateOpen , EStateErrorRecovery , EStateErrorShutdown , EStateShutdown }
Private Attributes
__FLOG_DECLARATION_MEMBER_MUTABLE
TUint iConnectionId
TInt iDataReceiveResult
TSglQue < CMTPEventLink > iEventQ
TAny * iExtendedInterface
TInt iPendingEventCount
RProperty iProperty
TMTPTypeResponse iResponse
RPointerArray < CMTPSession > iSessions
RMTPFramework iSingletons
TUint iState
MMTPTransportConnection * iTransportConnection

Constructor & Destructor Documentation

CMTPConnection(TUint, MMTPTransportConnection &)

CMTPConnection ( TUint aConnectionId,
MMTPTransportConnection & aTransportConnection
) [private]

Constructor.

Parameters

TUint aConnectionId
MMTPTransportConnection & aTransportConnection

~CMTPConnection()

~CMTPConnection ( )

Destructor.

Member Functions Documentation

ActiveSessions()

TUint ActiveSessions ( ) const [private]

Provides a count of the number of sessions with transactions in-progress.

CloseAllSessions()

void CloseAllSessions ( ) [private]

Closes all sessions which have been opened on the connection.

CloseSession(TUint)

void CloseSession ( TUint aIdx ) [private]

Closes the sessions with the specified session index.

Parameters

TUint aIdx The session index.

CompleteCloseConnection()

void CompleteCloseConnection ( ) [private]

ConnectionId()

TUint ConnectionId ( ) const

ConnectionResumedL(MMTPTransportConnection &)

void ConnectionResumedL ( MMTPTransportConnection & aTransportConnection )

Parameters

MMTPTransportConnection & aTransportConnection

ConnectionSuspended()

TBool ConnectionSuspended ( )

ConstructL()

void ConstructL ( ) [private]
Second phase constructor.
leave
One of the system wide error code, if a processing failure occurs.

DefineConnStatePropertyL()

void DefineConnStatePropertyL ( ) [private]

This method define and attach the property for publishing connection state events.

DequeueEvent(CMTPEventLink *)

void DequeueEvent ( CMTPEventLink * aLink ) [private]

Parameters

CMTPEventLink * aLink

DisconnectionNotifyL()

void DisconnectionNotifyL ( )

EnqueueEvent(CMTPEventLink *)

void EnqueueEvent ( CMTPEventLink * aLink ) [private]

Parameters

CMTPEventLink * aLink

GetDataReceiveResult()

IMPORT_C TInt GetDataReceiveResult ( ) const

Get the data receive result.

InitiateMTPErrorRecoveryL(const TMTPTypeRequest &, TUint16)

void InitiateMTPErrorRecoveryL ( const TMTPTypeRequest & aRequest,
TUint16 aResponseCode
) [private]
Initiates an MTP connection level protocol error recovery sequence. This sequence is invoked when a recoverable protocol error is detected that cannot be processed above the connection layer, e.g. when a request is made on a non-existant SessionID, or an out-of-sequence TransactionID is detected. An appropriate MTP response dataset is formed and sent to the MTP initiator. The error recovery sequence is concluded by MTPErrorRecoveryComplete when the connection transport layer signals SendResponseComplete to the MTP connection protocol layer.
leave
One of the system wide error codes, if a processing failure occurs.
MTPErrorRecoveryComplete

Parameters

const TMTPTypeRequest & aRequest The MTP request dataset of the erroneous MTP transaction.
TUint16 aResponseCode The MTP response datacode to be returned to the MTP initiator.

InitiateTransactionCancelL(TInt)

void InitiateTransactionCancelL ( TInt aSessionIdx ) [private]
Signals the MTP connection transport to terminate any in-progress data phase processing on the specified session.
leave
One of the system wide error codes, if a processing failure occurs.

Parameters

TInt aSessionIdx

MTPErrorRecoveryComplete()

void MTPErrorRecoveryComplete ( ) [private]

Concludes an MTP connection level protocol error recovery sequence. InitiateMTPErrorRecoveryL

NewLC(TUint, MMTPTransportConnection &)

CMTPConnection * NewLC ( TUint aConnectionId,
MMTPTransportConnection & aTransportConnection
) [static]
CMTPConnection factory method. A pointer to the new CMTPConnection instance is placed on the cleanup stack.
leave
One of the system wide error codes if a processing failure occurs.

Parameters

TUint aConnectionId The unique identifier assigned to this connection by the MTP framework.
MMTPTransportConnection & aTransportConnection The MTP transport layer connection interface to which the CMTPConnection will bind.

PublishConnState(TMTPConnStateType)

void PublishConnState ( TMTPConnStateType aConnState ) [private]

This method is to publish various connection state.

Parameters

TMTPConnStateType aConnState

ReceiveDataCompleteL(TInt, const MMTPType &, const TMTPTypeRequest &)

void ReceiveDataCompleteL ( TInt aErr,
const MMTPType & aData,
const TMTPTypeRequest & aRequest
) [private]

Parameters

TInt aErr
const MMTPType & aData
const TMTPTypeRequest & aRequest

ReceiveDataL(MMTPType &, const TMTPTypeRequest &, TRequestStatus &)

void ReceiveDataL ( MMTPType & aData,
const TMTPTypeRequest & aRequest,
TRequestStatus & aStatus
)
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.
leave
KErrNotFound If the MTP request dataset specifies an invalid SessionID.
panic
CMTPConnection 0 If an asynchronous request is already pending on the connection.
panic
CMTPConnection 2 If the MTP transaction phase is invalid.

Parameters

MMTPType & aData The MTP data object sink.
const TMTPTypeRequest & aRequest The MTP request dataset of the active MTP transaction.
TRequestStatus & aStatus The status used to return asynchronous completion information regarding the request.

ReceivedEventL(const TMTPTypeEvent &)

void ReceivedEventL ( const TMTPTypeEvent & aEvent ) [private]

Parameters

const TMTPTypeEvent & aEvent

ReceivedRequestL(const TMTPTypeRequest &)

void ReceivedRequestL ( const TMTPTypeRequest & aRequest ) [private]

Parameters

const TMTPTypeRequest & aRequest

RemoveEventsForSession(TUint32)

void RemoveEventsForSession ( TUint32 aMTPId ) [private]

Parameters

TUint32 aMTPId

SendDataCompleteL(TInt, const MMTPType &, const TMTPTypeRequest &)

void SendDataCompleteL ( TInt aErr,
const MMTPType & aData,
const TMTPTypeRequest & aRequest
) [private]

Parameters

TInt aErr
const MMTPType & aData
const TMTPTypeRequest & aRequest

SendDataL(const MMTPType &, const TMTPTypeRequest &, TRequestStatus &)

void SendDataL ( const MMTPType & aData,
const TMTPTypeRequest & aRequest,
TRequestStatus & aStatus
)
Initiates MTP transaction data phase processing for responder-to-initiator data flows. This method should only be invoked when the MTP transaction phase state is ERequestPhase. This is an asynchronous method.
leave
KErrNotFound If the MTP request dataset specifies an invalid SessionID.
panic
CMTPConnection 0 If an asynchronous request is already pending on the connection.
panic
CMTPConnection 2 If the MTP transaction phase is invalid.

Parameters

const MMTPType & aData The MTP data object source.
const TMTPTypeRequest & aRequest The MTP request dataset of the active MTP transaction.
TRequestStatus & aStatus The status used to return asynchronous completion information regarding the request.

SendEventCompleteL(TInt, const TMTPTypeEvent &)

void SendEventCompleteL ( TInt aErr,
const TMTPTypeEvent & aEvent
) [private]

Parameters

TInt aErr
const TMTPTypeEvent & aEvent

SendEventL(const TMTPTypeEvent &)

void SendEventL ( const TMTPTypeEvent & aEvent )
Sends an MTP event dataset.
leave
KErrNotFound If the MTP event dataset specifies an invalid SessionID.

Parameters

const TMTPTypeEvent & aEvent The MTP event dataset source.

SendResponseCompleteL(TInt, const TMTPTypeResponse &, const TMTPTypeRequest &)

void SendResponseCompleteL ( TInt aErr,
const TMTPTypeResponse & aResponse,
const TMTPTypeRequest & aRequest
) [private]

Parameters

TInt aErr
const TMTPTypeResponse & aResponse
const TMTPTypeRequest & aRequest

SendResponseL(const TMTPTypeResponse &, const TMTPTypeRequest &, TRequestStatus &)

void SendResponseL ( const TMTPTypeResponse & aResponse,
const TMTPTypeRequest & aRequest,
TRequestStatus & aStatus
)
Initiates MTP transaction response phase processing. This method should only be invoked when the MTP transaction phase state is either ERequestPhase, or EResponsePhase. This is an asynchronous method.
leave
KErrNotFound If the MTP response dataset specifies an invalid SessionID.
leave
KErrArgument If the MTP response dataset does not match the specified request dataset.
panic
CMTPConnection 0 If an asynchronous request is already pending on the connection.
panic
CMTPConnection 2 If the MTP transaction phase is invalid.

Parameters

const TMTPTypeResponse & aResponse The MTP response dataset source.
const TMTPTypeRequest & aRequest The MTP request dataset of the active MTP transaction.
TRequestStatus & aStatus The status used to return asynchronous completion information regarding the request.

SessionClosedL(TUint32)

IMPORT_C void SessionClosedL ( TUint32 aSessionMTPId )
Deletes the session object assigned to the specified session and notifies all loaded data providers.
leave
KErrNotFound, if a session with the specified SessionMTPId is not found.
leave
One of the system wide error codes, if a general processing failure occurs.

Parameters

TUint32 aSessionMTPId The session identifier assigned by the MTP connection initiator.

SessionCount()

TUint SessionCount ( ) const

SessionL(const TMTPTypeFlatBase &, TInt)

CMTPSession & SessionL ( const TMTPTypeFlatBase & aDataset,
TInt aSessionIdElementNo
) const [private]
Provides a reference to the session with the MTP connection assigned identifier specified in the supplied MTP dataset.
leave
KErrNotFound If the specified session identifier is not currently active on the connection.

Parameters

const TMTPTypeFlatBase & aDataset The MTP dataset.
TInt aSessionIdElementNo The element number in the MTP dataset of the MTP connection assigned identifier.

SessionOpenedL(TUint32)

IMPORT_C void SessionOpenedL ( TUint32 aSessionMTPId )
Creates a new session object for the specified session and notifies all loaded data providers. The session is known by two identifiers: 1. SessionMTPId - Assigned by the MTP connection initiator and unique only to the MTP connection on which the session was opened. In a multiple- connection configuration this identifier may not uniquely identify the session. 2. SessionUniqueId - Assigned by the MTP daemon and guaranteed to uniquely identify the session in a multiple-connection configuration. Currently the MTP daemon does not support multiple-connection configuration and both identifiers are assigned the same value.
leave
KErrAlreadyExists, if a session with the specified SessionMTPId is already open.
leave
One of the system wide error codes, if a general processing failure occurs.

Parameters

TUint32 aSessionMTPId The session identifier assigned by the MTP connection initiator.

SessionOrder(const TUint32 *, const CMTPSession &)

TInt SessionOrder ( const TUint32 * aL,
const CMTPSession & aR
) [private, static]

Implements an order relation for CMTPSession objects based on relative MTP connection assigned session IDs.

Parameters

const TUint32 * aL The first MTP connection assigned session ID.
const CMTPSession & aR The second object.

SessionOrder(const CMTPSession &, const CMTPSession &)

TInt SessionOrder ( const CMTPSession & aL,
const CMTPSession & aR
) [private, static]

Implements a TLinearOrder relation for CMTPSession objects based on relative MTP connection assigned session IDs.

Parameters

const CMTPSession & aL The first object.
const CMTPSession & aR The second object.

SessionWithMTPIdExists(TUint32)

TBool SessionWithMTPIdExists ( TUint32 aMTPId ) const

Parameters

TUint32 aMTPId

SessionWithMTPIdL(TUint32)

MMTPSession & SessionWithMTPIdL ( TUint32 aMTPId ) const

Parameters

TUint32 aMTPId

SessionWithUniqueIdExists(TUint32)

TBool SessionWithUniqueIdExists ( TUint32 aUniqueId ) const

Parameters

TUint32 aUniqueId

SessionWithUniqueIdL(TUint32)

MMTPSession & SessionWithUniqueIdL ( TUint32 aUniqueId ) const

Parameters

TUint32 aUniqueId

SetState(TUint)

void SetState ( TUint aState ) [private]

Sets the MTP connection state variable.

Parameters

TUint aState The new MTP connection state value.

State()

TUint State ( ) const [private]

Provide the current MTP connection state.

TransactionCompleteL(const TMTPTypeRequest &)

void TransactionCompleteL ( const TMTPTypeRequest & aRequest )
Signals the completion of the current transaction processing sequence. This method should only be invoked when the MTP transaction phase state is ECompletingPhase.
leave
KErrNotFound If the MTP request dataset specifies an invalid SessionID.
panic
CMTPConnection 2 If the MTP transaction phase is invalid.

Parameters

const TMTPTypeRequest & aRequest The MTP request dataset of the completed MTP transaction.

TransactionPhaseL(TUint32)

TMTPTransactionPhase TransactionPhaseL ( TUint32 aMTPSessionId ) const

Parameters

TUint32 aMTPSessionId

Unbind(MMTPTransportConnection &)

void Unbind ( MMTPTransportConnection & aConnection ) [private]

Parameters

MMTPTransportConnection & aConnection

UnrecoverableMTPError()

void UnrecoverableMTPError ( ) [private]

Forces the immediate shutdown of the MTP connection. This is invoked when a protocol error is detected that cannot be recovered from, e.g. if an attempt is detected to initiate an MTP transaction before a previous transaction has concluded.

ValidFrameworkRequest(CMTPSession *, TUint, TRequestStatus *)

TBool ValidFrameworkRequest ( CMTPSession * aSession,
TUint aValidStates,
TRequestStatus * aStatus
) [private]
Performs common validation processing for requests initiated from the data provider framework layer. The following validation checks are performed. 1. Attempt to initiate concurrent asynchronous requests to the same connection. This will result in a panic. 2. Attempt to initiate a request that is invalid for the current transaction phase. This will result in a panic. 3. Attempt to initiate a request when the connection is in an unrecoverable error shutdown mode. This will result in the immediate cancellation of the request.
panic
CMTPConnection 0 If an asynchronous request is already pending on the connection.
panic
CMTPConnection 2 If the MTP transaction phase is invalid.

Parameters

CMTPSession * aSession
TUint aValidStates
TRequestStatus * aStatus

ValidateAndPublishConnState(CMTPSession &, TInt)

void ValidateAndPublishConnState ( CMTPSession & aSession,
TInt aState
) [private]

This method is used to publish the events based on the TransactionPhase.

Parameters

CMTPSession & aSession
TInt aState

Member Enumerations Documentation

Enum TStates

Enumerators

EStateUnknown
EStateOpen
EStateErrorRecovery
EStateErrorShutdown
EStateShutdown

Member Data Documentation

__FLOG_DECLARATION_MEMBER_MUTABLE

__FLOG_DECLARATION_MEMBER_MUTABLE [private]

FLOGGER debug trace member variable.

TUint iConnectionId

TUint iConnectionId [private]

TInt iDataReceiveResult

TInt iDataReceiveResult [private]

TSglQue< CMTPEventLink > iEventQ

TSglQue < CMTPEventLink > iEventQ [private]

TAny * iExtendedInterface

TAny * iExtendedInterface [private]

TInt iPendingEventCount

TInt iPendingEventCount [private]

RProperty iProperty

RProperty iProperty [private]

TMTPTypeResponse iResponse

TMTPTypeResponse iResponse [private]

RPointerArray< CMTPSession > iSessions

RPointerArray < CMTPSession > iSessions [private]

RMTPFramework iSingletons

RMTPFramework iSingletons [private]

TUint iState

TUint iState [private]

MMTPTransportConnection * iTransportConnection

MMTPTransportConnection * iTransportConnection [private]