mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevrequestunknown.cpp
changeset 0 d0791faffa3f
child 2 4843bb5893b6
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/cmtpobjectmetadata.h>
       
    17 #include <mtp/tmtptyperequest.h>
       
    18 
       
    19 #include "cmtpdevrequestunknown.h"
       
    20 #include "cmtpobjectmgr.h"
       
    21 #include "cmtpparserrouter.h"
       
    22 
       
    23 /**
       
    24 Factory method.
       
    25 @param aFramework The data provider framework
       
    26 @param aConnection The connection on which the request was received.
       
    27 @return A pointer to the created request processor object.
       
    28 @leave One of the system wide error codes, if a processing error occurs.
       
    29 */ 
       
    30 MMTPRequestProcessor* CMTPDevRequestUnknown::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
       
    31     {
       
    32     CMTPDevRequestUnknown* self = new (ELeave) CMTPDevRequestUnknown(aFramework, aConnection);
       
    33     CleanupStack::PushL(self);
       
    34     self->ConstructL();
       
    35     CleanupStack::Pop(self);
       
    36     return self;
       
    37     }
       
    38 
       
    39 /**
       
    40 Destructor.
       
    41 */    
       
    42 CMTPDevRequestUnknown::~CMTPDevRequestUnknown()
       
    43     {
       
    44     iSingletons.Close(); 
       
    45     delete iDataSet;
       
    46     iDataSet = NULL;
       
    47     }
       
    48 
       
    49 /**
       
    50 Implements the default MTP request handler.
       
    51 @leave One of the system wide error codes, if a processing error occurs.
       
    52 */    
       
    53 void CMTPDevRequestUnknown::ServiceL()    
       
    54     {
       
    55     const TUint KOpCode(iRequest->Uint16(TMTPTypeRequest::ERequestOperationCode));
       
    56     TBool NoDataPhase(ETrue);
       
    57     TMTPResponseCode rsp(EMTPRespCodeOperationNotSupported);
       
    58     if (iSingletons.Router().OperationSupportedL(KOpCode))
       
    59     	{
       
    60     	switch (KOpCode)
       
    61     	    {
       
    62 	    case EMTPOpCodeGetInterdependentPropDesc:
       
    63 	        {
       
    64             const TUint32 KFormatcode = iRequest->Uint32(TMTPTypeRequest::ERequestParameter1);
       
    65             
       
    66             if ((KFormatcode == KMTPFormatsAll) || (KFormatcode == KMTPNotSpecified32))
       
    67                 {
       
    68                 rsp = EMTPRespCodeInvalidCodeFormat;
       
    69                 }
       
    70             else
       
    71                 {
       
    72             ServiceInterdependentPropDescL();
       
    73             NoDataPhase = EFalse;
       
    74                 }
       
    75             }
       
    76             break;
       
    77 
       
    78 	        
       
    79 	    case EMTPOpCodeTerminateOpenCapture:
       
    80 	        {
       
    81 	        if (iSingletons.Router().RouteRequestRegisteredL(*iRequest, iConnection))
       
    82 	            {
       
    83     	        rsp = EMTPRespCodeInvalidTransactionID;
       
    84 	            }
       
    85             else
       
    86                 {
       
    87     	        rsp = EMTPRespCodeCaptureAlreadyTerminated;
       
    88                 }
       
    89 	        }
       
    90 	        break;
       
    91 	        
       
    92 	    case EMTPOpCodeGetPartialObject:
       
    93 	    case EMTPOpCodeGetObjectReferences:
       
    94 	    case EMTPOpCodeSetObjectReferences:
       
    95             {
       
    96             CMTPObjectMetaData* object(CMTPObjectMetaData::NewLC());
       
    97             if (!iSingletons.ObjectMgr().ObjectL(iRequest->Uint32(TMTPTypeRequest::ERequestParameter1), *object))
       
    98                 {
       
    99     	        rsp = EMTPRespCodeInvalidObjectHandle;
       
   100                 }
       
   101             else if ((KOpCode == EMTPOpCodeSetObjectReferences) &&
       
   102                         (object->Uint(CMTPObjectMetaData::EFormatCode) == EMTPFormatCodeAssociation) &&
       
   103                         (object->Uint(CMTPObjectMetaData::EFormatSubCode) == EMTPAssociationTypeGenericFolder))
       
   104                 {
       
   105     	        rsp = EMTPRespCodeAccessDenied;
       
   106                 }
       
   107             else
       
   108                 {
       
   109     	        rsp = EMTPRespCodeOperationNotSupported;
       
   110                 }
       
   111             CleanupStack::PopAndDestroy(object);
       
   112             }
       
   113 	        break;
       
   114 	        
       
   115         case EMTPOpCodeGetServiceCapabilities:
       
   116 	    case EMTPOpCodeGetServicePropDesc:
       
   117         case EMTPOpCodeGetServicePropList:
       
   118         case EMTPOpCodeSetServicePropList:    
       
   119 	    case EMTPOpCodeDeleteServicePropList:
       
   120 	        {
       
   121 	         rsp = EMTPRespCodeInvalidServiceID;
       
   122 	        }
       
   123 	        break;
       
   124 	    case EMTPOpCodeDeleteObjectPropList:
       
   125 	    case EMTPOpCodeUpdateObjectPropList:
       
   126 	        {
       
   127 	        rsp = EMTPRespCodeInvalidObjectHandle;
       
   128 	        }
       
   129 	        break;
       
   130 	        
       
   131 	    default:
       
   132 	        rsp = EMTPRespCodeGeneralError;
       
   133 	        break;
       
   134     	    }
       
   135         }
       
   136     if ( NoDataPhase )
       
   137        {
       
   138        SendResponseL(rsp);
       
   139        }
       
   140 
       
   141     }  
       
   142 
       
   143 
       
   144 /**
       
   145 +Send empty interdependentpropdesc data when the request is route to device dp
       
   146 +*/
       
   147 void CMTPDevRequestUnknown::ServiceInterdependentPropDescL()
       
   148     {
       
   149     delete iDataSet;
       
   150     iDataSet = NULL;
       
   151 
       
   152     iDataSet = CMTPTypeInterdependentPropDesc::NewL();
       
   153     SendDataL(*iDataSet);
       
   154     }
       
   155 
       
   156     
       
   157 /**
       
   158 Constructor.
       
   159 @param aFramework The data provider framework
       
   160 @param aConnection The connection on which the request was received.
       
   161 */    
       
   162 CMTPDevRequestUnknown::CMTPDevRequestUnknown(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
       
   163     CMTPRequestUnknown(aFramework, aConnection)
       
   164     {
       
   165     
       
   166     }
       
   167     
       
   168 /**
       
   169 Second phase constructor.
       
   170 */
       
   171 void CMTPDevRequestUnknown::ConstructL()
       
   172     {
       
   173     iSingletons.OpenL();
       
   174     }