|
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 "cmediamtpdataprovidermoveobject.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 // CMediaMtpDataProviderMoveObject::NewL |
|
34 // Two-phase construction method |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 MMmRequestProcessor* CMediaMtpDataProviderMoveObject::NewL( MMTPDataProviderFramework& aFramework, |
|
38 MMTPConnection& aConnection, |
|
39 MMmMtpDpConfig& aDpConfig ) |
|
40 { |
|
41 CMediaMtpDataProviderMoveObject* self = |
|
42 new ( ELeave ) CMediaMtpDataProviderMoveObject( aFramework, |
|
43 aConnection, |
|
44 aDpConfig ); |
|
45 CleanupStack::PushL( self ); |
|
46 self->ConstructL(); |
|
47 CleanupStack::Pop( self ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CMediaMtpDataProviderMoveObject::ConstructL |
|
53 // Two-phase construction method |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void CMediaMtpDataProviderMoveObject::ConstructL() |
|
57 { |
|
58 CMoveObject::ConstructL(); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CMediaMtpDataProviderMoveObject::~CMediaMtpDataProviderMoveObject |
|
63 // Destructor |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CMediaMtpDataProviderMoveObject::~CMediaMtpDataProviderMoveObject() |
|
67 { |
|
68 |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CMediaMtpDataProviderMoveObject::CMediaMtpDataProviderMoveObject |
|
73 // Standard c++ constructor |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CMediaMtpDataProviderMoveObject::CMediaMtpDataProviderMoveObject( MMTPDataProviderFramework& aFramework, |
|
77 MMTPConnection& aConnection, |
|
78 MMmMtpDpConfig& aDpConfig ) : |
|
79 CMoveObject( aFramework, aConnection, aDpConfig ) |
|
80 { |
|
81 |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL |
|
86 // |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CMediaMtpDataProviderMoveObject::ServiceGetSpecificObjectPropertyL( TUint16 aPropCode, |
|
90 TUint32 aHandle, |
|
91 const CMTPObjectMetaData& aObject ) |
|
92 { |
|
93 PRINT1( _L( "MM MTP => CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL aPropCode(0x%x)" ), aPropCode ); |
|
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 <> CMediaMtpDataProviderMoveObject::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 else if ( err == KErrNotFound ) |
|
133 { |
|
134 iPropertyElement = NULL; |
|
135 } |
|
136 else |
|
137 { |
|
138 User::Leave( err ); |
|
139 } |
|
140 |
|
141 CleanupStack::PopAndDestroy( textData ); // - textData |
|
142 } |
|
143 break; |
|
144 |
|
145 case EMTPObjectPropCodeDescription: |
|
146 { |
|
147 desData = CMTPTypeArray::NewLC( EMTPTypeAUINT16 ); // + desData |
|
148 |
|
149 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
|
150 *desData, |
|
151 aObject ) ); |
|
152 |
|
153 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
|
154 |
|
155 if ( err == KErrNone ) |
|
156 { |
|
157 |
|
158 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
159 iPropertyElement->SetArrayL( CMTPTypeObjectPropListElement::EValue, *desData); |
|
160 |
|
161 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
|
162 // aPropCode, |
|
163 // *desData ); |
|
164 } |
|
165 else if ( err == KErrNotFound ) |
|
166 { |
|
167 iPropertyElement = NULL; |
|
168 } |
|
169 else |
|
170 { |
|
171 User::Leave( err ); |
|
172 } |
|
173 |
|
174 CleanupStack::PopAndDestroy( desData ); // - desData |
|
175 } |
|
176 break; |
|
177 |
|
178 case EMTPObjectPropCodeTrack: |
|
179 case EMTPObjectPropCodeNumberOfChannels: |
|
180 case EMTPObjectPropCodeScanType: |
|
181 case EMTPObjectPropCodeDRMStatus: |
|
182 { |
|
183 TMTPTypeUint16 uint16( 0 ); |
|
184 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
|
185 uint16, |
|
186 aObject ) ); |
|
187 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
|
188 |
|
189 if ( err == KErrNone ) |
|
190 { |
|
191 |
|
192 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
193 iPropertyElement->SetUint16L( CMTPTypeObjectPropListElement::EValue, uint16.Value()); |
|
194 |
|
195 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
|
196 // aPropCode, |
|
197 // uint16 ); |
|
198 } |
|
199 else if ( err == KErrNotFound ) |
|
200 { |
|
201 iPropertyElement = NULL; |
|
202 } |
|
203 else |
|
204 { |
|
205 User::Leave( err ); |
|
206 } |
|
207 } |
|
208 break; |
|
209 |
|
210 case EMTPObjectPropCodeWidth: |
|
211 case EMTPObjectPropCodeHeight: |
|
212 case EMTPObjectPropCodeDuration: |
|
213 case EMTPObjectPropCodeUseCount: |
|
214 case EMTPObjectPropCodeSampleRate: |
|
215 case EMTPObjectPropCodeAudioWAVECodec: |
|
216 case EMTPObjectPropCodeAudioBitRate: |
|
217 case EMTPObjectPropCodeVideoFourCCCodec: |
|
218 case EMTPObjectPropCodeVideoBitRate: |
|
219 case EMTPObjectPropCodeFramesPerThousandSeconds: |
|
220 case EMTPObjectPropCodeKeyFrameDistance: |
|
221 { |
|
222 TMTPTypeUint32 uint32 = 0; |
|
223 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
|
224 uint32, |
|
225 aObject ) ); |
|
226 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
|
227 |
|
228 if ( err == KErrNone ) |
|
229 { |
|
230 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
231 iPropertyElement->SetUint32L( CMTPTypeObjectPropListElement::EValue, uint32.Value()); |
|
232 |
|
233 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
|
234 // aPropCode, |
|
235 // uint32 ); |
|
236 } |
|
237 else if ( err == KErrNotFound ) |
|
238 { |
|
239 iPropertyElement = NULL; |
|
240 } |
|
241 else |
|
242 { |
|
243 User::Leave( err ); |
|
244 } |
|
245 } |
|
246 break; |
|
247 |
|
248 case EMTPExtObjectPropCodeOmaDrmStatus: |
|
249 { |
|
250 TInt drmStatus = MmMtpDpUtility::GetDrmStatus( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
|
251 TMTPTypeUint8 result; |
|
252 result.Set( 0 ); |
|
253 |
|
254 if ( drmStatus == EMTPDrmStatusProtected ) |
|
255 result.Set( 1 ); |
|
256 |
|
257 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
258 iPropertyElement->SetUint16L( CMTPTypeObjectPropListElement::EDatatype, EMTPTypeUINT8); |
|
259 iPropertyElement->SetUint8L( CMTPTypeObjectPropListElement::EValue, result.Value()); |
|
260 |
|
261 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
|
262 // aPropCode, |
|
263 // EMTPTypeUINT8, |
|
264 // result ); |
|
265 } |
|
266 break; |
|
267 |
|
268 default: |
|
269 { |
|
270 User::Leave( KErrNotSupported ); |
|
271 } |
|
272 break; |
|
273 } |
|
274 |
|
275 PRINT( _L( "MM MTP <= CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL" ) ); |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CMediaMtpDataProviderMoveObject::ServiceSetSpecificObjectPropertyL |
|
280 // |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 TMTPResponseCode CMediaMtpDataProviderMoveObject::ServiceSetSpecificObjectPropertyL( TUint16 aPropCode, const CMTPObjectMetaData& aObject, |
|
284 const CMTPTypeObjectPropListElement& aElement ) |
|
285 { |
|
286 PRINT( _L( "MM MTP => CMediaMtpDataProviderMoveObject::ServiceSetSpecificObjectPropertyL" ) ); |
|
287 TMTPResponseCode responseCode( EMTPRespCodeOK ); |
|
288 |
|
289 switch ( aPropCode ) |
|
290 { |
|
291 case EMTPObjectPropCodeArtist: |
|
292 case EMTPObjectPropCodeGenre: |
|
293 case EMTPObjectPropCodeComposer: |
|
294 case EMTPObjectPropCodeOriginalReleaseDate: |
|
295 case EMTPObjectPropCodeAlbumName: |
|
296 case EMTPObjectPropCodeParentalRating: |
|
297 case EMTPObjectPropCodeEncodingProfile: |
|
298 { |
|
299 CMTPTypeString* stringData = |
|
300 CMTPTypeString::NewLC( aElement.StringL( CMTPTypeObjectPropListElement::EValue ) );// + stringData |
|
301 |
|
302 responseCode = ServiceMetaDataToWrapper( aPropCode, |
|
303 *stringData, |
|
304 aObject ); |
|
305 |
|
306 CleanupStack::PopAndDestroy( stringData );// - stringData |
|
307 } |
|
308 break; |
|
309 |
|
310 case EMTPObjectPropCodeVideoBitRate: |
|
311 { |
|
312 responseCode = EMTPRespCodeAccessDenied; |
|
313 } |
|
314 break; |
|
315 |
|
316 case EMTPObjectPropCodeDescription: |
|
317 { |
|
318 CMTPTypeArray* desData = CMTPTypeArray::NewLC( EMTPTypeAUINT16 ); // + desData |
|
319 // aElement.GetL( CMTPTypeObjectPropListElement::EValue, *desData ); |
|
320 |
|
321 desData->SetByDesL(aElement.ArrayL(CMTPTypeObjectPropListElement::EValue )); |
|
322 responseCode = ServiceMetaDataToWrapper( aPropCode, |
|
323 *desData, |
|
324 aObject ); |
|
325 CleanupStack::PopAndDestroy( desData ); // - desData |
|
326 } |
|
327 break; |
|
328 |
|
329 case EMTPObjectPropCodeWidth: |
|
330 case EMTPObjectPropCodeHeight: |
|
331 case EMTPObjectPropCodeDuration: |
|
332 case EMTPObjectPropCodeUseCount: |
|
333 case EMTPObjectPropCodeSampleRate: |
|
334 case EMTPObjectPropCodeAudioWAVECodec: |
|
335 case EMTPObjectPropCodeAudioBitRate: |
|
336 case EMTPObjectPropCodeVideoFourCCCodec: |
|
337 case EMTPObjectPropCodeFramesPerThousandSeconds: |
|
338 case EMTPObjectPropCodeKeyFrameDistance: |
|
339 { |
|
340 TMTPTypeUint32 uint32( aElement.Uint32L( CMTPTypeObjectPropListElement::EValue ) ); |
|
341 responseCode = ServiceMetaDataToWrapper( aPropCode, |
|
342 uint32, |
|
343 aObject ); |
|
344 } |
|
345 break; |
|
346 |
|
347 case EMTPObjectPropCodeTrack: |
|
348 case EMTPObjectPropCodeNumberOfChannels: |
|
349 case EMTPObjectPropCodeScanType: |
|
350 case EMTPObjectPropCodeDRMStatus: |
|
351 { |
|
352 TMTPTypeUint16 uint16( aElement.Uint16L( CMTPTypeObjectPropListElement::EValue )); |
|
353 responseCode = ServiceMetaDataToWrapper( aPropCode, |
|
354 uint16, |
|
355 aObject ); |
|
356 } |
|
357 break; |
|
358 |
|
359 case EMTPExtObjectPropCodeOmaDrmStatus: |
|
360 { |
|
361 TInt drmStatus = MmMtpDpUtility::GetDrmStatus( aObject.DesC( |
|
362 CMTPObjectMetaData::ESuid ) ); |
|
363 |
|
364 if ( drmStatus == EMTPDrmStatusUnknown ) |
|
365 { |
|
366 responseCode = EMTPRespCodeAccessDenied; |
|
367 } |
|
368 else |
|
369 { |
|
370 TMTPTypeUint8 newValue( aElement.Uint8L( CMTPTypeObjectPropListElement::EValue ) ); |
|
371 |
|
372 // there's no DB field to remember the value, so return an error |
|
373 // if there's a mismatch to CAF protection status |
|
374 if ( ( ( drmStatus == EMTPDrmStatusProtected ) && ( newValue.Value() == 0 ) ) |
|
375 || ( ( drmStatus == EMTPDrmStatusNotProtected ) && ( newValue.Value() == 1 ) ) ) |
|
376 { |
|
377 responseCode = EMTPRespCodeAccessDenied; |
|
378 } |
|
379 } |
|
380 } |
|
381 break; |
|
382 |
|
383 default: |
|
384 { |
|
385 User::Leave( KErrNotSupported ); |
|
386 } |
|
387 break; |
|
388 } |
|
389 |
|
390 PRINT( _L( "MM MTP <= CMediaMtpDataProviderMoveObject::ServiceSetSpecificObjectPropertyL" ) ); |
|
391 |
|
392 return responseCode; |
|
393 } |
|
394 |
|
395 // end of file |