1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "T_DataWsGraphicAnimation.h" |
|
19 |
|
20 /*@{*/ |
|
21 /// Commands |
|
22 _LIT(KCmdnew, "new"); |
|
23 _LIT(KCmdIsPaused, "IsPaused"); |
|
24 _LIT(KCmdIsPlaying, "IsPlaying"); |
|
25 _LIT(KCmdIsStopped, "IsStopped"); |
|
26 _LIT(KCmdIsStopping, "IsStopping"); |
|
27 _LIT(KCmdLoops, "Loops"); |
|
28 _LIT(KCmdPause, "Pause"); |
|
29 _LIT(KCmdPlay, "Play"); |
|
30 _LIT(KCmdStop, "Stop"); |
|
31 |
|
32 /// Fields |
|
33 _LIT(KFldExpected, "expected"); |
|
34 _LIT(KFldLoop, "loop"); |
|
35 _LIT(KFldImmediately, "immediately"); |
|
36 |
|
37 /// Logging |
|
38 _LIT(KLogError, "Error=%d"); |
|
39 _LIT(KLogMissingParameter, "Missing parameter '%S'"); |
|
40 _LIT(KLogNotExpectedValue, "Not expected value"); |
|
41 /*@}*/ |
|
42 |
|
43 ////////////////////////////////////////////////////////////////////// |
|
44 // Construction/Destruction |
|
45 ////////////////////////////////////////////////////////////////////// |
|
46 |
|
47 CT_DataWsGraphicAnimation::CT_DataWsGraphicAnimation() |
|
48 : CT_DataWsGraphicMsgFixedBase() |
|
49 , iWsGraphicAnimation(NULL) |
|
50 { |
|
51 } |
|
52 |
|
53 CT_DataWsGraphicAnimation::~CT_DataWsGraphicAnimation() |
|
54 { |
|
55 DestroyData(); |
|
56 } |
|
57 |
|
58 void CT_DataWsGraphicAnimation::DestroyData() |
|
59 { |
|
60 delete iWsGraphicAnimation; |
|
61 iWsGraphicAnimation=NULL; |
|
62 } |
|
63 |
|
64 /** |
|
65 * Return a pointer to the object that the data wraps |
|
66 * |
|
67 * @return pointer to the object that the data wraps |
|
68 */ |
|
69 TAny* CT_DataWsGraphicAnimation::GetObject() |
|
70 { |
|
71 return iWsGraphicAnimation; |
|
72 } |
|
73 |
|
74 TWsGraphicMsgFixedBase* CT_DataWsGraphicAnimation::GetWsGraphicMsgFixedBase() const |
|
75 { |
|
76 return iWsGraphicAnimation; |
|
77 } |
|
78 |
|
79 /** |
|
80 * Process a command read from the ini file |
|
81 * |
|
82 * @param aCommand the command to process |
|
83 * @param aSection the entry in the ini file requiring the command to be processed |
|
84 * @param aAsyncErrorIndex index of command. used for async calls |
|
85 * |
|
86 * @return ETrue if the command is processed |
|
87 */ |
|
88 TBool CT_DataWsGraphicAnimation::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
89 { |
|
90 TBool ret=ETrue; |
|
91 |
|
92 if ( aCommand==KCmdnew ) |
|
93 { |
|
94 DoCmdnew(); |
|
95 } |
|
96 else if ( aCommand==KCmdIsPaused ) |
|
97 { |
|
98 DoCmdIsPaused(aSection); |
|
99 } |
|
100 else if ( aCommand==KCmdIsPlaying ) |
|
101 { |
|
102 DoCmdIsPlaying(aSection); |
|
103 } |
|
104 else if ( aCommand==KCmdIsStopped ) |
|
105 { |
|
106 DoCmdIsStopped(aSection); |
|
107 } |
|
108 else if ( aCommand==KCmdIsStopping ) |
|
109 { |
|
110 DoCmdIsStopping(aSection); |
|
111 } |
|
112 else if ( aCommand==KCmdLoops ) |
|
113 { |
|
114 DoCmdLoops(aSection); |
|
115 } |
|
116 else if ( aCommand==KCmdPause ) |
|
117 { |
|
118 DoCmdPause(); |
|
119 } |
|
120 else if ( aCommand==KCmdPlay ) |
|
121 { |
|
122 DoCmdPlay(aSection); |
|
123 } |
|
124 else if ( aCommand==KCmdStop ) |
|
125 { |
|
126 DoCmdStop(aSection); |
|
127 } |
|
128 else |
|
129 { |
|
130 ret=CT_DataWsGraphicMsgFixedBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
131 } |
|
132 |
|
133 return ret; |
|
134 } |
|
135 |
|
136 void CT_DataWsGraphicAnimation::DoCmdnew() |
|
137 { |
|
138 INFO_PRINTF1(_L("execute new")); |
|
139 DestroyData(); |
|
140 TRAPD(err, iWsGraphicAnimation=new (ELeave) TWsGraphicAnimation()); |
|
141 if ( err!=KErrNone ) |
|
142 { |
|
143 ERR_PRINTF2(KLogError, err); |
|
144 SetError(err); |
|
145 } |
|
146 } |
|
147 |
|
148 void CT_DataWsGraphicAnimation::DoCmdIsPaused(const TDesC& aSection) |
|
149 { |
|
150 TBool actual=iWsGraphicAnimation->IsPaused(); |
|
151 INFO_PRINTF2(_L("execute IsPaused() = %d"), actual); |
|
152 |
|
153 TBool expected; |
|
154 if ( GetBoolFromConfig(aSection, KFldExpected, expected) ) |
|
155 { |
|
156 if ( expected!=actual ) |
|
157 { |
|
158 ERR_PRINTF1(KLogNotExpectedValue); |
|
159 SetBlockResult(EFail); |
|
160 } |
|
161 } |
|
162 } |
|
163 |
|
164 void CT_DataWsGraphicAnimation::DoCmdIsPlaying(const TDesC& aSection) |
|
165 { |
|
166 TBool actual=iWsGraphicAnimation->IsPlaying(); |
|
167 INFO_PRINTF2(_L("execute IsPlaying() = %d"), actual); |
|
168 |
|
169 TBool expected; |
|
170 if ( GetBoolFromConfig(aSection, KFldExpected, expected) ) |
|
171 { |
|
172 if ( expected!=actual ) |
|
173 { |
|
174 ERR_PRINTF1(KLogNotExpectedValue); |
|
175 SetBlockResult(EFail); |
|
176 } |
|
177 } |
|
178 } |
|
179 |
|
180 void CT_DataWsGraphicAnimation::DoCmdIsStopped(const TDesC& aSection) |
|
181 { |
|
182 TBool actual=iWsGraphicAnimation->IsStopped(); |
|
183 INFO_PRINTF2(_L("execute IsStopped() = %d"), actual); |
|
184 |
|
185 TBool expected; |
|
186 if ( GetBoolFromConfig(aSection, KFldExpected, expected) ) |
|
187 { |
|
188 if ( expected!=actual ) |
|
189 { |
|
190 ERR_PRINTF1(KLogNotExpectedValue); |
|
191 SetBlockResult(EFail); |
|
192 } |
|
193 } |
|
194 } |
|
195 |
|
196 void CT_DataWsGraphicAnimation::DoCmdIsStopping(const TDesC& aSection) |
|
197 { |
|
198 TBool actual=iWsGraphicAnimation->IsStopping(); |
|
199 INFO_PRINTF2(_L("execute IsStopping() = %d"), actual); |
|
200 |
|
201 TBool expected; |
|
202 if ( GetBoolFromConfig(aSection, KFldExpected, expected) ) |
|
203 { |
|
204 if ( expected!=actual ) |
|
205 { |
|
206 ERR_PRINTF1(KLogNotExpectedValue); |
|
207 SetBlockResult(EFail); |
|
208 } |
|
209 } |
|
210 } |
|
211 |
|
212 void CT_DataWsGraphicAnimation::DoCmdLoops(const TDesC& aSection) |
|
213 { |
|
214 TBool actual=iWsGraphicAnimation->Loops(); |
|
215 INFO_PRINTF2(_L("execute Loops() = %d"), actual); |
|
216 |
|
217 TBool expected; |
|
218 if ( GetBoolFromConfig(aSection, KFldExpected, expected) ) |
|
219 { |
|
220 if ( expected!=actual ) |
|
221 { |
|
222 ERR_PRINTF1(KLogNotExpectedValue); |
|
223 SetBlockResult(EFail); |
|
224 } |
|
225 } |
|
226 } |
|
227 |
|
228 void CT_DataWsGraphicAnimation::DoCmdPause() |
|
229 { |
|
230 iWsGraphicAnimation->Pause(); |
|
231 INFO_PRINTF1(_L("execute Pause()")); |
|
232 } |
|
233 |
|
234 void CT_DataWsGraphicAnimation::DoCmdPlay(const TDesC& aSection) |
|
235 { |
|
236 TBool loop; |
|
237 if ( !GetBoolFromConfig(aSection, KFldLoop, loop) ) |
|
238 { |
|
239 ERR_PRINTF2(KLogMissingParameter, &KFldLoop()); |
|
240 SetBlockResult(EFail); |
|
241 } |
|
242 else |
|
243 { |
|
244 iWsGraphicAnimation->Play(loop); |
|
245 INFO_PRINTF1(_L("execute Play(TBool)")); |
|
246 } |
|
247 } |
|
248 |
|
249 void CT_DataWsGraphicAnimation::DoCmdStop(const TDesC& aSection) |
|
250 { |
|
251 TBool immediately; |
|
252 if ( !GetBoolFromConfig(aSection, KFldImmediately, immediately) ) |
|
253 { |
|
254 ERR_PRINTF2(KLogMissingParameter, &KFldImmediately()); |
|
255 SetBlockResult(EFail); |
|
256 } |
|
257 else |
|
258 { |
|
259 iWsGraphicAnimation->Stop(immediately); |
|
260 INFO_PRINTF1(_L("execute Stop(TBool)")); |
|
261 } |
|
262 } |
|