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_GraphicsUtil.h" |
|
19 #include "T_DataWsSpriteBase.h" |
|
20 |
|
21 /*@{*/ |
|
22 //Commands |
|
23 _LIT(KCmdActivate, "Activate"); |
|
24 _LIT(KCmdAppendMember, "AppendMember"); |
|
25 _LIT(KCmdUpdateMember, "UpdateMember"); |
|
26 _LIT(KCmdClose, "Close"); |
|
27 |
|
28 // Fields |
|
29 _LIT(KFldIndex, "index"); |
|
30 _LIT(KFldOneParameter, "oneparameter"); |
|
31 _LIT(KFldSpriteMember, "spritemember"); |
|
32 /// Logging |
|
33 _LIT(KLogError, "Error=%d"); |
|
34 _LIT(KLogMissingParameter, "Missing parameter '%S'"); |
|
35 |
|
36 |
|
37 _LIT(KLogActivate, "execute Activate()"); |
|
38 _LIT(KLogAppendMember, "execute AppendMember(const TSpriteMember &aMemberData)"); |
|
39 _LIT(KLogUpdateMember, "execute UpdateMember(TInt aIndex)"); |
|
40 _LIT(KLogUpdateMember2, "execute UpdateMember(TInt aIndex, const TSpriteMember &aMemberData)"); |
|
41 _LIT(KLogClose, "execute Close()"); |
|
42 /*@}*/ |
|
43 |
|
44 ////////////////////////////////////////////////////////////////////// |
|
45 // Construction/Destruction |
|
46 ////////////////////////////////////////////////////////////////////// |
|
47 |
|
48 CT_DataWsSpriteBase::CT_DataWsSpriteBase():CDataWrapperBase() |
|
49 { |
|
50 } |
|
51 |
|
52 MWsClientClass* CT_DataWsSpriteBase::GetClientClass() const |
|
53 { |
|
54 return GetWsSpriteBase(); |
|
55 } |
|
56 /** |
|
57 * Process a command read from the ini file |
|
58 * |
|
59 * @param aCommand the command to process |
|
60 * @param aSection the entry in the ini file requiring the command to be processed |
|
61 * @param aAsyncErrorIndex index of command. used for async calls |
|
62 * |
|
63 * @return ETrue if the command is processed |
|
64 */ |
|
65 TBool CT_DataWsSpriteBase::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
66 { |
|
67 TBool ret = ETrue; |
|
68 |
|
69 if ( aCommand==KCmdActivate ) |
|
70 { |
|
71 DoCmdActivate(); |
|
72 } |
|
73 else if ( aCommand==KCmdAppendMember ) |
|
74 { |
|
75 DoCmdAppendMemberL(aSection); |
|
76 } |
|
77 else if ( aCommand==KCmdUpdateMember ) |
|
78 { |
|
79 DoCmdUpdateMemberL(aSection); |
|
80 } |
|
81 else if ( aCommand==KCmdClose ) |
|
82 { |
|
83 DoCmdClose(); |
|
84 } |
|
85 else |
|
86 { |
|
87 ret=EFalse; |
|
88 } |
|
89 |
|
90 return ret; |
|
91 } |
|
92 |
|
93 /** |
|
94 * Process Activate command |
|
95 * |
|
96 * @param: None |
|
97 * |
|
98 * @return: None |
|
99 */ |
|
100 void CT_DataWsSpriteBase::DoCmdActivate() |
|
101 { |
|
102 // Execute command and log parameters |
|
103 INFO_PRINTF1(KLogActivate); |
|
104 TInt nErr=GetWsSpriteBase()->Activate(); |
|
105 |
|
106 if(nErr!=KErrNone) |
|
107 { |
|
108 ERR_PRINTF2(KLogError, nErr); |
|
109 SetError(nErr); |
|
110 } |
|
111 |
|
112 // No command return value and output parameter to display and check |
|
113 } |
|
114 |
|
115 /** |
|
116 * Process AppendMember command |
|
117 * |
|
118 * @param: aSection the entry in the ini file requiring the command to be processed |
|
119 * |
|
120 * @return: None |
|
121 */ |
|
122 void CT_DataWsSpriteBase::DoCmdAppendMemberL(const TDesC& aSection) |
|
123 { |
|
124 // Execute command and log parameters |
|
125 INFO_PRINTF1(KLogAppendMember); |
|
126 |
|
127 //Init TSpriteMember |
|
128 TSpriteMember spriteMember; |
|
129 |
|
130 if ( !CT_GraphicsUtil::GetSpriteMemberL(*this, aSection, KFldSpriteMember, spriteMember) ) |
|
131 { |
|
132 ERR_PRINTF2(KLogMissingParameter, &KFldSpriteMember); |
|
133 SetBlockResult(EFail); |
|
134 } |
|
135 |
|
136 TInt returnCode=GetWsSpriteBase()->AppendMember(spriteMember); |
|
137 |
|
138 if(KErrNone!=returnCode) |
|
139 { |
|
140 ERR_PRINTF2(KLogError, returnCode); |
|
141 SetError(returnCode); |
|
142 } |
|
143 |
|
144 // No command return value and output parameter to display and check |
|
145 } |
|
146 |
|
147 /** |
|
148 * Process UpdateMember command |
|
149 * |
|
150 * @param: aSection the entry in the ini file requiring the command to be processed |
|
151 * |
|
152 * @return: None |
|
153 */ |
|
154 void CT_DataWsSpriteBase::DoCmdUpdateMemberL(const TDesC& aSection) |
|
155 { |
|
156 TBool dataOk=ETrue; |
|
157 //get update index |
|
158 TInt datIndex; |
|
159 |
|
160 if ( !GetIntFromConfig(aSection, KFldIndex, datIndex) ) |
|
161 { |
|
162 dataOk=EFalse; |
|
163 ERR_PRINTF2(KLogMissingParameter, &KFldIndex); |
|
164 } |
|
165 //get if one parameter |
|
166 TBool bOneParameter=TRUE; |
|
167 |
|
168 if ( !GetBoolFromConfig(aSection, KFldOneParameter, bOneParameter) ) |
|
169 { |
|
170 dataOk=EFalse; |
|
171 ERR_PRINTF2(KLogMissingParameter, &KFldOneParameter); |
|
172 } |
|
173 |
|
174 //Init new TSpriteMember |
|
175 TSpriteMember spriteMember; |
|
176 |
|
177 if ( !CT_GraphicsUtil::GetSpriteMemberL(*this, aSection, KFldSpriteMember, spriteMember) ) |
|
178 { |
|
179 if(!bOneParameter) |
|
180 { |
|
181 dataOk=EFalse; |
|
182 ERR_PRINTF2(KLogMissingParameter, &KFldSpriteMember); |
|
183 SetBlockResult(EFail); |
|
184 } |
|
185 } |
|
186 |
|
187 if(dataOk) |
|
188 { |
|
189 TInt returnCode=KErrNone; |
|
190 |
|
191 if(bOneParameter) |
|
192 { |
|
193 INFO_PRINTF1(KLogUpdateMember); |
|
194 GetWsSpriteBase()->UpdateMember(datIndex); |
|
195 } |
|
196 else |
|
197 { |
|
198 INFO_PRINTF1(KLogUpdateMember2); |
|
199 returnCode=GetWsSpriteBase()->UpdateMember(datIndex,spriteMember); |
|
200 } |
|
201 |
|
202 if(returnCode!=KErrNone) |
|
203 { |
|
204 ERR_PRINTF2(KLogError, returnCode); |
|
205 SetError(returnCode); |
|
206 } |
|
207 } |
|
208 // No command return value and output parameter to display and check |
|
209 } |
|
210 |
|
211 /** |
|
212 * Process Close command |
|
213 * |
|
214 * @param: None |
|
215 * |
|
216 * @return: None |
|
217 */ |
|
218 void CT_DataWsSpriteBase::DoCmdClose() |
|
219 { |
|
220 // Execute command and log parameters |
|
221 INFO_PRINTF1(KLogClose); |
|
222 GetWsSpriteBase()->Close(); |
|
223 } |
|