Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: freespacechecker.h
Link against: serversocket.lib

This item is not part of the S60 3rd Edition SDK for Symbian OS, Feature Pack 2.

Namespace conn

namespace conn

Description

the connect namespace

Members

Defined in conn:
CClientSocket, CCommand, CMessage, CServerSocket, DeserialiseL(), DeserialiseL(), EBig, ELittle, IsFreeSpaceAvailableL(), IsFreeSpaceAvailableL(), MCommand, MFactory, MHeader, MMessage, MServerSocketObserver, Pack(), PackImpl(), PackImpl(), RServiceBrokerClient, Serialise(), Serialise(), TEndian, TFreeSpaceCache, TServerInfo, UnpackImplL(), UnpackImplL(), UnpackL()


Member functions


Serialise()

IMPORT_C void Serialise(const TAny *aType, TInt aSize, TDes8 &aBuffer, const TEndian &aEndian);

Description

Appends data to the buffer using either BIG or LITTLE endian ordering.

Parameters

const TAny *aType

The address of the data

TInt aSize

The size of the data

TDes8 &aBuffer

The buffer the data is copied into

const TEndian &aEndian

The endiannes

Panic codes

KErrBadDescriptor

When the buffer is not big enough

See also:


DeserialiseL()

IMPORT_C void DeserialiseL(TAny *aType, TInt aSize, TDes8 &aBuffer, const TEndian &aEndian);

Description

Extracts data from the buffer into the address specified, using either BIG or SMALL endian ordering. The data extracted is removed from the buffer.

Parameters

TAny *aType

The address of the data

TInt aSize

The size of the data

TDes8 &aBuffer

The buffer the data is copied from

const TEndian &aEndian

The endiannes

Leave codes

KErrCorrupt

when the buffer is not big enough

See also:


IsFreeSpaceAvailableL()

IMPORT_C TBool IsFreeSpaceAvailableL(RFs &aFileServ, TInt aDrive, TInt aBytesRequired);

Description

This method provides an example implementation of the IsFreeSpaceAvailable operation which is used by the connectivity subsystem to prevent connect operations filling the disk/flash below a certain safety threshold.

You should update this method for your specific device and hardware requirements. It will be called before any connectivity operation which writes to the file system.

Parameters

RFs &aFileServ

a Reference to an RFs object which must have been previously connected to the file server.

TInt aDrive

The ID of the drive which is about to be written to.

TInt aBytesRequired

The amount of free disk space required for the write in bytes

Return value

TBool

TBool Returns non-zero if the required space is available

Leave codes

RFs::Volume()

If an error is returned


Serialise()

IMPORT_C void Serialise(const TDesC &aString, TDes8 &aBuffer, const TEndian &aEndian);

Description

Stores the string into the buffer using either BIG or SMALL endian ordering. The length of the string is stored in the first two bytes of the buffer.

Parameters

const TDesC &aString

The string

TDes8 &aBuffer

The buffer the string is copied into

const TEndian &aEndian

The endiannes

Panic codes

KErrBadDescriptor

When the buffer is not big enough

See also:


DeserialiseL()

IMPORT_C void DeserialiseL(TDes &aString, TDes8 &aBuffer, const TEndian &aEndian);

Description

Extracts the string from the buffer.

Parameters

TDes &aString

The string

TDes8 &aBuffer

The buffer the string is extracted from

const TEndian &aEndian

The endiannes

Leave codes

KErrCorrupt

when the buffer is not big enough

KErrCorrupt

when the string is not big enough

With

standard Symbian OS error codes

See also:


IsFreeSpaceAvailableL()

IMPORT_C TBool IsFreeSpaceAvailableL(RFs &aFileServ, TInt aDrive, TInt aBytesRequired, TFreeSpaceCache *aCache);

Description

This method provides an example implementation of the IsFreeSpaceAvailable operation which is used by the connectivity subsystem to prevent connect operations filling the disk/flash below a certain safety threshold.

You should update this method for your specific device and hardware requirements. It will be called before any connectivity operation which writes to the file system.

If desired, a more complex implementation may be inserted here so that the call to RFs::Volume does not have to be executed every time this method is called, based on the data stored in the TFreeSpaceCache object.

This object must also be updated here. The following is a simple example which is NOT guaranteed to prevent the disk filling up, merely to illustrate the concept

Parameters

RFs &aFileServ

a Reference to an RFs object which must have been previously connected to the file server.

TInt aDrive

The ID of the drive which is about to be written to.

TInt aBytesRequired

The amount of free disk space required for the write in bytes

