258 { |
260 { |
259 TMsgStoreId msgId = iMessages[i]; |
261 TMsgStoreId msgId = iMessages[i]; |
260 |
262 |
261 if ( EFalse == iImmediateDelete ) |
263 if ( EFalse == iImmediateDelete ) |
262 { |
264 { |
263 //try to find the message in the deleted items folder. |
265 //try to find the message |
264 CMsgStoreMessage* theMessage = NULL; |
266 CMsgStoreMessage* theMessage = NULL; |
265 TRAP_IGNORE( theMessage = mailBox.FetchMessageL( |
267 theMessage = mailBox.FetchMessageL( |
266 msgId, mailBoxInfo.iRootFolders.iFolders[EFSDeleted] ) ); |
268 msgId, KMsgStoreInvalidId ) ; |
267 |
269 //save parentId |
268 if ( NULL == theMessage ) |
270 TMsgStoreId msgParentId; |
|
271 msgParentId =theMessage->ParentId(); |
|
272 //check if message is in deleted folder or not. |
|
273 if ( msgParentId != mailBoxInfo.iRootFolders.iFolders[EFSDeleted] ) |
269 { |
274 { |
270 //if not in deleted items then move it there. |
275 //if not in deleted items then move it there. |
271 __LOG_WRITE8_FORMAT1_INFO("Moving message 0x%X to the deleted items.", msgId ); |
276 __LOG_WRITE8_FORMAT1_INFO("Moving message 0x%X to the deleted items.", msgId ); |
272 mailBox.MoveMessageL( |
277 TRAP(result,mailBox.MoveMessageL( |
273 msgId, KMsgStoreInvalidId, |
278 msgId, KMsgStoreInvalidId, |
274 mailBoxInfo.iRootFolders.iFolders[EFSDeleted] ); |
279 mailBoxInfo.iRootFolders.iFolders[EFSDeleted] )); |
|
280 if(result == KErrNone) |
|
281 { |
|
282 GetPlugin().NotifyEventL( iMailBoxId, msgId, KMsgStoreInvalidId , TFSEventMailMoved, msgParentId); |
|
283 } |
|
284 else |
|
285 { |
|
286 User::Leave(result); |
|
287 } |
|
288 |
275 } |
289 } |
276 else |
290 else |
277 { |
291 { |
278 //in deleted items, really delete it. |
292 //in deleted items, really delete it. |
279 __LOG_WRITE8_FORMAT1_INFO( "Deleting message 0x%X.", msgId ); |
293 __LOG_WRITE8_FORMAT1_INFO( "Deleting message 0x%X.", msgId ); |
280 |
294 |
281 delete theMessage; |
295 delete theMessage; |
282 mailBox.DeleteMessageL( msgId, iFolderId ); |
296 TRAP(result,mailBox.DeleteMessageL( msgId, iFolderId )); |
|
297 if(result == KErrNone) |
|
298 { |
|
299 GetPlugin().NotifyEventL( iMailBoxId, msgId, KMsgStoreInvalidId, TFSEventMailDeleted, iFolderId ); |
|
300 } |
|
301 else |
|
302 { |
|
303 User::Leave(result); |
|
304 } |
283 } |
305 } |
284 } |
306 } |
285 else |
307 else |
286 { |
308 { |
287 mailBox.DeleteMessageL( msgId, iFolderId ); |
309 TRAP(result,mailBox.DeleteMessageL( msgId, iFolderId )); |
|
310 if(result == KErrNone) |
|
311 { |
|
312 GetPlugin().NotifyEventL( iMailBoxId, msgId, KMsgStoreInvalidId, TFSEventMailDeleted, iFolderId ); |
|
313 } |
|
314 else |
|
315 { |
|
316 User::Leave(result); |
|
317 } |
288 } |
318 } |
|
319 //</qmail> |
289 } |
320 } |
290 __LOG_EXIT; |
321 __LOG_EXIT; |
291 return done; |
322 return done; |
292 } |
323 } |
293 /** |
324 /** |