|
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 "cmediamtpdataprovidergetobjectproplist.h" |
|
25 #include "mediamtpdataproviderconst.h" |
|
26 #include "mmmtpdplogger.h" |
|
27 #include "cmmmtpdpmetadataaccesswrapper.h" |
|
28 #include "mmmtpdputility.h" |
|
29 #include "mmmtpdpdefs.h" |
|
30 #include "mmmtpdpconfig.h" |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CMediaMtpDataProviderGetObjectPropList::NewL |
|
34 // Two-phase construction method |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 MMmRequestProcessor* CMediaMtpDataProviderGetObjectPropList::NewL( MMTPDataProviderFramework& aFramework, |
|
38 MMTPConnection& aConnection, |
|
39 MMmMtpDpConfig& aDpConfig ) |
|
40 { |
|
41 CMediaMtpDataProviderGetObjectPropList* self = |
|
42 new ( ELeave ) CMediaMtpDataProviderGetObjectPropList( aFramework, aConnection, aDpConfig ); |
|
43 |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CMediaMtpDataProviderGetObjectPropList::~CMediaMtpDataProviderGetObjectPropList |
|
52 // Destructor |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CMediaMtpDataProviderGetObjectPropList::~CMediaMtpDataProviderGetObjectPropList() |
|
56 { |
|
57 |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CMediaMtpDataProviderGetObjectPropList::CMediaMtpDataProviderGetObjectPropList |
|
62 // Standard C++ Constructor |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CMediaMtpDataProviderGetObjectPropList::CMediaMtpDataProviderGetObjectPropList( MMTPDataProviderFramework& aFramework, |
|
66 MMTPConnection& aConnection, |
|
67 MMmMtpDpConfig& aDpConfig ) : |
|
68 CGetObjectPropList( aFramework, aConnection, aDpConfig ) |
|
69 { |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CMediaMtpDataProviderGetObjectPropList::ConstructL |
|
74 // 2nd Phase Constructor |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CMediaMtpDataProviderGetObjectPropList::ConstructL() |
|
78 { |
|
79 CGetObjectPropList::ConstructL(); |
|
80 } |
|
81 |
|
82 TInt CMediaMtpDataProviderGetObjectPropList::ServiceSpecificObjectPropertyL( TUint16 aPropCode, |
|
83 TUint32 aHandle ) |
|
84 { |
|
85 PRINT( _L( "MM MTP => CMediaMtpDataProviderGetObjectPropList::ServiceSpecificObjectPropertyL" ) ); |
|
86 |
|
87 CMTPTypeString* textData = NULL; |
|
88 CMTPTypeArray* desData = NULL; |
|
89 TInt err = KErrNone; |
|
90 |
|
91 if ( iPropertyElement != NULL ) |
|
92 { |
|
93 delete iPropertyElement; |
|
94 iPropertyElement = NULL; |
|
95 } |
|
96 |
|
97 switch ( aPropCode ) |
|
98 { |
|
99 //case EMTPObjectPropCodeName: |
|
100 case EMTPObjectPropCodeArtist: |
|
101 case EMTPObjectPropCodeGenre: |
|
102 case EMTPObjectPropCodeComposer: |
|
103 case EMTPObjectPropCodeOriginalReleaseDate: |
|
104 case EMTPObjectPropCodeAlbumName: |
|
105 case EMTPObjectPropCodeParentalRating: |
|
106 case EMTPObjectPropCodeEncodingProfile: |
|
107 { |
|
108 textData = CMTPTypeString::NewLC(); // + textData |
|
109 |
|
110 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
|
111 *textData, |
|
112 *iObject ) ); |
|
113 |
|
114 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderGetObjectPropList::ServiceSpecificObjectPropertyL err = %d" ), err ); |
|
115 |
|
116 if ( err == KErrNone ) |
|
117 { |
|
118 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
119 iPropertyElement->SetStringL( CMTPTypeObjectPropListElement::EValue, textData->StringChars()); |
|
120 } |
|
121 |
|
122 CleanupStack::PopAndDestroy( textData ); // - textData |
|
123 } |
|
124 break; |
|
125 |
|
126 case EMTPObjectPropCodeDescription: |
|
127 { |
|
128 desData = CMTPTypeArray::NewLC( EMTPTypeAUINT16 ); // + desData |
|
129 |
|
130 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
|
131 *desData, |
|
132 *iObject ) ); |
|
133 |
|
134 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderGetObjectPropList::ServiceSpecificObjectPropertyL err = %d" ), err ); |
|
135 |
|
136 if ( err == KErrNone ) |
|
137 { |
|
138 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
139 iPropertyElement->SetArrayL( CMTPTypeObjectPropListElement::EValue, *desData); |
|
140 } |
|
141 |
|
142 CleanupStack::PopAndDestroy( desData ); // - desData |
|
143 } |
|
144 break; |
|
145 |
|
146 case EMTPObjectPropCodeTrack: |
|
147 case EMTPObjectPropCodeNumberOfChannels: |
|
148 case EMTPObjectPropCodeScanType: |
|
149 case EMTPObjectPropCodeDRMStatus: |
|
150 { |
|
151 TMTPTypeUint16 uint16( 0 ); |
|
152 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
|
153 uint16, |
|
154 *iObject ) ); |
|
155 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderGetObjectPropList::ServiceSpecificObjectPropertyL err = %d" ), err ); |
|
156 |
|
157 if ( err == KErrNone ) |
|
158 { |
|
159 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
160 iPropertyElement->SetUint16L( CMTPTypeObjectPropListElement::EValue, uint16.Value()); |
|
161 } |
|
162 } |
|
163 break; |
|
164 |
|
165 case EMTPObjectPropCodeWidth: |
|
166 case EMTPObjectPropCodeHeight: |
|
167 case EMTPObjectPropCodeDuration: |
|
168 case EMTPObjectPropCodeUseCount: |
|
169 case EMTPObjectPropCodeSampleRate: |
|
170 case EMTPObjectPropCodeAudioWAVECodec: |
|
171 case EMTPObjectPropCodeAudioBitRate: |
|
172 case EMTPObjectPropCodeVideoFourCCCodec: |
|
173 case EMTPObjectPropCodeVideoBitRate: |
|
174 case EMTPObjectPropCodeFramesPerThousandSeconds: |
|
175 case EMTPObjectPropCodeKeyFrameDistance: |
|
176 { |
|
177 TMTPTypeUint32 uint32 = 0; |
|
178 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
|
179 uint32, |
|
180 *iObject ) ); |
|
181 PRINT1( _L( "MM MTP <> CMediaMtpDataProviderGetObjectPropList::ServiceSpecificObjectPropertyL err = %d" ), err ); |
|
182 |
|
183 if ( err == KErrNone ) |
|
184 { |
|
185 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
186 iPropertyElement->SetUint32L( CMTPTypeObjectPropListElement::EValue, uint32.Value()); |
|
187 } |
|
188 } |
|
189 break; |
|
190 |
|
191 case EMTPExtObjectPropCodeOmaDrmStatus: |
|
192 { |
|
193 TInt drmStatus = MmMtpDpUtility::GetDrmStatus( iObject->DesC( CMTPObjectMetaData::ESuid ) ); |
|
194 TMTPTypeUint8 result; |
|
195 result.Set( 0 ); |
|
196 |
|
197 if ( drmStatus == EMTPDrmStatusProtected ) |
|
198 result.Set( 1 ); |
|
199 |
|
200 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
201 iPropertyElement->SetUint16L( CMTPTypeObjectPropListElement::EDatatype, EMTPTypeUINT8); |
|
202 iPropertyElement->SetUint8L( CMTPTypeObjectPropListElement::EValue, result.Value()); |
|
203 } |
|
204 break; |
|
205 |
|
206 default: |
|
207 { |
|
208 iPropertyElement = NULL; |
|
209 err = KErrNotSupported; |
|
210 } |
|
211 break; |
|
212 } |
|
213 |
|
214 PRINT( _L( "MM MTP <= CMediaMtpDataProviderGetObjectPropList::ServiceSpecificObjectPropertyL" ) ); |
|
215 |
|
216 return err; |
|
217 } |
|
218 |
|
219 // end of file |