TFreeSpaceCache *aCache

A pointer to a TFreeSpaceCache object which should be used/updated by this call.

Return value

TBool

TBool Returns non-zero if the required space is available

Leave codes

RFs::Volume()

If an error is returned


PackImpl()

inline void PackImpl(const TDesC &aType, TDes8 &aBuffer, const TEndian &aEndian, Int2Type< true >);

Description

Calls the serialise method for strings

Parameters

const TDesC &aType

The data to pack

TDes8 &aBuffer

The buffer to pack the data into

const TEndian &aEndian

The endianness of the buffer

Int2Type< true >


UnpackImplL()

inline void UnpackImplL(TDes &aType, TDes8 &aBuffer, const TEndian &aEndian, Int2Type< true >);

Description

Calls the deserialise method for strings

Parameters

TDes &aType

The data to unpack

TDes8 &aBuffer

The buffer to unpack the data from

const TEndian &aEndian

The endianness of the buffer

Int2Type< true >


PackImpl()

inline void PackImpl(const T &aType, TDes8 &aBuffer, const TEndian &aEndian, Int2Type< false >);

Description

Calls the serialise method for generic types

Parameters

const T &aType

The data to pack

TDes8 &aBuffer

The buffer to pack the data into

const TEndian &aEndian

The endianness of the buffer

Int2Type< false >


UnpackImplL()

inline void UnpackImplL(T &aType, TDes8 &aBuffer, const TEndian &aEndian, Int2Type< false >);

Description

Calls the deserialise method for generic types

Parameters

T &aType

The data to unpack

TDes8 &aBuffer

The buffer to unpack the data from

const TEndian &aEndian

The endianness of the buffer

Int2Type< false >


Pack()

inline void Pack(const T &aType, TDes8 &aBuffer, const TEndian &aEndian);

Description

Packs any type into the buffer, including strings.

Performs a test to determine if the template arugment can be converted to a TDesC, i.e. is a string. It then uses Int2Type to call the correct implementation of PackImpl(), either the one for strings or the one for any other type.

Note: Unfortunately the implementation of CanBeConvertedTo is not completed because of a problem with the gcc compiler. The test "sizeof(I::Test(aType)) == sizeof(I::Small)" should be encapsulated into an enum inside CanBeConvertedTo but the gnu compiler complains that there is not "Test" method, although there is one. Therefore there is this meaningless test on the sizeof as opposite to something like "CanBeConvertedTo::Yes", which would evalutate to 1 if it is convertable and to 0 otherwise.

Parameters

const T &aType

The data to pack

TDes8 &aBuffer

The buffer to pack the data into

const TEndian &aEndian

The endianness of the buffer

See also:


UnpackL()

inline void UnpackL(T &aType, TDes8 &aBuffer, const TEndian &aEndian);

Description

Unpacks any type from a buffer, including strings. More details in the documentation of Pack().

Parameters

T &aType

The data to unpack

TDes8 &aBuffer

The buffer to unpack the data from

const TEndian &aEndian

The endianness of the buffer

See also:

[Top]


Member classes


Class MMessage

class MMessage;

Description

The message class.

Receives message header and data from the client socket.

Members

Defined in conn::MMessage:
Data(), IsReceiveComplete(), IsSendComplete(), Receive(), ReceiveCompleteL(), Reset(), Send(), SendCompleteL(), ~MMessage()

Construction and destruction


~MMessage()

inline virtual ~MMessage();

Description

Empty virtual destructor to avoid memory leaks

Member functions


Data()

virtual TDes8 &Data()=0;

Description

This returns a pointer to the next data to be sent

Return value

TDes8 &

A pointer to the data that must be sent next. This might point to the header or to the body depending on the receiving state.


Receive()

virtual void Receive()=0;

Description

Initiates or resumes a receive operation.


ReceiveCompleteL()

virtual void ReceiveCompleteL()=0;

Description

Called when a previous receive has completed. The state machine should be progressed in this function.


IsReceiveComplete()

virtual TBool IsReceiveComplete() const=0;

Description

Returns true if the whole receive operation (header and body) has completed.

Return value

TBool

True if the whole receive operation (header and body) has completed.


Send()

virtual void Send()=0;

Description

Initiates or resumes a send operation (header and body).


SendCompleteL()

virtual void SendCompleteL()=0;

Description

A partial send has completed.


IsSendComplete()

virtual TBool IsSendComplete() const=0;

Description

Returns true if the whole send operation (header and body) has completed.

Return value

TBool

True if the whole send operation (header and body) has completed.


