|
1 // Copyright (c) 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 // |
|
15 |
|
16 |
|
17 #include <mtp/cmtptypeinterdependentpropdesc.h> |
|
18 #include <mtp/cmtptypeobjectpropdesc.h> |
|
19 #include <mtp/mtpprotocolconstants.h> |
|
20 #include <mtp/mmtpdataproviderframework.h> |
|
21 #include "cmtprequestprocessor.h" |
|
22 #include "cmtppictbridgegetformatcapabilities.h" |
|
23 #include "ptpdef.h" |
|
24 |
|
25 /** |
|
26 Two-phase construction method |
|
27 @param aFramework The data provider framework |
|
28 @param aConnection The connection object |
|
29 @param aDataProvider The pictbridge Dp |
|
30 */ |
|
31 MMTPRequestProcessor* CMTPPictBridgeDpGetFormatCapabilities::NewL( |
|
32 MMTPDataProviderFramework& aFramework, |
|
33 MMTPConnection& aConnection, |
|
34 CMTPPictBridgeDataProvider& aDataProvider) |
|
35 { |
|
36 CMTPPictBridgeDpGetFormatCapabilities* self = new (ELeave) CMTPPictBridgeDpGetFormatCapabilities(aFramework, aConnection, aDataProvider); |
|
37 CleanupStack::PushL(self); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 /** |
|
44 Destructor |
|
45 */ |
|
46 CMTPPictBridgeDpGetFormatCapabilities::~CMTPPictBridgeDpGetFormatCapabilities() |
|
47 { |
|
48 delete iCapabilityList; |
|
49 __FLOG_CLOSE; |
|
50 } |
|
51 |
|
52 /** |
|
53 ServiceL |
|
54 */ |
|
55 void CMTPPictBridgeDpGetFormatCapabilities::ServiceL() |
|
56 { |
|
57 __FLOG(_L8(">> CMTPPictBridgeDpGetFormatCapabilities::ServiceL")); |
|
58 delete iCapabilityList; |
|
59 iCapabilityList = CMTPTypeFormatCapabilityList::NewL(); |
|
60 iFormatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
|
61 BuildFormatScriptL(); |
|
62 |
|
63 SendDataL(*iCapabilityList); |
|
64 __FLOG(_L8("<< CMTPPictBridgeDpGetFormatCapabilities::ServiceL")); |
|
65 } |
|
66 |
|
67 /** |
|
68 BuildFormatScriptL |
|
69 */ |
|
70 void CMTPPictBridgeDpGetFormatCapabilities::BuildFormatScriptL() |
|
71 { |
|
72 __FLOG(_L8(">> CMTPPictBridgeDpGetFormatCapabilities::BuildFormatScriptL")); |
|
73 CMTPTypeInterdependentPropDesc* interDesc = CMTPTypeInterdependentPropDesc::NewLC(); |
|
74 CMTPTypeFormatCapability* frmCap = CMTPTypeFormatCapability::NewLC( EMTPFormatCodeScript ,interDesc ); |
|
75 |
|
76 //for group code |
|
77 //EMTPObjectPropCodeStorageID |
|
78 CMTPTypeObjectPropDesc* objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeStorageID); |
|
79 objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeStorageID)); |
|
80 frmCap->AppendL( objectProperty ); |
|
81 |
|
82 //EMTPObjectPropCodeObjectFormat |
|
83 objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectFormat); |
|
84 objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeObjectFormat)); |
|
85 frmCap->AppendL( objectProperty ); |
|
86 |
|
87 //EMTPObjectPropCodeProtectionStatus |
|
88 frmCap->AppendL( ServiceProtectionStatusL() ); |
|
89 |
|
90 //EMTPObjectPropCodeObjectSize |
|
91 objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectSize); |
|
92 objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeObjectSize)); |
|
93 frmCap->AppendL( objectProperty ); |
|
94 |
|
95 //EMTPObjectPropCodeObjectFileName |
|
96 objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectFileName); |
|
97 objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeObjectFileName)); |
|
98 frmCap->AppendL( objectProperty ); |
|
99 |
|
100 //EMTPObjectPropCodeDateModified |
|
101 objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeDateModified); |
|
102 objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeDateModified)); |
|
103 frmCap->AppendL( objectProperty ); |
|
104 |
|
105 //EMTPObjectPropCodeParentObject |
|
106 objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeParentObject); |
|
107 objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeParentObject)); |
|
108 frmCap->AppendL( objectProperty ); |
|
109 |
|
110 //EMTPObjectPropCodePersistentUniqueObjectIdentifier |
|
111 objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodePersistentUniqueObjectIdentifier); |
|
112 objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodePersistentUniqueObjectIdentifier)); |
|
113 frmCap->AppendL( objectProperty ); |
|
114 |
|
115 //EMTPObjectPropCodeName |
|
116 objectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeName); |
|
117 objectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeName)); |
|
118 frmCap->AppendL( objectProperty); |
|
119 |
|
120 //EMTPObjectPropCodeNonConsumable |
|
121 frmCap->AppendL(ServiceNonConsumableL() ); |
|
122 |
|
123 iCapabilityList->AppendL(frmCap); |
|
124 CleanupStack::Pop(frmCap); |
|
125 CleanupStack::Pop(interDesc); |
|
126 __FLOG(_L8("<< CMTPPictBridgeDpGetFormatCapabilities::BuildFormatScriptL")); |
|
127 } |
|
128 |
|
129 /** |
|
130 ServiceProtectionStatusL |
|
131 */ |
|
132 CMTPTypeObjectPropDesc* CMTPPictBridgeDpGetFormatCapabilities::ServiceProtectionStatusL() |
|
133 { |
|
134 CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT16); |
|
135 CleanupStack::PushL(expectedForm); |
|
136 //Currently, we only support EMTPProtectionNoProtection and EMTPProtectionReadOnly |
|
137 TUint16 values[] = {EMTPProtectionNoProtection, EMTPProtectionReadOnly}; |
|
138 TUint numValues((sizeof(values) / sizeof(values[0]))); |
|
139 for (TUint i = 0; i < numValues; i++) |
|
140 { |
|
141 TMTPTypeUint16 data(values[i]); |
|
142 expectedForm->AppendSupportedValueL(data); |
|
143 } |
|
144 CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeProtectionStatus, *expectedForm); |
|
145 ret->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeProtectionStatus)); |
|
146 CleanupStack::PopAndDestroy(expectedForm); |
|
147 return ret; |
|
148 } |
|
149 |
|
150 /** |
|
151 ServiceNonConsumableL |
|
152 */ |
|
153 CMTPTypeObjectPropDesc* CMTPPictBridgeDpGetFormatCapabilities::ServiceNonConsumableL() |
|
154 { |
|
155 CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT8); |
|
156 CleanupStack::PushL(expectedForm); |
|
157 TUint8 values[] = {0,1}; |
|
158 TUint numValues((sizeof(values) / sizeof(values[0]))); |
|
159 for (TUint i = 0; i < numValues; i++) |
|
160 { |
|
161 TMTPTypeUint8 data(values[i]); |
|
162 expectedForm->AppendSupportedValueL(data); |
|
163 } |
|
164 CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeNonConsumable, *expectedForm); |
|
165 ret->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(EMTPObjectPropCodeNonConsumable)); |
|
166 CleanupStack::PopAndDestroy(expectedForm); |
|
167 |
|
168 return ret; |
|
169 } |
|
170 |
|
171 /** |
|
172 CheckRequestL |
|
173 */ |
|
174 TMTPResponseCode CMTPPictBridgeDpGetFormatCapabilities::CheckRequestL() |
|
175 { |
|
176 __FLOG(_L8(">> CMTPPictBridgeDpGetFormatCapabilities::CheckRequestL")); |
|
177 TMTPResponseCode response = CMTPRequestProcessor::CheckRequestL(); |
|
178 if(EMTPRespCodeOK != response) |
|
179 return response; |
|
180 |
|
181 TUint32 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
|
182 |
|
183 if((formatCode != EMTPFormatCodeScript)&& (iFormatCode != KMTPFormatsAll)) |
|
184 { |
|
185 return EMTPRespCodeInvalidObjectFormatCode; |
|
186 } |
|
187 |
|
188 __FLOG(_L8("<< CMTPPictBridgeDpGetFormatCapabilities::CheckRequestL")); |
|
189 return EMTPRespCodeOK; |
|
190 } |
|
191 |
|
192 /** |
|
193 Standard c++ constructor |
|
194 */ |
|
195 CMTPPictBridgeDpGetFormatCapabilities::CMTPPictBridgeDpGetFormatCapabilities( |
|
196 MMTPDataProviderFramework& aFramework, |
|
197 MMTPConnection& aConnection, |
|
198 CMTPPictBridgeDataProvider& aDataProvider): |
|
199 CMTPRequestProcessor(aFramework, aConnection, 0, NULL), |
|
200 iPictBridgeDP(aDataProvider) |
|
201 { |
|
202 } |
|
203 |
|
204 /** |
|
205 ConstructL |
|
206 */ |
|
207 void CMTPPictBridgeDpGetFormatCapabilities::ConstructL() |
|
208 { |
|
209 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
210 __FLOG(_L8("CMTPPictBridgeDpGetFormatCapabilities::ConstructL")); |
|
211 } |
|
212 |
|
213 /** |
|
214 GetPropertyGroupNumber |
|
215 */ |
|
216 TUint16 CMTPPictBridgeDpGetFormatCapabilities::GetPropertyGroupNumber(const TUint16 aPropCode) const |
|
217 { |
|
218 |
|
219 // begin from group 1, since group 0 is not used |
|
220 for(int group = 1; group <= KMTPDpPropertyGroupNumber; group++) |
|
221 { |
|
222 for( int propCodeIndex = 0 ; propCodeIndex < KMTPDpPropertyNumber ; propCodeIndex++) |
|
223 { |
|
224 if(KMTPDpPropertyGroups[group][propCodeIndex] == aPropCode) |
|
225 { |
|
226 return group; |
|
227 } |
|
228 } |
|
229 } |
|
230 |
|
231 // if not foud, the group number should be 0. |
|
232 return 0; |
|
233 } |