Added MCommandExtensionsV1 as an extensible way of adding new virtual functions to CCommandBase without breaking BC.
Using this, added a custom error code resolver and added lots of Software Install errors to swi.
--- a/commands/swi/swi.cpp Wed Jul 07 16:07:08 2010 +0100
+++ b/commands/swi/swi.cpp Fri Jul 09 10:11:55 2010 +0100
@@ -49,6 +49,7 @@
CCmdSwi::CCmdSwi():
CCommandBase(CCommandBase::EManualComplete)
{
+ SetExtension(this);
}
const TDesC& CCmdSwi::Name() const
@@ -196,11 +197,88 @@
// CCmdSwi::Finished
// callback from the underlying AO's RunL
//
-void CCmdSwi::Finished(const TInt aError)
+void CCmdSwi::Finished(TInt aError)
{
Complete(aError);
}
+#define CASE_RETURN_LIT(XXX, YYY) case XXX: { _LIT(_KLit, #YYY); return &_KLit; }
+const TDesC* CCmdSwi::StringifyError(TInt aError) const
+ {
+ switch (aError)
+ {
+ CASE_RETURN_LIT(-10100, KErrSISFieldIdMissing);
+ CASE_RETURN_LIT(-10101, KErrSISFieldLengthMissing);
+ CASE_RETURN_LIT(-10102, KErrSISFieldLengthInvalid);
+ CASE_RETURN_LIT(-10103, KErrSISStringInvalidLength);
+ CASE_RETURN_LIT(-10104, KErrSISSignedControllerSISControllerMissing);
+ CASE_RETURN_LIT(-10105, KErrSISControllerSISInfoMissing);
+ CASE_RETURN_LIT(-10106, KErrSISInfoSISUidMissing);
+ CASE_RETURN_LIT(-10107, KErrSISInfoSISNamesMissing);
+ CASE_RETURN_LIT(-10108, KErrSISFieldBufferTooShort);
+ CASE_RETURN_LIT(-10109, KErrSISStringArrayInvalidElement);
+ CASE_RETURN_LIT(-10110, KErrSISInfoSISVendorNamesMissing);
+ CASE_RETURN_LIT(-10111, KErrSISInfoSISVersionMissing);
+ CASE_RETURN_LIT(-10112, KErrSISControllerSISSupportedLanguagesMissing);
+ CASE_RETURN_LIT(-10113, KErrSISSupportedLanguagesInvalidElement);
+ CASE_RETURN_LIT(-10114, KErrSISLanguageInvalidLength);
+ CASE_RETURN_LIT(-10115, KErrSISContentsSISSignedControllerMissing);
+ CASE_RETURN_LIT(-10116, KErrSISContentsSISDataMissing);
+ CASE_RETURN_LIT(-10117, KErrSISDataSISFileDataUnitMissing);
+ CASE_RETURN_LIT(-10118, KErrSISFileDataUnitTargetMissing);
+ CASE_RETURN_LIT(-10119, KErrSISFileOptionsMissing);
+ CASE_RETURN_LIT(-10120, KErrSISFileDataUnitDescriptorMissing);
+ CASE_RETURN_LIT(-10121, KErrSISFileDataDescriptionMissing);
+ CASE_RETURN_LIT(-10122, KErrSISContentsMissing);
+ CASE_RETURN_LIT(-10123, KErrSISEmbeddedControllersMissing);
+ CASE_RETURN_LIT(-10124, KErrSISEmbeddedDataUnitsMissing);
+ CASE_RETURN_LIT(-10125, KErrSISControllerOptionsMissing);
+ CASE_RETURN_LIT(-10126, KErrSISExpressionMissing);
+ CASE_RETURN_LIT(-10127, KErrSISExpressionStringValueMissing);
+ CASE_RETURN_LIT(-10128, KErrSISOptionsStringMissing);
+ CASE_RETURN_LIT(-10129, KErrSISFileOptionsExpressionMissing);
+ CASE_RETURN_LIT(-10130, KErrSISExpressionHeadValueMissing);
+ CASE_RETURN_LIT(-10131, KErrSISEmbeddedSISOptionsMissing);
+ CASE_RETURN_LIT(-10132, KErrSISInfoSISUpgradeRangeMissing);
+ CASE_RETURN_LIT(-10133, KErrSISDependencyMissingUid);
+ CASE_RETURN_LIT(-10134, KErrSISDependencyMissingVersion);
+ CASE_RETURN_LIT(-10135, KErrSISDependencyMissingNames);
+ CASE_RETURN_LIT(-10136, KErrSISPrerequisitesMissingDependency);
+ CASE_RETURN_LIT(-10137, KErrSISControllerMissingPrerequisites);
+ CASE_RETURN_LIT(-10138, KErrSISUpgradeRangeMissingVersion);
+ CASE_RETURN_LIT(-10139, KErrSISUnexpectedFieldType);
+ CASE_RETURN_LIT(-10140, KErrSISExpressionUnknownOperator);
+ CASE_RETURN_LIT(-10141, KErrSISArrayReadError);
+ CASE_RETURN_LIT(-10142, KErrSISArrayTypeMismatch);
+ CASE_RETURN_LIT(-10143, KErrSISInvalidStringLength);
+ CASE_RETURN_LIT(-10144, KErrSISCompressionNotSupported);
+ CASE_RETURN_LIT(-10145, KErrSISTooDeeplyEmbedded);
+ CASE_RETURN_LIT(-10146, KErrSISInvalidTargetFile);
+ CASE_RETURN_LIT(-10147, KErrSISWouldOverWrite);
+ CASE_RETURN_LIT(-10148, KErrSISInfoMissingRemoveDirectories);
+ CASE_RETURN_LIT(-10149, KErrSISNotEnoughSpaceToInstall);
+ CASE_RETURN_LIT(-10200, KErrInstallerLeave);
+ CASE_RETURN_LIT(-10250, KErrPolicyFileCorrupt);
+ CASE_RETURN_LIT(-10251, KErrSignatureSchemeNotSupported);
+ CASE_RETURN_LIT(-10252, KErrDigestNotSupported);
+ CASE_RETURN_LIT(-10253, KErrBadHash);
+ CASE_RETURN_LIT(-10254, KErrSecurityError);
+ CASE_RETURN_LIT(-10263, KErrBadUsage);
+ CASE_RETURN_LIT(-10260, KErrInvalidType);
+ CASE_RETURN_LIT(-10261, KErrInvalidExpression);
+ CASE_RETURN_LIT(-10262, KErrExpressionToComplex);
+ CASE_RETURN_LIT(-10255, KErrMissingBasePackage);
+ CASE_RETURN_LIT(-10256, KErrInvalidUpgrade);
+ CASE_RETURN_LIT(-10257, KErrInvalidEclipsing);
+ CASE_RETURN_LIT(-10258, KErrWrongHeaderFormat);
+ CASE_RETURN_LIT(-10259, KErrCapabilitiesMismatch);
+ CASE_RETURN_LIT(-10270, KErrLegacySisFile);
+ CASE_RETURN_LIT(-10271, KErrInvalidSoftwareTypeRegistrationFile);
+ default:
+ return NULL;
+ }
+ }
+
//
// Sis installer AO
//
--- a/commands/swi/swi.h Wed Jul 07 16:07:08 2010 +0100
+++ b/commands/swi/swi.h Fri Jul 09 10:11:55 2010 +0100
@@ -178,7 +178,7 @@
// CCmdSwi
// Fshell-console based class handling swi related functionality
//
-class CCmdSwi : public CCommandBase, public MCmdSwiParent
+class CCmdSwi : public CCommandBase, public MCmdSwiParent, public MCommandExtensionsV1
{
public:
static CCommandBase* NewLC();
@@ -194,11 +194,12 @@
virtual void DoRunL();
virtual void ArgumentsL(RCommandArgumentList& aArguments);
virtual void OptionsL(RCommandOptionList& aOptions);
+ const TDesC* StringifyError(TInt aError) const;
// MCmdSwiParent hooks
virtual RIoConsoleReadHandle& Input();
virtual RIoConsoleWriteHandle& Output(TInt aError);
- virtual void Finished(const TInt aError);
+ virtual void Finished(TInt aError);
virtual TBool GetAnswer();
private:
#ifndef SYMBIAN_JAVA_NOT_INCLUDED
--- a/libraries/iosrv/bwins/iocliu.def Wed Jul 07 16:07:08 2010 +0100
+++ b/libraries/iosrv/bwins/iocliu.def Fri Jul 09 10:11:55 2010 +0100
@@ -542,4 +542,7 @@
?Type@TValue@IoUtils@@QBEIXZ @ 541 NONAME ; unsigned int IoUtils::TValue::Type(void) const
?ValuePtr@TValue@IoUtils@@QBEPAXXZ @ 542 NONAME ; void * IoUtils::TValue::ValuePtr(void) const
?EnumValueList@TValue@IoUtils@@QBEABVTDesC16@@XZ @ 543 NONAME ; class TDesC16 const & IoUtils::TValue::EnumValueList(void) const
+ ?StringifyError@MCommandExtensionsV1@IoUtils@@UBEPBVTDesC16@@H@Z @ 544 NONAME ; class TDesC16 const * IoUtils::MCommandExtensionsV1::StringifyError(int) const
+ ?ExtensionVersion@MCommandExtensionsV1@IoUtils@@UBE?AW4TCommandExtensionVersion@2@XZ @ 545 NONAME ; enum IoUtils::TCommandExtensionVersion IoUtils::MCommandExtensionsV1::ExtensionVersion(void) const
+ ?SetExtension@CCommandBase@IoUtils@@IAEXPAVMCommandExtensionsV1@2@@Z @ 546 NONAME ; void IoUtils::CCommandBase::SetExtension(class IoUtils::MCommandExtensionsV1 *)
--- a/libraries/iosrv/client/command_base.cpp Wed Jul 07 16:07:08 2010 +0100
+++ b/libraries/iosrv/client/command_base.cpp Fri Jul 09 10:11:55 2010 +0100
@@ -3067,7 +3067,12 @@
TOverflowTruncate overflow;
aDes = _L("Error: ");
aDes.AppendFormatList(aFmt, aList, &overflow);
- aDes.AppendFormat(_L(" : %S (%d)\r\n"), &overflow, Stringify::Error(aError), aError);
+ const TDesC* errorDesc = NULL;
+ // See if we have an extension that knows about this error
+ if (iExtension) errorDesc = iExtension->StringifyError(aError);
+ // If the extension didn't know, fall back to Stringify::Error() to handle the system ones
+ if (errorDesc == NULL) errorDesc = Stringify::Error(aError);
+ aDes.AppendFormat(_L(" : %S (%d)\r\n"), &overflow, errorDesc, aError);
}
void CCommandBase::FormatWarningText(TDes& aDes, TRefByValue<const TDesC> aFmt, VA_LIST& aList) const
@@ -3835,4 +3840,19 @@
iReadHandle.CancelNotifyChange();
}
-
+//
+
+EXPORT_C TCommandExtensionVersion MCommandExtensionsV1::ExtensionVersion() const
+ {
+ return ECommandExtensionV1;
+ }
+
+EXPORT_C const TDesC* MCommandExtensionsV1::StringifyError(TInt /*aError*/) const
+ {
+ return NULL; // By default we don't have anything additional
+ }
+
+EXPORT_C void CCommandBase::SetExtension(MCommandExtensionsV1* aExtension)
+ {
+ iExtension = aExtension;
+ }
--- a/libraries/iosrv/eabi/iocliu.def Wed Jul 07 16:07:08 2010 +0100
+++ b/libraries/iosrv/eabi/iocliu.def Fri Jul 09 10:11:55 2010 +0100
@@ -614,4 +614,9 @@
_ZNK7IoUtils6TValue4TypeEv @ 613 NONAME
_ZNK7IoUtils6TValue8ValuePtrEv @ 614 NONAME
_ZNK7IoUtils6TValue13EnumValueListEv @ 615 NONAME
+ _ZN7IoUtils12CCommandBase12SetExtensionEPNS_20MCommandExtensionsV1E @ 616 NONAME
+ _ZNK7IoUtils20MCommandExtensionsV114StringifyErrorEi @ 617 NONAME
+ _ZNK7IoUtils20MCommandExtensionsV116ExtensionVersionEv @ 618 NONAME
+ _ZTIN7IoUtils20MCommandExtensionsV1E @ 619 NONAME
+ _ZTVN7IoUtils20MCommandExtensionsV1E @ 620 NONAME
--- a/libraries/iosrv/inc/ioutils.h Wed Jul 07 16:07:08 2010 +0100
+++ b/libraries/iosrv/inc/ioutils.h Fri Jul 09 10:11:55 2010 +0100
@@ -638,6 +638,20 @@
static HBufC* ReadLC(TLex& aLex, const TChar& aEscapeChar, CCommandBase* aErrorContext, TUint aReadMode);
};
+enum TCommandExtensionVersion
+ {
+ ECommandExtensionV1 = 1,
+ };
+
+class MCommandExtensionsV1
+ {
+public:
+ IMPORT_C virtual TCommandExtensionVersion ExtensionVersion() const; // Don't override this yourself!
+
+ // Override this if you have custom error codes you want CCommandBase to understand
+ IMPORT_C virtual const TDesC* StringifyError(TInt aError) const;
+ };
+
class CCommandBase : public CActive
{
public:
@@ -713,6 +727,7 @@
protected:
IMPORT_C CCommandBase();
IMPORT_C CCommandBase(TUint aFlags);
+ IMPORT_C void SetExtension(MCommandExtensionsV1* aExtension);
IMPORT_C virtual void BaseConstructL();
IMPORT_C void CreateEnvironmentL(CEnvironment* aEnv);
@@ -796,11 +811,11 @@
CReaderChangeNotifier* iReadChangeNotifier;
TInt iCompletionReason;
CCommandInfoFile* iCif;
+ MCommandExtensionsV1* iExtension;
void* iSpare1;
void* iSpare2;
void* iSpare3;
void* iSpare4;
- void* iSpare5;
};