commonuis/CommonUi/src/ErrorUI.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include    <AknGlobalNote.h>
       
    22 #include    <AknGlobalConfirmationQuery.h>
       
    23 #include    "ErrorUI.h"
       
    24 #include    <avkon.rsg>
       
    25 
       
    26 EXPORT_C CErrorUI* CErrorUI::NewL()
       
    27     {
       
    28     CErrorUI* me;
       
    29     me = ConstructLC();
       
    30     CleanupStack::Pop();
       
    31     return me;
       
    32     }
       
    33 
       
    34 EXPORT_C CErrorUI* CErrorUI::NewLC()
       
    35     {
       
    36     return ConstructLC();
       
    37     }
       
    38 
       
    39 
       
    40 
       
    41 CErrorUI* CErrorUI::ConstructLC()
       
    42     {
       
    43     CErrorUI* me;
       
    44     me = new (ELeave) CErrorUI();
       
    45     CleanupStack::PushL(me);
       
    46     me->ConstructL();
       
    47     return me;  
       
    48     }
       
    49 
       
    50 EXPORT_C CErrorUI* CErrorUI::NewL(CCoeEnv& aEnv)
       
    51     {
       
    52     CErrorUI* me = CErrorUI::NewLC(aEnv);
       
    53     CleanupStack::Pop();
       
    54     return me;
       
    55     }
       
    56 
       
    57 EXPORT_C CErrorUI* CErrorUI::NewLC(CCoeEnv& /*aEnv*/)
       
    58     {
       
    59     CErrorUI* me;
       
    60     me = new (ELeave) CErrorUI();
       
    61     CleanupStack::PushL(me);
       
    62     me->ConstructL();
       
    63     return me;
       
    64     }
       
    65 
       
    66 EXPORT_C CErrorUI::~CErrorUI()
       
    67     { 
       
    68     delete iTextResolver;
       
    69     }
       
    70 
       
    71 EXPORT_C TBool CErrorUI::ShowGlobalErrorNoteL
       
    72         (
       
    73         TInt aError,
       
    74         CTextResolver::TErrorContext Context
       
    75         )
       
    76     {
       
    77     
       
    78     TInt resourceID = 0;
       
    79     TUint flags = 0;
       
    80     TPtrC errorstring = iTextResolver->ResolveErrorString(aError,resourceID,flags,Context);
       
    81     if ( !(flags & ETextResolverBlankErrorFlag) )
       
    82         {
       
    83         CAknGlobalNote * note1 = CAknGlobalNote::NewL();
       
    84         CleanupStack::PushL(note1);
       
    85         if ( aError == KErrDiskFull ) 
       
    86             {
       
    87             note1->SetSoftkeys(R_AVKON_SOFTKEYS_OK_EMPTY);
       
    88             }
       
    89         note1->ShowNoteL( EAknGlobalErrorNote, (TDesC&)errorstring );
       
    90 
       
    91         CleanupStack::PopAndDestroy();  // note1
       
    92         return ETrue;
       
    93         }
       
    94         
       
    95     return EFalse;
       
    96     }
       
    97 
       
    98 EXPORT_C TBool CErrorUI::ShowGlobalErrorQueryL(TInt aError, CTextResolver::TErrorContext Context)
       
    99     { 
       
   100     // Copy-Paste code, but I see no sense in creating two internal methods to save two rows code.
       
   101     TInt resourceID = 0;
       
   102     TUint flags = 0;
       
   103     TPtrC errorstring = iTextResolver->ResolveErrorString(aError,resourceID,flags,Context);
       
   104     if ( !(flags & ETextResolverBlankErrorFlag) )
       
   105         {
       
   106         CAknGlobalNote * note1 = CAknGlobalNote::NewL();
       
   107         CleanupStack::PushL(note1);
       
   108         
       
   109         note1->SetSoftkeys(R_AVKON_SOFTKEYS_OK_EMPTY);
       
   110         note1->ShowNoteL( EAknGlobalErrorNote, (TDesC&)errorstring );
       
   111 
       
   112         CleanupStack::PopAndDestroy();  // note1
       
   113         return ETrue;
       
   114         }
       
   115         
       
   116     return EFalse;
       
   117     }
       
   118 
       
   119 void CErrorUI::ConstructL()
       
   120     {
       
   121     iTextResolver = CTextResolver::NewL();
       
   122     }
       
   123 
       
   124 
       
   125 // End of File