|
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef _EMS_MSG_TEST_UTILS_H |
|
17 #define _EMS_MSG_TEST_UTILS_H |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <emsinformationelement.h> |
|
21 |
|
22 // The following descriptors are the tags for EMS objects. Note that not all |
|
23 // object types are supported - in particular, picture types and user defined |
|
24 // animations |
|
25 // |
|
26 // The syntax for adding EMS objects is as follows: |
|
27 // <TAG>= <numObjects> [<startPos> <specific parameters>] (n times) |
|
28 // |
|
29 // Specific parameters are: |
|
30 // EmsFormat: <formatLength> <formatValue> |
|
31 // EmsUserSound: <sound, where a = 0x01>, eg abcdefghijklmn |
|
32 // EmsPredefSound: <soundValue> |
|
33 // EmsPic: <picture-type> where 0 is small, 1 is large, 2 is user defined |
|
34 // EmsAnim: <anim-type> where 0 is small, 1 is large |
|
35 // EmsPredefAnim: <animValue> |
|
36 // EmsUserPrompt: <numObjects> |
|
37 // |
|
38 // eg, to create two user sounds, at position 10 and 20, you do: |
|
39 // EmsUserSound= 2 10 abcde 20 fghijk |
|
40 _LIT(KEmsItemFormat, "EmsFormat"); |
|
41 _LIT(KEmsItemUserSound, "EmsUserSound"); |
|
42 _LIT(KEmsItemPredefSound, "EmsPredefSound"); |
|
43 _LIT(KEmsItemPic, "EmsPicture"); |
|
44 _LIT(KEmsItemPredefAnim, "EmsPredefAnim"); |
|
45 _LIT(KEmsItemAnim, "EmsAnimation"); |
|
46 _LIT(KEmsItemUserPrompt, "EmsUserPrompt"); |
|
47 |
|
48 class CScriptSection; |
|
49 class EmsParser; |
|
50 class CSmsMessage; |
|
51 |
|
52 // This class extracts all ems objects from a given section when the class |
|
53 // is constructed |
|
54 class CEmsExtractor : public CBase |
|
55 { |
|
56 public: |
|
57 // Constructs an EmsExtractor object from a given script section and |
|
58 // processes it |
|
59 static CEmsExtractor* NewL(CScriptSection& aSection); |
|
60 static CEmsExtractor* NewLC(CScriptSection& aSection); |
|
61 |
|
62 virtual ~CEmsExtractor(); |
|
63 |
|
64 // This method adds all the extracted EMS objects into the actual message |
|
65 void AddToMessageL(CSmsMessage& msg) const; |
|
66 |
|
67 private: |
|
68 CEmsExtractor() : iEmsArray(10) {} |
|
69 |
|
70 // Constructs the EmsExtractor object and sets up the array from the |
|
71 // specified section |
|
72 void ConstructL(CScriptSection& aSection); |
|
73 |
|
74 private: |
|
75 // array of CEmsInformationElement pointers |
|
76 RPointerArray<CEmsInformationElement> iEmsArray; |
|
77 RPointerArray<EmsParser> iParsers; |
|
78 }; |
|
79 |
|
80 |
|
81 // abstract base class which encapsulates the parsers for each object. |
|
82 // EmsParsers will parse the parameters of an EMS tag. Each specialised |
|
83 // EmsParser will implement the GetElementL method to extract the |
|
84 // specific parameters section above. |
|
85 class EmsParser |
|
86 { |
|
87 public: |
|
88 EmsParser(const TDesC& aTagName) : iTagName(aTagName) {} |
|
89 virtual ~EmsParser() {} |
|
90 |
|
91 // For a given section, parse my EMS object type and put the newly |
|
92 // created objects into the array |
|
93 void ParseL(CScriptSection& aSection, RPointerArray<CEmsInformationElement>& aEmsArray) const; |
|
94 |
|
95 protected: |
|
96 virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const = 0; |
|
97 |
|
98 // utility function for extracting the first integer after the marked |
|
99 // position |
|
100 static TInt ExtractIntegerL(TLex& aInput); |
|
101 |
|
102 private: |
|
103 const TDesC& iTagName; |
|
104 }; |
|
105 |
|
106 // Parser for format object |
|
107 class EmsFormatParser : public EmsParser |
|
108 { |
|
109 public: |
|
110 EmsFormatParser() : EmsParser(KEmsItemFormat) {} |
|
111 |
|
112 protected: |
|
113 virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const; |
|
114 }; |
|
115 |
|
116 // Parser for user sound object |
|
117 class EmsUserSoundParser : public EmsParser |
|
118 { |
|
119 public: |
|
120 EmsUserSoundParser() : EmsParser(KEmsItemUserSound) {} |
|
121 |
|
122 protected: |
|
123 virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const; |
|
124 }; |
|
125 |
|
126 // Parser for predefined sound object |
|
127 class EmsPredefSoundParser : public EmsParser |
|
128 { |
|
129 public: |
|
130 EmsPredefSoundParser() : EmsParser(KEmsItemPredefSound) {} |
|
131 |
|
132 protected: |
|
133 virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const; |
|
134 }; |
|
135 |
|
136 // Parser for picture object |
|
137 class EmsPicParser : public EmsParser |
|
138 { |
|
139 public: |
|
140 EmsPicParser() : EmsParser(KEmsItemPic) {} |
|
141 |
|
142 protected: |
|
143 virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const; |
|
144 }; |
|
145 |
|
146 // Parser for animation object |
|
147 class EmsAnimParser : public EmsParser |
|
148 { |
|
149 public: |
|
150 EmsAnimParser() : EmsParser(KEmsItemAnim) {} |
|
151 |
|
152 protected: |
|
153 virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const; |
|
154 }; |
|
155 |
|
156 // Parser for predefined animation object |
|
157 class EmsPredefAnimParser : public EmsParser |
|
158 { |
|
159 public: |
|
160 EmsPredefAnimParser() : EmsParser(KEmsItemPredefAnim) {} |
|
161 |
|
162 protected: |
|
163 virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const; |
|
164 }; |
|
165 |
|
166 // Parser for user prompt object |
|
167 class EmsUserPromptParser : public EmsParser |
|
168 { |
|
169 public: |
|
170 EmsUserPromptParser() : EmsParser(KEmsItemUserPrompt) {} |
|
171 |
|
172 protected: |
|
173 virtual CEmsInformationElement* GetElementL(TLex& aInput, TInt aStartPos) const; |
|
174 }; |
|
175 |
|
176 |
|
177 #endif |