24
|
1 |
// Copyright (c) 1997-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 |
// Contains the header file of the CWapDatagram
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
@internalAll
|
|
21 |
*/
|
|
22 |
|
|
23 |
#if !defined (WAPDGRM_H__)
|
|
24 |
#define WAPDGRM_H__
|
|
25 |
|
|
26 |
#include <e32def.h>
|
|
27 |
#include <e32std.h>
|
|
28 |
#include <s32buf.h>
|
|
29 |
#include <s32mem.h>
|
|
30 |
#include "gsmubuf.h"
|
|
31 |
#include "gsmuset.h"
|
|
32 |
#include "Gsmuelem.h"
|
|
33 |
#include "Gsmumsg.h"
|
|
34 |
#include "wapthdr.h"
|
|
35 |
|
|
36 |
class RMBufChain;
|
|
37 |
|
|
38 |
const TInt KSmsBufferExpansion=0x100;
|
|
39 |
|
|
40 |
// Notes !
|
|
41 |
// - Character sets
|
|
42 |
// Incoming (up stack):
|
|
43 |
// This class converts Unicode characters of a CSmsMessage object
|
|
44 |
// to either 7 or 8 bit.
|
|
45 |
// Outgoing (down stack): This class converts 7 or 8 bit input data to Unicode.
|
|
46 |
//
|
|
47 |
// - Text based headers
|
|
48 |
// Concerning 7 bit characters:
|
|
49 |
// port information is ALWAYS encoded in //SCK style.
|
|
50 |
|
|
51 |
/**
|
|
52 |
* @internalComponent
|
|
53 |
*/
|
|
54 |
class CWapDatagram : public CBase
|
|
55 |
{
|
|
56 |
public:
|
|
57 |
|
|
58 |
enum TWapDatagramVersion
|
|
59 |
{
|
|
60 |
EBaseVersion=0,
|
|
61 |
EFirstVersion=1,
|
|
62 |
};
|
|
63 |
|
|
64 |
struct TSegmentData
|
|
65 |
{
|
|
66 |
TInt iSegmentNumber;
|
|
67 |
TBuf8<KMaxSmsChars> iData; //< application data
|
|
68 |
};
|
|
69 |
|
|
70 |
// Contructor for incoming short messages
|
|
71 |
// Set the character width 7- or 8-bit in the parameter aAlphabet,
|
|
72 |
// which you expect to get through WapDatagram().
|
|
73 |
// UNICODE is not supported.
|
|
74 |
// If the WAP datagram is complete (IsComplete()),
|
|
75 |
// call the WapDatagram() to retrieve the data.
|
|
76 |
|
|
77 |
// If the datagram is not complete, concatenate
|
|
78 |
// the WAP datagram, when all the segments are available
|
|
79 |
// through DecodeConcatenatedMessagesL().
|
|
80 |
static CWapDatagram* NewL( const CSmsMessage& aSms);
|
|
81 |
|
|
82 |
// for outgoing short messages
|
|
83 |
static CWapDatagram* NewL( const TDesC8& aBuffer);
|
|
84 |
|
|
85 |
~CWapDatagram();
|
|
86 |
|
|
87 |
// Only 7-bit text mode socket header may return false
|
|
88 |
// when the datagram is not complete.
|
|
89 |
inline TBool IsComplete() const;
|
|
90 |
|
|
91 |
// Get the length of the datagram
|
|
92 |
inline TInt WapDatagramLength() const;
|
|
93 |
|
|
94 |
// Copies the user data of incoming WAP datagram to the aBufChain
|
|
95 |
// Prior to calling this method IsComplete() should return true
|
|
96 |
// and/or DecodeConcatenatedMessagesL() should have been called.
|
|
97 |
// aMaxLength indicates largest size that will be passed atomically
|
|
98 |
// to the client: generally the whole datagram should be returned
|
|
99 |
// but this can be used for truncation if required.
|
|
100 |
// Returns error code
|
|
101 |
inline TInt WapDatagram(RMBufChain& aBufChain, TUint aMaxLength) const;
|
|
102 |
|
|
103 |
// if CWapDatagram object is incomplete, get the
|
|
104 |
// TSegmentData information of the short message
|
|
105 |
inline void SegmentData(TSegmentData& aSegmentData) const;
|
|
106 |
|
|
107 |
// from WAP spec: destination address
|
|
108 |
inline TPtrC ToAddress() const;
|
|
109 |
inline void SetToAddress(const TDesC& aToAddress);
|
|
110 |
|
|
111 |
// from WAP spec: source address
|
|
112 |
inline TPtrC FromAddress() const;
|
|
113 |
inline void SetFromAddress(const TDesC& aFromAddress);
|
|
114 |
|
|
115 |
// from WAP spec: destination port
|
|
116 |
// 16bit width port addressing is used automatically, if
|
|
117 |
// the port value is > 255
|
|
118 |
inline void Ports(TInt& aFromPort,TInt& aToPort,TBool* aIs16Bit = NULL) const;
|
|
119 |
inline void SetPorts(TInt aFromPort, TInt aToPort,TBool aIs16BIt = EFalse);
|
|
120 |
|
|
121 |
// from WAP spec: other header support by text header only
|
|
122 |
// no idea what it is used for
|
|
123 |
inline void OtherHeader(TDes8& aOtherHeader) const;
|
|
124 |
inline void SetOtherHeader(const TDesC8& aOtherHeader);
|
|
125 |
|
|
126 |
// from GSM SMS spec
|
|
127 |
// NT: time of first CSmsMessage received
|
|
128 |
// MO: validity period
|
|
129 |
inline const TTime& Time() const;
|
|
130 |
//inline void SetTime(const TTime& aTime);
|
|
131 |
|
|
132 |
inline TTimeIntervalSeconds UTCOffset() const;
|
|
133 |
TBool SetUTCOffset(const TTimeIntervalSeconds& aUTCOffset);
|
|
134 |
|
|
135 |
// May return > 1, if the socket text headers are used
|
|
136 |
inline TInt NumConcatenatedMessages() const;
|
|
137 |
|
|
138 |
inline TInt ConcatenatedMessageReference(TBool* aIs16BIt = NULL) const;
|
|
139 |
// concerns socket text headers only
|
|
140 |
// otherwise ignored
|
|
141 |
inline void SetConcatenatedMessageReference(TInt aReference);
|
|
142 |
|
|
143 |
// what about service centre address ?
|
|
144 |
// aSmsMessageArray contains CSmsMessage objects
|
|
145 |
// aSmsBufferArray contains respective CSmsMessage objects
|
|
146 |
void EncodeConcatenatedMessagesL(RFs& aFs, CArrayPtr<CSmsMessage>& aSmsMessageArray);
|
|
147 |
|
|
148 |
void DecodeConcatenatedMessagesL(CArrayPtr<TSegmentData>& aSmsMessageArray);
|
|
149 |
|
|
150 |
// from GSM spec: Alphabet setting of outgoing datagram only
|
|
151 |
// set the alphabet on incoming datagrams in the contructor
|
|
152 |
inline TSmsDataCodingScheme::TSmsAlphabet Alphabet() const;
|
|
153 |
inline void SetAlphabet(TSmsDataCodingScheme::TSmsAlphabet aAlphabet);
|
|
154 |
|
|
155 |
void InternalizeL(RReadStream& aStream);
|
|
156 |
void ExternalizeL(RWriteStream& aStream) const;
|
|
157 |
|
|
158 |
// for 8-bit datagrams. Reads/writes iSmsBuffer from/to stream
|
|
159 |
void InternalizeBufferL(RReadStream& aStream);
|
|
160 |
void ExternalizeBufferL(RWriteStream& aStream) const;
|
|
161 |
|
|
162 |
inline TInt LogServerId() const;
|
|
163 |
inline void SetLogServerId(TInt aId);
|
|
164 |
|
|
165 |
inline TSmsStatusReportScheme Scheme() const;
|
|
166 |
inline void SetStatusReportScheme(TSmsStatusReportScheme aScheme);
|
|
167 |
|
|
168 |
CBufFlat* SmsExternalisedStream() const;
|
|
169 |
private:
|
|
170 |
CWapDatagram();
|
|
171 |
|
|
172 |
// incoming
|
|
173 |
void ConstructL(const CSmsMessage& aSms);
|
|
174 |
|
|
175 |
// outgoing
|
|
176 |
void Construct(const TDesC8& aSendBuffer);
|
|
177 |
|
|
178 |
// Set underlying CWapDatagram private member variables
|
|
179 |
// from CSmsMessage object + any common settings
|
|
180 |
void GetDatagramSettings(const CSmsMessage& aSms);
|
|
181 |
|
|
182 |
// Sets underlying WAP datagram private member variables
|
|
183 |
// from a text header short message
|
|
184 |
void GetDatagramSettingsL();
|
|
185 |
|
|
186 |
// converts from const type variable to other type
|
|
187 |
void ConvertL(const TDesC8& aNarrowChars,
|
|
188 |
CSmsBufferBase& aSmsBufferBase) const;
|
|
189 |
|
|
190 |
void ConvertL(const CSmsBufferBase& aSmsBufferBase,
|
|
191 |
HBufC8** aNarrowChars) const;
|
|
192 |
|
|
193 |
void SetSmsMessageSettingsL(CSmsMessage& aSmsMessage,
|
|
194 |
TBool aSetPorts);
|
|
195 |
private:
|
|
196 |
|
|
197 |
// WAP datagram specific settings
|
|
198 |
TSmsUserDataSettings iUserDataSettings;
|
|
199 |
TBuf<32> iToAddress;
|
|
200 |
TBuf<32> iFromAddress;
|
|
201 |
TBool i16BitPorts;
|
|
202 |
// Port numbers are initialized to (-1)
|
|
203 |
TInt iFromPort;
|
|
204 |
TInt iToPort;
|
|
205 |
TTime iTime;
|
|
206 |
TTimeIntervalSeconds iUTCOffset;
|
|
207 |
// SAR information
|
|
208 |
TBool iIsComplete;
|
|
209 |
TInt iReference;
|
|
210 |
TInt iTotalSegments;
|
|
211 |
TInt iSegmentNumber;
|
|
212 |
|
|
213 |
TBool iIsTextHeader;
|
|
214 |
// member iSegment contains a reference
|
|
215 |
// - Incoming messages: iSmsBuffer
|
|
216 |
// - Outgoing messages:
|
|
217 |
TWapTextMessage* iSegment;
|
|
218 |
// for storing text based concatenated message segment
|
|
219 |
TBuf8<KMaxSmsChars> iSmsBuffer;
|
|
220 |
// Incoming: complete wap datagram
|
|
221 |
HBufC8* iBuffer;
|
|
222 |
|
|
223 |
// Outgoing:
|
|
224 |
TPtrC8 iSendBuffer;
|
|
225 |
TPtrC8 iOtherHeader;
|
|
226 |
|
|
227 |
TInt iLogServerId;
|
|
228 |
TInt iVersionNumber;
|
|
229 |
TInt iSpare1; // spare fields
|
|
230 |
TInt iSpare2; // spare fields
|
|
231 |
TInt iSpare3; // spare fields
|
|
232 |
TSmsStatusReportScheme iScheme;
|
|
233 |
|
|
234 |
CBufFlat* iRecvbuf;
|
|
235 |
|
|
236 |
public:
|
|
237 |
static TInt LinkOffset();
|
|
238 |
private:
|
|
239 |
TSglQueLink iLink;
|
|
240 |
};
|
|
241 |
|
|
242 |
#include "wapdgrm.inl"
|
|
243 |
|
|
244 |
#endif // WAPDGRM_H__
|