williamr@2: // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // This file contains the header file of the CSmsBuffers. williamr@2: // williamr@2: // williamr@2: williamr@2: /** williamr@2: @file williamr@2: */ williamr@2: williamr@2: #ifndef __GSMUBUF_H__ williamr@2: #define __GSMUBUF_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: williamr@2: class CEditableText; williamr@2: class RReadStream; williamr@2: class RWriteStream; williamr@2: williamr@2: williamr@2: /** williamr@2: * The base class for all SMS buffers. williamr@2: * @publishedAll williamr@2: * @released williamr@2: */ williamr@2: class CSmsBufferBase : public CBase williamr@2: { williamr@2: public: williamr@2: enum williamr@2: { williamr@2: EMaxBufLength=0x100 williamr@2: }; williamr@2: public: williamr@2: /** williamr@2: * Gets the number of characters in the buffer. williamr@2: * williamr@2: * @return The number of characters in the buffer. williamr@2: */ williamr@2: virtual TInt Length() const=0; williamr@2: /** williamr@2: * Extracts buffer data to a descriptor. williamr@2: * williamr@2: * @param aBuf On return, buffer data williamr@2: * @param aPos Position within buffer to begin reading williamr@2: * @param aLength The number of bytes to read from the buffer williamr@2: */ williamr@2: virtual void Extract(TDes& aBuf,TInt aPos,TInt aLength) const=0; williamr@2: /** williamr@2: * Inserts data into the buffer. williamr@2: * williamr@2: * @param aPos Position in the buffer to insert the data williamr@2: * @param aBuf The data to insert into the buffer williamr@2: */ williamr@2: virtual void InsertL(TInt aPos,const TDesC& aBuf)=0; williamr@2: /** williamr@2: * Deletes data from the buffer. williamr@2: * williamr@2: * @param aPos Position in the buffer to delete the data williamr@2: * @param aLength The number of bytes to delete from the buffer williamr@2: */ williamr@2: virtual void DeleteL(TInt aPos,TInt aLength)=0; williamr@2: /** Resets the buffer. */ williamr@2: virtual void Reset()=0; williamr@2: IMPORT_C void InternalizeL(RReadStream& aStream); williamr@2: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: * This is the simplest implementation of CSmsBufferBase. williamr@2: * williamr@2: * It stores the buffer in an array of TTexts. williamr@2: * @publishedAll williamr@2: * @released williamr@2: */ williamr@2: class CSmsBuffer : public CSmsBufferBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C static CSmsBuffer* NewL(); williamr@2: IMPORT_C ~CSmsBuffer(); williamr@2: IMPORT_C TInt Length() const; williamr@2: IMPORT_C void Extract(TDes& aBuf,TInt aPos,TInt aLength) const; williamr@2: IMPORT_C void InsertL(TInt aPos,const TDesC& aBuf); williamr@2: IMPORT_C void DeleteL(TInt aPos,TInt aLength); williamr@2: IMPORT_C void Reset(); williamr@2: private: williamr@2: CSmsBuffer(); williamr@2: private: williamr@2: williamr@2: CArrayFix* iBuffer; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: * SMS buffer, implemented as a thin wrapper over CEditableText. williamr@2: * williamr@2: * This class is designed to be used by the Message Server, which stores SMS williamr@2: * text as CRichText, which is derived from CEditableText. williamr@2: * @publishedAll williamr@2: * @released williamr@2: */ williamr@2: class CSmsEditorBuffer : public CSmsBufferBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C static CSmsEditorBuffer* NewL(CEditableText& aText); williamr@2: IMPORT_C ~CSmsEditorBuffer(); williamr@2: IMPORT_C TInt Length() const; williamr@2: IMPORT_C void Extract(TDes& aBuf,TInt aPos,TInt aLength) const; williamr@2: IMPORT_C void InsertL(TInt aPos,const TDesC& aBuf); williamr@2: IMPORT_C void DeleteL(TInt aPos,TInt aLength); williamr@2: IMPORT_C void Reset(); williamr@2: private: williamr@2: CSmsEditorBuffer(CEditableText& aText); williamr@2: private: williamr@2: CEditableText& iText; williamr@2: }; williamr@2: williamr@2: #endif // !defined __GSMUBUF_H__