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: SendObjectInfo/SendObjectPropList/SendObject |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <mtp/mmtpdataproviderframework.h> |
|
19 #include <mtp/cmtptypeobjectproplist.h> |
|
20 #include <mtp/cmtptypestring.h> |
|
21 #include <mtp/cmtptypearray.h> |
|
22 |
|
23 #include "cmediamtpdataprovidersendobject.h" |
|
24 #include "mediamtpdataproviderconst.h" |
|
25 #include "mmmtpdplogger.h" |
|
26 #include "cmmmtpdpmetadataaccesswrapper.h" |
|
27 #include "mmmtpdputility.h" |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CMediaMtpDataProviderSendObject::NewL |
|
31 // Two-phase construction method |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 MMmRequestProcessor* CMediaMtpDataProviderSendObject::NewL( MMTPDataProviderFramework& aFramework, |
|
35 MMTPConnection& aConnection, |
|
36 MMmMtpDpConfig& aDpConfig) |
|
37 { |
|
38 CMediaMtpDataProviderSendObject* self = new ( ELeave ) CMediaMtpDataProviderSendObject( aFramework, aConnection, aDpConfig ); |
|
39 |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop(self); |
|
43 |
|
44 return self; |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CMediaMtpDataProviderSendObject::~CMediaMtpDataProviderSendObject |
|
49 // Destructor |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CMediaMtpDataProviderSendObject::~CMediaMtpDataProviderSendObject() |
|
53 { |
|
54 |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CMediaMtpDataProviderSendObject::CMediaMtpDataProviderSendObject |
|
59 // Standard C++ Constructor |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CMediaMtpDataProviderSendObject::CMediaMtpDataProviderSendObject( |
|
63 MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, |
|
64 MMmMtpDpConfig& aDpConfig) : |
|
65 CSendObject(aFramework, aConnection, aDpConfig) |
|
66 { |
|
67 |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CMediaMtpDataProviderSendObject::ConstructL |
|
72 // 2nd Phase Constructor |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void CMediaMtpDataProviderSendObject::ConstructL() |
|
76 { |
|
77 CSendObject::ConstructL(); |
|
78 } |
|
79 |
|
80 TMTPResponseCode CMediaMtpDataProviderSendObject::CheckSepecificPropType( TUint16 aPropCode, TUint16 aDataType ) |
|
81 { |
|
82 PRINT( _L( "MM MTP => CMediaMtpDataProviderSendObject::CheckSepecificPropType" ) ); |
|
83 TMTPResponseCode responseCode( EMTPRespCodeOK ); |
|
84 |
|
85 switch ( aPropCode ) |
|
86 { |
|
87 case EMTPObjectPropCodeArtist: // 0xDC46 |
|
88 case EMTPObjectPropCodeGenre: // 0xDC8C |
|
89 case EMTPObjectPropCodeParentalRating: // 0xDC94 |
|
90 case EMTPObjectPropCodeComposer: // 0xDC96 |
|
91 case EMTPObjectPropCodeOriginalReleaseDate: // 0xDC99 |
|
92 case EMTPObjectPropCodeAlbumName: // 0xDC9A |
|
93 case EMTPObjectPropCodeEncodingProfile: // 0xDEA1 |
|
94 if ( aDataType != EMTPTypeString) |
|
95 { |
|
96 responseCode = EMTPRespCodeInvalidObjectPropFormat; |
|
97 } |
|
98 break; |
|
99 |
|
100 case EMTPObjectPropCodeDescription: |
|
101 if ( aDataType != EMTPTypeAUINT16) |
|
102 { |
|
103 responseCode = EMTPRespCodeInvalidObjectPropFormat; |
|
104 } |
|
105 break; |
|
106 |
|
107 case EMTPObjectPropCodeTrack: // 0xDC8B |
|
108 case EMTPObjectPropCodeDRMStatus: // 0xDC9D |
|
109 case EMTPObjectPropCodeNumberOfChannels: // 0xDE94 |
|
110 case EMTPObjectPropCodeScanType: // 0xDE97 |
|
111 if ( aDataType != EMTPTypeUINT16) |
|
112 { |
|
113 responseCode = EMTPRespCodeInvalidObjectPropFormat; |
|
114 } |
|
115 break; |
|
116 |
|
117 //Get Data for Int32 objects |
|
118 case EMTPObjectPropCodeWidth: // 0xDC87 |
|
119 case EMTPObjectPropCodeHeight: // 0xDC88 |
|
120 case EMTPObjectPropCodeDuration: // 0xDC89 |
|
121 case EMTPObjectPropCodeUseCount: // 0xDC91 |
|
122 case EMTPObjectPropCodeSampleRate: // 0xDE93 |
|
123 case EMTPObjectPropCodeAudioWAVECodec: // 0xDE99 |
|
124 case EMTPObjectPropCodeAudioBitRate: // 0xDE9A |
|
125 case EMTPObjectPropCodeVideoFourCCCodec: // 0xDE9B |
|
126 case EMTPObjectPropCodeFramesPerThousandSeconds: // 0xDE9D |
|
127 case EMTPObjectPropCodeKeyFrameDistance: // 0xDE9E |
|
128 if ( aDataType != EMTPTypeUINT32) |
|
129 { |
|
130 responseCode = EMTPRespCodeInvalidObjectPropFormat; |
|
131 } |
|
132 break; |
|
133 |
|
134 case EMTPExtObjectPropCodeOmaDrmStatus: |
|
135 if ( aDataType != EMTPTypeUINT8) |
|
136 { |
|
137 responseCode = EMTPRespCodeInvalidObjectPropFormat; |
|
138 } |
|
139 break; |
|
140 |
|
141 default: |
|
142 // It's not possible to run here. |
|
143 responseCode = EMTPRespCodeInvalidObjectPropCode; |
|
144 break; |
|
145 |
|
146 } |
|
147 PRINT1( _L( "MM MTP <= CMediaMtpDataProviderSendObject::CheckSepecificPropType, responseCode = 0x%X" ), responseCode ); |
|
148 return responseCode; |
|
149 } |
|
150 |
|
151 TMTPResponseCode CMediaMtpDataProviderSendObject::SetSpecificObjectPropertyL( TUint16 aPropCode, |
|
152 const CMTPObjectMetaData& aObject, |
|
153 const CMTPTypeObjectPropListElement& aElement ) |
|
154 { |
|
155 PRINT( _L( "MM MTP => CMediaMtpDataProviderSendObject::SetSpecificObjectPropertyL" ) ); |
|
156 TMTPResponseCode responseCode(EMTPRespCodeOK); |
|
157 |
|
158 switch ( aPropCode ) |
|
159 { |
|
160 case EMTPObjectPropCodeArtist: |
|
161 case EMTPObjectPropCodeGenre: |
|
162 case EMTPObjectPropCodeComposer: |
|
163 case EMTPObjectPropCodeOriginalReleaseDate: |
|
164 case EMTPObjectPropCodeAlbumName: |
|
165 case EMTPObjectPropCodeParentalRating: |
|
166 case EMTPObjectPropCodeEncodingProfile: |
|
167 { |
|
168 CMTPTypeString* stringData = |
|
169 CMTPTypeString::NewLC( aElement.StringL( CMTPTypeObjectPropListElement::EValue ) );// + stringData |
|
170 |
|
171 responseCode = SetMetaDataToWrapperL( aPropCode, |
|
172 *stringData, |
|
173 aObject ); |
|
174 |
|
175 CleanupStack::PopAndDestroy( stringData );// - stringData |
|
176 } |
|
177 break; |
|
178 |
|
179 case EMTPObjectPropCodeVideoBitRate: |
|
180 // TODO: Does anything need to be done? |
|
181 /* spec: |
|
182 * Object properties that are get-only (0x00 GET) |
|
183 * should accept values during object creation by |
|
184 * way of the SendObjectPropList command. |
|
185 */ |
|
186 break; |
|
187 |
|
188 case EMTPObjectPropCodeDescription: |
|
189 { |
|
190 CMTPTypeArray* desData = CMTPTypeArray::NewLC( EMTPTypeAUINT16 ); // + desData |
|
191 // aElement.GetL( CMTPTypeObjectPropListElement::EValue, *desData ); |
|
192 desData->SetByDesL( aElement.ArrayL( CMTPTypeObjectPropListElement::EValue ) ); |
|
193 responseCode = SetMetaDataToWrapperL( aPropCode, |
|
194 *desData, |
|
195 aObject ); |
|
196 CleanupStack::PopAndDestroy( desData ); // - desData |
|
197 } |
|
198 break; |
|
199 |
|
200 case EMTPObjectPropCodeWidth: |
|
201 case EMTPObjectPropCodeHeight: |
|
202 case EMTPObjectPropCodeDuration: |
|
203 case EMTPObjectPropCodeUseCount: |
|
204 case EMTPObjectPropCodeSampleRate: |
|
205 case EMTPObjectPropCodeAudioWAVECodec: |
|
206 case EMTPObjectPropCodeAudioBitRate: |
|
207 case EMTPObjectPropCodeVideoFourCCCodec: |
|
208 case EMTPObjectPropCodeFramesPerThousandSeconds: |
|
209 case EMTPObjectPropCodeKeyFrameDistance: |
|
210 { |
|
211 TMTPTypeUint32 uint32( aElement.Uint32L( CMTPTypeObjectPropListElement::EValue ) ); |
|
212 responseCode = SetMetaDataToWrapperL( aPropCode, |
|
213 uint32, |
|
214 aObject ); |
|
215 } |
|
216 break; |
|
217 |
|
218 case EMTPObjectPropCodeTrack: |
|
219 case EMTPObjectPropCodeNumberOfChannels: |
|
220 case EMTPObjectPropCodeScanType: |
|
221 case EMTPObjectPropCodeDRMStatus: |
|
222 { |
|
223 TMTPTypeUint16 uint16( aElement.Uint16L( CMTPTypeObjectPropListElement::EValue ) ); |
|
224 responseCode = SetMetaDataToWrapperL( aPropCode, |
|
225 uint16, |
|
226 aObject ); |
|
227 } |
|
228 break; |
|
229 |
|
230 case EMTPExtObjectPropCodeOmaDrmStatus: |
|
231 { |
|
232 TInt drmStatus = MmMtpDpUtility::GetDrmStatus( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
|
233 |
|
234 if ( drmStatus == EMTPDrmStatusUnknown ) |
|
235 { |
|
236 responseCode = EMTPRespCodeAccessDenied; |
|
237 } |
|
238 else |
|
239 { |
|
240 TMTPTypeUint8 newValue( aElement.Uint8L( CMTPTypeObjectPropListElement::EValue ) ); |
|
241 |
|
242 // there's no DB field to remember the value, so return an error |
|
243 // if there's a mismatch to CAF protection status |
|
244 if ( ( ( drmStatus == EMTPDrmStatusProtected ) |
|
245 && ( newValue.Value() == 0 ) ) |
|
246 || ( ( drmStatus == EMTPDrmStatusNotProtected ) |
|
247 && ( newValue.Value() == 1 ) ) ) |
|
248 { |
|
249 responseCode = EMTPRespCodeAccessDenied; |
|
250 } |
|
251 } |
|
252 } |
|
253 break; |
|
254 |
|
255 default: |
|
256 { |
|
257 PRINT( _L( "MM MTP <> Default CASE leaving CMedia...tInfo::SetSpecificObjectPropertyL" ) ); |
|
258 User::Leave( KErrNotSupported ); |
|
259 } |
|
260 break; |
|
261 } |
|
262 |
|
263 PRINT( _L( "MM MTP <= CMediaMtpDataProviderSendObject::ServiceSpecificObjectPropertyL" ) ); |
|
264 |
|
265 return responseCode; |
|
266 } |
|
267 |
|
268 // TODO: Is it necessary? |
|
269 TInt CMediaMtpDataProviderSendObject::HandleSpecificWrapperError( TInt aError, |
|
270 const CMTPObjectMetaData& aObject ) |
|
271 { |
|
272 PRINT( _L( "MM MTP <> CMediaMtpDataProviderSendObject::HandleSpecificWrapperError" ) ); |
|
273 TInt err = aError; |
|
274 |
|
275 if ( ( err == KErrNotSupported ) |
|
276 && ( ( aObject.Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCodeASF ) |
|
277 || ( aObject.Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCodeMP4Container ) |
|
278 || ( aObject.Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCode3GPContainer ) ) ) |
|
279 { |
|
280 // do nothing, handle gracefully |
|
281 // should only happens for container case where metadata field does not match in different DB |
|
282 err = KErrNone; |
|
283 PRINT( _L( "MM MTP <> CMediaMtpDataProviderSendObject::HandleSpecificWrapperError, gracefully dealt with error" ) ); |
|
284 } |
|
285 |
|
286 return err; |
|
287 } |
|
288 |
|
289 // end of file |
|