mtpfws/mtpfw/dataproviders/dputility/src/cmtpsvcgetserviceproplist.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/cmtpsvcgetserviceproplist.cpp
       
    15 
       
    16 #include "cmtpsvcgetserviceproplist.h"
       
    17 #include "mmtpservicedataprovider.h"
       
    18 #include "mmtpservicehandler.h"
       
    19 
       
    20 __FLOG_STMT (_LIT8(KComponent,"SvcGetSvcPList");)
       
    21 
       
    22 const TUint16 KMTPServicePropsAll(0x0000);
       
    23 
       
    24 EXPORT_C MMTPRequestProcessor* CMTPSvcGetServicePropList::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider)
       
    25 	{
       
    26 	CMTPSvcGetServicePropList* self = new (ELeave) CMTPSvcGetServicePropList(aFramework, aConnection, aDataProvider);
       
    27 	CleanupStack::PushL(self);
       
    28 	self->ConstructL();
       
    29 	CleanupStack::Pop(self);
       
    30 	return self;
       
    31 	}
       
    32 
       
    33 EXPORT_C CMTPSvcGetServicePropList::~CMTPSvcGetServicePropList()
       
    34 	{
       
    35 	__FLOG(_L8("~CMTPSvcGetServicePropList - Entry"));
       
    36 	delete iServicePropList;
       
    37 	__FLOG(_L8("~CMTPSvcGetServicePropList - Exit"));
       
    38 	__FLOG_CLOSE;
       
    39 	}
       
    40 
       
    41 CMTPSvcGetServicePropList::CMTPSvcGetServicePropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider) :
       
    42 	CMTPRequestProcessor(aFramework, aConnection, 0, NULL), iDataProvider(aDataProvider), iResponseCode(EMTPRespCodeOK)
       
    43 	{	
       
    44 	}
       
    45 
       
    46 void CMTPSvcGetServicePropList::ConstructL()
       
    47 	{
       
    48 	__FLOG_OPEN(KMTPSubsystem, KComponent);
       
    49 	__FLOG(_L8("ConstructL - Entry")); 
       
    50 	iServicePropList = CMTPTypeServicePropList::NewL();
       
    51 	__FLOG(_L8("ConstructL - Exit")); 
       
    52 	}
       
    53 
       
    54 void CMTPSvcGetServicePropList::ServiceL()
       
    55 	{
       
    56 	__FLOG(_L8("ServiceL - Entry"));
       
    57 	TUint32 propcode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
       
    58 	if (KMTPServicePropertyAll == propcode)
       
    59 		{
       
    60 		RArray<TUint32> servicePropArray;
       
    61 		CleanupClosePushL(servicePropArray);
       
    62 		(iDataProvider.ServiceHandler())->GetAllSevicePropCodesL(servicePropArray);
       
    63 		TInt count = servicePropArray.Count();
       
    64 		for (TInt i = 0; i < count && iResponseCode == EMTPRespCodeOK; i++)
       
    65 			{
       
    66 			iResponseCode = (iDataProvider.ServiceHandler())->GetServicePropertyL(servicePropArray[i], *iServicePropList);
       
    67 			}
       
    68 		CleanupStack::PopAndDestroy(&servicePropArray);
       
    69 		}
       
    70 	else
       
    71 		{
       
    72 		iResponseCode = (iDataProvider.ServiceHandler())->GetServicePropertyL(propcode, *iServicePropList);
       
    73 		}
       
    74 	SendDataL(*iServicePropList);
       
    75 	__FLOG(_L8("ServiceL - Exit"));
       
    76 	}
       
    77 
       
    78 TMTPResponseCode CMTPSvcGetServicePropList::CheckRequestL()
       
    79 {
       
    80 	__FLOG(_L8("CheckRequestL - Entry")); 
       
    81 	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
       
    82 	if (EMTPRespCodeOK == responseCode)
       
    83 		{
       
    84 		TUint32 serviceId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
       
    85 		if (serviceId != iDataProvider.ServiceID())
       
    86 			{
       
    87 			responseCode  = EMTPRespCodeInvalidServiceID;
       
    88 			}
       
    89 		
       
    90 		if (EMTPRespCodeOK == responseCode)
       
    91 			{
       
    92 			TUint32 propcode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
       
    93 			if (KMTPServicePropsAll != propcode && !iDataProvider.IsValidServicePropCodeL(propcode))
       
    94 				{
       
    95 				responseCode = EMTPRespCodeInvalidServicePropCode;
       
    96 				}
       
    97 			}
       
    98 		}
       
    99 	__FLOG_VA((_L8("CheckRequestL - Exit with responseCode = 0x%04X"), responseCode));
       
   100 	return responseCode;
       
   101 }
       
   102 
       
   103 TBool CMTPSvcGetServicePropList::DoHandleResponsePhaseL()
       
   104 	{
       
   105 	__FLOG(_L8("DoHandleResponsePhaseL - Entry"));
       
   106 	TMTPResponseCode responseCode = (iCancelled ? EMTPRespCodeIncompleteTransfer : iResponseCode);
       
   107 	SendResponseL(responseCode);
       
   108 	__FLOG_VA((_L8("DoHandleResponsePhaseL - Exit with Response Code: 0x%x"), iResponseCode));
       
   109 	return EFalse;
       
   110 	}