diff -r 000000000000 -r 3553901f7fa8 smsprotocols/smsstack/gsmu/src/gsmubuf.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/smsprotocols/smsstack/gsmu/src/gsmubuf.cpp Tue Feb 02 01:41:59 2010 +0200 @@ -0,0 +1,256 @@ +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// This file contains the implementation of the SMS buffer +// +// + +/** + @file +*/ + +#include "gsmubuf.h" +#include "Gsmumain.h" + +#include + + +/** + * Internalises the object. + * + * @param aStream Stream to read from + * @capability None + */ +EXPORT_C void CSmsBufferBase::InternalizeL(RReadStream& aStream) + { + Reset(); + TInt length=aStream.ReadInt32L(); + TBuf buf; + for (TInt pos=0; pos buf; + TInt buflength=(pos+EMaxBufLength)<=length? EMaxBufLength: length-pos; + Extract(buf,pos,buflength); + aStream.WriteL(buf,buflength); + } + } // CSmsBufferBase::ExternalizeL + + +/** + * Allocates and constructs the buffer. + * + * @return New CSmsBuffer object + * @capability None + */ +EXPORT_C CSmsBuffer* CSmsBuffer::NewL() + { + CSmsBuffer* smsbuffer=new(ELeave) CSmsBuffer(); + CleanupStack::PushL(smsbuffer); + smsbuffer->iBuffer=new(ELeave) CArrayFixSeg(EMaxBufLength); + CleanupStack::Pop(); + return smsbuffer; + } // CSmsBuffer::NewL + + +/** + * Destructor, frees resource. + * @capability None + */ +EXPORT_C CSmsBuffer::~CSmsBuffer() + { + delete iBuffer; + } // CSmsBuffer::NewL + + +/** + * Gets the amount of space currently used in the buffer. + * + * @return Amount of space currently used in the buffer + * @capability None + */ +EXPORT_C TInt CSmsBuffer::Length() const + { + return iBuffer->Count(); + } // CSmsBuffer::Length + + +/** + * Extracts buffer data to a descriptor. + * + * @param aBuf On return, buffer data + * @param aPos Position within buffer to begin reading + * @param aLength The amount of data to read from the buffer + * @capability None + */ +EXPORT_C void CSmsBuffer::Extract(TDes& aBuf,TInt aPos,TInt aLength) const + { + aBuf.SetLength(aLength); + for (TInt i=0; iAt(aPos+i); + } // CSmsBuffer::Extract + + +/** + * Inserts data into the buffer. + * + * @param aPos Position in the buffer to insert the data + * @param aBuf The data to insert into the buffer + * @capability None + */ +EXPORT_C void CSmsBuffer::InsertL(TInt aPos,const TDesC& aBuf) + { + iBuffer->InsertL(aPos,aBuf.Ptr(),aBuf.Length()); + } // CSmsBuffer::InsertL + + +/** + * Deletes data from the buffer. + * + * @param aPos Position in the buffer to delete the data + * @param aLength The amount of data to delete from the buffer + * @capability None + */ +EXPORT_C void CSmsBuffer::DeleteL(TInt aPos,TInt aLength) + { + iBuffer->Delete(aPos,aLength); + } // CSmsBuffer::DeleteL + + +/** + * Resets the buffer. + * @capability None + */ +EXPORT_C void CSmsBuffer::Reset() + { + iBuffer->Reset(); + } // CSmsBuffer::Reset + + +CSmsBuffer::CSmsBuffer() + { + // NOP + } // CSmsBuffer::CSmsBuffer + + +/** + * Allocates and constructs the buffer. + * + * @param aText Text object to use as buffer + * @return New CSmsEditorBuffer object + * @capability None + */ +EXPORT_C CSmsEditorBuffer* CSmsEditorBuffer::NewL(CEditableText& aText) + { + CSmsEditorBuffer* smseditorbuffer=new(ELeave) CSmsEditorBuffer(aText); + CleanupStack::PushL(smseditorbuffer); + CleanupStack::Pop(); + return smseditorbuffer; + } // CSmsEditorBuffer::NewL + + +/** + * Destructor. + * @capability None + */ +EXPORT_C CSmsEditorBuffer::~CSmsEditorBuffer() + { + // NOP + } // CSmsEditorBuffer::NewL + + +/** + * Gets the number of characters in the buffer. + * + * @return The number of characters in the buffer. + * @capability None + */ +EXPORT_C TInt CSmsEditorBuffer::Length() const + { + return iText.DocumentLength(); + } // CSmsEditorBuffer::Length + + +/** + * Extracts buffer data to a descriptor. + * + * @param aBuf On return, buffer data + * @param aPos Position within buffer to begin reading + * @param aLength The amount of data to read from the buffer + * @capability None + */ +EXPORT_C void CSmsEditorBuffer::Extract(TDes& aBuf,TInt aPos,TInt aLength) const + { + iText.Extract(aBuf,aPos,aLength); + } // CSmsEditorBuffer::Extract + + +/** + * Inserts data into the buffer. + * + * @param aPos Position in the buffer to insert the data + * @param aBuf The data to insert into the buffer + * @capability None + */ +EXPORT_C void CSmsEditorBuffer::InsertL(TInt aPos,const TDesC& aBuf) + { + iText.InsertL(aPos,aBuf); + } // CSmsEditorBuffer::InsertL + + +/** + * Deletes data from the buffer. + * + * @param aPos Position in the buffer to delete the data + * @param aLength The amount of data to delete from the buffer + * @capability None + */ +EXPORT_C void CSmsEditorBuffer::DeleteL(TInt aPos,TInt aLength) + { + iText.DeleteL(aPos,aLength); + } // CSmsEditorBuffer::DeleteL + + +/** + * Reset the buffer. + * @capability None + */ +EXPORT_C void CSmsEditorBuffer::Reset() + { + iText.Reset(); + } // CSmsEditorBuffer::Reset + + +CSmsEditorBuffer::CSmsEditorBuffer(CEditableText& aText): + iText(aText) + { + // NOP + } // CSmsEditorBuffer::CSmsEditorBuffer