24
|
1 |
// Copyright (c) 2000-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 "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Segmentation and reassembly utility classes
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
*/
|
|
21 |
|
|
22 |
#ifndef __GSMUSAR_H__
|
|
23 |
#define __GSMUSAR_H__
|
|
24 |
|
|
25 |
#include <charconv.h>
|
|
26 |
#include <gsmubuf.h>
|
|
27 |
#include <gsmuelem.h>
|
|
28 |
|
|
29 |
/**
|
|
30 |
* @internalComponent
|
|
31 |
*/
|
|
32 |
_LIT8(KMOSES,"\x40\x4d\x64\xd3\x50\x00");
|
|
33 |
/**
|
|
34 |
* @internalComponent
|
|
35 |
*/
|
|
36 |
_LIT16(KNETWORK,"NETWORK");
|
|
37 |
|
|
38 |
|
|
39 |
// Constants
|
|
40 |
/**
|
|
41 |
* @internalComponent
|
|
42 |
*/
|
|
43 |
const TUint8 KSms7BitAlphabetEscapeChar=0x1b;
|
|
44 |
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Segments unpacked data from a CsmsBufferBase
|
|
48 |
* @internalComponent
|
|
49 |
*/
|
|
50 |
class CSmsBufferSegmenter : public CBase
|
|
51 |
{
|
|
52 |
friend class CSmsUserData;
|
|
53 |
public:
|
|
54 |
// Construction / destruction methods
|
|
55 |
IMPORT_C static CSmsBufferSegmenter* NewLC(CSmsAlphabetConverter& aAlphabetConverter,const CSmsBufferBase& aBuffer,TInt aSegmentSize=0);
|
|
56 |
IMPORT_C ~CSmsBufferSegmenter();
|
|
57 |
|
|
58 |
// Segmentation methods
|
|
59 |
void Reset();
|
|
60 |
IMPORT_C TBool SegmentNextL(TDes8& aSegmentBuffer, TInt& aUnconvertedChars,
|
|
61 |
TInt& aDowngradedChars,
|
|
62 |
TSmsEncoding aEncoding);
|
|
63 |
IMPORT_C TInt TotalConvertedLengthL(TSmsEncoding aEncoding);
|
|
64 |
TBool MoreL();
|
|
65 |
|
|
66 |
TSmsEncoding FindBestAlternativeEncodingL(TSmsEncoding aSuggestedEncoding,
|
|
67 |
TInt aMaxBodyLength) const;
|
|
68 |
|
|
69 |
protected:
|
|
70 |
// Protected construction methods
|
|
71 |
CSmsBufferSegmenter(CSmsAlphabetConverter& aAlphabetConverter,const CSmsBufferBase& aBuffer,TInt aSegmentSize);
|
|
72 |
void ConstructL();
|
|
73 |
|
|
74 |
// Protected helper methods
|
|
75 |
virtual TBool DoSegmentNextL(TDes8& aSegmentBuffer,TInt aSegmentSize,
|
|
76 |
TInt& aUnconvertedChars, TInt& aDowngradedChars,
|
|
77 |
TSmsEncoding aEncoding);
|
|
78 |
void CheckConvertedBufferAllocL(TInt aMaxLength);
|
|
79 |
TInt ElementsToReturnFromConvertedBufferL(TInt aSegmentSize);
|
|
80 |
|
|
81 |
protected:
|
|
82 |
// Private data
|
|
83 |
CSmsAlphabetConverter& iAlphabetConverter;
|
|
84 |
const CSmsBufferBase& iSmsBuffer;
|
|
85 |
TInt iElementsExtracted;
|
|
86 |
TInt iSegmentSize;
|
|
87 |
HBufC8* iConvertedBuffer;
|
|
88 |
TPtr8 iConvertedBufferPtr;
|
|
89 |
};
|
|
90 |
|
|
91 |
|
|
92 |
/**
|
|
93 |
* @internalComponent
|
|
94 |
*/
|
|
95 |
class CSmsEMSBufferSegmenter : public CSmsBufferSegmenter
|
|
96 |
{
|
|
97 |
public:
|
|
98 |
IMPORT_C static CSmsEMSBufferSegmenter* NewLC(CSmsAlphabetConverter& aAlphabetConverter,const CSmsBufferBase& aBuffer, TInt aSegmentSize=0);
|
|
99 |
|
|
100 |
IMPORT_C TBool SegmentNextL(TDes8& aSegmentBuffer,TInt aSegmentSize,
|
|
101 |
TInt& aUnconvertedChars, TInt& aDowngradedChars,
|
|
102 |
TSmsEncoding aEncoding);
|
|
103 |
|
|
104 |
TInt SegmentL(TDes8& aSegmentBuffer, TInt aNativeChars, TInt aSegmentMax,
|
|
105 |
TInt& aUnconvertedChars, TInt& aDowngradedChars,
|
|
106 |
TSmsEncoding aEncoding);
|
|
107 |
|
|
108 |
protected:
|
|
109 |
CSmsEMSBufferSegmenter(CSmsAlphabetConverter& aAlphabetConverter,const CSmsBufferBase& aBuffer,TInt aSegmentSize);
|
|
110 |
|
|
111 |
};
|
|
112 |
|
|
113 |
|
|
114 |
/**
|
|
115 |
* TSmsBufferReassembler - reassembles (unpacked) data to CSmsBufferBase
|
|
116 |
* @internalComponent
|
|
117 |
*/
|
|
118 |
class TSmsBufferReassembler
|
|
119 |
{
|
|
120 |
public:
|
|
121 |
// Construction / destruction methods
|
|
122 |
IMPORT_C TSmsBufferReassembler(CSmsAlphabetConverter& aAlphabetConverter,CSmsBufferBase& aBuffer);
|
|
123 |
|
|
124 |
// Reassembly methods
|
|
125 |
IMPORT_C void ReassembleNextL(const TDesC8& aSegmentBuffer,
|
|
126 |
TSmsEncoding aEncoding, TBool aIsLast);
|
|
127 |
|
|
128 |
private:
|
|
129 |
CSmsAlphabetConverter& iAlphabetConverter;
|
|
130 |
CSmsBufferBase& iSmsBuffer;
|
|
131 |
};
|
|
132 |
|
|
133 |
#endif // __GSMUSAR_H__
|