|
1 /* |
|
2 * ============================================================================ |
|
3 * Name : CTestAppAppUi from TestAppAppUi.cpp |
|
4 * Part of : TestApp |
|
5 * ============================================================================ |
|
6 */ |
|
7 |
|
8 // INCLUDE FILES |
|
9 #include <ipssostestapp.rsg> |
|
10 |
|
11 #include <avkon.hrh> |
|
12 #include <aknnotewrappers.h> |
|
13 #include <e32property.h> |
|
14 #include <msvstd.h> |
|
15 #include <ImumDaSettingsData.h> |
|
16 #include <ImumDaSettingsDatacollection.h> |
|
17 #include <ImumDaMailboxServices.h> |
|
18 #include <ImumDaMailboxUtilities.h> |
|
19 #include <ImumDomainApi.h> |
|
20 #include <Imumdasettingskeys.h> |
|
21 #include <senduiconsts.h> |
|
22 #include <cemailaccounts.h> |
|
23 //#include <ODSUtility.h> |
|
24 |
|
25 #include "TestAppAppUi.h" |
|
26 #include "TestAppContainer.h" |
|
27 #include "TestApp.hrh" |
|
28 #include "ipssetdataapi.h" |
|
29 #include "ipssetwizardadapter.h" |
|
30 |
|
31 //#include "ODSConfigSettings.h" |
|
32 |
|
33 const TUid KTestAppCRUidWizardSettings = {0x2000B112}; |
|
34 |
|
35 const TInt KTestAppWizardDataPopIndicator = 0; |
|
36 const TInt KTestAppWizardDataImapIndicator = 1; |
|
37 |
|
38 const TInt KTestAppWizardDataSecurityOff = 0; |
|
39 const TInt KTestAppWizardDataSecurityTLS = 1; |
|
40 const TInt KTestAppWizardDataSecuritySSL = 2; |
|
41 |
|
42 _LIT( KTestAppFsBasicPluginStr, "fsp" ); |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 // ================= MEMBER FUNCTIONS ======================= |
|
48 // |
|
49 // ---------------------------------------------------------- |
|
50 // CTestAppAppUi::LaunchPluginL() |
|
51 // ---------------------------------------------------------- |
|
52 // |
|
53 void CTestAppAppUi::LaunchPluginL() |
|
54 { |
|
55 CIpsSetDataApi::LaunchSettingsL( iMailboxId ); |
|
56 } |
|
57 |
|
58 // ---------------------------------------------------------- |
|
59 // CTestAppAppUi::WriteSettingsL() |
|
60 // ---------------------------------------------------------- |
|
61 // |
|
62 void CTestAppAppUi::HandleSessionEventL( |
|
63 TMsvSessionEvent /*aEvent*/, |
|
64 TAny* /*aArg1*/, |
|
65 TAny* /*aArg2*/, |
|
66 TAny* /*aArg3*/ ) |
|
67 { |
|
68 |
|
69 } |
|
70 |
|
71 // ---------------------------------------------------------- |
|
72 // CTestAppAppUi::WriteSettingsL() |
|
73 // ---------------------------------------------------------- |
|
74 // |
|
75 void CTestAppAppUi::WriteSettingsViaODSUtilityL() |
|
76 { |
|
77 |
|
78 } |
|
79 |
|
80 |
|
81 // ---------------------------------------------------------- |
|
82 // CTestAppAppUi::WriteSettingsToWizardCenRepL() |
|
83 // ---------------------------------------------------------- |
|
84 // |
|
85 void CTestAppAppUi::WriteSettingsToWizardCenRepL() |
|
86 { |
|
87 CRepository* repository; |
|
88 repository = CRepository::NewL( KTestAppCRUidWizardSettings ); |
|
89 CleanupStack::PushL( repository ); |
|
90 TInt error = KErrNone; |
|
91 error = repository->Set( CIpsSetWizardAdapter::ECRKSetupWizAccountType, |
|
92 KTestAppFsBasicPluginStr ); |
|
93 |
|
94 error = repository->Set( CIpsSetWizardAdapter::ECRKMaxAccountsReached, |
|
95 EFalse ); |
|
96 |
|
97 |
|
98 if ( iProtocol == KSenduiMtmImap4UidValue ) |
|
99 { |
|
100 error = repository->Set( |
|
101 CIpsSetWizardAdapter::ECRKPopImapProtocolIndicatorId, |
|
102 KTestAppWizardDataImapIndicator ); |
|
103 } |
|
104 else if ( iProtocol == KSenduiMtmPop3UidValue ) |
|
105 { |
|
106 error = repository->Set( |
|
107 CIpsSetWizardAdapter::ECRKPopImapProtocolIndicatorId, |
|
108 KTestAppWizardDataPopIndicator ); |
|
109 } |
|
110 else |
|
111 { |
|
112 User::Leave( KErrArgument ); |
|
113 } |
|
114 |
|
115 |
|
116 error = repository->Set( |
|
117 CIpsSetWizardAdapter::ECRKPopImapEmailAddressId, |
|
118 iEmailAddress ); |
|
119 |
|
120 error = repository->Set( |
|
121 CIpsSetWizardAdapter::ECRKPopImapUsernameId, |
|
122 iUserName ); |
|
123 error = repository->Set( |
|
124 CIpsSetWizardAdapter::ECRKPopImapPasswordId, |
|
125 iPassword ); |
|
126 error = repository->Set( |
|
127 CIpsSetWizardAdapter::ECRKPopImapIncomingServerId, |
|
128 iIncomingServerAddress ); |
|
129 |
|
130 error = repository->Set( |
|
131 CIpsSetWizardAdapter::ECRKPopImapIncomingSecurityAuthId, 0 ); |
|
132 |
|
133 error = repository->Set( |
|
134 CIpsSetWizardAdapter::ECRKPopImapIncomingSecurityProtocolId, |
|
135 iIncomingSecurity ); |
|
136 |
|
137 error = repository->Set( |
|
138 CIpsSetWizardAdapter::ECRKPopImapIncomingPortId, |
|
139 iIncomingPort ); |
|
140 |
|
141 iOutgoingServerAddress.ZeroTerminate(); |
|
142 error = repository->Set( |
|
143 CIpsSetWizardAdapter::ECRKPopImapOutgoingServerId, |
|
144 iOutgoingServerAddress ); |
|
145 |
|
146 error = repository->Set( |
|
147 CIpsSetWizardAdapter::ECRKPopImapOutgoingSecurityAuthId, 0 ); |
|
148 |
|
149 error = repository->Set( |
|
150 CIpsSetWizardAdapter::ECRKPopImapOutgoingSecurityProtocolId, |
|
151 iOutgoingSecurity ); |
|
152 |
|
153 error = repository->Set( |
|
154 CIpsSetWizardAdapter::ECRKPopImapOutgoingPortId, |
|
155 iOutgoingPort ); |
|
156 |
|
157 error = repository->Set( |
|
158 CIpsSetWizardAdapter::ECRKPopImapAccessPointId, |
|
159 iAccessPoint ); |
|
160 |
|
161 error = repository->Set( |
|
162 CIpsSetWizardAdapter::ECRKPopImapMailboxName, |
|
163 iMailboxName ); |
|
164 |
|
165 |
|
166 CMsvSession* msvSession = CMsvSession::OpenSyncL( *this ); |
|
167 CleanupStack::PushL( msvSession ); |
|
168 CIpsSetDataApi* dataApi = CIpsSetDataApi::NewL( *msvSession ); |
|
169 CleanupStack::PushL( dataApi ); |
|
170 |
|
171 error = dataApi->HandleMailboxCreation( TUid::Uid(iProtocol), *msvSession ); |
|
172 |
|
173 CleanupStack::PopAndDestroy( 3, repository ); |
|
174 } |
|
175 // ---------------------------------------------------------- |
|
176 // CTestAppAppUi::WriteSettingsViaImumL() |
|
177 // ---------------------------------------------------------- |
|
178 // |
|
179 void CTestAppAppUi::WriteSettingsViaImumL() |
|
180 { |
|
181 CImumDomainApi* api = CreateDomainApiLC( ); |
|
182 MImumDaMailboxServices& services = api->MailboxServicesL(); |
|
183 |
|
184 CImumDaSettingsData* settings = services.CreateSettingsDataL( KNullUid ); |
|
185 CleanupStack::PushL( settings ); |
|
186 |
|
187 |
|
188 settings->SetAttr( TImumDaSettings::EKeyEmailAddress, iEmailAddress ); |
|
189 settings->SetAttr( TImumDaSettings::EKeyMailboxName, iMailboxName ); |
|
190 settings->SetAttr( TImumDaSettings::EKeyUserAlias, iUserAlias ); |
|
191 |
|
192 TUid protocolUid = KSenduiMtmImap4Uid; |
|
193 if ( TImumDaSettings::EValueProtocolPop3 == iProtocol ) |
|
194 { |
|
195 protocolUid = KSenduiMtmPop3Uid; |
|
196 } |
|
197 MImumDaSettingsDataCollection& incoming = settings->AddSetL( protocolUid ); |
|
198 |
|
199 incoming.SetAttr( TImumDaSettings::EKeyProtocol , iProtocol ); |
|
200 incoming.SetAttr( TImumDaSettings::EKeyAccessPoint, iAccessPoint ); |
|
201 incoming.SetAttr( TImumDaSettings::EKeyServer, iIncomingServerAddress ); |
|
202 incoming.SetAttr( TImumDaSettings::EKeyUsername, iUserName ); |
|
203 incoming.SetAttr( TImumDaSettings::EKeyPassword, iPassword ); |
|
204 incoming.SetAttr( TImumDaSettings::EKeyPort, iIncomingPort ); |
|
205 incoming.SetAttr( TImumDaSettings::EKeySecurity, iIncomingSecurity ); |
|
206 |
|
207 MImumDaSettingsDataCollection& smtpSettings = settings->AddSetL( KSenduiMtmSmtpUid ); |
|
208 |
|
209 smtpSettings.SetAttr( TImumDaSettings::EKeyProtocol, TImumDaSettings::EValueProtocolSmtp ); |
|
210 smtpSettings.SetAttr( TImumDaSettings::EKeyAccessPoint, iAccessPoint ); |
|
211 smtpSettings.SetAttr( TImumDaSettings::EKeyServer, iOutgoingServerAddress ); |
|
212 smtpSettings.SetAttr( TImumDaSettings::EKeySecurity, iOutgoingSecurity ); |
|
213 smtpSettings.SetAttr( TImumDaSettings::EKeyPort, iOutgoingPort ); |
|
214 |
|
215 TInt error( KErrNone ) ; |
|
216 // this leaves if incorrect settings |
|
217 TRAP( error, iMailboxId = services.CreateMailboxL( *settings ) ); |
|
218 |
|
219 CleanupStack::PopAndDestroy( 2, api ); |
|
220 if ( error == KErrNone ) |
|
221 { |
|
222 // creation is done, save id |
|
223 SetRecentMsvIdL( iMailboxId ); |
|
224 } |
|
225 else |
|
226 { |
|
227 User::Leave( error ); |
|
228 } |
|
229 |
|
230 } |
|
231 |
|
232 // ---------------------------------------------------------- |
|
233 // CTestAppAppUi::ReadSettingsL() |
|
234 // ---------------------------------------------------------- |
|
235 // |
|
236 void CTestAppAppUi::ReadSettingsL( TInt aFileId ) |
|
237 { |
|
238 TBuf<100> fileName( KIpsSosTestFilePath ); |
|
239 fileName.Append( KIpsSosTestFileName ); |
|
240 if ( KIpsSosTestDefaultFile != aFileId ) |
|
241 { |
|
242 fileName.AppendNum( aFileId ); |
|
243 } |
|
244 fileName.Append( KIpsSosTestFileExtension ); |
|
245 // open the RFs |
|
246 RFs fileSession; |
|
247 User::LeaveIfError( fileSession.Connect() ); |
|
248 CleanupClosePushL( fileSession ); // << fileSession |
|
249 |
|
250 // open the RFileReadStream |
|
251 RFileReadStream fileReader; |
|
252 User::LeaveIfError( fileReader.Open( fileSession, fileName, EFileShareExclusive ) ); |
|
253 CleanupClosePushL( fileReader ); // << fileReader |
|
254 |
|
255 TBuf8<200> lineBuffer; |
|
256 TChar delim( KIpsSosTestLineFeed ); |
|
257 |
|
258 TInt error( KErrNone ); |
|
259 while ( KErrNone == error ) // Expected KErrEof |
|
260 { |
|
261 TRAP( error, fileReader.ReadL( lineBuffer, delim ) ); |
|
262 TInt length = lineBuffer.Length(); |
|
263 if ( length ) |
|
264 { |
|
265 // remove line feed |
|
266 lineBuffer.Delete( length - KIpsSosTestDelimeterSize, KIpsSosTestDelimeterSize ); |
|
267 // remove spaces |
|
268 lineBuffer.TrimAll(); |
|
269 // ignore comment lines |
|
270 TInt comment = lineBuffer.FindF( KIpsSosTestIniCommentLine ); |
|
271 if ( KErrNotFound == comment ) |
|
272 { |
|
273 // find keys & values |
|
274 TInt separator = lineBuffer.FindF( KIpsSosTestIniSeparator ); |
|
275 if ( KErrNotFound != separator ) |
|
276 { |
|
277 TPtrC8 key( KNullDesC8 ); |
|
278 TPtrC8 value( KNullDesC8 ); |
|
279 key.Set( lineBuffer.Left( separator ) ); |
|
280 TInt valueStart( separator ); |
|
281 valueStart += KIpsSosTestIniSeparator().Length(); |
|
282 value.Set( lineBuffer.Mid( valueStart ) ); |
|
283 |
|
284 HBufC* value16 = HBufC::NewLC( value.Length() ); |
|
285 value16->Des().Copy( value ); |
|
286 // protocol |
|
287 if ( !key.CompareF( KIpsSosTestProtocol ) ) |
|
288 { |
|
289 if ( !value.CompareF( KIpsSosTestPOP ) ) |
|
290 { |
|
291 iProtocol = KSenduiMtmImap4UidValue; |
|
292 } |
|
293 else |
|
294 { |
|
295 iProtocol = KSenduiMtmPop3UidValue; |
|
296 } |
|
297 } |
|
298 // mailbox name |
|
299 else if ( !key.CompareF( KIpsSosTestMailboxName ) ) |
|
300 { |
|
301 iMailboxName = value16->Des(); |
|
302 } |
|
303 // email address |
|
304 else if ( !key.CompareF( KIpsSosTestEmailAddress ) ) |
|
305 { |
|
306 iEmailAddress = value16->Des(); |
|
307 } |
|
308 // user name |
|
309 else if ( !key.CompareF( KIpsSosTestUserName ) ) |
|
310 { |
|
311 iUserName = value16->Des(); |
|
312 } |
|
313 // password |
|
314 else if ( !key.CompareF( KIpsSosTestPassword ) ) |
|
315 { |
|
316 iPassword = value16->Des(); |
|
317 } |
|
318 // alias |
|
319 else if ( !key.CompareF( KIpsSosTestUserAlias ) ) |
|
320 { |
|
321 iUserAlias = value16->Des(); |
|
322 } |
|
323 // signature |
|
324 else if ( !key.CompareF( KIpsSosTestSignature ) ) |
|
325 { |
|
326 iSignature = value16->Des(); |
|
327 } |
|
328 // folder path |
|
329 else if ( !key.CompareF( KIpsSosTestFolderPath ) ) |
|
330 { |
|
331 iFolderPath = value16->Des(); |
|
332 } |
|
333 // access point |
|
334 else if ( !key.CompareF( KIpsSosTestAccessPoint ) ) |
|
335 { |
|
336 if ( !value.CompareF( KIpsSosTestAPAlwaysAsk) ) |
|
337 { |
|
338 |
|
339 iAccessPoint = _L(""); |
|
340 } |
|
341 else |
|
342 { |
|
343 iAccessPoint = value16->Des(); |
|
344 } |
|
345 } |
|
346 // incoming server |
|
347 else if ( !key.CompareF( KIpsSosTestIncomingServerAddress ) ) |
|
348 { |
|
349 iIncomingServerAddress = value16->Des(); |
|
350 } |
|
351 // incoming port |
|
352 else if ( !key.CompareF( KIpsSosTestIncomingPort ) ) |
|
353 { |
|
354 if ( !value.CompareF( KIpsSosTestPortValueDefault ) ) |
|
355 { |
|
356 iIncomingPort = KIpsSosTestPortDefault; |
|
357 } |
|
358 else |
|
359 { |
|
360 TLex8 lex( value ); |
|
361 TInt port = 0; |
|
362 TInt error = lex.Val( port ); |
|
363 iIncomingPort = port; |
|
364 } |
|
365 } |
|
366 // incoming security |
|
367 else if ( !key.CompareF( KIpsSosTestIncomingSecurity ) ) |
|
368 { |
|
369 if ( !value.CompareF( KIpsSosTestSecurityTls ) ) |
|
370 { |
|
371 iIncomingSecurity = KTestAppWizardDataSecurityTLS; |
|
372 } |
|
373 else if ( !value.CompareF( KIpsSosTestSecuritySsl ) ) |
|
374 { |
|
375 iIncomingSecurity = KTestAppWizardDataSecuritySSL; |
|
376 } |
|
377 else |
|
378 { |
|
379 iIncomingSecurity = KTestAppWizardDataSecurityOff; |
|
380 } |
|
381 } |
|
382 // outgoing server |
|
383 else if ( !key.CompareF( KIpsSosTestOutgoingServerAddress ) ) |
|
384 { |
|
385 iOutgoingServerAddress = value16->Des(); |
|
386 } |
|
387 // outgoing port |
|
388 else if ( !key.CompareF( KIpsSosTestOutgoingPort ) ) |
|
389 { |
|
390 if ( !value.CompareF( KIpsSosTestPortValueDefault) ) |
|
391 { |
|
392 iOutgoingPort = KIpsSosTestPortDefault; |
|
393 } |
|
394 else |
|
395 { |
|
396 TLex8 lex( value ); |
|
397 TInt port = 0; |
|
398 TInt error = lex.Val( port ); |
|
399 iOutgoingPort = port; |
|
400 } |
|
401 } |
|
402 // outgoing security |
|
403 else if ( !key.CompareF( KIpsSosTestOutgoingSecurity ) ) |
|
404 { |
|
405 if ( !value.CompareF( KIpsSosTestSecurityTls ) ) |
|
406 { |
|
407 iOutgoingSecurity = KTestAppWizardDataSecurityTLS; |
|
408 } |
|
409 else if ( !value.CompareF( KIpsSosTestSecuritySsl ) ) |
|
410 { |
|
411 iOutgoingSecurity = KTestAppWizardDataSecuritySSL; |
|
412 } |
|
413 else |
|
414 { |
|
415 iOutgoingSecurity = KTestAppWizardDataSecurityOff; |
|
416 } |
|
417 } |
|
418 else |
|
419 { |
|
420 ShowNoteL( KIpsSosTestUnknownValue ); |
|
421 } |
|
422 CleanupStack::PopAndDestroy( value16 ); |
|
423 } |
|
424 } |
|
425 } |
|
426 } |
|
427 |
|
428 // close the RFileReadStream |
|
429 CleanupStack::PopAndDestroy( &fileReader ); // >>> fileReader |
|
430 |
|
431 // close the RFs |
|
432 CleanupStack::PopAndDestroy( &fileSession ); // >>> fileSession |
|
433 |
|
434 } |
|
435 |
|
436 // ---------------------------------------------------------- |
|
437 // CTestAppAppUi::ShowNoteL() |
|
438 // ---------------------------------------------------------- |
|
439 // |
|
440 void CTestAppAppUi::ShowNoteL( const TDesC& aMessage ) |
|
441 { |
|
442 CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; |
|
443 informationNote->ExecuteLD( aMessage ); |
|
444 } |
|
445 |
|
446 // ---------------------------------------------------------- |
|
447 // CTestAppAppUi::DeleteAllSettingsL() |
|
448 // ---------------------------------------------------------- |
|
449 // |
|
450 void CTestAppAppUi::DeleteAllSettingsL( ) |
|
451 { |
|
452 TInt error( KErrNone ); |
|
453 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
|
454 // imap |
|
455 RArray<TImapAccount> imapArray; |
|
456 CleanupClosePushL( imapArray ); |
|
457 accounts->GetImapAccountsL( imapArray ); |
|
458 for ( TInt mailbox(0); mailbox < imapArray.Count(); mailbox++ ) |
|
459 { |
|
460 TImapAccount imap = imapArray[mailbox]; |
|
461 TRAP( error, accounts->DeleteImapAccountL( imap ) ); |
|
462 } |
|
463 CleanupStack::PopAndDestroy( &imapArray ); |
|
464 // pop |
|
465 RArray<TPopAccount> popArray; |
|
466 CleanupClosePushL( popArray ); |
|
467 accounts->GetPopAccountsL( popArray ); |
|
468 |
|
469 for ( TInt mailbox(0); mailbox < popArray.Count(); mailbox++ ) |
|
470 { |
|
471 TPopAccount pop = popArray[mailbox];; |
|
472 TRAP( error, accounts->DeletePopAccountL( pop ) ); |
|
473 } |
|
474 CleanupStack::PopAndDestroy( &popArray ); |
|
475 // smtp |
|
476 RArray<TSmtpAccount> smtpArray; |
|
477 accounts->GetSmtpAccountsL( smtpArray ); |
|
478 CleanupClosePushL( smtpArray ); |
|
479 |
|
480 for ( TInt mailbox(0); mailbox < smtpArray.Count(); mailbox++ ) |
|
481 { |
|
482 TSmtpAccount smtp = smtpArray[mailbox]; |
|
483 TRAP( error, accounts->DeleteSmtpAccountL( smtp ) ); |
|
484 } |
|
485 CleanupStack::PopAndDestroy( &smtpArray ); |
|
486 |
|
487 CleanupStack::PopAndDestroy( accounts ); |
|
488 } |
|
489 |
|
490 // ---------------------------------------------------------- |
|
491 // CTestAppAppUi::ConstructL() |
|
492 // ---------------------------------------------------------- |
|
493 // |
|
494 void CTestAppAppUi::ConstructL() |
|
495 { |
|
496 BaseConstructL( EAknEnableSkin ); |
|
497 iAppContainer = new (ELeave) CTestAppContainer; |
|
498 iAppContainer->SetMopParent( this ); |
|
499 iAppContainer->ConstructL( ClientRect() ); |
|
500 AddToStackL( iAppContainer ); |
|
501 } |
|
502 |
|
503 // ---------------------------------------------------- |
|
504 // CTestAppAppUi::~CTestAppAppUi() |
|
505 // Destructor |
|
506 // Frees reserved resources |
|
507 // ---------------------------------------------------- |
|
508 // |
|
509 CTestAppAppUi::~CTestAppAppUi() |
|
510 { |
|
511 if ( iAppContainer ) |
|
512 { |
|
513 RemoveFromStack( iAppContainer ); |
|
514 delete iAppContainer; |
|
515 } |
|
516 } |
|
517 |
|
518 // ------------------------------------------------------------------------------ |
|
519 // CTestAppAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) |
|
520 // This function is called by the EIKON framework just before it displays |
|
521 // a menu pane. Its default implementation is empty, and by overriding it, |
|
522 // the application can set the state of menu items dynamically according |
|
523 // to the state of application data. |
|
524 // ------------------------------------------------------------------------------ |
|
525 // |
|
526 void CTestAppAppUi::DynInitMenuPaneL( |
|
527 TInt aResourceId, CEikMenuPane* /*aMenuPane*/ ) |
|
528 { |
|
529 switch( aResourceId ) |
|
530 { |
|
531 case R_TESTAPP_MENU: |
|
532 { |
|
533 break; |
|
534 } |
|
535 default: |
|
536 { |
|
537 break; |
|
538 } |
|
539 } |
|
540 } |
|
541 |
|
542 // ---------------------------------------------------- |
|
543 // CTestAppAppUi::HandleKeyEventL( |
|
544 // const TKeyEvent& aKeyEvent,TEventCode /*aType*/) |
|
545 // ---------------------------------------------------- |
|
546 // |
|
547 TKeyResponse CTestAppAppUi::HandleKeyEventL( |
|
548 const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/) |
|
549 { |
|
550 return EKeyWasNotConsumed; |
|
551 } |
|
552 |
|
553 // ---------------------------------------------------- |
|
554 // CTestAppAppUi::HandleCommandL(TInt aCommand) |
|
555 // ---------------------------------------------------- |
|
556 // |
|
557 void CTestAppAppUi::HandleCommandL(TInt aCommand) |
|
558 { |
|
559 switch ( aCommand ) |
|
560 { |
|
561 case EAknSoftkeyExit: |
|
562 case EEikCmdExit: |
|
563 { |
|
564 Exit(); |
|
565 break; |
|
566 } |
|
567 case ETest1Cmd: |
|
568 { |
|
569 // read settings |
|
570 TInt error( KErrNone ); |
|
571 TRAP( error, ReadSettingsL( KIpsSosTestDefaultFile ) ); |
|
572 if ( KErrNone != error ) |
|
573 { |
|
574 if ( KErrNotFound == error ) |
|
575 { |
|
576 ShowNoteL( KIpsSosTestFileNotFound ); |
|
577 } |
|
578 else |
|
579 { |
|
580 ShowNoteL( KIpsSosTestErrorInReading ); |
|
581 } |
|
582 return; |
|
583 } |
|
584 // write settings |
|
585 TRAP( error, WriteSettingsToWizardCenRepL() ); |
|
586 if ( KErrNone != error ) |
|
587 { |
|
588 ShowNoteL( KIpsSosTestErrorInWriting ); |
|
589 } |
|
590 else |
|
591 { |
|
592 ShowNoteL( KIpsSosTestSettingsCreated ); |
|
593 } |
|
594 break; |
|
595 } |
|
596 case ETest2Cmd: |
|
597 { |
|
598 // query |
|
599 TInt queryValue( KErrNotFound ); |
|
600 CAknNumberQueryDialog* dlg = CAknNumberQueryDialog::NewL( queryValue, CAknQueryDialog::ENoTone ); |
|
601 dlg->PrepareLC( R_NUMBER_QUERY_DIALOG ); |
|
602 dlg->SetPromptL( _L("Give init file id") ); |
|
603 TInt ret = dlg->RunLD(); |
|
604 TInt error( KErrNone ); |
|
605 // read settings |
|
606 TRAP( error, ReadSettingsL( queryValue ) ); |
|
607 if ( KErrNone != error ) |
|
608 { |
|
609 if ( KErrNotFound == error ) |
|
610 { |
|
611 ShowNoteL( KIpsSosTestFileNotFound ); |
|
612 } |
|
613 else |
|
614 { |
|
615 ShowNoteL( KIpsSosTestErrorInReading ); |
|
616 } |
|
617 return; |
|
618 } |
|
619 // write settings |
|
620 TRAP( error, WriteSettingsToWizardCenRepL() ); |
|
621 if ( KErrNone != error ) |
|
622 { |
|
623 ShowNoteL( KIpsSosTestErrorInWriting ); |
|
624 return; |
|
625 } |
|
626 // launch plugin |
|
627 TRAP( error, LaunchPluginL() ); |
|
628 if ( KErrNone != error ) |
|
629 { |
|
630 ShowNoteL( KIpsSosTestErrorLaunching ); |
|
631 } |
|
632 break; |
|
633 } |
|
634 case ETest3Cmd: |
|
635 { |
|
636 TMsvId recent = RecentMsvId(); |
|
637 if ( KErrNotFound != recent ) |
|
638 { |
|
639 iMailboxId = recent; |
|
640 // launch plugin |
|
641 TInt error( KErrNone ); |
|
642 TRAP( error, LaunchPluginL() ); |
|
643 if ( KErrNone != error ) |
|
644 { |
|
645 ShowNoteL( KIpsSosTestErrorLaunching ); |
|
646 } |
|
647 } |
|
648 else |
|
649 { |
|
650 ShowNoteL( KIpsSosTestRecentNotFound ); |
|
651 } |
|
652 break; |
|
653 } |
|
654 |
|
655 default: |
|
656 User::Leave( KErrArgument ); |
|
657 break; |
|
658 } |
|
659 } |
|
660 |
|
661 // ---------------------------------------------------------- |
|
662 // CTestAppAppUi::SetRecentMsvIdL() |
|
663 // ---------------------------------------------------------- |
|
664 // |
|
665 void CTestAppAppUi::SetRecentMsvIdL( TMsvId aMsvId ) |
|
666 { |
|
667 // define integer-type property |
|
668 TInt err = RProperty::Define( KIpsSosTestPropertyCat, EIpsSosTestRecentMsvId, RProperty::EInt ); |
|
669 if ( KErrAlreadyExists != err && KErrNone != err ) |
|
670 { |
|
671 User::Leave( err ); |
|
672 } |
|
673 // publish property using category and key |
|
674 err = RProperty::Set( KIpsSosTestPropertyCat, EIpsSosTestRecentMsvId, aMsvId ); |
|
675 } |
|
676 |
|
677 // ---------------------------------------------------------- |
|
678 // CTestAppAppUi::RecentMsvId() |
|
679 // ---------------------------------------------------------- |
|
680 // |
|
681 TMsvId CTestAppAppUi::RecentMsvId( ) |
|
682 { |
|
683 TInt recent( KErrNotFound ); |
|
684 // get property using category and key |
|
685 TInt err = RProperty::Get( KIpsSosTestPropertyCat, EIpsSosTestRecentMsvId, recent ); |
|
686 return recent; |
|
687 } |
|
688 |
|
689 |
|
690 // End of File |