mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetobjectinfo.cpp
changeset 0 d0791faffa3f
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2008-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 // mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetobjectinfo.cpp
       
    15 
       
    16 #include <mtp/mmtpdataproviderframework.h>
       
    17 #include <mtp/mtpprotocolconstants.h>
       
    18 #include <mtp/mmtpobjectmgr.h>
       
    19 #include <mtp/cmtptypeobjectinfo.h>
       
    20 #include <mtp/cmtpobjectmetadata.h>
       
    21 
       
    22 
       
    23 #include "cmtpsvcgetobjectinfo.h"
       
    24 #include "mmtpservicedataprovider.h"
       
    25 #include "mmtpsvcobjecthandler.h"
       
    26 
       
    27 __FLOG_STMT(_LIT8(KComponent,"SvcGetObjInfo");)
       
    28 
       
    29 EXPORT_C MMTPRequestProcessor* CMTPSvcGetObjectInfo::NewL(MMTPDataProviderFramework& aFramework, 
       
    30 														MMTPConnection& aConnection, 
       
    31 														MMTPServiceDataProvider& aDataProvider)
       
    32 	{
       
    33 	CMTPSvcGetObjectInfo* self = new (ELeave) CMTPSvcGetObjectInfo(aFramework, aConnection, aDataProvider);
       
    34 	CleanupStack::PushL(self);
       
    35 	self->ConstructL();
       
    36 	CleanupStack::Pop(self);
       
    37 	return self;
       
    38 	}
       
    39 
       
    40 EXPORT_C CMTPSvcGetObjectInfo::~CMTPSvcGetObjectInfo()
       
    41 	{
       
    42 	__FLOG(_L8("~CMTPSvcGetObjectInfo - Destructed"));
       
    43 	delete iReceivedObjectMetaData;
       
    44 	delete iObjectInfo;
       
    45 	__FLOG_CLOSE;
       
    46 	}
       
    47 
       
    48 CMTPSvcGetObjectInfo::CMTPSvcGetObjectInfo(MMTPDataProviderFramework& aFramework,
       
    49 									MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider)
       
    50 	: CMTPRequestProcessor(aFramework, aConnection, 0, NULL), iDataProvider(aDataProvider)
       
    51 	{
       
    52 	}
       
    53 	
       
    54 void CMTPSvcGetObjectInfo::ConstructL()
       
    55 	{
       
    56 	__FLOG_OPEN(KMTPSubsystem, KComponent);
       
    57 	__FLOG(_L8("ConstructL -  - Entry"));
       
    58 	
       
    59     iObjectInfo = CMTPTypeObjectInfo::NewL();
       
    60     
       
    61     __FLOG(_L8("ConstructL -  - Exit"));
       
    62 	}
       
    63 
       
    64 TMTPResponseCode CMTPSvcGetObjectInfo::CheckRequestL()
       
    65 	{
       
    66 	__FLOG(_L8("CheckRequestL - Entry"));
       
    67 	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
       
    68 	if (EMTPRespCodeOK == responseCode)
       
    69 		{
       
    70 		TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
       
    71 		MMTPObjectMgr& objectMgr(iFramework.ObjectMgr());
       
    72 		iReceivedObjectMetaData = CMTPObjectMetaData::NewL();
       
    73 		if (objectMgr.ObjectL(objectHandle, *iReceivedObjectMetaData))
       
    74 			{
       
    75 			//Check whether the owner of this object is correct data provider
       
    76 			if (iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EDataProviderId) != iFramework.DataProviderId())
       
    77 				{
       
    78 				responseCode = EMTPRespCodeInvalidObjectHandle;
       
    79 				__FLOG(_L8("CheckRequestL - DataProviderId dismatch"));
       
    80 				}
       
    81 			else
       
    82 				{
       
    83 				// Check format and set handler
       
    84 				TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode);
       
    85 				iObjectHandler = iDataProvider.ObjectHandler(formatCode);
       
    86 				if (!iObjectHandler)
       
    87 					{
       
    88 					responseCode = EMTPRespCodeInvalidObjectFormatCode;
       
    89 					}
       
    90 				}
       
    91 			}
       
    92 		else
       
    93 			{
       
    94 			responseCode = EMTPRespCodeInvalidObjectHandle;
       
    95 			}
       
    96 		}
       
    97 	__FLOG_VA((_L8("CheckRequestL - Exit with response code = 0x%04X"), responseCode));
       
    98 	return responseCode;
       
    99 	}
       
   100 	
       
   101 void CMTPSvcGetObjectInfo::ServiceL()
       
   102 	{
       
   103 	__FLOG(_L8("ServiceL - Entry"));
       
   104 	__ASSERT_DEBUG(iObjectHandler, User::Invariant());
       
   105 	TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
       
   106 	iObjectHandler->GetObjectInfoL(*iReceivedObjectMetaData, *iObjectInfo);
       
   107 	SendDataL(*iObjectInfo);
       
   108 	__FLOG(_L8("ServiceL - Exit"));
       
   109 	}