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_DataBackedUpWindow.h" |
|
19 #include "T_GraphicsUtil.h" |
|
20 |
|
21 /*@{*/ |
|
22 _LIT(KDataClassname, "RBackedUpWindow"); |
|
23 |
|
24 //Commands |
|
25 _LIT(KCmdnew, "new"); |
|
26 _LIT(KCmdDestructor, "~"); |
|
27 _LIT(KCmdConstruct, "Construct"); |
|
28 _LIT(KCmdBitmapHandle, "BitmapHandle"); |
|
29 _LIT(KCmdUpdateScreen, "UpdateScreen"); |
|
30 _LIT(KCmdUpdateBackupBitmap, "UpdateBackupBitmap"); |
|
31 _LIT(KCmdMaintainBackup, "MaintainBackup"); |
|
32 |
|
33 // Fields |
|
34 _LIT(KFldDisplayMode, "displaymode"); |
|
35 _LIT(KFldHandle, "handle"); |
|
36 _LIT(KFldParent, "parent"); |
|
37 _LIT(KFldRegion, "region"); |
|
38 _LIT(KFldWs, "ws"); |
|
39 |
|
40 /// Logging |
|
41 _LIT(KLogError, "Error=%d"); |
|
42 _LIT(KLogMissingParameter, "Missing parameter '%S'"); |
|
43 /*@}*/ |
|
44 |
|
45 ////////////////////////////////////////////////////////////////////// |
|
46 // Construction/Destruction |
|
47 ////////////////////////////////////////////////////////////////////// |
|
48 |
|
49 CT_DataBackedUpWindow* CT_DataBackedUpWindow::NewL() |
|
50 { |
|
51 CT_DataBackedUpWindow* ret=new (ELeave) CT_DataBackedUpWindow(); |
|
52 CleanupStack::PushL(ret); |
|
53 ret->ConstructL(); |
|
54 CleanupStack::Pop(ret); |
|
55 return ret; |
|
56 } |
|
57 |
|
58 CT_DataBackedUpWindow::CT_DataBackedUpWindow() |
|
59 : CT_DataDrawableWindow() |
|
60 , iBackedUpWindow(NULL) |
|
61 { |
|
62 } |
|
63 |
|
64 void CT_DataBackedUpWindow::ConstructL() |
|
65 { |
|
66 } |
|
67 |
|
68 CT_DataBackedUpWindow::~CT_DataBackedUpWindow() |
|
69 { |
|
70 DestroyData(); |
|
71 } |
|
72 |
|
73 void CT_DataBackedUpWindow::SetObjectL(TAny* aAny) |
|
74 { |
|
75 DestroyData(); |
|
76 iBackedUpWindow = static_cast<RBackedUpWindow*> (aAny); |
|
77 } |
|
78 |
|
79 void CT_DataBackedUpWindow::DestroyData() |
|
80 { |
|
81 delete iBackedUpWindow; |
|
82 iBackedUpWindow=NULL; |
|
83 } |
|
84 |
|
85 void CT_DataBackedUpWindow::DisownObjectL() |
|
86 { |
|
87 iBackedUpWindow = NULL; |
|
88 } |
|
89 |
|
90 RDrawableWindow* CT_DataBackedUpWindow::GetDrawableWindow() const |
|
91 { |
|
92 return iBackedUpWindow; |
|
93 } |
|
94 |
|
95 /** |
|
96 * Process a command read from the ini file |
|
97 * |
|
98 * @param aCommand the command to process |
|
99 * @param aSection the entry in the ini file requiring the command to be processed |
|
100 * @param aAsyncErrorIndex index of command. used for async calls |
|
101 * |
|
102 * @return ETrue if the command is processed |
|
103 */ |
|
104 TBool CT_DataBackedUpWindow::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
105 { |
|
106 TBool ret = ETrue; |
|
107 |
|
108 if ( aCommand==KCmdDestructor ) |
|
109 { |
|
110 DestroyData(); |
|
111 } |
|
112 else if ( aCommand==KCmdnew || aCommand==KDataClassname ) |
|
113 { |
|
114 DoCmdnewL(aSection); |
|
115 } |
|
116 else if ( aCommand==KCmdConstruct ) |
|
117 { |
|
118 DoCmdConstructL(aSection); |
|
119 } |
|
120 else if ( aCommand==KCmdBitmapHandle ) |
|
121 { |
|
122 DoCmdBitmapHandle(); |
|
123 } |
|
124 else if ( aCommand==KCmdUpdateScreen ) |
|
125 { |
|
126 DoCmdUpdateScreenL(aSection); |
|
127 } |
|
128 else if ( aCommand==KCmdUpdateBackupBitmap ) |
|
129 { |
|
130 DoCmdUpdateBackupBitmap(); |
|
131 } |
|
132 else if ( aCommand==KCmdMaintainBackup ) |
|
133 { |
|
134 DoCmdMaintainBackup(); |
|
135 } |
|
136 else |
|
137 { |
|
138 ret=CT_DataDrawableWindow::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
139 } |
|
140 |
|
141 return ret; |
|
142 } |
|
143 |
|
144 |
|
145 void CT_DataBackedUpWindow::DoCmdnewL(const TDesC& aSection) |
|
146 { |
|
147 DestroyData(); |
|
148 |
|
149 // Get test data for command input parameter(s) |
|
150 TPtrC wsName; |
|
151 RWsSession* ws=NULL; |
|
152 if ( GetStringFromConfig(aSection, KFldWs, wsName) ) |
|
153 { |
|
154 ws = static_cast<RWsSession*>(GetDataObjectL(wsName)); |
|
155 } |
|
156 |
|
157 TInt err=KErrNone; |
|
158 if ( ws!=NULL ) |
|
159 { |
|
160 // Execute command and log parameters |
|
161 INFO_PRINTF1(_L("execute new RBackedUpWindow(RWsSession)")); |
|
162 TRAP( err, iBackedUpWindow = new (ELeave) RBackedUpWindow(*ws)); |
|
163 } |
|
164 else |
|
165 { |
|
166 // Execute command and log parameters |
|
167 INFO_PRINTF1(_L("execute new RBackedUpWindow()")); |
|
168 TRAP( err, iBackedUpWindow = new (ELeave) RBackedUpWindow()); |
|
169 } |
|
170 |
|
171 if ( err!=KErrNone ) |
|
172 { |
|
173 ERR_PRINTF2(KLogError, err); |
|
174 SetError(err); |
|
175 } |
|
176 } |
|
177 |
|
178 |
|
179 void CT_DataBackedUpWindow::DoCmdConstructL(const TDesC& aSection) |
|
180 { |
|
181 TBool dataOk=ETrue; |
|
182 |
|
183 // Get test data for command input parameter(s) |
|
184 TPtrC parentName; |
|
185 RWindowTreeNode* parent=NULL; |
|
186 if ( GetStringFromConfig(aSection, KFldParent, parentName) ) |
|
187 { |
|
188 parent = static_cast<RWindowTreeNode*>(GetDataObjectL(parentName)); |
|
189 } |
|
190 if ( parent==NULL ) |
|
191 { |
|
192 dataOk=EFalse; |
|
193 ERR_PRINTF2(KLogMissingParameter, &KFldParent); |
|
194 SetBlockResult(EFail); |
|
195 } |
|
196 |
|
197 TDisplayMode datDisplayMode; |
|
198 if ( !CT_GraphicsUtil::ReadDisplayMode(*this, aSection, KFldDisplayMode, datDisplayMode) ) |
|
199 { |
|
200 dataOk=EFalse; |
|
201 ERR_PRINTF2(KLogMissingParameter, &KFldDisplayMode); |
|
202 SetBlockResult(EFail); |
|
203 } |
|
204 |
|
205 TInt datHandle; |
|
206 if ( !GetIntFromConfig(aSection, KFldHandle, datHandle) ) |
|
207 { |
|
208 dataOk=EFalse; |
|
209 ERR_PRINTF2(KLogMissingParameter, &KFldHandle); |
|
210 SetBlockResult(EFail); |
|
211 } |
|
212 |
|
213 if ( dataOk ) |
|
214 { |
|
215 // Execute command and log parameters |
|
216 INFO_PRINTF1(_L("execute Construct(RWindowTreeNode, TDisplayMode, TUint32)")); |
|
217 TInt returnCode = iBackedUpWindow->Construct(*parent, datDisplayMode, datHandle); |
|
218 |
|
219 // Check the command return code, if !=KErrNone then stop this command |
|
220 if ( returnCode!=KErrNone ) |
|
221 { |
|
222 ERR_PRINTF2(KLogError, returnCode); |
|
223 SetError(returnCode); |
|
224 } |
|
225 |
|
226 // No command output parameter to display and check |
|
227 } |
|
228 } |
|
229 |
|
230 |
|
231 void CT_DataBackedUpWindow::DoCmdBitmapHandle() |
|
232 { |
|
233 // Execute command and log parameters |
|
234 TInt handle=iBackedUpWindow->BitmapHandle(); |
|
235 INFO_PRINTF2(_L("BitmapHandle() %d"), handle); |
|
236 SetHandle(handle); |
|
237 } |
|
238 |
|
239 |
|
240 void CT_DataBackedUpWindow::DoCmdUpdateScreenL(const TDesC& aSection) |
|
241 { |
|
242 // Get test data for command input parameter(s) |
|
243 RRegion region(1); |
|
244 CleanupClosePushL(region); |
|
245 |
|
246 if ( GetRegionFromConfig(aSection, KFldRegion, region) ) |
|
247 { |
|
248 // Execute command and log parameters |
|
249 INFO_PRINTF1(_L("execute UpdateScreen(TRegion)")); |
|
250 iBackedUpWindow->UpdateScreen(region); |
|
251 |
|
252 // No command return value and output parameter to display and check |
|
253 } |
|
254 else |
|
255 { |
|
256 // Execute command and log parameters |
|
257 INFO_PRINTF1(_L("execute UpdateScreen()")); |
|
258 iBackedUpWindow->UpdateScreen(); |
|
259 |
|
260 // No command return value and output parameter to display and check |
|
261 } |
|
262 |
|
263 CleanupStack::PopAndDestroy(®ion); |
|
264 } |
|
265 |
|
266 |
|
267 void CT_DataBackedUpWindow::DoCmdUpdateBackupBitmap() |
|
268 { |
|
269 // No command input parameter to process |
|
270 |
|
271 // Execute command and log parameters |
|
272 INFO_PRINTF1(_L("execute UpdateBackupBitmap()")); |
|
273 iBackedUpWindow->UpdateBackupBitmap(); |
|
274 |
|
275 // No command return value and output parameter to display and check |
|
276 } |
|
277 |
|
278 |
|
279 void CT_DataBackedUpWindow::DoCmdMaintainBackup() |
|
280 { |
|
281 // No command input parameter to process |
|
282 |
|
283 // Execute command and log parameters |
|
284 INFO_PRINTF1(_L("execute MaintainBackup()")); |
|
285 iBackedUpWindow->MaintainBackup(); |
|
286 |
|
287 // No command return value and output parameter to display and check |
|
288 } |
|