|
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 // TODO: to be removed ? |
|
137 inline TInt NumConcatenatedMessages() const; |
|
138 |
|
139 inline TInt ConcatenatedMessageReference(TBool* aIs16BIt = NULL) const; |
|
140 // concerns socket text headers only |
|
141 // otherwise ignored |
|
142 inline void SetConcatenatedMessageReference(TInt aReference); |
|
143 |
|
144 // what about service centre address ? |
|
145 // aSmsMessageArray contains CSmsMessage objects |
|
146 // aSmsBufferArray contains respective CSmsMessage objects |
|
147 void EncodeConcatenatedMessagesL(RFs& aFs, CArrayPtr<CSmsMessage>& aSmsMessageArray); |
|
148 |
|
149 void DecodeConcatenatedMessagesL(CArrayPtr<TSegmentData>& aSmsMessageArray); |
|
150 |
|
151 // from GSM spec: Alphabet setting of outgoing datagram only |
|
152 // set the alphabet on incoming datagrams in the contructor |
|
153 inline TSmsDataCodingScheme::TSmsAlphabet Alphabet() const; |
|
154 inline void SetAlphabet(TSmsDataCodingScheme::TSmsAlphabet aAlphabet); |
|
155 |
|
156 void InternalizeL(RReadStream& aStream); |
|
157 void ExternalizeL(RWriteStream& aStream) const; |
|
158 |
|
159 // for 8-bit datagrams. Reads/writes iSmsBuffer from/to stream |
|
160 void InternalizeBufferL(RReadStream& aStream); |
|
161 void ExternalizeBufferL(RWriteStream& aStream) const; |
|
162 |
|
163 inline TInt LogServerId() const; |
|
164 inline void SetLogServerId(TInt aId); |
|
165 |
|
166 inline TSmsStatusReportScheme Scheme() const; |
|
167 inline void SetStatusReportScheme(TSmsStatusReportScheme aScheme); |
|
168 |
|
169 CBufFlat* SmsExternalisedStream() const; |
|
170 private: |
|
171 CWapDatagram(); |
|
172 |
|
173 // incoming |
|
174 void ConstructL(const CSmsMessage& aSms); |
|
175 |
|
176 // outgoing |
|
177 void Construct(const TDesC8& aSendBuffer); |
|
178 |
|
179 // Set underlying CWapDatagram private member variables |
|
180 // from CSmsMessage object + any common settings |
|
181 void GetDatagramSettings(const CSmsMessage& aSms); |
|
182 |
|
183 // Sets underlying WAP datagram private member variables |
|
184 // from a text header short message |
|
185 void GetDatagramSettingsL(); |
|
186 |
|
187 // converts from const type variable to other type |
|
188 void ConvertL(const TDesC8& aNarrowChars, |
|
189 CSmsBufferBase& aSmsBufferBase) const; |
|
190 |
|
191 void ConvertL(const CSmsBufferBase& aSmsBufferBase, |
|
192 HBufC8** aNarrowChars) const; |
|
193 |
|
194 void SetSmsMessageSettingsL(CSmsMessage& aSmsMessage, |
|
195 TBool aSetPorts); |
|
196 private: |
|
197 |
|
198 // WAP datagram specific settings |
|
199 TSmsUserDataSettings iUserDataSettings; |
|
200 TBuf<32> iToAddress; |
|
201 TBuf<32> iFromAddress; |
|
202 TBool i16BitPorts; |
|
203 // Port numbers are initialized to (-1) |
|
204 TInt iFromPort; |
|
205 TInt iToPort; |
|
206 TTime iTime; |
|
207 TTimeIntervalSeconds iUTCOffset; |
|
208 // SAR information |
|
209 TBool iIsComplete; |
|
210 TInt iReference; |
|
211 TInt iTotalSegments; |
|
212 TInt iSegmentNumber; |
|
213 |
|
214 TBool iIsTextHeader; |
|
215 // member iSegment contains a reference |
|
216 // - Incoming messages: iSmsBuffer |
|
217 // - Outgoing messages: |
|
218 TWapTextMessage* iSegment; |
|
219 // for storing text based concatenated message segment |
|
220 TBuf8<KMaxSmsChars> iSmsBuffer; |
|
221 // Incoming: complete wap datagram |
|
222 HBufC8* iBuffer; |
|
223 |
|
224 // Outgoing: |
|
225 TPtrC8 iSendBuffer; |
|
226 TPtrC8 iOtherHeader; |
|
227 |
|
228 TInt iLogServerId; |
|
229 TInt iVersionNumber; |
|
230 TInt iSpare1; // spare fields |
|
231 TInt iSpare2; // spare fields |
|
232 TInt iSpare3; // spare fields |
|
233 TSmsStatusReportScheme iScheme; |
|
234 |
|
235 CBufFlat* iRecvbuf; |
|
236 |
|
237 public: |
|
238 static TInt LinkOffset(); |
|
239 private: |
|
240 TSglQueLink iLink; |
|
241 }; |
|
242 |
|
243 #include "wapdgrm.inl" |
|
244 |
|
245 #endif // WAPDGRM_H__ |