|
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: getobjectproplist |
|
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 "cmediamtpdataprovidersetobjectproplist.h" |
|
25 #include "mediamtpdataproviderconst.h" |
|
26 #include "mmmtpdplogger.h" |
|
27 #include "cmmmtpdpmetadataaccesswrapper.h" |
|
28 #include "mmmtpdputility.h" |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CMediaMtpDataProviderSetObjectPropList::NewL |
|
32 // Two-phase construction method |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 MMmRequestProcessor* CMediaMtpDataProviderSetObjectPropList::NewL( MMTPDataProviderFramework& aFramework, |
|
36 MMTPConnection& aConnection, |
|
37 MMmMtpDpConfig& aDpConfig ) |
|
38 { |
|
39 CMediaMtpDataProviderSetObjectPropList* self = |
|
40 new ( ELeave ) CMediaMtpDataProviderSetObjectPropList( aFramework, aConnection, aDpConfig ); |
|
41 |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop( self ); |
|
45 |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CMediaMtpDataProviderSetObjectPropList::~CMediaMtpDataProviderSetObjectPropList |
|
51 // Destructor |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CMediaMtpDataProviderSetObjectPropList::~CMediaMtpDataProviderSetObjectPropList() |
|
55 { |
|
56 |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CMediaMtpDataProviderSetObjectPropList::CMediaMtpDataProviderSetObjectPropList |
|
61 // Standard C++ Constructor |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CMediaMtpDataProviderSetObjectPropList::CMediaMtpDataProviderSetObjectPropList( MMTPDataProviderFramework& aFramework, |
|
65 MMTPConnection& aConnection, |
|
66 MMmMtpDpConfig& aDpConfig ) : |
|
67 CSetObjectPropList( aFramework, aConnection, aDpConfig ) |
|
68 { |
|
69 |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CMediaMtpDataProviderSetObjectPropList::ConstructL |
|
74 // 2nd Phase Constructor |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CMediaMtpDataProviderSetObjectPropList::ConstructL() |
|
78 { |
|
79 CSetObjectPropList::ConstructL(); |
|
80 } |
|
81 |
|
82 TMTPResponseCode CMediaMtpDataProviderSetObjectPropList::ServiceSpecificObjectPropertyL( TUint16 aPropCode, const CMTPObjectMetaData& aObject, |
|
83 const CMTPTypeObjectPropListElement& aElement ) |
|
84 { |
|
85 PRINT( _L( "MM MTP => CMediaMtpDataProviderSetObjectPropList::ServiceSpecificObjectPropertyL" ) ); |
|
86 TMTPResponseCode responseCode( EMTPRespCodeOK ); |
|
87 |
|
88 switch ( aPropCode ) |
|
89 { |
|
90 case EMTPObjectPropCodeArtist: |
|
91 case EMTPObjectPropCodeGenre: |
|
92 case EMTPObjectPropCodeComposer: |
|
93 case EMTPObjectPropCodeOriginalReleaseDate: |
|
94 case EMTPObjectPropCodeAlbumName: |
|
95 case EMTPObjectPropCodeParentalRating: |
|
96 case EMTPObjectPropCodeEncodingProfile: |
|
97 { |
|
98 CMTPTypeString* stringData = |
|
99 CMTPTypeString::NewLC( aElement.StringL( CMTPTypeObjectPropListElement::EValue ) );// + stringData |
|
100 |
|
101 responseCode = ServiceMetaDataToWrapperL( aPropCode, |
|
102 *stringData, |
|
103 aObject ); |
|
104 |
|
105 CleanupStack::PopAndDestroy( stringData );// - stringData |
|
106 } |
|
107 break; |
|
108 |
|
109 case EMTPObjectPropCodeVideoBitRate: |
|
110 { |
|
111 responseCode = EMTPRespCodeAccessDenied; |
|
112 } |
|
113 break; |
|
114 |
|
115 case EMTPObjectPropCodeDescription: |
|
116 { |
|
117 CMTPTypeArray* desData = CMTPTypeArray::NewLC( EMTPTypeAUINT16 ); // + desData |
|
118 // aElement.GetL( CMTPTypeObjectPropListElement::EValue, *desData ); |
|
119 desData->SetByDesL(aElement.ArrayL(CMTPTypeObjectPropListElement::EValue )); |
|
120 responseCode = ServiceMetaDataToWrapperL( aPropCode, |
|
121 *desData, |
|
122 aObject ); |
|
123 CleanupStack::PopAndDestroy( desData ); // - desData |
|
124 } |
|
125 break; |
|
126 |
|
127 case EMTPObjectPropCodeWidth: |
|
128 case EMTPObjectPropCodeHeight: |
|
129 case EMTPObjectPropCodeDuration: |
|
130 case EMTPObjectPropCodeUseCount: |
|
131 case EMTPObjectPropCodeSampleRate: |
|
132 case EMTPObjectPropCodeAudioWAVECodec: |
|
133 case EMTPObjectPropCodeAudioBitRate: |
|
134 case EMTPObjectPropCodeVideoFourCCCodec: |
|
135 case EMTPObjectPropCodeFramesPerThousandSeconds: |
|
136 case EMTPObjectPropCodeKeyFrameDistance: |
|
137 { |
|
138 TMTPTypeUint32 uint32( aElement.Uint32L( CMTPTypeObjectPropListElement::EValue ) ); |
|
139 responseCode = ServiceMetaDataToWrapperL( aPropCode, |
|
140 uint32, |
|
141 aObject ); |
|
142 } |
|
143 break; |
|
144 |
|
145 case EMTPObjectPropCodeTrack: |
|
146 case EMTPObjectPropCodeNumberOfChannels: |
|
147 case EMTPObjectPropCodeScanType: |
|
148 case EMTPObjectPropCodeDRMStatus: |
|
149 { |
|
150 TMTPTypeUint16 uint16( aElement.Uint16L( CMTPTypeObjectPropListElement::EValue )); |
|
151 responseCode = ServiceMetaDataToWrapperL( aPropCode, |
|
152 uint16, |
|
153 aObject ); |
|
154 } |
|
155 break; |
|
156 |
|
157 case EMTPExtObjectPropCodeOmaDrmStatus: |
|
158 { |
|
159 TInt drmStatus = MmMtpDpUtility::GetDrmStatus( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
|
160 |
|
161 if (drmStatus == EMTPDrmStatusUnknown) |
|
162 { |
|
163 responseCode = EMTPRespCodeAccessDenied; |
|
164 } |
|
165 else |
|
166 { |
|
167 TMTPTypeUint8 newValue( aElement.Uint8L( CMTPTypeObjectPropListElement::EValue ) ); |
|
168 |
|
169 // there's no DB field to remember the value, so return an error |
|
170 // if there's a mismatch to CAF protection status |
|
171 if ( ( ( drmStatus == EMTPDrmStatusProtected) && ( newValue.Value() == 0 ) ) || |
|
172 ( ( drmStatus == EMTPDrmStatusNotProtected ) && ( newValue.Value() == 1 ) ) ) |
|
173 { |
|
174 responseCode = EMTPRespCodeAccessDenied; |
|
175 } |
|
176 } |
|
177 } |
|
178 break; |
|
179 |
|
180 default: |
|
181 { |
|
182 User::Leave( KErrNotSupported ); |
|
183 } |
|
184 break; |
|
185 } |
|
186 |
|
187 PRINT( _L( "MM MTP <= CMediaMtpDataProviderSetObjectPropList::ServiceSpecificObjectPropertyL" ) ); |
|
188 |
|
189 return responseCode; |
|
190 } |
|
191 |
|
192 TInt CMediaMtpDataProviderSetObjectPropList::HandleSpecificWrapperError( TInt aError, |
|
193 const CMTPObjectMetaData& aObject) |
|
194 { |
|
195 TInt err = aError; |
|
196 |
|
197 if ( ( err == KErrNotSupported ) |
|
198 && ( ( aObject.Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCodeASF ) |
|
199 || ( aObject.Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCodeMP4Container ) |
|
200 || ( aObject.Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCode3GPContainer ) ) ) |
|
201 { |
|
202 // do nothing, handle gracefully |
|
203 // should only happens for container case where metadata field does not match in different DB |
|
204 err = KErrNone; |
|
205 PRINT( _L( "MM MTP <> CMediaMtpDataProviderSetObjectPropList::HandleSpecificWrapperError, gracefully dealt with error" ) ); |
|
206 } |
|
207 |
|
208 return err; |
|
209 } |
|
210 |
|
211 // end of file |