CObexServer Class Reference

class CObexServer : public CObex

OBEX server.

CObexServer provides a framework for servicing OBEX requests from remote clients. It is designed to be able to act as either a "default" application (in IrDA terms, registering on the IrDA:OBEX IAS class), or as a application specific server (registering itself on a private IAS class).

You implement service-specific behaviour by providing a MObexServerNotify interface implementation to the server object. The server calls the interface's functions to provide notification of server events, which specific implementations can process (or ignore) as appropriate.

This class is not designed for user derivation.

Inherits from

Public Member Functions
~CObexServer ()
TBool CheckObjectForConnectionId ( CObexBaseObject &)
TBool CheckPacketForConnectionId ( CObexPacket &)
IMPORT_C TOperation CurrentOperation ()
IMPORT_C TAny * ExtensionInterfaceL ( TUid )
IMPORT_C TBool IsStarted ()
IMPORT_C CObexServer * NewL ( TObexProtocolInfo &)
IMPORT_C CObexServer * NewL ( TObexProtocolInfo &, TObexProtocolPolicy &)
IMPORT_C CObexServer * NewL ( TObexTransportInfo &)
IMPORT_C TInt PacketHeaders ( CObexHeaderSet *&)
IMPORT_C TInt PacketHeaders ( CObexHeaderSet *&, MObexHeaderCheck &)
TInt ParseConnectPacket ( CObexPacket &)
TInt PrepareConnectPacket ( CObexPacket &)
TInt PrepareErroredConnectPacket ( CObexPacket &)
IMPORT_C TInt RequestCompleteIndicationCallback ( TObexResponse )
IMPORT_C TInt RequestCompleteIndicationCallback ( TInt )
IMPORT_C TInt RequestIndicationCallback ( CObexBaseObject *)
IMPORT_C TInt RequestIndicationCallbackWithError ( TObexResponse )
IMPORT_C TInt RequestIndicationCallbackWithError ( TInt )
IMPORT_C void ResetChallenge ()
IMPORT_C void SetChallengeL (const TDesC &)
void SetCurrentOperation (const TOperation )
IMPORT_C TInt SetPutFinalResponseHeaders ( CObexHeaderSet *)
IMPORT_C void SetReadActivityObserver ( MObexReadActivityObserver *)
IMPORT_C void SetTargetChecking ( TTargetChecking )
void SignalPacketProcessEvent ( TInt )
void SignalReadActivity ()
IMPORT_C TInt Start ( MObexServerNotify *)
IMPORT_C TInt Start ( MObexServerNotifyAsync *)
IMPORT_C void Stop ()
IMPORT_C const TObexTransportInfo * TransportInfo ()
IMPORT_C void UserPasswordL (const TDesC &)
Private Member Functions
CObexServer ()
TInt AcceptConnection ()
TInt AddConnectionIDHeader ( CObexPacket &)
void CheckServerAppResponseCode ( TObexOpcode , TObexResponse )
void CheckTarget ( TConnectState &, TInt &)
TUint32 ConnectionID ()
void ConstructL ( TObexTransportInfo &)
TInt DoPacketHeaders ( CObexHeaderSet *&, MObexHeaderCheck *)
void OnError ( TInt )
void OnPacketReceive ( CObexPacket &)
void OnTransportDown ()
void OnTransportUp ()
TInt PrepareFinalChallResponse ( CObexPacket &, TConnectState &)
void ResetConnectionID ()
void SetConnectionID ( TUint32 )
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()
CObex::CObex()
CObex::CancelObexConnection()
CObex::ConnectState()const
CObex::ControlledTransportDown()
CObex::Error(TInt)
CObex::ForcedTransportDown()
CObex::GenerateChallenge(CObexPacket &)
CObex::GetConnectState()const
CObex::IsAuthenticating()const
CObex::IsConnected()const
CObex::IsStrictPeer()const
CObex::LocalInfo()const
CObex::NotifyError(TInt)
CObex::NotifyProcess(CObexPacket &)
CObex::NotifyTransportDown(TBool)
CObex::NotifyTransportUp()
CObex::PrepareChallResponseL(const TDesC &)
CObex::Process(CObexPacket &)
CObex::ProcessChallResponseL(const TObexInternalHeader &)
CObex::ProcessChallengeL(const TObexInternalHeader &)
CObex::RemoteAddr(TSockAddr &)
CObex::RemoteInfo()const
CObex::RemoteInfoCleanup()
CObex::SetCallBack(MObexAuthChallengeHandler &)
CObex::SetConnectState(TConnectState)
CObex::SetLocalWho(const TDesC8 &)
CObex::SuppressAuthenticationHeaderElements(TObexSuppressedAuthElements)
CObex::TransportDown(TBool)
CObex::TransportUp()
CObex::~CObex()
Public Member Enumerations
enum TTargetChecking { ENoChecking , EIfPresent , EAlways }
Inherited Enumerations
CObex:TConnectState
CObex:TObexSuppressedAuthElements
CObex:TOperation
Private Attributes
TUint32 iConnectionID
TBool iConnectionIdSet
TBool iEnabled
CObexHeader * iHeader
MObexServerNotifyAsync * iOwner
CObexPacketSignaller * iPacketProcessSignaller
CObexServerRequestPacketEngine * iServerRequestPacketEngine
TBool iSpecDone
CObexServerStateMachine * iStateMachine
CObexServerNotifySyncWrapper * iSyncWrapper
TTargetChecking iTargetChecking
TBool iTargetReceived
Inherited Attributes
CObex::iAuthEngine
CObex::iCallBack
CObex::iChallPassword
CObex::iChallenge
CObex::iConnectState
CObex::iCurrentOperation
CObex::iIncomingChallResp
CObex::iIncomingNonce
CObex::iIncomingRequestDigest
CObex::iLocalInfo
CObex::iNotifyHandler
CObex::iOutgoingChallResp
CObex::iOutgoingNonce
CObex::iRemoteInfo
CObex::iRemoteRealm
CObex::iRemoteUID
CObex::iReserved
CObex::iRespPassword
CObex::iRxChallenge
CObex::iSuppressedObexAuthElements
CObex::iTransportController
CObex::iUserIDRequested

