mtpfws/mtpfw/dataproviders/proxydp/src/mtpproxydpprocessor.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 //
       
    15 
       
    16 #include <mtp/tmtptyperequest.h>
       
    17 
       
    18 #include "cmtpcopyobject.h"
       
    19 #include "cmtpmoveobject.h"
       
    20 #include "cmtpdeleteobject.h"
       
    21 #include "cmtpgetobjectproplist.h"
       
    22 #include "cmtpgetobjectpropssupported.h"
       
    23 #include "cmtprequestprocessor.h"
       
    24 #include "cmtprequestunknown.h"
       
    25 #include "cmtpsendobjectinfo.h"
       
    26 #include "cmtpsendobjectproplist.h"
       
    27 #include "cmtpsetobjectproplist.h"
       
    28 #include "mtpproxydpprocessor.h"
       
    29 #include "cmtpgetformatcapabilities.h"
       
    30 #include "cmtpdeleteobjectproplist.h"
       
    31 /**
       
    32 proxy data provider mapping table from request ID to factory method of the request processor
       
    33 */
       
    34 static const TMTPRequestProcessorEntry KMTPRequestProcessorTable[] = 
       
    35     {
       
    36         {EMTPOpCodeCopyObject,              CMTPCopyObject::NewL},
       
    37         {EMTPOpCodeMoveObject,              CMTPMoveObject::NewL},
       
    38         {EMTPOpCodeDeleteObject,            CMTPDeleteObject::NewL},
       
    39         {EMTPOpCodeGetObjectPropList,       CMTPGetObjectPropList::NewL},
       
    40         {EMTPOpCodeGetObjectPropsSupported, CMTPGetObjectPropsSupported::NewL},
       
    41         {EMTPOpCodeSendObjectInfo,          CMTPSendObjectInfo::NewL},
       
    42         {EMTPOpCodeSendObjectPropList,      CMTPSendObjectPropList::NewL},
       
    43         {EMTPOpCodeSetObjectPropList,       CMTPSetObjectPropList::NewL},
       
    44         {EMTPOpCodeGetFormatCapabilities,   CMTPGetFormatCapabilities::NewL},
       
    45         {EMTPOpCodeDeleteObjectPropList,    CMTPDeleteObjectPropList::NewL}
       
    46    
       
    47     };
       
    48 
       
    49 /**
       
    50 Creates request processor based on the request and connection
       
    51 */    
       
    52 MMTPRequestProcessor* MTPProxyDpProcessor::CreateL(MMTPDataProviderFramework& aFramework, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
       
    53     {
       
    54     TMTPRequestProcessorCreateFunc factory(NULL); 
       
    55     TUint16 op(aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode));
       
    56     const TInt count(sizeof(KMTPRequestProcessorTable) / sizeof(TMTPRequestProcessorEntry));
       
    57     for (TInt i(0); ((!factory) && (i < count)); i++)
       
    58         {
       
    59         if (KMTPRequestProcessorTable[i].iOperationCode == op)
       
    60             {
       
    61             factory = KMTPRequestProcessorTable[i].iCreateFunc;
       
    62             }
       
    63         }
       
    64 
       
    65     if (!factory)    
       
    66         {
       
    67         factory = CMTPRequestUnknown::NewL;
       
    68         }
       
    69                 
       
    70     return (*factory)(aFramework, aConnection);
       
    71     }