Reset()

virtual void Reset()=0;

Description

Resets an ongoing send or receive operation. Cancels any data content in the message body.


Class MHeader

class MHeader;

Description

The message header.

Abstract class that allows library clients to use CMessage instead of re-implementing the MMessage interface.

Members

Defined in conn::MHeader:
BodyLength(), MaxBodyLength(), PrepareToWrite(), ReadL(), ReadPtr(), Reset(), SetBodyLength(), WritePtr(), ~MHeader()

Construction and destruction


~MHeader()

inline virtual ~MHeader();

Description

Empty virtual destructor to avoid memory leaks

Member functions


ReadPtr()

virtual const TDes8 &ReadPtr() const=0;

Description

The pointer for reading data from the socket The buffer returned can be partially filled. The message class will try to read starting at the current length of this buffer up to its maximum length.

Return value

const TDes8 &

A const reference to the data buffer for reading


ReadL()

virtual TBool ReadL(TUint aReadBytes)=0;

Description

The header is notified when the read operation completes, the number of bytes that have been received is passed as a parameter. The header can do any unpacking of data in here.

Parameters

TUint aReadBytes

The number of bytes received on the socket

Return value

TBool

True if all of the header has been received, false otherwise


PrepareToWrite()

virtual void PrepareToWrite()=0;

Description

The header should get ready to send data, i.e. do any packing in here.


WritePtr()

virtual const TDes8 &WritePtr() const=0;

Description

The pointer for writing data to the socket, data will be written up to the current length of this buffer.

Return value

const TDes8 &

A const reference to the data buffer for writing


Reset()

virtual void Reset()=0;

Description

The current send or read operation is aborted


SetBodyLength()

virtual void SetBodyLength(TInt aLength)=0;

Description

Sets the length of the message body, called by CMessage immediately before calling PrepareToWrite()

Parameters

TInt aLength

The length of the message body


BodyLength()

virtual TInt BodyLength() const=0;

Description

Returns the length of the message body

Note: I know the return should be unsigned but having it signed avoids warning due to descriptor's length being signed.

Return value

TInt

The length of the message body


MaxBodyLength()

virtual TInt MaxBodyLength() const=0;

Description

Returns the maximum allowed length of the message body

Note: I know the return should be unsigned but having it signed avoids warning due to descriptor's length being signed.

Return value

TInt

The maximum allowed length of the message body


Class TFreeSpaceCache

class TFreeSpaceCache;

Description

This class is used to store a cache of the previous results of an IsFreeSpaceAvailable operation within a component which may call IsFreeSpaceAvailable again. It is provided so that specific implementations of IsFreeSpaceAvailable can provide performance enhancements based on the disk space situation after a previous call if desired.

Members

Defined in conn::TFreeSpaceCache:
iBytesFree, iDriveId, iDriveSize, iLastChecked

Member data


iDriveId

TInt iDriveId;

Description

The ID of the drive


iBytesFree

TInt iBytesFree;

Description

A count of the remaining free bytes


iLastChecked

TInt64 iLastChecked;

Description

Used to determine whether or not to do an actual check


iDriveSize

TInt iDriveSize;

Description

This attribute is unused


Class MServerSocketObserver

class MServerSocketObserver;

Description

The observer of the server socket, gets notified of events relative to the server socket.

Members

Defined in conn::MServerSocketObserver:
ServerSocketStoppedDueToErr()

Member functions


ServerSocketStoppedDueToErr()

virtual void ServerSocketStoppedDueToErr(TInt aErr)=0;

Description

Called when the server socket is stopping due to an error

Parameters

TInt aErr

Standard Symbian OS error code


Class MCommand

class MCommand;

Description

A client command. It is created with a message, which is passed as a pointer and the command is then responsible for the memory of this message. A pointer to the client socket is also passed as a parameter in the constructor. It can process more than one message

Members

Defined in conn::MCommand:
ExecuteLD(), NewMessageReceived(), SendCompleteL(), SendErrorMessage(), SocketClosing(), TakeOwnershipOfMessage(), ~MCommand()

Construction and destruction


~MCommand()

inline virtual ~MCommand();

Description

Empty virtual destructor to avoid memory leaks

Member functions


ExecuteLD()

virtual void ExecuteLD()=0;

Description

Executes the command, called by the client socket when the command has been created, or after an observer command has captured a message.


SendErrorMessage()

virtual void SendErrorMessage(TUint aErrorCode)=0;

Description

Sends an error message to the remote client

Parameters

TUint aErrorCode

The error code to send in the message


