2 * Copyright (c) 2009 Sony Ericsson Mobile Communications AB
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Sony Ericsson Mobile Communications AB - initial contribution.
11 * Nokia Corporation - additional changes.
16 * Provides the base class for CEmsInformationElements and a factory with which
17 * to create Ems Elements.
25 * Defines CEmsInformationElement class
29 #ifndef __EMSInformationElement__
30 #define __EMSInformationElement__
37 #define SHIFT_BOOL_LEFT(a,x) ((TUint8) ((a ? 1 : 0) <<x))
41 #define BOOL_AT(a,x) ((TBool) ((a >> x) & 0x01))
46 #define HI_BYTE(a) (TUint8) ((a&0xFF00) >> 8)
50 #define LO_BYTE(a) (TUint8) (a&0x00FF)
54 class CEmsInformationElement : public CSmsInformationElement
56 * Abstract base class used to allow ems objects to be passed around, and to be
57 * handled as a generic group of objects.
61 friend class CEmsFactory;
64 // Externally available and exported functions
65 IMPORT_C virtual CEmsInformationElement* DuplicateL() const = 0;
66 IMPORT_C void SetStartPosition(TUint aValue);
67 IMPORT_C TUint StartPosition() const;
69 // Length of the generated encoded information element, INCLUDING
71 IMPORT_C TInt Length() const;
74 // Encodes the CSmsInformationElement part and decodes to from an
75 // external CSmsInformationElement.
76 IMPORT_C void EncodeInformationElementL();
77 static CEmsInformationElement* DecodeInformationElementL(const CSmsInformationElement& aSmsIe);
79 // Serialisation operations
80 void ExternalizeL(RWriteStream& aStream) const;
81 static CEmsInformationElement* InternalizeL(RReadStream& aStream);
84 // constructor which takes an ems id and a boolean indicating whether or
85 // not the start position is encoded in the pdu (true by default,
86 // but needs to false for UserPrompt
87 inline CEmsInformationElement(TSmsId aId, TBool aStartPosEncoded = ETrue);
88 void CopyL(const CEmsInformationElement& aSrc);
90 // Encodes and decodes the body of an information element, EXCLUDING the
91 // start position. The boolean flag indicates whether or not it is for
92 // serialisation or PDU transmission. This impacts in particular the
93 // EmsFormatIE object, which stores the length in 16-bits if serialised
94 // but only 8-bits when encoded.
95 virtual void EncodeBodyL(TPtr8 aPtr, TBool aIsForSerialisation) const = 0;
96 virtual void DecodeBodyL(const TPtrC8 aPtr, TBool aIsFromSerialisation) = 0;
98 // This virtual function returns the length of object body when it is to
99 // be serialised - note that this is generally the same as the encoded
100 // body length, except for the Format object
101 virtual TInt SerialisedBodyLength() const;
104 // The start position in relation to the entire text
105 TUint iStartPosition;
107 // Length of the encoded body, EXCLUDING the start position and IE header
108 TUint iEncodedBodyLength;
111 // boolean to indicate if the start position needs to be encoded in the
113 const TBool iStartPosEncoded;
116 // the scope of the following functions of CSmsInformationElement have
117 // been downgraded to protected to prevent them from being used when
118 // accessed as an EMS element. The point of transition from being
119 // a CEmsInformationElement to a CSmsInformation element should occur
120 // in the EncodeInformationElement function
121 using CSmsInformationElement::Data;
122 using CSmsInformationElement::EncodeL;
123 using CSmsInformationElement::DecodeL;
127 class CEmsFactory : public CBase
129 * Factory class used to create an EMS object from the given data.
134 static TBool Supported(TSmsId aId);
136 // Creates an information element with a given ID
137 static CEmsInformationElement* CreateIeL(TSmsId aId);
138 static void InternalizeL(RPointerArray<CEmsInformationElement>& aObjectStore, RReadStream& aStream);
139 static void ExternalizeL(RPointerArray<CEmsInformationElement>& aObjectStore, RWriteStream& aStream);
140 static CEmsInformationElement* CreateReceivedEmsIEL(const CSmsInformationElement& aIE,TInt aBaseAddr);
143 #include <emsinformationelement.inl>
144 #endif // __EMSInformationElement__