Constructor & Destructor Documentation

CObexServer()

CObexServer ( ) [private]

Constructor - set initial values

~CObexServer()

~CObexServer ( )

Destructor.

Member Functions Documentation

AcceptConnection()

TInt AcceptConnection ( ) [private]

AddConnectionIDHeader(CObexPacket &)

TInt AddConnectionIDHeader ( CObexPacket & aPacket ) [private]

Parameters

CObexPacket & aPacket

CheckObjectForConnectionId(CObexBaseObject &)

TBool CheckObjectForConnectionId ( CObexBaseObject & aObject )

Check, if required, the object connection ID.

Parameters

CObexBaseObject & aObject

CheckPacketForConnectionId(CObexPacket &)

TBool CheckPacketForConnectionId ( CObexPacket & aObject )

Check, if required, that the packet connection ID matches that of the Server's current connection

Parameters

CObexPacket & aObject

CheckServerAppResponseCode(TObexOpcode, TObexResponse)

void CheckServerAppResponseCode ( TObexOpcode aOpcode,
TObexResponse aResponse
) [private]

This function is to ensure that a response a server application provides the Obex Server to respond to the Obex Client with when it has overriden the default handling of a request packet does not represent a success.

The rationale for this is to attempt to keep the Obex peers synchronised. As the packet has been dropped, the client should not be lead to believe it has been received successfully.

Therefore, this function asserts that the application does not send a success response for the request packet received.

Parameters

TObexOpcode aOpcode
TObexResponse aResponse

CheckTarget(TConnectState &, TInt &)

void CheckTarget ( TConnectState & aNextState,
TInt & aRetVal
) [private]

Parameters

TConnectState & aNextState
TInt & aRetVal

ConnectionID()

TUint32 ConnectionID ( ) [private]

ConstructL(TObexTransportInfo &)

void ConstructL ( TObexTransportInfo & aObexTransportInfo ) [private, virtual]

Parameters

