1 gsmubuf.h |
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This file contains the header file of the CSmsBuffers. |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 */ |
|
23 |
|
24 #ifndef __GSMUBUF_H__ |
|
25 #define __GSMUBUF_H__ |
|
26 |
|
27 #include <e32std.h> |
|
28 #include <s32strm.h> |
|
29 |
|
30 class CEditableText; |
|
31 class RReadStream; |
|
32 class RWriteStream; |
|
33 |
|
34 |
|
35 /** |
|
36 * The base class for all SMS buffers. |
|
37 * @publishedAll |
|
38 * @released |
|
39 */ |
|
40 class CSmsBufferBase : public CBase |
|
41 { |
|
42 public: |
|
43 enum |
|
44 { |
|
45 EMaxBufLength=0x100 |
|
46 }; |
|
47 public: |
|
48 /** |
|
49 * Gets the number of characters in the buffer. |
|
50 * |
|
51 * @return The number of characters in the buffer. |
|
52 */ |
|
53 virtual TInt Length() const=0; |
|
54 /** |
|
55 * Extracts buffer data to a descriptor. |
|
56 * |
|
57 * @param aBuf On return, buffer data |
|
58 * @param aPos Position within buffer to begin reading |
|
59 * @param aLength The number of bytes to read from the buffer |
|
60 */ |
|
61 virtual void Extract(TDes& aBuf,TInt aPos,TInt aLength) const=0; |
|
62 /** |
|
63 * Inserts data into the buffer. |
|
64 * |
|
65 * @param aPos Position in the buffer to insert the data |
|
66 * @param aBuf The data to insert into the buffer |
|
67 */ |
|
68 virtual void InsertL(TInt aPos,const TDesC& aBuf)=0; |
|
69 /** |
|
70 * Deletes data from the buffer. |
|
71 * |
|
72 * @param aPos Position in the buffer to delete the data |
|
73 * @param aLength The number of bytes to delete from the buffer |
|
74 */ |
|
75 virtual void DeleteL(TInt aPos,TInt aLength)=0; |
|
76 /** Resets the buffer. */ |
|
77 virtual void Reset()=0; |
|
78 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
79 IMPORT_C void ExternalizeL(RWriteStream& aStream) const; |
|
80 }; |
|
81 |
|
82 |
|
83 /** |
|
84 * This is the simplest implementation of CSmsBufferBase. |
|
85 * |
|
86 * It stores the buffer in an array of TTexts. |
|
87 * @publishedAll |
|
88 * @released |
|
89 */ |
|
90 class CSmsBuffer : public CSmsBufferBase |
|
91 { |
|
92 public: |
|
93 IMPORT_C static CSmsBuffer* NewL(); |
|
94 IMPORT_C ~CSmsBuffer(); |
|
95 IMPORT_C TInt Length() const; |
|
96 IMPORT_C void Extract(TDes& aBuf,TInt aPos,TInt aLength) const; |
|
97 IMPORT_C void InsertL(TInt aPos,const TDesC& aBuf); |
|
98 IMPORT_C void DeleteL(TInt aPos,TInt aLength); |
|
99 IMPORT_C void Reset(); |
|
100 private: |
|
101 CSmsBuffer(); |
|
102 private: |
|
103 |
|
104 CArrayFix<TText>* iBuffer; |
|
105 }; |
|
106 |
|
107 |
|
108 /** |
|
109 * SMS buffer, implemented as a thin wrapper over CEditableText. |
|
110 * |
|
111 * This class is designed to be used by the Message Server, which stores SMS |
|
112 * text as CRichText, which is derived from CEditableText. |
|
113 * @publishedAll |
|
114 * @released |
|
115 */ |
|
116 class CSmsEditorBuffer : public CSmsBufferBase |
|
117 { |
|
118 public: |
|
119 IMPORT_C static CSmsEditorBuffer* NewL(CEditableText& aText); |
|
120 IMPORT_C ~CSmsEditorBuffer(); |
|
121 IMPORT_C TInt Length() const; |
|
122 IMPORT_C void Extract(TDes& aBuf,TInt aPos,TInt aLength) const; |
|
123 IMPORT_C void InsertL(TInt aPos,const TDesC& aBuf); |
|
124 IMPORT_C void DeleteL(TInt aPos,TInt aLength); |
|
125 IMPORT_C void Reset(); |
|
126 private: |
|
127 CSmsEditorBuffer(CEditableText& aText); |
|
128 private: |
|
129 CEditableText& iText; |
|
130 }; |
|
131 |
|
132 #endif // !defined __GSMUBUF_H__ |