16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 #include <mtp/mmtpdataproviderframework.h> |
19 #include <mtp/mmtpdataproviderframework.h> |
20 #include <mtp/mmtpobjectmgr.h> |
20 #include <mtp/mmtpobjectmgr.h> |
|
21 #include <mtp/cmtptypestring.h> |
|
22 #include <mtp/cmtpobjectmetadata.h> |
21 #include <bautils.h> |
23 #include <bautils.h> |
22 #include <e32math.h> |
24 #include <e32math.h> |
23 #include <e32property.h> |
25 #include <e32property.h> |
24 #include <mtpprivatepskeys.h> |
26 #include <mtpprivatepskeys.h> |
25 |
27 |
26 #include "cmmmtpdpmetadataaccesswrapper.h" |
28 #include "cmmmtpdpmetadataaccesswrapper.h" |
27 #include "cmmmtpdpmetadatampxaccess.h" |
29 #include "cmmmtpdpmetadatampxaccess.h" |
28 #include "cmmmtpdpmetadatavideoaccess.h" |
30 #include "cmmmtpdpmetadatavideoaccess.h" |
29 #include "mmmtpdputility.h" |
31 #include "mmmtpdputility.h" |
|
32 #include "tobjectdescription.h" |
30 #include "mmmtpdplogger.h" |
33 #include "mmmtpdplogger.h" |
31 |
34 |
32 const TInt KMMMTPDummyFileArrayGranularity = 5; |
35 const TInt KMmMtpDummyFileArrayGranularity = 5; |
33 |
36 |
34 CMmMtpDpMetadataAccessWrapper* CMmMtpDpMetadataAccessWrapper::NewL( RFs& aRfs, |
37 CMmMtpDpMetadataAccessWrapper* CMmMtpDpMetadataAccessWrapper::NewL( MMTPDataProviderFramework& aFramework ) |
35 MMTPDataProviderFramework& aFramework ) |
38 { |
36 { |
39 CMmMtpDpMetadataAccessWrapper* me = new (ELeave) CMmMtpDpMetadataAccessWrapper( aFramework ); |
37 CMmMtpDpMetadataAccessWrapper* me = new (ELeave) CMmMtpDpMetadataAccessWrapper( aRfs, aFramework ); |
|
38 CleanupStack::PushL( me ); |
40 CleanupStack::PushL( me ); |
39 me->ConstructL(); |
41 me->ConstructL(); |
40 CleanupStack::Pop( me ); |
42 CleanupStack::Pop( me ); |
41 |
43 |
42 return me; |
44 return me; |
43 } |
45 } |
44 |
46 |
45 CMmMtpDpMetadataAccessWrapper::CMmMtpDpMetadataAccessWrapper( RFs& aRfs, |
47 CMmMtpDpMetadataAccessWrapper::CMmMtpDpMetadataAccessWrapper( MMTPDataProviderFramework& aFramework ) : |
46 MMTPDataProviderFramework& aFramework ) : |
48 iFramework( aFramework ), |
47 iRfs( aRfs ), |
49 iFs( aFramework.Fs() ) |
48 iFramework( aFramework ) |
|
49 { |
50 { |
50 // Do nothing |
51 // Do nothing |
51 } |
52 } |
52 |
53 |
53 // --------------------------------------------------------------------------- |
54 // --------------------------------------------------------------------------- |
57 // |
58 // |
58 void CMmMtpDpMetadataAccessWrapper::ConstructL() |
59 void CMmMtpDpMetadataAccessWrapper::ConstructL() |
59 { |
60 { |
60 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::ConstructL" ) ); |
61 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::ConstructL" ) ); |
61 |
62 |
62 iMmMtpDpMetadataMpxAccess = CMmMtpDpMetadataMpxAccess::NewL( iRfs, iFramework ); |
63 iMmMtpDpMetadataMpxAccess = CMmMtpDpMetadataMpxAccess::NewL( iFs ); |
63 |
64 |
64 iMmMtpDpMetadataVideoAccess = CMmMtpDpMetadataVideoAccess::NewL( iRfs ); |
65 iMmMtpDpMetadataVideoAccess = CMmMtpDpMetadataVideoAccess::NewL( iFs ); |
65 |
66 |
66 iAbstractMediaArray = new ( ELeave ) CDesCArrayFlat( KMMMTPDummyFileArrayGranularity ); |
67 iAbstractMediaArray = new ( ELeave ) CDesCArrayFlat( KMmMtpDummyFileArrayGranularity ); |
67 |
68 |
68 // Create the PS key to notify subscribers that MTP mode is activated |
69 // Create the PS key to notify subscribers that MTP mode is activated |
69 _LIT_SECURITY_POLICY_C1(KKeyReadPolicy, ECapabilityReadUserData); |
70 _LIT_SECURITY_POLICY_C1(KKeyReadPolicy, ECapabilityReadUserData); |
70 _LIT_SECURITY_POLICY_C1(KKeyWritePolicy, ECapabilityWriteUserData); |
71 _LIT_SECURITY_POLICY_C1(KKeyWritePolicy, ECapabilityWriteUserData); |
71 RProperty::Define( KMtpPSUid, |
72 RProperty::Define( KMtpPSUid, |
98 EMtpPSStatusUninitialized ); |
99 EMtpPSStatusUninitialized ); |
99 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper" ) ); |
100 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::~CMmMtpDpMetadataAccessWrapper" ) ); |
100 } |
101 } |
101 |
102 |
102 // ----------------------------------------------------------------------------- |
103 // ----------------------------------------------------------------------------- |
103 // CMmMtpDpMetadataAccessWrapper::SetAbstractMediaL |
104 // CMmMtpDpMetadataAccessWrapper::SetReferenceL |
104 // Set abstract media to DB |
105 // Set abstract media to DB |
105 // ----------------------------------------------------------------------------- |
106 // ----------------------------------------------------------------------------- |
106 // |
107 // |
107 EXPORT_C void CMmMtpDpMetadataAccessWrapper::SetAbstractMediaL( const TDesC& aAbstractMediaFileName, |
108 EXPORT_C void CMmMtpDpMetadataAccessWrapper::SetReferenceL( const CMTPObjectMetaData& aObject, |
108 CDesCArray& aRefFileArray, |
109 CDesCArray& aRefFileArray ) |
109 TMPXGeneralCategory aCategory ) |
110 { |
110 { |
111 TPtrC refOwner( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
111 PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::SetAbstractMediaL aAbstractMediaFileName = %S" ), &aAbstractMediaFileName ); |
112 PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::SetReferenceL reference owner = %S" ), |
112 |
113 &refOwner ); |
113 if ( !MmMtpDpUtility::IsVideoL( aAbstractMediaFileName, iFramework ) ) |
114 |
114 { |
115 TMPXGeneralCategory category = Category( aObject ); |
115 iMmMtpDpMetadataMpxAccess->SetAbstractMediaL( aAbstractMediaFileName, aRefFileArray, aCategory ); |
116 if ( category == EMPXPlaylist || category == EMPXAbstractAlbum ) |
116 } |
117 { |
117 |
118 iMmMtpDpMetadataMpxAccess->SetReferenceL( refOwner, aRefFileArray, category ); |
118 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetAbstractMediaL" ) ); |
119 } |
|
120 |
|
121 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetReferenceL" ) ); |
119 } |
122 } |
120 |
123 |
121 // --------------------------------------------------------------------------- |
124 // --------------------------------------------------------------------------- |
122 // CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL |
125 // CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL |
123 // Gets a piece of metadata from the collection |
126 // Gets a piece of metadata from the collection |
127 MMTPType& aNewData, |
130 MMTPType& aNewData, |
128 const CMTPObjectMetaData& aObjectMetaData ) |
131 const CMTPObjectMetaData& aObjectMetaData ) |
129 { |
132 { |
130 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL" ) ); |
133 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL" ) ); |
131 |
134 |
132 TPtrC fullFileName( aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ) ); |
135 TMPXGeneralCategory category = Category( aObjectMetaData ); |
133 if ( !MmMtpDpUtility::IsVideoL( fullFileName, iFramework ) ) |
136 switch ( category ) |
134 { |
137 { |
135 iMmMtpDpMetadataMpxAccess->GetObjectMetadataValueL( aPropCode, |
138 case EMPXAbstractAlbum: |
136 aNewData, |
139 if ( aPropCode == EMTPObjectPropCodeDateAdded && EMTPTypeString == aNewData.Type() ) |
137 aObjectMetaData ); |
140 { |
138 } |
141 TBuf<KMtpMaxDateTimeStringLength> timeStr; |
139 else |
142 MmMtpDpUtility::GetObjectDateModifiedL( iFs, |
140 { |
143 aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ), |
141 iMmMtpDpMetadataVideoAccess->GetObjectMetadataValueL( aPropCode, |
144 timeStr ); |
142 aNewData, |
145 PRINT1( _L( "MM MTP <> CGetObjectPropList::ServiceOneObjectPropertyL Date time %S" ), &timeStr ); |
143 aObjectMetaData ); |
146 |
|
147 ( ( CMTPTypeString & ) aNewData ).SetL( timeStr ); |
|
148 break; |
|
149 } |
|
150 // else |
|
151 // get from mpx |
|
152 case EMPXPlaylist: |
|
153 case EMPXSong: |
|
154 { |
|
155 iMmMtpDpMetadataMpxAccess->GetObjectMetadataValueL( aPropCode, |
|
156 aNewData, |
|
157 aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ), |
|
158 category ); |
|
159 } |
|
160 break; |
|
161 case EMPXVideo: |
|
162 if ( aPropCode == EMTPObjectPropCodeDateAdded && EMTPTypeString == aNewData.Type() ) |
|
163 { |
|
164 TBuf<KMtpMaxDateTimeStringLength> timeStr; |
|
165 MmMtpDpUtility::GetObjectDateModifiedL( iFs, |
|
166 aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ), |
|
167 timeStr ); |
|
168 PRINT1( _L( "MM MTP <> CGetObjectPropList::ServiceOneObjectPropertyL Date time %S" ), &timeStr ); |
|
169 |
|
170 ( ( CMTPTypeString & ) aNewData ).SetL( timeStr ); |
|
171 } |
|
172 else |
|
173 { |
|
174 iMmMtpDpMetadataVideoAccess->GetObjectMetadataValueL( aPropCode, |
|
175 aNewData, |
|
176 aObjectMetaData ); |
|
177 } |
|
178 break; |
|
179 default: |
|
180 // do nothing |
|
181 break; |
144 } |
182 } |
145 |
183 |
146 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL" ) ); |
184 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL" ) ); |
147 } |
185 } |
148 |
186 |
155 const MMTPType& aNewData, |
193 const MMTPType& aNewData, |
156 const CMTPObjectMetaData& aObjectMetaData ) |
194 const CMTPObjectMetaData& aObjectMetaData ) |
157 { |
195 { |
158 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL" ) ); |
196 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL" ) ); |
159 |
197 |
160 // In SendObjectPropList, formatCode has already know, but object handle has not been committed into db |
198 TMPXGeneralCategory category = Category( aObjectMetaData ); |
161 // In that case, format couldn't be get from object manager |
199 switch ( category ) |
162 TUint formatCode = aObjectMetaData.Uint( CMTPObjectMetaData::EFormatCode ); |
200 { |
163 TUint formatSubCode = aObjectMetaData.Uint( CMTPObjectMetaData::EFormatSubCode ); |
201 case EMPXAbstractAlbum: |
164 |
202 case EMPXSong: |
165 TBool isVideo = EFalse; |
203 case EMPXPlaylist: |
166 isVideo = MmMtpDpUtility::IsVideoL( formatCode, formatSubCode ); |
204 iMmMtpDpMetadataMpxAccess->SetObjectMetadataValueL( aPropCode, |
167 |
205 aNewData, |
168 if ( isVideo ) |
206 aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ), |
169 { |
207 category ); |
170 iMmMtpDpMetadataVideoAccess->SetObjectMetadataValueL( aPropCode, |
208 break; |
171 aNewData, |
209 case EMPXVideo: |
172 aObjectMetaData ); |
210 iMmMtpDpMetadataVideoAccess->SetObjectMetadataValueL( aPropCode, |
173 } |
211 aNewData, |
174 else |
212 aObjectMetaData ); |
175 { |
213 break; |
176 iMmMtpDpMetadataMpxAccess->SetObjectMetadataValueL( aPropCode, |
214 default: |
177 aNewData, |
215 break; |
178 aObjectMetaData ); |
|
179 } |
216 } |
180 |
217 |
181 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL" ) ); |
218 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL" ) ); |
182 } |
219 } |
183 |
220 |
184 // --------------------------------------------------------------------------- |
221 // --------------------------------------------------------------------------- |
185 // CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL |
222 // CMmMtpDpMetadataAccessWrapper::RenameObjectL |
186 // Renames the file part of a record in the collection database |
223 // Renames the file part of a record in the collection database |
187 // --------------------------------------------------------------------------- |
224 // --------------------------------------------------------------------------- |
188 // |
225 // |
189 EXPORT_C void CMmMtpDpMetadataAccessWrapper::RenameObjectL( const TDesC& aOldFileName, |
226 EXPORT_C void CMmMtpDpMetadataAccessWrapper::RenameObjectL( const CMTPObjectMetaData& aOldObject, |
190 const TDesC& aNewFileName ) |
227 const TDesC& aNewFileName ) |
191 { |
228 { |
|
229 TPtrC oldFileName( aOldObject.DesC( CMTPObjectMetaData::ESuid ) ); |
192 PRINT2( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::RenameObjectL old = %S, new = %S" ), |
230 PRINT2( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::RenameObjectL old = %S, new = %S" ), |
193 &aOldFileName, |
231 &oldFileName, |
194 &aNewFileName ); |
232 &aNewFileName ); |
195 |
233 |
196 if ( MmMtpDpUtility::IsVideoL( aOldFileName, iFramework ) ) |
234 TMPXGeneralCategory category = Category( aOldObject ); |
197 { |
235 switch ( category ) |
198 iMmMtpDpMetadataVideoAccess->RenameRecordL( aOldFileName, aNewFileName ); |
236 { |
199 } |
237 case EMPXSong: |
200 else |
238 case EMPXAbstractAlbum: |
201 { |
239 case EMPXPlaylist: |
202 CMTPObjectMetaData* object = CMTPObjectMetaData::NewLC(); |
240 { |
203 iFramework.ObjectMgr().ObjectL( aOldFileName, *object ); |
241 iMmMtpDpMetadataMpxAccess->RenameObjectL( oldFileName, |
204 iMmMtpDpMetadataMpxAccess->RenameObjectL( aOldFileName, |
242 aNewFileName, |
205 aNewFileName, |
243 category ); |
206 object->Uint( CMTPObjectMetaData::EFormatCode ) ); |
244 } |
207 CleanupStack::PopAndDestroy( object ); |
245 break; |
208 } |
246 case EMPXVideo: |
|
247 iMmMtpDpMetadataVideoAccess->RenameRecordL( oldFileName, aNewFileName ); |
|
248 break; |
|
249 default: |
|
250 break; |
|
251 } |
|
252 |
209 |
253 |
210 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RenameObjectL" ) ); |
254 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RenameObjectL" ) ); |
211 } |
255 } |
212 |
256 |
213 // --------------------------------------------------------------------------- |
257 // --------------------------------------------------------------------------- |
214 // CMmMtpDpMetadataAccessWrapper::SetObjectMetadataValueL |
258 // CMmMtpDpMetadataAccessWrapper::DeleteObjectL |
215 // Deletes metadata information associated with the object |
259 // Deletes metadata information associated with the object |
216 // --------------------------------------------------------------------------- |
260 // --------------------------------------------------------------------------- |
217 // |
261 // |
218 void CMmMtpDpMetadataAccessWrapper::DeleteObjectL( const TDesC& aFullFileName, |
262 void CMmMtpDpMetadataAccessWrapper::DeleteObjectL( const CMTPObjectMetaData& aObject ) |
219 const TUint aFormatCode ) |
263 { |
220 { |
264 TPtrC fileName( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
221 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::DeleteObjectL" ) ); |
265 PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::DeleteObjectL name = %S" ), &fileName ); |
222 |
266 |
223 TMPXGeneralCategory category = Category( aFormatCode ); |
267 TMPXGeneralCategory category = Category( aObject ); |
224 |
|
225 // Have to do this. File might not be in file system anymore, have to |
|
226 // reply on ObjectManager |
|
227 if ( ( aFormatCode == EMTPFormatCodeMP4Container ) |
|
228 || ( aFormatCode == EMTPFormatCode3GPContainer ) |
|
229 || ( aFormatCode == EMTPFormatCodeASF ) ) |
|
230 { |
|
231 if ( MmMtpDpUtility::IsVideoL( aFullFileName, iFramework ) ) |
|
232 { |
|
233 category = EMPXVideo; |
|
234 } |
|
235 else |
|
236 { |
|
237 category = EMPXSong; |
|
238 } |
|
239 } |
|
240 |
268 |
241 switch ( category ) |
269 switch ( category ) |
242 { |
270 { |
|
271 case EMPXSong: |
|
272 case EMPXAbstractAlbum: |
243 case EMPXPlaylist: |
273 case EMPXPlaylist: |
244 case EMPXSong: |
274 { |
245 { |
275 iMmMtpDpMetadataMpxAccess->DeleteObjectL( fileName, category ); |
246 iMmMtpDpMetadataMpxAccess->DeleteObjectL( aFullFileName, category ); |
|
247 } |
276 } |
248 break; |
277 break; |
249 |
278 |
250 case EMPXVideo: |
279 case EMPXVideo: |
251 { |
280 { |
252 iMmMtpDpMetadataVideoAccess->DeleteRecordL( aFullFileName ); |
281 iMmMtpDpMetadataVideoAccess->DeleteRecordL( fileName ); |
253 } |
282 } |
254 break; |
283 break; |
255 |
284 |
256 default: |
285 default: |
257 PRINT( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::DeleteObjectL default" ) ); |
286 PRINT( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::DeleteObjectL default" ) ); |
273 iMmMtpDpMetadataVideoAccess->SetStorageRootL( aStorageRoot ); |
302 iMmMtpDpMetadataVideoAccess->SetStorageRootL( aStorageRoot ); |
274 iMmMtpDpMetadataMpxAccess->SetStorageRootL( aStorageRoot ); |
303 iMmMtpDpMetadataMpxAccess->SetStorageRootL( aStorageRoot ); |
275 |
304 |
276 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetStorageRootL" ) ); |
305 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::SetStorageRootL" ) ); |
277 } |
306 } |
|
307 |
278 // ----------------------------------------------------------------------------- |
308 // ----------------------------------------------------------------------------- |
279 // CMmMtpDpMetadataMpxAccess::SetImageObjPropL |
309 // CMmMtpDpMetadataMpxAccess::SetImageObjPropL |
280 // set image specific properties specific to videos |
310 // set image specific properties specific to videos |
281 // ----------------------------------------------------------------------------- |
311 // ----------------------------------------------------------------------------- |
282 // |
312 // |
283 void CMmMtpDpMetadataAccessWrapper::SetImageObjPropL( const TDesC& aFullFileName, |
313 void CMmMtpDpMetadataAccessWrapper::SetImageObjPropL( const CMTPObjectMetaData& aObject, |
284 const TUint32 aWidth, |
314 const TUint32 aWidth, |
285 const TUint32 aHeight ) |
315 const TUint32 aHeight ) |
286 { |
316 { |
287 iMmMtpDpMetadataVideoAccess->SetStorageRootL( aFullFileName ); |
317 TMPXGeneralCategory category = Category( aObject ); |
288 iMmMtpDpMetadataVideoAccess->SetImageObjPropL( aFullFileName, |
318 if ( category == EMPXVideo ) |
289 aWidth, |
319 { |
290 aHeight ); |
320 TPtrC fullFileName( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
|
321 iMmMtpDpMetadataVideoAccess->SetStorageRootL( fullFileName ); |
|
322 iMmMtpDpMetadataVideoAccess->SetImageObjPropL( fullFileName, |
|
323 aWidth, |
|
324 aHeight ); |
|
325 } |
291 } |
326 } |
292 |
327 |
293 // ----------------------------------------------------------------------------- |
328 // ----------------------------------------------------------------------------- |
294 // CMmMtpDpMetadataMpxAccess::GetImageObjPropL |
329 // CMmMtpDpMetadataMpxAccess::GetImageObjPropL |
295 // get image specific properties specific to videos |
330 // get image specific properties specific to videos |
296 // ----------------------------------------------------------------------------- |
331 // ----------------------------------------------------------------------------- |
297 // |
332 // |
298 void CMmMtpDpMetadataAccessWrapper::GetImageObjPropL( const TDesC& aFullFileName, |
333 void CMmMtpDpMetadataAccessWrapper::GetImageObjPropL( const CMTPObjectMetaData& aObject, |
299 TUint32& aWidth, |
334 TUint32& aWidth, |
300 TUint32& aHeight ) |
335 TUint32& aHeight ) |
301 { |
336 { |
302 if ( MmMtpDpUtility::IsVideoL( aFullFileName, iFramework ) ) |
337 TMPXGeneralCategory category = Category( aObject ); |
303 { |
338 if ( category == EMPXVideo ) |
304 iMmMtpDpMetadataVideoAccess->SetStorageRootL( aFullFileName ); |
339 { |
305 iMmMtpDpMetadataVideoAccess->GetImageObjPropL( aFullFileName, aWidth, aHeight ); |
340 TPtrC fullFileName( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
306 } |
341 iMmMtpDpMetadataVideoAccess->SetStorageRootL( fullFileName ); |
307 } |
342 iMmMtpDpMetadataVideoAccess->GetImageObjPropL( fullFileName, aWidth, aHeight ); |
|
343 } |
|
344 } |
|
345 |
308 // ----------------------------------------------------------------------------- |
346 // ----------------------------------------------------------------------------- |
309 // CMmMtpDpMetadataAccessWrapper::OpenSessionL |
347 // CMmMtpDpMetadataAccessWrapper::OpenSessionL |
310 // Called when the MTP session is initialised |
348 // Called when the MTP session is initialised |
311 // ----------------------------------------------------------------------------- |
349 // ----------------------------------------------------------------------------- |
312 // |
350 // |
337 // --------------------------------------------------------------------------- |
375 // --------------------------------------------------------------------------- |
338 // CMmMtpDpMetadataAccessWrapper::Category |
376 // CMmMtpDpMetadataAccessWrapper::Category |
339 // Get category according format code |
377 // Get category according format code |
340 // --------------------------------------------------------------------------- |
378 // --------------------------------------------------------------------------- |
341 // |
379 // |
342 TMPXGeneralCategory CMmMtpDpMetadataAccessWrapper::Category( const TUint aFormatCode ) |
380 TMPXGeneralCategory CMmMtpDpMetadataAccessWrapper::Category( const CMTPObjectMetaData& aObject ) |
343 { |
381 { |
344 TMPXGeneralCategory category = EMPXNoCategory; |
382 TMPXGeneralCategory category = EMPXNoCategory; |
345 switch ( aFormatCode ) |
383 TUint formatCode = aObject.Uint( CMTPObjectMetaData::EFormatCode ); |
346 { |
384 switch ( formatCode ) |
|
385 { |
|
386 case EMTPFormatCodeASF: |
|
387 case EMTPFormatCodeMP4Container: |
|
388 case EMTPFormatCode3GPContainer: |
|
389 { |
|
390 TUint aSubFormatCode = aObject.Uint( CMTPObjectMetaData::EFormatSubCode ); |
|
391 if ( aSubFormatCode == EMTPSubFormatCodeUnknown ) |
|
392 { |
|
393 category = ContainerCategory( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
|
394 if ( category == EMPXSong ) |
|
395 aSubFormatCode = EMTPSubFormatCodeAudio; |
|
396 else if ( category == EMPXVideo ) |
|
397 aSubFormatCode = EMTPSubFormatCodeVideo; |
|
398 else |
|
399 aSubFormatCode = EMTPSubFormatCodeUndefine; |
|
400 const_cast<CMTPObjectMetaData&>(aObject).SetUint( CMTPObjectMetaData::EFormatSubCode, aSubFormatCode ); |
|
401 // If object doesn't exist, do nothing |
|
402 TRAP_IGNORE( iFramework.ObjectMgr().ModifyObjectL( aObject ) ); |
|
403 } |
|
404 else if ( aSubFormatCode == EMTPSubFormatCodeAudio ) |
|
405 category = EMPXSong; |
|
406 else if ( aSubFormatCode == EMTPSubFormatCodeVideo ) |
|
407 category = EMPXVideo; |
|
408 else if( aSubFormatCode == EMTPSubFormatCodeUndefine ) |
|
409 category = EMPXOther; |
|
410 } |
|
411 break; |
|
412 |
347 case EMTPFormatCodeMP3: |
413 case EMTPFormatCodeMP3: |
348 case EMTPFormatCodeWAV: |
414 case EMTPFormatCodeWAV: |
349 case EMTPFormatCodeWMA: |
415 case EMTPFormatCodeWMA: |
350 case EMTPFormatCodeAAC: |
416 case EMTPFormatCodeAAC: |
351 case EMTPFormatCodeASF: |
|
352 case EMTPFormatCodeMP4Container: |
|
353 case EMTPFormatCode3GPContainer: |
|
354 { |
417 { |
355 category = EMPXSong; |
418 category = EMPXSong; |
356 } |
419 } |
357 break; |
420 break; |
358 |
421 |
|
422 case EMTPFormatCodeM3UPlaylist: |
359 case EMTPFormatCodeAbstractAudioVideoPlaylist: |
423 case EMTPFormatCodeAbstractAudioVideoPlaylist: |
360 { |
424 { |
361 category = EMPXPlaylist; |
425 category = EMPXPlaylist; |
362 } |
426 } |
363 break; |
427 break; |
364 |
428 |
|
429 case EMTPFormatCodeAbstractAudioAlbum: |
|
430 { |
|
431 category = EMPXAbstractAlbum; |
|
432 } |
|
433 break; |
|
434 |
365 case EMTPFormatCodeWMV: |
435 case EMTPFormatCodeWMV: |
366 { |
436 { |
367 category = EMPXVideo; |
437 category = EMPXVideo; |
368 } |
438 } |
369 break; |
439 break; |
370 |
440 |
371 default: |
441 default: |
372 break; |
442 break; |
373 } |
443 } |
|
444 PRINT1( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::Category category = %d" ), category ); |
|
445 return category; |
|
446 } |
|
447 |
|
448 TMPXGeneralCategory CMmMtpDpMetadataAccessWrapper::ContainerCategory( const TDesC& aFullFileName ) |
|
449 { |
|
450 PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::ContainerCategory aFullFileName = %S" ), &aFullFileName ); |
|
451 |
|
452 TMPXGeneralCategory category = EMPXNoCategory; |
|
453 TParsePtrC pathParser( aFullFileName ); |
|
454 TPtrC ext( pathParser.Ext() ); |
|
455 |
|
456 if ( ext.Length() <= 0 ) |
|
457 category = EMPXOther; |
|
458 |
|
459 if ( ext.CompareF( KTxtExtensionMP4 ) == 0 |
|
460 || ext.CompareF( KTxtExtension3GP ) == 0 |
|
461 || ext.CompareF( KTxtExtension3G2 ) == 0 |
|
462 || ext.CompareF( KTxtExtensionODF ) == 0 |
|
463 || ext.CompareF( KTxtExtensionASF ) == 0 ) |
|
464 { |
|
465 HBufC8* mimetype = MmMtpDpUtility::ContainerMimeType( aFullFileName ); |
|
466 if ( mimetype != NULL ) |
|
467 { |
|
468 TMmMtpSubFormatCode subFormatCode = MmMtpDpUtility::SubFormatCodeFromMime( *mimetype ); |
|
469 |
|
470 if ( subFormatCode == EMTPSubFormatCodeVideo ) |
|
471 category = EMPXVideo; |
|
472 else if( subFormatCode == EMTPSubFormatCodeAudio ) |
|
473 category = EMPXSong; |
|
474 else |
|
475 category = EMPXOther; |
|
476 } |
|
477 } |
|
478 else if ( ext.CompareF( KTxtExtensionO4V ) == 0 ) |
|
479 category = EMPXVideo; |
|
480 else |
|
481 category = EMPXOther; |
|
482 |
|
483 PRINT1( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::ContainerCategory, category = %d" ), category ); |
374 return category; |
484 return category; |
375 } |
485 } |
376 |
486 |
377 // --------------------------------------------------------------------------- |
487 // --------------------------------------------------------------------------- |
378 // CMmMtpDpMetadataAccessWrapper::GetAllAbstractMediaL |
488 // CMmMtpDpMetadataAccessWrapper::GetAllAbstractMediaL |
406 // ----------------------------------------------------------------------------- |
516 // ----------------------------------------------------------------------------- |
407 // CMmMtpDpMetadataAccessWrapper::AddObjectL |
517 // CMmMtpDpMetadataAccessWrapper::AddObjectL |
408 // Add object (music, video, playlist and abstract media) info to DB |
518 // Add object (music, video, playlist and abstract media) info to DB |
409 // ----------------------------------------------------------------------------- |
519 // ----------------------------------------------------------------------------- |
410 // |
520 // |
411 void CMmMtpDpMetadataAccessWrapper::AddObjectL( const TDesC& aFullFileName, TUint aFormatCode, TUint aSubFormatCode ) |
521 void CMmMtpDpMetadataAccessWrapper::AddObjectL( const CMTPObjectMetaData& aObject ) |
412 { |
522 { |
413 PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL aFullFileName = %S" ), &aFullFileName ); |
523 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL" ) ); |
414 |
524 TMPXGeneralCategory category = Category( aObject ); |
415 if ( aFullFileName.Length() <= 0 ) |
525 |
416 { |
526 TPtrC fullFileName( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
417 User::Leave( KErrArgument ); |
527 if ( category == EMPXVideo ) |
418 } |
|
419 if ( MmMtpDpUtility::IsVideoL( aFormatCode, aSubFormatCode ) ) |
|
420 { |
528 { |
421 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL Addvideo" ) ); |
529 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL Addvideo" ) ); |
422 iMmMtpDpMetadataVideoAccess->AddVideoL( aFullFileName ); |
530 iMmMtpDpMetadataVideoAccess->AddVideoL( fullFileName ); |
423 } |
531 } |
424 else |
532 else if ( category == EMPXPlaylist || category == EMPXAbstractAlbum ) |
425 { |
533 { |
426 if ( aFormatCode == EMTPFormatCodeM3UPlaylist |
534 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL AddPlaylist" ) ); |
427 || aFormatCode == EMTPFormatCodeMPLPlaylist |
535 iMmMtpDpMetadataMpxAccess->AddAbstractMediaL( fullFileName, |
428 || aFormatCode == EMTPFormatCodeAbstractAudioVideoPlaylist |
536 category ); |
429 || aFormatCode == EMTPFormatCodeAbstractAudioPlaylist |
537 } |
430 || aFormatCode == EMTPFormatCodeAbstractVideoPlaylist |
538 else if ( category == EMPXSong ) |
431 || aFormatCode == EMTPFormatCodeASXPlaylist |
539 { |
432 || aFormatCode == EMTPFormatCodePLSPlaylist ) |
540 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL AddSong" ) ); |
433 { |
541 iMmMtpDpMetadataMpxAccess->AddSongL( fullFileName ); |
434 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL AddPlaylist" ) ); |
|
435 iMmMtpDpMetadataMpxAccess->AddAbstractMediaL( aFullFileName, |
|
436 EMPXPlaylist ); |
|
437 } |
|
438 else |
|
439 { |
|
440 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL AddSong" ) ); |
|
441 iMmMtpDpMetadataMpxAccess->AddSongL( aFullFileName ); |
|
442 } |
|
443 } |
542 } |
444 |
543 |
445 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::AddObjectL" ) ); |
544 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::AddObjectL" ) ); |
446 } |
545 } |
447 |
546 |
516 |
615 |
517 if ( MmMtpDpUtility::FormatFromFilename( aPlaylistName ) == |
616 if ( MmMtpDpUtility::FormatFromFilename( aPlaylistName ) == |
518 EMTPFormatCodeAbstractAudioVideoPlaylist ) |
617 EMTPFormatCodeAbstractAudioVideoPlaylist ) |
519 { |
618 { |
520 RFile newfile; |
619 RFile newfile; |
521 TInt err = newfile.Replace( iFramework.Fs(), aPlaylistName, EFileWrite ); |
620 TInt err = newfile.Replace( iFs, aPlaylistName, EFileWrite ); |
522 |
621 |
523 if ( err != KErrNone ) |
622 if ( err != KErrNone ) |
524 { |
623 { |
525 newfile.Close(); |
624 newfile.Close(); |
526 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile err = %d" ), err ); |
625 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile err = %d" ), err ); |
527 } |
626 } |
528 else // File created OK |
627 else // File created OK |
529 { |
628 { |
530 err = newfile.Flush(); |
629 err = newfile.Flush(); |
531 newfile.Close(); |
630 newfile.Close(); |
532 err = iFramework.Fs().SetAtt( aPlaylistName, KEntryAttSystem | KEntryAttHidden, |
631 err = iFs.SetAtt( aPlaylistName, KEntryAttSystem | KEntryAttHidden, |
533 KEntryAttReadOnly | KEntryAttNormal ); |
632 KEntryAttReadOnly | KEntryAttNormal ); |
534 if ( err != KErrNone ) |
633 if ( err != KErrNone ) |
535 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile Dummy Playlist file created. err = %d" ), err ); |
634 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::CreateDummyFile Dummy Playlist file created. err = %d" ), err ); |
536 } |
635 } |
537 } |
636 } |
538 } |
637 } |
539 |
638 |
540 // ----------------------------------------------------------------------------- |
639 // ----------------------------------------------------------------------------- |
541 // CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles |
640 // CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles |
542 // Remove all dummy file of which format is "pla", and leave the "m3u" |
641 // Remove all dummy file of which format is "pla" and "alb", and leave the "m3u" |
543 // ----------------------------------------------------------------------------- |
642 // ----------------------------------------------------------------------------- |
544 // |
643 // |
545 void CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles() |
644 void CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles() |
546 { |
645 { |
547 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) ); |
646 PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) ); |
548 |
647 |
549 TInt count = iAbstractMediaArray->Count(); |
648 TInt count = iAbstractMediaArray->Count(); |
|
649 PRINT1( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles, count = %d" ), count ); |
550 // Check if playlist file is a dummy file or an imported file |
650 // Check if playlist file is a dummy file or an imported file |
551 for ( TInt i = 0; i < count; i++ ) |
651 for ( TInt i = 0; i < count; i++ ) |
552 { |
652 { |
553 TPtrC dummyFileName( (*iAbstractMediaArray)[i] ); |
653 TPtrC fileName( (*iAbstractMediaArray)[i] ); |
554 if ( MmMtpDpUtility::FormatFromFilename( dummyFileName ) != |
654 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles, fileName = %S" ), &fileName ); |
555 EMTPFormatCodeM3UPlaylist ) |
655 |
556 { |
656 TMTPFormatCode format = MmMtpDpUtility::FormatFromFilename( fileName ); |
557 // delete the virtual playlist |
657 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles, format = 0x%x" ), format ); |
558 // iFramework has release don't use iFramework.FS() |
658 if ( format == EMTPFormatCodeAbstractAudioAlbum ) |
559 TInt err = iRfs.Delete( ( *iAbstractMediaArray )[i] ); |
659 { |
|
660 // delete the abstract album if its size is zero |
|
661 TEntry entry; |
|
662 TInt err = iFs.Entry( fileName, entry ); |
|
663 if ( err == KErrNone && entry.iSize == 0 ) |
|
664 { |
|
665 TRAP( err, iMmMtpDpMetadataMpxAccess->DeleteObjectL( fileName, EMPXAbstractAlbum ) ); |
|
666 if( err == KErrNone ) |
|
667 { |
|
668 err = iFs.Delete( fileName ); |
|
669 } |
|
670 } |
|
671 PRINT3( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d, entry.iSize = %d" ), |
|
672 &fileName, err, entry.iSize ); |
|
673 } |
|
674 else if ( format != EMTPFormatCodeM3UPlaylist ) |
|
675 { |
|
676 TInt err = iFs.Delete( fileName ); |
560 |
677 |
561 PRINT2( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d" ), |
678 PRINT2( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile filename = %S, err %d" ), |
562 &dummyFileName, |
679 &fileName, |
563 err ); |
680 err ); |
564 } |
681 } |
565 else |
682 else |
566 { |
683 { |
567 // leave the Imported playlist in the file system |
684 // leave the Imported playlist in the file system |
568 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile, Don't delete m3u file [%S]" ), &dummyFileName ); |
685 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::RemoveDummyFile, Don't delete m3u file [%S]" ), &fileName ); |
569 } |
686 } |
570 } |
687 } |
571 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) ); |
688 PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::RemoveDummyFiles" ) ); |
572 } |
689 } |
573 |
690 |