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