epoc32/include/emsinformationelement.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2009 Sony Ericsson Mobile Communications AB
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     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
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Sony Ericsson Mobile Communications AB - initial contribution.
williamr@2
    11
* Nokia Corporation - additional changes.
williamr@2
    12
* 
williamr@2
    13
* Contributors:
williamr@2
    14
* 
williamr@2
    15
* Description:
williamr@2
    16
* Provides the base class for CEmsInformationElements and a factory with which
williamr@2
    17
* to create Ems Elements.
williamr@2
    18
*
williamr@2
    19
*/
williamr@2
    20
williamr@2
    21
williamr@2
    22
/**
williamr@2
    23
 *  @file
williamr@2
    24
 *  
williamr@2
    25
 *  Defines  CEmsInformationElement  class
williamr@2
    26
 */
williamr@2
    27
williamr@2
    28
williamr@2
    29
#ifndef __EMSInformationElement__
williamr@2
    30
#define __EMSInformationElement__
williamr@2
    31
williamr@2
    32
#include <gsmuelem.h>
williamr@2
    33
williamr@2
    34
/**
williamr@2
    35
 *  @internalComponent
williamr@2
    36
 */
williamr@2
    37
#define SHIFT_BOOL_LEFT(a,x) ((TUint8) ((a ? 1 : 0) <<x))
williamr@2
    38
/**
williamr@2
    39
 *  @internalComponent
williamr@2
    40
 */
williamr@2
    41
#define BOOL_AT(a,x)		 ((TBool) ((a >> x) & 0x01))
williamr@2
    42
williamr@2
    43
/**
williamr@2
    44
 *  @internalComponent
williamr@2
    45
 */
williamr@2
    46
#define HI_BYTE(a)	(TUint8) ((a&0xFF00) >> 8)
williamr@2
    47
/**
williamr@2
    48
 *  @internalComponent
williamr@2
    49
 */
williamr@2
    50
#define LO_BYTE(a)	(TUint8) (a&0x00FF)
williamr@2
    51
williamr@2
    52
williamr@2
    53
williamr@2
    54
class CEmsInformationElement : public CSmsInformationElement
williamr@2
    55
/**
williamr@2
    56
 *  Abstract base class used to allow ems objects to be passed around, and to be
williamr@2
    57
 *  handled as a generic group of objects.
williamr@2
    58
 *  @internalComponent
williamr@2
    59
 */
williamr@2
    60
	{
williamr@2
    61
	friend class CEmsFactory;
williamr@2
    62
williamr@2
    63
public:
williamr@2
    64
	// Externally available and exported functions
williamr@2
    65
	IMPORT_C virtual CEmsInformationElement* DuplicateL() const = 0;
williamr@2
    66
	IMPORT_C void SetStartPosition(TUint aValue);
williamr@2
    67
	IMPORT_C TUint StartPosition() const;
williamr@2
    68
williamr@2
    69
	// Length of the generated encoded information element, INCLUDING
williamr@2
    70
	// the IE header
williamr@2
    71
	IMPORT_C TInt Length() const;
williamr@2
    72
williamr@2
    73
public:
williamr@2
    74
	// Encodes the CSmsInformationElement part and decodes to from an
williamr@2
    75
	// external CSmsInformationElement.
williamr@2
    76
	IMPORT_C void EncodeInformationElementL();
williamr@2
    77
	static CEmsInformationElement* DecodeInformationElementL(const CSmsInformationElement& aSmsIe);
williamr@2
    78
williamr@2
    79
	// Serialisation operations
williamr@2
    80
	void ExternalizeL(RWriteStream& aStream) const;
williamr@2
    81
	static CEmsInformationElement* InternalizeL(RReadStream& aStream);
williamr@2
    82
williamr@2
    83
protected:
williamr@2
    84
	// constructor which takes an ems id and a boolean indicating whether or
williamr@2
    85
	// not the start position is encoded in the pdu (true by default,
williamr@2
    86
	// but needs to false for UserPrompt
williamr@2
    87
	inline CEmsInformationElement(TSmsId aId, TBool aStartPosEncoded = ETrue);
williamr@2
    88
	void CopyL(const CEmsInformationElement& aSrc);
williamr@2
    89
williamr@2
    90
	// Encodes and decodes the body of an information element, EXCLUDING the
williamr@2
    91
	// start position. The boolean flag indicates whether or not it is for
williamr@2
    92
	// serialisation or PDU transmission. This impacts in particular the
williamr@2
    93
	// EmsFormatIE object, which stores the length in 16-bits if serialised
williamr@2
    94
	// but only 8-bits when encoded.
williamr@2
    95
	virtual void EncodeBodyL(TPtr8 aPtr, TBool aIsForSerialisation) const = 0;
williamr@2
    96
	virtual void DecodeBodyL(const TPtrC8 aPtr, TBool aIsFromSerialisation) = 0;
williamr@2
    97
williamr@2
    98
	// This virtual function returns the length of object body when it is to
williamr@2
    99
	// be serialised - note that this is generally the same as the encoded
williamr@2
   100
	// body length, except for the Format object
williamr@2
   101
	virtual TInt SerialisedBodyLength() const;
williamr@2
   102
williamr@2
   103
protected:
williamr@2
   104
	// The start position in relation to the entire text
williamr@2
   105
	TUint iStartPosition;
williamr@2
   106
williamr@2
   107
	// Length of the encoded body, EXCLUDING the start position and IE header
williamr@2
   108
	TUint iEncodedBodyLength;
williamr@2
   109
williamr@2
   110
private:
williamr@2
   111
	// boolean to indicate if the start position needs to be encoded in the
williamr@2
   112
	// pdu
williamr@2
   113
	const TBool iStartPosEncoded;
williamr@2
   114
williamr@2
   115
protected:
williamr@2
   116
	// the scope of the following functions of CSmsInformationElement have
williamr@2
   117
	// been downgraded to protected to prevent them from being used when
williamr@2
   118
	// accessed as an EMS element. The point of transition from being
williamr@2
   119
	// a CEmsInformationElement to a CSmsInformation element should occur
williamr@2
   120
	// in the EncodeInformationElement function
williamr@2
   121
	using CSmsInformationElement::Data;
williamr@2
   122
	using CSmsInformationElement::EncodeL;
williamr@2
   123
	using CSmsInformationElement::DecodeL;
williamr@2
   124
	};
williamr@2
   125
williamr@2
   126
williamr@2
   127
class CEmsFactory : public CBase
williamr@2
   128
/**
williamr@2
   129
 *  Factory class used to create an EMS object from the given data.
williamr@2
   130
 *  @internalComponent
williamr@2
   131
 */
williamr@2
   132
	{
williamr@2
   133
public:
williamr@2
   134
	static TBool Supported(TSmsId aId);
williamr@2
   135
williamr@2
   136
	// Creates an information element with a given ID
williamr@2
   137
	static CEmsInformationElement* CreateIeL(TSmsId aId);
williamr@2
   138
	static void InternalizeL(RPointerArray<CEmsInformationElement>& aObjectStore, RReadStream& aStream);
williamr@2
   139
	static void ExternalizeL(RPointerArray<CEmsInformationElement>& aObjectStore, RWriteStream& aStream);
williamr@2
   140
	static CEmsInformationElement* CreateReceivedEmsIEL(const CSmsInformationElement& aIE,TInt aBaseAddr);
williamr@2
   141
	};
williamr@2
   142
williamr@2
   143
#include <emsinformationelement.inl>
williamr@2
   144
#endif // __EMSInformationElement__