NewMessageReceived()

virtual TBool NewMessageReceived(MMessage *aMessage)=0;

Description

Called by the client socket when a receive operation has completed, it gives observers (i.e. commands) a chance of grabbing extra messages in addition to the one that created the command in the first place. The observer implementing this method can take ownership of the pointer parameter, in which case true should be returned. Alternatively it may ignore the message (default behaviour for all commands) in which case false should be returned.

Parameters

MMessage *aMessage

The message containing the data received

Return value

TBool

ETrue if the implemented has taken ownership of the parameter pointer, false otherwise.


SendCompleteL()

virtual void SendCompleteL()=0;

Description

Called when a send operation has completed. No error is reported by the send operation because it is always assumed to succeed. Should it fail, the socket is closed and therefore SocketClosing() is called. Observers don't need to take any action on write failure, they simply stop to exist.


SocketClosing()

virtual void SocketClosing()=0;

Description

Called when the socket is closing


TakeOwnershipOfMessage()

virtual void TakeOwnershipOfMessage(MMessage *aMessage)=0;

Description

Pure virtual function to be implemented in order to take ownership of the message

Parameters

MMessage *aMessage

Pointer to the message for which ownership will be passed


Class RServiceBrokerClient

class RServiceBrokerClient : public RSessionBase;

Description

Client-side API for the Symbian Connect Service Broker

Derivation

Members

Defined in conn::RServiceBrokerClient:
Connect(), Disconnect(), FailedToStart(), RServiceBrokerClient(), RegisterPort(), StopServer(), Version(), ~RServiceBrokerClient()

Inherited from RHandleBase:
Attributes(), Close(), Duplicate(), FullName(), Handle(), HandleInfo(), Name(), SetHandle(), SetHandleNC(), iHandle

Inherited from RSessionBase:
CreateSession(), EAutoAttach, EExplicitAttach, Open(), Send(), SendReceive(), SetReturnedHandle(), ShareAuto(), ShareProtected(), TAttachMode

Construction and destruction


RServiceBrokerClient()

IMPORT_C RServiceBrokerClient();

Description

Class constructor.


~RServiceBrokerClient()

IMPORT_C ~RServiceBrokerClient();

Description

Class default destructor.

Member functions


Connect()

IMPORT_C TInt Connect();

Description

Connects the handle to the service.

Return value

TInt

KErrNone if successfull, KErrCouldNotConnect otherwise


Disconnect()

IMPORT_C void Disconnect();

Description

Detaches from the service.


Version()

IMPORT_C TVersion Version() const;

Description

Getter method for the version of the Service Broker client API

Return value

TVersion

The version of this API


RegisterPort()

IMPORT_C TInt RegisterPort(const TDesC &aServiceName, TUint aPortNumber);

Description

Registers the port number corresponding to the specified service name.

Parameters

const TDesC &aServiceName

The service name

TUint aPortNumber

The port number

Return value

TInt

KErrNone on success, system wide error code otherwise


FailedToStart()

IMPORT_C TInt FailedToStart(const TDesC &aServiceName, TUint aErrorCode);

Description

Communicates to the named service server that the specified service failed the startup procedure. The reason of failure should be specified in the error code parameter, if known.

Parameters

const TDesC &aServiceName

The service name

TUint aErrorCode

The reason for failing to startup

Return value

TInt

KErrNone on success, system wide error code otherwise


StopServer()

IMPORT_C TInt StopServer();

Description

Works only in DEBUG builds, in RELEASE builds the server does not take action of this command, intended for debugging purposes

Return value

TInt


Class MFactory

class MFactory;

Description

The command factory.

Creates concrete instances of messages and commands.

Members

Defined in conn::MFactory:
NewClientL(), NewCommandL(), NewMessageL(), ~MFactory()

Construction and destruction


~MFactory()

inline virtual ~MFactory();

Description

Empty virtual destructor to avoid memory leaks

Member functions


NewClientL()

virtual IMPORT_C CClientSocket *NewClientL(CServerSocket *aServerSocket);

Description

Creates an instance of the client socket

Parameters

CServerSocket *aServerSocket

Pointer to a CServerSocket instance

Return value

CClientSocket *

Pointer to a CClientSocket instance


NewCommandL()

virtual MCommand *NewCommandL(MMessage *aMessage, CClientSocket *aSocket)=0;

Description

Creates and returns a new command

Parameters

MMessage *aMessage

The incoming message

CClientSocket *aSocket

The client socket

Return value

MCommand *

A new command


NewMessageL()

