epoc32/include/emsinformationelement.h
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
       
     1 /*
       
     2 * Copyright (c) 2009 Sony Ericsson Mobile Communications AB
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * 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
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Sony Ericsson Mobile Communications AB - initial contribution.
       
    11 * Nokia Corporation - additional changes.
       
    12 * 
       
    13 * Contributors:
       
    14 * 
       
    15 * Description:
       
    16 * Provides the base class for CEmsInformationElements and a factory with which
       
    17 * to create Ems Elements.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 /**
       
    23  *  @file
       
    24  *  
       
    25  *  Defines  CEmsInformationElement  class
       
    26  */
       
    27 
       
    28 
       
    29 #ifndef __EMSInformationElement__
       
    30 #define __EMSInformationElement__
       
    31 
       
    32 #include <gsmuelem.h>
       
    33 
       
    34 /**
       
    35  *  @internalComponent
       
    36  */
       
    37 #define SHIFT_BOOL_LEFT(a,x) ((TUint8) ((a ? 1 : 0) <<x))
       
    38 /**
       
    39  *  @internalComponent
       
    40  */
       
    41 #define BOOL_AT(a,x)		 ((TBool) ((a >> x) & 0x01))
       
    42 
       
    43 /**
       
    44  *  @internalComponent
       
    45  */
       
    46 #define HI_BYTE(a)	(TUint8) ((a&0xFF00) >> 8)
       
    47 /**
       
    48  *  @internalComponent
       
    49  */
       
    50 #define LO_BYTE(a)	(TUint8) (a&0x00FF)
       
    51 
       
    52 
       
    53 
       
    54 class CEmsInformationElement : public CSmsInformationElement
       
    55 /**
       
    56  *  Abstract base class used to allow ems objects to be passed around, and to be
       
    57  *  handled as a generic group of objects.
       
    58  *  @internalComponent
       
    59  */
       
    60 	{
       
    61 	friend class CEmsFactory;
       
    62 
       
    63 public:
       
    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;
       
    68 
       
    69 	// Length of the generated encoded information element, INCLUDING
       
    70 	// the IE header
       
    71 	IMPORT_C TInt Length() const;
       
    72 
       
    73 public:
       
    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);
       
    78 
       
    79 	// Serialisation operations
       
    80 	void ExternalizeL(RWriteStream& aStream) const;
       
    81 	static CEmsInformationElement* InternalizeL(RReadStream& aStream);
       
    82 
       
    83 protected:
       
    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);
       
    89 
       
    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;
       
    97 
       
    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;
       
   102 
       
   103 protected:
       
   104 	// The start position in relation to the entire text
       
   105 	TUint iStartPosition;
       
   106 
       
   107 	// Length of the encoded body, EXCLUDING the start position and IE header
       
   108 	TUint iEncodedBodyLength;
       
   109 
       
   110 private:
       
   111 	// boolean to indicate if the start position needs to be encoded in the
       
   112 	// pdu
       
   113 	const TBool iStartPosEncoded;
       
   114 
       
   115 protected:
       
   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;
       
   124 	};
       
   125 
       
   126 
       
   127 class CEmsFactory : public CBase
       
   128 /**
       
   129  *  Factory class used to create an EMS object from the given data.
       
   130  *  @internalComponent
       
   131  */
       
   132 	{
       
   133 public:
       
   134 	static TBool Supported(TSmsId aId);
       
   135 
       
   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);
       
   141 	};
       
   142 
       
   143 #include <emsinformationelement.inl>
       
   144 #endif // __EMSInformationElement__