mtpdataproviders/mtpfileandfolderdp/src/mtpfiledpprocessor.cpp
changeset 0 d0791faffa3f
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // mtpdevicedpprocessor.h
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <mtp/tmtptyperequest.h>
       
    19 
       
    20 #include "mtpfiledpprocessor.h"
       
    21 #include "cmtprequestprocessor.h"
       
    22 #include "cmtpgetobjectinfo.h"
       
    23 #include "cmtpgetobject.h"
       
    24 #include "cmtpdeleteobject.h"
       
    25 #include "cmtpsendobjectinfo.h"
       
    26 #include "cmtpcopyobject.h"
       
    27 #include "cmtpmoveobject.h"
       
    28 #include "cmtpgetobjectpropssupported.h"
       
    29 #include "cmtpgetobjectpropdesc.h"
       
    30 #include "cmtpgetobjectpropvalue.h"
       
    31 #include "cmtpsetobjectpropvalue.h"
       
    32 #include "cmtprequestunknown.h"
       
    33 #include "cmtpgetobjectproplist.h"
       
    34 #include "cmtpsetobjectproplist.h"
       
    35 #include "cmtpgetreferences.h"
       
    36 #include "cmtpsetreferences.h"
       
    37 #include "cmtpgetformatcapabilities.h"
       
    38 #include "cmtpgetpartialobject.h"
       
    39 #include "cmtpsetobjectprotection.h"
       
    40 /**
       
    41 A mapping table from the operation code to the request processor factory method
       
    42 */
       
    43 static const TMTPRequestProcessorEntry KMTPFileDpRequestProcessorTable[] = 
       
    44 	{
       
    45 		{EMTPOpCodeGetObjectInfo, CMTPGetObjectInfo::NewL},
       
    46 		{EMTPOpCodeGetObject, CMTPGetObject::NewL},
       
    47 		{EMTPOpCodeDeleteObject, CMTPDeleteObject::NewL},		
       
    48 		{EMTPOpCodeSendObjectInfo, CMTPSendObjectInfo::NewL},
       
    49 		{EMTPOpCodeSendObject, CMTPSendObjectInfo::NewL},	//force the SendObject request to be processed by the SendObjectInfo processor 
       
    50 		{EMTPOpCodeSendObjectPropList, CMTPSendObjectInfo::NewL},	//force the SendObjectPropList request to be processed by the SendObjectInfo processor 
       
    51 		{EMTPOpCodeMoveObject, CMTPMoveObject::NewL},	
       
    52 		{EMTPOpCodeCopyObject, CMTPCopyObject::NewL},
       
    53 		{EMTPOpCodeGetObjectPropsSupported, CMTPGetObjectPropsSupported::NewL},
       
    54 		{EMTPOpCodeGetObjectPropDesc, CMTPGetObjectPropDesc::NewL},
       
    55 		{EMTPOpCodeGetObjectPropValue, CMTPGetObjectPropValue::NewL},
       
    56 		{EMTPOpCodeSetObjectPropValue, CMTPSetObjectPropValue::NewL},
       
    57 		{EMTPOpCodeSetObjectPropList, CMTPSetObjectPropList::NewL},
       
    58 		{EMTPOpCodeGetObjectPropList, CMTPGetObjectPropList::NewL},
       
    59 		{EMTPOpCodeGetObjectReferences, CMTPGetReferences::NewL},
       
    60 		{EMTPOpCodeSetObjectReferences, CMTPSetReferences::NewL},
       
    61         {EMTPOpCodeGetFormatCapabilities,CMTPGetFormatCapabilities::NewL},
       
    62         {EMTPOpCodeGetPartialObject, CMTPGetPartialObject::NewL},
       
    63 	 {EMTPOpCodeSetObjectProtection, CMTPSetObjectProtection::NewL}				
       
    64 	};
       
    65 
       
    66 /**
       
    67 Create a request processor that matches the request
       
    68 @param aPlugin	The reference to the data provider plugin 
       
    69 @param aFramework The reference to the data provider framework
       
    70 @param aRequest	The request to be processed
       
    71 @param aConnection The connection from which the request comes from
       
    72 @return a pointer to the request processor
       
    73 */	
       
    74 MMTPRequestProcessor* MTPFileDpProcessor::CreateL(
       
    75 													MMTPDataProviderFramework& aFramework,
       
    76 													const TMTPTypeRequest& aRequest, 
       
    77 													MMTPConnection& aConnection)
       
    78 	{
       
    79 	TMTPRequestProcessorCreateFunc createFunc = NULL; 
       
    80 	TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
       
    81 	TInt count = sizeof(KMTPFileDpRequestProcessorTable) / sizeof(TMTPRequestProcessorEntry);
       
    82 	for(TInt i = 0; i < count; i++)
       
    83 		{
       
    84 		if(KMTPFileDpRequestProcessorTable[i].iOperationCode == operationCode)
       
    85 			{
       
    86 			createFunc = KMTPFileDpRequestProcessorTable[i].iCreateFunc;
       
    87 			break;
       
    88 			}
       
    89 		}
       
    90 		
       
    91 	if(!createFunc)	
       
    92 		{
       
    93 		createFunc = CMTPRequestUnknown::NewL;
       
    94 		}
       
    95 		
       
    96 	return (*createFunc)(aFramework, aConnection);
       
    97 	}
       
    98 	
       
    99 
       
   100