|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <mtp/cmtptypeobjectproplist.h> |
|
19 #include <mtp/cmtptypestring.h> |
|
20 #include <mtp/cmtptypearray.h> |
|
21 #include <mtp/tmtptypeuint8.h> |
|
22 #include <mtp/tmtptypeuint16.h> |
|
23 #include <mtp/tmtptypeuint32.h> |
|
24 #include <mtp/mtpdatatypeconstants.h> |
|
25 |
|
26 #include "tobjectdescription.h" |
|
27 #include "cmmmtpdpmetadataaccesswrapper.h" |
|
28 #include "mmmtpdpconfig.h" |
|
29 #include "mmmtpdputility.h" |
|
30 |
|
31 #include "cmediamtpdataproviderpropertysettingutility.h" |
|
32 #include "mmmtpdplogger.h" |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CMediaMtpDataProviderPropertySettingUtility::NewL |
|
36 // Two-phase construction method |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CMediaMtpDataProviderPropertySettingUtility* CMediaMtpDataProviderPropertySettingUtility::NewL() |
|
40 { |
|
41 CMediaMtpDataProviderPropertySettingUtility* self = |
|
42 new ( ELeave ) CMediaMtpDataProviderPropertySettingUtility(); |
|
43 |
|
44 return self; |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CMediaMtpDataProviderPropertySettingUtility::~CMediaMtpDataProviderPropertySettingUtility |
|
49 // Destructor |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CMediaMtpDataProviderPropertySettingUtility::~CMediaMtpDataProviderPropertySettingUtility() |
|
53 { |
|
54 // Do nothing |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CMediaMtpDataProviderSetObjectPropList::CMediaMtpDataProviderSetObjectPropList |
|
59 // Standard C++ Constructor |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CMediaMtpDataProviderPropertySettingUtility::CMediaMtpDataProviderPropertySettingUtility() |
|
63 { |
|
64 // Do nothing |
|
65 } |
|
66 |
|
67 TMTPResponseCode CMediaMtpDataProviderPropertySettingUtility::SetSpecificObjectPropertyL( MMmMtpDpConfig& aDpConfig, |
|
68 TUint16 aPropCode, |
|
69 const CMTPObjectMetaData& aObject, |
|
70 const CMTPTypeObjectPropListElement& aElement ) |
|
71 { |
|
72 PRINT( _L( "MM MTP => CMediaMtpDataProviderPropertySettingUtility::SetSpecificObjectPropertyL" ) ); |
|
73 TMTPResponseCode responseCode( EMTPRespCodeOK ); |
|
74 |
|
75 switch ( aPropCode ) |
|
76 { |
|
77 case EMTPObjectPropCodeArtist: |
|
78 case EMTPObjectPropCodeGenre: |
|
79 case EMTPObjectPropCodeComposer: |
|
80 case EMTPObjectPropCodeOriginalReleaseDate: |
|
81 case EMTPObjectPropCodeAlbumName: |
|
82 case EMTPObjectPropCodeParentalRating: |
|
83 case EMTPObjectPropCodeEncodingProfile: |
|
84 { |
|
85 CMTPTypeString* stringData = |
|
86 CMTPTypeString::NewLC( aElement.StringL( CMTPTypeObjectPropListElement::EValue ) );// + stringData |
|
87 |
|
88 responseCode = SetMetaDataToWrapperL( aDpConfig, |
|
89 aPropCode, |
|
90 *stringData, |
|
91 aObject ); |
|
92 |
|
93 CleanupStack::PopAndDestroy( stringData );// - stringData |
|
94 } |
|
95 break; |
|
96 |
|
97 case EMTPObjectPropCodeVideoBitRate: |
|
98 /* |
|
99 spec: |
|
100 * Object properties that are get-only (0x00 GET) |
|
101 * should accept values during object creation by |
|
102 * way of the SendObjectPropList command. |
|
103 */ |
|
104 break; |
|
105 |
|
106 case EMTPObjectPropCodeDescription: |
|
107 { |
|
108 CMTPTypeArray* desData = CMTPTypeArray::NewLC( EMTPTypeAUINT16 ); // + desData |
|
109 desData->SetByDesL( aElement.ArrayL( CMTPTypeObjectPropListElement::EValue ) ); |
|
110 responseCode = SetMetaDataToWrapperL( aDpConfig, |
|
111 aPropCode, |
|
112 *desData, |
|
113 aObject ); |
|
114 CleanupStack::PopAndDestroy( desData ); // - desData |
|
115 } |
|
116 break; |
|
117 |
|
118 case EMTPObjectPropCodeWidth: |
|
119 case EMTPObjectPropCodeHeight: |
|
120 case EMTPObjectPropCodeDuration: |
|
121 case EMTPObjectPropCodeUseCount: |
|
122 case EMTPObjectPropCodeSampleRate: |
|
123 case EMTPObjectPropCodeAudioWAVECodec: |
|
124 case EMTPObjectPropCodeAudioBitRate: |
|
125 case EMTPObjectPropCodeVideoFourCCCodec: |
|
126 case EMTPObjectPropCodeFramesPerThousandSeconds: |
|
127 case EMTPObjectPropCodeKeyFrameDistance: |
|
128 { |
|
129 TMTPTypeUint32 uint32( aElement.Uint32L( CMTPTypeObjectPropListElement::EValue ) ); |
|
130 responseCode = SetMetaDataToWrapperL( aDpConfig, |
|
131 aPropCode, |
|
132 uint32, |
|
133 aObject ); |
|
134 } |
|
135 break; |
|
136 |
|
137 case EMTPObjectPropCodeTrack: |
|
138 case EMTPObjectPropCodeNumberOfChannels: |
|
139 case EMTPObjectPropCodeScanType: |
|
140 case EMTPObjectPropCodeDRMStatus: |
|
141 { |
|
142 TMTPTypeUint16 uint16( aElement.Uint16L( CMTPTypeObjectPropListElement::EValue ) ); |
|
143 responseCode = SetMetaDataToWrapperL( aDpConfig, |
|
144 aPropCode, |
|
145 uint16, |
|
146 aObject ); |
|
147 } |
|
148 break; |
|
149 |
|
150 case EMTPExtObjectPropCodeOmaDrmStatus: |
|
151 { |
|
152 TInt drmStatus = MmMtpDpUtility::GetDrmStatus( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
|
153 |
|
154 if ( drmStatus == EMTPDrmStatusUnknown ) |
|
155 { |
|
156 responseCode = EMTPRespCodeAccessDenied; |
|
157 } |
|
158 else |
|
159 { |
|
160 TMTPTypeUint8 newValue( aElement.Uint8L( CMTPTypeObjectPropListElement::EValue ) ); |
|
161 |
|
162 // there's no DB field to remember the value, so return an error |
|
163 // if there's a mismatch to CAF protection status |
|
164 if ( ( ( drmStatus == EMTPDrmStatusProtected ) |
|
165 && ( newValue.Value() == 0 ) ) |
|
166 || ( ( drmStatus == EMTPDrmStatusNotProtected ) |
|
167 && ( newValue.Value() == 1 ) ) ) |
|
168 { |
|
169 responseCode = EMTPRespCodeAccessDenied; |
|
170 } |
|
171 } |
|
172 } |
|
173 break; |
|
174 |
|
175 default: |
|
176 { |
|
177 // Should not happen, property code should have been checked before set to store. |
|
178 User::Leave( KErrNotSupported ); |
|
179 } |
|
180 break; |
|
181 } |
|
182 |
|
183 PRINT( _L( "MM MTP <= CMediaMtpDataProviderPropertySettingUtility::ServiceSpecificObjectPropertyL" ) ); |
|
184 |
|
185 return responseCode; |
|
186 } |
|
187 |
|
188 // end of file |