videditor/VideoEditorUiComponents/src/VeiErrorUi.cpp
branchRCL_3
changeset 3 e0b5df5c0969
parent 0 951a5db380a0
child 5 4c409de21d23
equal deleted inserted replaced
0:951a5db380a0 3:e0b5df5c0969
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "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 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDES
       
    21 #include <errorui.h>
       
    22 #include <StringLoader.h>
       
    23 #include <AknNoteWrappers.h>
       
    24 #include <data_caging_path_literals.hrh>
       
    25 #include <VideoeditorUiComponents.rsg>
       
    26 #include "VeiErrorUi.h"
       
    27 #include "VideoEditorDebugUtils.h"
       
    28 
       
    29 // CONSTANTS
       
    30 _LIT(KResourceFile, "VideoEditorUiComponents.rsc");
       
    31 
       
    32 
       
    33 //=============================================================================
       
    34 EXPORT_C CVeiErrorUI* CVeiErrorUI::NewL( CCoeEnv& aCoeEnv )
       
    35 	{
       
    36 	CVeiErrorUI* self = new (ELeave) CVeiErrorUI( aCoeEnv );
       
    37 	CleanupStack::PushL(self);
       
    38 	self->ConstructL();
       
    39 	CleanupStack::Pop(self);
       
    40 	return self;
       
    41 	}
       
    42 
       
    43 //=============================================================================
       
    44 void CVeiErrorUI::ConstructL()
       
    45 	{
       
    46 	iErrorUI = CErrorUI::NewL();
       
    47 
       
    48 	// Locate and open the resource file
       
    49     TFileName fileName;
       
    50     TParse p;    
       
    51 
       
    52     Dll::FileName(fileName);
       
    53     p.Set(KResourceFile, &KDC_RESOURCE_FILES_DIR, &fileName);
       
    54     fileName = p.FullName();
       
    55     
       
    56     LOGFMT(KVideoEditorLogFile, "\tLoading resource file: %S", &fileName);
       
    57 	iResLoader.OpenL( fileName ); // RConeResourceLoader selects the correct language file
       
    58 	}
       
    59 
       
    60 //=============================================================================
       
    61 CVeiErrorUI::CVeiErrorUI( CCoeEnv& aCoeEnv ) : iCoeEnv( aCoeEnv ), iResLoader( aCoeEnv )
       
    62 	{
       
    63 	}
       
    64 
       
    65 //=============================================================================
       
    66 CVeiErrorUI::~CVeiErrorUI()
       
    67 	{
       
    68 	delete iErrorUI;
       
    69 	iResLoader.Close();
       
    70 	}
       
    71 
       
    72 //=============================================================================
       
    73 EXPORT_C TInt CVeiErrorUI::ShowGlobalErrorNote( const TInt aError ) const
       
    74     {
       
    75     LOGFMT(KVideoEditorLogFile, "CVeiErrorUI::ShowGlobalErrorNoteL: In (%d)", aError);
       
    76 
       
    77 	TRAPD ( err,
       
    78 	    switch( aError )
       
    79 	        {
       
    80 	        case 0:
       
    81 	            {
       
    82 	            // do nothing to KErrNone
       
    83 	            break;
       
    84 	            }
       
    85 	        case -3:
       
    86 	            {
       
    87 	            // do nothing to KErrCancel
       
    88 	            break;
       
    89 	            }
       
    90 	        case -4: // KErrNoMemory
       
    91 	            {
       
    92 	            iErrorUI->ShowGlobalErrorNoteL( aError );
       
    93 	            break;
       
    94 	            }
       
    95 	        case -5: // KErrNotSupported
       
    96 	            {
       
    97 	            iErrorUI->ShowGlobalErrorNoteL( aError );
       
    98 	            break;
       
    99 	            }
       
   100 	        case -14: // KErrInUse
       
   101 	            {
       
   102 	            iErrorUI->ShowGlobalErrorNoteL( aError );
       
   103 	            break;
       
   104 	            }
       
   105 	        case -26: // KErrDiskFull
       
   106 	            {
       
   107 	            iErrorUI->ShowGlobalErrorNoteL( aError );
       
   108 	            break;
       
   109 	            }
       
   110 	        case -33: // KErrTimedOut
       
   111 	            {
       
   112 	            iErrorUI->ShowGlobalErrorNoteL( aError );
       
   113 	            break;
       
   114 	            }
       
   115 	        case -46: // KErrPermissionDenied
       
   116 	            {
       
   117 	            iErrorUI->ShowGlobalErrorNoteL( aError );
       
   118 	            break;
       
   119 	            }
       
   120 	        default :
       
   121 	            {
       
   122 				HBufC* stringholder;
       
   123 				stringholder = StringLoader::LoadLC( R_VEI_DEFAULT_ERROR_NOTE, &iCoeEnv );
       
   124 				CAknErrorNote* dlg = new ( ELeave ) CAknErrorNote( ETrue );
       
   125 				dlg->ExecuteLD( *stringholder );
       
   126 				CleanupStack::PopAndDestroy( stringholder );
       
   127 	            break;
       
   128 	            }
       
   129 	        }
       
   130 		);
       
   131 
       
   132     LOGFMT(KVideoEditorLogFile, "CVeiErrorUI::ShowGlobalErrorNote: Out: %d", err);
       
   133 
       
   134     return err;
       
   135     }
       
   136 
       
   137 //=============================================================================
       
   138 EXPORT_C TInt CVeiErrorUI::ShowErrorNote( CCoeEnv& aCoeEnv, const TInt aResourceId, TInt aError )
       
   139 	{
       
   140 	LOG(KVideoEditorLogFile, "CVeiErrorUI::ShowErrorNote: in");
       
   141 
       
   142 	TRAPD ( err,
       
   143 
       
   144 		HBufC* stringholder;
       
   145 		if ( aError == 0 )
       
   146 			{
       
   147 			stringholder = StringLoader::LoadLC( aResourceId, &aCoeEnv );
       
   148 			}
       
   149 		else
       
   150 			{
       
   151 			stringholder = StringLoader::LoadLC( aResourceId, aError, &aCoeEnv );
       
   152 			}
       
   153 
       
   154 		CAknErrorNote* dlg = new ( ELeave ) CAknErrorNote( ETrue );
       
   155 		dlg->ExecuteLD( *stringholder );
       
   156 
       
   157 		CleanupStack::PopAndDestroy( stringholder );
       
   158 	);
       
   159 
       
   160 	LOGFMT(KVideoEditorLogFile, "CVeiErrorUI::ShowErrorNote: out: %d", err);
       
   161 
       
   162 	return err;
       
   163 	}
       
   164 
       
   165 // End of File