--- a/mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/crequestchecker.cpp Fri Apr 16 15:28:14 2010 +0300
+++ b/mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/crequestchecker.cpp Mon May 03 12:58:40 2010 +0300
@@ -11,12 +11,11 @@
*
* Contributors:
*
-* Description:
+* Description:
*
*/
-#include <mtp/cmtpobjectmetadata.h>
#include <mtp/mmtpconnection.h>
#include <mtp/mmtpdataproviderframework.h>
#include <mtp/mmtpobjectmgr.h>
@@ -54,7 +53,7 @@
iHandles( KMTPRequestCheckerHandleGranularity ),
iObjectArray( KMTPRequestCheckerHandleGranularity )
{
-
+ // Do nothing
}
// -----------------------------------------------------------------------------
@@ -64,7 +63,7 @@
//
void CRequestChecker::ConstructL()
{
-
+ // Do nothing
}
// -----------------------------------------------------------------------------
@@ -80,12 +79,12 @@
// -----------------------------------------------------------------------------
// CRequestChecker::VerifyRequestL
-// Verfiy the request
+// Verify the request
// -----------------------------------------------------------------------------
//
TMTPResponseCode CRequestChecker::VerifyRequestL( const TMTPTypeRequest& aRequest,
- TInt aCount,
- const TMTPRequestElementInfo* aElementInfo )
+ TInt aCount,
+ const TMTPRequestElementInfo* aElementInfo )
{
TMTPResponseCode result = EMTPRespCodeOK;
iHandles.Close();
@@ -96,9 +95,11 @@
for ( TInt i = 0; i < aCount && EMTPRespCodeOK == result; i++ )
{
TUint32 parameter = aRequest.Uint32( aElementInfo[i].iElementIndex );
- PRINT3( _L( "MM MTP <> CRequestChecker parameter %d/%d = %d" ),
- i + 1, aCount, parameter );
-
+ PRINT3( _L( "MM MTP <> CRequestChecker parameter %d/%d = %d" ),
+ i + 1,
+ aCount,
+ parameter );
+
if ( !IsSpecialValue( parameter, aElementInfo[i] ) )
{
switch ( aElementInfo[i].iElementType )
@@ -198,7 +199,7 @@
ret = EMTPRespCodeSessionNotOpen;
}
}
-
+
return ret;
}
@@ -209,7 +210,7 @@
// -----------------------------------------------------------------------------
//
TMTPResponseCode CRequestChecker::VerifySessionId( TUint32 aSessionId,
- const TMTPRequestElementInfo& /*aElementInfo*/ ) const
+ const TMTPRequestElementInfo& /*aElementInfo*/ ) const
{
TMTPResponseCode ret = EMTPRespCodeOK;
@@ -224,7 +225,7 @@
{
ret = EMTPRespCodeInvalidParameter;
}
-
+
return ret;
}
@@ -235,7 +236,7 @@
// -----------------------------------------------------------------------------
//
TMTPResponseCode CRequestChecker::VerifyObjectHandleL( TUint32 aHandle,
- const TMTPRequestElementInfo& aElementInfo )
+ const TMTPRequestElementInfo& aElementInfo )
{
PRINT1( _L("MM MTP => CRequestChecker::VerifyObjectHandleL aHandle = 0x%x"), aHandle );
TMTPResponseCode ret = EMTPRespCodeOK;
@@ -252,61 +253,35 @@
const TDesC& suid( object->DesC( CMTPObjectMetaData::ESuid ) );
TEntry entry;
TInt err = iFramework.Fs().Entry( suid, entry );
-
- if ( object->Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCodeAssociation )
-// && ( object->Uint( CMTPObjectMetaData::EFormatSubCode ) == EMTPAssociationTypeGenericFolder ) )
- {
- // Special association type .. not always present on the filesystem.
- return ret;
- }
- else
+
+ if ( err == KErrNotFound )
{
- User::LeaveIfError( err );
-
+ iFramework.ObjectMgr().RemoveObjectL( suid );
+ // TODO: workaround for abstractalbumart
+ // ret = EMTPRespCodeInvalidObjectHandle;
+ }
+ else if ( err != KErrNone )
+ ret = EMTPRespCodeGeneralError;
+ else if ( object->Uint( CMTPObjectMetaData::EFormatCode ) != EMTPFormatCodeAssociation )
+ {
if ( iFramework.ObjectMgr().ObjectOwnerId( aHandle ) != iFramework.DataProviderId() )
- {
- PRINT( _L(" ewrwe ret = EMTPRespCodeInvalidObjectHandle;"));
ret = EMTPRespCodeInvalidObjectHandle;
- }
- }
- if ( aElementInfo.iElementAttr & EMTPElementAttrWrite )
- {
- if ( entry.IsReadOnly() )
- {
+ if ( ( aElementInfo.iElementAttr & EMTPElementAttrWrite ) && entry.IsReadOnly() )
ret = EMTPRespCodeObjectWriteProtected;
- }
- }
-
- //((EMTPRespCodeOK == ret) && (aElementInfo.iElementAttr & EMTPElementAttrFileOrDir)) is
- // covered implicitly here, EMTPRespCodeOK will be returned. It is a valid case for an object to be either a folder or file
- // for certain operation's request parameter, for instance the first parameter of copyObject or
- // moveObject can be either a file or a directory.
- // Other cases.
- if ( ( EMTPRespCodeOK == ret ) && ( aElementInfo.iElementAttr & EMTPElementAttrFile) )
- {
- if ( entry.IsDir() )
- {
+ if ( ( EMTPRespCodeOK == ret ) && ( aElementInfo.iElementAttr & EMTPElementAttrFile ) && entry.IsDir() )
ret = EMTPRespCodeInvalidObjectHandle;
- }
- }
- if ( ( EMTPRespCodeOK == ret ) && ( aElementInfo.iElementAttr & EMTPElementAttrDir ) )
- {
- if (!entry.IsDir())
- {
+ if ( ( EMTPRespCodeOK == ret ) && ( aElementInfo.iElementAttr & EMTPElementAttrDir ) && !entry.IsDir() )
ret = EMTPRespCodeInvalidParentObject;
- }
}
}
else
- {
- PRINT( _L( "MM MTP <> CRequestChecker::VerifyObjectHandleL, Object does not exist." ) );
ret = EMTPRespCodeInvalidObjectHandle;
- }
+
PRINT1( _L( "MM MTP <= CRequestChecker::VerifyObjectHandleL ret = 0x%x" ), ret );
-
+
return ret;
}
@@ -316,7 +291,7 @@
// -----------------------------------------------------------------------------
//
TMTPResponseCode CRequestChecker::VerifyStorageIdL( TUint32 aStorageId,
- const TMTPRequestElementInfo& aElementInfo ) const
+ const TMTPRequestElementInfo& aElementInfo ) const
{
MMTPStorageMgr& mgr( iFramework.StorageMgr() );
TMTPResponseCode ret( EMTPRespCodeOK );
@@ -357,7 +332,7 @@
}
}
}
-
+
return ret;
}
@@ -367,7 +342,7 @@
// -----------------------------------------------------------------------------
//
TMTPResponseCode CRequestChecker::VerifyFormatCode( TUint32 aFormatCode,
- const TMTPRequestElementInfo& aElementInfo ) const
+ const TMTPRequestElementInfo& aElementInfo ) const
{
PRINT1( _L( "MM MTP => CRequestChecker::VerifyFormatCode aFormatCode = 0x%x" ), aFormatCode );
TMTPResponseCode ret = EMTPRespCodeInvalidObjectFormatCode;
@@ -395,7 +370,7 @@
}
PRINT1( _L( "MM MTP => CRequestChecker::VerifyFormatCode ret = 0x%x" ), ret );
-
+
return ret;
}
@@ -405,7 +380,7 @@
// -----------------------------------------------------------------------------
//
TBool CRequestChecker::IsSpecialValue( TUint32 aParameter,
- const TMTPRequestElementInfo& aElementInfo ) const
+ const TMTPRequestElementInfo& aElementInfo ) const
{
TBool result = EFalse;
switch ( aElementInfo.iCount )
@@ -413,16 +388,16 @@
case 1:
result = ( aParameter == aElementInfo.iValue1 );
break;
-
+
case 2:
result = ( aParameter == aElementInfo.iValue1
|| aParameter == aElementInfo.iValue2 );
break;
-
+
default:
break;
}
-
+
return result;
}