30 #include "mmmtpdplogger.h" |
29 #include "mmmtpdplogger.h" |
31 #include "tmmmtpdppanic.h" |
30 #include "tmmmtpdppanic.h" |
32 #include "mmmtpdputility.h" |
31 #include "mmmtpdputility.h" |
33 #include "cmmmtpdpmetadataaccesswrapper.h" |
32 #include "cmmmtpdpmetadataaccesswrapper.h" |
34 #include "mmmtpdpconfig.h" |
33 #include "mmmtpdpconfig.h" |
|
34 #include "cpropertysettingutility.h" |
35 |
35 |
36 /** |
36 /** |
37 * Verification data for the MoveObject request |
37 * Verification data for the MoveObject request |
38 */ |
38 */ |
39 const TMTPRequestElementInfo KMTPMoveObjectPolicy[] = |
39 const TMTPRequestElementInfo KMTPMoveObjectPolicy[] = |
40 { |
40 { |
41 { |
41 { |
42 TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, |
42 TMTPTypeRequest::ERequestParameter1, |
43 EMTPElementAttrFileOrDir | EMTPElementAttrWrite, 0, 0, 0 |
43 EMTPElementTypeObjectHandle, |
|
44 EMTPElementAttrFile | EMTPElementAttrWrite, |
|
45 0, |
|
46 0, |
|
47 0 |
44 }, |
48 }, |
45 { |
49 { |
46 TMTPTypeRequest::ERequestParameter2, EMTPElementTypeStorageId, |
50 TMTPTypeRequest::ERequestParameter2, |
47 EMTPElementAttrWrite, 0, 0, 0 |
51 EMTPElementTypeStorageId, |
|
52 EMTPElementAttrWrite, |
|
53 0, |
|
54 0, |
|
55 0 |
48 }, |
56 }, |
49 { |
57 { |
50 TMTPTypeRequest::ERequestParameter3, EMTPElementTypeObjectHandle, |
58 TMTPTypeRequest::ERequestParameter3, |
51 EMTPElementAttrDir | EMTPElementAttrWrite, 1, 0, 0 |
59 EMTPElementTypeObjectHandle, |
|
60 EMTPElementAttrDir | EMTPElementAttrWrite, |
|
61 1, |
|
62 0, |
|
63 0 |
52 } |
64 } |
53 }; |
65 }; |
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CMoveObject::NewL |
|
57 // Two-phase construction method |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 //EXPORT_C MMmRequestProcessor* CMoveObject::NewL( MMTPDataProviderFramework& aFramework, |
|
61 // MMTPConnection& aConnection, |
|
62 // CMmMtpDpMetadataAccessWrapper& aWrapper ) |
|
63 // { |
|
64 // CMoveObject* self = new (ELeave) CMoveObject( aFramework, aConnection, aWrapper ); |
|
65 // CleanupStack::PushL( self ); |
|
66 // self->ConstructL(); |
|
67 // CleanupStack::Pop( self ); |
|
68 // |
|
69 // return self; |
|
70 // } |
|
71 |
66 |
72 // ----------------------------------------------------------------------------- |
67 // ----------------------------------------------------------------------------- |
73 // CMoveObject::~CMoveObject |
68 // CMoveObject::~CMoveObject |
74 // Destructor |
69 // Destructor |
75 // ----------------------------------------------------------------------------- |
70 // ----------------------------------------------------------------------------- |
77 EXPORT_C CMoveObject::~CMoveObject() |
72 EXPORT_C CMoveObject::~CMoveObject() |
78 { |
73 { |
79 Cancel(); |
74 Cancel(); |
80 |
75 |
81 delete iDest; |
76 delete iDest; |
82 delete iFileMan; |
77 |
83 delete iPathToMove; |
|
84 delete iNewRootFolder; |
|
85 iObjectHandles.Close(); |
|
86 if ( iPropertyElement ) |
78 if ( iPropertyElement ) |
87 delete iPropertyElement; |
79 delete iPropertyElement; |
|
80 |
88 delete iPropertyList; |
81 delete iPropertyList; |
89 } |
82 } |
90 |
83 |
91 // ----------------------------------------------------------------------------- |
84 // ----------------------------------------------------------------------------- |
92 // CMoveObject::CMoveObject |
85 // CMoveObject::CMoveObject |
93 // Standard c++ constructor |
86 // Standard c++ constructor |
94 // ----------------------------------------------------------------------------- |
87 // ----------------------------------------------------------------------------- |
95 // |
88 // |
96 EXPORT_C CMoveObject::CMoveObject( MMTPDataProviderFramework& aFramework, |
89 EXPORT_C CMoveObject::CMoveObject( MMTPDataProviderFramework& aFramework, |
97 MMTPConnection& aConnection, |
90 MMTPConnection& aConnection, |
98 MMmMtpDpConfig& aDpConfig) : |
91 MMmMtpDpConfig& aDpConfig ) : |
99 CRequestProcessor( aFramework, aConnection, sizeof( KMTPMoveObjectPolicy ) |
92 CRequestProcessor( aFramework, |
100 /sizeof( TMTPRequestElementInfo ), KMTPMoveObjectPolicy), |
93 aConnection, |
101 iDpConfig( aDpConfig ), |
94 sizeof( KMTPMoveObjectPolicy ) / sizeof( TMTPRequestElementInfo ), |
102 iObjectHandles( KMmMtpRArrayGranularity ), |
95 KMTPMoveObjectPolicy ), |
103 iMoveObjectIndex( 0 ) |
96 iDpConfig( aDpConfig ) |
104 { |
97 { |
105 PRINT( _L( "Operation: MoveObject(0x1019)" ) ); |
98 PRINT( _L( "Operation: MoveObject(0x1019)" ) ); |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CMoveObject::ConstructL |
|
103 // Second phase constructor |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 EXPORT_C void CMoveObject::ConstructL() |
|
107 { |
|
108 iPropertyList = CMTPTypeObjectPropList::NewL(); |
|
109 |
|
110 // Set the CenRep value of MTP status, |
|
111 // also need to do in other processors which related to MPX |
|
112 SetPSStatus(); |
106 } |
113 } |
107 |
114 |
108 // ----------------------------------------------------------------------------- |
115 // ----------------------------------------------------------------------------- |
109 // CMoveObject::ServiceL |
116 // CMoveObject::ServiceL |
110 // MoveObject request handler |
117 // MoveObject request handler |
111 // ----------------------------------------------------------------------------- |
118 // ----------------------------------------------------------------------------- |
112 // |
119 // |
113 EXPORT_C void CMoveObject::ServiceL() |
120 EXPORT_C void CMoveObject::ServiceL() |
114 { |
121 { |
115 PRINT( _L( "MM MTP => CMoveObject::ServiceL" ) ); |
122 PRINT( _L( "MM MTP => CMoveObject::ServiceL" ) ); |
116 TMTPResponseCode ret = MoveObjectL(); |
123 |
117 PRINT1( _L( "MM MTP <> CMoveObject::ServiceL ret = 0x%x" ), ret ); |
124 MoveObjectL(); |
118 if ( EMTPRespCodeOK != ret ) |
125 |
119 { |
|
120 SendResponseL( ret ); |
|
121 } |
|
122 PRINT( _L( "MM MTP <= CMoveObject::ServiceL" ) ); |
126 PRINT( _L( "MM MTP <= CMoveObject::ServiceL" ) ); |
123 } |
127 } |
124 |
128 |
125 // ----------------------------------------------------------------------------- |
129 // ----------------------------------------------------------------------------- |
126 // CMoveObject::ConstructL |
|
127 // Second phase constructor |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 EXPORT_C void CMoveObject::ConstructL() |
|
131 { |
|
132 CActiveScheduler::Add( this ); |
|
133 |
|
134 iPropertyList = CMTPTypeObjectPropList::NewL(); |
|
135 SetPSStatus(); |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CMoveObject::RunL |
|
140 // |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 EXPORT_C void CMoveObject::RunL() |
|
144 { |
|
145 PRINT( _L( "MM MTP => CMoveObject::RunL" ) ); |
|
146 if ( MoveOwnedObjectsL() ) |
|
147 { |
|
148 // Reset iMoveObjectIndex count since move completed |
|
149 iMoveObjectIndex = 0; |
|
150 |
|
151 TMTPResponseCode ret = EMTPRespCodeOK; |
|
152 // Delete the original folders in the device dp. |
|
153 if ( iObjectInfo->Uint( CMTPObjectMetaData::EDataProviderId ) |
|
154 == iFramework.DataProviderId() ) |
|
155 { |
|
156 ret = FinalPhaseMove(); |
|
157 } |
|
158 PRINT1( _L("MM MTP <> CMoveObject::RunL ret = 0x%x"), ret ); |
|
159 SendResponseL( ret ); |
|
160 } |
|
161 PRINT( _L( "MM MTP <= CMoveObject::RunL" ) ); |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CMoveObject::RunError |
|
166 // |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 EXPORT_C TInt CMoveObject::RunError( TInt aError ) |
|
170 { |
|
171 if ( aError != KErrNone ) |
|
172 PRINT1( _L( "MM MTP <> CMoveObject::RunError aError = %d" ), aError ); |
|
173 TRAP_IGNORE( SendResponseL( EMTPRespCodeGeneralError ) ); |
|
174 return KErrNone; |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CMoveObject::MoveFileL |
|
179 // A helper function of MoveObjectL |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 void CMoveObject::MoveFileL( const TDesC& aNewFileName ) |
|
183 { |
|
184 PRINT1( _L( "MM MTP => CMoveObject::MoveFileL aNewFileName = %S" ), &aNewFileName ); |
|
185 const TDesC& suid( iObjectInfo->DesC( CMTPObjectMetaData::ESuid ) ); |
|
186 TFileName oldFileName( suid ); // save the old file name, the suid will be modified |
|
187 PRINT1( _L( "MM MTP <> CMoveObject::MoveFileL oldFileName = %S" ), &suid ); |
|
188 |
|
189 if ( iStorageId == iObjectInfo->Uint( CMTPObjectMetaData::EStorageId ) ) |
|
190 iSameStorage = ETrue; |
|
191 else |
|
192 iSameStorage = EFalse; |
|
193 GetPreviousPropertiesL( *iObjectInfo ); |
|
194 User::LeaveIfError( iFileMan->Move( suid, aNewFileName ) ); // iDest just Folder |
|
195 User::LeaveIfError( iFramework.Fs().SetModified( aNewFileName, iPreviousModifiedTime ) ); |
|
196 |
|
197 iObjectInfo->SetDesCL( CMTPObjectMetaData::ESuid, aNewFileName ); |
|
198 iObjectInfo->SetUint( CMTPObjectMetaData::EStorageId, iStorageId ); |
|
199 iObjectInfo->SetUint( CMTPObjectMetaData::EParentHandle, iNewParentHandle ); |
|
200 iFramework.ObjectMgr().ModifyObjectL( *iObjectInfo ); |
|
201 SetPropertiesL( oldFileName, aNewFileName, *iObjectInfo ); |
|
202 PRINT( _L( "MM MTP <= CMoveObject::MoveFileL" ) ); |
|
203 } |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // CMoveObject::MoveOwnedObjectsL |
|
207 // Move the objects through iterations of RunL |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 TBool CMoveObject::MoveOwnedObjectsL() |
|
211 { |
|
212 PRINT( _L( "MM MTP => CMoveObject::MoveOwnedObjectsL" ) ); |
|
213 TBool ret = EFalse; |
|
214 |
|
215 if ( iMoveObjectIndex < iNumberOfObjects ) |
|
216 { |
|
217 MoveAndUpdateL( iObjectHandles[iMoveObjectIndex++] ); |
|
218 |
|
219 TRequestStatus* status = &iStatus; |
|
220 User::RequestComplete( status, iStatus.Int() ); |
|
221 SetActive(); |
|
222 } |
|
223 else |
|
224 { |
|
225 ret = ETrue; |
|
226 } |
|
227 |
|
228 PRINT1( _L( "MM MTP <= CMoveObject::MoveOwnedObjectsL ret = %d" ), ret ); |
|
229 return ret; |
|
230 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // CMoveObject::MoveFolderL |
|
234 // A helper function of MoveObjectL |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 void CMoveObject::MoveFolderL() |
|
238 { |
|
239 PRINT( _L( "MM MTP => CMoveObject::MoveFolderL" ) ); |
|
240 RBuf oldFolderName; |
|
241 oldFolderName.CreateL( KMaxFileName ); |
|
242 oldFolderName.CleanupClosePushL(); // + oldFileName |
|
243 oldFolderName = iObjectInfo->DesC( CMTPObjectMetaData::ESuid ); |
|
244 PRINT1( _L( "MM MTP <> CMoveObject::MoveFolderL oldFolderName = %S" ), &oldFolderName ); |
|
245 iPathToMove = oldFolderName.AllocL(); |
|
246 CleanupStack::PopAndDestroy( &oldFolderName ); // - oldFolderName |
|
247 |
|
248 GenerateObjectHandleListL( iObjectInfo->Uint( CMTPObjectMetaData::EHandle ) ); |
|
249 |
|
250 iNumberOfObjects = iObjectHandles.Count(); |
|
251 PRINT1( _L( "MM MTP <> CMoveObject::MoveFolderL iNumberOfObjects = %d" ), iNumberOfObjects ); |
|
252 |
|
253 TRequestStatus* status = &iStatus; |
|
254 User::RequestComplete( status, iStatus.Int() ); |
|
255 SetActive(); |
|
256 |
|
257 PRINT( _L( "MM MTP <= CMoveObject::MoveFolderL" ) ); |
|
258 } |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // CMoveObject::MoveObjectL |
130 // CMoveObject::MoveObjectL |
262 // move object operations |
131 // Move object operation |
263 // ----------------------------------------------------------------------------- |
132 // ----------------------------------------------------------------------------- |
264 // |
133 // |
265 TMTPResponseCode CMoveObject::MoveObjectL() |
134 void CMoveObject::MoveObjectL() |
266 { |
135 { |
267 PRINT( _L( "MM MTP => CMoveObject::MoveObjectL" ) ); |
136 PRINT( _L( "MM MTP => CMoveObject::MoveObjectL" ) ); |
268 TMTPResponseCode responseCode = EMTPRespCodeOK; |
137 TMTPResponseCode responseCode = EMTPRespCodeOK; |
269 |
138 |
270 GetParametersL(); |
139 GetParametersL(); |
274 newObjectName.CleanupClosePushL(); // + newObjectName |
143 newObjectName.CleanupClosePushL(); // + newObjectName |
275 newObjectName = *iDest; |
144 newObjectName = *iDest; |
276 |
145 |
277 const TDesC& suid( iObjectInfo->DesC( CMTPObjectMetaData::ESuid ) ); |
146 const TDesC& suid( iObjectInfo->DesC( CMTPObjectMetaData::ESuid ) ); |
278 TParsePtrC fileNameParser( suid ); |
147 TParsePtrC fileNameParser( suid ); |
279 |
148 if ( ( newObjectName.Length() + fileNameParser.NameAndExt().Length() ) |
280 // Check if the object is a folder or a file. |
149 <= newObjectName.MaxLength() ) |
281 TBool isFolder = EFalse; |
150 { |
282 User::LeaveIfError( BaflUtils::IsFolder( iFramework.Fs(), suid, isFolder ) ); |
151 newObjectName.Append( fileNameParser.NameAndExt() ); |
283 |
152 } |
284 if ( !isFolder ) |
153 responseCode = CanMoveObjectL( suid, newObjectName ); |
285 { |
|
286 if ( ( newObjectName.Length() + fileNameParser.NameAndExt().Length() ) <= newObjectName.MaxLength() ) |
|
287 { |
|
288 newObjectName.Append( fileNameParser.NameAndExt() ); |
|
289 } |
|
290 responseCode = CanMoveObjectL( suid, newObjectName ); |
|
291 } |
|
292 else // It is a folder. |
|
293 { |
|
294 TFileName rightMostFolderName; |
|
295 User::LeaveIfError( BaflUtils::MostSignificantPartOfFullName( suid, |
|
296 rightMostFolderName ) ); |
|
297 if ( ( newObjectName.Length() + rightMostFolderName.Length() + 1 ) <= newObjectName.MaxLength() ) |
|
298 { |
|
299 newObjectName.Append( rightMostFolderName ); |
|
300 // Add backslash. |
|
301 _LIT( KBackSlash, "\\" ); |
|
302 newObjectName.Append( KBackSlash ); |
|
303 } |
|
304 } |
|
305 |
|
306 iNewRootFolder = newObjectName.AllocL(); |
|
307 |
154 |
308 if ( responseCode == EMTPRespCodeOK ) |
155 if ( responseCode == EMTPRespCodeOK ) |
309 { |
156 MoveFileL( newObjectName ); |
310 delete iFileMan; |
157 |
311 iFileMan = NULL; |
158 SendResponseL( responseCode ); |
312 iFileMan = CFileMan::NewL( iFramework.Fs() ); |
159 |
313 |
160 CleanupStack::PopAndDestroy( &newObjectName ); // - newObjectName |
314 if ( !isFolder ) |
|
315 { |
|
316 MoveFileL( newObjectName ); |
|
317 SendResponseL( responseCode ); |
|
318 } |
|
319 else |
|
320 { |
|
321 MoveFolderL(); |
|
322 } |
|
323 } |
|
324 CleanupStack::PopAndDestroy( &newObjectName ); // - newObjectName. |
|
325 |
161 |
326 PRINT1( _L( "MM MTP <= CMoveObject::MoveObjectL responseCode = 0x%x" ), responseCode ); |
162 PRINT1( _L( "MM MTP <= CMoveObject::MoveObjectL responseCode = 0x%x" ), responseCode ); |
327 return responseCode; |
|
328 } |
163 } |
329 |
164 |
330 // ----------------------------------------------------------------------------- |
165 // ----------------------------------------------------------------------------- |
331 // CMoveObject::GetParametersL |
166 // CMoveObject::GetParametersL |
332 // Retrieve the parameters of the request |
167 // Retrieve the parameters of the request |
333 // ----------------------------------------------------------------------------- |
168 // ----------------------------------------------------------------------------- |
334 // |
169 // |
335 void CMoveObject::GetParametersL() |
170 void CMoveObject::GetParametersL() |
336 { |
171 { |
337 PRINT( _L( "MM MTP => CMoveObject::GetParametersL" ) ); |
172 PRINT( _L( "MM MTP => CMoveObject::GetParametersL" ) ); |
|
173 |
338 __ASSERT_DEBUG( iRequestChecker, Panic( EMmMTPDpRequestCheckNull ) ); |
174 __ASSERT_DEBUG( iRequestChecker, Panic( EMmMTPDpRequestCheckNull ) ); |
339 |
175 |
340 TUint32 objectHandle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 ); |
176 TUint32 objectHandle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 ); |
341 iStorageId = Request().Uint32( TMTPTypeRequest::ERequestParameter2 ); |
177 iStorageId = Request().Uint32( TMTPTypeRequest::ERequestParameter2 ); |
342 iNewParentHandle = Request().Uint32( TMTPTypeRequest::ERequestParameter3 ); |
178 iNewParentHandle = Request().Uint32( TMTPTypeRequest::ERequestParameter3 ); |
343 PRINT3( _L( "MM MTP <> objectHandle = 0x%x, iStoargeId = 0x%x, iNewParentHandle = 0x%x" ), |
179 PRINT3( _L( "MM MTP <> objectHandle = 0x%x, iStorageId = 0x%x, iNewParentHandle = 0x%x" ), |
344 objectHandle, iStorageId, iNewParentHandle ); |
180 objectHandle, |
|
181 iStorageId, |
|
182 iNewParentHandle ); |
345 |
183 |
346 // not taking owernship |
184 // not taking owernship |
347 iObjectInfo = iRequestChecker->GetObjectInfo( objectHandle ); |
185 iObjectInfo = iRequestChecker->GetObjectInfo( objectHandle ); |
348 __ASSERT_DEBUG( iObjectInfo, Panic( EMmMTPDpObjectNull ) ); |
186 __ASSERT_DEBUG( iObjectInfo, Panic( EMmMTPDpObjectNull ) ); |
349 |
187 |
350 if ( iNewParentHandle == 0 ) |
188 if ( iNewParentHandle == KMTPHandleNone ) |
351 { |
189 { |
352 SetDefaultParentObjectL(); |
190 SetDefaultParentObjectL(); |
353 } |
191 } |
354 else |
192 else |
355 { |
193 { |
356 CMTPObjectMetaData* parentObjectInfo = |
194 CMTPObjectMetaData* parentObject = iRequestChecker->GetObjectInfo( iNewParentHandle ); |
357 iRequestChecker->GetObjectInfo( iNewParentHandle ); |
195 __ASSERT_DEBUG( parentObject, Panic( EMmMTPDpObjectNull ) ); |
358 __ASSERT_DEBUG( parentObjectInfo, Panic( EMmMTPDpObjectNull ) ); |
196 |
359 delete iDest; |
197 delete iDest; |
360 iDest = NULL; |
198 iDest = NULL; |
361 iDest = parentObjectInfo->DesC( CMTPObjectMetaData::ESuid ).AllocL(); |
199 iDest = parentObject->DesC( CMTPObjectMetaData::ESuid ).AllocL(); |
362 PRINT1( _L( "MM MTP <> CMoveObject::GetParametersL iDest = %S" ), iDest ); |
200 PRINT1( _L( "MM MTP <> CMoveObject::GetParametersL iDest = %S" ), iDest ); |
363 } |
201 } |
364 PRINT( _L( "MM MTP <= CMoveObject::GetParametersL" ) ); |
202 PRINT( _L( "MM MTP <= CMoveObject::GetParametersL" ) ); |
365 } |
203 } |
366 |
204 |
433 PRINT1( _L( "MM MTP <= CMoveObject::CanMoveObjectL result = 0x%x" ), result ); |
272 PRINT1( _L( "MM MTP <= CMoveObject::CanMoveObjectL result = 0x%x" ), result ); |
434 return result; |
273 return result; |
435 } |
274 } |
436 |
275 |
437 // ----------------------------------------------------------------------------- |
276 // ----------------------------------------------------------------------------- |
|
277 // CMoveObject::MoveFileL |
|
278 // A helper function of MoveObjectL |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void CMoveObject::MoveFileL( const TDesC& aNewFileName ) |
|
282 { |
|
283 TFileName oldFileName = iObjectInfo->DesC( CMTPObjectMetaData::ESuid ); |
|
284 PRINT2( _L( "MM MTP => CMoveObject::MoveFileL old name = %S, aNewFileName = %S" ), |
|
285 &oldFileName, |
|
286 &aNewFileName ); |
|
287 |
|
288 if ( iStorageId == iObjectInfo->Uint( CMTPObjectMetaData::EStorageId ) ) |
|
289 iSameStorage = ETrue; |
|
290 else |
|
291 iSameStorage = EFalse; |
|
292 GetPreviousPropertiesL( *iObjectInfo ); |
|
293 SetPropertiesL( oldFileName, aNewFileName ); |
|
294 |
|
295 CFileMan* fileMan = CFileMan::NewL( iFramework.Fs() ); |
|
296 CleanupStack::PushL( fileMan ); |
|
297 User::LeaveIfError( fileMan->Move( oldFileName, aNewFileName ) ); |
|
298 CleanupStack::PopAndDestroy( fileMan ); |
|
299 |
|
300 User::LeaveIfError( iFramework.Fs().SetModified( aNewFileName, |
|
301 iPreviousModifiedTime ) ); |
|
302 |
|
303 PRINT( _L( "MM MTP <= CMoveObject::MoveFileL" ) ); |
|
304 } |
|
305 |
|
306 // ----------------------------------------------------------------------------- |
438 // CMoveObject::GetPreviousPropertiesL |
307 // CMoveObject::GetPreviousPropertiesL |
439 // Save the object properties before doing the move |
308 // Save the object properties before doing the move |
440 // ----------------------------------------------------------------------------- |
309 // ----------------------------------------------------------------------------- |
441 // |
310 // |
442 void CMoveObject::GetPreviousPropertiesL( const CMTPObjectMetaData& aObject ) |
311 void CMoveObject::GetPreviousPropertiesL( const CMTPObjectMetaData& aObject ) |
443 { |
312 { |
444 PRINT( _L( "MM MTP => CMoveObject::GetPreviousPropertiesL" ) ); |
313 PRINT( _L( "MM MTP => CMoveObject::GetPreviousPropertiesL" ) ); |
445 |
314 |
446 const TDesC& suid( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
315 const TDesC& suid( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
447 |
|
448 User::LeaveIfError( iFramework.Fs().Modified( suid, iPreviousModifiedTime ) ); |
316 User::LeaveIfError( iFramework.Fs().Modified( suid, iPreviousModifiedTime ) ); |
449 |
317 |
450 // same storage, not necessary to get the properties |
318 // same storage, not necessary to get the properties |
451 if ( iSameStorage ) |
319 if ( iSameStorage ) |
452 return; |
320 return; |
453 |
321 |
454 TUint formatCode = aObject.Uint( CMTPObjectMetaData::EFormatCode ); |
322 TUint formatCode = aObject.Uint( CMTPObjectMetaData::EFormatCode ); |
455 const RArray<TUint>* properties = iDpConfig.GetSupportedPropertiesL( formatCode ); |
323 const RArray<TUint>* properties = iDpConfig.GetSupportedPropertiesL( formatCode ); |
456 TInt count = properties->Count(); |
324 TInt count = properties->Count(); |
457 CMTPTypeString* textData = NULL; |
|
458 TInt err = KErrNone; |
325 TInt err = KErrNone; |
459 TUint16 propCode; |
326 TUint16 propCode; |
460 TUint32 handle = aObject.Uint( CMTPObjectMetaData::EHandle ) ; |
327 TUint32 handle = aObject.Uint( CMTPObjectMetaData::EHandle ); |
461 |
328 |
462 if ( iPropertyElement ) |
329 if ( iPropertyElement != NULL ) |
463 { |
330 { |
464 delete iPropertyElement; |
331 delete iPropertyElement; |
465 iPropertyElement = NULL; |
332 iPropertyElement = NULL; |
466 } |
333 } |
467 |
334 |
468 for ( TInt i = 0; i < count; i++ ) |
335 for ( TInt i = 0; i < count; i++ ) |
469 { |
336 { |
470 propCode = (*properties)[i]; |
337 propCode = ( *properties )[i]; |
471 switch( propCode ) |
338 |
|
339 switch ( propCode ) |
472 { |
340 { |
473 case EMTPObjectPropCodeStorageID: |
341 case EMTPObjectPropCodeStorageID: |
474 case EMTPObjectPropCodeObjectFormat: |
342 case EMTPObjectPropCodeObjectFormat: |
475 case EMTPObjectPropCodeProtectionStatus: |
343 case EMTPObjectPropCodeProtectionStatus: |
476 case EMTPObjectPropCodeObjectSize: |
344 case EMTPObjectPropCodeObjectSize: |
477 case EMTPObjectPropCodeObjectFileName: |
345 case EMTPObjectPropCodeObjectFileName: |
478 case EMTPObjectPropCodeParentObject: |
346 case EMTPObjectPropCodeParentObject: |
479 case EMTPObjectPropCodePersistentUniqueObjectIdentifier: |
347 case EMTPObjectPropCodePersistentUniqueObjectIdentifier: |
480 case EMTPObjectPropCodeNonConsumable: |
|
481 case EMTPObjectPropCodeDateCreated: |
348 case EMTPObjectPropCodeDateCreated: |
482 case EMTPObjectPropCodeDateModified: |
349 case EMTPObjectPropCodeDateModified: |
|
350 break; |
|
351 |
|
352 case EMTPObjectPropCodeNonConsumable: |
|
353 iPropertyElement = &( iPropertyList->ReservePropElemL( handle, propCode ) ); |
|
354 iPropertyElement->SetUint8L( CMTPTypeObjectPropListElement::EValue, |
|
355 aObject.Uint( CMTPObjectMetaData::ENonConsumable ) ); |
483 break; |
356 break; |
484 |
357 |
485 case EMTPObjectPropCodeName: |
358 case EMTPObjectPropCodeName: |
486 case EMTPObjectPropCodeDateAdded: |
359 case EMTPObjectPropCodeDateAdded: |
487 if ( ( propCode == EMTPObjectPropCodeName ) |
360 if ( ( propCode == EMTPObjectPropCodeName ) |
488 || ( ( !MmMtpDpUtility::IsVideoL( aObject.DesC( CMTPObjectMetaData::ESuid ), iFramework ) ) |
361 || ( !MmMtpDpUtility::IsVideoL( aObject.DesC( CMTPObjectMetaData::ESuid ), iFramework ) |
489 && ( propCode == EMTPObjectPropCodeDateAdded ) ) ) |
362 && ( propCode == EMTPObjectPropCodeDateAdded ) ) ) |
490 { |
363 { |
491 textData = CMTPTypeString::NewLC(); // + textData |
364 CMTPTypeString* textData = CMTPTypeString::NewLC(); // + textData |
492 |
365 |
493 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( propCode, |
366 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( propCode, |
494 *textData, |
367 *textData, |
495 aObject ) ); |
368 aObject ) ); |
496 |
369 |
497 PRINT1( _L( "MM MTP <> CMoveObject::GetPreviousPropertiesL::ServiceSpecificObjectPropertyL err = %d" ), err ); |
370 PRINT1( _L( "MM MTP <> CMoveObject::GetPreviousPropertiesL err = %d" ), err ); |
498 |
371 |
499 if ( err == KErrNone ) |
372 if ( err == KErrNone ) |
500 { |
373 { |
501 iPropertyElement = &(iPropertyList->ReservePropElemL(handle, propCode)); |
374 iPropertyElement = &( iPropertyList->ReservePropElemL( handle, propCode ) ); |
502 iPropertyElement->SetStringL(CMTPTypeObjectPropListElement::EValue, textData->StringChars()); |
375 iPropertyElement->SetStringL( CMTPTypeObjectPropListElement::EValue, |
503 // iPropertyElement = CMTPTypeObjectPropListElement::NewL( |
376 textData->StringChars() ); |
504 // handle, propCode, *textData ); |
|
505 } |
377 } |
506 else if ( err == KErrNotFound ) |
378 else if ( err == KErrNotFound ) |
507 { |
379 { |
508 iPropertyElement = NULL; |
380 iPropertyElement = NULL; |
509 } |
381 } |
510 else |
382 else |
511 { |
383 { |
512 User::Leave( err ); |
384 User::Leave( err ); |
513 } |
385 } |
514 |
386 |
515 CleanupStack::PopAndDestroy( textData ); // - textData |
387 CleanupStack::PopAndDestroy( textData ); // - textData |
516 } |
388 } |
517 break; |
389 break; |
518 |
390 |
521 ServiceGetSpecificObjectPropertyL( propCode, handle, aObject ); |
393 ServiceGetSpecificObjectPropertyL( propCode, handle, aObject ); |
522 } |
394 } |
523 break; |
395 break; |
524 } |
396 } |
525 |
397 |
526 if ( iPropertyElement ) |
398 if ( iPropertyElement != NULL ) |
527 { |
399 { |
528 iPropertyList->CommitPropElemL( *iPropertyElement ); |
400 iPropertyList->CommitPropElemL( *iPropertyElement ); |
529 |
|
530 iPropertyElement = NULL; |
401 iPropertyElement = NULL; |
531 } |
402 } |
532 |
|
533 } // end of for loop |
403 } // end of for loop |
534 |
404 |
535 PRINT1( _L( "MM MTP <= CMoveObject::GetPreviousPropertiesL err = %d" ), err ); |
405 PRINT1( _L( "MM MTP <= CMoveObject::GetPreviousPropertiesL err = %d" ), err ); |
536 } |
|
537 |
|
538 // ----------------------------------------------------------------------------- |
|
539 // CMoveObject::ServiceMetaDataToWrapper |
|
540 // |
|
541 // ----------------------------------------------------------------------------- |
|
542 // |
|
543 EXPORT_C TMTPResponseCode CMoveObject::ServiceMetaDataToWrapper( |
|
544 const TUint16 aPropCode, |
|
545 MMTPType& aNewData, |
|
546 const CMTPObjectMetaData& aObject ) |
|
547 { |
|
548 TMTPResponseCode resCode = EMTPRespCodeOK; |
|
549 |
|
550 TRAPD( err, iDpConfig.GetWrapperL().SetObjectMetadataValueL( aPropCode, |
|
551 aNewData, |
|
552 aObject ) ); |
|
553 |
|
554 PRINT1( _L("MM MTP <> CMoveObject::ServiceMetaDataToWrapper err = %d"), err); |
|
555 |
|
556 if ( err == KErrNone ) |
|
557 { |
|
558 resCode = EMTPRespCodeOK; |
|
559 } |
|
560 else if ( err == KErrTooBig ) |
|
561 // according to the codes of S60 |
|
562 { |
|
563 resCode = EMTPRespCodeInvalidDataset; |
|
564 } |
|
565 else if ( err == KErrPermissionDenied ) |
|
566 { |
|
567 resCode = EMTPRespCodeAccessDenied; |
|
568 } |
|
569 else if ( err == KErrNotFound ) |
|
570 { |
|
571 if ( MmMtpDpUtility::HasMetadata( aObject.Uint( CMTPObjectMetaData::EFormatCode ) ) ) |
|
572 resCode = EMTPRespCodeAccessDenied; |
|
573 else |
|
574 resCode = EMTPRespCodeOK; |
|
575 } |
|
576 else |
|
577 { |
|
578 resCode = EMTPRespCodeGeneralError; |
|
579 } |
|
580 |
|
581 PRINT1( _L("MM MTP <= CMoveObject::ServiceMetaDataToWrapper resCode = 0x%x"), resCode); |
|
582 |
|
583 return resCode; |
|
584 } |
406 } |
585 |
407 |
586 // ----------------------------------------------------------------------------- |
408 // ----------------------------------------------------------------------------- |
587 // CMoveObject::SetPreviousPropertiesL |
409 // CMoveObject::SetPreviousPropertiesL |
588 // Set the object properties after doing the move |
410 // Set the object properties after doing the move |
589 // ----------------------------------------------------------------------------- |
411 // ----------------------------------------------------------------------------- |
590 // |
412 // |
591 void CMoveObject::SetPreviousPropertiesL( const CMTPObjectMetaData& aObject ) |
413 void CMoveObject::SetPreviousPropertiesL() |
592 { |
414 { |
593 PRINT( _L( "MM MTP => CMoveObject::SetPreviousPropertiesL" ) ); |
415 PRINT( _L( "MM MTP => CMoveObject::SetPreviousPropertiesL" ) ); |
594 const TInt count( iPropertyList->NumberOfElements() ); |
416 |
595 PRINT1( _L( "MM MTP <> CMoveObject::SetPreviousPropertiesL count = %d" ), count ); |
|
596 TMTPResponseCode respcode = EMTPRespCodeOK; |
417 TMTPResponseCode respcode = EMTPRespCodeOK; |
597 CMTPTypeString* stringData = NULL; |
418 |
598 iPropertyList->ResetCursor(); |
419 iPropertyList->ResetCursor(); |
599 |
420 const TInt count = iPropertyList->NumberOfElements(); |
600 for ( TInt i = 0; i < count; i++ ) |
421 for ( TInt i = 0; i < count; i++ ) |
601 { |
422 { |
602 CMTPTypeObjectPropListElement& element = iPropertyList->GetNextElementL( ); |
423 CMTPTypeObjectPropListElement& element = iPropertyList->GetNextElementL(); |
603 |
424 |
604 TUint32 handle = element.Uint32L( |
425 TUint32 handle = element.Uint32L( CMTPTypeObjectPropListElement::EObjectHandle ); |
605 CMTPTypeObjectPropListElement::EObjectHandle ); |
426 TUint16 propertyCode = element.Uint16L( CMTPTypeObjectPropListElement::EPropertyCode ); |
606 TUint16 propertyCode = element.Uint16L( |
427 TUint16 dataType = element.Uint16L( CMTPTypeObjectPropListElement::EDatatype ); |
607 CMTPTypeObjectPropListElement::EPropertyCode ); |
428 PRINT3( _L( "MM MTP <> CCopyObject::SetPreviousPropertiesL = 0x%x, propertyCode = 0x%x, dataType = 0x%x" ), |
608 TUint16 dataType = element.Uint16L( |
429 handle, |
609 CMTPTypeObjectPropListElement::EDatatype ); |
430 propertyCode, |
610 PRINT3( _L( "MM MTP <> CMoveObject::SetPreviousPropertiesL = 0x%x, propertyCode = 0x%x, dataType = 0x%x" ), |
431 dataType ); |
611 handle, propertyCode, dataType ); |
|
612 |
432 |
613 switch ( propertyCode ) |
433 switch ( propertyCode ) |
614 { |
434 { |
615 case EMTPObjectPropCodeStorageID: |
435 case EMTPObjectPropCodeStorageID: |
616 case EMTPObjectPropCodeObjectFormat: |
436 case EMTPObjectPropCodeObjectFormat: |
617 case EMTPObjectPropCodeProtectionStatus: |
437 case EMTPObjectPropCodeProtectionStatus: |
618 case EMTPObjectPropCodeObjectSize: |
438 case EMTPObjectPropCodeObjectSize: |
619 case EMTPObjectPropCodeObjectFileName: |
439 case EMTPObjectPropCodeObjectFileName: |
620 case EMTPObjectPropCodeParentObject: |
440 case EMTPObjectPropCodeParentObject: |
621 case EMTPObjectPropCodePersistentUniqueObjectIdentifier: |
441 case EMTPObjectPropCodePersistentUniqueObjectIdentifier: |
622 case EMTPObjectPropCodeNonConsumable: |
|
623 case EMTPObjectPropCodeDateCreated: |
442 case EMTPObjectPropCodeDateCreated: |
624 case EMTPObjectPropCodeDateModified: |
443 case EMTPObjectPropCodeDateModified: |
625 case EMTPObjectPropCodeDateAdded: |
444 case EMTPObjectPropCodeDateAdded: |
626 break; |
445 break; |
627 |
446 |
|
447 case EMTPObjectPropCodeNonConsumable: |
|
448 iObjectInfo->SetUint( CMTPObjectMetaData::ENonConsumable, |
|
449 element.Uint8L( CMTPTypeObjectPropListElement::EValue ) ); |
|
450 break; |
|
451 |
628 case EMTPObjectPropCodeName: |
452 case EMTPObjectPropCodeName: |
629 { |
453 { |
630 stringData = CMTPTypeString::NewLC( |
454 CMTPTypeString *stringData = CMTPTypeString::NewLC( element.StringL( CMTPTypeObjectPropListElement::EValue ) ); // + stringData |
631 element.StringL(CMTPTypeObjectPropListElement::EValue)); // + stringData |
455 |
632 |
456 respcode = iDpConfig.PropSettingUtility()->SetMetaDataToWrapperL( iDpConfig, |
633 respcode = ServiceMetaDataToWrapper( propertyCode, |
457 propertyCode, |
634 *stringData, |
458 *stringData, |
635 aObject ); |
459 *iObjectInfo ); |
636 |
460 |
637 CleanupStack::PopAndDestroy( stringData ); // - stringData |
461 CleanupStack::PopAndDestroy( stringData ); // - stringData |
638 } |
462 } |
639 break; |
463 break; |
640 |
464 |
641 default: |
465 default: |
642 { |
466 { |
643 respcode = ServiceSetSpecificObjectPropertyL( propertyCode, |
467 respcode = iDpConfig.PropSettingUtility()->SetSpecificObjectPropertyL( iDpConfig, |
644 aObject, |
468 propertyCode, |
645 element ); |
469 *iObjectInfo, |
|
470 element ); |
646 } |
471 } |
647 break; |
472 break; |
648 } |
473 } |
649 } // end of for loop |
474 } // end of for loop |
650 |
475 |
651 if( respcode == EMTPRespCodeOK ) |
476 // ignore errors |
652 { |
|
653 // do nothing, ignore warning |
|
654 } |
|
655 |
477 |
656 PRINT1( _L( "MM MTP <= CMoveObject::SetPreviousPropertiesL respcode = 0x%x" ), respcode ); |
478 PRINT1( _L( "MM MTP <= CMoveObject::SetPreviousPropertiesL respcode = 0x%x" ), respcode ); |
657 } |
479 } |
658 |
480 |
659 // ----------------------------------------------------------------------------- |
481 // ----------------------------------------------------------------------------- |
660 // CMoveObject::SetPropertiesL |
482 // CMoveObject::SetPropertiesL |
661 // Set the object properties in the object property store. |
483 // Set the object properties in the object property store. |
662 // ----------------------------------------------------------------------------- |
484 // ----------------------------------------------------------------------------- |
663 // |
485 // |
664 void CMoveObject::SetPropertiesL( const TDesC& aOldFileName, const TDesC& aNewFileName, |
486 void CMoveObject::SetPropertiesL( const TDesC& aOldFileName, |
665 const CMTPObjectMetaData& aNewObject ) |
487 const TDesC& aNewFileName ) |
666 { |
488 { |
667 PRINT2( _L( "MM MTP => CMoveObject::SetPropertiesL aOldFileName = %S, aNewFileName = %S" ), |
489 PRINT2( _L( "MM MTP => CMoveObject::SetPropertiesL aOldFileName = %S, aNewFileName = %S" ), |
668 &aOldFileName, &aNewFileName ); |
490 &aOldFileName, |
669 |
491 &aNewFileName ); |
670 TUint32 formatCode = aNewObject.Uint( CMTPObjectMetaData::EFormatCode ); |
492 |
671 // This is used to keep the same behavior in mass storage and device file manager. |
493 iObjectInfo->SetDesCL( CMTPObjectMetaData::ESuid, aNewFileName ); |
|
494 iObjectInfo->SetUint( CMTPObjectMetaData::EStorageId, iStorageId ); |
|
495 iObjectInfo->SetUint( CMTPObjectMetaData::EParentHandle, iNewParentHandle ); |
|
496 |
|
497 TUint32 formatCode = iObjectInfo->Uint( CMTPObjectMetaData::EFormatCode ); |
672 if ( formatCode == EMTPFormatCodeAbstractAudioVideoPlaylist ) |
498 if ( formatCode == EMTPFormatCodeAbstractAudioVideoPlaylist ) |
673 { |
499 { |
|
500 // This is used to keep the same behavior in mass storage and device file manager. |
674 PRINT( _L( "MM MTP <> CMoveObject::SetPropertiesL Playlist file do not update the MPX DB" ) ); |
501 PRINT( _L( "MM MTP <> CMoveObject::SetPropertiesL Playlist file do not update the MPX DB" ) ); |
675 } |
502 } |
676 else |
503 else |
677 { |
504 { |
678 // if the two object in different stoarge, we should delete the old one and insert new one |
|
679 if ( iSameStorage ) |
505 if ( iSameStorage ) |
680 iDpConfig.GetWrapperL().RenameObjectL( aOldFileName, aNewFileName ); |
506 iDpConfig.GetWrapperL().RenameObjectL( aOldFileName, aNewFileName ); |
|
507 // if the two object in different storage, we should delete the old one and insert new one |
681 else |
508 else |
682 { |
509 { |
683 iDpConfig.GetWrapperL().DeleteObjectL( aOldFileName, formatCode ); |
510 iDpConfig.GetWrapperL().DeleteObjectL( aOldFileName, formatCode ); |
684 iDpConfig.GetWrapperL().AddObjectL( aNewFileName ); |
511 |
685 SetPreviousPropertiesL( aNewObject ); |
512 TUint32 subFormatCode = iObjectInfo->Uint( CMTPObjectMetaData::EFormatSubCode ); |
|
513 iDpConfig.GetWrapperL().AddObjectL( aNewFileName, |
|
514 formatCode, |
|
515 subFormatCode ); |
|
516 |
|
517 SetPreviousPropertiesL(); |
686 } |
518 } |
687 } |
519 } |
688 |
520 |
689 // Reference DB is used PUID |
521 iFramework.ObjectMgr().ModifyObjectL( *iObjectInfo ); |
690 // if ( formatCode == EMTPFormatCodeAbstractAudioVideoPlaylist |
522 |
691 // || formatCode == EMTPFormatCodeM3UPlaylist ) |
523 // It's not necessary to change references of playlists since Reference DB is used PUID |
692 // { |
|
693 // MMTPReferenceMgr& referenceMgr = iFramework.ReferenceMgr(); |
|
694 // CDesCArray* references = referenceMgr.ReferencesLC( aOldFileName ); // + references |
|
695 // referenceMgr.SetReferencesL( aNewFileName, *references ); |
|
696 // CleanupStack::PopAndDestroy( references ); // - references |
|
697 // // delete the old references |
|
698 // referenceMgr.RemoveReferencesL( aOldFileName ); |
|
699 // } |
|
700 |
|
701 |
524 |
702 PRINT( _L( "MM MTP <= CMoveObject::SetPropertiesL" ) ); |
525 PRINT( _L( "MM MTP <= CMoveObject::SetPropertiesL" ) ); |
703 } |
526 } |
704 |
527 |
705 // ----------------------------------------------------------------------------- |
|
706 // CMoveObject::FinalPhaseMove |
|
707 // This function will actually delete the orginal folders from the file system |
|
708 // ----------------------------------------------------------------------------- |
|
709 // |
|
710 TMTPResponseCode CMoveObject::FinalPhaseMove() |
|
711 { |
|
712 PRINT( _L( "MM MTP => CMoveObject::FinalPhaseMove" ) ); |
|
713 TMTPResponseCode ret = EMTPRespCodeOK; |
|
714 |
|
715 TInt rel = iFileMan->RmDir( *iPathToMove ); |
|
716 PRINT1( _L( "MM MTP <> CMoveObject::FinalPhaseMove rel = %d" ), rel ); |
|
717 |
|
718 if ( rel != KErrNone ) |
|
719 { |
|
720 ret = EMTPRespCodeGeneralError; |
|
721 } |
|
722 |
|
723 PRINT1( _L( "MM MTP <= CMoveObject::FinalPhaseMove ret = 0x%x" ), ret ); |
|
724 return ret; |
|
725 } |
|
726 |
|
727 // ----------------------------------------------------------------------------- |
|
728 // CMoveObject::GenerateObjectHandleListL |
|
729 // Generate the list of handles that need to be moved to the new location |
|
730 // ----------------------------------------------------------------------------- |
|
731 // |
|
732 void CMoveObject::GenerateObjectHandleListL( TUint32 aParentHandle ) |
|
733 { |
|
734 PRINT1( _L( "MM MTP => CMoveObject::GenerateObjectHandleListL aParentHandle = 0x%x" ), aParentHandle ); |
|
735 RMTPObjectMgrQueryContext context; |
|
736 RArray<TUint> handles; |
|
737 TMTPObjectMgrQueryParams params( KMTPStorageAll, KMTPFormatsAll, |
|
738 aParentHandle ); |
|
739 CleanupClosePushL( context ); // + context |
|
740 CleanupClosePushL( handles ); // - handles |
|
741 |
|
742 do |
|
743 { |
|
744 iFramework.ObjectMgr().GetObjectHandlesL( params, context, handles ); |
|
745 |
|
746 TInt numberOfObjects = handles.Count(); |
|
747 for ( TInt i = 0; i < numberOfObjects; i++ ) |
|
748 { |
|
749 if ( iFramework.ObjectMgr().ObjectOwnerId( handles[i] ) == iFramework.DataProviderId() ) |
|
750 { |
|
751 iObjectHandles.AppendL( handles[i] ); |
|
752 continue; |
|
753 } |
|
754 |
|
755 // Folder |
|
756 if ( iFramework.ObjectMgr().ObjectOwnerId( handles[i] ) == 0 ) // We know that the device dp id is always 0, otherwise the whole MTP won't work. |
|
757 { |
|
758 GenerateObjectHandleListL( handles[i] ); |
|
759 } |
|
760 } |
|
761 } |
|
762 while ( !context.QueryComplete() ); |
|
763 |
|
764 CleanupStack::PopAndDestroy( &handles ); // - handles |
|
765 CleanupStack::PopAndDestroy( &context ); // - contect |
|
766 |
|
767 PRINT( _L( "MM MTP <= CMoveObject::GenerateObjectHandleListL" ) ); |
|
768 } |
|
769 |
|
770 // ----------------------------------------------------------------------------- |
|
771 // CMoveObject::MoveAndUpdateL |
|
772 // Move a single object and update the database |
|
773 // ----------------------------------------------------------------------------- |
|
774 // |
|
775 void CMoveObject::MoveAndUpdateL( TUint32 aObjectHandle ) |
|
776 { |
|
777 PRINT1( _L( "MM MTP => CMoveObject::MoveAndUpdateL aObjectHanlde = 0x%x" ), aObjectHandle ); |
|
778 |
|
779 CMTPObjectMetaData* objectInfo( CMTPObjectMetaData::NewLC() ); // + objectInfo |
|
780 |
|
781 RBuf fileName; |
|
782 fileName.CreateL( KMaxFileName ); |
|
783 fileName.CleanupClosePushL(); // + fileName |
|
784 |
|
785 RBuf rightPartName; |
|
786 rightPartName.CreateL( KMaxFileName ); |
|
787 rightPartName.CleanupClosePushL(); // + rightPartName |
|
788 |
|
789 RBuf oldName; |
|
790 oldName.CreateL( KMaxFileName ); |
|
791 oldName.CleanupClosePushL(); // + oldName |
|
792 |
|
793 if ( iFramework.ObjectMgr().ObjectL( TMTPTypeUint32( aObjectHandle ), *objectInfo ) ) |
|
794 { |
|
795 fileName = objectInfo->DesC( CMTPObjectMetaData::ESuid ); |
|
796 oldName = fileName; |
|
797 |
|
798 if ( objectInfo->Uint( CMTPObjectMetaData::EDataProviderId ) |
|
799 == iFramework.DataProviderId() ) |
|
800 { |
|
801 rightPartName = fileName.Right( fileName.Length() - iPathToMove->Length() ); |
|
802 |
|
803 if ( ( iNewRootFolder->Length() + rightPartName.Length() ) > fileName.MaxLength() ) |
|
804 { |
|
805 User::Leave( KErrCorrupt ); |
|
806 } |
|
807 |
|
808 fileName.Zero(); |
|
809 fileName.Append( *iNewRootFolder ); |
|
810 fileName.Append( rightPartName ); |
|
811 PRINT1( _L( "MM MTP <> MoveAndUpdateL fileName = %S" ), &fileName ); |
|
812 |
|
813 if ( iStorageId == objectInfo->Uint( CMTPObjectMetaData::EStorageId ) ) |
|
814 iSameStorage = ETrue; |
|
815 else |
|
816 iSameStorage = EFalse; |
|
817 GetPreviousPropertiesL( *objectInfo ); |
|
818 TInt err = iFileMan->Move( oldName, fileName ); |
|
819 PRINT1( _L( "MM MTP <> CMoveObject::MoveAndUpdateL Move error code = %d" ), err ); |
|
820 User::LeaveIfError( err ); |
|
821 User::LeaveIfError( iFramework.Fs().SetModified( fileName, iPreviousModifiedTime ) ); |
|
822 |
|
823 objectInfo->SetDesCL( CMTPObjectMetaData::ESuid, fileName ); |
|
824 objectInfo->SetUint( CMTPObjectMetaData::EStorageId, iStorageId ); |
|
825 TParsePtrC parentSuid( fileName ); |
|
826 TUint32 parentHandle = iFramework.ObjectMgr().HandleL( parentSuid.DriveAndPath() ); |
|
827 objectInfo->SetUint( CMTPObjectMetaData::EParentHandle, parentHandle ); |
|
828 |
|
829 //TUint32 parentHandle = iFramework.ObjectMgr().HandleL( parentSuid.DriveAndPath() ); |
|
830 PRINT1( _L( "MM MTP <> CMoveObject::MoveAndUpdateL parentHandle = 0x%x" ), parentHandle ); |
|
831 |
|
832 iFramework.ObjectMgr().ModifyObjectL( *objectInfo ); |
|
833 |
|
834 SetPropertiesL( oldName, fileName, *objectInfo ); |
|
835 } |
|
836 } |
|
837 else |
|
838 { |
|
839 User::Leave( KErrCorrupt ); |
|
840 } |
|
841 |
|
842 CleanupStack::PopAndDestroy( &oldName ); // - oldName |
|
843 CleanupStack::PopAndDestroy( &rightPartName ); // - rightPartName |
|
844 CleanupStack::PopAndDestroy( &fileName ); // - fileName |
|
845 CleanupStack::PopAndDestroy( objectInfo ); // - objectInfo |
|
846 PRINT( _L( "MM MTP <= CMoveObject::MoveAndUpdateL" ) ); |
|
847 } |
|
848 |
|
849 // end of file |
528 // end of file |