|
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 the License "Symbian Foundation License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-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_DataWsPointerCursor.h" |
|
20 |
|
21 /*@{*/ |
|
22 //Commands |
|
23 _LIT(KCmdNew, "new"); |
|
24 _LIT(KCmdConstruct, "Construct"); |
|
25 |
|
26 // Fields |
|
27 _LIT(KFldWs, "ws"); |
|
28 _LIT(KFldFlag, "flag"); |
|
29 |
|
30 /// Logging |
|
31 _LIT(KLogError, "Error=%d"); |
|
32 _LIT(KLogMissingParameter, "Missing parameter '%S'"); |
|
33 |
|
34 _LIT(KLogConstruct, "execute Construct(TInt aFlags)"); |
|
35 _LIT(KLogNew, "execute new RWsPointerCursor()"); |
|
36 _LIT(KLogNew2, "execute new RWsPointerCursor(RWsSession)"); |
|
37 /*@}*/ |
|
38 |
|
39 ////////////////////////////////////////////////////////////////////// |
|
40 // Construction/Destruction |
|
41 ////////////////////////////////////////////////////////////////////// |
|
42 |
|
43 CT_DataWsPointerCursor::CT_DataWsPointerCursor() |
|
44 : CT_DataWsSpriteBase(),iWsPointerCursor(NULL) |
|
45 { |
|
46 } |
|
47 |
|
48 CT_DataWsPointerCursor* CT_DataWsPointerCursor::NewL() |
|
49 { |
|
50 CT_DataWsPointerCursor* ret=new (ELeave) CT_DataWsPointerCursor(); |
|
51 CleanupStack::PushL(ret); |
|
52 ret->ConstructL(); |
|
53 CleanupStack::Pop(ret); |
|
54 return ret; |
|
55 } |
|
56 |
|
57 void CT_DataWsPointerCursor::ConstructL() |
|
58 { |
|
59 } |
|
60 |
|
61 CT_DataWsPointerCursor::~CT_DataWsPointerCursor() |
|
62 { |
|
63 DestroyData(); |
|
64 } |
|
65 |
|
66 /** |
|
67 * Called by TEF framework to set object. |
|
68 * |
|
69 * @param: None |
|
70 * |
|
71 * @return: None |
|
72 */ |
|
73 void CT_DataWsPointerCursor::SetObjectL(TAny* aAny) |
|
74 { |
|
75 DestroyData(); |
|
76 iWsPointerCursor=static_cast<RWsPointerCursor*> (aAny); |
|
77 } |
|
78 |
|
79 /** |
|
80 * Called by TEF framework to disown the object. |
|
81 * |
|
82 * @param: None |
|
83 * |
|
84 * @return: None |
|
85 */ |
|
86 void CT_DataWsPointerCursor::DisownObjectL() |
|
87 { |
|
88 iWsPointerCursor=NULL; |
|
89 } |
|
90 |
|
91 /** |
|
92 * Destroy the object which has been constructed. |
|
93 * |
|
94 * @param: None |
|
95 * |
|
96 * @return: None |
|
97 */ |
|
98 void CT_DataWsPointerCursor::DestroyData() |
|
99 { |
|
100 delete iWsPointerCursor; |
|
101 iWsPointerCursor=NULL; |
|
102 } |
|
103 |
|
104 |
|
105 /** |
|
106 * Process a command read from the ini file |
|
107 * |
|
108 * @param aCommand the command to process |
|
109 * @param aSection the entry in the ini file requiring the command to be processed |
|
110 * @param aAsyncErrorIndex index of command. used for async calls |
|
111 * |
|
112 * @return ETrue if the command is processed |
|
113 */ |
|
114 TBool CT_DataWsPointerCursor::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
115 { |
|
116 TBool ret=ETrue; |
|
117 |
|
118 if ( aCommand==KCmdNew ) |
|
119 { |
|
120 DoCmdNewL(aSection); |
|
121 } |
|
122 else if ( aCommand==KCmdConstruct ) |
|
123 { |
|
124 DoCmdConstructL(aSection); |
|
125 } |
|
126 else |
|
127 { |
|
128 ret=CT_DataWsSpriteBase::DoCommandL(aCommand,aSection,aAsyncErrorIndex); |
|
129 } |
|
130 |
|
131 return ret; |
|
132 } |
|
133 |
|
134 /** |
|
135 * Process new command |
|
136 * |
|
137 * @param aSection the entry in the ini file requiring the command to be processed |
|
138 * |
|
139 * @return: None |
|
140 */ |
|
141 void CT_DataWsPointerCursor::DoCmdNewL(const TDesC& aSection) |
|
142 { |
|
143 TPtrC wsName; |
|
144 RWsSession* ws=NULL; |
|
145 |
|
146 if ( GetStringFromConfig(aSection, KFldWs, wsName) ) |
|
147 { |
|
148 ws=static_cast<RWsSession*>(GetDataObjectL(wsName)); |
|
149 } |
|
150 |
|
151 TInt err=KErrNone; |
|
152 |
|
153 if ( ws!=NULL ) |
|
154 { |
|
155 // Execute command and log parameters |
|
156 INFO_PRINTF1(KLogNew2); |
|
157 TRAP( err, iWsPointerCursor = new (ELeave) RWsPointerCursor(*ws)); |
|
158 } |
|
159 else |
|
160 { |
|
161 // Execute command and log parameters |
|
162 INFO_PRINTF1(KLogNew); |
|
163 TRAP( err, iWsPointerCursor = new (ELeave) RWsPointerCursor()); |
|
164 } |
|
165 |
|
166 if ( err!=KErrNone ) |
|
167 { |
|
168 ERR_PRINTF2(KLogError, err); |
|
169 SetError(err); |
|
170 } |
|
171 // No command return value and output parameter to display and check |
|
172 } |
|
173 |
|
174 |
|
175 /** |
|
176 * Process Construct command |
|
177 * |
|
178 * @param aSection the entry in the ini file requiring the command to be processed |
|
179 * |
|
180 * @return: None |
|
181 */ |
|
182 void CT_DataWsPointerCursor::DoCmdConstructL(const TDesC& aSection) |
|
183 { |
|
184 // Execute command and log parameters |
|
185 INFO_PRINTF1(KLogConstruct); |
|
186 TBool dataOk=ETrue; |
|
187 |
|
188 // Get test data for command input parameter(s) |
|
189 TUint aSpriteFlags=0; |
|
190 |
|
191 if(!CT_GraphicsUtil::ReadSpriteFlags(*this,aSection,KFldFlag,aSpriteFlags)) |
|
192 { |
|
193 dataOk=EFalse; |
|
194 ERR_PRINTF2(KLogMissingParameter, &KFldFlag); |
|
195 SetBlockResult(EFail); |
|
196 } |
|
197 |
|
198 if ( dataOk ) |
|
199 { |
|
200 // Execute command and log parameters |
|
201 INFO_PRINTF1(KLogConstruct); |
|
202 TInt returnCode=iWsPointerCursor->Construct(aSpriteFlags); |
|
203 |
|
204 // Check the command return code, if !=KErrNone then stop this command |
|
205 if ( returnCode!=KErrNone ) |
|
206 { |
|
207 ERR_PRINTF2(KLogError, returnCode); |
|
208 SetError(returnCode); |
|
209 } |
|
210 |
|
211 // No command output parameter to display and check |
|
212 } |
|
213 } |