mtpdataproviders/mtpimagedp/src/mtpimagedprequestprocessor.cpp
changeset 0 d0791faffa3f
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalTechnology
       
    19 */
       
    20 
       
    21 
       
    22 #include <mtp/tmtptyperequest.h>
       
    23 
       
    24 #include "mtpimagedpconst.h"
       
    25 #include "cmtprequestprocessor.h"
       
    26 #include "mtpimagedprequestprocessor.h"
       
    27 
       
    28 //processors
       
    29 #include "cmtpimagedpgetobjectpropdesc.h"
       
    30 #include "cmtpimagedpgetobjectproplist.h"
       
    31 #include "cmtpimagedpgetobject.h"
       
    32 #include "cmtpimagedpgetobjectinfo.h"
       
    33 #include "cmtpimagedpgetthumb.h"
       
    34 #include "cmtpimagedpgetobjectpropssupported.h"
       
    35 #include "cmtpimagedpsendobjectinfo.h"
       
    36 #include "cmtpimagedpgetpartialobject.h"
       
    37 #include "cmtpimagedpcopyobject.h"
       
    38 #include "cmtpimagedpmoveobject.h"
       
    39 #include "cmtpimagedpdeleteobject.h"
       
    40 #include "cmtpimagedpgetobjectpropvalue.h"
       
    41 #include "cmtpimagedpsetobjectpropvalue.h"
       
    42 #include "cmtpimagedpsetobjectproplist.h"
       
    43 #include "cmtpimagedpgetformatcapabilities.h"
       
    44 #include "cmtpimagedpgetobjectreferences.h"
       
    45 #include "cmtpimagedpsetobjectreferences.h"
       
    46 #include "cmtprequestunknown.h"
       
    47 #include "cmtpimagedpsetobjectprotection.h"
       
    48 
       
    49 /** 
       
    50 Defines a processor factory function pointer
       
    51 */
       
    52 typedef MMTPRequestProcessor* (*TMTPImageDpRequestProcessorCreateFunc)(
       
    53                                                                 MMTPDataProviderFramework& aFramework, 
       
    54                                                                 MMTPConnection& aConnection,
       
    55                                                                 CMTPImageDataProvider& aDataProvider);
       
    56 
       
    57 /** 
       
    58 Defines an entry which maps from operation code to the request processor
       
    59 */
       
    60 typedef struct 
       
    61 	{
       
    62 	TUint16                                  iOperationCode;
       
    63 	TMTPImageDpRequestProcessorCreateFunc    iCreateFunc;
       
    64 	}TMTPImageDpRequestProcessorEntry;
       
    65 
       
    66 /**
       
    67 A mapping table from the operation code to the request processor factory method
       
    68 */
       
    69 
       
    70 // --------------------------------------------------------------------------
       
    71 // A mapping table from the operation code to the request processor factory method
       
    72 // --------------------------------------------------------------------------
       
    73 //
       
    74 static const TMTPImageDpRequestProcessorEntry KMTPImageDpRequestProcessorTable[] = 
       
    75 	{
       
    76 	{EMTPOpCodeGetObjectInfo, CMTPImageDpGetObjectInfo::NewL},
       
    77 	{EMTPOpCodeGetObject,  CMTPImageDpGetObject::NewL},
       
    78 	{EMTPOpCodeGetPartialObject,  CMTPImageDpGetPartialObject::NewL},		
       
    79     {EMTPOpCodeGetThumb, CMTPImageDpGetThumb::NewL}, 
       
    80 	{EMTPOpCodeGetObjectPropsSupported, CMTPImageDpGetObjectPropsSupported::NewL}, 
       
    81 	{EMTPOpCodeGetObjectPropDesc, CMTPImageDpGetObjectPropDesc::NewL},
       
    82 	{EMTPOpCodeGetObjectPropValue, CMTPImageDpGetObjectPropValue::NewL},
       
    83 	{EMTPOpCodeGetObjectPropList, CMTPImageDpGetObjectPropList::NewL},
       
    84 	{EMTPOpCodeGetObjectReferences, CMTPImageDpGetObjectReferences::NewL},
       
    85 	{EMTPOpCodeSetObjectReferences, CMTPImageDpSetObjectReferences::NewL},
       
    86 	{EMTPOpCodeDeleteObject, CMTPImageDpDeleteObject::NewL},		
       
    87 	{EMTPOpCodeSendObjectInfo,  CMTPImageDpSendObjectInfo::NewL},
       
    88 	{EMTPOpCodeSendObject,  CMTPImageDpSendObjectInfo::NewL},	//force the SendObject request to be processed by the SendObjectInfo processor 
       
    89 	{EMTPOpCodeSendObjectPropList, CMTPImageDpSendObjectInfo::NewL},	//force the SendObjectPropList request to be processed by the SendObjectInfo processor 
       
    90 	{EMTPOpCodeSetObjectPropValue, CMTPImageDpSetObjectPropValue::NewL},
       
    91 	{EMTPOpCodeSetObjectPropList, CMTPImageDpSetObjectPropList::NewL},	
       
    92 	{EMTPOpCodeMoveObject, CMTPImageDpMoveObject::NewL},	
       
    93 	{EMTPOpCodeCopyObject, CMTPImageDpCopyObject::NewL},
       
    94 	{EMTPOpCodeGetFormatCapabilities,CMTPImageDpGetFormatCapabilities::NewL},
       
    95 	{EMTPOpCodeSetObjectProtection,CMTPImageDpSetObjectProtection::NewL},
       
    96 	};
       
    97 
       
    98 // --------------------------------------------------------------------------
       
    99 // Create a request processor that matches the request
       
   100 // @param aPlugin	The reference to the data provider plugin 
       
   101 // @param aFramework The reference to the data provider framework
       
   102 // @param aRequest	The request to be processed
       
   103 // @param aConnection The connection from which the request comes from
       
   104 // @return a pointer to the request processor
       
   105 // --------------------------------------------------------------------------
       
   106 //
       
   107 MMTPRequestProcessor* MTPImageDpProcessor::CreateL(
       
   108 													MMTPDataProviderFramework& aFramework,
       
   109 													const TMTPTypeRequest& aRequest, 
       
   110 													MMTPConnection& aConnection,
       
   111 													CMTPImageDataProvider& aDataProvider)
       
   112 	{
       
   113     TMTPImageDpRequestProcessorCreateFunc createFunc = NULL; 
       
   114 	TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
       
   115 	TInt count = sizeof(KMTPImageDpRequestProcessorTable) / sizeof(TMTPRequestProcessorEntry);
       
   116 
       
   117 	for(TInt i = 0; i < count; i++)
       
   118 		{
       
   119 		if(KMTPImageDpRequestProcessorTable[i].iOperationCode == operationCode)
       
   120 			{
       
   121 			createFunc = KMTPImageDpRequestProcessorTable[i].iCreateFunc;
       
   122 			break;
       
   123 			}
       
   124 		}
       
   125 		
       
   126 	if(!createFunc)	
       
   127 		{
       
   128 		return CMTPRequestUnknown::NewL(aFramework, aConnection);
       
   129 		}
       
   130 	else
       
   131 	    {
       
   132 	    return (*createFunc)(aFramework, aConnection, aDataProvider);
       
   133 	    }
       
   134 	}