TObexTransportInfo & aObexTransportInfo

CurrentOperation()

IMPORT_C TOperation CurrentOperation ( ) const

Returns the operation currently being performed by the remote client, or EOpIdle if between operations. Note that there is no implication of whether the server is currently connected; EOpIdle will be returned regardless of connection state, if no operation is currently being performed. Use CObex::IsConnected () to find connection staus.

DoPacketHeaders(CObexHeaderSet *&, MObexHeaderCheck *)

TInt DoPacketHeaders ( CObexHeaderSet *& aHeaderSet,
MObexHeaderCheck * aHeaderCheck
) [private]

Contains the functionality for the PacketHeader interface functions in a refactored way.

Parameters

CObexHeaderSet *& aHeaderSet A reference to a pointer that will be modified to NULL if no interesting header are contained in the request packet, or to point to a new headerset containing representations of the headers within the packet that are of interest. Ownership of the headerset (when aHeaderSet is not NULL) is passed to the caller.
MObexHeaderCheck * aHeaderCheck A pointer to an MObexHeaderCheck derived class that encapsulates whether or not a particular header or headers should be included in the returned header set (i.e. whether the headers are "interesting"). If the pointer is NULL then that is taken to mean that all headers should be added to the aHeaderSet.

ExtensionInterfaceL(TUid)

IMPORT_C TAny * ExtensionInterfaceL ( TUid aUid )

Provides additional interfaces for CObexServer .

leave
KErrNotSupported if the given UID does not represent an interface CObexServer can provide.
leave
KErrInUse if an instance of MObexServerRequestPacketNotifyRegister has already been provided by an earlier call to ExtensionInterfaceL, and it has not been released.

Parameters

TUid aUid The UID of the interface that is required.

IsStarted()

IMPORT_C TBool IsStarted ( )

Tests if the server is started, and is available to accept connections.

NewL(TObexProtocolInfo &)

IMPORT_C CObexServer * NewL ( TObexProtocolInfo & aObexProtocolInfoPtr ) [static]

Allocates and constructs a new OBEX server object.

The received protocol information object, aObexProtocolInfoPtr, specifies the transport protocol to use: For the standard transports the following are used, TObexIrProtocolInfo for IrDA, TObexBluetoothProtocolInfo for Bluetooth, TObexUsbProtocolInfo for USB.

Parameters

TObexProtocolInfo & aObexProtocolInfoPtr Protocol information object describing the transport to use

NewL(TObexProtocolInfo &, TObexProtocolPolicy &)

IMPORT_C CObexServer * NewL ( TObexProtocolInfo & aObexProtocolInfoPtr,
TObexProtocolPolicy & aObexProtocolPolicy
) [static]

Allocates and constructs a new OBEX server object with packet sizing information.

The received protocol information object, aObexProtocolInfoPtr, specifies the transport protocol to use: For the standard transports the following are used, TObexIrProtocolInfo for IrDA, TObexBluetoothProtocolInfo for Bluetooth, TObexUsbProtocolInfo for USB.

The aObexProtocolPolicy parameter specifies the packet sizing policy for this OBEX object.

Parameters

TObexProtocolInfo & aObexProtocolInfoPtr Protocol information object describing the transport to use
TObexProtocolPolicy & aObexProtocolPolicy Protocol policy object specifying the packet sizes to use

NewL(TObexTransportInfo &)

IMPORT_C CObexServer * NewL ( TObexTransportInfo & aObexTransportInfo ) [static]

Allocates and constructs a new OBEX server object with packet sizing information.

The received transport information object, aObexTransportInfo, specifies the transport protocol and packet sizes to use: For the standard transports the following are used, TObexIrProtocolInfo for IrDA, TObexBluetoothProtocolInfo for Bluetooth, TObexUsbProtocolInfo for USB.

capability
WriteDeviceData If the TObexIrV3TransportInfo is passed as the argument and the associated name is valid.

Parameters

TObexTransportInfo & aObexTransportInfo Transport information object describing the transport and packet sizes to use

OnError(TInt)

void OnError ( TInt aError ) [private, virtual]

Parameters

