mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectpropssupported.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 <f32file.h>
       
    17 #include <mtp/tmtptyperequest.h>
       
    18 #include <mtp/mmtpdataproviderframework.h>
       
    19 #include <mtp/mtpprotocolconstants.h>
       
    20 #include <mtp/cmtptypearray.h>
       
    21 #include <mtp/mtpdatatypeconstants.h>
       
    22 
       
    23 #include "cmtpgetobjectpropssupported.h"
       
    24 #include "mtpdpconst.h"
       
    25 
       
    26 /**
       
    27 Verification data for the GetObjectPropSupported request
       
    28 */
       
    29 const TMTPRequestElementInfo KMTPGetObjectPropSupportedPolicy[] = 
       
    30     {
       
    31         {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeFormatCode, EMTPElementAttrNone, 1, EMTPFormatCodeUndefined, 0},
       
    32     };
       
    33  
       
    34 /**
       
    35 Two-phase construction method
       
    36 @param aPlugin	The data provider plugin
       
    37 @param aFramework	The data provider framework
       
    38 @param aConnection	The connection from which the request comes
       
    39 @return a pointer to the created request processor object
       
    40 */     
       
    41 EXPORT_C MMTPRequestProcessor* CMTPGetObjectPropsSupported::NewL(
       
    42 											MMTPDataProviderFramework& aFramework,
       
    43 											MMTPConnection& aConnection)
       
    44 	{
       
    45 	CMTPGetObjectPropsSupported* self = new (ELeave) CMTPGetObjectPropsSupported(aFramework, aConnection);
       
    46 	CleanupStack::PushL(self);
       
    47 	self->ConstructL();
       
    48 	CleanupStack::Pop(self);
       
    49 	return self;
       
    50 	}
       
    51 
       
    52 /**
       
    53 Destructor
       
    54 */	
       
    55 EXPORT_C CMTPGetObjectPropsSupported::~CMTPGetObjectPropsSupported()
       
    56 	{
       
    57 	delete iObjectPropsSupported;
       
    58 	}
       
    59 
       
    60 /**
       
    61 Standard c++ constructor
       
    62 */		
       
    63 CMTPGetObjectPropsSupported::CMTPGetObjectPropsSupported(
       
    64 									MMTPDataProviderFramework& aFramework,
       
    65 									MMTPConnection& aConnection)
       
    66 	:CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectPropSupportedPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectPropSupportedPolicy)
       
    67 	{
       
    68 	}
       
    69 									
       
    70 /**
       
    71 check format code
       
    72 */
       
    73 TMTPResponseCode CMTPGetObjectPropsSupported::CheckRequestL()
       
    74     {
       
    75     TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL(); 
       
    76     
       
    77     if (EMTPRespCodeOK == responseCode)
       
    78         {
       
    79         TUint32 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
       
    80         
       
    81         /**
       
    82          * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, 
       
    83          * but it does not really own the format 0x3002.
       
    84          * 
       
    85          * Make the same behavior betwen 0x3000 and 0x3002.
       
    86          */
       
    87         if((formatCode != EMTPFormatCodeUndefined) && (formatCode != EMTPFormatCodeAssociation) &&(EMTPFormatCodeScript != formatCode))
       
    88             {
       
    89             responseCode = EMTPRespCodeInvalidObjectFormatCode;
       
    90             }
       
    91         }
       
    92 
       
    93     return responseCode;
       
    94     }									
       
    95 	
       
    96 /**
       
    97 GetObjectPropSupported request handler
       
    98 */
       
    99 void CMTPGetObjectPropsSupported::ServiceL()
       
   100 	{
       
   101 	TInt count = sizeof(KMTPDpSupportedProperties) / sizeof(TUint16);
       
   102 	for(TInt i = 0; i < count; i++)
       
   103 		{
       
   104 		iObjectPropsSupported->AppendUintL(KMTPDpSupportedProperties[i]);
       
   105 		}
       
   106 	TUint32 objectFormatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
       
   107 	if(objectFormatCode == EMTPFormatCodeAssociation)
       
   108 		{
       
   109 		iObjectPropsSupported->AppendUintL(EMTPObjectPropCodeAssociationType);
       
   110 		iObjectPropsSupported->AppendUintL(EMTPObjectPropCodeAssociationDesc);
       
   111 		}			
       
   112 	SendDataL(*iObjectPropsSupported);	
       
   113 	}
       
   114 
       
   115 /**
       
   116 Second-phase construction
       
   117 */		
       
   118 void CMTPGetObjectPropsSupported::ConstructL()
       
   119 	{
       
   120 	iObjectPropsSupported = CMTPTypeArray::NewL(EMTPTypeAUINT16);	
       
   121 	}
       
   122 		
       
   123 
       
   124 
       
   125 
       
   126 
       
   127 	
       
   128 
       
   129 
       
   130 
       
   131 
       
   132 
       
   133 
       
   134 
       
   135 
       
   136 
       
   137 
       
   138 
       
   139 
       
   140 
       
   141 
       
   142 
       
   143 
       
   144 	
       
   145 
       
   146 	
       
   147 
       
   148 
       
   149    	
       
   150 
       
   151 	
       
   152 
       
   153 
       
   154 
       
   155 
       
   156 
       
   157