CObexBufObject Class Reference

class CObexBufObject : public CObexBaseObject

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 NewL() passing in a NULL pointer, then call SetDataBufL() 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.

Inherits from

Public Member Functions
~CObexBufObject()
IMPORT_C CBufBase *DataBuf()
HBufC *FileName()
IMPORT_C CObexBufObject *NewL(CBufBase *)
IMPORT_C voidSetDataBufL(TObexBufferingDetails &)
IMPORT_C voidSetDataBufL(CBufBase *)
IMPORT_C voidSetDataBufL(const TPtrC &)
IMPORT_C voidSetDataBufL(const TPtrC &, CBufBase *)
IMPORT_C voidSetDataBufL(const TPtrC &, CBufBase &, const TFileBuffering)
IMPORT_C TIntWriteToFile(const TPtrC &)
Private Member Functions
CObexBufObject()
voidCloseDataFile()
voidCloseFileServer()
voidConstructL(CBufBase *)
voidCopyFileL(const TDesC &)
TInt DataSize()
voidGetData(TInt, TDes8 &)
voidGetFileData(TInt, TDes8 &)
voidNewData(TInt, TDes8 &)
TInt NewFileData(TInt, TDes8 &)
TInt OpenDataFile(const TDesC &)
TInt OpenFileServer()
voidPrepareToSetBufferL()
voidResetData()
TInt WriteBufferToFile(TBool)
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()
CObexBaseObject::AddHeaderL(CObexHeader &)
CObexBaseObject::AddHttpL(const TDesC8 &)
CObexBaseObject::AppParam()const
CObexBaseObject::BytesReceived()
CObexBaseObject::BytesSent()
CObexBaseObject::CObexBaseObject()
CObexBaseObject::ConnectionID()
CObexBaseObject::CreateHeaderStorageDataL()
CObexBaseObject::Description()
CObexBaseObject::GetLastError()const
CObexBaseObject::GuessTypeFromExtL(const TDesC &)
CObexBaseObject::HeaderMask()
CObexBaseObject::HeaderSet()
CObexBaseObject::HeaderSet()const
CObexBaseObject::Http()const
CObexBaseObject::InitReceive()
CObexBaseObject::InitSend(TObexOpcode)
CObexBaseObject::Length()
CObexBaseObject::Name()
CObexBaseObject::ParseNextReceivePacket(CObexPacket &)
CObexBaseObject::PrepareConnectionHeader(CObexPacket &)
CObexBaseObject::PrepareNextSendPacket(CObexPacket &)
CObexBaseObject::Reset()
CObexBaseObject::ResetHeaders()
CObexBaseObject::SetAppParamL(const TDesC8 &)
CObexBaseObject::SetConnectionIdL(TUint32)
CObexBaseObject::SetDescriptionL(const TDesC &)
CObexBaseObject::SetHeaderMask(const TObexHeaderMask)
CObexBaseObject::SetLengthL(const TUint32)
CObexBaseObject::SetNameL(const TDesC &)
CObexBaseObject::SetTargetL(const TDesC8 &)
CObexBaseObject::SetTimeHeaderL(const TDesC8 &)
CObexBaseObject::SetTimeL(const TTime)
CObexBaseObject::SetTypeL(const TDesC8 &)
CObexBaseObject::SetUtcTimeL(const TTime)
CObexBaseObject::Target()
CObexBaseObject::Time()
CObexBaseObject::Type()
CObexBaseObject::ValidHeaders()
CObexBaseObject::~CObexBaseObject()
Public Member Enumerations
enumTFileBuffering { ESingleBuffering, EDoubleBuffering }
Inherited Enumerations
CObexBaseObject:TProgress
Private Attributes
CBufBase *iBuf
TInt iBufOffset
TInt iBufSegSize
TInt iBuffered
CBufBase *iDoubleBuf
RFile *iFile
RFs *iFileServ
HBufC *iFilename
MObexFileWriter *iWriter

Constructor & Destructor Documentation

CObexBufObject()

CObexBufObject()[private]

~CObexBufObject()

IMPORT_C~CObexBufObject()[virtual]

Destructor.

Member Functions Documentation

CloseDataFile()

voidCloseDataFile()[private]

CloseFileServer()

voidCloseFileServer()[private]

ConstructL(CBufBase *)

voidConstructL(CBufBase *aDataBuf)[private]

Parameters

CBufBase * aDataBuf

CopyFileL(const TDesC &)

voidCopyFileL(const TDesC &aFilename)[private]

Parameters

const TDesC & aFilename

DataBuf()

IMPORT_C CBufBase *DataBuf()

Gets the buffer.

DataSize()

TInt DataSize()[private, virtual]

FileName()

HBufC *FileName()

Returns a pointer to the HBuf holding the filename this object is using. May return a null pointer.

GetData(TInt, TDes8 &)

voidGetData(TIntaPos,
TDes8 &aDes
)[private, virtual]

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

Parameters

TInt aPosThe offset into the buffer to read from
TDes8 & aDesThe descriptor to read from

GetFileData(TInt, TDes8 &)

voidGetFileData(TIntaPos,
TDes8 &aDes
)[private]

Parameters

TInt aPos
TDes8 & aDes

NewData(TInt, TDes8 &)

voidNewData(TIntaPos,
TDes8 &aDes
)[private, virtual]

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

Parameters

TInt aPos
TDes8 & aDes

NewFileData(TInt, TDes8 &)

TInt NewFileData(TIntaPos,
TDes8 &aDes
)[private]

Write new data into a file