TInt aError

OnPacketReceive(CObexPacket &)

void OnPacketReceive ( CObexPacket & aPacket ) [private, virtual]

Parameters

CObexPacket & aPacket

OnTransportDown()

void OnTransportDown ( ) [private, virtual]

Tell the MObexServerNotifyAsync observer the transport is down and listen for another connection.

OnTransportUp()

void OnTransportUp ( ) [private, virtual]

PacketHeaders(CObexHeaderSet *&)

IMPORT_C TInt PacketHeaders ( CObexHeaderSet *& aHeaderSet )

Provides the pre-parsed contents of the most recently received request packet.

Parameters

CObexHeaderSet *& aHeaderSet A reference to a pointer that will be modified to NULL if no headers are contained in the request packet, or to point to a new headerset containing representations of the headers within the packet. Ownership of the headerset (when aHeaderSet is not NULL) is passed to the caller.

PacketHeaders(CObexHeaderSet *&, MObexHeaderCheck &)

IMPORT_C TInt PacketHeaders ( CObexHeaderSet *& aHeaderSet,
MObexHeaderCheck & aHeaderCheck
)

Provides the selectively pre-parsed contents of the most recently received request packet.

Parameters

CObexHeaderSet *& aHeaderSet A reference to a pointer that will be modified to NULL if no interesting header are contained in the request packet, or to point to a new headerset containing representations of the headers within the packet that are of interest. Ownership of the headerset (when aHeaderSet is not NULL) is passed to the caller.
MObexHeaderCheck & aHeaderCheck A reference to an MObexHeaderCheck derived class that encapsulates whether or not a particular header or headers should be included in the returned header set (i.e. whether the headers are "interesting").

ParseConnectPacket(CObexPacket &)

TInt ParseConnectPacket ( CObexPacket & aPacket ) [virtual]

Parameters

CObexPacket & aPacket

PrepareConnectPacket(CObexPacket &)

TInt PrepareConnectPacket ( CObexPacket & aPacket )

Prepare next packet for the connection attempt ConnectionID and Who headers are Mandatory if the Target header was used in the connection from

Parameters

CObexPacket & aPacket Packet to fill

PrepareErroredConnectPacket(CObexPacket &)

TInt PrepareErroredConnectPacket ( CObexPacket & aPacket )

Prepare next packet for an invalid connection attempt (i.e. the ParseConnectPacket failed). A fail response (to a connect request) includes the version, flags, and packet size information.

Parameters

CObexPacket & aPacket Packet to fill

PrepareFinalChallResponse(CObexPacket &, TConnectState &)

TInt PrepareFinalChallResponse ( CObexPacket & aPacket,
TConnectState & aNextState
) [private]

Parameters

CObexPacket & aPacket
TConnectState & aNextState

RequestCompleteIndicationCallback(TObexResponse)

IMPORT_C TInt RequestCompleteIndicationCallback ( TObexResponse aResponseCode )

Complete an asynchronous callback, supplying a obex response code. This function is used for asychronously handling PutComplete, GetComplete and SetPath Indication.

panic
Obex ENoNotificationToComplete Raised if the server does not have a request outstanding.
panic
Obex EInvalidResponseCodeFromServerApp raised if TObexResponse aResponseCode is outside range [1,255] or it is ERespContinue (which would confuse the client)

Parameters

TObexResponse aResponseCode

RequestCompleteIndicationCallback(TInt)

IMPORT_C TInt RequestCompleteIndicationCallback ( TInt aErrorCode )

Complete an asynchronous callback, supplying a obex response code. This function is used for asychronously handling PutComplete, GetComplete and SetPath Indication.

panic
Obex ENoNotificationToComplete Raised if the server does not have a request outstanding.
panic
Obex EInvalidResponseCodeFromServerApp raised if aErrorCode is positive, i.e. invalid Symbian error code

Parameters

TInt aErrorCode

RequestIndicationCallback(CObexBaseObject *)

IMPORT_C TInt RequestIndicationCallback ( CObexBaseObject * aObject )

