Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <obexserver.h>
Link against: obex.lib

Class CObexServer

class CObexServer : public CObex;

Description

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.

Derivation

Members

Defined in CObexServer:

Inherited from CBase:

Inherited from CObex:


Construction and destruction


NewL(TObexProtocolInfo &)

Capability: WriteDeviceData Conditional on: KObexIrTTPProtocolV3

IMPORT_C static CObexServer* NewL(TObexProtocolInfo &aObexProtocolInfoPtr);

Description

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

Return value

CObexServer *

New OBEX server object


NewL(TObexProtocolInfo &,TObexProtocolPolicy &)

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

Description

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

Return value

CObexServer *

New OBEX server object


NewL(TObexTransportInfo &)

Capability: WriteDeviceData If the

IMPORT_C static CObexServer* NewL(TObexTransportInfo &aObexTransportInfo);

Description

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.

Parameters

TObexTransportInfo &aObexTransportInfo

Transport information object describing the transport and packet sizes to use

Return value

CObexServer *

New OBEX server object


~CObexServer()

IMPORT_C ~CObexServer();

Description

Destructor.


ConstructL(TObexTransportInfo &)

private: virtual void ConstructL(TObexTransportInfo &aObexTransportInfo);

Description

Parameters

TObexTransportInfo &aObexTransportInfo

[Top]


Member functions


Start(MObexServerNotify *)

IMPORT_C TInt Start(MObexServerNotify *aOwner);

Description

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.

Parameters

MObexServerNotify *aOwner

Server notification interface

Return value

TInt

KErrArgument if parameter is NULL, KErrAlreadyExists if server has already been started (but notification object will still be updated), otherwise a system wide error code

Panic codes

OBEX

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


Start(MObexServerNotifyAsync *)

IMPORT_C TInt Start(MObexServerNotifyAsync *aOwner);

Description

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.

Parameters

MObexServerNotifyAsync *aOwner

Server notification interface

Return value

TInt

KErrArgument if parameter is NULL, KErrAlreadyExists if server has already been started (but notification object will still be updated), otherwise a system wide error code

Panic codes

OBEX

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


Stop()

IMPORT_C void Stop();

Description

Disconnects any transfer in progress and disables further connections.


IsStarted()

IMPORT_C TBool IsStarted();

Description

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

Return value

TBool

ETrue if the server is started, EFalse otherwise


CurrentOperation()const

IMPORT_C TOperation CurrentOperation() const;

Description

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()const () to find connection staus.

Return value

CObex::TOperation

Operation currently being performed by the remote client


SetChallengeL(const TDesC &)

IMPORT_C void SetChallengeL(const TDesC &aPassword);

Description

Sets a password required to access the server.

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

Parameters

const TDesC16 &aPassword

Password


ResetChallenge()

IMPORT_C void ResetChallenge();

Description

Resets the password.

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


UserPasswordL(const TDesC &)

IMPORT_C virtual void UserPasswordL(const TDesC &aPassword);

Description

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

Parameters

const TDesC16 &aPassword

Password

Leave codes

KErrNotReady

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


SetTargetChecking(TTargetChecking)

IMPORT_C void SetTargetChecking(TTargetChecking aChecking);

Description

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

CObexServer::TTargetChecking aChecking

The desired level of target header checking.


SetPutFinalResponseHeaders(CObexHeaderSet *)

IMPORT_C TInt SetPutFinalResponseHeaders(CObexHeaderSet *aHeaderSet);

Description

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.

Return value

TInt

KErrNone if the operation completes successfully. KErrNotReady if the current operation is not a Put. KErrArgument if the length of the headers when encoded exceeds the maximum Obex packet payload size.


RequestIndicationCallback(CObexBaseObject *)

IMPORT_C TInt RequestIndicationCallback(CObexBaseObject *aObject);

Description

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.

Parameters

CObexBaseObject *aObject

The object passed back from application

Return value

TInt

result of state changes

Panic codes

Obex

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


RequestIndicationCallbackWithError(TObexResponse)

IMPORT_C TInt RequestIndicationCallbackWithError(TObexResponse aResponseCode);

Description

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.

Parameters

TObexResponse aResponseCode

Return value

TInt

result of state changes

Panic codes

Obex

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

Obex

EInvalidResponseCodeFromServerApp raised if TObexResponse aResponseCode is outside range [1,255] or it is one of the successful response (e.g. ERespSuccess, ERespContinue)


RequestIndicationCallbackWithError(TInt)

IMPORT_C TInt RequestIndicationCallbackWithError(TInt aErrorCode);

Description

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.

Parameters

TInt aErrorCode

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

Return value

TInt

result of state changes

Panic codes

Obex

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

Obex

EInvalidResponseCodeFromServerApp raised if TObexResponse aResponseCode non-negtive. Note: KErrNone is not acceptable because this function is only used when there is an error.


RequestCompleteIndicationCallback(TObexResponse)

IMPORT_C TInt RequestCompleteIndicationCallback(TObexResponse aResponseCode);

Description

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

Parameters

TObexResponse aResponseCode

Return value

TInt

result of state changes

Panic codes

Obex

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

Obex

EInvalidResponseCodeFromServerApp raised if TObexResponse aResponseCode is outside range [1,255] or it is ERespContinue (which would confuse the client)


RequestCompleteIndicationCallback(TInt)

IMPORT_C TInt RequestCompleteIndicationCallback(TInt aErrorCode);

Description

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

Parameters

TInt aErrorCode

Return value

TInt

result of state changes

Panic codes

Obex

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

Obex

EInvalidResponseCodeFromServerApp raised if aErrorCode is positive, i.e. invalid Symbian error code


TransportInfo()const

IMPORT_C const TObexTransportInfo* TransportInfo() const;

Description

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(MObexServerNotify *) has returned KErrNone.

Return value

const TObexTransportInfo *

Pointer to the transport layer's transport info.


OnPacketReceive(CObexPacket &)

private: virtual void OnPacketReceive(CObexPacket &aPacket);

Description

Parameters

CObexPacket &aPacket


OnError(TInt)

private: virtual void OnError(TInt aError);

Description

Parameters

TInt aError


OnTransportUp()

private: virtual void OnTransportUp();

Description


OnTransportDown()

private: virtual void OnTransportDown();

Description

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


ParseConnectPacket(CObexPacket &)

virtual TInt ParseConnectPacket(CObexPacket &aPacket);

Description

Parameters

CObexPacket &aPacket

Return value

TInt

[Top]


Member enumerations


Enum TTargetChecking

TTargetChecking

Description

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

See also:

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.