We write data out to the file in chunks of iBufSegSize, the (segment) size of the buffer. A packet of data is passed to this method in aDes. aDes may or may not take us past the the end of the buffer. If it does, then we write out the buffer then continue filling it up with the rest of aDes. We repeat this until we have used up all of aDes. iBufOffset is the last write position in the file. remaining is the amount of data in aDes yet to be processed, written is the amount of data in aDes that has been processed. iBuffered is the amount of data in iBuf and spare is the amount of free space in the buffer.

                               aDes.Length()
                        <---------------------->
 ------------------------------------------------------------------------
| ...      |xxxxxxxxxxxx|\\\\\\\\\\|//|*************|  ...      |
| ...      |xxxxxxxxxxxx|\\\\\\\\\\|//|*************|  ...      |
 ------------------------------------------------------------------------
0 ...  iBufOffset     aPos                                      ...  this.Length()

                           written    remaining
                         <---------><----------->

                    iBuffered                 spare
            <----------------------><------------------------>

                              iBufSegSize
            <------------------------------------------------>

 Key:
      xxx = data already in buffer
      \\\ = processed data from aDes, copied into iBuf
      // = unprocessed data from aDes, not yet copied into iBuf
 = free space in iBuf

If there is more data remaining than there is spare space in the buffer, then the buffer is filled and written to disk and the remainer of the data is then used to continue filling the buffer.

Parameters

TInt aPosThe position at which aDes is to be written into the file.
TDes8 & aDesThe data to write to the file.

NewL(CBufBase *)

IMPORT_C CObexBufObject *NewL(CBufBase *aDataBuf)[static]

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

Parameters

CBufBase * aDataBufThe buffer for the body of the object. This must be set either by this constructor or by calling SetDataBufL() before using the object.

OpenDataFile(const TDesC &)

TInt OpenDataFile(const TDesC &aFilename)[private]

Parameters

const TDesC & aFilename

OpenFileServer()

TInt OpenFileServer()[private]

PrepareToSetBufferL()

voidPrepareToSetBufferL()[private]

Delete all owned resources in preparation for getting new settings.

ResetData()

voidResetData()[private, virtual]

SetDataBufL(TObexBufferingDetails &)

IMPORT_C voidSetDataBufL(TObexBufferingDetails &aDetails)
Set the data buffers as specified in the supplied TObexBufferingDetails object.
panic
Obex ENullFileHandle TObexPanicCode::ENullFileHandle The RFile object does not point to a valid (open) file.
panic
Obex EEmptyBuffer TObexPanicCode::EEmptyBuffer The supplied buffer is of zero length.
panic
Obex EInvalidBufferDetails TObexPanicCode::EInvalidBufferDetails An unknown TObexBufferingDetails object was supplied
panic
Obex EInvalidBufferStrategy TObexPanicCode::EInvalidBufferStrategy An unknown TFileBuffering value was supplied.

Parameters

TObexBufferingDetails & aDetailsThe 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.

SetDataBufL(CBufBase *)

IMPORT_C voidSetDataBufL(CBufBase *aDataBuf)

Sets a buffer to use the object body data.

Note that the function can leave.

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

Parameters

CBufBase * aDataBufThe buffer for the body of the object.

SetDataBufL(const TPtrC &)

IMPORT_C voidSetDataBufL(const TPtrC &aFilename)

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

Parameters

const TPtrC & aFilenameThe filename to link the object to.

SetDataBufL(const TPtrC &, CBufBase *)

IMPORT_C voidSetDataBufL(const TPtrC &aFilename,
CBufBase *aDataBuf
)

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.

panic
Obex ENullPointer TObexPanicCode::ENullPointer A NULL value was supplied for the data buffer.
panic
Obex EEmptyBuffer TObexPanicCode::EEmptyBuffer The supplied buffer is of zero length.

Parameters

const TPtrC & aFilenameThe filename to link the object to.
CBufBase * aDataBufThe buffer for the body of the object.

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

IMPORT_C voidSetDataBufL(const TPtrC &aFilename,
CBufBase &aDataBuf,
const TFileBufferingaBufferingStrategy
)

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.

panic
Obex EEmptyBuffer TObexPanicCode::EEmptyBuffer The supplied buffer is of zero length.
panic
Obex EInvalidBufferStrategy TObexPanicCode::EInvalidBufferStrategy An unknown TFileBuffering

Parameters

const TPtrC & aFilenameThe file to link the object to.
CBufBase & aDataBufA buffer to use.
const TFileBuffering aBufferingStrategyThe buffering strategy to employ.

WriteBufferToFile(TBool)

TInt WriteBufferToFile(TBoolaFinal)[private]

Parameters

TBool aFinal

WriteToFile(const TPtrC &)

IMPORT_C TIntWriteToFile(const TPtrC &aFileName)

Writes contents of object to a file

Parameters

const TPtrC & aFileNameTarget file

Member Enumerations Documentation

Enum TFileBuffering

Obex file buffering method.

Enumerators

ESingleBuffering

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

EDoubleBuffering

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

Member Data Documentation

CBufBase * iBuf

CBufBase *iBuf[private]

TInt iBufOffset

TInt iBufOffset[private]

TInt iBufSegSize

TInt iBufSegSize[private]

TInt iBuffered

TInt iBuffered[private]

CBufBase * iDoubleBuf

CBufBase *iDoubleBuf[private]

RFile * iFile

RFile *iFile[private]

RFs * iFileServ

RFs *iFileServ[private]

HBufC * iFilename

HBufC *iFilename[private]

MObexFileWriter * iWriter

MObexFileWriter *iWriter[private]