diff -r 9f5ae1728557 -r db3f5fa34ec7 messagingfw/msgtest/testutils/sms/inc/EmsMsgTestUtils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingfw/msgtest/testutils/sms/inc/EmsMsgTestUtils.h Wed Nov 03 22:41:46 2010 +0530 @@ -0,0 +1,177 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef _EMS_MSG_TEST_UTILS_H +#define _EMS_MSG_TEST_UTILS_H + +#include +#include + +// The following descriptors are the tags for EMS objects. Note that not all +// object types are supported - in particular, picture types and user defined +// animations +// +// The syntax for adding EMS objects is as follows: +// = [ ] (n times) +// +// Specific parameters are: +// EmsFormat: +// EmsUserSound: , eg abcdefghijklmn +// EmsPredefSound: +// EmsPic: where 0 is small, 1 is large, 2 is user defined +// EmsAnim: where 0 is small, 1 is large +// EmsPredefAnim: +// EmsUserPrompt: +// +// eg, to create two user sounds, at position 10 and 20, you do: +// EmsUserSound= 2 10 abcde 20 fghijk +_LIT(KEmsItemFormat, "EmsFormat"); +_LIT(KEmsItemUserSound, "EmsUserSound"); +_LIT(KEmsItemPredefSound, "EmsPredefSound"); +_LIT(KEmsItemPic, "EmsPicture"); +_LIT(KEmsItemPredefAnim, "EmsPredefAnim"); +_LIT(KEmsItemAnim, "EmsAnimation"); +_LIT(KEmsItemUserPrompt, "EmsUserPrompt"); + +class CScriptSection; +class EmsParser; +class CSmsMessage; + +// This class extracts all ems objects from a given section when the class +// is constructed +class CEmsExtractor : public CBase + { +public: + // Constructs an EmsExtractor object from a given script section and + // processes it + static CEmsExtractor* NewL(CScriptSection& aSection); + static CEmsExtractor* NewLC(CScriptSection& aSection); + + virtual ~CEmsExtractor(); + + // This method adds all the extracted EMS objects into the actual message + void AddToMessageL(CSmsMessage& msg) const; + +private: + CEmsExtractor() : iEmsArray(10) {} + + // Constructs the EmsExtractor object and sets up the array from the + // specified section + void ConstructL(CScriptSection& aSection); + +private: + // array of CEmsInformationElement pointers + RPointerArray iEmsArray; + RPointerArray iParsers; + }; + + +// abstract base class which encapsulates the parsers for each object. +// EmsParsers will parse the parameters of an EMS tag. Each specialised +// EmsParser will implement the GetElementL method to extract the +// specific parameters section above. +class EmsParser + { +public: + EmsParser(const TDesC& aTagName) : iTagName(aTagName) {} + virtual ~EmsParser() {} + + // For a given section, parse my EMS object type and put the newly + // created objects into the array + void ParseL(CScriptSection& aSection, RPointerArray& aEmsArray) const; + +protected: + virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const = 0; + + // utility function for extracting the first integer after the marked + // position + static TInt ExtractIntegerL(TLex& aInput); + +private: + const TDesC& iTagName; + }; + +// Parser for format object +class EmsFormatParser : public EmsParser + { +public: + EmsFormatParser() : EmsParser(KEmsItemFormat) {} + +protected: + virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const; + }; + +// Parser for user sound object +class EmsUserSoundParser : public EmsParser + { +public: + EmsUserSoundParser() : EmsParser(KEmsItemUserSound) {} + +protected: + virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const; + }; + +// Parser for predefined sound object +class EmsPredefSoundParser : public EmsParser + { +public: + EmsPredefSoundParser() : EmsParser(KEmsItemPredefSound) {} + +protected: + virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const; + }; + +// Parser for picture object +class EmsPicParser : public EmsParser + { +public: + EmsPicParser() : EmsParser(KEmsItemPic) {} + +protected: + virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const; + }; + +// Parser for animation object +class EmsAnimParser : public EmsParser + { +public: + EmsAnimParser() : EmsParser(KEmsItemAnim) {} + +protected: + virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const; + }; + +// Parser for predefined animation object +class EmsPredefAnimParser : public EmsParser + { +public: + EmsPredefAnimParser() : EmsParser(KEmsItemPredefAnim) {} + +protected: + virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const; + }; + +// Parser for user prompt object +class EmsUserPromptParser : public EmsParser + { +public: + EmsUserPromptParser() : EmsParser(KEmsItemUserPrompt) {} + +protected: + virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const; + }; + + +#endif