appinstaller/AppinstUi/sisxsifplugin/src/sisxsifpluginerrorhandler.cpp
branchRCL_3
changeset 25 7333d7932ef7
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
       
     1 /*
       
     2 * Copyright (c) 2008-2010 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:  CSisxSifPluginError collects information about errors.
       
    15 *               Error details are then passed to framework (USIF).
       
    16 *
       
    17 */
       
    18 
       
    19 #include "sisxsifpluginerrorhandler.h"      // CSisxSifPluginErrorHandler
       
    20 #include <swi/sisinstallerrors.h>           // SWI error codes
       
    21 #include <usif/sif/sifcommon.h>             // COpaqueNamedParams
       
    22 #include "sisxsifplugin.pan"                // Panic codes
       
    23 
       
    24 using namespace Usif;
       
    25 
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // CSisxSifPluginErrorHandler::NewL()
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CSisxSifPluginErrorHandler* CSisxSifPluginErrorHandler::NewL()
       
    34     {
       
    35     CSisxSifPluginErrorHandler* self = new ( ELeave ) CSisxSifPluginErrorHandler;
       
    36     CleanupStack::PushL( self );
       
    37     self->ConstructL();
       
    38     CleanupStack::Pop( self );
       
    39     return self;
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CSisxSifPluginErrorHandler::~CSisxSifPluginErrorHandler()
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CSisxSifPluginErrorHandler::~CSisxSifPluginErrorHandler()
       
    47     {
       
    48     delete iErrorMessage;
       
    49     delete iErrorMessageDetails;
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // CSisxSifPluginErrorHandler::ErrorCategory()
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 TErrorCategory CSisxSifPluginErrorHandler::ErrorCategory() const
       
    57     {
       
    58     switch( iErrorCode )
       
    59         {
       
    60         // System-wide error codes
       
    61         case KErrNone:
       
    62             return ENone;
       
    63         case KErrNotFound:
       
    64         case KErrGeneral:
       
    65             return EUnexpectedError;
       
    66         case KErrCancel:
       
    67             return EUserCancelled;
       
    68         case KErrNoMemory:
       
    69             return ELowMemory;
       
    70         case KErrNotSupported:
       
    71         case KErrArgument:
       
    72         case KErrTotalLossOfPrecision:
       
    73         case KErrBadHandle:
       
    74         case KErrOverflow:
       
    75         case KErrUnderflow:
       
    76         case KErrAlreadyExists:
       
    77         case KErrPathNotFound:
       
    78         case KErrDied:
       
    79             return EUnexpectedError;
       
    80         case KErrInUse:
       
    81             return EInstallerBusy;
       
    82         case KErrServerTerminated:
       
    83         case KErrServerBusy:
       
    84         case KErrCompletion:
       
    85         case KErrNotReady:
       
    86         case KErrUnknown:
       
    87             return EUnexpectedError;
       
    88         case KErrCorrupt:
       
    89             return ECorruptedPackage;
       
    90         case KErrAccessDenied:
       
    91             return ESecurityError;
       
    92         case KErrLocked:
       
    93         case KErrWrite:
       
    94         case KErrDisMounted:
       
    95         case KErrEof:
       
    96             return EUnexpectedError;
       
    97         case KErrDiskFull:
       
    98             return ELowDiskSpace;
       
    99         case KErrBadDriver:
       
   100         case KErrBadName:
       
   101         case KErrCommsLineFail:
       
   102         case KErrCommsFrame:
       
   103         case KErrCommsOverrun:
       
   104         case KErrCommsParity:
       
   105         case KErrTimedOut:
       
   106         case KErrCouldNotConnect:
       
   107         case KErrCouldNotDisconnect:
       
   108         case KErrDisconnected:
       
   109         case KErrBadLibraryEntryPoint:
       
   110         case KErrBadDescriptor:
       
   111         case KErrAbort:
       
   112         case KErrTooBig:
       
   113         case KErrDivideByZero:
       
   114         case KErrBadPower:
       
   115         case KErrDirFull:
       
   116         case KErrHardwareNotAvailable:
       
   117         case KErrSessionClosed:
       
   118             return EUnexpectedError;
       
   119         case KErrPermissionDenied:
       
   120             return ESecurityError;
       
   121         case KErrExtensionNotSupported:
       
   122         case KErrCommsBreak:
       
   123         case KErrNoSecureTime:
       
   124             return EUnexpectedError;
       
   125 
       
   126         // Native SW Installer error codes
       
   127         case KErrSISFieldIdMissing:
       
   128         case KErrSISFieldLengthMissing:
       
   129         case KErrSISFieldLengthInvalid:
       
   130         case KErrSISStringInvalidLength:
       
   131         case KErrSISSignedControllerSISControllerMissing:
       
   132         case KErrSISControllerSISInfoMissing:
       
   133         case KErrSISInfoSISUidMissing:
       
   134         case KErrSISInfoSISNamesMissing:
       
   135             return ECorruptedPackage;
       
   136         case KErrSISFieldBufferTooShort:
       
   137             return EUnexpectedError;
       
   138         case KErrSISStringArrayInvalidElement:
       
   139         case KErrSISInfoSISVendorNamesMissing:
       
   140         case KErrSISInfoSISVersionMissing:
       
   141         case KErrSISControllerSISSupportedLanguagesMissing:
       
   142         case KErrSISSupportedLanguagesInvalidElement:
       
   143         case KErrSISLanguageInvalidLength:
       
   144         case KErrSISContentsSISSignedControllerMissing:
       
   145         case KErrSISContentsSISDataMissing:
       
   146         case KErrSISDataSISFileDataUnitMissing:
       
   147         case KErrSISFileDataUnitTargetMissing:
       
   148         case KErrSISFileOptionsMissing:
       
   149         case KErrSISFileDataUnitDescriptorMissing:
       
   150         case KErrSISFileDataDescriptionMissing:
       
   151         case KErrSISContentsMissing:
       
   152         case KErrSISEmbeddedControllersMissing:
       
   153         case KErrSISEmbeddedDataUnitsMissing:
       
   154         case KErrSISControllerOptionsMissing:
       
   155         case KErrSISExpressionMissing:
       
   156         case KErrSISExpressionStringValueMissing:
       
   157         case KErrSISOptionsStringMissing:
       
   158         case KErrSISFileOptionsExpressionMissing:
       
   159         case KErrSISExpressionHeadValueMissing:
       
   160         case KErrSISEmbeddedSISOptionsMissing:
       
   161         case KErrSISInfoSISUpgradeRangeMissing:
       
   162         case KErrSISDependencyMissingUid:
       
   163         case KErrSISDependencyMissingVersion:
       
   164         case KErrSISDependencyMissingNames:
       
   165         case KErrSISPrerequisitesMissingDependency:
       
   166         case KErrSISControllerMissingPrerequisites:
       
   167         case KErrSISUpgradeRangeMissingVersion:
       
   168         case KErrSISUnexpectedFieldType:
       
   169         case KErrSISExpressionUnknownOperator:
       
   170         case KErrSISArrayReadError:
       
   171         case KErrSISArrayTypeMismatch:
       
   172         case KErrSISInvalidStringLength:
       
   173         case KErrSISCompressionNotSupported:
       
   174         case KErrSISTooDeeplyEmbedded:
       
   175             return ECorruptedPackage;
       
   176         case KErrSISInvalidTargetFile:
       
   177         case KErrSISWouldOverWrite:
       
   178             return ESecurityError;
       
   179         case KErrSISInfoMissingRemoveDirectories:
       
   180             return ECorruptedPackage;
       
   181         case KErrSISNotEnoughSpaceToInstall:
       
   182             return ELowDiskSpace;
       
   183         case KErrInstallerLeave:
       
   184         case KErrPolicyFileCorrupt:
       
   185             return EUnexpectedError;
       
   186         case KErrSignatureSchemeNotSupported:
       
   187         case KErrDigestNotSupported:
       
   188             return EApplicationNotCompatible;
       
   189         case KErrBadHash:
       
   190             return ECorruptedPackage;
       
   191         case KErrSecurityError:
       
   192             return ESecurityError;
       
   193         case KErrBadUsage:
       
   194         case KErrInvalidType:
       
   195         case KErrInvalidExpression:
       
   196         case KErrExpressionToComplex:
       
   197             return EUnexpectedError;
       
   198         case KErrMissingBasePackage:
       
   199         case KErrInvalidUpgrade:
       
   200             return EApplicationNotCompatible;
       
   201         case KErrInvalidEclipsing:
       
   202             return ESecurityError;
       
   203         case KErrWrongHeaderFormat:
       
   204             return EUnexpectedError;
       
   205         case KErrCapabilitiesMismatch:
       
   206             return ESecurityError;
       
   207         case KErrLegacySisFile:
       
   208         case KErrInvalidSoftwareTypeRegistrationFile:
       
   209             return EApplicationNotCompatible;
       
   210 
       
   211         // Other error codes
       
   212         default:
       
   213             __ASSERT_DEBUG( EFalse, Panic( ESisxSifUnknownErrorCode ) );
       
   214             return EUnexpectedError;
       
   215         }
       
   216     }
       
   217 
       
   218 // ---------------------------------------------------------------------------
       
   219 // CSisxSifPluginErrorHandler::ErrorCode()
       
   220 // ---------------------------------------------------------------------------
       
   221 //
       
   222 void CSisxSifPluginErrorHandler::FillOutputParamsL( COpaqueNamedParams& aOutputParams ) const
       
   223     {
       
   224     if( iErrorCode )
       
   225         {
       
   226         aOutputParams.AddIntL( KSifOutParam_ErrCategory, ErrorCategory() );
       
   227         aOutputParams.AddIntL( KSifOutParam_ErrCode, iErrorCode );
       
   228         }
       
   229     if( iExtendedErrorCode )
       
   230         {
       
   231         aOutputParams.AddIntL( KSifOutParam_ExtendedErrCode, iExtendedErrorCode );
       
   232         }
       
   233     if( iErrorMessage )
       
   234         {
       
   235         aOutputParams.AddStringL( KSifOutParam_ErrMessage, *iErrorMessage );
       
   236         }
       
   237     if( iErrorMessageDetails )
       
   238         {
       
   239         aOutputParams.AddStringL( KSifOutParam_ErrMessageDetails, *iErrorMessageDetails );
       
   240         }
       
   241     }
       
   242 
       
   243 // ---------------------------------------------------------------------------
       
   244 // CSisxSifPluginErrorHandler::ErrorCode()
       
   245 // ---------------------------------------------------------------------------
       
   246 //
       
   247 TInt CSisxSifPluginErrorHandler::ErrorCode() const
       
   248     {
       
   249     return iErrorCode;
       
   250     }
       
   251 
       
   252 // ---------------------------------------------------------------------------
       
   253 // CSisxSifPluginErrorHandler::SetErrorCode()
       
   254 // ---------------------------------------------------------------------------
       
   255 //
       
   256 void CSisxSifPluginErrorHandler::SetErrorCode( TInt aErrorCode )
       
   257     {
       
   258     iErrorCode = aErrorCode;
       
   259     }
       
   260 
       
   261 // ---------------------------------------------------------------------------
       
   262 // CSisxSifPluginErrorHandler::ExtendedErrorCode()
       
   263 // ---------------------------------------------------------------------------
       
   264 //
       
   265 TInt CSisxSifPluginErrorHandler::ExtendedErrorCode() const
       
   266     {
       
   267     return iExtendedErrorCode;
       
   268     }
       
   269 
       
   270 // ---------------------------------------------------------------------------
       
   271 // CSisxSifPluginErrorHandler::SetExtendedErrorCode()
       
   272 // ---------------------------------------------------------------------------
       
   273 //
       
   274 void CSisxSifPluginErrorHandler::SetExtendedErrorCode( TInt aExtendedErrorCode )
       
   275     {
       
   276     iExtendedErrorCode = aExtendedErrorCode;
       
   277     }
       
   278 
       
   279 // ---------------------------------------------------------------------------
       
   280 // CSisxSifPluginErrorHandler::ErrorMessage()
       
   281 // ---------------------------------------------------------------------------
       
   282 //
       
   283 const TDesC& CSisxSifPluginErrorHandler::ErrorMessage() const
       
   284     {
       
   285     if( iErrorMessage )
       
   286         {
       
   287         return *iErrorMessage;
       
   288         }
       
   289     return KNullDesC;
       
   290     }
       
   291 
       
   292 // ---------------------------------------------------------------------------
       
   293 // CSisxSifPluginErrorHandler::SetErrorMessage()
       
   294 // ---------------------------------------------------------------------------
       
   295 //
       
   296 void CSisxSifPluginErrorHandler::SetErrorMessage( const TDesC& aErrorMessage )
       
   297     {
       
   298     if( iErrorMessage )
       
   299         {
       
   300         delete iErrorMessage;
       
   301         iErrorMessage = NULL;
       
   302         }
       
   303     iErrorMessage = aErrorMessage.AllocL();
       
   304     }
       
   305 
       
   306 // ---------------------------------------------------------------------------
       
   307 // CSisxSifPluginErrorHandler::ErrorMessageDetails()
       
   308 // ---------------------------------------------------------------------------
       
   309 //
       
   310 const TDesC& CSisxSifPluginErrorHandler::ErrorMessageDetails() const
       
   311     {
       
   312     if( iErrorMessageDetails )
       
   313         {
       
   314         return *iErrorMessageDetails;
       
   315         }
       
   316     return KNullDesC;
       
   317     }
       
   318 
       
   319 // ---------------------------------------------------------------------------
       
   320 // CSisxSifPluginErrorHandler::SetErrorMessageDetails()
       
   321 // ---------------------------------------------------------------------------
       
   322 //
       
   323 void CSisxSifPluginErrorHandler::SetErrorMessageDetails(
       
   324         const TDesC& aErrorMessageDetails )
       
   325     {
       
   326     if( iErrorMessageDetails )
       
   327         {
       
   328         delete iErrorMessageDetails;
       
   329         iErrorMessageDetails = NULL;
       
   330         }
       
   331     iErrorMessageDetails = aErrorMessageDetails.AllocL();
       
   332     }
       
   333 
       
   334 // ---------------------------------------------------------------------------
       
   335 // CSisxSifPluginErrorHandler::CSisxSifPluginErrorHandler()
       
   336 // ---------------------------------------------------------------------------
       
   337 //
       
   338 CSisxSifPluginErrorHandler::CSisxSifPluginErrorHandler()
       
   339     {
       
   340     }
       
   341 
       
   342 // ---------------------------------------------------------------------------
       
   343 // CSisxSifPluginError::ConstructL()
       
   344 // ---------------------------------------------------------------------------
       
   345 //
       
   346 void CSisxSifPluginErrorHandler::ConstructL()
       
   347     {
       
   348     }
       
   349