mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/crequestchecker.cpp
branchRCL_3
changeset 9 bee149131e4b
parent 0 a2952bb97e68
child 14 05b0d2323768
equal deleted inserted replaced
4:d45095c2f4f3 9:bee149131e4b
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: 
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include <mtp/cmtpobjectmetadata.h>
    19 #include <mtp/cmtpobjectmetadata.h>
    52     iFramework( aFramework ),
    52     iFramework( aFramework ),
    53     iConnection( aConnection ),
    53     iConnection( aConnection ),
    54     iHandles( KMTPRequestCheckerHandleGranularity ),
    54     iHandles( KMTPRequestCheckerHandleGranularity ),
    55     iObjectArray( KMTPRequestCheckerHandleGranularity )
    55     iObjectArray( KMTPRequestCheckerHandleGranularity )
    56     {
    56     {
    57     
    57     // Do nothing
    58     }
    58     }
    59 
    59 
    60 // -----------------------------------------------------------------------------
    60 // -----------------------------------------------------------------------------
    61 // CRequestChecker::ConstructL
    61 // CRequestChecker::ConstructL
    62 // Two-phase construction method
    62 // Two-phase construction method
    63 // -----------------------------------------------------------------------------
    63 // -----------------------------------------------------------------------------
    64 //
    64 //
    65 void CRequestChecker::ConstructL()
    65 void CRequestChecker::ConstructL()
    66     {
    66     {
    67     
    67     // Do nothing
    68     }
    68     }
    69 
    69 
    70 // -----------------------------------------------------------------------------
    70 // -----------------------------------------------------------------------------
    71 // CRequestChecker::~CRequestChecker
    71 // CRequestChecker::~CRequestChecker
    72 // Destructor
    72 // Destructor
    82 // CRequestChecker::VerifyRequestL
    82 // CRequestChecker::VerifyRequestL
    83 // Verfiy the request
    83 // Verfiy the request
    84 // -----------------------------------------------------------------------------
    84 // -----------------------------------------------------------------------------
    85 //
    85 //
    86 TMTPResponseCode CRequestChecker::VerifyRequestL( const TMTPTypeRequest& aRequest,
    86 TMTPResponseCode CRequestChecker::VerifyRequestL( const TMTPTypeRequest& aRequest,
    87         TInt aCount,
    87     TInt aCount,
    88         const TMTPRequestElementInfo* aElementInfo )
    88     const TMTPRequestElementInfo* aElementInfo )
    89     {
    89     {
    90     TMTPResponseCode result = EMTPRespCodeOK;
    90     TMTPResponseCode result = EMTPRespCodeOK;
    91     iHandles.Close();
    91     iHandles.Close();
    92     iObjectArray.ResetAndDestroy();
    92     iObjectArray.ResetAndDestroy();
    93 
    93 
    94     result = CheckRequestHeader( aRequest );
    94     result = CheckRequestHeader( aRequest );
    95 
    95 
    96     for ( TInt i = 0; i < aCount && EMTPRespCodeOK == result; i++ )
    96     for ( TInt i = 0; i < aCount && EMTPRespCodeOK == result; i++ )
    97         {
    97         {
    98         TUint32 parameter = aRequest.Uint32( aElementInfo[i].iElementIndex );
    98         TUint32 parameter = aRequest.Uint32( aElementInfo[i].iElementIndex );
    99         PRINT3( _L( "MM MTP <> CRequestChecker parameter %d/%d = %d" ), 
    99         PRINT3( _L( "MM MTP <> CRequestChecker parameter %d/%d = %d" ),
   100                 i + 1, aCount, parameter );
   100             i + 1,
   101         
   101             aCount, 
       
   102             parameter );
       
   103 
   102         if ( !IsSpecialValue( parameter, aElementInfo[i] ) )
   104         if ( !IsSpecialValue( parameter, aElementInfo[i] ) )
   103             {
   105             {
   104             switch ( aElementInfo[i].iElementType )
   106             switch ( aElementInfo[i].iElementType )
   105                 {
   107                 {
   106                 case EMTPElementTypeSessionID:
   108                 case EMTPElementTypeSessionID:
   196         else if ( !iConnection.SessionWithMTPIdExists( sessionId ) )
   198         else if ( !iConnection.SessionWithMTPIdExists( sessionId ) )
   197             {
   199             {
   198             ret = EMTPRespCodeSessionNotOpen;
   200             ret = EMTPRespCodeSessionNotOpen;
   199             }
   201             }
   200         }
   202         }
   201     
   203 
   202     return ret;
   204     return ret;
   203     }
   205     }
   204 
   206 
   205 // -----------------------------------------------------------------------------
   207 // -----------------------------------------------------------------------------
   206 // CRequestChecker::VerifySessionId
   208 // CRequestChecker::VerifySessionId
   222         }
   224         }
   223     else
   225     else
   224         {
   226         {
   225         ret = EMTPRespCodeInvalidParameter;
   227         ret = EMTPRespCodeInvalidParameter;
   226         }
   228         }
   227     
   229 
   228     return ret;
   230     return ret;
   229     }
   231     }
   230 
   232 
   231 // -----------------------------------------------------------------------------
   233 // -----------------------------------------------------------------------------
   232 // CRequestChecker::VerifyObjectHandleL
   234 // CRequestChecker::VerifyObjectHandleL
   250     if ( result )
   252     if ( result )
   251         {
   253         {
   252         const TDesC& suid( object->DesC( CMTPObjectMetaData::ESuid ) );
   254         const TDesC& suid( object->DesC( CMTPObjectMetaData::ESuid ) );
   253         TEntry entry;
   255         TEntry entry;
   254         TInt err = iFramework.Fs().Entry( suid, entry );
   256         TInt err = iFramework.Fs().Entry( suid, entry );
   255         
   257 
   256         if ( object->Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCodeAssociation )
   258         if ( object->Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCodeAssociation )
   257 //            && ( object->Uint( CMTPObjectMetaData::EFormatSubCode ) == EMTPAssociationTypeGenericFolder ) )
   259 //            && ( object->Uint( CMTPObjectMetaData::EFormatSubCode ) == EMTPAssociationTypeGenericFolder ) )
   258             {
   260             {
   259             // Special association type .. not always present on the filesystem.
   261             // Special association type .. not always present on the filesystem.
   260             return ret;
   262             return ret;
   261             }
   263             }
   262         else
   264         else
   263             {
   265             {
   264             User::LeaveIfError( err );
   266             User::LeaveIfError( err );
   265             
   267 
   266             if ( iFramework.ObjectMgr().ObjectOwnerId( aHandle ) != iFramework.DataProviderId() )
   268             if ( iFramework.ObjectMgr().ObjectOwnerId( aHandle ) != iFramework.DataProviderId() )
   267                 {
   269                 {
   268                 PRINT( _L(" ewrwe ret = EMTPRespCodeInvalidObjectHandle;"));
   270                 PRINT( _L(" ewrwe ret = EMTPRespCodeInvalidObjectHandle;"));
   269                 ret = EMTPRespCodeInvalidObjectHandle;
   271                 ret = EMTPRespCodeInvalidObjectHandle;
   270                 }
   272                 }
   304         {
   306         {
   305         PRINT( _L( "MM MTP <> CRequestChecker::VerifyObjectHandleL, Object does not exist." ) );
   307         PRINT( _L( "MM MTP <> CRequestChecker::VerifyObjectHandleL, Object does not exist." ) );
   306         ret = EMTPRespCodeInvalidObjectHandle;
   308         ret = EMTPRespCodeInvalidObjectHandle;
   307         }
   309         }
   308     PRINT1( _L( "MM MTP <= CRequestChecker::VerifyObjectHandleL ret = 0x%x" ), ret );
   310     PRINT1( _L( "MM MTP <= CRequestChecker::VerifyObjectHandleL ret = 0x%x" ), ret );
   309     
   311 
   310     return ret;
   312     return ret;
   311     }
   313     }
   312 
   314 
   313 // -----------------------------------------------------------------------------
   315 // -----------------------------------------------------------------------------
   314 // CRequestChecker::VerifyStorageIdL
   316 // CRequestChecker::VerifyStorageIdL
   355                         ret = EMTPRespCodeStoreReadOnly;
   357                         ret = EMTPRespCodeStoreReadOnly;
   356                         }
   358                         }
   357                 }
   359                 }
   358             }
   360             }
   359        }
   361        }
   360     
   362 
   361     return ret;
   363     return ret;
   362     }
   364     }
   363 
   365 
   364 // -----------------------------------------------------------------------------
   366 // -----------------------------------------------------------------------------
   365 // CRequestChecker::VerifyFormatCode
   367 // CRequestChecker::VerifyFormatCode
   393             ret = EMTPRespCodeOK;
   395             ret = EMTPRespCodeOK;
   394             }
   396             }
   395         }
   397         }
   396 
   398 
   397     PRINT1( _L( "MM MTP => CRequestChecker::VerifyFormatCode ret = 0x%x" ), ret );
   399     PRINT1( _L( "MM MTP => CRequestChecker::VerifyFormatCode ret = 0x%x" ), ret );
   398     
   400 
   399     return ret;
   401     return ret;
   400     }
   402     }
   401 
   403 
   402 // -----------------------------------------------------------------------------
   404 // -----------------------------------------------------------------------------
   403 // CRequestChecker::IsSpecialValue
   405 // CRequestChecker::IsSpecialValue
   411     switch ( aElementInfo.iCount )
   413     switch ( aElementInfo.iCount )
   412         {
   414         {
   413         case 1:
   415         case 1:
   414             result = ( aParameter == aElementInfo.iValue1 );
   416             result = ( aParameter == aElementInfo.iValue1 );
   415             break;
   417             break;
   416             
   418 
   417         case 2:
   419         case 2:
   418             result = ( aParameter == aElementInfo.iValue1
   420             result = ( aParameter == aElementInfo.iValue1
   419                 || aParameter == aElementInfo.iValue2 );
   421                 || aParameter == aElementInfo.iValue2 );
   420             break;
   422             break;
   421             
   423 
   422         default:
   424         default:
   423             break;
   425             break;
   424         }
   426         }
   425     
   427 
   426     return result;
   428     return result;
   427     }
   429     }
   428 
   430 
   429 // end of file
   431 // end of file