// ----------------------------------------------------------------------------- // CLocalizationAppUi::HandleCommandL() // Takes care of command handling. // ----------------------------------------------------------------------------- // void CLocalizationAppUi::HandleCommandL( TInt aCommand ) { switch( aCommand ) { case EEikCmdExit: case EAknSoftkeyExit: Exit(); break; // Number case ELocalizationCommandNumber: { // buffer for localized text TBuf<50> myBuf; // Amount to show TReal myAmount = 1234.567; // Real number formatter, initialized with system's current locale settings TRealFormat myFormat; // Format real with current locales decimal separator setting myBuf.AppendNum(myAmount, myFormat); // Show formatted text CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; informationNote->ExecuteLD( myBuf ); } break; // Currency case ELocalizationCommandCurrency: { // locale is initialized with system's current locale settings TLocale myLocale; // buffer for localized text TBuf<50> myBuf; // amount is integer, but it is treated as last two digits // were decimal digits e.g. 1249 = 12.49, 2 = 0.02 ... TInt myAmount = 123456789; // Format currency according to current locale settings myLocale.FormatCurrency(myBuf, myAmount); // Show formatted text CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; informationNote->ExecuteLD( myBuf ); } break; // Date case ELocalizationCommandDate: { // buffer for localized text TBuf<50> myBuf; // Object for datetime data TTime myDate; // Set current datetime to object myDate.HomeTime(); // Format date according to current locale settings // Format string is universal, so that whatever the locale is, // date is always formatted correctly myDate.FormatL(myBuf, _L("%/0%1%/1%2%/2%3%/3%X")); // Show formatted text CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; informationNote->ExecuteLD( myBuf ); } break; // Time case ELocalizationCommandTime: { // buffer for localized text TBuf<50> myBuf; // Object for datetime data TTime myTime; // Set current datetime to object myTime.HomeTime(); // Format time to current locale // Format string is universal, so that whatever the locale is, // time is always formatted correctly myTime.FormatL(myBuf, _L("%-B%:0%J%:1%T%:2%S%:3%+B")); // Show formatted text CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; informationNote->ExecuteLD( myBuf ); } break; // Text case ELocalizationCommandText: { // buffer for string parameters that may change order CDesCArrayFlat* strings = new CDesCArrayFlat( 2 ); CleanupStack::PushL( strings ); // Initialize parameter buffer // First parameter strings->AppendL( _L("Heidi") ); // Second parameter strings->AppendL( _L("2") ); // Load a string from the resource file, and append parameters into it HBufC* textResource = StringLoader::LoadL( R_LOC_COMMANDTEXT_TEXT, *strings ); CleanupStack::PushL( textResource ); // Show formatted text CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; informationNote->ExecuteLD( *textResource ); // Cleanupstack CleanupStack::PopAndDestroy( textResource ); CleanupStack::PopAndDestroy( strings ); } break; // Image case ELocalizationCommandImage: { // find the drive where the app has been installed TParse parse; parse.Set(Application()->AppFullName(),0,0); // Load bitmap name from the resource file HBufC* bmpFile = StringLoader::LoadLC( R_LOC_COMMANDIMAGE_BMPFILE, parse.Drive()); // bitmap pointer CFbsBitmap* bitmap; // Create and Load the Bitmap bitmap = new( ELeave )CFbsBitmap; CleanupStack::PushL( bitmap ); // Load the first bitmap (index 0) from multi-bitmap file User::LeaveIfError(bitmap->Load( *bmpFile, 0 )); CleanupStack::Pop( bitmap ); // Draw bitmap to screen // ownership of bitmap is transferred to view iAppView->DrawImage( bitmap ); // Cleanupstack CleanupStack::PopAndDestroy( bmpFile ); } break; // Default case default: break; } }
// ----------------------------------------------------------------------------- // CHelloS60AppUi::HandleCommandL() // Takes care of command handling. // ----------------------------------------------------------------------------- // void CHelloS60AppUi::HandleCommandL(TInt aCommand) { switch (aCommand) { case EEikCmdExit: case EAknSoftkeyExit: Exit(); break; case ECommand1: { // Load a string from the resource file and display it HBufC* textResource = StringLoader::LoadLC(R_COMMAND1_TEXT); CAknInformationNote* informationNote; informationNote = new (ELeave) CAknInformationNote; // Show the information Note with // textResource loaded with StringLoader. informationNote->ExecuteLD(*textResource); // Pop HBuf from CleanUpStack and Destroy it. CleanupStack::PopAndDestroy(textResource); } break; case ECommand2: { RFile rFile; //Open file where the stream text is User::LeaveIfError(rFile.Open(CCoeEnv::Static()->FsSession(), KFileName, EFileStreamText));//EFileShareReadersOnly));// EFileStreamText)); CleanupClosePushL(rFile); // copy stream from file to RFileStream object RFileReadStream inputFileStream(rFile); CleanupClosePushL(inputFileStream); // HBufC descriptor is created from the RFileStream object. HBufC* fileData = HBufC::NewLC(inputFileStream, 32); CAknInformationNote* informationNote; informationNote = new (ELeave) CAknInformationNote; // Show the information Note informationNote->ExecuteLD(*fileData); // Pop loaded resources from the cleanup stack CleanupStack::PopAndDestroy(3); // filedata, inputFileStream, rFile } break; case EHelp: { CArrayFix<TCoeHelpContext>* buf = CCoeAppUi::AppHelpContextL(); HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf); } break; case EAbout: { CAknMessageQueryDialog* dlg = new (ELeave) CAknMessageQueryDialog(); dlg->PrepareLC(R_ABOUT_QUERY_DIALOG); HBufC* title = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TITLE); dlg->QueryHeading()->SetTextL(*title); CleanupStack::PopAndDestroy(); //title HBufC* msg = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TEXT); dlg->SetMessageTextL(*msg); CleanupStack::PopAndDestroy(); //msg dlg->RunLD(); } break; default: Panic( EHelloS60Ui); break; } }
void CIncallertAppUi::HandleCommandL(TInt aCommand) { switch(aCommand) { case EAknSoftkeyExit: //flow through to next case case EEikCmdExit: { if(!iAutoStarted) Exit(); else { TTime now; now.HomeTime(); TTimeIntervalMicroSeconds diff = now.MicroSecondsFrom(iStartTime); if(diff<=TTimeIntervalMicroSeconds(5)) { //auto started apps must not exit sooner than 5 secs or phone might say our app has corrupted iEikonEnv->RootWin().SetOrdinalPosition(-1,ECoeWinPriorityNeverAtFront); if(!iExitTimer)//if not already started exit timer { iExitTimer = CPeriodic::NewL(0); iExitTimer->Start( 5000000, 5000000, TCallBack(ExitTimerCallBack,this)); } } else Exit(); //app was already started long enough } return; } default: break; } if(CAknViewAppUi::iView == iAppView) { switch(aCommand) { case EIncallertSettingsCommand: { this->iLineStatusHandler->PlaySoundTest(); iTabGroup->SetActiveTabById(ENavigationPaneSettingsViewId); ActivateLocalViewL(TUid::Uid(iTabGroup->ActiveTabId())); }; break; case EAknSoftkeyDone: { _LIT(msg,"Switching to Background"); CAknInformationNote* informationNote = new (ELeave) CAknInformationNote(ETrue); informationNote->SetTimeout(CAknNoteDialog::EShortTimeout); informationNote->ExecuteLD(msg); TApaTask task(iEikonEnv->WsSession( )); task.SetWgId(CEikonEnv::Static()->RootWin().Identifier()); task.SendToBackground(); } break; case EIncallertHelpCommand: { iTabGroup->SetActiveTabById(ENavigationPaneHelpViewId); ActivateLocalViewL(TUid::Uid(iTabGroup->ActiveTabId())); }; break; case EIncallertAboutCommand: { iTabGroup->SetActiveTabById(ENavigationPaneAboutViewId); ActivateLocalViewL(TUid::Uid(iTabGroup->ActiveTabId())); }; break; default: break; } } else if(CAknViewAppUi::iView == iHelpAppView || CAknViewAppUi::iView == iAboutAppView) { iTabGroup->SetActiveTabById(ENavigationPaneStatusViewId); ActivateLocalViewL(TUid::Uid(iTabGroup->ActiveTabId())); } }