virtual MMessage *NewMessageL()=0;

Description

Creates and returns a new message

Return value

MMessage *

A new message


Class CMessage

class CMessage : public CBase, public conn::MMessage;

Description

The message class.

Receives message header and data from the client socket. Gives access to the data and message ID to command classes. Commands extract information from the message data buffer and package response information into the message data buffer.

Derivation

Members

Defined in conn::CMessage:
Append(), CMessage(), ConstructL(), Data(), DataBuf(), DataBuf(), DataPtr(), DataPtr(), ENull, EReceiveComplete, EReceiveData, EReceiveHdr, ESendComplete, ESendData, ESendHdr, Endian(), ExtractDataL(), ExtractL(), ExtractL(), ExtractLC(), ExtractRawDataBlockL(), ExtractRawDataBlockLC(), ExtractRawDataL(), ExtractWithRawLenPrefixLC(), Header(), Header(), IsReceiveComplete(), IsSendComplete(), Length(), NewL(), PeekL(), Receive(), ReceiveCompleteL(), Reset(), Send(), SendCompleteL(), State(), State(), TState, ~CMessage()

Inherited from CBase:
Delete(), Extension_(), operator new()

Construction and destruction


NewL()

static IMPORT_C CMessage *NewL(MHeader *aHeader, const TEndian &aEndian, CMessage *aMessage=0);

Description

The factory method. By default the parameter is NULL, this signals default construction. If the parameter is not NULL it means we are cloned from another message. This is not yet implmented and will panic when passed a non-NULL CMessage.

Parameters

MHeader *aHeader

The message header, message takes ownership

const TEndian &aEndian

The endianess, by default this is big endian

CMessage *aMessage

The message to be copied, NULL by default

Return value

CMessage *

Pointer to the CMessage object


~CMessage()

IMPORT_C ~CMessage();

Description

The class destructor, delete the data buffer.


CMessage()

protected: IMPORT_C CMessage(const TEndian &aEndian);

Description

Class constructor

Parameters

const TEndian &aEndian

The endianess, either Big or Little


ConstructL()

protected: virtual IMPORT_C void ConstructL(CMessage *aMessage, MHeader *aHeader);

Description

Constructs the message. The received parameter by default is null (default construction). If the parameter pointer is not null, this is a copy operation and the data of the parameter is copied (copy construction). This is not yet implmented and will panic when passed a non-NULL CMessage.

The data buffer is allocated to the maximum possible length as specified by the header. This might be inefficient and we might need to change this or allow specialised implementations to override this.

Parameters

CMessage *aMessage

The message to be copied, NULL by default

MHeader *aHeader

The message Header, we take ownership

Panic codes

KNullPointer

If aHeader is passed in as NULL

KNullPointer

If aMessage is passed in as NULL

Member functions


Reset()

virtual IMPORT_C void Reset();

Description

Set the state to null and reset the data buffer


Data()

virtual IMPORT_C TDes8 &Data();

Description

Gives writable access to the data. Used by the client socket for receiving data. Allows segmented receiving of data.

When our state is either EReceiveHdr or EReceiveData this method is called in order to retrieve a buffer for the socket read calls. This is ensured by IsReceiving() returning true. When we are receiving the header, we return a TPtr8 pointing to the header buffer. The position inside this buffer is determined by the data already received - set in ReceiveCompleteL(). Likewise when receiving data we return the data buffer, with the position determined by the data already received.

When our state is either ESendHdr or ESendData this method is called in order to retrieve a buffer for the socket write calls. This is ensured by IsSending() returning true. We send the header first, by returning a pointer to the beginning of the header buffer. Then we send the data, by returning a pointer to the beginning of the data buffer. SendCompleteL() ensures that we do not try to send any data when the length of the data is zero.

Return value

TDes8 &

Header buffer if state is EReceiveHdr or ESendHdr, message data otherwise

See also:


Receive()

virtual IMPORT_C void Receive();

Description

Signals that we are in the receving phase, this is true until Reset() is called.


ReceiveCompleteL()

virtual IMPORT_C void ReceiveCompleteL();

Description

Data has been received by the socket. The socket used the data returned by CMessage::Data() for receiving. Therefore, depending on our state, either the header or the message data has been received. If the header has been received, unpack the header content and set the state to receiving data. If the data has been received, set the state to receive complete.


IsReceiveComplete()

virtual IMPORT_C TBool IsReceiveComplete() const;

Description

Returns true if the state is EReceiveComplete, false otherwise. Signals to the client socket that the message has received all of the data required.

Return value

TBool

