mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetservicepropdesc.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/cmtpsvcgetservicepropdesc.cpp
       
    15 
       
    16 #include <mtp/mmtpdataproviderframework.h>
       
    17 #include <mtp/mtpdatatypeconstants.h>
       
    18 #include <mtp/cmtptypeservicepropdesclist.h>
       
    19 
       
    20 #include "cmtpsvcgetservicepropdesc.h"
       
    21 #include "mmtpservicedataprovider.h"
       
    22 #include "mmtpservicehandler.h"
       
    23 
       
    24 __FLOG_STMT(_LIT8(KComponent,"SvcGetSvcPDesc");)
       
    25 
       
    26 EXPORT_C MMTPRequestProcessor* CMTPSvcGetServicePropDesc::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider)
       
    27 	{
       
    28 	CMTPSvcGetServicePropDesc* self = new (ELeave) CMTPSvcGetServicePropDesc(aFramework, aConnection, aDataProvider);
       
    29 	CleanupStack::PushL(self);
       
    30 	self->ConstructL();
       
    31 	CleanupStack::Pop(self);
       
    32 	return self;
       
    33 	}
       
    34 
       
    35 EXPORT_C CMTPSvcGetServicePropDesc::~CMTPSvcGetServicePropDesc()
       
    36 	{
       
    37 	__FLOG(_L8("~CMTPSvcGetServicePropDesc - Entry"));
       
    38 	delete iPropDescList;
       
    39 	__FLOG(_L8("~CMTPSvcGetServicePropDesc - Exit"));
       
    40 	__FLOG_CLOSE;
       
    41 	}
       
    42 
       
    43 CMTPSvcGetServicePropDesc::CMTPSvcGetServicePropDesc(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider) :
       
    44 	CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
       
    45 	iDataProvider(aDataProvider),
       
    46 	iResponseCode(EMTPRespCodeOK)
       
    47 	{
       
    48 	}
       
    49 
       
    50 void CMTPSvcGetServicePropDesc::ConstructL()
       
    51 	{
       
    52 	__FLOG_OPEN(KMTPSubsystem, KComponent);
       
    53 	__FLOG(_L8("ConstructL - Entry"));
       
    54 	iPropDescList = CMTPTypeServicePropDescList::NewL();
       
    55 	__FLOG(_L8("ConstructL - Exit"));
       
    56 	}
       
    57 
       
    58 TMTPResponseCode CMTPSvcGetServicePropDesc::CheckRequestL()
       
    59 	{
       
    60 	__FLOG(_L8("CheckRequestL - Entry"));
       
    61 	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
       
    62 	if (EMTPRespCodeOK == responseCode)
       
    63 		{
       
    64 		TUint32 serviceID = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
       
    65 		TUint32 propCode(Request().Uint32(TMTPTypeRequest::ERequestParameter2));
       
    66 		
       
    67 		if ((iDataProvider.ServiceID() != serviceID))
       
    68 			{
       
    69 			responseCode = EMTPRespCodeInvalidServiceID;
       
    70 			__FLOG(_L8("Service Id Parameter don't be supported"));
       
    71 			}
       
    72 		
       
    73 		if (EMTPRespCodeOK == responseCode)
       
    74 			{
       
    75 			if ((KMTPNotSpecified32 != propCode) && 
       
    76 				!(iDataProvider.IsValidServicePropCodeL(propCode)))
       
    77 				{
       
    78 				responseCode = EMTPRespCodeInvalidServicePropCode;
       
    79 				__FLOG(_L8("Service Object PropCode Parameter don't be supported"));
       
    80 				}
       
    81 			}
       
    82 		}
       
    83 	__FLOG_VA((_L8("CheckRequestL - Exit with response code = 0x%04X"), responseCode));
       
    84 	return responseCode;
       
    85 	}
       
    86 
       
    87 void CMTPSvcGetServicePropDesc::ServiceL()
       
    88 	{
       
    89 	__FLOG(_L8("ServiceL - Entry"));
       
    90 	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
       
    91 	
       
    92 	if (KMTPNotSpecified32 != propCode)
       
    93 		{
       
    94 		iResponseCode = (iDataProvider.ServiceHandler())->GetServicePropDescL(propCode, *iPropDescList);
       
    95 		}
       
    96 	else
       
    97 		{
       
    98 		RArray<TUint32> propCodeArray;
       
    99 		CleanupClosePushL(propCodeArray);
       
   100 		(iDataProvider.ServiceHandler())->GetAllSevicePropCodesL(propCodeArray); 
       
   101 		TInt count = propCodeArray.Count();
       
   102 		for (TInt i = 0; i < count && iResponseCode == EMTPRespCodeOK; i++)
       
   103 			{
       
   104 			iResponseCode = (iDataProvider.ServiceHandler())->GetServicePropDescL(propCodeArray[i], *iPropDescList);
       
   105 			}
       
   106 		CleanupStack::PopAndDestroy(&propCodeArray);
       
   107 		}
       
   108 	SendDataL(*iPropDescList);
       
   109 	__FLOG_VA((_L8("ServiceL - Exit with Response Code: 0x%x, Service Property Count: %u"), iResponseCode, iPropDescList->NumberOfElements()));
       
   110 	}
       
   111 
       
   112 TBool CMTPSvcGetServicePropDesc::DoHandleResponsePhaseL()
       
   113 	{
       
   114 	__FLOG(_L8("DoHandleResponsePhaseL - Entry"));
       
   115 	TMTPResponseCode responseCode = (iCancelled ? EMTPRespCodeIncompleteTransfer : iResponseCode);
       
   116 	SendResponseL(responseCode);
       
   117 	__FLOG_VA((_L8("DoHandleResponsePhaseL - Exit with Response Code: 0x%x"), iResponseCode));
       
   118 	return EFalse;
       
   119 	}
       
   120