epoc32/include/emsinformationelement.h
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/emsinformationelement.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,144 @@
     1.4 +/*
     1.5 +* Copyright (c) 2009 Sony Ericsson Mobile Communications AB
     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 +* Sony Ericsson Mobile Communications AB - initial contribution.
    1.14 +* Nokia Corporation - additional changes.
    1.15 +* 
    1.16 +* Contributors:
    1.17 +* 
    1.18 +* Description:
    1.19 +* Provides the base class for CEmsInformationElements and a factory with which
    1.20 +* to create Ems Elements.
    1.21 +*
    1.22 +*/
    1.23 +
    1.24 +
    1.25 +/**
    1.26 + *  @file
    1.27 + *  
    1.28 + *  Defines  CEmsInformationElement  class
    1.29 + */
    1.30 +
    1.31 +
    1.32 +#ifndef __EMSInformationElement__
    1.33 +#define __EMSInformationElement__
    1.34 +
    1.35 +#include <gsmuelem.h>
    1.36 +
    1.37 +/**
    1.38 + *  @internalComponent
    1.39 + */
    1.40 +#define SHIFT_BOOL_LEFT(a,x) ((TUint8) ((a ? 1 : 0) <<x))
    1.41 +/**
    1.42 + *  @internalComponent
    1.43 + */
    1.44 +#define BOOL_AT(a,x)		 ((TBool) ((a >> x) & 0x01))
    1.45 +
    1.46 +/**
    1.47 + *  @internalComponent
    1.48 + */
    1.49 +#define HI_BYTE(a)	(TUint8) ((a&0xFF00) >> 8)
    1.50 +/**
    1.51 + *  @internalComponent
    1.52 + */
    1.53 +#define LO_BYTE(a)	(TUint8) (a&0x00FF)
    1.54 +
    1.55 +
    1.56 +
    1.57 +class CEmsInformationElement : public CSmsInformationElement
    1.58 +/**
    1.59 + *  Abstract base class used to allow ems objects to be passed around, and to be
    1.60 + *  handled as a generic group of objects.
    1.61 + *  @internalComponent
    1.62 + */
    1.63 +	{
    1.64 +	friend class CEmsFactory;
    1.65 +
    1.66 +public:
    1.67 +	// Externally available and exported functions
    1.68 +	IMPORT_C virtual CEmsInformationElement* DuplicateL() const = 0;
    1.69 +	IMPORT_C void SetStartPosition(TUint aValue);
    1.70 +	IMPORT_C TUint StartPosition() const;
    1.71 +
    1.72 +	// Length of the generated encoded information element, INCLUDING
    1.73 +	// the IE header
    1.74 +	IMPORT_C TInt Length() const;
    1.75 +
    1.76 +public:
    1.77 +	// Encodes the CSmsInformationElement part and decodes to from an
    1.78 +	// external CSmsInformationElement.
    1.79 +	IMPORT_C void EncodeInformationElementL();
    1.80 +	static CEmsInformationElement* DecodeInformationElementL(const CSmsInformationElement& aSmsIe);
    1.81 +
    1.82 +	// Serialisation operations
    1.83 +	void ExternalizeL(RWriteStream& aStream) const;
    1.84 +	static CEmsInformationElement* InternalizeL(RReadStream& aStream);
    1.85 +
    1.86 +protected:
    1.87 +	// constructor which takes an ems id and a boolean indicating whether or
    1.88 +	// not the start position is encoded in the pdu (true by default,
    1.89 +	// but needs to false for UserPrompt
    1.90 +	inline CEmsInformationElement(TSmsId aId, TBool aStartPosEncoded = ETrue);
    1.91 +	void CopyL(const CEmsInformationElement& aSrc);
    1.92 +
    1.93 +	// Encodes and decodes the body of an information element, EXCLUDING the
    1.94 +	// start position. The boolean flag indicates whether or not it is for
    1.95 +	// serialisation or PDU transmission. This impacts in particular the
    1.96 +	// EmsFormatIE object, which stores the length in 16-bits if serialised
    1.97 +	// but only 8-bits when encoded.
    1.98 +	virtual void EncodeBodyL(TPtr8 aPtr, TBool aIsForSerialisation) const = 0;
    1.99 +	virtual void DecodeBodyL(const TPtrC8 aPtr, TBool aIsFromSerialisation) = 0;
   1.100 +
   1.101 +	// This virtual function returns the length of object body when it is to
   1.102 +	// be serialised - note that this is generally the same as the encoded
   1.103 +	// body length, except for the Format object
   1.104 +	virtual TInt SerialisedBodyLength() const;
   1.105 +
   1.106 +protected:
   1.107 +	// The start position in relation to the entire text
   1.108 +	TUint iStartPosition;
   1.109 +
   1.110 +	// Length of the encoded body, EXCLUDING the start position and IE header
   1.111 +	TUint iEncodedBodyLength;
   1.112 +
   1.113 +private:
   1.114 +	// boolean to indicate if the start position needs to be encoded in the
   1.115 +	// pdu
   1.116 +	const TBool iStartPosEncoded;
   1.117 +
   1.118 +protected:
   1.119 +	// the scope of the following functions of CSmsInformationElement have
   1.120 +	// been downgraded to protected to prevent them from being used when
   1.121 +	// accessed as an EMS element. The point of transition from being
   1.122 +	// a CEmsInformationElement to a CSmsInformation element should occur
   1.123 +	// in the EncodeInformationElement function
   1.124 +	using CSmsInformationElement::Data;
   1.125 +	using CSmsInformationElement::EncodeL;
   1.126 +	using CSmsInformationElement::DecodeL;
   1.127 +	};
   1.128 +
   1.129 +
   1.130 +class CEmsFactory : public CBase
   1.131 +/**
   1.132 + *  Factory class used to create an EMS object from the given data.
   1.133 + *  @internalComponent
   1.134 + */
   1.135 +	{
   1.136 +public:
   1.137 +	static TBool Supported(TSmsId aId);
   1.138 +
   1.139 +	// Creates an information element with a given ID
   1.140 +	static CEmsInformationElement* CreateIeL(TSmsId aId);
   1.141 +	static void InternalizeL(RPointerArray<CEmsInformationElement>& aObjectStore, RReadStream& aStream);
   1.142 +	static void ExternalizeL(RPointerArray<CEmsInformationElement>& aObjectStore, RWriteStream& aStream);
   1.143 +	static CEmsInformationElement* CreateReceivedEmsIEL(const CSmsInformationElement& aIE,TInt aBaseAddr);
   1.144 +	};
   1.145 +
   1.146 +#include <emsinformationelement.inl>
   1.147 +#endif // __EMSInformationElement__