|
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/cmtpsetserviceproplist.cpp |
|
15 |
|
16 #include "cmtpsvcsetserviceproplist.h" |
|
17 #include "mmtpservicedataprovider.h" |
|
18 #include "mmtpservicehandler.h" |
|
19 |
|
20 __FLOG_STMT (_LIT8(KComponent, "SvcSetSvcPList");) |
|
21 |
|
22 EXPORT_C MMTPRequestProcessor* CMTPSvcSetServicePropList::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider) |
|
23 { |
|
24 CMTPSvcSetServicePropList* self = new (ELeave) CMTPSvcSetServicePropList(aFramework, aConnection, aDataProvider); |
|
25 CleanupStack::PushL(self); |
|
26 self->ConstructL(); |
|
27 CleanupStack::Pop(self); |
|
28 return self; |
|
29 } |
|
30 |
|
31 EXPORT_C CMTPSvcSetServicePropList::~CMTPSvcSetServicePropList() |
|
32 { |
|
33 __FLOG(_L8("~CMTPSvcSetServicePropList - Entry")); |
|
34 delete iServicePropList; |
|
35 __FLOG(_L8("~CMTPSvcSetServicePropList - Exit")); |
|
36 __FLOG_CLOSE; |
|
37 } |
|
38 |
|
39 CMTPSvcSetServicePropList::CMTPSvcSetServicePropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, MMTPServiceDataProvider& aDataProvider) : |
|
40 CMTPRequestProcessor(aFramework, aConnection, 0, NULL), iDataProvider(aDataProvider) |
|
41 { |
|
42 } |
|
43 |
|
44 void CMTPSvcSetServicePropList::ConstructL() |
|
45 { |
|
46 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
47 __FLOG(_L8("ConstructL - Entry")); |
|
48 iServicePropList = CMTPTypeServicePropList::NewL(); |
|
49 __FLOG(_L8("ConstructL - Exit")); |
|
50 } |
|
51 |
|
52 TMTPResponseCode CMTPSvcSetServicePropList::CheckRequestL() |
|
53 { |
|
54 __FLOG(_L8("CheckRequestL - Entry")); |
|
55 TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL(); |
|
56 if (EMTPRespCodeOK == responseCode) |
|
57 { |
|
58 TUint32 serviceId = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
|
59 if (serviceId != iDataProvider.ServiceID()) |
|
60 { |
|
61 responseCode = EMTPRespCodeInvalidServiceID; |
|
62 } |
|
63 } |
|
64 |
|
65 __FLOG_VA((_L8("CheckRequestL - Exit with responseCode = 0x%04X"), responseCode)); |
|
66 return responseCode; |
|
67 } |
|
68 |
|
69 void CMTPSvcSetServicePropList::ServiceL() |
|
70 { |
|
71 __FLOG(_L8("ServiceL - Entry")); |
|
72 //Recieve the data from the property list |
|
73 ReceiveDataL(*iServicePropList); |
|
74 __FLOG(_L8("ServiceL - Exit")); |
|
75 } |
|
76 |
|
77 TBool CMTPSvcSetServicePropList::DoHandleResponsePhaseL() |
|
78 { |
|
79 __FLOG(_L8("DoHandleResponsePhaseL - Entry")); |
|
80 TUint32 parameter = 0; |
|
81 TMTPResponseCode responseCode = EMTPRespCodeOK; |
|
82 const TUint count = iServicePropList->NumberOfElements(); |
|
83 for (TUint i = 0; i < count && responseCode == EMTPRespCodeOK; i++) |
|
84 { |
|
85 CMTPTypeServicePropListElement& element = iServicePropList->Element(i); |
|
86 |
|
87 if(iDataProvider.ServiceID() != element.Uint32L(CMTPTypeServicePropListElement::EObjectHandle)) |
|
88 { |
|
89 parameter = i; |
|
90 responseCode = EMTPRespCodeInvalidServiceID; |
|
91 break; |
|
92 } |
|
93 |
|
94 responseCode = (iDataProvider.ServiceHandler())->SetServicePropertyL(element); |
|
95 if (EMTPRespCodeOK != responseCode) |
|
96 { |
|
97 parameter = i; |
|
98 break; |
|
99 } |
|
100 } |
|
101 SendResponseL(responseCode, 1, ¶meter); |
|
102 __FLOG_VA((_L8("DoHandleResponsePhaseL - Exit with responseCode = 0x%04X and failed index: %u"), responseCode, parameter)); |
|
103 return EFalse; |
|
104 } |
|
105 |
|
106 TBool CMTPSvcSetServicePropList::HasDataphase() const |
|
107 { |
|
108 return ETrue; |
|
109 } |