mtpfws/mtpfw/dataproviders/dputility/src/cmtpcommonrequestprocessor.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/mmtpdataproviderframework.h>
       
    17 #include <mtp/tmtptyperequest.h>
       
    18 
       
    19 #include "cmtpcommonrequestprocessor.h"
       
    20 #include "mtpdppanic.h"
       
    21 
       
    22 
       
    23 /**
       
    24 Two-phase construction method
       
    25 @param aPlugin The data provider plugin
       
    26 @param aFramework The data provider framework
       
    27 @param aConnection The connection from which the request comes
       
    28 @return a pointer to the created request processor object
       
    29 */    
       
    30 EXPORT_C MMTPRequestProcessor* CMTPCommonRequestProcessor ::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, TMTPResponseCode aResponseCode, TBool aHasIToRDataPhase)
       
    31     {
       
    32     CMTPCommonRequestProcessor * self = new (ELeave) CMTPCommonRequestProcessor (aFramework, aConnection, aResponseCode, aHasIToRDataPhase);
       
    33     CleanupStack::PushL(self);
       
    34     self->ConstructL();
       
    35     CleanupStack::Pop(self);    
       
    36     return self;
       
    37     }
       
    38 
       
    39 /**
       
    40 Destructor
       
    41 */    
       
    42 EXPORT_C CMTPCommonRequestProcessor ::~CMTPCommonRequestProcessor ()
       
    43     {
       
    44     delete iIToRData;
       
    45     }
       
    46 
       
    47 /**
       
    48 Standard c++ constructor
       
    49 */    
       
    50 CMTPCommonRequestProcessor ::CMTPCommonRequestProcessor (MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, TMTPResponseCode aResponseCode, TBool aHasIToRDataPhase)
       
    51     :CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
       
    52      iResponseCode(aResponseCode), iHasIToRDataPhase(aHasIToRDataPhase)
       
    53     {
       
    54     
       
    55     }
       
    56 
       
    57 void CMTPCommonRequestProcessor ::ConstructL ()
       
    58     {
       
    59     if (iHasIToRDataPhase)
       
    60         {
       
    61         iIToRData = CMTPTypeTrivialData::NewL();
       
    62         }
       
    63     }
       
    64 
       
    65 /**
       
    66 GetReferences request handler
       
    67 */    
       
    68 void CMTPCommonRequestProcessor ::ServiceL()
       
    69     {
       
    70     if (HasDataphase())
       
    71         {
       
    72         __ASSERT_DEBUG(iIToRData, Panic(EMTPDpObjectNull));
       
    73         ReceiveDataL(*iIToRData);
       
    74         }
       
    75     else
       
    76         {
       
    77         SendResponseL(iResponseCode);
       
    78         }
       
    79     }
       
    80 
       
    81 TBool CMTPCommonRequestProcessor::DoHandleResponsePhaseL()
       
    82     {
       
    83     SendResponseL(iResponseCode);
       
    84     return EFalse;
       
    85     }
       
    86 
       
    87 TBool CMTPCommonRequestProcessor::HasDataphase() const
       
    88     {
       
    89     return iHasIToRDataPhase;
       
    90     }
       
    91 
       
    92