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 |
17 |
18 |
18 |
19 #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> |
23 |
22 |
24 #include "cmediamtpdataprovidermoveobject.h" |
23 #include "cmediamtpdataprovidermoveobject.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 |
129 // aPropCode, |
129 { |
130 // *textData ); |
130 iPropertyElement = NULL; |
131 } |
131 } |
132 else if ( err == KErrNotFound ) |
132 |
133 { |
133 CleanupStack::PopAndDestroy( textData ); // - textData |
134 iPropertyElement = NULL; |
|
135 } |
|
136 else |
|
137 { |
|
138 User::Leave( err ); |
|
139 } |
|
140 |
|
141 CleanupStack::PopAndDestroy( textData ); // - textData |
|
142 } |
134 } |
143 break; |
135 break; |
144 |
136 |
145 case EMTPObjectPropCodeDescription: |
137 case EMTPObjectPropCodeDescription: |
146 { |
138 { |
147 desData = CMTPTypeArray::NewLC( EMTPTypeAUINT16 ); // + desData |
139 desData = CMTPTypeArray::NewLC( EMTPTypeAUINT16 ); // + desData |
148 |
140 |
149 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
141 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
150 *desData, |
142 *desData, |
151 aObject ) ); |
143 aObject ) ); |
152 |
144 |
153 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
145 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
154 |
146 |
155 if ( err == KErrNone ) |
147 if ( err == KErrNone ) |
156 { |
148 { |
157 |
149 iPropertyElement = &( iPropertyList->ReservePropElemL( aHandle, aPropCode ) ); |
158 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
150 iPropertyElement->SetArrayL( CMTPTypeObjectPropListElement::EValue, *desData ); |
159 iPropertyElement->SetArrayL( CMTPTypeObjectPropListElement::EValue, *desData); |
151 } |
160 |
152 else |
161 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
153 { |
162 // aPropCode, |
154 iPropertyElement = NULL; |
163 // *desData ); |
155 } |
164 } |
156 |
165 else if ( err == KErrNotFound ) |
157 CleanupStack::PopAndDestroy( desData ); // - desData |
166 { |
|
167 iPropertyElement = NULL; |
|
168 } |
|
169 else |
|
170 { |
|
171 User::Leave( err ); |
|
172 } |
|
173 |
|
174 CleanupStack::PopAndDestroy( desData ); // - desData |
|
175 } |
158 } |
176 break; |
159 break; |
177 |
160 |
178 case EMTPObjectPropCodeTrack: |
161 case EMTPObjectPropCodeTrack: |
179 case EMTPObjectPropCodeNumberOfChannels: |
162 case EMTPObjectPropCodeNumberOfChannels: |
186 aObject ) ); |
169 aObject ) ); |
187 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
170 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
188 |
171 |
189 if ( err == KErrNone ) |
172 if ( err == KErrNone ) |
190 { |
173 { |
191 |
174 iPropertyElement = &( iPropertyList->ReservePropElemL( aHandle, aPropCode ) ); |
192 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
175 iPropertyElement->SetUint16L( CMTPTypeObjectPropListElement::EValue, uint16.Value() ); |
193 iPropertyElement->SetUint16L( CMTPTypeObjectPropListElement::EValue, uint16.Value()); |
176 } |
194 |
177 else |
195 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
178 { |
196 // aPropCode, |
179 iPropertyElement = NULL; |
197 // uint16 ); |
|
198 } |
|
199 else if ( err == KErrNotFound ) |
|
200 { |
|
201 iPropertyElement = NULL; |
|
202 } |
|
203 else |
|
204 { |
|
205 User::Leave( err ); |
|
206 } |
180 } |
207 } |
181 } |
208 break; |
182 break; |
209 |
183 |
210 case EMTPObjectPropCodeWidth: |
184 case EMTPObjectPropCodeWidth: |
211 case EMTPObjectPropCodeHeight: |
185 case EMTPObjectPropCodeHeight: |
212 case EMTPObjectPropCodeDuration: |
186 case EMTPObjectPropCodeDuration: |
213 case EMTPObjectPropCodeUseCount: |
|
214 case EMTPObjectPropCodeSampleRate: |
187 case EMTPObjectPropCodeSampleRate: |
215 case EMTPObjectPropCodeAudioWAVECodec: |
188 case EMTPObjectPropCodeAudioWAVECodec: |
216 case EMTPObjectPropCodeAudioBitRate: |
189 case EMTPObjectPropCodeAudioBitRate: |
217 case EMTPObjectPropCodeVideoFourCCCodec: |
190 case EMTPObjectPropCodeVideoFourCCCodec: |
218 case EMTPObjectPropCodeVideoBitRate: |
191 case EMTPObjectPropCodeVideoBitRate: |
225 aObject ) ); |
198 aObject ) ); |
226 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
199 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL err = %d" ), err ); |
227 |
200 |
228 if ( err == KErrNone ) |
201 if ( err == KErrNone ) |
229 { |
202 { |
230 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
203 iPropertyElement = &( iPropertyList->ReservePropElemL( aHandle, aPropCode ) ); |
231 iPropertyElement->SetUint32L( CMTPTypeObjectPropListElement::EValue, uint32.Value()); |
204 iPropertyElement->SetUint32L( CMTPTypeObjectPropListElement::EValue, uint32.Value() ); |
232 |
205 } |
233 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
206 else |
234 // aPropCode, |
207 { |
235 // uint32 ); |
208 iPropertyElement = NULL; |
236 } |
|
237 else if ( err == KErrNotFound ) |
|
238 { |
|
239 iPropertyElement = NULL; |
|
240 } |
|
241 else |
|
242 { |
|
243 User::Leave( err ); |
|
244 } |
209 } |
245 } |
210 } |
246 break; |
211 break; |
247 |
212 |
248 case EMTPExtObjectPropCodeOmaDrmStatus: |
213 case EMTPExtObjectPropCodeOmaDrmStatus: |
252 result.Set( 0 ); |
217 result.Set( 0 ); |
253 |
218 |
254 if ( drmStatus == EMTPDrmStatusProtected ) |
219 if ( drmStatus == EMTPDrmStatusProtected ) |
255 result.Set( 1 ); |
220 result.Set( 1 ); |
256 |
221 |
257 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
222 iPropertyElement = &( iPropertyList->ReservePropElemL( aHandle, aPropCode ) ); |
258 iPropertyElement->SetUint16L( CMTPTypeObjectPropListElement::EDatatype, EMTPTypeUINT8); |
223 iPropertyElement->SetUint16L( CMTPTypeObjectPropListElement::EDatatype, EMTPTypeUINT8 ); |
259 iPropertyElement->SetUint8L( CMTPTypeObjectPropListElement::EValue, result.Value()); |
224 iPropertyElement->SetUint8L( CMTPTypeObjectPropListElement::EValue, result.Value() ); |
260 |
|
261 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( aHandle, |
|
262 // aPropCode, |
|
263 // EMTPTypeUINT8, |
|
264 // result ); |
|
265 } |
225 } |
266 break; |
226 break; |
267 |
227 |
268 default: |
228 default: |
269 { |
229 { |
270 User::Leave( KErrNotSupported ); |
230 User::Leave( KErrNotSupported ); |
271 } |
231 } |
272 break; |
232 break; |
273 } |
233 } |
274 |
234 |
275 PRINT( _L( "MM MTP <= CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL" ) ); |
235 PRINT( _L( "MM MTP <= CMediaMtpDataProviderMoveObject::ServiceSpecificObjectPropertyL" ) ); |
276 } |
236 } |
277 |
237 |
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 |
238 // end of file |