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 ()
void InitialiseObexClientL ()
IMPORT_C void PostConnectOperations ()
IMPORT_C void PostSendOperations ()
IMPORT_C void PreConnectOperations ()
IMPORT_C void PreSendOperations ()
IMPORT_C const TDesC8 & ProgressL ()
IMPORT_C void SecondPhaseObexClientInitL ()
void TimeOut ()
Protected Member Functions
CObexServerSendOperation ( TUid , CMsvServerEntry &, TInt , TInt , TRequestStatus &)
CObexServerSendOperation ( TUid , CMsvServerEntry &, TInt , TInt , TRequestStatus &, TBool )
IMPORT_C TBool CompletingObserver ( TInt )
IMPORT_C void ConstructL (const TDesC *)
IMPORT_C void DoCancel ()
Private Member Functions
void ActivateRunLWithError ( TInt )
void BuildSpecificConstructL ()
void BuildSpecificDestructor ()
TBool CheckStatusOfLastObject ( TInt , TObexMtmProgress::TSendState )
void CleanupAfterMovedToSent ()
void CompleteObserverL ()
void CompleteSelf ( TInt )
void ExplicitCancel ()
RFs & FileSession ()
IMPORT_C void GetUserPasswordL (const TDesC &)
void InitialiseAttachmentL ( CMsvServerEntry &, TInt )
void LoadFileIntoObjectL (const TDesC &, const TDesC &, const TDesC8 &)
void MoveToSentAndSetActiveL ()
TInt PrepareCurrentObjectAndSetStateL ()
void RealRunL ()
IMPORT_C void RunL ()
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 TInt iConnectTimeout
CMsvEntrySelection * iMoveEntrySelection
CMsvOperation * iMoveOperation
CMsvServerEntry & iMsvSendParent
const TUid iMtm
TInt iNextAttachment
CObexFileObject * iObexObject
TRequestStatus & iObserverRequestStatus
TPckgBuf < TObexMtmProgress > iProgressPckg
const TInt iPutTimeout
TFileName iSendFile
TObexMtmProgress::TSendState iSendState
TFileName iServicePath
CObexSendOpTimeout * iTimeoutTimer
Inherited Attributes
CActive::iStatus

Constructor & Destructor Documentation

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

IMPORT_C CObexServerSendOperation ( TUid aMsgTypeUid,
CMsvServerEntry & aSendObj,
TInt aConnectTimeoutMicroSeconds,
TInt aPutTimeoutMicroSeconds,
TRequestStatus & aObserverRequestStatus
) [protected]

Constructor.

Parameters

TUid aMsgTypeUid UID of message type
CMsvServerEntry & aSendObj Reference to the object to send.
TInt aConnectTimeoutMicroSeconds Timeout period for Connect operation in microseconds.
TInt aPutTimeoutMicroSeconds
TRequestStatus & aObserverRequestStatus TRequestStatus of owning active object.

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

IMPORT_C CObexServerSendOperation ( TUid aMsgTypeUid,
CMsvServerEntry & aSendObj,
TInt aConnectTimeoutMicroSeconds,
TInt aPutTimeoutMicroSeconds,
TRequestStatus & aObserverRequestStatus,
TBool aLastSendAttempt
) [protected]

Constructor.

Parameters

TUid aMsgTypeUid UID of message type
CMsvServerEntry & aSendObj Reference to the object to send.
TInt aConnectTimeoutMicroSeconds Timeout period for Connect operation in microseconds.
TInt aPutTimeoutMicroSeconds
TRequestStatus & aObserverRequestStatus TRequestStatus of owning active object.
TBool aLastSendAttempt TBool 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)

void ActivateRunLWithError ( TInt aError ) [private]

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

Parameters

TInt aError Error code to be passed to CompleteSelf.

BuildSpecificConstructL()

void BuildSpecificConstructL ( ) [private]

Normal second phase constructor.

BuildSpecificDestructor()

void BuildSpecificDestructor ( ) [private]

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

CheckStatusOfLastObject(TInt, TObexMtmProgress::TSendState)

TBool CheckStatusOfLastObject ( TInt aStatus,
TObexMtmProgress::TSendState aSendState
) [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 aStatus Status of last object
TObexMtmProgress::TSendState aSendState

CleanupAfterMovedToSent()

void CleanupAfterMovedToSent ( ) [private]

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

CompleteObserverL()

void CompleteObserverL ( ) [private]

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

CompleteSelf(TInt)

void CompleteSelf ( TInt aError ) [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 aError Error to be passed forward to the next step of the state machine

CompletingObserver(TInt)

IMPORT_C TBool CompletingObserver ( TInt aErrorCode ) [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 aErrorCode The last error code encountered during operation

ConstructL(const TDesC *)

IMPORT_C void ConstructL ( 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 * aConnectPassword Pointer to the password to be used for authentication.

DoCancel()

IMPORT_C void DoCancel ( ) [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()

void ExplicitCancel ( ) [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 void GetUserPasswordL ( 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)

void InitialiseAttachmentL ( CMsvServerEntry & aParent,
TInt aWhichAttachment
) [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 & aParent Reference to CMsvServerEntry to be sent.
TInt aWhichAttachment Zero-based index of attachment to send.

InitialiseObexClientL()

void InitialiseObexClientL ( ) [pure virtual]

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

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

Parameters

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

MoveToSentAndSetActiveL()

void MoveToSentAndSetActiveL ( ) [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 void PostConnectOperations ( ) [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 void PostSendOperations ( ) [virtual]

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

PreConnectOperations()

IMPORT_C void PreConnectOperations ( ) [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 void PreSendOperations ( ) [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()

void RealRunL ( ) [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 void RunL ( ) [private, virtual]

Calls RealRunL() , and traps errors

leave
Leaves with errors from RealRunL()

SecondPhaseObexClientInitL()

IMPORT_C void SecondPhaseObexClientInitL ( ) [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()

void TimeOut ( )

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 TInt iConnectTimeout [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 TUid iMtm [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 TInt iPutTimeout [private]

TFileName iSendFile

TFileName iSendFile [private]

TObexMtmProgress::TSendState iSendState

TObexMtmProgress::TSendState iSendState [private]

TFileName iServicePath

TFileName iServicePath [private]

CObexSendOpTimeout * iTimeoutTimer

CObexSendOpTimeout * iTimeoutTimer [private]