Complete an asynchronous callback, supplying a CObexBaseObject derived object. Passing in NULL results in an Obex level error being sent to the client -- the semantics are that either a PUT request has been rejected or a GET request has not found a suitable object to return.

panic
Obex ENoNotificationToComplete Raised if the server does not have a request outstanding.

Parameters

CObexBaseObject * aObject The object passed back from application

RequestIndicationCallbackWithError(TObexResponse)

IMPORT_C TInt RequestIndicationCallbackWithError ( TObexResponse aResponseCode )

Complete an asynchronous callback, supplying a obex response code. Applications should use this function when rejecting Get/Put RequestIndication in order to specify the response code.

panic
Obex ENoNotificationToComplete Raised if the server does not have a request outstanding.
panic
Obex EInvalidResponseCodeFromServerApp raised if TObexResponse aResponseCode is outside range [1,255] or it is one of the successful response (e.g. ERespSuccess, ERespContinue)

Parameters

TObexResponse aResponseCode

RequestIndicationCallbackWithError(TInt)

IMPORT_C TInt RequestIndicationCallbackWithError ( TInt aErrorCode )

Complete an asynchronous callback, supplying a obex response code. Applications should use this function when rejecting Get/Put RequestIndication in order to specify the error code.

panic
Obex ENoNotificationToComplete Raised if the server does not have a request outstanding.
panic
Obex EInvalidResponseCodeFromServerApp raised if TObexResponse aResponseCode non-negtive. Note: KErrNone is not acceptable because this function is only used when there is an error.

Parameters

TInt aErrorCode Application's response to the indication as an Obex response Code.

ResetChallenge()

IMPORT_C void ResetChallenge ( )

Resets the password.

After this call, a client does not need to provide a password to access the server.

ResetConnectionID()

void ResetConnectionID ( ) [private]

SetChallengeL(const TDesC &)

IMPORT_C void SetChallengeL ( const TDesC & aPassword )

Sets a password required to access the server.

When a password is set, a client must specify it to access the server.

Parameters

const TDesC & aPassword Password

SetConnectionID(TUint32)

void SetConnectionID ( TUint32 aConnectionID ) [private]

Parameters

TUint32 aConnectionID

SetCurrentOperation(const TOperation)

void SetCurrentOperation ( const TOperation aOperation )

Setter function to allow other classes in the DLL to set the Server's current operation. Used by the Server state machine. CObexServerStateMachine

Parameters

const TOperation aOperation The operation currently being performed by the remote client

SetPutFinalResponseHeaders(CObexHeaderSet *)

IMPORT_C TInt SetPutFinalResponseHeaders ( CObexHeaderSet * aHeaderSet )

Specify the set of headers to return to remote Obex client in final Put response packet. The total length of the headers when encoded should not exceed the maximum Obex packet payload size.

This function may be called at any point during a Put operation. Repeated calls to this replace rather than add to the header set for inclusion in the final Put response packet.

It may be called with a NULL pointer, which means that no headers will be sent with the Put Final Response.

Even if this function returns with an error (even KErrNotReady) a best-effort attempt will be made to send as many headers as will fit in the final Put response packet.

Parameters

CObexHeaderSet * aHeaderSet A set of headers to be encoded in the final Put response packet. Ownership of the header set always passes to CObexServer.

SetReadActivityObserver(MObexReadActivityObserver *)

IMPORT_C void SetReadActivityObserver ( MObexReadActivityObserver * aObserver )

Sets a read activity observer.

This replaces any previous observer. The observer will receive a callback when the first read arrives for a put or get request.

This does not transfer ownership.

Parameters

MObexReadActivityObserver * aObserver The observer to receive packet process events. This may be NULL.

SetTargetChecking(TTargetChecking)

IMPORT_C void SetTargetChecking ( TTargetChecking aChecking )

Specifies target header checking behaviour.

Supports three behaviours---never check, always check, and check only if a target header has been sent. The default behaviour is to only check when a target header has been sent.

No checking allows a form of multiplexing to be used, where one server object may respond to multiple target headers. The behaviour desired by the client can be determined by examining the target header specified in the Connect.

Parameters