true - all data has been received, false otherwise


Send()

virtual IMPORT_C void Send();

Description

Signals that we are sending data, starting with the header. This is true until Reset() is called. Also packs the header content and sets the state to ESendHdr.


SendCompleteL()

virtual IMPORT_C void SendCompleteL();

Description

Data has been sent by the socket.

Leave codes

KErrNotSupported

The state of the message is not correct


IsSendComplete()

virtual IMPORT_C TBool IsSendComplete() const;

Description

Signals that data has been successfully sent.

Return value

TBool

true if state is ESendComplete, false otherwise


Append()

inline void Append(const T &aData);

Description

Appends aData to the data trailer

Parameters

const T &aData

The data


ExtractL()

inline void ExtractL(T &aData);

Description

Extracts aData from the data trailer

Parameters

T &aData

The data


PeekL()

inline void PeekL(T &aData) const;

Description

Peeks aData from the data trailer

Parameters

T &aData

The data

Leave codes

KErrCorrupt

If the buffer length is less than the size of the argument class


ExtractLC()

IMPORT_C HBufC *ExtractLC();

Description

Extracts a string from the data buffer, and returns it. The string is stored in an HBufC, which is put on the cleanup stack

Return value

HBufC *

Pointer to a HBufC containing the the extracted data

Leave codes

KErrCorrupt

if extraction fails


ExtractL()

IMPORT_C HBufC *ExtractL();

Description

Extracts a string from the data buffer, and returns it. The string is stored in an HBufC and not left on the cleanup stack.

Return value

HBufC *

Pointer to the data extracted


ExtractWithRawLenPrefixLC()

IMPORT_C HBufC *ExtractWithRawLenPrefixLC();

Description

Extracts a unicode string which is prefixed by its size in bytes from the data buffer, and returns it. The string is stored in an HBufC, which is put on the cleanup stack

Return value

HBufC *

Pointer to a HBufC, pointer left on cleanup stack

Leave codes

KErrCorrupt

if extraction fails


ExtractDataL()

IMPORT_C HBufC8 *ExtractDataL();

Description

Extracts raw data from a message and returns a HBufC8 pointer to it

Return value

HBufC8 *

Pointer to the HBufC containing extracted data

Panic codes

KNullPointer

If iData is NULL


ExtractRawDataL()

IMPORT_C TPtrC8 ExtractRawDataL();

Description

Extracts raw data from the data buffer, it returns a pointer to the start of the data.

Return value

TPtrC8

Returns a pointer to the start of the raw data

Panic codes

KNullPointer

If iData is NULL


ExtractRawDataBlockLC()

IMPORT_C HBufC8 *ExtractRawDataBlockLC();

Description

Extracts a raw data block from a message and returns a HBufC8 pointer to it

Return value

HBufC8 *

Pointer to the HBufC8 containing extracted data

Panic codes

KNullPointer

If iData is NULL


ExtractRawDataBlockL()

IMPORT_C HBufC8 *ExtractRawDataBlockL();

Description

Extracts a raw data block from a message and returns a HBufC8 pointer to it and is not left on the cleanup stack

Return value

HBufC8 *

Pointer to the HBufC8 containing extracted data


Length()

inline TUint Length();

Description

Getter for the length of the messgae body

Return value

TUint

The length of the message body


Header()

inline MHeader *&Header();

Description

Returns a reference to the message header pointer

Return value

MHeader *&

The message header


Header()

inline const MHeader *const &Header() const;

Description

Returns a const referenct to the message header pointer

Return value

const MHeader *const &

The message header


State()

protected: inline TState &State();

Description

Returns a reference to the state of the message

Return value

TState &

The state of the message


State()

protected: inline const TState &State() const;

Description

Returns a const reference to the state of the message

Return value

const TState &

The state of the message


DataBuf()

protected: inline HBufC8 *&DataBuf();

Description

Returns a pointer reference to the body data

Return value

HBufC8 *&

The message body data


DataBuf()

protected: inline const HBufC8 *const &DataBuf() const;

Description

Returns a const pointer reference to the body data

Return value

const HBufC8 *const &

The message body data


DataPtr()

protected: inline TPtr8 &DataPtr();

Description

Returns the current pointer to the message body data. The position of this pointer depends on the message state

Return value

TPtr8 &

Current pointer to the message body data.


DataPtr()

protected: inline const TPtr8 &DataPtr() const;

Description

Returns the current pointer to the message body data. The position of this pointer depends on the message state

Return value

const TPtr8 &

Current pointer to the message body data.


Endian()

