startupservices/Startup/syserrcmd/src/syserrcmd.cpp
branchRCL_3
changeset 63 c2c61fdca848
parent 62 924385140d98
child 66 9af619316cbf
equal deleted inserted replaced
62:924385140d98 63:c2c61fdca848
     1 /*
     1 /*
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17 */
    17 */
    18 
    18 
    19 #include "syserrcmd.h"
    19 #include "syserrcmd.h"
    20 #include "trace.h"
    20 #include "trace.h"
    21 
    21 
    22 
    22 #include <AknGlobalNote.h>
       
    23 #include <aknSDData.h>
    23 #include <data_caging_path_literals.hrh>
    24 #include <data_caging_path_literals.hrh>
    24 #include <featmgr.h>
    25 #include <featmgr.h>
    25 #include <SecondaryDisplay/SecondaryDisplayStartupAPI.h>
    26 #include <secondarydisplay/SecondaryDisplayStartupAPI.h>
    26 #include <StringLoader.h>
    27 #include <StringLoader.h>
    27 #include <startup.rsg>
    28 #include <startup.rsg>
    28 #include <stringresourcereader.h>
    29 #include <stringresourcereader.h>
    29 #include <hb/hbwidgets/hbdevicemessageboxsymbian.h>
    30 
    30 
    31 
       
    32 _LIT( KResourceFileName, "Z:startup.rsc" );
       
    33 
       
    34 // ======== LOCAL FUNCTIONS ========
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // CSysErrorPlugin::GetResourceFileNameLC
       
    38 //
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 static TFileName* GetResourceFileNameLC()
       
    42     {
       
    43     FUNC_LOG;
       
    44 
       
    45     // TParse uses a lot of stack space, so allocate it from heap.
       
    46     TParse* parse = new ( ELeave ) TParse; 
       
    47     CleanupDeletePushL( parse );
       
    48     TInt errorCode = parse->Set( KResourceFileName, 
       
    49                                  &KDC_APP_RESOURCE_DIR, 
       
    50                                  NULL );
       
    51     ERROR( errorCode, "parse::Set() failed with error code %d" );
       
    52     User::LeaveIfError( errorCode );
       
    53 
       
    54     TFileName* filename = new ( ELeave ) TFileName( parse->FullName() );
       
    55 
       
    56     CleanupStack::PopAndDestroy( parse );
       
    57     CleanupDeletePushL( filename );
       
    58 
       
    59     INFO_1( "Resource file name: %S", filename );
       
    60 
       
    61     return filename;
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // CSysErrorPlugin::GetFatalErrorStringLC
       
    66 //
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 static TBool IsCoverUiSupported()
       
    70     {
       
    71     FUNC_LOG;
       
    72 
       
    73     // If this fails, default to false.
       
    74     TRAPD( errorCode, FeatureManager::InitializeLibL() ); 
       
    75     ERROR( errorCode, "Failed to initialize FeatureManager" );
       
    76 
       
    77     TBool retVal = EFalse;
       
    78     if ( errorCode == KErrNone &&
       
    79          FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
       
    80         {
       
    81         retVal = ETrue;
       
    82         }
       
    83 
       
    84     FeatureManager::UnInitializeLib();
       
    85 
       
    86     INFO_1( "CoverUiSupported = %d", retVal );
       
    87     return retVal;
       
    88     }
    31 
    89 
    32 // ======== MEMBER FUNCTIONS ========
    90 // ======== MEMBER FUNCTIONS ========
    33 
    91 
    34 // ---------------------------------------------------------------------------
    92 // ---------------------------------------------------------------------------
    35 // CSysErrCmd::NewL
    93 // CSysErrCmd::NewL
    47 // ---------------------------------------------------------------------------
   105 // ---------------------------------------------------------------------------
    48 //
   106 //
    49 CSysErrCmd::~CSysErrCmd()
   107 CSysErrCmd::~CSysErrCmd()
    50     {
   108     {
    51     FUNC_LOG;
   109     FUNC_LOG;
       
   110     
       
   111     delete iNote;
    52     }
   112     }
    53 
   113 
    54 
   114 
    55 // ---------------------------------------------------------------------------
   115 // ---------------------------------------------------------------------------
    56 // CSysErrCmd::Initialize
   116 // CSysErrCmd::Initialize
    86 //
   146 //
    87 void CSysErrCmd::ExecuteCancel()
   147 void CSysErrCmd::ExecuteCancel()
    88     {
   148     {
    89     FUNC_LOG;
   149     FUNC_LOG;
    90 
   150 
       
   151     if ( iNote )
       
   152         {
       
   153         TInt errorCode( KErrNone );
       
   154         TRAP( errorCode, iNote->CancelNoteL( iNoteId ) );
       
   155         ERROR( errorCode, "Failed to cancel global note" );
       
   156         }
       
   157 
       
   158     delete iNote; // Note must be deleted here! Otherwise it doesn't complete
       
   159     iNote = NULL; // request with KErrCancel and Cancel() gets stuck.
    91     }
   160     }
    92 
   161 
    93 
   162 
    94 // ---------------------------------------------------------------------------
   163 // ---------------------------------------------------------------------------
    95 // CSysErrCmd::Close
   164 // CSysErrCmd::Close
   116 // CSysErrCmd::DoExecuteL
   185 // CSysErrCmd::DoExecuteL
   117 // ---------------------------------------------------------------------------
   186 // ---------------------------------------------------------------------------
   118 //
   187 //
   119 void CSysErrCmd::DoExecuteL( TRequestStatus& aRequest )
   188 void CSysErrCmd::DoExecuteL( TRequestStatus& aRequest )
   120     {
   189     {
   121     aRequest = NULL;
   190     delete iNote;
   122 	//Hb device message box implementation for global permanent note goes here
   191     iNote = NULL;
   123 	CHbDeviceMessageBoxSymbian *aMessageBox = NULL;
   192     iNote = CAknGlobalNote::NewL();
   124     aMessageBox = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EWarning);
   193 
   125     _LIT(KText, "Self-test failed. Contact retailer.");
   194     if ( IsCoverUiSupported() )
   126     aMessageBox->SetTextL(KText);
   195         {
   127     aMessageBox -> SetDismissPolicy(0);
   196         CAknSDData* sdData = CAknSDData::NewL( 
   128 	aMessageBox -> SetTimeout(0);
   197                         SecondaryDisplay::KCatStartup,
   129     aMessageBox->ExecL();
   198                         SecondaryDisplay::ECmdShowErrorNote,
   130 	delete aMessageBox;
   199                         TPckgBuf<TInt>( SecondaryDisplay::EContactService ) );
   131     }
   200         
       
   201         // ownership to notifier client
       
   202         iNote->SetSecondaryDisplayData( sdData ); 
       
   203         }
       
   204 
       
   205     TFileName* filename = GetResourceFileNameLC();
       
   206     
       
   207     RFs& fs = const_cast<RFs&>( iEnv->Rfs() );
       
   208     
       
   209     CStringResourceReader* resReader = CStringResourceReader::NewLC( *filename,
       
   210                                                                      fs );
       
   211     
       
   212     TPtrC errorStr( resReader->ReadResourceString( 
       
   213                                             R_SU_SELFTEST_FAILED_NOTE_TEXT ) );
       
   214 
       
   215     iNoteId = iNote->ShowNoteL( aRequest, EAknGlobalPermanentNote, errorStr );
       
   216     
       
   217     CleanupStack::PopAndDestroy( resReader );
       
   218     CleanupStack::PopAndDestroy( filename );
       
   219     
       
   220     }