|
1 // Copyright (c) 2006-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 #include <mtp/cmtptypeinterdependentpropdesc.h> |
|
17 #include <mtp/cmtptypeobjectpropdesc.h> |
|
18 #include <mtp/mtpprotocolconstants.h> |
|
19 #include <mtp/mmtpdataproviderframework.h> |
|
20 #include <mtp/cmtptypestring.h> |
|
21 |
|
22 #include "cmtpdataprovidercontroller.h" |
|
23 #include "cmtpdataprovider.h" |
|
24 #include "mtpframeworkconst.h" |
|
25 #include "cmtpgetformatcapabilities.h" |
|
26 |
|
27 |
|
28 |
|
29 EXPORT_C MMTPRequestProcessor* CMTPGetFormatCapabilities::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) |
|
30 { |
|
31 CMTPGetFormatCapabilities* self = new (ELeave) CMTPGetFormatCapabilities(aFramework, aConnection); |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop(self); |
|
35 return self; |
|
36 } |
|
37 |
|
38 EXPORT_C CMTPGetFormatCapabilities::~CMTPGetFormatCapabilities() |
|
39 { |
|
40 //[SP-Format-0x3002] |
|
41 //Make the same behavior betwen 0x3000 and 0x3002. |
|
42 //iSingletons is used to judge whether FileDP supports 0x3002 or not. |
|
43 iSingletons.Close(); |
|
44 |
|
45 delete iCapabilityList; |
|
46 } |
|
47 |
|
48 void CMTPGetFormatCapabilities::ServiceL() |
|
49 { |
|
50 delete iCapabilityList; |
|
51 iCapabilityList = CMTPTypeFormatCapabilityList::NewL(); |
|
52 iFormatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
|
53 |
|
54 /** |
|
55 * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002, |
|
56 * but it does not really own the format 0x3002. |
|
57 * |
|
58 * Make the same behavior betwen 0x3000 and 0x3002. |
|
59 */ |
|
60 if((EMTPFormatCodeUndefined == iFormatCode) || (EMTPFormatCodeScript == iFormatCode)) |
|
61 { |
|
62 BuildFormatAsUndefinedL(iFormatCode); |
|
63 } |
|
64 else if(EMTPFormatCodeAssociation == iFormatCode) |
|
65 { |
|
66 BuildFormatAssociationL(); |
|
67 } |
|
68 else |
|
69 { |
|
70 if(iFramework.DataProviderId() == KMTPDeviceDPID) |
|
71 { |
|
72 BuildFormatAssociationL(); |
|
73 } |
|
74 else if(iFramework.DataProviderId() == KMTPFileDPID) |
|
75 { |
|
76 BuildFormatAsUndefinedL(EMTPFormatCodeUndefined); |
|
77 |
|
78 //[SP-Format-0x3002] |
|
79 //Make the same behavior betwen 0x3000 and 0x3002. |
|
80 CMTPDataProvider& filedp(iSingletons.DpController().DataProviderL(KMTPFileDPID)); |
|
81 if(filedp.SupportedCodes(EObjectCaptureFormats).Find(EMTPFormatCodeScript) != KErrNotFound) |
|
82 { |
|
83 BuildFormatAsUndefinedL(EMTPFormatCodeScript); |
|
84 } |
|
85 } |
|
86 } |
|
87 |
|
88 |
|
89 SendDataL(*iCapabilityList); |
|
90 } |
|
91 |
|
92 void CMTPGetFormatCapabilities::BuildFormatAssociationL() |
|
93 { |
|
94 CMTPTypeInterdependentPropDesc* interDesc = CMTPTypeInterdependentPropDesc::NewLC(); |
|
95 CMTPTypeFormatCapability* frmCap = CMTPTypeFormatCapability::NewLC( EMTPFormatCodeAssociation ,interDesc ); |
|
96 |
|
97 //EMTPObjectPropCodeStorageID |
|
98 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeStorageID) ); |
|
99 |
|
100 //EMTPObjectPropCodeObjectFormat |
|
101 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectFormat) ); |
|
102 |
|
103 //EMTPObjectPropCodeProtectionStatus |
|
104 frmCap->AppendL( ServiceProtectionStatusL() ); |
|
105 |
|
106 //EMTPObjectPropCodeAssociationType |
|
107 frmCap->AppendL( ServiceAssociationTypeL() ); |
|
108 |
|
109 //EMTPObjectPropCodeAssociationDesc |
|
110 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeAssociationDesc) ); |
|
111 |
|
112 //EMTPObjectPropCodeObjectSize |
|
113 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectSize) ); |
|
114 |
|
115 //EMTPObjectPropCodeObjectFileName |
|
116 _LIT(KMtpObjDescObjFileName, "[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 7}\\.[[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 2}]?"); |
|
117 CMTPTypeString* form = CMTPTypeString::NewLC( KMtpObjDescObjFileName ); |
|
118 frmCap->AppendL(CMTPTypeObjectPropDesc::NewL( EMTPObjectPropCodeObjectFileName, |
|
119 CMTPTypeObjectPropDesc::ERegularExpressionForm, form)); |
|
120 CleanupStack::PopAndDestroy(form ); |
|
121 |
|
122 //EMTPObjectPropCodeDateModified |
|
123 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeDateModified) ); |
|
124 |
|
125 //EMTPObjectPropCodeParentObject |
|
126 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeParentObject) ); |
|
127 |
|
128 //EMTPObjectPropCodePersistentUniqueObjectIdentifier |
|
129 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodePersistentUniqueObjectIdentifier) ); |
|
130 |
|
131 //EMTPObjectPropCodeName |
|
132 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeName)); |
|
133 |
|
134 //EMTPObjectPropCodeNonConsumable |
|
135 frmCap->AppendL(ServiceNonConsumableL() ); |
|
136 |
|
137 iCapabilityList->AppendL(frmCap); |
|
138 CleanupStack::Pop(frmCap); |
|
139 CleanupStack::Pop(interDesc); |
|
140 } |
|
141 |
|
142 |
|
143 void CMTPGetFormatCapabilities::BuildFormatAsUndefinedL( TUint aFormatCode ) |
|
144 { |
|
145 CMTPTypeInterdependentPropDesc* interDesc = CMTPTypeInterdependentPropDesc::NewLC(); |
|
146 CMTPTypeFormatCapability* frmCap = CMTPTypeFormatCapability::NewLC( aFormatCode ,interDesc ); |
|
147 |
|
148 //EMTPObjectPropCodeStorageID |
|
149 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeStorageID) ); |
|
150 |
|
151 //EMTPObjectPropCodeObjectFormat |
|
152 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectFormat) ); |
|
153 |
|
154 //EMTPObjectPropCodeProtectionStatus |
|
155 frmCap->AppendL( ServiceProtectionStatusL() ); |
|
156 |
|
157 //EMTPObjectPropCodeObjectSize |
|
158 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectSize) ); |
|
159 |
|
160 //EMTPObjectPropCodeObjectFileName |
|
161 _LIT(KMtpObjDescObjFileName, "[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 7}\\.[[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 2}]?"); |
|
162 CMTPTypeString* form = CMTPTypeString::NewLC( KMtpObjDescObjFileName ); |
|
163 frmCap->AppendL(CMTPTypeObjectPropDesc::NewL( EMTPObjectPropCodeObjectFileName, |
|
164 CMTPTypeObjectPropDesc::ERegularExpressionForm, form)); |
|
165 CleanupStack::PopAndDestroy(form ); |
|
166 |
|
167 //EMTPObjectPropCodeDateModified |
|
168 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeDateModified) ); |
|
169 |
|
170 //EMTPObjectPropCodeParentObject |
|
171 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeParentObject) ); |
|
172 |
|
173 //EMTPObjectPropCodePersistentUniqueObjectIdentifier |
|
174 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodePersistentUniqueObjectIdentifier) ); |
|
175 |
|
176 //EMTPObjectPropCodeName |
|
177 frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeName)); |
|
178 |
|
179 //EMTPObjectPropCodeNonConsumable |
|
180 frmCap->AppendL(ServiceNonConsumableL() ); |
|
181 |
|
182 iCapabilityList->AppendL(frmCap); |
|
183 CleanupStack::Pop(frmCap); |
|
184 CleanupStack::Pop(interDesc); |
|
185 } |
|
186 |
|
187 CMTPTypeObjectPropDesc* CMTPGetFormatCapabilities::ServiceProtectionStatusL() |
|
188 { |
|
189 CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT16); |
|
190 CleanupStack::PushL(expectedForm); |
|
191 //Currently, we only support EMTPProtectionNoProtection and EMTPProtectionReadOnly |
|
192 // TUint16 values[] = {EMTPProtectionNoProtection, EMTPProtectionReadOnly, EMTPProtectionReadOnlyData, EMTPProtectionNonTransferable}; |
|
193 TUint16 values[] = {EMTPProtectionNoProtection, EMTPProtectionReadOnly}; |
|
194 TUint numValues((sizeof(values) / sizeof(values[0]))); |
|
195 for (TUint i = 0; i < numValues; i++) |
|
196 { |
|
197 TMTPTypeUint16 data(values[i]); |
|
198 expectedForm->AppendSupportedValueL(data); |
|
199 } |
|
200 CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeProtectionStatus, *expectedForm); |
|
201 CleanupStack::PopAndDestroy(expectedForm); |
|
202 return ret; |
|
203 } |
|
204 |
|
205 CMTPTypeObjectPropDesc* CMTPGetFormatCapabilities::ServiceAssociationTypeL() |
|
206 { |
|
207 CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT16); |
|
208 CleanupStack::PushL(expectedForm); |
|
209 const TUint16 KMtpValues[] = {EMTPAssociationTypeUndefined, EMTPAssociationTypeGenericFolder}; |
|
210 const TUint KNumMtpValues(sizeof(KMtpValues) / sizeof(KMtpValues[0])); |
|
211 const TUint16 KPtpValues[] = {EMTPAssociationTypeUndefined, EMTPAssociationTypeGenericFolder, EMTPAssociationTypeAlbum, EMTPAssociationTypeTimeSequence, EMTPAssociationTypeHorizontalPanoramic, EMTPAssociationTypeVerticalPanoramic, EMTPAssociationType2DPanoramic,EMTPAssociationTypeAncillaryData}; |
|
212 const TUint KNumPtpValues(sizeof(KPtpValues) / sizeof(KPtpValues[0])); |
|
213 |
|
214 TUint numValues(KNumMtpValues); |
|
215 const TUint16* values = KMtpValues; |
|
216 if (EModeMTP != iFramework.Mode()) |
|
217 { |
|
218 numValues = KNumPtpValues; |
|
219 values = KPtpValues; |
|
220 } |
|
221 |
|
222 for (TUint i = 0; i < numValues; i++) |
|
223 { |
|
224 TMTPTypeUint16 data(values[i]); |
|
225 expectedForm->AppendSupportedValueL(data); |
|
226 } |
|
227 CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeAssociationType, *expectedForm); |
|
228 CleanupStack::PopAndDestroy(expectedForm); |
|
229 return ret; |
|
230 } |
|
231 |
|
232 CMTPTypeObjectPropDesc* CMTPGetFormatCapabilities::ServiceNonConsumableL() |
|
233 { |
|
234 CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT8); |
|
235 CleanupStack::PushL(expectedForm); |
|
236 TUint8 values[] = {0,1}; |
|
237 TUint numValues((sizeof(values) / sizeof(values[0]))); |
|
238 for (TUint i = 0; i < numValues; i++) |
|
239 { |
|
240 TMTPTypeUint8 data(values[i]); |
|
241 expectedForm->AppendSupportedValueL(data); |
|
242 } |
|
243 CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeNonConsumable, *expectedForm); |
|
244 CleanupStack::PopAndDestroy(expectedForm); |
|
245 |
|
246 return ret; |
|
247 } |
|
248 |
|
249 TMTPResponseCode CMTPGetFormatCapabilities::CheckRequestL() |
|
250 { |
|
251 TMTPResponseCode response = CMTPRequestProcessor::CheckRequestL(); |
|
252 if( EMTPRespCodeOK != response ) |
|
253 return response; |
|
254 |
|
255 TUint32 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
|
256 |
|
257 //[SP-Format-0x3002] |
|
258 //Make the same behavior betwen 0x3000 and 0x3002. |
|
259 if( (formatCode != EMTPFormatCodeUndefined) && (formatCode != EMTPFormatCodeAssociation) && (formatCode != KMTPFormatsAll) && ( EMTPFormatCodeScript != formatCode )) |
|
260 { |
|
261 return EMTPRespCodeInvalidObjectFormatCode; |
|
262 } |
|
263 |
|
264 if( (formatCode == EMTPFormatCodeAssociation) && (iFramework.DataProviderId() != KMTPDeviceDPID) ) |
|
265 { |
|
266 return EMTPRespCodeInvalidObjectFormatCode; |
|
267 } |
|
268 |
|
269 if( (formatCode == EMTPFormatCodeUndefined) && (iFramework.DataProviderId() != KMTPFileDPID) ) |
|
270 { |
|
271 return EMTPRespCodeInvalidObjectFormatCode; |
|
272 } |
|
273 |
|
274 return EMTPRespCodeOK; |
|
275 } |
|
276 |
|
277 |
|
278 CMTPGetFormatCapabilities::CMTPGetFormatCapabilities(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) : |
|
279 CMTPRequestProcessor(aFramework, aConnection, 0, NULL) |
|
280 { |
|
281 } |
|
282 |
|
283 void CMTPGetFormatCapabilities::ConstructL() |
|
284 { |
|
285 //[SP-Format-0x3002] |
|
286 //Make the same behavior betwen 0x3000 and 0x3002. |
|
287 //iSingletons is used to judge whether FileDP supports 0x3002 or not. |
|
288 iSingletons.OpenL(); |
|
289 } |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |