diff -r 924385140d98 -r c2c61fdca848 startupservices/Startup/syserrcmd/src/syserrcmd.cpp --- a/startupservices/Startup/syserrcmd/src/syserrcmd.cpp Tue Aug 31 15:24:25 2010 +0300 +++ b/startupservices/Startup/syserrcmd/src/syserrcmd.cpp Wed Sep 01 12:24:48 2010 +0100 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -19,15 +19,73 @@ #include "syserrcmd.h" #include "trace.h" - +#include +#include #include #include -#include +#include #include #include #include -#include + + +_LIT( KResourceFileName, "Z:startup.rsc" ); + +// ======== LOCAL FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// CSysErrorPlugin::GetResourceFileNameLC +// +// --------------------------------------------------------------------------- +// +static TFileName* GetResourceFileNameLC() + { + FUNC_LOG; + + // TParse uses a lot of stack space, so allocate it from heap. + TParse* parse = new ( ELeave ) TParse; + CleanupDeletePushL( parse ); + TInt errorCode = parse->Set( KResourceFileName, + &KDC_APP_RESOURCE_DIR, + NULL ); + ERROR( errorCode, "parse::Set() failed with error code %d" ); + User::LeaveIfError( errorCode ); + + TFileName* filename = new ( ELeave ) TFileName( parse->FullName() ); + + CleanupStack::PopAndDestroy( parse ); + CleanupDeletePushL( filename ); + INFO_1( "Resource file name: %S", filename ); + + return filename; + } + +// --------------------------------------------------------------------------- +// CSysErrorPlugin::GetFatalErrorStringLC +// +// --------------------------------------------------------------------------- +// +static TBool IsCoverUiSupported() + { + FUNC_LOG; + + // If this fails, default to false. + TRAPD( errorCode, FeatureManager::InitializeLibL() ); + ERROR( errorCode, "Failed to initialize FeatureManager" ); + + TBool retVal = EFalse; + if ( errorCode == KErrNone && + FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) + { + retVal = ETrue; + } + + FeatureManager::UnInitializeLib(); + + INFO_1( "CoverUiSupported = %d", retVal ); + return retVal; + } // ======== MEMBER FUNCTIONS ======== @@ -49,6 +107,8 @@ CSysErrCmd::~CSysErrCmd() { FUNC_LOG; + + delete iNote; } @@ -88,6 +148,15 @@ { FUNC_LOG; + if ( iNote ) + { + TInt errorCode( KErrNone ); + TRAP( errorCode, iNote->CancelNoteL( iNoteId ) ); + ERROR( errorCode, "Failed to cancel global note" ); + } + + delete iNote; // Note must be deleted here! Otherwise it doesn't complete + iNote = NULL; // request with KErrCancel and Cancel() gets stuck. } @@ -118,14 +187,34 @@ // void CSysErrCmd::DoExecuteL( TRequestStatus& aRequest ) { - aRequest = NULL; - //Hb device message box implementation for global permanent note goes here - CHbDeviceMessageBoxSymbian *aMessageBox = NULL; - aMessageBox = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EWarning); - _LIT(KText, "Self-test failed. Contact retailer."); - aMessageBox->SetTextL(KText); - aMessageBox -> SetDismissPolicy(0); - aMessageBox -> SetTimeout(0); - aMessageBox->ExecL(); - delete aMessageBox; + delete iNote; + iNote = NULL; + iNote = CAknGlobalNote::NewL(); + + if ( IsCoverUiSupported() ) + { + CAknSDData* sdData = CAknSDData::NewL( + SecondaryDisplay::KCatStartup, + SecondaryDisplay::ECmdShowErrorNote, + TPckgBuf( SecondaryDisplay::EContactService ) ); + + // ownership to notifier client + iNote->SetSecondaryDisplayData( sdData ); + } + + TFileName* filename = GetResourceFileNameLC(); + + RFs& fs = const_cast( iEnv->Rfs() ); + + CStringResourceReader* resReader = CStringResourceReader::NewLC( *filename, + fs ); + + TPtrC errorStr( resReader->ReadResourceString( + R_SU_SELFTEST_FAILED_NOTE_TEXT ) ); + + iNoteId = iNote->ShowNoteL( aRequest, EAknGlobalPermanentNote, errorStr ); + + CleanupStack::PopAndDestroy( resReader ); + CleanupStack::PopAndDestroy( filename ); + }