1 gsmumsg.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 defines the class CSmsMessage |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 */ |
|
23 |
|
24 #ifndef __GSMUMSG_H__ |
|
25 #define __GSMUMSG_H__ |
|
26 |
|
27 #include <e32std.h> |
|
28 #include <f32file.h> |
|
29 #include <gsmuetel.h> |
|
30 #include <charconv.h> |
|
31 #include <gsmunmspacemobstore.h> |
|
32 #include "gsmupdu.h" |
|
33 |
|
34 #include <emsinformationelement.h> |
|
35 |
|
36 /** |
|
37 * @internalComponent |
|
38 */ |
|
39 const TUint IoctlWriteSMSBufferSize = 256; |
|
40 const TUint KMaxMobileNameSize = 32; |
|
41 |
|
42 class CSmsBufferBase; |
|
43 class CSmsCompressedBuffer; |
|
44 class TSmsUserDataSettings; |
|
45 class CSmsEMSBufferSegmenter; |
|
46 class CGsmCompressionBase; |
|
47 class CEmsUserPrompt; |
|
48 class CEmsObjectDistribution; |
|
49 class CSmsIEOperation; |
|
50 class CSmsNonIEOperation; |
|
51 |
|
52 /** |
|
53 * This class is used in CSmsMessage only. |
|
54 * @internalComponent |
|
55 */ |
|
56 class TGsmSmsSlotEntry |
|
57 { |
|
58 public: |
|
59 IMPORT_C TGsmSmsSlotEntry(); |
|
60 |
|
61 public: |
|
62 TInt iIndex; |
|
63 TBuf<KMaxMobileNameSize> iStore; // equivalent to RMobilePhone::TMobileName |
|
64 void InternalizeL(RReadStream& aStream); |
|
65 void ExternalizeL(RWriteStream& aStream) const; |
|
66 }; |
|
67 |
|
68 |
|
69 /** |
|
70 * Represents a complete SMS message. |
|
71 * |
|
72 * This class can: |
|
73 * |
|
74 * Internalise and externalise its data |
|
75 * |
|
76 * Encode/decode itself to/from one or more SMS PDU's |
|
77 * |
|
78 * SMS Message Data is stored in the CSmsBufferBase iBuffer. SMS Message Settings |
|
79 * are stored in the CSmsPDU iSmsPDU. |
|
80 * @publishedAll |
|
81 * @released |
|
82 */ |
|
83 class CSmsMessage : public CBase |
|
84 { |
|
85 public: |
|
86 /** User data optimisation flags. */ |
|
87 enum TSmsOptimizationFlags |
|
88 { |
|
89 /** |
|
90 * The alphabet flag causes an alphabet to be chosen which preserves information |
|
91 * in the message and makes the number of PDUs as small as possible. |
|
92 */ |
|
93 ESmsFlagOptimizeAlphabet=0x01, |
|
94 /** |
|
95 * 8-bit referenced concatenation. |
|
96 * |
|
97 * This causes compression to be switched off and if the message length is greater |
|
98 * than the maximum message length, concatenation is switched on. |
|
99 */ |
|
100 ESmsFlagOptimizeConcatenation=0x08, |
|
101 /** |
|
102 * 16-bit referenced concatenation. |
|
103 * |
|
104 * This causes compression to be switched off and if the message length is greater |
|
105 * than the maximum message length, concatenation is switched on. |
|
106 */ |
|
107 ESmsFlagOptimizeConcatenation16BitReference=0x10, |
|
108 }; |
|
109 |
|
110 /** Flags that indicate whether a message is stored. */ |
|
111 enum TMobileSmsStorage |
|
112 { |
|
113 /** No storage. */ |
|
114 ESmsNoStorage=0x00, |
|
115 /** SIM storage. */ |
|
116 ESmsSIMStorage=0x04, |
|
117 /** Phone storage. */ |
|
118 ESmsPhoneStorage=0x08, |
|
119 /** Combined storage. */ |
|
120 ESmsCombinedStorage=0x0C |
|
121 }; |
|
122 |
|
123 enum TTimeIntervalsRepresentedInSeconds |
|
124 { |
|
125 E15MinutesRepresentedInSeconds = 15 * 60, |
|
126 EMaximumSeconds = 79 * E15MinutesRepresentedInSeconds |
|
127 // Harmonised with maximum offset allowed for |
|
128 // Service Centre Time Stamp per 23.040 V4.4 Sect 9.2.3.11. |
|
129 }; |
|
130 |
|
131 |
|
132 public: |
|
133 IMPORT_C static CSmsMessage* NewL(RFs& aFs, const TGsmSms& aGsmSms,CSmsBufferBase* aBuffer, TBool aIsRPError=EFalse,TBool aIsMobileTerminated=ETrue); |
|
134 IMPORT_C static CSmsMessage* NewL(RFs& aFs, CSmsPDU::TSmsPDUType aType,CSmsBufferBase* aBuffer,TBool aIsRPError=EFalse); |
|
135 IMPORT_C ~CSmsMessage(); |
|
136 |
|
137 inline CSmsPDU::TSmsPDUType Type() const; |
|
138 inline TBool IsComplete() const; |
|
139 inline TBool IsDecoded() const; |
|
140 inline TMobileSmsStorage Storage() const; |
|
141 inline void SetStorage(TMobileSmsStorage aStorage); |
|
142 inline NMobileSmsStore::TMobileSmsStoreStatus Status() const; |
|
143 inline void SetStatus(NMobileSmsStore::TMobileSmsStoreStatus aStatus); |
|
144 inline TInt LogServerId() const; |
|
145 inline void SetLogServerId(TInt aId); |
|
146 inline const TTime& Time() const; |
|
147 inline void SetTime(const TTime& aTime); |
|
148 IMPORT_C TTimeIntervalSeconds UTCOffset() const; |
|
149 IMPORT_C TBool SetUTCOffset(const TTimeIntervalSeconds& aTimeOffset); |
|
150 IMPORT_C void SetDecodedOnSIM(TBool aOnSim); |
|
151 IMPORT_C TBool DecodedOnSim(); |
|
152 IMPORT_C void SetForwardToClient(TBool aForward); |
|
153 IMPORT_C TBool ForwardToClient(); |
|
154 |
|
155 inline CSmsPDU& SmsPDU(); |
|
156 inline const CSmsPDU& SmsPDU() const; |
|
157 |
|
158 inline TPtrC ServiceCenterAddress() const; |
|
159 inline void SetServiceCenterAddressL(const TDesC& aAddress); |
|
160 inline void ParsedServiceCenterAddress(TGsmSmsTelNumber& aParsedAddress) const; |
|
161 inline void SetParsedServiceCenterAddressL(const TGsmSmsTelNumber& aParsedAddress); |
|
162 |
|
163 inline TPtrC ToFromAddress() const; |
|
164 inline void SetToFromAddressL(const TDesC& aAddress); |
|
165 inline void ParsedToFromAddress(TGsmSmsTelNumber& aParsedAddress) const; |
|
166 inline void SetParsedToFromAddressL(const TGsmSmsTelNumber& aParsedAddress); |
|
167 |
|
168 IMPORT_C void InternalizeWithoutBufferL(RReadStream& aStream); |
|
169 IMPORT_C void ExternalizeWithoutBufferL(RWriteStream& aStream) const; |
|
170 |
|
171 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
172 IMPORT_C void ExternalizeL(RWriteStream& aStream) const; |
|
173 |
|
174 inline CSmsBufferBase& Buffer(); |
|
175 inline const CSmsBufferBase& Buffer() const; |
|
176 |
|
177 // Functions related to encoding/decoding the text buffer |
|
178 IMPORT_C TBool TextPresent() const; |
|
179 IMPORT_C TInt NumMessagePDUsL(); |
|
180 IMPORT_C TInt MaxMessageLength() const; |
|
181 IMPORT_C TInt MessageLengthL(); |
|
182 IMPORT_C void GetEncodingInfoL(TInt& aPdus, TInt& aUnconvertedChars, |
|
183 TInt& aDowngradedChars, TInt& aFreeUDUnitsInLastPDU); |
|
184 |
|
185 IMPORT_C void UserDataSettings(TSmsUserDataSettings& aSettings) const; |
|
186 IMPORT_C void SetUserDataSettingsL(const TSmsUserDataSettings& aSettings); |
|
187 IMPORT_C void OptimizeSettingsL(TInt aOptions); |
|
188 |
|
189 IMPORT_C TSmsEncoding Alternative7bitEncoding() const; |
|
190 IMPORT_C TInt SetAlternative7bitEncoding(TSmsEncoding aEncoding); |
|
191 IMPORT_C TBool IsSupportedL(const TDesC& aDes,TInt& aNumberOfUnconvertibleCharacters, TInt& aIndexOfFirstUnconvertibleCharacter); |
|
192 IMPORT_C TBool IsSupportedL(const TDesC& aDes, TInt& aNumberOfUnconvertibleCharacters, |
|
193 TInt& aNumberOfDowngradedCharacters, |
|
194 TInt& aNumberRequiringAlternativeEncoding, |
|
195 TInt& aIndexOfFirstUnconvertibleCharacter) const; |
|
196 |
|
197 IMPORT_C void EncodeMessagePDUsL(CArrayFix<TGsmSms>& aSmsArray, TInt aReference=0); |
|
198 IMPORT_C void DecodeMessagePDUsL(const CArrayFix<TGsmSms>& aSmsArray); |
|
199 IMPORT_C const RPointerArray<const CEmsInformationElement>& GetEMSInformationElementsL()const; |
|
200 IMPORT_C void AddEMSInformationElementL(const CEmsInformationElement& aEmsIE); |
|
201 IMPORT_C RPointerArray<CEmsInformationElement>* RemoveEMSInformationElementsL(const TUint aStartPosition,const TSmsId aEmsId); |
|
202 IMPORT_C CEmsInformationElement* RemoveEMSInformationElementL(const TUint aStartPosition,const TSmsId aEmsId); |
|
203 IMPORT_C void ResetEMSL(); |
|
204 IMPORT_C TBool EncodeIntoSinglePDUL(CArrayFix<TGsmSms>& aSmsArray); |
|
205 IMPORT_C void CopyEmsElementsL(CSmsMessage& aToMessage) const; |
|
206 IMPORT_C void AddSlotL(const TGsmSmsSlotEntry& aSlot); |
|
207 IMPORT_C TBool MatchSlots(const CArrayFixFlat<TGsmSmsSlotEntry>& aSlotArray); |
|
208 // E-mail header |
|
209 IMPORT_C void AddEmailHeaderL(const TDesC& aEmailHeader,const TDesC& aEmailBody); |
|
210 IMPORT_C TBool IsEmailHeader() const; |
|
211 IMPORT_C TBool GetEmailHeaderL(HBufC** aEmailHeader,HBufC** aEmailBody); |
|
212 void InstallEmailHeaderInformationElementL(CSmsUserData& aUserData,TInt& aHeaderLength); |
|
213 void InstallEmailHeaderInformationElementL(CSmsCommand& aCommand,TInt& aHeaderLength); |
|
214 inline void Set16BitConcatenation(TBool aIs16BitConcatenation); |
|
215 inline TBool Is16BitConcatenation()const; |
|
216 IMPORT_C void UpdateSlotsL(TDesC8& aBuf); |
|
217 // Version information |
|
218 IMPORT_C TInt Version(); |
|
219 // from this point downwards, all functions should be published internally only |
|
220 IMPORT_C TInt SetVersion(TInt aVersion); |
|
221 IMPORT_C void InternalizeWithoutBufferAndVersionL(RReadStream& aStream); |
|
222 IMPORT_C void ExternalizeWithoutBufferAndVersionL(RWriteStream& aStream) const; |
|
223 IMPORT_C void InternalizeBufferL(RReadStream& aStream); |
|
224 IMPORT_C void ExternalizeBufferL(RWriteStream& aStream) const; |
|
225 IMPORT_C void InternalizeVersionL(RReadStream& aStream); |
|
226 IMPORT_C void ExternalizeVersionL(RWriteStream& aStream) const; |
|
227 |
|
228 void* AdditionalInfo() {return iAdditionalInfo;}; |
|
229 IMPORT_C CSmsIEOperation& GetOperationsForIEL(CSmsInformationElement::TSmsInformationElementIdentifier) const; |
|
230 IMPORT_C CSmsNonIEOperation& GetOperationsForNonIEL(TSmsNonIEIdentifier) const; |
|
231 |
|
232 IMPORT_C TSmsStatusReportScheme Scheme() const; |
|
233 IMPORT_C void DecodePartialCompleteMessagePDUsL(const CArrayFix<TGsmSms>& aSmsArray, TBool aLastPartialCompleteMsg); |
|
234 |
|
235 private: |
|
236 |
|
237 CSmsMessage(RFs& aFs, CSmsBufferBase* aBuffer); |
|
238 void ConstructL(const TGsmSms& aGsmSms, TBool aIsRPError,TBool aIsMobileTerminated); |
|
239 void ConstructL(CSmsPDU::TSmsPDUType aType,TBool aIsRPError); |
|
240 |
|
241 void CreateControlIEOperationsClassesL(); |
|
242 void CreateControlNonIEOperationsClassesL(); |
|
243 |
|
244 inline void SetIsComplete(TBool aIsComplete); |
|
245 inline void SetIsDecoded(TBool aIsDecoded); |
|
246 |
|
247 |
|
248 inline TBool BinaryData() const; |
|
249 TInt ConvertedBufferLengthL(const CSmsBufferBase& aBuffer); |
|
250 void EncodeBufferL(CArrayFix<TGsmSms>& aSmsArray,TInt aReference,const CSmsBufferBase& aBuffer, |
|
251 TInt& aUnconvertedChars, TInt& aDowngradedChars, |
|
252 TInt& aFreeUDUnitsInLastPDU, TBool aDoEncode=ETrue); |
|
253 void DecodeBufferL(CArrayPtr<CSmsPDU>& aSmsPDUArray,CSmsBufferBase& aBuffer); |
|
254 TBool EncodeIntoSinglePDUL(CArrayFix<TGsmSms>& aSmsArray, TInt& aUnconvertedChars, |
|
255 TInt& aDowngradedChars, TInt& aFreeUDUnitsInLastPDU); |
|
256 void PrepareCommandMessageL(void); |
|
257 void InstallEmsInformationElementsL(CSmsUserData& aUserData, TInt aStartPosition); |
|
258 void InstallEmsInformationElementsL(CSmsCommand& aCommand, TInt aStartPosition); |
|
259 void InstallControlInformationElementsL(CSmsUserData& aUserData, TInt aSegmentSequenceNum); |
|
260 void InstallControlInformationElementsL(CSmsCommand& aCommand); |
|
261 TBool AddEMSInformationElementsToMultiSegmentMessageL(CArrayFix<TGsmSms>& aSmsArray,CSmsEMSBufferSegmenter& aSegmenter,TUint& aCharsAdded,TBool aDoEncode,TSmsEncoding& aEncoding,RPointerArray<CEmsInformationElement>& aCorrectedFormatingIEArray,TUint& aCurEMSIEno,TUint& aBaseAddr); |
|
262 TBool AddEMSInformationElementsToSingleSegmentMessageL(CSmsEMSBufferSegmenter& aSegmenter, |
|
263 TSmsEncoding aEncoding); |
|
264 void AddControlInformationElementsToMultiSegmentMessageL(CArrayFix<TGsmSms>& aSmsArray); |
|
265 void AddControlInformationElementsToMultiSegmentMessageL(TSmsInformationElementCategories::TInformationElementCategory aCategory, TBool aMandatoryInPDU, CArrayFix<TGsmSms>& aSmsArray); |
|
266 void AddCurrentPDUToSmsArrayL(CArrayFix<TGsmSms>& aSmsArray,TBool aDoEncode); |
|
267 TBool AddIEToUserDataL(CEmsInformationElement* aIe, TInt aCharsAlreadyAdded,TUint& aCharsAddedToCurrentPDU,CSmsEMSBufferSegmenter& aSeg); |
|
268 TInt FillPduL(CSmsEMSBufferSegmenter& aSeg, TInt aNumChars, TSmsEncoding aEncoding); |
|
269 TInt NumMessageEmsPDUsL(); |
|
270 void CorrectFormattingL(TUint aCharsAddedToCurrentPDU,RPointerArray<CEmsInformationElement>& aCorrectedFormatingIEArray,TUint aBaseAddr); |
|
271 void CorrectFormattingInSinglePDUL(); |
|
272 void ResetWorkingPDUL(); |
|
273 TBool CanBeRemoved(const CEmsInformationElement& aIE, TUint aIEIndex); |
|
274 void AddEmsUserPromptL(const CEmsUserPrompt& aEmsIE); |
|
275 void AddEmsObjectDistributionL(const CEmsObjectDistribution& aObjectDistributionIE); |
|
276 void UpdateUserPromptAndODIElementsStartPosition(); |
|
277 TInt AddReceivedEmsInformationElement(CEmsInformationElement* aIE); |
|
278 TSmsStatusReportScheme FindScheme(const CArrayPtr<CSmsPDU>& aSmsPDUArray); |
|
279 void InstallTPSRRInformationL(const CArrayPtr<CSmsPDU>& aSmsPDUArray, TInt aSegmentSequenceNum); |
|
280 void EncodingTPSRRFromSchemesIntoSinglePDUL(); |
|
281 void DecodeOnlyTextL(CArrayPtr<CSmsPDU>& aSmsPDUArray,CSmsBufferBase& aBuffer); |
|
282 void AddIncompleteMessageInfoL(TInt aStartPDU, TInt aEndPDU, TBool aLastPartialCompleteMsg); |
|
283 void MergeAlternative7bitEncoding(TSmsEncoding aEncoding) const; |
|
284 |
|
285 private: |
|
286 enum TSmsMessageFlags |
|
287 { |
|
288 ESmsFlagIsComplete=0x01, |
|
289 ESmsFlagIsDecoded=0x02, |
|
290 |
|
291 ESmsStorageMask=0x0C, |
|
292 ESmsUTCOffsetSecondGranularityMask =0x1FFFF0,//Bits needed to represent 79 * 15 * 60 seconds |
|
293 ESmsUTCOffsetSignBit =0x200000 |
|
294 }; |
|
295 |
|
296 enum TTimeBitMaskOffsets |
|
297 { |
|
298 ESecondBitOffset = 4, |
|
299 ESignBitOffset = 21 |
|
300 }; |
|
301 |
|
302 enum TDecodedOnSimBit |
|
303 { |
|
304 EDecodedOnSimBit = 0x80000000 |
|
305 }; |
|
306 |
|
307 enum TForwardToClientBit |
|
308 { |
|
309 EForwardToClientBit = 0x40000000 |
|
310 }; |
|
311 |
|
312 |
|
313 private: |
|
314 |
|
315 TInt iFlags; |
|
316 NMobileSmsStore::TMobileSmsStoreStatus iStatus; |
|
317 TInt iLogServerId; |
|
318 TTime iTime; |
|
319 CSmsPDU* iSmsPDU; |
|
320 CSmsBufferBase* iBuffer; |
|
321 RFs& iFs; |
|
322 |
|
323 TBool iIs16BitConcatenation; |
|
324 RPointerArray<CEmsInformationElement>* iInformationElementArray; |
|
325 CCnvCharacterSetConverter* iCharacterSetConverter; |
|
326 |
|
327 public: |
|
328 CArrayFixFlat<TGsmSmsSlotEntry> iSlotArray; ///< Array for slots |
|
329 /** |
|
330 * SMS versions |
|
331 */ |
|
332 enum TSmsMessageVersion |
|
333 { |
|
334 /** The default value. */ |
|
335 ESmsMessageV0, |
|
336 /** Release 6 SMS Support */ |
|
337 ESmsMessageV1, |
|
338 /** Latest version */ |
|
339 ESmsMessageV2, |
|
340 /** Incomplete Class0 Information Support */ |
|
341 ESmsMessageV3, |
|
342 ESmsIncompleteClass0MessageV = ESmsMessageV3, |
|
343 /** National language 7bit encoding support */ |
|
344 ESmsMessageV4 |
|
345 // for all other versions the corresponding enum values would be added i.e. ESmsMessageV5, etc. |
|
346 }; |
|
347 |
|
348 protected: |
|
349 |
|
350 /** |
|
351 * iVersion is the version of CSmsMessage. This parameter will be |
|
352 * used to identify what iAdditionalInfo points to for that particular |
|
353 * version of CSmsMessage |
|
354 */ |
|
355 TInt iVersion; |
|
356 |
|
357 /** |
|
358 * iAdditionalInfo would point to any new added data structure. |
|
359 * iVersion would identify which data structure is valid for that |
|
360 * * particular version of CSmsMessage |
|
361 */ |
|
362 void* iAdditionalInfo; |
|
363 }; |
|
364 |
|
365 #include <gsmumsg.inl> |
|
366 |
|
367 #endif // !defined __GSMUMSG_H__ |