Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

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

Class CObexBufObject

class CObexBufObject : public CObexBaseObject;

Description

Use this class to hold objects where the body part is stored in a CBufFlat object. Please note that although parameters are supplied as CBufBase objects, non-CBufFlat parameters are not supported and will have unpredictable results. At no point does the CObexBufObject create, or take ownership of any CBaseBuf object it uses - it is always the responsibility of the creator/owner of the CBaseBuf to free it when no longer required.

As this class does not take ownership of the buffers it uses, it equally can not create its own buffers ad-hoc for storing new data into. Hence at no time is it valid for a CObexBufObject to exist with out it having a valid data buffer set. If such a situation arises, where it is required that received information should be discarded, consider using a CObexNullObject.

It is also posible to supply a file instead of a memory buffer, or to supply both. This functionality is due to the MObexServerNotify class expecting to work only on CObexBufObjects, so CObexFileObjects cannot be returned from the upcalls. To use a file for body storage, call CObexBufObject::NewL(CBufBase *) passing in a NULL pointer, then call CObexBufObject::SetDataBufL(TObexBufferingDetails &) manually afterwards. There are three overloads---to allow purely memory based objects, purely file based, or a hybrid. The hybrid object buffers into a memory buffer (which is not allowed to grow), then writes data to the file when the buffer is full. The buffering behaviour can therefore be tuned to the application by setting the size of the buffer prior to use.

This class is not designed for user derivation.

Derivation

Members

Defined in CObexBufObject:

Inherited from CBase:

Inherited from CObexBaseObject:


Construction and destruction


NewL(CBufBase *)

IMPORT_C static CObexBufObject* NewL(CBufBase *aDataBuf);

Description

Allocates and constructs a new OBEX dynamic buffer object, specifying a buffer.

Parameters

CBufBase *aDataBuf

The buffer for the body of the object. This must be set either by this constructor or by calling CObexBufObject::SetDataBufL(TObexBufferingDetails &) before using the object.

Return value

CObexBufObject *

New OBEX dynamic buffer object


~CObexBufObject()

IMPORT_C virtual ~CObexBufObject();

Description

Destructor.

[Top]


Member functions


WriteToFile(const TPtrC &)

IMPORT_C TInt WriteToFile(const TPtrC &aFileName);

Description

Writes contents of object to a file

Parameters

const TPtrC16 &aFileName

Target file

Return value

TInt

a Symbian OS error code if file write fails.


SetDataBufL(TObexBufferingDetails &)

IMPORT_C void SetDataBufL(TObexBufferingDetails &aDetails);

Description

Set the data buffers as specified in the supplied TObexBufferingDetails object.

Parameters

TObexBufferingDetails &aDetails

The buffering techniques to use. This only has to persist over the duration of the call to SetDataBufL, once this has returned it can be allowed to go out of scope.

Panic codes

Obex

ENullFileHandle TObexPanicCode::ENullFileHandle The RFile object does not point to a valid (open) file.

Obex

EEmptyBuffer TObexPanicCode::EEmptyBuffer The supplied buffer is of zero length.

Obex

EInvalidBufferDetails TObexPanicCode::EInvalidBufferDetails An unknown TObexBufferingDetails object was supplied

Obex

EInvalidBufferStrategy TObexPanicCode::EInvalidBufferStrategy An unknown TFileBuffering value was supplied.


SetDataBufL(CBufBase *)

Interface status: deprecated

IMPORT_C void SetDataBufL(CBufBase *aDataBuf);

Description

Sets a buffer to use the object body data.

Note that the function can leave.

Parameters

CBufBase *aDataBuf

The buffer for the body of the object.

Panic codes

Obex

ENullPointer TObexPanicCode::ENullPointer A NULL value was supplied for the data buffer.


SetDataBufL(const TPtrC &)

Interface status: deprecated

IMPORT_C void SetDataBufL(const TPtrC &aFilename);

Description

Set object to use aFilename as its data area. Leaves if unable to open file.

Parameters

const TPtrC16 &aFilename

The filename to link the object to.


SetDataBufL(const TPtrC &,CBufBase *)

Interface status: deprecated

IMPORT_C void SetDataBufL(const TPtrC &aFilename, CBufBase *aDataBuf);

Description

Set object to use aFilename as its data area. Leaves if unable to open file. Buffers data into aDataBuf before writing to file. Will not grow the memory buffer, so user can tune buffering behaviour when calling function.

Parameters

const TPtrC16 &aFilename

The filename to link the object to.

CBufBase *aDataBuf

The buffer for the body of the object.

Panic codes

Obex

ENullPointer TObexPanicCode::ENullPointer A NULL value was supplied for the data buffer.

Obex

EEmptyBuffer TObexPanicCode::EEmptyBuffer The supplied buffer is of zero length.


SetDataBufL(const TPtrC &,CBufBase &,const TFileBuffering)

Interface status: deprecated

IMPORT_C void SetDataBufL(const TPtrC &aFilename, CBufBase &aDataBuf, const TFileBuffering aBufferingStrategy);

Description

Set object to write to file, using buffering and the specified buffering strategy. Note the size of the buffer passed to this function will determine the size of the second buffer if double buffering is employed.

Parameters

const TPtrC16 &aFilename

The file to link the object to.

CBufBase &aDataBuf

A buffer to use.

const CObexBufObject::TFileBuffering aBufferingStrategy

The buffering strategy to employ.

Panic codes

Obex

EEmptyBuffer TObexPanicCode::EEmptyBuffer The supplied buffer is of zero length.

Obex

EInvalidBufferStrategy TObexPanicCode::EInvalidBufferStrategy An unknown TFileBuffering


DataBuf()

IMPORT_C CBufBase* DataBuf();

Description

Gets the buffer.

Return value

CBufBase *

The buffer for the body of the object.


GetData(TInt,TDes8 &)

private: virtual void GetData(TInt aPos, TDes8 &aDes);

Description

Reads aDes (up to MaxLength) from aPos offset into the buffer

Parameters

TInt aPos

The offset into the buffer to read from

TDes8 &aDes

The descriptor to read from


NewData(TInt,TDes8 &)

private: virtual void NewData(TInt aPos, TDes8 &aDes);

Description

Writes aDes into the buffer at aPos offset, growing the buffer if necessary

Parameters

TInt aPos

TDes8 &aDes


DataSize()

private: virtual TInt DataSize();

Description

Return value

TInt


ResetData()

private: virtual void ResetData();

Description

[Top]


Member enumerations


Enum TFileBuffering

TFileBuffering

Description

Obex file buffering method.

ESingleBuffering

Only the supplied buffer will be used to buffer file writes.

EDoubleBuffering

The object will create a second buffer and perform double buffering.