1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Implement the operation: Copy Object |
14 * Description: Implement the operation: Move Object |
15 * |
15 * |
16 */ |
16 */ |
17 |
|
18 |
17 |
19 #include <mtp/mmtpdataproviderframework.h> |
18 #include <mtp/mmtpdataproviderframework.h> |
20 #include <mtp/cmtptypeobjectproplist.h> |
19 #include <mtp/cmtptypeobjectproplist.h> |
21 #include <mtp/cmtptypestring.h> |
20 #include <mtp/cmtptypestring.h> |
22 #include <mtp/cmtptypearray.h> |
21 #include <mtp/cmtptypearray.h> |
76 CMediaMtpDataProviderMoveObject::CMediaMtpDataProviderMoveObject( MMTPDataProviderFramework& aFramework, |
75 CMediaMtpDataProviderMoveObject::CMediaMtpDataProviderMoveObject( MMTPDataProviderFramework& aFramework, |
77 MMTPConnection& aConnection, |
76 MMTPConnection& aConnection, |
78 MMmMtpDpConfig& aDpConfig ) : |
77 MMmMtpDpConfig& aDpConfig ) : |
79 CMoveObject( aFramework, aConnection, aDpConfig ) |
78 CMoveObject( aFramework, aConnection, aDpConfig ) |
80 { |
79 { |
81 |
80 // Do nothing |
82 } |
81 } |
83 |
82 |
84 // ----------------------------------------------------------------------------- |
83 // ----------------------------------------------------------------------------- |
85 // CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL |
84 // CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL |
86 // |
85 // |
110 case EMTPObjectPropCodeOriginalReleaseDate: |
110 case EMTPObjectPropCodeOriginalReleaseDate: |
111 case EMTPObjectPropCodeAlbumName: |
111 case EMTPObjectPropCodeAlbumName: |
112 case EMTPObjectPropCodeParentalRating: |
112 case EMTPObjectPropCodeParentalRating: |
113 case EMTPObjectPropCodeEncodingProfile: |
113 case EMTPObjectPropCodeEncodingProfile: |
114 { |
114 { |
115 textData = CMTPTypeString::NewLC(); // + textData |
115 textData = CMTPTypeString::NewLC(); // + textData |
116 |
116 |
117 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
117 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
118 *textData, |
118 *textData, |
119 aObject ) ); |
119 aObject ) ); |
120 |
120 |
121 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
121 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
122 |
122 |
123 if ( err == KErrNone ) |
123 if ( err == KErrNone ) |
124 { |
124 { |
125 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
125 iPropertyElement = &( iPropertyList->ReservePropElemL( aHandle, aPropCode ) ); |
126 iPropertyElement->SetStringL( CMTPTypeObjectPropListElement::EValue, textData->StringChars()); |
126 iPropertyElement->SetStringL( CMTPTypeObjectPropListElement::EValue, textData->StringChars() ); |
127 |
127 } |
128 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
128 else if ( err == KErrNotFound ) |
129 // aPropCode, |
129 { |
130 // *textData ); |
130 iPropertyElement = NULL; |
131 } |
131 } |
132 else if ( err == KErrNotFound ) |
132 else |
133 { |
133 { |
134 iPropertyElement = NULL; |
134 User::Leave( err ); |
135 } |
135 } |
136 else |
136 |
137 { |
137 CleanupStack::PopAndDestroy( textData ); // - textData |
138 User::Leave( err ); |
|
139 } |
|
140 |
|
141 CleanupStack::PopAndDestroy( textData ); // - textData |
|
142 } |
138 } |
143 break; |
139 break; |
144 |
140 |
145 case EMTPObjectPropCodeDescription: |
141 case EMTPObjectPropCodeDescription: |
146 { |
142 { |
147 desData = CMTPTypeArray::NewLC( EMTPTypeAUINT16 ); // + desData |
143 desData = CMTPTypeArray::NewLC( EMTPTypeAUINT16 ); // + desData |
148 |
144 |
149 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
145 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
150 *desData, |
146 *desData, |
151 aObject ) ); |
147 aObject ) ); |
152 |
148 |
153 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
149 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
154 |
150 |
155 if ( err == KErrNone ) |
151 if ( err == KErrNone ) |
156 { |
152 { |
157 |
153 |
158 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
154 iPropertyElement = &( iPropertyList->ReservePropElemL( aHandle, aPropCode ) ); |
159 iPropertyElement->SetArrayL( CMTPTypeObjectPropListElement::EValue, *desData); |
155 iPropertyElement->SetArrayL( CMTPTypeObjectPropListElement::EValue, *desData ); |
160 |
156 } |
161 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
157 else if ( err == KErrNotFound ) |
162 // aPropCode, |
158 { |
163 // *desData ); |
159 iPropertyElement = NULL; |
164 } |
160 } |
165 else if ( err == KErrNotFound ) |
161 else |
166 { |
162 { |
167 iPropertyElement = NULL; |
163 User::Leave( err ); |
168 } |
164 } |
169 else |
165 |
170 { |
166 CleanupStack::PopAndDestroy( desData ); // - desData |
171 User::Leave( err ); |
|
172 } |
|
173 |
|
174 CleanupStack::PopAndDestroy( desData ); // - desData |
|
175 } |
167 } |
176 break; |
168 break; |
177 |
169 |
178 case EMTPObjectPropCodeTrack: |
170 case EMTPObjectPropCodeTrack: |
179 case EMTPObjectPropCodeNumberOfChannels: |
171 case EMTPObjectPropCodeNumberOfChannels: |
186 aObject ) ); |
178 aObject ) ); |
187 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
179 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
188 |
180 |
189 if ( err == KErrNone ) |
181 if ( err == KErrNone ) |
190 { |
182 { |
191 |
183 iPropertyElement = &( iPropertyList->ReservePropElemL( aHandle, aPropCode ) ); |
192 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
184 iPropertyElement->SetUint16L( CMTPTypeObjectPropListElement::EValue, uint16.Value() ); |
193 iPropertyElement->SetUint16L( CMTPTypeObjectPropListElement::EValue, uint16.Value()); |
|
194 |
|
195 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
|
196 // aPropCode, |
|
197 // uint16 ); |
|
198 } |
185 } |
199 else if ( err == KErrNotFound ) |
186 else if ( err == KErrNotFound ) |
200 { |
187 { |
201 iPropertyElement = NULL; |
188 iPropertyElement = NULL; |
202 } |
189 } |
225 aObject ) ); |
212 aObject ) ); |
226 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
213 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
227 |
214 |
228 if ( err == KErrNone ) |
215 if ( err == KErrNone ) |
229 { |
216 { |
230 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
217 iPropertyElement = &( iPropertyList->ReservePropElemL( aHandle, aPropCode ) ); |
231 iPropertyElement->SetUint32L( CMTPTypeObjectPropListElement::EValue, uint32.Value()); |
218 iPropertyElement->SetUint32L( CMTPTypeObjectPropListElement::EValue, uint32.Value() ); |
232 |
|
233 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
|
234 // aPropCode, |
|
235 // uint32 ); |
|
236 } |
219 } |
237 else if ( err == KErrNotFound ) |
220 else if ( err == KErrNotFound ) |
238 { |
221 { |
239 iPropertyElement = NULL; |
222 iPropertyElement = NULL; |
240 } |
223 } |
252 result.Set( 0 ); |
235 result.Set( 0 ); |
253 |
236 |
254 if ( drmStatus == EMTPDrmStatusProtected ) |
237 if ( drmStatus == EMTPDrmStatusProtected ) |
255 result.Set( 1 ); |
238 result.Set( 1 ); |
256 |
239 |
257 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
240 iPropertyElement = &( iPropertyList->ReservePropElemL( aHandle, aPropCode ) ); |
258 iPropertyElement->SetUint16L( CMTPTypeObjectPropListElement::EDatatype, EMTPTypeUINT8); |
241 iPropertyElement->SetUint16L( CMTPTypeObjectPropListElement::EDatatype, EMTPTypeUINT8 ); |
259 iPropertyElement->SetUint8L( CMTPTypeObjectPropListElement::EValue, result.Value()); |
242 iPropertyElement->SetUint8L( CMTPTypeObjectPropListElement::EValue, result.Value() ); |
260 |
|
261 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
|
262 // aPropCode, |
|
263 // EMTPTypeUINT8, |
|
264 // result ); |
|
265 } |
243 } |
266 break; |
244 break; |
267 |
245 |
268 default: |
246 default: |
269 { |
247 { |
270 User::Leave( KErrNotSupported ); |
248 User::Leave( KErrNotSupported ); |
271 } |
249 } |
272 break; |
250 break; |
273 } |
251 } |
274 |
252 |
275 PRINT( _L( "MM MTP <= CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL" ) ); |
253 PRINT( _L( "MM MTP <= CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL" ) ); |
276 } |
254 } |
277 |
255 |
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 |
256 // end of file |