📄 magictrainappui.cpp
字号:
{
if (iTSSResult) {
iTSSResult->ResetAndDestroy();
iTSSResult = NULL;
}
iTSSResult = new RPointerArray<CTSSResult>(10);
TInt err = iEngine->GetTrainByTwoStations(iStationName1,iStationName2,iTSSResult);
if (err == -1)
{
HBufC* noteText;
noteText = StringLoader::LoadLC(R_ASKSTATION_NOSTATION);
CAknInformationNote* note = new (ELeave) CAknInformationNote();
note->ExecuteLD(*noteText);
CleanupStack::PopAndDestroy(noteText);
}else if(err == -2)
{
HBufC* noteText;
noteText = StringLoader::LoadLC(R_ASKSTATION_NORESULT);
CAknInformationNote* note = new (ELeave) CAknInformationNote();
note->ExecuteLD(*noteText);
CleanupStack::PopAndDestroy(noteText);
}
if (!iTSSResult || iTSSResult->Count() == 0) {
HBufC* noteText;
noteText = StringLoader::LoadLC(R_ASKSTATION_NORESULT);
CAknInformationNote* note = new (ELeave) CAknInformationNote();
note->ExecuteLD(*noteText);
CleanupStack::PopAndDestroy(noteText);
break;
}
SetMenuBar(EStationResult);
iAppView->SetTSSResult(iStationName1,iStationName2,iTSSResult);
}else {
HBufC* noteText;
noteText = StringLoader::LoadLC(R_ASKSTATION_NOTINPUT);
CAknInformationNote* note = new (ELeave) CAknInformationNote();
note->ExecuteLD(*noteText);
CleanupStack::PopAndDestroy(noteText);
}
}
break;
case EAskTrainOk:
{
static_cast<CEikEdwin*>(( iAskTrainDialog->Control( EAsktrainDlgCIdNameEditor ) ) )->GetText( iTrainName );
if ( iAskTrainDialog )
{
RemoveFromStack( iAskTrainDialog );
delete iAskTrainDialog;
iAskTrainDialog = NULL;
}
if (iTrainName.Length() > 0)
{
if (iOTResult) {
iOTResult->ResetAndDestroy();
iOTResult = NULL;
}
iOTResult = new RPointerArray<COTResult>(10);
iTrainName.UpperCase();
if (iEngine->GetTrainByTrainName(iTrainName,iOTResult))
{
if (iOTResult->Count() == 0) {
HBufC* noteText;
noteText = StringLoader::LoadLC(R_ASKTRAIN_NORESULT);
CAknInformationNote* note = new (ELeave) CAknInformationNote();
note->ExecuteLD(*noteText);
CleanupStack::PopAndDestroy(noteText);
break;
}
SetMenuBar(ETrainResult);
iAppView->SetOTResult(iTrainName,iOTResult);
}else{
HBufC* noteText;
noteText = StringLoader::LoadLC(R_ASKTRAIN_NOTRAIN);
CAknInformationNote* note = new (ELeave) CAknInformationNote();
note->ExecuteLD(*noteText);
CleanupStack::PopAndDestroy(noteText);
}
}else {
HBufC* noteText;
noteText = StringLoader::LoadLC(R_ASKTRAIN_NOTINPUT);
CAknInformationNote* note = new (ELeave) CAknInformationNote();
note->ExecuteLD(*noteText);
CleanupStack::PopAndDestroy(noteText);
}
}
break;
case EAskTrainCancel:
{
if ( iAskTrainDialog )
{
RemoveFromStack( iAskTrainDialog );
delete iAskTrainDialog;
iAskTrainDialog = NULL;
}
SetMenuBar(EResultNew);
}
break;
case EAskOneStationCancel:
{
if ( iAskOneStationDialog )
{
RemoveFromStack( iAskOneStationDialog );
delete iAskOneStationDialog;
iAskOneStationDialog = NULL;
}
SetMenuBar(EResultNew);
}
break;
case EAskStationCancel:
{
if ( iAskStationDialog )
{
RemoveFromStack( iAskStationDialog );
delete iAskStationDialog;
iAskStationDialog = NULL;
}
SetMenuBar(EResultNew);
}
break;
case EResultNew:
{
iAppView->iStatus = EInitStatus;
SetMenuBar(EResultNew);
SetMenuBar(EShowMenu);
iAppView->DrawDeferred();
}
break;
case EStationBack:
{
SetMenuBar(EStationResult);
iAppView->SetTSSResult(iStationName1,iStationName2,iTSSResult);
break;
}
break;
case EOneStationBack:
{
SetMenuBar(EStationResult);
iAppView->SetOSResult(iStationName,iOSResult);
}
break;
case EOneStationTrainResult:
{
iTrainName.Copy(iAppView->GetOneStationSelectTrain());
if (iTrainName.Length() > 0)
{
if (iOTResult) {
iOTResult->ResetAndDestroy();
iOTResult = NULL;
}
iOTResult = new RPointerArray<COTResult>(10);
if (iEngine->GetTrainByTrainName(iTrainName,iOTResult))
{
if (iOTResult->Count() == 0) {
HBufC* noteText;
noteText = StringLoader::LoadLC(R_ASKTRAIN_NORESULT);
CAknInformationNote* note = new (ELeave) CAknInformationNote();
note->ExecuteLD(*noteText);
CleanupStack::PopAndDestroy(noteText);
break;
}
SetMenuBar(R_ONESTATIONTRAINRESULT_MENU);
iAppView->SetOTResult(iTrainName,iOTResult);
}else{
HBufC* noteText;
noteText = StringLoader::LoadLC(R_ASKTRAIN_NOTRAIN);
CAknInformationNote* note = new (ELeave) CAknInformationNote();
note->ExecuteLD(*noteText);
CleanupStack::PopAndDestroy(noteText);
}
}else {
HBufC* noteText;
noteText = StringLoader::LoadLC(R_ASKTRAIN_NOTINPUT);
CAknInformationNote* note = new (ELeave) CAknInformationNote();
note->ExecuteLD(*noteText);
CleanupStack::PopAndDestroy(noteText);
}
}
break;
case EStationTrainResult:
{
iTrainName.Copy(iAppView->GetNowSelectTrain());
if (iTrainName.Length() > 0)
{
if (iOTResult) {
iOTResult->ResetAndDestroy();
iOTResult = NULL;
}
iOTResult = new RPointerArray<COTResult>(10);
if (iEngine->GetTrainByTrainName(iTrainName,iOTResult))
{
if (iOTResult->Count() == 0) {
HBufC* noteText;
noteText = StringLoader::LoadLC(R_ASKTRAIN_NORESULT);
CAknInformationNote* note = new (ELeave) CAknInformationNote();
note->ExecuteLD(*noteText);
CleanupStack::PopAndDestroy(noteText);
break;
}
SetMenuBar(R_STATIONTRAINRESULT_MENU);
iAppView->SetOTResult(iTrainName,iOTResult);
}else{
HBufC* noteText;
noteText = StringLoader::LoadLC(R_ASKTRAIN_NOTRAIN);
CAknInformationNote* note = new (ELeave) CAknInformationNote();
note->ExecuteLD(*noteText);
CleanupStack::PopAndDestroy(noteText);
}
}else {
HBufC* noteText;
noteText = StringLoader::LoadLC(R_ASKTRAIN_NOTINPUT);
CAknInformationNote* note = new (ELeave) CAknInformationNote();
note->ExecuteLD(*noteText);
CleanupStack::PopAndDestroy(noteText);
}
}
break;
case ETrainResultDetail:
{
iAppView->ShowTrainResultDetail();
}
break;
case EUpdate:
// LaunchWapBrowswerL(updateurl);
{
if (!iDownloadEntity)
iDownloadEntity = CDownloadEntity::NewL(iFs,*this);
TBuf8<256> updateurl;
updateurl.Copy(KUpdateS);
TFileName downloadfile;
downloadfile.Copy(iDataPath);
downloadfile.Append(_L("update.html"));
iDownloadEntity->Initialize(updateurl,downloadfile);
iUpdateStatus = EUSSV;
}
break;
case EAbout:
{
HBufC* r_about = StringLoader::LoadLC( R_ABOUT);
HBufC* r_about_text = StringLoader::LoadLC( R_ABOUT_TEXT);
CEikonEnv::InfoWinL(r_about->Des(),r_about_text->Des());
CleanupStack::PopAndDestroy(2);
}
break;
default:
{
//// Panic( ETrainUi );
}
break;
}
}
void CMagicTrainAppUi::SetMenuBar(TInt a)
{
CEikMenuBar* menubar = iEikonEnv->AppUiFactory()->MenuBar();
if (a == EStationResult)
{
menubar->SetMenuTitleResourceId(R_STATIONRESULT_MENU);
// menubar->TryDisplayMenuBarL();
}else if(a == ETrainResult)
{
menubar->SetMenuTitleResourceId(R_TRAINRESULT_MENU);
}else if(a == EResultNew)
{
menubar->SetMenuTitleResourceId(R_MENUBAR);
//menubar->TryDisplayMenuBarL();
}else if (a == R_STATIONTRAINRESULT_MENU) {
menubar->SetMenuTitleResourceId(R_STATIONTRAINRESULT_MENU);
}else if (a == R_ONESTATIONRESULT_MENU) {
menubar->SetMenuTitleResourceId(R_ONESTATIONRESULT_MENU);
}else if (a == R_ONESTATIONTRAINRESULT_MENU) {
menubar->SetMenuTitleResourceId(R_ONESTATIONTRAINRESULT_MENU);
}
else if(a == EShowMenu)
{
menubar->TryDisplayMenuBarL();
}
}
// -----------------------------------------------------------------------------
// Called by the framework when the application status pane
// size is changed. Passes the new client rectangle to the
// AppView
// -----------------------------------------------------------------------------
//
void CMagicTrainAppUi::HandleResourceChangeL( TInt aType )
{
CAknAppUi::HandleResourceChangeL( aType );
if ( aType == KEikDynamicLayoutVariantSwitch )
{
iAppView->SizeChanged();
}
}
const TUid KPhoneUidWmlBrowser = { 0x10008D39 };
void CMagicTrainAppUi::LaunchWapBrowswerL(const TDesC& aAddr )
{
TUid id( KPhoneUidWmlBrowser );
TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
TApaTask task = taskList.FindApp( id );
if ( task.Exists() )
{
HBufC8* param8 = HBufC8::NewLC( aAddr.Length() );
param8->Des().Append( aAddr );
task.SendMessage( TUid::Uid( 0 ), *param8 ); // UID is not used
CleanupStack::PopAndDestroy( param8 );
}
else
{
if ( !iApaLsSession.Handle() )
{
User::LeaveIfError( iApaLsSession.Connect() );
}
TThreadId thread;
User::LeaveIfError( iApaLsSession.StartDocument( aAddr, KPhoneUidWmlBrowser, thread ) );
}
}
void CMagicTrainAppUi::DownloadFinished(TDownloadStatus aStatus)
{
if (aStatus == EDownloaded && iUpdateStatus == EUSSV) {
RFileReadStream rs;
TInt err;
TFileName downloadfile;
downloadfile.Copy(iDataPath);
downloadfile.Append(_L("update.html"));
err = rs.Open(iFs,downloadfile,EFileRead);
if (err == KErrNone) {
TBuf<1000> words;
TRAP(err,rs.ReadL(words,1000););
TBuf<10> version(GetLastVersion(words));
if (version.Compare(iVersion) >0) {
CAknMessageQueryDialog* updateDlg = CAknMessageQueryDialog::NewL( words );
updateDlg->PrepareLC(R_AVKON_MESSAGE_QUERY_DIALOG);
HBufC* updatesoft = iEikonEnv->AllocReadResourceLC(R_UPDATE_SOFT);
updateDlg->QueryHeading()->SetTextL(*updatesoft);
CleanupStack::PopAndDestroy(updatesoft);
if( updateDlg->RunLD() )
{
TBuf<256> updateurl;
updateurl.Copy(KDownSis);
updateurl.Append(GetLastVersion(words));
updateurl.Append(KDownSisExt);
LaunchWapBrowswerL(updateurl);
}else{
if (!iDownloadEntity)
iDownloadEntity = CDownloadEntity::NewL(iFs,*this);
TBuf8<256> updateurl;
updateurl.Copy(KUpdateD);
updateurl.Append(iDataVersion8);
updateurl.Append(KUpdateDExt8);
TFileName downloadfile;
downloadfile.Copy(iDataPath);
downloadfile.Append(iDataVersion);
downloadfile.Append(KUpdateDExt);
iDownloadEntity->Initialize(updateurl,downloadfile);
iUpdateStatus = EUSDV;
}
}else{
HBufC* r_nosoft_update = StringLoader::LoadLC( R_NOSOFT_UPDATE);
HBufC* r_update_title = StringLoader::LoadLC( R_UPDATE_TITLE);
CEikonEnv::InfoWinL(r_update_title->Des(),r_nosoft_update->Des());
CleanupStack::PopAndDestroy(2);
if (!iDownloadEntity)
iDownloadEntity = CDownloadEntity::NewL(iFs,*this);
TBuf8<256> updateurl;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -