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.
Public Member Functions | |
---|---|
~CObexBufObject() | |
IMPORT_C CBufBase * | DataBuf() |
HBufC * | FileName() |
IMPORT_C CObexBufObject * | NewL(CBufBase *) |
IMPORT_C void | SetDataBufL(TObexBufferingDetails &) |
IMPORT_C void | SetDataBufL(CBufBase *) |
IMPORT_C void | SetDataBufL(const TPtrC &) |
IMPORT_C void | SetDataBufL(const TPtrC &, CBufBase *) |
IMPORT_C void | SetDataBufL(const TPtrC &, CBufBase &, const TFileBuffering) |
IMPORT_C TInt | WriteToFile(const TPtrC &) |
Private Member Functions | |
---|---|
CObexBufObject() | |
void | CloseDataFile() |
void | CloseFileServer() |
void | ConstructL(CBufBase *) |
void | CopyFileL(const TDesC &) |
TInt | DataSize() |
void | GetData(TInt, TDes8 &) |
void | GetFileData(TInt, TDes8 &) |
void | NewData(TInt, TDes8 &) |
TInt | NewFileData(TInt, TDes8 &) |
TInt | OpenDataFile(const TDesC &) |
TInt | OpenFileServer() |
void | PrepareToSetBufferL() |
void | ResetData() |
TInt | WriteBufferToFile(TBool) |
Public Member Enumerations | |
---|---|
enum | TFileBuffering { 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 |
void | CopyFileL | ( | const TDesC & | aFilename | ) | [private] |
const TDesC & aFilename |
HBufC * | FileName | ( | ) |
Returns a pointer to the HBuf holding the filename this object is using. May return a null pointer.
void | GetData | ( | TInt | aPos, |
TDes8 & | aDes | |||
) | [private, virtual] |
Reads aDes (up to MaxLength) from aPos offset into the buffer
void | NewData | ( | TInt | aPos, |
TDes8 & | aDes | |||
) | [private, virtual] |
Writes aDes into the buffer at aPos offset, growing the buffer if necessary
TInt | NewFileData | ( | TInt | aPos, |
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.
IMPORT_C CObexBufObject * | NewL | ( | CBufBase * | aDataBuf | ) | [static] |
Allocates and constructs a new OBEX dynamic buffer object, specifying a buffer.
CBufBase * aDataBuf | The buffer for the body of the object. This must be set either by this constructor or by calling SetDataBufL() before using the object. |
TInt | OpenDataFile | ( | const TDesC & | aFilename | ) | [private] |
const TDesC & aFilename |
void | PrepareToSetBufferL | ( | ) | [private] |
Delete all owned resources in preparation for getting new settings.
IMPORT_C void | SetDataBufL | ( | TObexBufferingDetails & | aDetails | ) |
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. |
IMPORT_C void | SetDataBufL | ( | CBufBase * | aDataBuf | ) |
Sets a buffer to use the object body data.
Note that the function can leave.
CBufBase * aDataBuf | The buffer for the body of the object. |
IMPORT_C void | SetDataBufL | ( | const TPtrC & | aFilename | ) |
Set object to use aFilename as its data area. Leaves if unable to open file.
const TPtrC & aFilename | The filename to link the object to. |
IMPORT_C void | SetDataBufL | ( | 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.
IMPORT_C void | SetDataBufL | ( | const TPtrC & | aFilename, |
CBufBase & | aDataBuf, | |||
const TFileBuffering | aBufferingStrategy | |||
) |
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.
const TPtrC & aFilename | The file to link the object to. |
CBufBase & aDataBuf | A buffer to use. |
const TFileBuffering aBufferingStrategy | The buffering strategy to employ. |
IMPORT_C TInt | WriteToFile | ( | const TPtrC & | aFileName | ) |
Writes contents of object to a file
const TPtrC & aFileName | Target file |
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. |
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.