TTargetChecking aChecking The desired level of target header checking.

SignalPacketProcessEvent(TInt)

void SignalPacketProcessEvent ( TInt aEvent )

Signals an event has ocurred.

Parameters

TInt aEvent The event that has occurred. (TObexPacketProcessEvent)

SignalReadActivity()

void SignalReadActivity ( )

Start(MObexServerNotify *)

IMPORT_C TInt Start ( MObexServerNotify * aOwner )

Starts the server, specifying a synchronous notification interface.

If the server is already started, no state changes occur (i.e. any connections/operations in progress are not interrupted), but the notifications will be sent to aOwner. This allows "child" servers to take over ownership of existing connections.

Details of this function behaviour depend on the transport specified when constructed: in general a listener socket is created, its port number registered as appropriate, and an accept queued.

panic
OBEX EChangeInterfaceDuringWait when attempting to change the interface at an inappropriate time.

Parameters

MObexServerNotify * aOwner Server notification interface

Start(MObexServerNotifyAsync *)

IMPORT_C TInt Start ( MObexServerNotifyAsync * aOwner )

Starts the server, specifying an asynchronous notification interface.

If the server is already started, no state changes occur (i.e. any connections/operations in progress are not interrupted), but the notifications will be sent to aOwner. This allows "child" servers to take over ownership of existing connections.

Details of this function behaviour depend on the transport specified when constructed: in general a listener socket is created, its port number registered as appropriate, and an accept queued.

panic
OBEX EChangeInterfaceDuringWait when attempting to change the interface at an inappropriate time.

Parameters

MObexServerNotifyAsync * aOwner Server notification interface

Stop()

IMPORT_C void Stop ( )

Disconnects any transfer in progress and disables further connections.

TransportInfo()

IMPORT_C const TObexTransportInfo * TransportInfo ( ) const

Returns a pointer to the TObexTransportInfo being used by the OBEX transport layer. THE USER MUST NOT MODIFY THE OBJECT POINTED TO. This is useful primarily when using OBEX over RFCOMM and the user has specified 'KRfcommPassiveAutoBind' as the port. KRfcommPassiveAutoBind makes RFCOMM itself find a free port. The user needs to know which port is really being used by RFCOMM in order to correctly populate the SDP record. May be called meaningfully after CObexServer::Start has returned KErrNone.

UserPasswordL(const TDesC &)

IMPORT_C void UserPasswordL ( const TDesC & aPassword ) [virtual]

A call back from the the service with the password required for use with generating the challenge response.

leave
KErrNotReady if this function is not called from a MObexAuthChallengeHandler::GetUserPasswordL callback.

Parameters

const TDesC & aPassword Password

Member Enumerations Documentation

Enum TTargetChecking

The target header checking to apply to incoming connection requests. Defaults to EIfPresent. CObexServer::SetTargetChecking

Enumerators

ENoChecking
EIfPresent

Allow all target headers to connect.

EAlways

Only check target header in response to receiving one. Allows all clients specifying an Inbox service to connect.

Member Data Documentation

TUint32 iConnectionID

TUint32 iConnectionID [private]

TBool iConnectionIdSet

TBool iConnectionIdSet [private]

TBool iEnabled

TBool iEnabled [private]

CObexHeader * iHeader

CObexHeader * iHeader [private]

MObexServerNotifyAsync * iOwner

MObexServerNotifyAsync * iOwner [private]

CObexPacketSignaller * iPacketProcessSignaller

CObexPacketSignaller * iPacketProcessSignaller [private]

CObexServerRequestPacketEngine * iServerRequestPacketEngine

CObexServerRequestPacketEngine * iServerRequestPacketEngine [private]

TBool iSpecDone

TBool iSpecDone [private]

CObexServerStateMachine * iStateMachine

CObexServerStateMachine * iStateMachine [private]

CObexServerNotifySyncWrapper * iSyncWrapper

CObexServerNotifySyncWrapper * iSyncWrapper [private]

TTargetChecking iTargetChecking

TTargetChecking iTargetChecking [private]

TBool iTargetReceived

TBool iTargetReceived [private]