protected: inline const TEndian &Endian() const;

Description

Returns the endianess as defined in serialise.h, by default this is big endian

Return value

const TEndian &

The endianess as defined in serialise.h

Member enumerations


Enum TState

TState

Description

The possible states for this class

ENull

null

EReceiveHdr

receive header

EReceiveData

receive data

EReceiveComplete

receive complete

ESendHdr

send header

ESendData

send data

ESendComplete

send complete


Class CCommand

class CCommand : public CBase, public conn::MCommand;

Description

A client command. It is created with a message, which is passed as a pointer and the command is then responsible for the memory of this message. A pointer to the client socket is also passed as a parameter in the constructor. Although usually not needed, it can process more than one message by registering itself as an observer of the client socket. It forwards a request to the file server and then packages the answer into a message, which is sent to the client via the client socket. It is created by the command factory, TFactory.

Derivation

Members

Defined in conn::CCommand:
CCommand(), Message(), Message(), NewMessageReceived(), SendCompleteL(), SendResponse(), Socket(), SocketClosing(), TakeOwnershipOfMessage(), ~CCommand()

Inherited from CBase:
Delete(), Extension_(), operator new()

Inherited from conn::MCommand:
ExecuteLD(), SendErrorMessage()

Construction and destruction


CCommand()

protected: IMPORT_C CCommand(CClientSocket *aSocket);

Description

The class constructor. This command is added to the observers of the client socket.

Parameters

CClientSocket *aSocket

Pointer to the client socket, not owned


~CCommand()

protected: virtual IMPORT_C ~CCommand();

Description

Class destructor

Member functions


SendResponse()

protected: virtual IMPORT_C void SendResponse();

Description

Sends a response message to the client via the connected socket.


SendCompleteL()

protected: virtual IMPORT_C void SendCompleteL();

Description

The reply message has been sent, by default the command deletes itself in this method.


NewMessageReceived()

protected: virtual IMPORT_C TBool NewMessageReceived(MMessage *aMessage);

Description

Called by the client socket when a new message is received. This should be implemented only by those command that receive the client request in more than one message, i.e. file copy.

Parameters

MMessage *aMessage

Unused

Return value

TBool

If true, the client socket will not create a new command. If false a new command will be created to process the message


SocketClosing()

protected: virtual IMPORT_C void SocketClosing();

Description

Socket closing, need to delete self


TakeOwnershipOfMessage()

protected: virtual IMPORT_C void TakeOwnershipOfMessage(MMessage *aMessage);

Description

Takes ownership of the message passed in

Parameters

MMessage *aMessage

Pointer to a MMessage object


Socket()

protected: inline CClientSocket *Socket() const;

Description

Returns a pointer to the client socket

Return value

CClientSocket *

Access to the client socket for derived classes


Message()

protected: inline CMessage *&Message();

Description

Returns a reference to the CMessage pointer

Return value

CMessage *&

Reference to the CMessage pointer


Message()

protected: inline const CMessage *const &Message() const;

Description

Returns a const reference to the CMessage pointer

Return value

const CMessage *const &

Access to the CMessage instance for derived classes


Class CClientSocket

class CClientSocket : public CBase;

Description

The client socket wrapper.

This class owns a CClientSocketImpl instance and publishes the public API of CClientSocketImpl to the outside world. The reason for this class is twofold:

Derivation

Members

Defined in conn::CClientSocket:
CommandArray(), CommandArray(), ConstructL(), HandleSocketError(), NewL(), Receive(), ReceiveCompleteL(), RemoveCommand(), Send(), SendCompleteL(), Socket(), Socket(), ~CClientSocket()

Inherited from CBase:
Delete(), Extension_(), operator new()

Construction and destruction


NewL()

static IMPORT_C CClientSocket *NewL(CServerSocket *aServerSocket, MFactory *aFactory);

Description

Static factory method (two phase construction)

Parameters

CServerSocket *aServerSocket

Pointer to the CServerSocket object

MFactory *aFactory

Pointer to the factory instance

Return value

CClientSocket *

Pointer to the CClientSocket instance

Panic codes

KNullPointer

if aServerSocket is NULL

KNullPointer

if aFactory is NULL


~CClientSocket()

virtual IMPORT_C ~CClientSocket();

Description

Class destructor. Deletes the implementation.


ConstructL()

protected: virtual IMPORT_C void ConstructL(CServerSocket *aServerSocket, MFactory *aFactory);

Description

Creates an instance of CClientSocketImpl, the client socket.

Parameters

CServerSocket *aServerSocket

