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_DataWsGraphic.h" |
|
19 |
|
20 /*@{*/ |
|
21 //Commands |
|
22 _LIT(KCmdDestructor, "~CWsGraphic"); |
|
23 _LIT(KCmdDestroy, "Destroy"); |
|
24 _LIT(KCmdId, "Id"); |
|
25 _LIT(KCmdIsActive, "IsActive"); |
|
26 _LIT(KCmdShare, "Share"); |
|
27 _LIT(KCmdShareGlobally, "ShareGlobally"); |
|
28 _LIT(KCmdUnShare, "UnShare"); |
|
29 _LIT(KCmdUnShareGlobally, "UnShareGlobally"); |
|
30 |
|
31 /// Fields |
|
32 _LIT(KFldClientId, "clientid"); |
|
33 _LIT(KFldExpected, "expected"); |
|
34 _LIT(KFldExpectNot, "expectnot"); |
|
35 |
|
36 /// Logging |
|
37 _LIT(KLogError, "Error=%d"); |
|
38 _LIT(KLogMissingParameter, "Missing parameter '%S'"); |
|
39 _LIT(KLogNotExpectedValue, "Not expected value"); |
|
40 /*@}*/ |
|
41 |
|
42 ////////////////////////////////////////////////////////////////////// |
|
43 // Construction/Destruction |
|
44 ////////////////////////////////////////////////////////////////////// |
|
45 |
|
46 CT_DataWsGraphic::CT_DataWsGraphic() |
|
47 : CDataWrapperBase() |
|
48 { |
|
49 } |
|
50 |
|
51 /** |
|
52 * Process a command read from the ini file |
|
53 * |
|
54 * @param aCommand the command to process |
|
55 * @param aSection the entry in the ini file requiring the command to be processed |
|
56 * @param aAsyncErrorIndex index of command. used for async calls |
|
57 * |
|
58 * @return ETrue if the command is processed |
|
59 */ |
|
60 TBool CT_DataWsGraphic::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
61 { |
|
62 TBool ret = ETrue; |
|
63 |
|
64 if ( aCommand==KCmdDestructor ) |
|
65 { |
|
66 DoCmdDestructorL(); |
|
67 } |
|
68 else if ( aCommand==KCmdDestroy ) |
|
69 { |
|
70 DoCmdDestroy(); |
|
71 } |
|
72 else if ( aCommand==KCmdId ) |
|
73 { |
|
74 DoCmdIdL(aSection); |
|
75 } |
|
76 else if ( aCommand==KCmdIsActive ) |
|
77 { |
|
78 DoCmdIsActive(aSection); |
|
79 } |
|
80 else if ( aCommand==KCmdShare ) |
|
81 { |
|
82 DoCmdShare(aSection); |
|
83 } |
|
84 else if ( aCommand==KCmdShareGlobally ) |
|
85 { |
|
86 DoCmdShareGlobally(); |
|
87 } |
|
88 else if ( aCommand==KCmdUnShare ) |
|
89 { |
|
90 DoCmdUnShare(aSection); |
|
91 } |
|
92 else if ( aCommand==KCmdUnShareGlobally ) |
|
93 { |
|
94 DoCmdUnShareGlobally(); |
|
95 } |
|
96 else |
|
97 { |
|
98 ret=EFalse; |
|
99 } |
|
100 |
|
101 return ret; |
|
102 } |
|
103 |
|
104 void CT_DataWsGraphic::DoCmdDestructorL() |
|
105 { |
|
106 // Execute command and log parameters |
|
107 INFO_PRINTF1(_L("execute ~CWsGraphic()")); |
|
108 CWsGraphic* graphic=GetWsGraphic(); |
|
109 CleanupStack::PushL(graphic); |
|
110 DisownObjectL(); |
|
111 CleanupStack::PopAndDestroy(graphic); |
|
112 } |
|
113 |
|
114 void CT_DataWsGraphic::DoCmdDestroy() |
|
115 { |
|
116 // Execute command and log parameters |
|
117 INFO_PRINTF1(_L("execute Destroy()")); |
|
118 GetWsGraphic()->Destroy(); |
|
119 } |
|
120 |
|
121 void CT_DataWsGraphic::DoCmdIdL(const TDesC& aSection) |
|
122 { |
|
123 // Execute command and log parameters |
|
124 INFO_PRINTF1(_L("execute Id()")); |
|
125 const TWsGraphicId& actual=GetWsGraphic()->Id(); |
|
126 SetId(actual); |
|
127 INFO_PRINTF3(_L("GetWsGraphic() Uid=0x%x Id=0x%x"), actual.Uid().iUid, actual.Id()); |
|
128 |
|
129 // Diaplay command return value, check if it matches the expected value |
|
130 TWsGraphicId expected(0); |
|
131 if ( GetWsGraphicIdFromConfigL(aSection, KFldExpectNot, expected) ) |
|
132 { |
|
133 if ( actual.Id()==expected.Uid().iUid ) |
|
134 { |
|
135 ERR_PRINTF1(KLogNotExpectedValue); |
|
136 SetBlockResult(EFail); |
|
137 } |
|
138 } |
|
139 else |
|
140 { |
|
141 if ( !GetWsGraphicIdFromConfigL(aSection, KFldExpected, expected) ) |
|
142 { |
|
143 ERR_PRINTF2(KLogMissingParameter, &KFldExpectNot); |
|
144 ERR_PRINTF2(KLogMissingParameter, &KFldExpected); |
|
145 SetBlockResult(EFail); |
|
146 } |
|
147 else |
|
148 { |
|
149 if ( actual.Uid()!=expected.Uid() ) |
|
150 { |
|
151 ERR_PRINTF1(KLogNotExpectedValue); |
|
152 SetBlockResult(EFail); |
|
153 } |
|
154 } |
|
155 } |
|
156 } |
|
157 |
|
158 void CT_DataWsGraphic::DoCmdIsActive(const TDesC& aSection) |
|
159 { |
|
160 // Execute command and log parameters |
|
161 TBool actual=GetWsGraphic()->IsActive(); |
|
162 INFO_PRINTF2(_L("execute IsActive()=%d"), actual); |
|
163 |
|
164 // Diaplay command return value, check if it matches the expected value |
|
165 TBool expected; |
|
166 if ( !GetBoolFromConfig(aSection, KFldExpected, expected) ) |
|
167 { |
|
168 ERR_PRINTF2(KLogMissingParameter, &KFldExpected()); |
|
169 SetBlockResult(EFail); |
|
170 } |
|
171 else |
|
172 { |
|
173 if ( actual!=expected ) |
|
174 { |
|
175 ERR_PRINTF1(KLogNotExpectedValue); |
|
176 SetBlockResult(EFail); |
|
177 } |
|
178 } |
|
179 } |
|
180 |
|
181 void CT_DataWsGraphic::DoCmdShare(const TDesC& aSection) |
|
182 { |
|
183 // Get test data for command input parameter(s) |
|
184 TInt datId; |
|
185 |
|
186 if ( !GetIntFromConfig(aSection, KFldClientId, datId) ) |
|
187 { |
|
188 ERR_PRINTF2(KLogMissingParameter, &KFldClientId()); |
|
189 SetBlockResult(EFail); |
|
190 } |
|
191 else |
|
192 { |
|
193 _LIT_SECURE_ID(datClientId, datId); |
|
194 |
|
195 // Execute command and log parameters |
|
196 INFO_PRINTF1(_L("execute Share(TSecureId)")); |
|
197 TInt err=Share(datClientId); |
|
198 if ( err!=KErrNone ) |
|
199 { |
|
200 ERR_PRINTF2(KLogError, err); |
|
201 SetError(err); |
|
202 } |
|
203 } |
|
204 } |
|
205 |
|
206 void CT_DataWsGraphic::DoCmdShareGlobally() |
|
207 { |
|
208 INFO_PRINTF1(_L("execute ShareGlobally()")); |
|
209 TInt err=ShareGlobally(); |
|
210 if ( err!=KErrNone ) |
|
211 { |
|
212 ERR_PRINTF2(KLogError, err); |
|
213 SetError(err); |
|
214 } |
|
215 } |
|
216 |
|
217 void CT_DataWsGraphic::DoCmdUnShare(const TDesC& aSection) |
|
218 { |
|
219 // Get test data for command input parameter(s) |
|
220 TInt datId; |
|
221 |
|
222 if ( !GetIntFromConfig(aSection, KFldClientId, datId) ) |
|
223 { |
|
224 ERR_PRINTF2(KLogMissingParameter, &KFldClientId()); |
|
225 SetBlockResult(EFail); |
|
226 } |
|
227 else |
|
228 { |
|
229 _LIT_SECURE_ID(datClientId, datId); |
|
230 |
|
231 // Execute command and log parameters |
|
232 INFO_PRINTF1(_L("execute UnShare(TSecureId)")); |
|
233 TInt err=UnShare(datClientId); |
|
234 if ( err!=KErrNone ) |
|
235 { |
|
236 ERR_PRINTF2(KLogError, err); |
|
237 SetError(err); |
|
238 } |
|
239 } |
|
240 } |
|
241 |
|
242 void CT_DataWsGraphic::DoCmdUnShareGlobally() |
|
243 { |
|
244 INFO_PRINTF1(_L("execute UnShareGlobally()")); |
|
245 TInt err=UnShareGlobally(); |
|
246 if ( err!=KErrNone ) |
|
247 { |
|
248 ERR_PRINTF2(KLogError, err); |
|
249 SetError(err); |
|
250 } |
|
251 } |
|