diff -r d45095c2f4f3 -r bee149131e4b mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/cgetformatcapabilities.cpp --- a/mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/cgetformatcapabilities.cpp Tue Feb 02 00:27:58 2010 +0200 +++ b/mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/cgetformatcapabilities.cpp Fri Feb 19 23:18:32 2010 +0200 @@ -11,23 +11,35 @@ * * Contributors: * -* Description: +* Description: * */ #include #include -#include -#include -#include - #include "cgetformatcapabilities.h" -#include "mmmtpdplogger.h" +#include "cdescriptionutility.h" #include "mmmtpdpconfig.h" -#include "tobjectdescription.h" +#include "mmmtpdplogger.h" -_LIT( KMtpObjDescObjFileName, "[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 7}\\.[[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 2}]?" ); +// ----------------------------------------------------------------------------- +// CGetFormatCapabilities::NewL +// Constructor +// ----------------------------------------------------------------------------- +// +EXPORT_C MMmRequestProcessor* CGetFormatCapabilities::NewL( MMTPDataProviderFramework& aFramework, + MMTPConnection& aConnection, + MMmMtpDpConfig& aDpConfig ) + { + CGetFormatCapabilities* self = new ( ELeave ) CGetFormatCapabilities( aFramework, aConnection, aDpConfig ); + + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + + return self; + } // ----------------------------------------------------------------------------- // CGetFormatCapabilities::CGetFormatCapabilities @@ -35,26 +47,27 @@ // ----------------------------------------------------------------------------- // EXPORT_C CGetFormatCapabilities::CGetFormatCapabilities( MMTPDataProviderFramework& aFramework, - MMTPConnection& aConnection, - MMmMtpDpConfig& aDpConfig ) : - CRequestProcessor( aFramework, aConnection, 0, NULL ), - iDpConfig( aDpConfig ) + MMTPConnection& aConnection, + MMmMtpDpConfig& aDpConfig ) : + CRequestProcessor( aFramework, aConnection, 0, NULL ), + iDpConfig( aDpConfig ) { PRINT( _L( "Operation: CGetFormatCapabilities(0x930A)" ) ); } // ----------------------------------------------------------------------------- // CGetFormatCapabilities::ConstructL -// Second phase constructor +// The second phase constructor // ----------------------------------------------------------------------------- // EXPORT_C void CGetFormatCapabilities::ConstructL() { + // Do nothing } // ----------------------------------------------------------------------------- // CGetFormatCapabilities::~CGetFormatCapabilities -// Second phase constructor +// Destructor // ----------------------------------------------------------------------------- // EXPORT_C CGetFormatCapabilities::~CGetFormatCapabilities() @@ -91,7 +104,7 @@ } } - PRINT1( _L( "MM MTP <= CGetFormatCapabilities::CheckRequestL, response = 0x%X" ), response ); + PRINT1( _L( "MM MTP <= CGetFormatCapabilities::CheckRequestL, response = 0x%x" ), response ); return response; } @@ -108,7 +121,6 @@ iCapabilityList = NULL; iCapabilityList = CMTPTypeFormatCapabilityList::NewL(); - iFormatCode = Request().Uint32( TMTPTypeRequest::ERequestParameter1 ); if ( KMTPFormatsAll == iFormatCode ) { @@ -117,102 +129,55 @@ for( TInt i = 0; i < count; i++ ) { PRINT( _L( "MM MTP <> CGetFormatCapabilities::ServiceL, KMTPFormatsAll!!!" ) ); + iFormatCode = ( *formatArray )[i]; - ServiceInterdepentPropDescL(); - CMTPTypeFormatCapability* frmCap = CMTPTypeFormatCapability::NewL( iFormatCode, iInterdependentPropDesc ); - const RArray* propertiesArray = iDpConfig.GetSupportedPropertiesL( iFormatCode ); - TInt num = propertiesArray->Count(); - for( TInt j = 0;j < num; j++ ) - { - CMTPTypeObjectPropDesc* propertyDesc = ServicePropDescL( (*propertiesArray)[j] ); - if ( propertyDesc != NULL ) - { - frmCap->AppendL( propertyDesc ); - } - }//end for j - iCapabilityList->AppendL( frmCap ); - }//end for i - }//end if + ServiceOneFormatCapabilitiesL( iFormatCode ); + } + } else - { - ServiceInterdepentPropDescL(); - PRINT1( _L( "MM MTP <> CGetFormatCapabilities::ServiceL, ONLY one Format!!! formatCode = 0x%X" ), iFormatCode ); - - CMTPTypeFormatCapability* frmCap = CMTPTypeFormatCapability::NewL( iFormatCode, iInterdependentPropDesc ); - const RArray* propertiesArray = iDpConfig.GetSupportedPropertiesL( iFormatCode ); - TInt num = propertiesArray->Count(); - for( TInt j = 0;j < num; j++ ) - { - CMTPTypeObjectPropDesc* propertyDesc = ServicePropDescL( ( *propertiesArray )[j] ); - if ( propertyDesc != NULL ) - { - frmCap->AppendL( propertyDesc ); - } - }//end for j - iCapabilityList->AppendL( frmCap ); - } + ServiceOneFormatCapabilitiesL( iFormatCode ); SendDataL( *iCapabilityList ); PRINT( _L( "MM MTP <= CGetFormatCapabilities::ServiceL" ) ); } +void CGetFormatCapabilities::ServiceOneFormatCapabilitiesL( TUint aFormatCode ) + { + CMTPTypeInterdependentPropDesc* interdependentPropDesc = iDpConfig.DescriptionUtility()->NewInterdepentPropDescL( iDpConfig, aFormatCode ); + CMTPTypeFormatCapability* frmCap = CMTPTypeFormatCapability::NewL( aFormatCode, interdependentPropDesc ); + + const RArray* properties = iDpConfig.GetSupportedPropertiesL( aFormatCode ); + TInt num = properties->Count(); + for ( TInt i = 0; i < num; i++ ) + { + CMTPTypeObjectPropDesc* propertyDesc = ServiceOnePropDescL( ( *properties )[i] ); + if ( propertyDesc != NULL ) + { + frmCap->AppendL( propertyDesc ); + } + } + iCapabilityList->AppendL( frmCap ); + } + // ----------------------------------------------------------------------------- // CGetFormatCapabilities::ServicePropDescL // Get MTPTypeObjectPropDesc according to property code // ----------------------------------------------------------------------------- // -CMTPTypeObjectPropDesc* CGetFormatCapabilities::ServicePropDescL( TUint16 aPropCode ) +CMTPTypeObjectPropDesc* CGetFormatCapabilities::ServiceOnePropDescL( TUint16 aPropCode ) { - PRINT1( _L( "MM MTP => CGetFormatCapabilities::ServicePropDescL, aPropCode = 0x%X" ), aPropCode ); - // implement just like what we did in CGetpropertyDescc::ServiceL - CMTPTypeObjectPropDesc* propertyDesc; - CMTPTypeObjectPropDesc::TPropertyInfo propertyInfo; - - /* Create new PropDesc object to return to device - m - signals only limited supported values - hence these requests require the expected form - variable to be passed into the NewL contstuctor as well */ - switch( aPropCode ) - { - case EMTPObjectPropCodeStorageID: // Storage ID - case EMTPObjectPropCodeObjectFormat: // Format Code - case EMTPObjectPropCodeObjectSize: // Object Size - case EMTPObjectPropCodeParentObject: // Parent Object - case EMTPObjectPropCodePersistentUniqueObjectIdentifier: // Unique Object Identifier - case EMTPObjectPropCodeName: // Name - case EMTPObjectPropCodeDateAdded: // Date Added - propertyDesc = CMTPTypeObjectPropDesc::NewL( aPropCode ); - break; + PRINT1( _L( "MM MTP => CGetFormatCapabilities::ServicePropDescL, aPropCode = 0x%x" ), aPropCode ); - // Protection Status (m) - case EMTPObjectPropCodeProtectionStatus: - propertyDesc = ServiceProtectionStatusL(); - break; - - // FileName - case EMTPObjectPropCodeObjectFileName: - propertyDesc = ServiceFileNameL(); - break; + // implement just like what we did in CGetpropertyDescc::ServiceL + CMTPTypeObjectPropDesc* propertyDesc = + iDpConfig.DescriptionUtility()->NewCommonObjectPropertyL( aPropCode ); - // Consumable (m) - case EMTPObjectPropCodeNonConsumable: - propertyDesc = ServiceNonConsumableL(); - break; + if ( propertyDesc == NULL ) + propertyDesc = iDpConfig.DescriptionUtility()->NewSpecificPropDescL( iFormatCode, aPropCode ); - case EMTPObjectPropCodeDateModified: // Date Modified - case EMTPObjectPropCodeDateCreated: // Date Created - propertyInfo.iDataType = EMTPTypeString; - propertyInfo.iFormFlag = CMTPTypeObjectPropDesc::EDateTimeForm; - propertyInfo.iGetSet = CMTPTypeObjectPropDesc::EReadOnly; - propertyDesc = CMTPTypeObjectPropDesc::NewL( aPropCode, propertyInfo, NULL); - break; - - default: - propertyDesc = ServiceSpecificPropertyDescL( aPropCode ); - break; - } if ( propertyDesc != NULL ) { - TUint32 groupCode = GetGroupCode( aPropCode ); + TUint32 groupCode = iDpConfig.DescriptionUtility()->GetGroupCode( aPropCode ); propertyDesc->SetUint32L( CMTPTypeObjectPropDesc::EGroupCode, groupCode ); } @@ -221,108 +186,4 @@ return propertyDesc; } -// ----------------------------------------------------------------------------- -// CGetFormatCapabilities::GetGroupCode -// Get MTPTypeObjectPropDesc according to property code -// ----------------------------------------------------------------------------- -// -TUint32 CGetFormatCapabilities::GetGroupCode( TUint32 aPropCode ) - { - TInt count = sizeof( KPropGroupMapTable ); - // TODO: if need to refine the search approach to improve performance - for( TInt i = 0; i < count; i++ ) - { - if ( aPropCode == KPropGroupMapTable[i].iPropCode ) - return KPropGroupMapTable[i].iGroupCode; - } - return EGroupCodeNotDefined; - } - -// ----------------------------------------------------------------------------- -// CGetFormatCapabilities::ServiceProtectionStatusL -// Get MTPTypeObjectPropDesc protection status -// ----------------------------------------------------------------------------- -// -CMTPTypeObjectPropDesc* CGetFormatCapabilities::ServiceProtectionStatusL() - { - PRINT( _L( "MM MTP => CGetFormatCapabilities::ServiceProtectionStatusL" ) ); - - CMTPTypeObjectPropDescEnumerationForm* expectedForm = - CMTPTypeObjectPropDescEnumerationForm::NewLC( EMTPTypeUINT16 ); // + expectedForm - - TUint16 values[] = - { - EMTPProtectionNoProtection, - EMTPProtectionReadOnly - }; - - TInt numValues = sizeof ( values ) / sizeof ( values[0] ) ; - for ( TInt i = 0; i < numValues; i++ ) - { - TMTPTypeUint16 data( values[i] ); - expectedForm->AppendSupportedValueL( data ); - } - - CMTPTypeObjectPropDesc* propertyDesc = CMTPTypeObjectPropDesc::NewL( EMTPObjectPropCodeProtectionStatus, *expectedForm ); - CleanupStack::PopAndDestroy( expectedForm ); // - expectedForm - - PRINT( _L( "MM MTP <= CGetFormatCapabilities::ServiceProtectionStatusL" ) ); - return propertyDesc; - } - -// ----------------------------------------------------------------------------- -// CGetFormatCapabilities::ServiceFileNameL -// Get MTPTypeObjectPropDesc service file name -// ----------------------------------------------------------------------------- -// -CMTPTypeObjectPropDesc* CGetFormatCapabilities::ServiceFileNameL() - { - PRINT( _L( "MM MTP => CGetFormatCapabilities::ServiceFileNameL" ) ); - CMTPTypeString* form = CMTPTypeString::NewLC( KMtpObjDescObjFileName ); // + form - - CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewL( EMTPObjectPropCodeObjectFileName, - CMTPTypeObjectPropDesc::ERegularExpressionForm, - form ); - - CleanupStack::PopAndDestroy( form ); // - form - PRINT( _L( "MM MTP <= CGetFormatCapabilities::ServiceFileNameL" ) ); - return ret; - } - -// ----------------------------------------------------------------------------- -// CGetFormatCapabilities::ServiceFileNameL -// Get MTPTypeObjectPropDesc service file name -// ----------------------------------------------------------------------------- -// -CMTPTypeObjectPropDesc* CGetFormatCapabilities::ServiceNonConsumableL() - { - PRINT( _L( "MM MTP => CGetFormatCapabilities::ServiceNonConsumableL" ) ); - CMTPTypeObjectPropDescEnumerationForm* expectedForm = - CMTPTypeObjectPropDescEnumerationForm::NewLC( EMTPTypeUINT8 ); // + expectedForm - TUint8 values[] = - { - EMTPConsumable, - EMTPNonConsumable - }; - - TInt numValues = sizeof ( values ) / sizeof ( values[0] ); - for ( TInt i = 0; i < numValues; i++ ) - { - TMTPTypeUint8 data( values[i] ); - expectedForm->AppendSupportedValueL( data ); - } - - CMTPTypeObjectPropDesc::TPropertyInfo propertyInfo; - propertyInfo.iDataType = EMTPTypeUINT8; - propertyInfo.iFormFlag = CMTPTypeObjectPropDesc::EEnumerationForm; - propertyInfo.iGetSet = CMTPTypeObjectPropDesc::EReadOnly; - CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewL( EMTPObjectPropCodeNonConsumable, - propertyInfo, - expectedForm ); - CleanupStack::PopAndDestroy( expectedForm ); // - expectedForm - - PRINT( _L( "MM MTP <= CGetFormatCapabilities::ServiceNonConsumableL" ) ); - return ret; - } - // end of file