|
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 opeartion setobjectpropvalue |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <mtp/mmtpdataproviderframework.h> |
|
20 #include <mtp/cmtptypestring.h> |
|
21 #include <mtp/cmtptypearray.h> |
|
22 #include <mtp/mmtpobjectmgr.h> |
|
23 |
|
24 #include "cmediamtpdataprovidersetobjectpropvalue.h" |
|
25 #include "mediamtpdataproviderconst.h" |
|
26 #include "mmmtpdplogger.h" |
|
27 #include "mmmtpdputility.h" |
|
28 #include "cmmmtpdpmetadataaccesswrapper.h" |
|
29 #include "mmmtpdpdefs.h" |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CMediaMtpDataProviderSetObjectPropValue::NewL |
|
33 // Two-phase construction method |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 MMmRequestProcessor* CMediaMtpDataProviderSetObjectPropValue::NewL( MMTPDataProviderFramework& aFramework, |
|
37 MMTPConnection& aConnection, |
|
38 MMmMtpDpConfig& aDpConfig ) |
|
39 { |
|
40 CMediaMtpDataProviderSetObjectPropValue* self = |
|
41 new ( ELeave ) CMediaMtpDataProviderSetObjectPropValue( aFramework, |
|
42 aConnection, |
|
43 aDpConfig ); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CMediaMtpDataProviderSetObjectPropValue::ConstructL |
|
52 // Two-phase construction method |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CMediaMtpDataProviderSetObjectPropValue::ConstructL() |
|
56 { |
|
57 |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CMediaMtpDataProviderSetObjectPropValue::CMediaMtpDataProviderSetObjectPropValue |
|
62 // Standard c++ constructor |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CMediaMtpDataProviderSetObjectPropValue::CMediaMtpDataProviderSetObjectPropValue( MMTPDataProviderFramework& aFramework, |
|
66 MMTPConnection& aConnection, |
|
67 MMmMtpDpConfig& aDpConfig ) : |
|
68 CSetObjectPropValue( aFramework, aConnection, aDpConfig ) |
|
69 { |
|
70 |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CMediaMtpDataProviderSetObjectPropValue::~CMediaMtpDataProviderSetObjectPropValue |
|
75 // Destructor |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 CMediaMtpDataProviderSetObjectPropValue::~CMediaMtpDataProviderSetObjectPropValue() |
|
79 { |
|
80 |
|
81 } |
|
82 |
|
83 TBool CMediaMtpDataProviderSetObjectPropValue::IsSpecificPropCodeReadOnly( TUint16 aPropCode ) const |
|
84 { |
|
85 TBool returnCode = EFalse; |
|
86 |
|
87 if ( aPropCode == EMTPObjectPropCodeVideoBitRate ) |
|
88 returnCode = ETrue; |
|
89 |
|
90 return returnCode; |
|
91 } |
|
92 |
|
93 void CMediaMtpDataProviderSetObjectPropValue::ReceiveDataSpecificObjectPropertyL( TUint16 aPropCode ) |
|
94 { |
|
95 PRINT( _L( "MM MTP => CMediaMtpDataProviderSetObjectPropValue::RecieveDataSpecificObjectPropertyL" ) ); |
|
96 |
|
97 switch ( aPropCode ) |
|
98 { |
|
99 case EMTPObjectPropCodeArtist: // 0xDC46 |
|
100 case EMTPObjectPropCodeGenre: // 0xDC8C |
|
101 case EMTPObjectPropCodeParentalRating: // 0xDC94 |
|
102 case EMTPObjectPropCodeComposer: // 0xDC96 |
|
103 case EMTPObjectPropCodeOriginalReleaseDate: // 0xDC99 |
|
104 case EMTPObjectPropCodeAlbumName: // 0xDC9A |
|
105 case EMTPObjectPropCodeEncodingProfile: // 0xDEA1 |
|
106 { |
|
107 delete iMTPTypeString; |
|
108 iMTPTypeString = NULL; |
|
109 iMTPTypeString = CMTPTypeString::NewL(); |
|
110 ReceiveDataL( *iMTPTypeString ); |
|
111 } |
|
112 break; |
|
113 |
|
114 case EMTPObjectPropCodeDescription: |
|
115 { |
|
116 delete iMTPTypeArray; |
|
117 iMTPTypeArray = NULL; |
|
118 iMTPTypeArray = CMTPTypeArray::NewL( EMTPTypeAUINT16 ); |
|
119 ReceiveDataL( *iMTPTypeArray ); |
|
120 } |
|
121 break; |
|
122 |
|
123 //Get Data for Int16 objects |
|
124 case EMTPObjectPropCodeTrack: // 0xDC8B |
|
125 case EMTPObjectPropCodeDRMStatus: // 0xDC9D |
|
126 case EMTPObjectPropCodeNumberOfChannels: // 0xDE94 |
|
127 case EMTPObjectPropCodeScanType: // 0xDE97 |
|
128 ReceiveDataL( iMTPTypeUint16 ); |
|
129 break; |
|
130 |
|
131 //Get Data for Int32 objects |
|
132 case EMTPObjectPropCodeWidth: // 0xDC87 |
|
133 case EMTPObjectPropCodeHeight: // 0xDC88 |
|
134 case EMTPObjectPropCodeDuration: // 0xDC89 |
|
135 case EMTPObjectPropCodeUseCount: // 0xDC91 |
|
136 case EMTPObjectPropCodeSampleRate: // 0xDE93 |
|
137 case EMTPObjectPropCodeAudioWAVECodec: // 0xDE99 |
|
138 case EMTPObjectPropCodeAudioBitRate: // 0xDE9A |
|
139 case EMTPObjectPropCodeVideoFourCCCodec: // 0xDE9B |
|
140 case EMTPObjectPropCodeFramesPerThousandSeconds: // 0xDE9D |
|
141 case EMTPObjectPropCodeKeyFrameDistance: // 0xDE9E |
|
142 ReceiveDataL( iMTPTypeUint32 ); |
|
143 break; |
|
144 |
|
145 case EMTPExtObjectPropCodeOmaDrmStatus: |
|
146 ReceiveDataL( iMTPTypeUint8 ); |
|
147 break; |
|
148 |
|
149 default: |
|
150 User::Leave( KErrNotSupported ); |
|
151 break; |
|
152 } |
|
153 |
|
154 PRINT( _L( "MM MTP <= CMediaMtpDataProviderSetObjectPropValue::RecieveDataSpecificObjectPropertyL" ) ); |
|
155 } |
|
156 |
|
157 TMTPResponseCode CMediaMtpDataProviderSetObjectPropValue::ServiceSpecificObjectPropertyL( TUint16 aPropCode ) |
|
158 { |
|
159 TMTPResponseCode responseCode = EMTPRespCodeOK; |
|
160 |
|
161 switch ( aPropCode ) |
|
162 { |
|
163 case EMTPObjectPropCodeArtist: // 0xDC46 |
|
164 case EMTPObjectPropCodeGenre: //0xDC8C |
|
165 case EMTPObjectPropCodeParentalRating: //0xDC94 |
|
166 case EMTPObjectPropCodeComposer: //0xDC96 |
|
167 case EMTPObjectPropCodeOriginalReleaseDate: //0xDC99 |
|
168 case EMTPObjectPropCodeAlbumName: //0xDC9A |
|
169 case EMTPObjectPropCodeEncodingProfile: //0xDEA1 |
|
170 { |
|
171 responseCode = ServiceMetaDataToWrapperL( iPropCode, |
|
172 *iMTPTypeString, |
|
173 *iObjectInfo ); |
|
174 } |
|
175 break; |
|
176 |
|
177 case EMTPObjectPropCodeDescription: |
|
178 { |
|
179 responseCode = ServiceMetaDataToWrapperL( EMTPObjectPropCodeDescription, |
|
180 *iMTPTypeArray, |
|
181 *iObjectInfo ); |
|
182 } |
|
183 break; |
|
184 |
|
185 case EMTPObjectPropCodeWidth: //0xDC87 |
|
186 case EMTPObjectPropCodeHeight: //0xDC88 |
|
187 case EMTPObjectPropCodeDuration: //0xDC89 |
|
188 case EMTPObjectPropCodeUseCount: //0xDC91 |
|
189 case EMTPObjectPropCodeSampleRate: //0xDE93 |
|
190 case EMTPObjectPropCodeAudioWAVECodec: //0xDE99 |
|
191 case EMTPObjectPropCodeAudioBitRate: //0xDE9A |
|
192 case EMTPObjectPropCodeVideoFourCCCodec: //0xDE9B |
|
193 case EMTPObjectPropCodeFramesPerThousandSeconds: //0xDE9D |
|
194 case EMTPObjectPropCodeKeyFrameDistance: //0xDE9E |
|
195 { |
|
196 responseCode = ServiceMetaDataToWrapperL( iPropCode, |
|
197 iMTPTypeUint32, |
|
198 *iObjectInfo ); |
|
199 } |
|
200 break; |
|
201 |
|
202 case EMTPObjectPropCodeTrack: // 0xDC8B |
|
203 case EMTPObjectPropCodeDRMStatus: // 0xDC9D |
|
204 case EMTPObjectPropCodeNumberOfChannels: // 0xDE94 |
|
205 case EMTPObjectPropCodeScanType: // 0xDE97 |
|
206 { |
|
207 responseCode = ServiceMetaDataToWrapperL( iPropCode, |
|
208 iMTPTypeUint16, |
|
209 *iObjectInfo ); |
|
210 } |
|
211 break; |
|
212 |
|
213 case EMTPExtObjectPropCodeOmaDrmStatus: |
|
214 { |
|
215 CMTPObjectMetaData& aObject( *iObjectInfo ); |
|
216 TInt drmStatus = MmMtpDpUtility::GetDrmStatus( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
|
217 |
|
218 if (drmStatus == EMTPDrmStatusUnknown) |
|
219 { |
|
220 responseCode = EMTPRespCodeAccessDenied; |
|
221 } |
|
222 else |
|
223 { |
|
224 TMTPTypeUint8 newValue( iMTPTypeUint8 ); |
|
225 |
|
226 // there's no DB field to remember the value, so return an error |
|
227 // if there's a mismatch to CAF protection status |
|
228 if ( ( ( drmStatus == EMTPDrmStatusProtected) && ( newValue.Value() == 0 ) ) || |
|
229 ( ( drmStatus == EMTPDrmStatusNotProtected ) && ( newValue.Value() == 1 ) ) ) |
|
230 { |
|
231 responseCode = EMTPRespCodeAccessDenied; |
|
232 } |
|
233 } |
|
234 } |
|
235 break; |
|
236 |
|
237 default: |
|
238 { |
|
239 User::Leave( KErrNotSupported ); |
|
240 } |
|
241 break; |
|
242 } |
|
243 |
|
244 return responseCode; |
|
245 } |
|
246 |
|
247 // end of file |