Pointer to the CServerSocket object

MFactory *aFactory

Pointer to the factory instance

Member functions


Receive()

IMPORT_C void Receive();

Description

Starts a receive operation.


Send()

IMPORT_C void Send(MCommand *aCommand, MMessage *aMessage);

Description

Sends a message to the socket. Only one message can be sent at any one time.

Parameters

MCommand *aCommand

The command sending the message

MMessage *aMessage

The message


RemoveCommand()

IMPORT_C void RemoveCommand(MCommand *aCommand);

Description

Removes a command from the socket. Existing commands that are registered with the socket receive a notification each time a message is received. By default commands are registered with the socket when they are created. They should remove themselves either when they cease to exist (i.e. in their destructor). As long as commands are registered they will also be deleted if the client socket is disconnected.

Parameters

MCommand *aCommand

The command


ReceiveCompleteL()

IMPORT_C void ReceiveCompleteL();

Description

Called when a message chunk has been received on the socket.


SendCompleteL()

IMPORT_C void SendCompleteL();

Description

Called when a message chunk has been sent to the socket.


HandleSocketError()

IMPORT_C void HandleSocketError(TInt aErr);

Description

Handles a socket error.

Parameters

TInt aErr

The error which has occurred


Socket()

IMPORT_C const RSocket &Socket() const;

Description

Returns a const handle to the client socket

Return value

const RSocket &

A handle to the client socket


Socket()

IMPORT_C RSocket &Socket();

Description

Returns a handle to the client socket

Return value

RSocket &

a handle to the client socket


CommandArray()

IMPORT_C const RPointerArray< MCommand > &CommandArray() const;

Description

Returns a const handle to the command array

Return value

const RPointerArray< MCommand > &

a handle to the command array


CommandArray()

IMPORT_C RPointerArray< MCommand > &CommandArray();

Description

Returns a handle to the command array

Return value

RPointerArray< MCommand > &

a handle to the command array


Class TServerInfo

class TServerInfo;

Description

Stores information regarding the server socket

Members

Defined in conn::TServerInfo:
TServerInfo(), iFactory, iMaxConnectionQueue, iObserver, iPortNumber, iServiceName

Construction and destruction


TServerInfo()

inline TServerInfo(MFactory *aFactory, TUint16 aPortNumber, TUint16 aMaxConnectionQueue, const TDesC &aServiceName, MServerSocketObserver *aObserver);

Description

Class constructor, initialises data members

Parameters

MFactory *aFactory

Pointer to a MFactory object

TUint16 aPortNumber

The port number to listen on

TUint16 aMaxConnectionQueue

Number of maximum connections

const TDesC &aServiceName

The name of the service

MServerSocketObserver *aObserver

Pointer to a MServerSocketObserver object

Member data


iFactory

MFactory * iFactory;

Description

A concrete instance of the factory


iPortNumber

TUint16 iPortNumber;

Description

The server port number


iMaxConnectionQueue

TUint16 iMaxConnectionQueue;

Description

The maximum number of outstanding connection requests


iServiceName

TPtrC iServiceName;

Description

The service name


iObserver

MServerSocketObserver * iObserver;

Description

The observer of the server socket

See also:


Class CServerSocket

class CServerSocket : public CBase;

Description

The server socket wrapper.

This class owns an instance of CServerSocketImpl and publishes its public API.

The reasons for this class are:

Derivation

Members

Defined in conn::CServerSocket:
Cancel(), IsActive(), NewL(), StartL(), ~CServerSocket()

Inherited from CBase:
Delete(), Extension_(), operator new()

Construction and destruction


NewL()

static IMPORT_C CServerSocket *NewL(const TServerInfo &aInfo);

Description

Static factory method (two phase construction)

Parameters

const TServerInfo &aInfo

Reference to a TServerInfo instance

Return value

CServerSocket *

Pointer to the CServerSocket instance


~CServerSocket()

IMPORT_C ~CServerSocket();

Description

Class destructor, deletes the implementation. socket

Member functions


StartL()

IMPORT_C void StartL();

Description

Starts listening on the server socket.


Cancel()

IMPORT_C void Cancel();

Description

Stops listening on the server socket.

See also:


IsActive()

IMPORT_C TBool IsActive();

Description

Returns true if the server socket is listening, false otherwise

Return value

TBool

True if the server socket is listening, false otherwise

See also:

[Top]


Member enumerations


Enum TEndian

TEndian

Description

The endianness supported by this library

EBig

BIG endian, MSB first

ELittle

LITTLE endian, LSB first