|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "coredumpui.h" |
|
17 #include <optionconfig.h> |
|
18 #include <bautils.h> |
|
19 |
|
20 |
|
21 // CDialogBase // |
|
22 |
|
23 CCoreDumpDialogBase::CCoreDumpDialogBase(RCoreDumpSession &aCoreDumpSession) |
|
24 : iCoreDumpSession(aCoreDumpSession) |
|
25 { |
|
26 } |
|
27 |
|
28 CCoreDumpDialogBase::~CCoreDumpDialogBase() |
|
29 { |
|
30 iConfs.ResetAndDestroy(); |
|
31 } |
|
32 |
|
33 void CCoreDumpDialogBase::DisplayErrorL(TDesC& aMessage, TInt aErrorNumber) |
|
34 { |
|
35 //could check doesn't go out of bounds |
|
36 TBuf<250> errorMssge(aMessage); |
|
37 errorMssge.Append(_L(" fails with system error no. ")); |
|
38 TBuf<3> errorNum; |
|
39 _LIT(KFormatDec, "%d"); |
|
40 errorNum.Format(KFormatDec, aErrorNumber); |
|
41 errorMssge.Append(errorNum); |
|
42 iEikonEnv->InfoWinL(_L("Error"), errorMssge); |
|
43 } |
|
44 |
|
45 void CCoreDumpDialogBase::DisplayErrorL(TDesC& aMessage) |
|
46 { |
|
47 //could check don't go out of bounds |
|
48 TBuf<250> errorMssge(aMessage); |
|
49 iEikonEnv->InfoWinL(_L("Error"), errorMssge); |
|
50 } |
|
51 |
|
52 |
|
53 // CConfigurePluginDialog // |
|
54 |
|
55 CConfigurePluginDialog::CConfigurePluginDialog(TUid aUid, RCoreDumpSession &aCoreDumpSession, TInt aInstance) |
|
56 : CCoreDumpDialogBase(aCoreDumpSession), iUid(aUid), iInstance(aInstance) |
|
57 { |
|
58 } |
|
59 |
|
60 CConfigurePluginDialog::~CConfigurePluginDialog() |
|
61 { |
|
62 iConfs.ResetAndDestroy(); |
|
63 } |
|
64 |
|
65 void CConfigurePluginDialog::PreLayoutDynInitL() |
|
66 { |
|
67 UpdateDialogDataL(); |
|
68 } |
|
69 |
|
70 void CConfigurePluginDialog::PostLayoutDynInitL() |
|
71 { |
|
72 } |
|
73 |
|
74 void CConfigurePluginDialog::UpdateDialogDataL() |
|
75 { |
|
76 //update dialog |
|
77 //RDebug::Print(_L("CConfigurePluginDialog::UpdateDialogDataL()")); |
|
78 LOG_MSG("->[UI]CConfigurePluginDialog::UpdateDialogDataL()"); |
|
79 |
|
80 RPointerArray<CEikEdwin> edwins; |
|
81 RPointerArray<CEikLabel> labels; |
|
82 CEikEdwin *edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin1)); |
|
83 edwins.Append(edwin); |
|
84 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin2)); |
|
85 edwins.Append(edwin); |
|
86 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin3)); |
|
87 edwins.Append(edwin); |
|
88 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin4)); |
|
89 edwins.Append(edwin); |
|
90 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin5)); |
|
91 edwins.Append(edwin); |
|
92 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin6)); |
|
93 edwins.Append(edwin); |
|
94 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin7)); |
|
95 edwins.Append(edwin); |
|
96 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin8)); |
|
97 edwins.Append(edwin); |
|
98 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin9)); |
|
99 edwins.Append(edwin); |
|
100 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin10)); |
|
101 edwins.Append(edwin); |
|
102 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin11)); |
|
103 edwins.Append(edwin); |
|
104 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin12)); |
|
105 edwins.Append(edwin); |
|
106 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin13)); |
|
107 edwins.Append(edwin); |
|
108 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin14)); |
|
109 edwins.Append(edwin); |
|
110 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin15)); |
|
111 edwins.Append(edwin); |
|
112 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin16)); |
|
113 edwins.Append(edwin); |
|
114 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin17)); |
|
115 edwins.Append(edwin); |
|
116 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin18)); |
|
117 edwins.Append(edwin); |
|
118 for (TInt i = 0; i < edwins.Count(); i++) |
|
119 { |
|
120 edwins[i]->SetDimmed(ETrue); |
|
121 edwins[i]->SetReadOnly(ETrue); |
|
122 } |
|
123 |
|
124 CEikLabel *label = static_cast<CEikLabel*>(Control(EPluginLabel1)); |
|
125 labels.Append(label); |
|
126 label = static_cast<CEikLabel*>(Control(EPluginLabel2)); |
|
127 labels.Append(label); |
|
128 label = static_cast<CEikLabel*>(Control(EPluginLabel3)); |
|
129 labels.Append(label); |
|
130 label = static_cast<CEikLabel*>(Control(EPluginLabel4)); |
|
131 labels.Append(label); |
|
132 label = static_cast<CEikLabel*>(Control(EPluginLabel5)); |
|
133 labels.Append(label); |
|
134 label = static_cast<CEikLabel*>(Control(EPluginLabel6)); |
|
135 labels.Append(label); |
|
136 label = static_cast<CEikLabel*>(Control(EPluginLabel7)); |
|
137 labels.Append(label); |
|
138 label = static_cast<CEikLabel*>(Control(EPluginLabel8)); |
|
139 labels.Append(label); |
|
140 label = static_cast<CEikLabel*>(Control(EPluginLabel9)); |
|
141 labels.Append(label); |
|
142 label = static_cast<CEikLabel*>(Control(EPluginLabel10)); |
|
143 labels.Append(label); |
|
144 label = static_cast<CEikLabel*>(Control(EPluginLabel11)); |
|
145 labels.Append(label); |
|
146 label = static_cast<CEikLabel*>(Control(EPluginLabel12)); |
|
147 labels.Append(label); |
|
148 label = static_cast<CEikLabel*>(Control(EPluginLabel13)); |
|
149 labels.Append(label); |
|
150 label = static_cast<CEikLabel*>(Control(EPluginLabel14)); |
|
151 labels.Append(label); |
|
152 label = static_cast<CEikLabel*>(Control(EPluginLabel15)); |
|
153 labels.Append(label); |
|
154 label = static_cast<CEikLabel*>(Control(EPluginLabel16)); |
|
155 labels.Append(label); |
|
156 label = static_cast<CEikLabel*>(Control(EPluginLabel17)); |
|
157 labels.Append(label); |
|
158 label = static_cast<CEikLabel*>(Control(EPluginLabel18)); |
|
159 labels.Append(label); |
|
160 |
|
161 |
|
162 // Read config parameters from CDS |
|
163 //RDebug::Print(_L("Read config parameters from CDS")); |
|
164 TInt noConfigParams = 0; |
|
165 iConfs.ResetAndDestroy(); |
|
166 |
|
167 LOG_MSG("\tiCoreDumpSession.GetNumberConfigParametersL()"); |
|
168 TRAPD(err, noConfigParams = iCoreDumpSession.GetNumberConfigParametersL()); |
|
169 if(err != KErrNone) |
|
170 { |
|
171 TBuf<23> error; |
|
172 error.Format(_L("Error: %d"), err); |
|
173 CEikonEnv::InfoWinL(_L("Could not get number of config params!"), error); |
|
174 User::Leave(err); |
|
175 } |
|
176 |
|
177 TInt control = 0; |
|
178 LOG_MSG2( "CConfigurePluginDialog::UpdateDialogDataL: noConfigParams: %d", noConfigParams); |
|
179 for (TInt i = 0; i < noConfigParams; i++) |
|
180 { |
|
181 COptionConfig* conf; |
|
182 RDebug::Printf("Getting ID = %d", i); |
|
183 conf = iCoreDumpSession.GetConfigParameterL(i); |
|
184 if (iUid == TUid::Uid(conf->Uid()) && iInstance == conf->Instance()) |
|
185 { |
|
186 iConfs.Append(conf); |
|
187 TBuf<255> buf = conf->Prompt(); |
|
188 switch (conf->Type()) |
|
189 { |
|
190 case COptionConfig::ETInt: |
|
191 { |
|
192 buf.Append(_L("\n(Signed int)")); |
|
193 TBuf<255> value; |
|
194 value.Format(_L("%d"), iConfs[control]->Value()); |
|
195 edwins[control]->SetTextL(&value); |
|
196 } |
|
197 break; |
|
198 |
|
199 case COptionConfig::ETUInt: |
|
200 { |
|
201 buf.Append(_L("\n(Unsigned int)")); |
|
202 TBuf<255> value; |
|
203 value.Format(_L("%d"), iConfs[control]->Value()); |
|
204 edwins[control]->SetTextL(&value); |
|
205 } |
|
206 break; |
|
207 |
|
208 case COptionConfig::ETString: |
|
209 { |
|
210 buf.Append(_L("\n(String)")); |
|
211 edwins[control]->SetTextL(&(iConfs[control]->ValueAsDesc())); |
|
212 } |
|
213 break; |
|
214 |
|
215 case COptionConfig::ETFileName: |
|
216 { |
|
217 buf.Append(_L("\n(File name)")); |
|
218 /* |
|
219 RDebug::Print(_L("edwins[control]->SetTextL(ValueAsDesc() Length=%d"), |
|
220 (iConfs[control]->ValueAsDesc()).Size() ); |
|
221 */ |
|
222 edwins[control]->SetTextL(&(iConfs[control]->ValueAsDesc())); |
|
223 } |
|
224 break; |
|
225 |
|
226 case COptionConfig::ETSingleEntryEnum: |
|
227 { |
|
228 buf.Append(_L("\n")); |
|
229 buf.Append(conf->Options()); |
|
230 edwins[control]->SetTextL(&(iConfs[control]->ValueAsDesc())); |
|
231 } |
|
232 break; |
|
233 |
|
234 case COptionConfig::ETMultiEntryEnum: |
|
235 { |
|
236 buf.Append(_L("\n")); |
|
237 buf.Append(conf->Options()); |
|
238 edwins[control]->SetTextL(&(iConfs[control]->ValueAsDesc())); |
|
239 } |
|
240 break; |
|
241 |
|
242 case COptionConfig::ETBool: |
|
243 { |
|
244 buf.Append(_L("\n")); |
|
245 buf.Append(conf->Options()); |
|
246 TBuf<255> value; |
|
247 iConfs[control]->Value() ? value = _L("True") : value = _L("False"); |
|
248 edwins[control]->SetTextL(&value); |
|
249 } |
|
250 break; |
|
251 |
|
252 default: |
|
253 break; |
|
254 } |
|
255 labels[control]->SetTextL(buf); |
|
256 edwins[control]->SetDimmed(EFalse); |
|
257 edwins[control++]->SetReadOnly(EFalse); |
|
258 } |
|
259 else |
|
260 { |
|
261 delete conf; |
|
262 } |
|
263 } |
|
264 edwins.Close(); |
|
265 labels.Close(); |
|
266 } |
|
267 |
|
268 TBool CConfigurePluginDialog::OkToExitL(TInt aButtonId) |
|
269 { |
|
270 LOG_MSG( "-> CConfigurePluginDialog::::OkToExitL" ); |
|
271 TBool ret = ETrue; |
|
272 TInt err; |
|
273 |
|
274 RPointerArray<CEikEdwin> edwins; |
|
275 CEikEdwin *edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin1)); |
|
276 edwins.Append(edwin); |
|
277 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin2)); |
|
278 edwins.Append(edwin); |
|
279 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin3)); |
|
280 edwins.Append(edwin); |
|
281 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin4)); |
|
282 edwins.Append(edwin); |
|
283 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin5)); |
|
284 edwins.Append(edwin); |
|
285 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin6)); |
|
286 edwins.Append(edwin); |
|
287 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin7)); |
|
288 edwins.Append(edwin); |
|
289 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin8)); |
|
290 edwins.Append(edwin); |
|
291 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin9)); |
|
292 edwins.Append(edwin); |
|
293 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin10)); |
|
294 edwins.Append(edwin); |
|
295 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin11)); |
|
296 edwins.Append(edwin); |
|
297 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin12)); |
|
298 edwins.Append(edwin); |
|
299 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin13)); |
|
300 edwins.Append(edwin); |
|
301 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin14)); |
|
302 edwins.Append(edwin); |
|
303 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin15)); |
|
304 edwins.Append(edwin); |
|
305 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin16)); |
|
306 edwins.Append(edwin); |
|
307 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin17)); |
|
308 edwins.Append(edwin); |
|
309 edwin = static_cast<CEikEdwin*>(Control(EPluginEdwin18)); |
|
310 edwins.Append(edwin); |
|
311 |
|
312 switch (aButtonId) |
|
313 { |
|
314 case EEikBidCancel: |
|
315 { |
|
316 //RDebug::Print(_L("CConfigurePluginDialog::OkToExitL: Cancel pressed")); |
|
317 } |
|
318 break; |
|
319 case EBidPluginConfigure: |
|
320 { |
|
321 RDebug::Print(_L("CConfigurePluginDialog::OkToExitL: iConfs.Count() == %d"), iConfs.Count()); |
|
322 for (TInt i = 0; i < iConfs.Count(); i++) |
|
323 { |
|
324 err = KErrNone; |
|
325 HBufC *input = NULL; |
|
326 if (edwins[i]->TextLength() > 0) |
|
327 { |
|
328 input = edwins[i]->GetTextInHBufL(); |
|
329 } |
|
330 if ( ! input ) |
|
331 { |
|
332 input = HBufC::NewL(KMaxFileName); |
|
333 TPtr ptr(input->Des()); |
|
334 ptr = KNullDesC; |
|
335 } |
|
336 |
|
337 RDebug::Print(_L("CConfigurePluginDialog::OkToExitL: input == %S"), input); |
|
338 RDebug::Print(_L("CConfigurePluginDialog::OkToExitL: iConfs[i]->Type() == %d"), iConfs[i]->Type()); |
|
339 |
|
340 switch (iConfs[i]->Type()) |
|
341 { |
|
342 case COptionConfig::ETInt: |
|
343 case COptionConfig::ETUInt: |
|
344 { |
|
345 TLex opts(*input); |
|
346 TInt32 conf; |
|
347 //RDebug::Print(_L("err = opts.Val(conf);")); |
|
348 err = opts.Val(conf); |
|
349 //RDebug::Print(_L("CConfigurePluginDialog::err = opts.Val(conf);")); |
|
350 if ( err ) |
|
351 { |
|
352 LOG_MSG("CConfigurePluginDialog::CEikonEnv::Static()->InfoMsg;"); |
|
353 CEikonEnv::Static()->InfoMsg(_L("Value must be an integer")); |
|
354 break; |
|
355 } |
|
356 |
|
357 iConfs[i]->Value(conf); |
|
358 TRAP( err, iCoreDumpSession.SetConfigParameterL( *iConfs[i]) ); |
|
359 } |
|
360 break; |
|
361 case COptionConfig::ETFileName: |
|
362 case COptionConfig::ETString: |
|
363 case COptionConfig::ETSingleEntryEnum: |
|
364 case COptionConfig::ETMultiEntryEnum: |
|
365 { |
|
366 TRAP( err, iConfs[i]->ValueL(*input) ); |
|
367 if ( KErrNone == err ) |
|
368 { |
|
369 TRAP( err, iCoreDumpSession.SetConfigParameterL( *iConfs[i]) ); |
|
370 } |
|
371 } |
|
372 break; |
|
373 |
|
374 case COptionConfig::ETBool: |
|
375 if (input->CompareF(_L("True"))== 0) |
|
376 { |
|
377 //RDebug::Print(_L("input->CompareF(_L(True))== 0")); |
|
378 iConfs[i]->Value(ETrue); |
|
379 iConfs[i]->ValueL(_L("True")); |
|
380 } |
|
381 else if (input->CompareF(_L("False"))== 0) |
|
382 { |
|
383 //RDebug::Print(_L("input->CompareF(_L(False))== 0")); |
|
384 iConfs[i]->Value(EFalse); |
|
385 iConfs[i]->ValueL(_L("False")); |
|
386 } |
|
387 else |
|
388 { |
|
389 LOG_MSG( " CConfigurePluginDialog::OkToExitL err = KErrCorrupt" ); |
|
390 err = KErrCorrupt; |
|
391 } |
|
392 |
|
393 if( KErrNone == err ) |
|
394 { |
|
395 TRAP( err, iCoreDumpSession.SetConfigParameterL( *iConfs[i]) ); |
|
396 RDebug::Print(_L("CConfigurePluginDialog::OkToExitL: SetConfigParameterL ret %d"), err); |
|
397 } |
|
398 break; |
|
399 |
|
400 default: |
|
401 CEikonEnv::Static()->InfoMsg(_L("Error with parameter type")); |
|
402 LOG_MSG("CConfigurePluginDialog::OkToExitL: none of the above" ); |
|
403 LOG_MSG("default err = KErrCorrupt"); |
|
404 err = KErrCorrupt; |
|
405 break; |
|
406 } |
|
407 |
|
408 if ( err != KErrNone ) |
|
409 { |
|
410 RBuf errorString; |
|
411 CleanupClosePushL( errorString ); |
|
412 errorString.CreateL( 128 ); |
|
413 errorString.Append( _L("Config Plugin - Error ") ); |
|
414 errorString.AppendNum( err ); |
|
415 errorString.Append( _L(" setting parameter number ") ); |
|
416 errorString.AppendNum( i ); |
|
417 CEikonEnv::InfoWinL( errorString, KNullDesC ); |
|
418 CleanupStack::PopAndDestroy( &errorString ); |
|
419 ret = EFalse; |
|
420 } |
|
421 if(input) |
|
422 { |
|
423 delete input; |
|
424 input = NULL; |
|
425 } |
|
426 }//for |
|
427 }//switch |
|
428 break; |
|
429 default: |
|
430 break; |
|
431 } |
|
432 //RDebug::Print(_L("<--------- CConfigurePluginDialog::OkToExitL")); |
|
433 edwins.Close(); |
|
434 return ret; |
|
435 } |
|
436 |