ipsservices/ipssosplugin/src/ipsplgsosbaseplugin.cpp
branchRCL_3
changeset 11 0396474f30f5
parent 8 e1b6206813b4
child 14 b13141f05c3d
equal deleted inserted replaced
10:f5907b1a1053 11:0396474f30f5
  1358 // ----------------------------------------------------------------------------
  1358 // ----------------------------------------------------------------------------
  1359 //
  1359 //
  1360 void CIpsPlgSosBasePlugin::CopyMessagePartFileL(
  1360 void CIpsPlgSosBasePlugin::CopyMessagePartFileL(
  1361     const TFSMailMsgId& /* aMailBoxId */,
  1361     const TFSMailMsgId& /* aMailBoxId */,
  1362     const TFSMailMsgId& /* aParentFolderId */,
  1362     const TFSMailMsgId& /* aParentFolderId */,
  1363     const TFSMailMsgId& aMessageId,
  1363     const TFSMailMsgId& /*aMessageId*/,
  1364     const TFSMailMsgId& aMessagePartId,
  1364     const TFSMailMsgId& aMessagePartId,
  1365     const TDesC& aFilePath)
  1365     const TDesC& aFilePath)
  1366 	{
  1366 	{
  1367     FUNC_LOG;
  1367     FUNC_LOG;
  1368     CMsvEntry* cEntry( NULL );
  1368     CMsvEntry* cEntry = iSession->GetEntryL( aMessagePartId.Id() );
  1369     CImEmailMessage* message( NULL );
  1369     CleanupStack::PushL( cEntry );
  1370 
  1370     CMsvStore* store = NULL;
  1371     CFileMan* fileMgr = CFileMan::NewL( iSession->FileSession() );
  1371     TBool hasStore = cEntry->HasStoreL();
  1372     CleanupStack::PushL( fileMgr );
  1372     if ( hasStore )
  1373 
  1373         {
  1374     // We trust that the message ID really refers to a message
  1374         store = cEntry->ReadStoreL();
  1375     GetMessageEntryL( aMessageId.Id(), cEntry, message );
  1375         }
  1376 
  1376     if ( !store || !hasStore )
  1377     // Without this e.g. alternative body iCal parts are not found
  1377         {
  1378     message->GetAttachmentsListL( aMessageId.Id(),
  1378         User::Leave( KErrNotFound );
  1379         CImEmailMessage::EAllAttachments,
  1379         }
  1380         CImEmailMessage::EThisMessageAndEmbeddedMessages );
  1380     CleanupStack::PushL( store );
  1381     MMsvAttachmentManager& attachmentMgr( message->AttachmentManager() );
  1381     MMsvAttachmentManager& attachmentMgr = store->AttachmentManagerL();
  1382     // It is assumed that the attachment ID is same as the corresponding
  1382     // It is assumed that the attachment file is always in the index 0
  1383     // entry ID
  1383     if ( attachmentMgr.AttachmentCount() )
  1384     RFile attachmentFile = attachmentMgr.GetAttachmentFileL(
  1384         {
  1385         (TMsvAttachmentId) aMessagePartId.Id() );
  1385         RFile attachmentFile =
  1386 
  1386             attachmentMgr.GetAttachmentFileL( 0 );
  1387     // Overwrites the target file if such exists
  1387         CleanupClosePushL( attachmentFile );
  1388     // There is no other way to report errors than leave
  1388         CFileMan* fileMgr = CFileMan::NewL( iSession->FileSession() );
  1389     User::LeaveIfError( fileMgr->Copy( attachmentFile, aFilePath ) );
  1389         CleanupStack::PushL( fileMgr );
  1390 
  1390         User::LeaveIfError( fileMgr->Copy( attachmentFile, aFilePath ) );
  1391     attachmentFile.Close();
  1391         CleanupStack::PopAndDestroy( fileMgr );
  1392     CleanupStack::PopAndDestroy( fileMgr );
  1392         CleanupStack::PopAndDestroy(); // attachmentFile.Close()
       
  1393         }
       
  1394     else
       
  1395         {
       
  1396         User::Leave( KErrNotFound );
       
  1397         }
       
  1398     CleanupStack::PopAndDestroy( store );
       
  1399     CleanupStack::PopAndDestroy( cEntry );
  1393 	}
  1400 	}
  1394 
  1401 
  1395 // ----------------------------------------------------------------------------
  1402 // ----------------------------------------------------------------------------
  1396 // The method supports only reading of the plain text body currently.
  1403 // The method supports only reading of the plain text body currently.
  1397 // ----------------------------------------------------------------------------
  1404 // ----------------------------------------------------------------------------
  1615 // ----------------------------------------------------------------------------
  1622 // ----------------------------------------------------------------------------
  1616 TFSProgress CIpsPlgSosBasePlugin::StatusL( TInt aRequestId )
  1623 TFSProgress CIpsPlgSosBasePlugin::StatusL( TInt aRequestId )
  1617 	{
  1624 	{
  1618     FUNC_LOG;
  1625     FUNC_LOG;
  1619 	TFSProgress status;
  1626 	TFSProgress status;
       
  1627 	status.iError = KErrNone;
  1620 	status.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
  1628 	status.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
  1621 	for ( TInt i = 0; i < iOperations.Count(); i++ )
  1629 	for ( TInt i = 0; i < iOperations.Count(); i++ )
  1622         {
  1630         {
  1623         const CIpsPlgBaseOperation* op = iOperations[i]->BaseOperation();
  1631         const CIpsPlgBaseOperation* op = iOperations[i]->BaseOperation();
  1624         if ( op && op->FSRequestId() == aRequestId )
  1632         if ( op && op->FSRequestId() == aRequestId )