|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implement the operation: Copy Object |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <mtp/mmtpdataproviderframework.h> |
|
20 #include <mtp/cmtptypeobjectproplist.h> |
|
21 #include <mtp/cmtptypestring.h> |
|
22 #include <mtp/cmtptypearray.h> |
|
23 |
|
24 #include "cmediamtpdataprovidercopyobject.h" |
|
25 #include "mediamtpdataproviderconst.h" |
|
26 #include "mmmtpdplogger.h" |
|
27 #include "mmmtpdputility.h" |
|
28 #include "cmmmtpdpmetadataaccesswrapper.h" |
|
29 #include "mmmtpdpdefs.h" |
|
30 #include "mmmtpdpconfig.h" |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CMediaMtpDataProviderCopyObject::NewL |
|
34 // Two-phase construction method |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 MMmRequestProcessor* CMediaMtpDataProviderCopyObject::NewL( MMTPDataProviderFramework& aFramework, |
|
38 MMTPConnection& aConnection, |
|
39 MMmMtpDpConfig& aDpConfig ) |
|
40 { |
|
41 CMediaMtpDataProviderCopyObject* self = |
|
42 new ( ELeave ) CMediaMtpDataProviderCopyObject( aFramework, |
|
43 aConnection, |
|
44 aDpConfig ); |
|
45 CleanupStack::PushL( self ); |
|
46 self->ConstructL(); |
|
47 CleanupStack::Pop( self ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CMediaMtpDataProviderCopyObject::ConstructL |
|
53 // Two-phase construction method |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void CMediaMtpDataProviderCopyObject::ConstructL() |
|
57 { |
|
58 CCopyObject::ConstructL(); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CMediaMtpDataProviderCopyObject::~CMediaMtpDataProviderCopyObject |
|
63 // Destructor |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CMediaMtpDataProviderCopyObject::~CMediaMtpDataProviderCopyObject() |
|
67 { |
|
68 |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CMediaMtpDataProviderCopyObject::CMediaMtpDataProviderCopyObject |
|
73 // Standard c++ constructor |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CMediaMtpDataProviderCopyObject::CMediaMtpDataProviderCopyObject( MMTPDataProviderFramework& aFramework, |
|
77 MMTPConnection& aConnection, |
|
78 MMmMtpDpConfig& aDpConfig ) : |
|
79 CCopyObject( aFramework, aConnection, aDpConfig ) |
|
80 { |
|
81 |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CMediaMtpDataProviderCopyObject::ServiceSpecificObjectPropertyL |
|
86 // |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CMediaMtpDataProviderCopyObject::ServiceGetSpecificObjectPropertyL( TUint16 aPropCode, |
|
90 TUint32 aHandle, |
|
91 const CMTPObjectMetaData& aObject ) |
|
92 { |
|
93 PRINT( _L( "MM MTP => CMediaMtpDataProviderCopyObject::ServiceSpecificObjectPropertyL" ) ); |
|
94 |
|
95 CMTPTypeString* textData = NULL; |
|
96 CMTPTypeArray* desData = NULL; |
|
97 TInt err = KErrNone; |
|
98 |
|
99 if ( iPropertyElement ) |
|
100 { |
|
101 delete iPropertyElement; |
|
102 iPropertyElement = NULL; |
|
103 } |
|
104 |
|
105 switch ( aPropCode ) |
|
106 { |
|
107 case EMTPObjectPropCodeArtist: |
|
108 case EMTPObjectPropCodeGenre: |
|
109 case EMTPObjectPropCodeComposer: |
|
110 case EMTPObjectPropCodeOriginalReleaseDate: |
|
111 case EMTPObjectPropCodeAlbumName: |
|
112 case EMTPObjectPropCodeParentalRating: |
|
113 case EMTPObjectPropCodeEncodingProfile: |
|
114 { |
|
115 textData = CMTPTypeString::NewLC(); // + textData |
|
116 |
|
117 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
|
118 *textData, |
|
119 aObject ) ); |
|
120 |
|
121 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderCopyObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
|
122 |
|
123 if ( err == KErrNone ) |
|
124 { |
|
125 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
126 iPropertyElement->SetStringL( CMTPTypeObjectPropListElement::EValue, textData->StringChars()); |
|
127 |
|
128 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
|
129 // aPropCode, |
|
130 // *textData ); |
|
131 } |
|
132 |
|
133 CleanupStack::PopAndDestroy( textData ); // - textData |
|
134 } |
|
135 break; |
|
136 |
|
137 case EMTPObjectPropCodeDescription: |
|
138 { |
|
139 desData = CMTPTypeArray::NewLC( EMTPTypeAUINT16 ); // + desData |
|
140 |
|
141 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
|
142 *desData, |
|
143 aObject ) ); |
|
144 |
|
145 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderCopyObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
|
146 |
|
147 if ( err == KErrNone ) |
|
148 { |
|
149 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
150 iPropertyElement->SetArrayL( CMTPTypeObjectPropListElement::EValue, *desData); |
|
151 |
|
152 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
|
153 // aPropCode, |
|
154 // *desData ); |
|
155 } |
|
156 |
|
157 CleanupStack::PopAndDestroy( desData ); // - desData |
|
158 } |
|
159 break; |
|
160 |
|
161 case EMTPObjectPropCodeTrack: |
|
162 case EMTPObjectPropCodeNumberOfChannels: |
|
163 case EMTPObjectPropCodeScanType: |
|
164 case EMTPObjectPropCodeDRMStatus: |
|
165 { |
|
166 TMTPTypeUint16 uint16( 0 ); |
|
167 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
|
168 uint16, |
|
169 aObject ) ); |
|
170 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderCopyObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
|
171 |
|
172 if ( err == KErrNone ) |
|
173 { |
|
174 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
175 iPropertyElement->SetUint16L( CMTPTypeObjectPropListElement::EValue, uint16.Value()); |
|
176 |
|
177 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
|
178 // aPropCode, |
|
179 // uint16 ); |
|
180 } |
|
181 |
|
182 } |
|
183 break; |
|
184 |
|
185 case EMTPObjectPropCodeWidth: |
|
186 case EMTPObjectPropCodeHeight: |
|
187 case EMTPObjectPropCodeDuration: |
|
188 case EMTPObjectPropCodeUseCount: |
|
189 case EMTPObjectPropCodeSampleRate: |
|
190 case EMTPObjectPropCodeAudioWAVECodec: |
|
191 case EMTPObjectPropCodeAudioBitRate: |
|
192 case EMTPObjectPropCodeVideoFourCCCodec: |
|
193 case EMTPObjectPropCodeVideoBitRate: |
|
194 case EMTPObjectPropCodeFramesPerThousandSeconds: |
|
195 case EMTPObjectPropCodeKeyFrameDistance: |
|
196 { |
|
197 TMTPTypeUint32 uint32 = 0; |
|
198 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
|
199 uint32, |
|
200 aObject ) ); |
|
201 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderCopyObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
|
202 |
|
203 if ( err == KErrNone ) |
|
204 { |
|
205 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
206 iPropertyElement->SetUint32L( CMTPTypeObjectPropListElement::EValue, uint32.Value()); |
|
207 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
|
208 // aPropCode, |
|
209 // uint32 ); |
|
210 } |
|
211 } |
|
212 break; |
|
213 |
|
214 case EMTPExtObjectPropCodeOmaDrmStatus: |
|
215 { |
|
216 TInt drmStatus = MmMtpDpUtility::GetDrmStatus( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
|
217 TMTPTypeUint8 result; |
|
218 result.Set( 0 ); |
|
219 |
|
220 if ( drmStatus == EMTPDrmStatusProtected ) |
|
221 result.Set( 1 ); |
|
222 |
|
223 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
224 iPropertyElement->SetUint16L( CMTPTypeObjectPropListElement::EDatatype, EMTPTypeUINT8); |
|
225 iPropertyElement->SetUint8L( CMTPTypeObjectPropListElement::EValue, result.Value()); |
|
226 |
|
227 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
|
228 // aPropCode, |
|
229 // EMTPTypeUINT8, |
|
230 // result ); |
|
231 } |
|
232 break; |
|
233 |
|
234 default: |
|
235 { |
|
236 User::Leave( KErrNotSupported ); |
|
237 } |
|
238 break; |
|
239 } |
|
240 |
|
241 // centralize logic to handle error, doing so, that's on need to trap the |
|
242 // leave for KErrNotSupported in base class like previous version. |
|
243 if ( ( err == KErrNotFound ) |
|
244 || ( ( err == KErrNotSupported ) |
|
245 && ( ( aObject.Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCodeASF ) |
|
246 || ( aObject.Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCodeMP4Container ) |
|
247 || ( aObject.Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCode3GPContainer ) ) ) ) |
|
248 { |
|
249 iPropertyElement = NULL; |
|
250 } |
|
251 else |
|
252 { |
|
253 User::LeaveIfError( err ); |
|
254 } |
|
255 PRINT( _L( "MM MTP <= CMediaMtpDataProviderCopyObject::ServiceSpecificObjectPropertyL" ) ); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CMediaMtpDataProviderCopyObject::ServiceSetSpecificObjectPropertyL |
|
260 // |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 TMTPResponseCode CMediaMtpDataProviderCopyObject::ServiceSetSpecificObjectPropertyL( TUint16 aPropCode, const CMTPObjectMetaData& aObject, |
|
264 const CMTPTypeObjectPropListElement& aElement ) |
|
265 { |
|
266 PRINT( _L( "MM MTP => CMediaMtpDataProviderCopyObject::ServiceSetSpecificObjectPropertyL" ) ); |
|
267 TMTPResponseCode responseCode( EMTPRespCodeOK ); |
|
268 |
|
269 switch ( aPropCode ) |
|
270 { |
|
271 case EMTPObjectPropCodeArtist: |
|
272 case EMTPObjectPropCodeGenre: |
|
273 case EMTPObjectPropCodeComposer: |
|
274 case EMTPObjectPropCodeOriginalReleaseDate: |
|
275 case EMTPObjectPropCodeAlbumName: |
|
276 case EMTPObjectPropCodeParentalRating: |
|
277 case EMTPObjectPropCodeEncodingProfile: |
|
278 { |
|
279 CMTPTypeString* stringData = |
|
280 CMTPTypeString::NewLC( aElement.StringL( CMTPTypeObjectPropListElement::EValue ) );// + stringData |
|
281 |
|
282 responseCode = ServiceMetaDataToWrapper( aPropCode, |
|
283 *stringData, |
|
284 aObject ); |
|
285 |
|
286 CleanupStack::PopAndDestroy( stringData ); // - stringData |
|
287 } |
|
288 break; |
|
289 |
|
290 case EMTPObjectPropCodeVideoBitRate: |
|
291 { |
|
292 responseCode = EMTPRespCodeAccessDenied; |
|
293 } |
|
294 break; |
|
295 |
|
296 case EMTPObjectPropCodeDescription: |
|
297 { |
|
298 CMTPTypeArray* desData = CMTPTypeArray::NewLC( EMTPTypeAUINT16 ); // + desData |
|
299 // aElement.GetL( CMTPTypeObjectPropListElement::EValue, *desData ); |
|
300 desData->SetByDesL(aElement.ArrayL(CMTPTypeObjectPropListElement::EValue)); |
|
301 //desData(aElement.ArrayL(CMTPTypeObjectPropListElement::EValue)); |
|
302 |
|
303 responseCode = ServiceMetaDataToWrapper( aPropCode, |
|
304 *desData, |
|
305 aObject ); |
|
306 CleanupStack::PopAndDestroy( desData ); // - desData |
|
307 } |
|
308 break; |
|
309 |
|
310 case EMTPObjectPropCodeWidth: |
|
311 case EMTPObjectPropCodeHeight: |
|
312 case EMTPObjectPropCodeDuration: |
|
313 case EMTPObjectPropCodeUseCount: |
|
314 case EMTPObjectPropCodeSampleRate: |
|
315 case EMTPObjectPropCodeAudioWAVECodec: |
|
316 case EMTPObjectPropCodeAudioBitRate: |
|
317 case EMTPObjectPropCodeVideoFourCCCodec: |
|
318 case EMTPObjectPropCodeFramesPerThousandSeconds: |
|
319 case EMTPObjectPropCodeKeyFrameDistance: |
|
320 { |
|
321 TMTPTypeUint32 uint32( aElement.Uint32L( CMTPTypeObjectPropListElement::EValue ) ); |
|
322 responseCode = ServiceMetaDataToWrapper( aPropCode, |
|
323 uint32, |
|
324 aObject ); |
|
325 } |
|
326 break; |
|
327 |
|
328 case EMTPObjectPropCodeTrack: |
|
329 case EMTPObjectPropCodeNumberOfChannels: |
|
330 case EMTPObjectPropCodeScanType: |
|
331 case EMTPObjectPropCodeDRMStatus: |
|
332 { |
|
333 TMTPTypeUint16 uint16( aElement.Uint16L( CMTPTypeObjectPropListElement::EValue )); |
|
334 responseCode = ServiceMetaDataToWrapper( aPropCode, |
|
335 uint16, |
|
336 aObject ); |
|
337 } |
|
338 break; |
|
339 |
|
340 case EMTPExtObjectPropCodeOmaDrmStatus: |
|
341 { |
|
342 TInt drmStatus = MmMtpDpUtility::GetDrmStatus( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
|
343 |
|
344 if (drmStatus == EMTPDrmStatusUnknown) |
|
345 { |
|
346 responseCode = EMTPRespCodeAccessDenied; |
|
347 } |
|
348 else |
|
349 { |
|
350 TMTPTypeUint8 newValue( aElement.Uint8L( CMTPTypeObjectPropListElement::EValue ) ); |
|
351 |
|
352 // there's no DB field to remember the value, so return an error |
|
353 // if there's a mismatch to CAF protection status |
|
354 if ( ( ( drmStatus == EMTPDrmStatusProtected) && ( newValue.Value() == 0 ) ) || |
|
355 ( ( drmStatus == EMTPDrmStatusNotProtected ) && ( newValue.Value() == 1 ) ) ) |
|
356 { |
|
357 responseCode = EMTPRespCodeAccessDenied; |
|
358 } |
|
359 } |
|
360 } |
|
361 break; |
|
362 |
|
363 default: |
|
364 { |
|
365 User::Leave( KErrNotSupported ); |
|
366 } |
|
367 break; |
|
368 } |
|
369 |
|
370 PRINT( _L( "MM MTP <= CMediaMtpDataProviderCopyObject::ServiceSetSpecificObjectPropertyL" ) ); |
|
371 |
|
372 return responseCode; |
|
373 } |
|
374 |
|
375 // end of file |