CObexServerSendOperation Class Reference

class CObexServerSendOperation : public CActive

class CObexServerSendOperation

Obex Server Send Operation:

Base class for Send operations using Obex protocol.

Implements a state machine with the following states: Initialise-->Connect-->ConnectAttemptComplete-->SendObject-->(SendNextObject-->)SendComplete-->MovedToSent-->Disconnected

The pure virtual function InitialiseObexClientL() must be overridden in the base class to initialise the iObexClient member to use the desired Obex transport mechanism (e.g. infrared, Bluetooth).

In order to allow asynchronous transport initialisations (for example BT's SDP Query) implementations of this function must set iAsyncInit and provide a mechanism to complete a request. See the bluetooth server mtm code for implementation details.

Inherits from

Public Member Functions
~CObexServerSendOperation()
voidInitialiseObexClientL()
IMPORT_C voidPostConnectOperations()
IMPORT_C voidPostSendOperations()
IMPORT_C voidPreConnectOperations()
IMPORT_C voidPreSendOperations()
IMPORT_C const TDesC8 &ProgressL()
IMPORT_C voidSecondPhaseObexClientInitL()
voidTimeOut()
Protected Member Functions
CObexServerSendOperation(TUid, CMsvServerEntry &, TInt, TInt, TRequestStatus &)
CObexServerSendOperation(TUid, CMsvServerEntry &, TInt, TInt, TRequestStatus &, TBool)
IMPORT_C TBoolCompletingObserver(TInt)
IMPORT_C voidConstructL(const TDesC *)
IMPORT_C voidDoCancel()
Private Member Functions
voidActivateRunLWithError(TInt)
voidBuildSpecificConstructL()
voidBuildSpecificDestructor()
TBool CheckStatusOfLastObject(TInt, TObexMtmProgress::TSendState)
voidCleanupAfterMovedToSent()
voidCompleteObserverL()
voidCompleteSelf(TInt)
voidExplicitCancel()
RFs &FileSession()
IMPORT_C voidGetUserPasswordL(const TDesC &)
voidInitialiseAttachmentL(CMsvServerEntry &, TInt)
voidLoadFileIntoObjectL(const TDesC &, const TDesC &, const TDesC8 &)
voidMoveToSentAndSetActiveL()
TInt PrepareCurrentObjectAndSetStateL()
voidRealRunL()
IMPORT_C voidRunL()
TInt SynchronousEntryDelete()
Inherited Functions
CActive::CActive(TInt)
CActive::Cancel()
CActive::Deque()
CActive::Extension_(TUint,TAny *&,TAny *)
CActive::IsActive()const
CActive::IsAdded()const
CActive::Priority()const
CActive::RunError(TInt)
CActive::SetActive()
CActive::SetPriority(TInt)
CActive::~CActive()
CBase::CBase()
CBase::Delete(CBase *)
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()
Inherited Enumerations
CActive:TPriority
Public Attributes
TBool iAsyncInit
Protected Attributes
TBool iLastSendAttempt
CObexClient *iObexClient
Private Attributes
TInt iAttachmentEntryCount
TBool iCancelWithoutCompleting
HBufC *iConnectPassword
const TIntiConnectTimeout
CMsvEntrySelection *iMoveEntrySelection
CMsvOperation *iMoveOperation
CMsvServerEntry &iMsvSendParent
const TUidiMtm
TInt iNextAttachment
CObexFileObject *iObexObject
TRequestStatus &iObserverRequestStatus
TPckgBuf< TObexMtmProgress >iProgressPckg
const TIntiPutTimeout
TFileName iSendFile
TObexMtmProgress::TSendState iSendState
TFileName iServicePath
CObexSendOpTimeout *iTimeoutTimer
Inherited Attributes
CActive::iStatus

Constructor & Destructor Documentation

CObexServerSendOperation(TUid, CMsvServerEntry &, TInt, TInt, TRequestStatus &)

IMPORT_CCObexServerSendOperation(TUidaMsgTypeUid,
CMsvServerEntry &aSendObj,
TIntaConnectTimeoutMicroSeconds,
TIntaPutTimeoutMicroSeconds,
TRequestStatus &aObserverRequestStatus
)[protected]

Constructor.

Parameters

TUid aMsgTypeUidUID of message type
CMsvServerEntry & aSendObjReference to the object to send.
TInt aConnectTimeoutMicroSecondsTimeout period for Connect operation in microseconds.
TInt aPutTimeoutMicroSeconds
TRequestStatus & aObserverRequestStatusTRequestStatus of owning active object.

CObexServerSendOperation(TUid, CMsvServerEntry &, TInt, TInt, TRequestStatus &, TBool)

IMPORT_CCObexServerSendOperation(TUidaMsgTypeUid,
CMsvServerEntry &aSendObj,
TIntaConnectTimeoutMicroSeconds,
TIntaPutTimeoutMicroSeconds,
TRequestStatus &aObserverRequestStatus,
TBoolaLastSendAttempt
)[protected]

Constructor.

Parameters

TUid aMsgTypeUidUID of message type
CMsvServerEntry & aSendObjReference to the object to send.
TInt aConnectTimeoutMicroSecondsTimeout period for Connect operation in microseconds.
TInt aPutTimeoutMicroSeconds
TRequestStatus & aObserverRequestStatusTRequestStatus of owning active object.
TBool aLastSendAttemptTBool flag to check for second send attempt and also for sending headers. EFalse sends full headers, ETrue only sends name and size

~CObexServerSendOperation()

IMPORT_C~CObexServerSendOperation()[virtual]

Destructor. Cancel()s, deletes owned objects and Close()s the connection to the FileServer.

Member Functions Documentation

ActivateRunLWithError(TInt)

voidActivateRunLWithError(TIntaError)[private]

Cancels the current operation, then reactivates with the given error code.

Parameters

TInt aErrorError code to be passed to CompleteSelf.

BuildSpecificConstructL()

voidBuildSpecificConstructL()[private]

Normal second phase constructor.

BuildSpecificDestructor()

voidBuildSpecificDestructor()[private]

Destructor. Cancel()s, deletes owned objects and Close()s the connection to the FileServer.

CheckStatusOfLastObject(TInt, TObexMtmProgress::TSendState)

TBool CheckStatusOfLastObject(TIntaStatus,
TObexMtmProgress::TSendStateaSendState
)[private]

Checks the last object was sent correctly, and tries to action appropriate error feedback if not. Only to be called from ESendObject/ESendNextObject or ESendComplete states.

Parameters

TInt aStatusStatus of last object
TObexMtmProgress::TSendState aSendState

CleanupAfterMovedToSent()

voidCleanupAfterMovedToSent()[private]

Restores after the message has been moved to the inbox, and marks the message as visible.

CompleteObserverL()

voidCompleteObserverL()[private]

Complete the observer, reporting any error via the progress. THIS METHOD MUST BE CALLED ONCE ONLY.

CompleteSelf(TInt)

voidCompleteSelf(TIntaError)[private]

This causes this active object's request to complete which means RunL() will be called again if we are active (immediately if there are no higher priority active objects in the active scheduler).

Parameters

TInt aErrorError to be passed forward to the next step of the state machine

CompletingObserver(TInt)

IMPORT_C TBoolCompletingObserver(TIntaErrorCode)[protected, virtual]

Tells the derived class that the base class is about to complete the observer. This is the first thing called when CompleteObserver is called. Since the behaviour of CompleteObserver is to clean up the message that it was trying to send, this calls gives the derived class an opportunity to either stop this deletion or recover any information synchronously from the message. If the derived class has no need to use this functionality, the default implementation allows deletion. This is the default implementation that allows the server mtm to continue normally. Tells the derived class that the base class is about to complete the observer. This is the first thing called when CompleteObserverL is called. Since the behaviour of CompleteObserverL is to clean up the message that it was trying to send, this calls gives the derived class an opportunity to either stop this deletion or recover any information synchronously from the message. If the derived class has no need to use this functionality, the default implementation allows deletion.

Parameters

TInt aErrorCodeThe last error code encountered during operation

ConstructL(const TDesC *)

IMPORT_C voidConstructL(const TDesC *aConnectPassword)[protected]

Second phase constructor. Sets up connection to the FileServer, initialises attachments or filename list then starts sending process by initialising.

leave
Leaves if insufficient memory.
leave
Leaves if cannot connect to FileServer.

Parameters

const TDesC * aConnectPasswordPointer to the password to be used for authentication.

DoCancel()

IMPORT_C voidDoCancel()[protected, virtual]

Cancels the current operation, deletes the client and Cancel()s the timeout timer. Only completes the observer (by a call to CompleteObserver) if an external entity (i.e. the owner) has called Cancel(). Otherwise the observer is not completed.

Cancels the current operation, deletes the client and Cancel()s the timeout timer. Only completes the observer (by a call to CompleteObserverL) if an external entity (i.e. the owner) has called Cancel(). Otherwise the observer is not completed.

ExplicitCancel()

voidExplicitCancel()[private]

Cancel any pending obex operation without completing the observer.

FileSession()

RFs &FileSession()[private]

Returns a reference to the file session (RFs) of the message

GetUserPasswordL(const TDesC &)

IMPORT_C voidGetUserPasswordL(const TDesC &aUserID)[private, virtual]

Called by the Obex Client when authentication is requested to pass the password back. If the password is invalid, this call should succeed but the send operation as a whole will inevitably fail.

leave
KErrXXX system wide error codes. Shouldn't leave just because the password is invalid.
Called by the Obex Client when authentication is requested to pass the password back. If the password is invalid, this call should succeed but the send operation as a whole will inevitably fail.
leave
KErrXXX system wide error codes. Shouldn't leave just because the password is invalid.
leave
KErrIrObexConnectChallRejected, if password is found empty.

Parameters

const TDesC & aUserID

InitialiseAttachmentL(CMsvServerEntry &, TInt)

voidInitialiseAttachmentL(CMsvServerEntry &aParent,
TIntaWhichAttachment
)[private]

Load an attachment into the obex sending buffer, and create a new Obex object of name TMsvEntry::iDetails.

leave
KErrXXX system wide error codes

Parameters

CMsvServerEntry & aParentReference to CMsvServerEntry to be sent.
TInt aWhichAttachmentZero-based index of attachment to send.

InitialiseObexClientL()

voidInitialiseObexClientL()[pure virtual]

LoadFileIntoObjectL(const TDesC &, const TDesC &, const TDesC8 &)

voidLoadFileIntoObjectL(const TDesC &aFileName,
const TDesC &aObexName,
const TDesC8 &aMimeType
)[private]

Parameters

const TDesC & aFileName
const TDesC & aObexName
const TDesC8 & aMimeType

MoveToSentAndSetActiveL()

voidMoveToSentAndSetActiveL()[private]

Moves the newly sent message to the global sent items folder, and sets active ready for its completion.

leave
KErrXXX system wide error codes

PostConnectOperations()

IMPORT_C voidPostConnectOperations()[virtual]

Operations to perform after attempting a connection. As multiple connection attempts can be made, it is necessary for this routine to ensure it can handle being called multiple times. May be overridden. Default implementation is blank.

PostSendOperations()

IMPORT_C voidPostSendOperations()[virtual]

Operations to perform after attempting to send a set of objects. May be overridden. Default implementation is blank.

PreConnectOperations()

IMPORT_C voidPreConnectOperations()[virtual]

Operations to perform before attempting a connection. As multiple connection attempts can be made, it is necessary for this routine to ensure it can handle being called multiple times. May be overridden. Default implementation is blank.

PreSendOperations()

IMPORT_C voidPreSendOperations()[virtual]

Operations to perform before attempting to send a set of objects. May be overridden. Default implementation is blank.

PrepareCurrentObjectAndSetStateL()

TInt PrepareCurrentObjectAndSetStateL()[private]

Loads the next object to be sent, whether an attachment or a file in the file list.

leave
KErrXXX system wide error codes

ProgressL()

IMPORT_C const TDesC8 &ProgressL()

Returns current progress information.

leave
KErrXXX system wide error codes

RealRunL()

voidRealRunL()[private]

Implementation of the send operation state machine. Progresses as: Initialise-->Connect-->ConnectAttemptComplete-->SendObject-->(SendNextObject-->)SendComplete-->Disconnected The SendNextObject state is repeated for each attachment in excess of one. Also handles UserCancelled and SendError states by CompleteObserver()ing with appropriate error codes. Leaves will be passed back to RunL and handled there.

leave
KErrXXX system wide error codes

RunL()

IMPORT_C voidRunL()[private, virtual]

Calls RealRunL(), and traps errors

leave
Leaves with errors from RealRunL()

SecondPhaseObexClientInitL()

IMPORT_C voidSecondPhaseObexClientInitL()[virtual]

This is not required to do anything in the base implementation.

SynchronousEntryDelete()

TInt SynchronousEntryDelete()[private]

Delete the outbox entry as operation has 'completed'. Will be invisible&InPreparation anyway (MS delete will delete it the next time it starts).

TimeOut()

voidTimeOut()

Called when the current operation times out. Causes the current operation to be cancelled, then reactivates with the appropriate error code (KErrIrObexClientNoDevicesFound or KErrIrObexClientPutPeerAborted).

Member Data Documentation

TBool iAsyncInit

TBool iAsyncInit

TInt iAttachmentEntryCount

TInt iAttachmentEntryCount[private]

TBool iCancelWithoutCompleting

TBool iCancelWithoutCompleting[private]

HBufC * iConnectPassword

HBufC *iConnectPassword[private]

const TInt iConnectTimeout

const TIntiConnectTimeout[private]

TBool iLastSendAttempt

TBool iLastSendAttempt[protected]

CMsvEntrySelection * iMoveEntrySelection

CMsvEntrySelection *iMoveEntrySelection[private]

CMsvOperation * iMoveOperation

CMsvOperation *iMoveOperation[private]

CMsvServerEntry & iMsvSendParent

CMsvServerEntry &iMsvSendParent[private]

const TUid iMtm

const TUidiMtm[private]

TInt iNextAttachment

TInt iNextAttachment[private]

CObexClient * iObexClient

CObexClient *iObexClient[protected]

CObexFileObject * iObexObject

CObexFileObject *iObexObject[private]

TRequestStatus & iObserverRequestStatus

TRequestStatus &iObserverRequestStatus[private]

TPckgBuf< TObexMtmProgress > iProgressPckg

TPckgBuf< TObexMtmProgress >iProgressPckg[private]

const TInt iPutTimeout

const TIntiPutTimeout[private]

TFileName iSendFile

TFileName iSendFile[private]

TObexMtmProgress::TSendState iSendState

TObexMtmProgress::TSendState iSendState[private]

TFileName iServicePath

TFileName iServicePath[private]

CObexSendOpTimeout * iTimeoutTimer

CObexSendOpTimeout *iTimeoutTimer[private]