epoc32/include/gsmumsg.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/gsmumsg.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/gsmumsg.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,367 @@
     1.4 -gsmumsg.h
     1.5 +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +// All rights reserved.
     1.7 +// This component and the accompanying materials are made available
     1.8 +// 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
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +//
    1.12 +// Initial Contributors:
    1.13 +// Nokia Corporation - initial contribution.
    1.14 +//
    1.15 +// Contributors:
    1.16 +//
    1.17 +// Description:
    1.18 +// This file defines the class CSmsMessage
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +
    1.23 +
    1.24 +/**
    1.25 + @file
    1.26 +*/
    1.27 +
    1.28 +#ifndef __GSMUMSG_H__
    1.29 +#define __GSMUMSG_H__
    1.30 +
    1.31 +#include <e32std.h>
    1.32 +#include <f32file.h>
    1.33 +#include <gsmuetel.h>
    1.34 +#include <charconv.h>
    1.35 +#include <gsmunmspacemobstore.h>
    1.36 +#include "gsmupdu.h"
    1.37 +
    1.38 +#include <emsinformationelement.h>
    1.39 +
    1.40 +/**
    1.41 + *  @internalComponent
    1.42 + */
    1.43 +const TUint IoctlWriteSMSBufferSize = 256;
    1.44 +const TUint KMaxMobileNameSize = 32;
    1.45 +
    1.46 +class CSmsBufferBase;
    1.47 +class CSmsCompressedBuffer;
    1.48 +class TSmsUserDataSettings;
    1.49 +class CSmsEMSBufferSegmenter;
    1.50 +class CGsmCompressionBase;
    1.51 +class CEmsUserPrompt;
    1.52 +class CEmsObjectDistribution;
    1.53 +class CSmsIEOperation;
    1.54 +class CSmsNonIEOperation;
    1.55 +
    1.56 +/**
    1.57 + *  This class is used in CSmsMessage only.
    1.58 + *  @internalComponent
    1.59 + */
    1.60 +class TGsmSmsSlotEntry
    1.61 +	{
    1.62 +public:
    1.63 +	IMPORT_C TGsmSmsSlotEntry();
    1.64 +
    1.65 +public:
    1.66 +    TInt iIndex;
    1.67 +    TBuf<KMaxMobileNameSize> iStore; 				// equivalent to RMobilePhone::TMobileName
    1.68 +	void InternalizeL(RReadStream& aStream);
    1.69 +	void ExternalizeL(RWriteStream& aStream) const;
    1.70 +    };
    1.71 +
    1.72 +
    1.73 +/**
    1.74 + *  Represents a complete SMS message.
    1.75 + *  
    1.76 + *  This class can:
    1.77 + *  
    1.78 + *  Internalise and externalise its data
    1.79 + *  
    1.80 + *  Encode/decode itself to/from one or more SMS PDU's
    1.81 + *  
    1.82 + *  SMS Message Data is stored in the CSmsBufferBase iBuffer. SMS Message Settings
    1.83 + *  are stored in the CSmsPDU iSmsPDU.
    1.84 + *  @publishedAll
    1.85 + *  @released 
    1.86 + */
    1.87 +class CSmsMessage : public CBase
    1.88 +	{
    1.89 +public:
    1.90 +/** User data optimisation flags. */
    1.91 +	enum TSmsOptimizationFlags
    1.92 +		{
    1.93 +	/**
    1.94 +	 *  The alphabet flag causes an alphabet to be chosen which preserves information
    1.95 +	 *  	in the message and makes the number of PDUs as small as possible. 
    1.96 +	 */
    1.97 +		ESmsFlagOptimizeAlphabet=0x01,
    1.98 +	/**
    1.99 +	 *  8-bit referenced concatenation.
   1.100 +	 *  
   1.101 +	 *  This causes compression to be switched off and if the message length is greater
   1.102 +	 *  	than the maximum message length, concatenation is switched on. 
   1.103 +	 */
   1.104 +		ESmsFlagOptimizeConcatenation=0x08,
   1.105 +	/**
   1.106 +	 *  16-bit referenced concatenation.
   1.107 +	 *  
   1.108 +	 *  This causes compression to be switched off and if the message length is greater
   1.109 +	 *  	than the maximum message length, concatenation is switched on. 
   1.110 +	 */
   1.111 +		ESmsFlagOptimizeConcatenation16BitReference=0x10,
   1.112 +		};
   1.113 +
   1.114 +/** Flags that indicate whether a message is stored. */
   1.115 +	enum TMobileSmsStorage
   1.116 +		{
   1.117 +	/** No storage. */
   1.118 +		ESmsNoStorage=0x00,
   1.119 +	/** SIM storage. */
   1.120 +		ESmsSIMStorage=0x04,
   1.121 +	/** Phone storage. */
   1.122 +		ESmsPhoneStorage=0x08,
   1.123 +	/** Combined storage. */
   1.124 +		ESmsCombinedStorage=0x0C
   1.125 +		};
   1.126 +
   1.127 +	enum TTimeIntervalsRepresentedInSeconds
   1.128 +		{
   1.129 +		E15MinutesRepresentedInSeconds = 15 * 60,
   1.130 +		EMaximumSeconds                = 79 * E15MinutesRepresentedInSeconds
   1.131 +		                                      // Harmonised with maximum offset allowed for
   1.132 +                                              // Service Centre Time Stamp per 23.040 V4.4 Sect 9.2.3.11.
   1.133 +		};
   1.134 +
   1.135 +
   1.136 +public:
   1.137 +	IMPORT_C static CSmsMessage* NewL(RFs& aFs, const TGsmSms& aGsmSms,CSmsBufferBase* aBuffer, TBool aIsRPError=EFalse,TBool aIsMobileTerminated=ETrue);
   1.138 +	IMPORT_C static CSmsMessage* NewL(RFs& aFs, CSmsPDU::TSmsPDUType aType,CSmsBufferBase* aBuffer,TBool aIsRPError=EFalse);
   1.139 +	IMPORT_C ~CSmsMessage();
   1.140 +
   1.141 +	inline CSmsPDU::TSmsPDUType Type() const;
   1.142 +	inline TBool IsComplete() const;
   1.143 +	inline TBool IsDecoded() const;
   1.144 +	inline TMobileSmsStorage Storage() const;
   1.145 +	inline void SetStorage(TMobileSmsStorage aStorage);
   1.146 +	inline NMobileSmsStore::TMobileSmsStoreStatus Status() const;
   1.147 +	inline void SetStatus(NMobileSmsStore::TMobileSmsStoreStatus aStatus);
   1.148 +	inline TInt LogServerId() const;
   1.149 +	inline void SetLogServerId(TInt aId);
   1.150 +	inline const TTime& Time() const;
   1.151 +	inline void SetTime(const TTime& aTime);
   1.152 +	IMPORT_C TTimeIntervalSeconds UTCOffset() const;
   1.153 +	IMPORT_C TBool SetUTCOffset(const TTimeIntervalSeconds& aTimeOffset);
   1.154 +    IMPORT_C void  SetDecodedOnSIM(TBool aOnSim);
   1.155 +    IMPORT_C TBool DecodedOnSim();
   1.156 +    IMPORT_C void  SetForwardToClient(TBool aForward);
   1.157 +    IMPORT_C TBool ForwardToClient();
   1.158 +
   1.159 +	inline CSmsPDU& SmsPDU();
   1.160 +	inline const CSmsPDU& SmsPDU() const;
   1.161 +
   1.162 +	inline TPtrC ServiceCenterAddress() const;
   1.163 +	inline void SetServiceCenterAddressL(const TDesC& aAddress);
   1.164 +	inline void ParsedServiceCenterAddress(TGsmSmsTelNumber& aParsedAddress) const;
   1.165 +	inline void SetParsedServiceCenterAddressL(const TGsmSmsTelNumber& aParsedAddress);
   1.166 +
   1.167 +	inline TPtrC ToFromAddress() const;
   1.168 +	inline void SetToFromAddressL(const TDesC& aAddress);
   1.169 +	inline void ParsedToFromAddress(TGsmSmsTelNumber& aParsedAddress) const;
   1.170 +	inline void SetParsedToFromAddressL(const TGsmSmsTelNumber& aParsedAddress);
   1.171 +
   1.172 +	IMPORT_C void InternalizeWithoutBufferL(RReadStream& aStream);
   1.173 +	IMPORT_C void ExternalizeWithoutBufferL(RWriteStream& aStream) const;
   1.174 +
   1.175 +	IMPORT_C void InternalizeL(RReadStream& aStream);
   1.176 +	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   1.177 +
   1.178 +	inline CSmsBufferBase& Buffer();
   1.179 +	inline const CSmsBufferBase& Buffer() const;
   1.180 +
   1.181 +//  Functions related to encoding/decoding the text buffer
   1.182 +	IMPORT_C TBool TextPresent() const;
   1.183 +	IMPORT_C TInt NumMessagePDUsL();
   1.184 +	IMPORT_C TInt MaxMessageLength() const;
   1.185 +	IMPORT_C TInt MessageLengthL();
   1.186 +	IMPORT_C void GetEncodingInfoL(TInt& aPdus, TInt& aUnconvertedChars,
   1.187 +                                   TInt& aDowngradedChars, TInt& aFreeUDUnitsInLastPDU);
   1.188 +
   1.189 +	IMPORT_C void UserDataSettings(TSmsUserDataSettings& aSettings) const;
   1.190 +	IMPORT_C void SetUserDataSettingsL(const TSmsUserDataSettings& aSettings);
   1.191 +	IMPORT_C void OptimizeSettingsL(TInt aOptions);
   1.192 +
   1.193 +	IMPORT_C TSmsEncoding Alternative7bitEncoding() const;
   1.194 +	IMPORT_C TInt SetAlternative7bitEncoding(TSmsEncoding aEncoding);
   1.195 +	IMPORT_C TBool IsSupportedL(const TDesC& aDes,TInt& aNumberOfUnconvertibleCharacters, TInt& aIndexOfFirstUnconvertibleCharacter);
   1.196 +	IMPORT_C TBool IsSupportedL(const TDesC& aDes, TInt& aNumberOfUnconvertibleCharacters,
   1.197 +			                    TInt& aNumberOfDowngradedCharacters,
   1.198 +			                    TInt& aNumberRequiringAlternativeEncoding,
   1.199 +			                    TInt& aIndexOfFirstUnconvertibleCharacter) const;
   1.200 +
   1.201 +	IMPORT_C void EncodeMessagePDUsL(CArrayFix<TGsmSms>& aSmsArray, TInt aReference=0);
   1.202 +	IMPORT_C void DecodeMessagePDUsL(const CArrayFix<TGsmSms>& aSmsArray);
   1.203 +	IMPORT_C const RPointerArray<const CEmsInformationElement>& GetEMSInformationElementsL()const;
   1.204 +	IMPORT_C void AddEMSInformationElementL(const CEmsInformationElement& aEmsIE);
   1.205 +	IMPORT_C RPointerArray<CEmsInformationElement>* RemoveEMSInformationElementsL(const TUint aStartPosition,const TSmsId aEmsId);
   1.206 +	IMPORT_C CEmsInformationElement* RemoveEMSInformationElementL(const TUint aStartPosition,const TSmsId aEmsId);
   1.207 +	IMPORT_C void ResetEMSL();
   1.208 +	IMPORT_C TBool EncodeIntoSinglePDUL(CArrayFix<TGsmSms>& aSmsArray);
   1.209 +	IMPORT_C void CopyEmsElementsL(CSmsMessage& aToMessage) const;
   1.210 +	IMPORT_C void AddSlotL(const TGsmSmsSlotEntry& aSlot);
   1.211 +	IMPORT_C TBool MatchSlots(const CArrayFixFlat<TGsmSmsSlotEntry>& aSlotArray);
   1.212 +// E-mail header
   1.213 + 	IMPORT_C void AddEmailHeaderL(const TDesC& aEmailHeader,const TDesC& aEmailBody);
   1.214 + 	IMPORT_C TBool IsEmailHeader() const;
   1.215 + 	IMPORT_C TBool GetEmailHeaderL(HBufC** aEmailHeader,HBufC** aEmailBody);
   1.216 + 	void InstallEmailHeaderInformationElementL(CSmsUserData& aUserData,TInt& aHeaderLength);
   1.217 + 	void InstallEmailHeaderInformationElementL(CSmsCommand& aCommand,TInt& aHeaderLength);
   1.218 +	inline void Set16BitConcatenation(TBool aIs16BitConcatenation);
   1.219 +	inline TBool Is16BitConcatenation()const;
   1.220 +	IMPORT_C void UpdateSlotsL(TDesC8& aBuf);
   1.221 +// Version information
   1.222 +	IMPORT_C TInt Version();
   1.223 +	// from this point downwards, all functions should be published internally only
   1.224 +	IMPORT_C TInt SetVersion(TInt aVersion);
   1.225 + 	IMPORT_C void InternalizeWithoutBufferAndVersionL(RReadStream& aStream);
   1.226 +	IMPORT_C void ExternalizeWithoutBufferAndVersionL(RWriteStream& aStream) const;
   1.227 + 	IMPORT_C void InternalizeBufferL(RReadStream& aStream);
   1.228 +	IMPORT_C void ExternalizeBufferL(RWriteStream& aStream) const;
   1.229 + 	IMPORT_C void InternalizeVersionL(RReadStream& aStream);
   1.230 +	IMPORT_C void ExternalizeVersionL(RWriteStream& aStream) const;
   1.231 +
   1.232 +    void* AdditionalInfo() {return iAdditionalInfo;};
   1.233 +    IMPORT_C CSmsIEOperation& GetOperationsForIEL(CSmsInformationElement::TSmsInformationElementIdentifier) const;
   1.234 +    IMPORT_C CSmsNonIEOperation& GetOperationsForNonIEL(TSmsNonIEIdentifier) const;
   1.235 +    
   1.236 +  	IMPORT_C TSmsStatusReportScheme Scheme() const;
   1.237 +	IMPORT_C void DecodePartialCompleteMessagePDUsL(const CArrayFix<TGsmSms>& aSmsArray, TBool aLastPartialCompleteMsg);
   1.238 +
   1.239 +private:
   1.240 +
   1.241 +	CSmsMessage(RFs& aFs, CSmsBufferBase* aBuffer);
   1.242 +	void ConstructL(const TGsmSms& aGsmSms, TBool aIsRPError,TBool aIsMobileTerminated);
   1.243 +	void ConstructL(CSmsPDU::TSmsPDUType aType,TBool aIsRPError);
   1.244 +
   1.245 +	void CreateControlIEOperationsClassesL();
   1.246 +	void CreateControlNonIEOperationsClassesL();
   1.247 +
   1.248 +	inline void SetIsComplete(TBool aIsComplete);
   1.249 +	inline void SetIsDecoded(TBool aIsDecoded);
   1.250 +
   1.251 +
   1.252 +	inline TBool BinaryData() const;
   1.253 +	TInt ConvertedBufferLengthL(const CSmsBufferBase& aBuffer);
   1.254 +	void EncodeBufferL(CArrayFix<TGsmSms>& aSmsArray,TInt aReference,const CSmsBufferBase& aBuffer,
   1.255 +			           TInt& aUnconvertedChars, TInt& aDowngradedChars,
   1.256 +			           TInt& aFreeUDUnitsInLastPDU, TBool aDoEncode=ETrue);
   1.257 +	void DecodeBufferL(CArrayPtr<CSmsPDU>& aSmsPDUArray,CSmsBufferBase& aBuffer);
   1.258 +	TBool EncodeIntoSinglePDUL(CArrayFix<TGsmSms>& aSmsArray, TInt& aUnconvertedChars,
   1.259 +			                   TInt& aDowngradedChars, TInt& aFreeUDUnitsInLastPDU);
   1.260 +	void PrepareCommandMessageL(void);
   1.261 +	void InstallEmsInformationElementsL(CSmsUserData& aUserData, TInt aStartPosition);
   1.262 +	void InstallEmsInformationElementsL(CSmsCommand& aCommand, TInt aStartPosition);
   1.263 +	void InstallControlInformationElementsL(CSmsUserData& aUserData, TInt aSegmentSequenceNum);
   1.264 +	void InstallControlInformationElementsL(CSmsCommand& aCommand);
   1.265 +	TBool AddEMSInformationElementsToMultiSegmentMessageL(CArrayFix<TGsmSms>& aSmsArray,CSmsEMSBufferSegmenter& aSegmenter,TUint& aCharsAdded,TBool aDoEncode,TSmsEncoding& aEncoding,RPointerArray<CEmsInformationElement>& aCorrectedFormatingIEArray,TUint& aCurEMSIEno,TUint& aBaseAddr);
   1.266 +	TBool AddEMSInformationElementsToSingleSegmentMessageL(CSmsEMSBufferSegmenter& aSegmenter,
   1.267 +			                                               TSmsEncoding aEncoding);
   1.268 +	void AddControlInformationElementsToMultiSegmentMessageL(CArrayFix<TGsmSms>& aSmsArray);
   1.269 +	void AddControlInformationElementsToMultiSegmentMessageL(TSmsInformationElementCategories::TInformationElementCategory aCategory, TBool aMandatoryInPDU, CArrayFix<TGsmSms>& aSmsArray);
   1.270 +	void AddCurrentPDUToSmsArrayL(CArrayFix<TGsmSms>& aSmsArray,TBool aDoEncode);
   1.271 +	TBool AddIEToUserDataL(CEmsInformationElement* aIe, TInt aCharsAlreadyAdded,TUint& aCharsAddedToCurrentPDU,CSmsEMSBufferSegmenter& aSeg);
   1.272 +	TInt FillPduL(CSmsEMSBufferSegmenter& aSeg, TInt aNumChars, TSmsEncoding aEncoding);
   1.273 +	TInt NumMessageEmsPDUsL();
   1.274 +	void CorrectFormattingL(TUint aCharsAddedToCurrentPDU,RPointerArray<CEmsInformationElement>& aCorrectedFormatingIEArray,TUint aBaseAddr);
   1.275 +	void CorrectFormattingInSinglePDUL();
   1.276 +	void ResetWorkingPDUL();
   1.277 +	TBool CanBeRemoved(const CEmsInformationElement& aIE, TUint aIEIndex);
   1.278 +	void AddEmsUserPromptL(const CEmsUserPrompt& aEmsIE);
   1.279 +	void AddEmsObjectDistributionL(const CEmsObjectDistribution& aObjectDistributionIE);
   1.280 +	void UpdateUserPromptAndODIElementsStartPosition();
   1.281 +	TInt AddReceivedEmsInformationElement(CEmsInformationElement* aIE);
   1.282 +	TSmsStatusReportScheme FindScheme(const CArrayPtr<CSmsPDU>& aSmsPDUArray);
   1.283 +	void InstallTPSRRInformationL(const CArrayPtr<CSmsPDU>& aSmsPDUArray, TInt aSegmentSequenceNum);
   1.284 +	void EncodingTPSRRFromSchemesIntoSinglePDUL();
   1.285 +	void DecodeOnlyTextL(CArrayPtr<CSmsPDU>& aSmsPDUArray,CSmsBufferBase& aBuffer);
   1.286 +	void AddIncompleteMessageInfoL(TInt aStartPDU, TInt aEndPDU, TBool aLastPartialCompleteMsg);
   1.287 +	void MergeAlternative7bitEncoding(TSmsEncoding aEncoding) const;
   1.288 +
   1.289 +private:
   1.290 +	enum TSmsMessageFlags
   1.291 +		{
   1.292 +		ESmsFlagIsComplete=0x01,
   1.293 +		ESmsFlagIsDecoded=0x02,
   1.294 +
   1.295 +		ESmsStorageMask=0x0C,
   1.296 +		ESmsUTCOffsetSecondGranularityMask  =0x1FFFF0,//Bits needed to represent 79 * 15 * 60 seconds
   1.297 +		ESmsUTCOffsetSignBit                =0x200000
   1.298 +		};
   1.299 +
   1.300 +	enum TTimeBitMaskOffsets
   1.301 +		{
   1.302 +		ESecondBitOffset   =  4,
   1.303 +		ESignBitOffset     = 21
   1.304 +		};
   1.305 +
   1.306 +    enum TDecodedOnSimBit
   1.307 +        {
   1.308 +        EDecodedOnSimBit = 0x80000000
   1.309 +        };
   1.310 +
   1.311 +    enum TForwardToClientBit
   1.312 +        {
   1.313 +        EForwardToClientBit = 0x40000000
   1.314 +        };
   1.315 +
   1.316 +
   1.317 +private:
   1.318 +
   1.319 +	TInt iFlags;
   1.320 +	NMobileSmsStore::TMobileSmsStoreStatus iStatus;
   1.321 +	TInt iLogServerId;
   1.322 +	TTime iTime;
   1.323 +	CSmsPDU* iSmsPDU;
   1.324 +	CSmsBufferBase* iBuffer;
   1.325 +	RFs& iFs;
   1.326 +
   1.327 +	TBool iIs16BitConcatenation;
   1.328 +	RPointerArray<CEmsInformationElement>* iInformationElementArray;
   1.329 +	CCnvCharacterSetConverter* iCharacterSetConverter;
   1.330 +
   1.331 +public:
   1.332 +	CArrayFixFlat<TGsmSmsSlotEntry> iSlotArray; ///< Array for slots
   1.333 +/**
   1.334 + *  SMS versions
   1.335 + */
   1.336 +	enum TSmsMessageVersion
   1.337 +		{
   1.338 +	/** The default value. */
   1.339 +		ESmsMessageV0, 
   1.340 +	/** Release 6 SMS Support */	
   1.341 +		ESmsMessageV1, 
   1.342 +	/** Latest version */
   1.343 +		ESmsMessageV2,
   1.344 +	/**	Incomplete Class0 Information Support	*/
   1.345 +		ESmsMessageV3,
   1.346 +		ESmsIncompleteClass0MessageV = ESmsMessageV3,
   1.347 +	/** National language 7bit encoding support */
   1.348 +		ESmsMessageV4
   1.349 +		// for all other versions the corresponding enum values would be added i.e. ESmsMessageV5, etc. 
   1.350 +		};
   1.351 +
   1.352 +protected:
   1.353 +
   1.354 +/**
   1.355 + *  iVersion is the version of CSmsMessage. This parameter will be
   1.356 + *  used to identify what iAdditionalInfo points to for that particular
   1.357 + *  version of CSmsMessage
   1.358 + */
   1.359 +	TInt iVersion;
   1.360 +
   1.361 +/**
   1.362 + *  iAdditionalInfo would point to any new added data structure.
   1.363 + *  iVersion would identify which data structure is valid for that
   1.364 + *   *  particular version of CSmsMessage 
   1.365 + */
   1.366 +	void* iAdditionalInfo;
   1.367 +	};
   1.368 +
   1.369 +#include <gsmumsg.inl>
   1.370 +
   1.371 +#endif // !defined __GSMUMSG_H__