commonuis/CommonUi/src/DocDefaultHandler.cpp
branchRCL_3
changeset 18 fcdfafb36fe7
parent 0 2f259fa3e83a
child 19 aecbbf00d063
equal deleted inserted replaced
17:a1caeb42b3a3 18:fcdfafb36fe7
   104         iSavedAsTemp( EFalse ),
   104         iSavedAsTemp( EFalse ),
   105         iServiceMode( aServiceMode ),
   105         iServiceMode( aServiceMode ),
   106         iStatus( KErrNone ),
   106         iStatus( KErrNone ),
   107         iUid( aUid ),
   107         iUid( aUid ),
   108         iOpenService( NULL ),
   108         iOpenService( NULL ),
   109         iMMCSaveAllowed ( ETrue )
   109         iMMCSaveAllowed ( ETrue ),
       
   110         iFileHandleSet( EFalse )
   110     {
   111     {
   111     }
   112     }
   112     
   113     
   113 // Destructor  
   114 // Destructor  
   114 //
   115 //
   547         return SetAndReturnStatus( KErrBadName );
   548         return SetAndReturnStatus( KErrBadName );
   548         
   549         
   549     iSourceFile = aFileName;
   550     iSourceFile = aFileName;
   550     return SetAndReturnStatus( KErrNone );
   551     return SetAndReturnStatus( KErrNone );
   551     }
   552     }
       
   553 
       
   554 TInt CDocDefaultHandler::SetSrcFile( const RFile& aFile )
       
   555 	{
       
   556 	TInt err = iFile.Duplicate( aFile );
       
   557 	iFileHandleSet = ( err == KErrNone ) ? ETrue : EFalse;
       
   558 	return SetAndReturnStatus( KErrNone );
       
   559 	}
   552 
   560 
   553 // ---------------------------------------------------------
   561 // ---------------------------------------------------------
   554 // CDocDefaultHandler::SetDestName()
   562 // CDocDefaultHandler::SetDestName()
   555 // Check the name and set iDestFile.
   563 // Check the name and set iDestFile.
   556 // ---------------------------------------------------------
   564 // ---------------------------------------------------------
  1655         {
  1663         {
  1656         TInt ret = EFalse;
  1664         TInt ret = EFalse;
  1657         TBuf<6> ext;
  1665         TBuf<6> ext;
  1658 
  1666 
  1659 		CContent* content = NULL;
  1667 		CContent* content = NULL;
  1660         TRAPD(err,content = CContent::NewL( iSourceFile ));
  1668 		if( iFileHandleSet )
  1661 
  1669 			{
  1662 		if(err == KErrNone)
  1670 		    content = CContent::NewL( iFile );
  1663 			{	
  1671 		    iFile.Close();
  1664 			CleanupStack::PushL(content);
  1672 		    iFileHandleSet = EFalse;
  1665 			content->GetAttribute( ContentAccess::EIsProtected, ret  );
  1673 			}
  1666 			if ( ret )
  1674 		else
       
  1675 			{
       
  1676 		    content = CContent::NewL( iSourceFile );
       
  1677 			}
       
  1678 		
       
  1679 		CleanupStack::PushL(content);
       
  1680 		content->GetAttribute( ContentAccess::EIsProtected, ret  );
       
  1681 		if ( ret )
       
  1682 			{
       
  1683 			content->GetAttribute( EFileType, ret );
       
  1684             
       
  1685 			#ifdef _DEBUG             
       
  1686 			RDebug::Print( _L("DocumentHandler: CDocDefaultHandler::CheckFileNameExtensionL: GetAttribute called, ret =%d"), ret);
       
  1687 			#endif 
       
  1688     
       
  1689 			if ( ret == EOma1Dcf )
  1667 				{
  1690 				{
  1668 				content->GetAttribute( EFileType, ret );
  1691 				// change extension to .dcf
  1669             
  1692 				ext.Copy( KOma1DcfExtension );         
  1670 				#ifdef _DEBUG             
  1693 				ReplaceExtension( aFileName, ext );            
  1671 				RDebug::Print( _L("DocumentHandler: CDocDefaultHandler::CheckFileNameExtensionL: GetAttribute called, ret =%d"), ret);
  1694 				CleanupStack::PopAndDestroy();  // content
  1672 				#endif 
  1695 				return;            
  1673     
  1696 				}
  1674 				if ( ret == EOma1Dcf )
  1697 			else if ( ret == EOma2Dcf )
       
  1698 	            {
       
  1699 		        // change extension to .odf if not already .o4a, .o4v or .odf
       
  1700 			    ext.Copy( KOma2DcfExtension );
       
  1701 				if ( NeedsToReplaceDcf2Extension( aFileName ) )
  1675 					{
  1702 					{
  1676 					// change extension to .dcf
  1703 				    ReplaceExtension( aFileName, ext );
  1677 					ext.Copy( KOma1DcfExtension );         
  1704 	                }
  1678 					ReplaceExtension( aFileName, ext );            
  1705 		        CleanupStack::PopAndDestroy();  // content
  1679 					CleanupStack::PopAndDestroy();  // content
  1706 			    return;            
  1680 					return;            
       
  1681 					}
       
  1682 				else if ( ret == EOma2Dcf )
       
  1683 	                {
       
  1684 		            // change extension to .odf if not already .o4a, .o4v or .odf
       
  1685 			        ext.Copy( KOma2DcfExtension );
       
  1686 				    if ( NeedsToReplaceDcf2Extension( aFileName ) )
       
  1687 					    {
       
  1688 						ReplaceExtension( aFileName, ext );
       
  1689 	                    }
       
  1690 		            CleanupStack::PopAndDestroy();  // content
       
  1691 			        return;            
       
  1692 				    }
       
  1693 				}
  1707 				}
  1694 			CleanupStack::PopAndDestroy();  // content
       
  1695 			}
  1708 			}
  1696         }
  1709 		CleanupStack::PopAndDestroy();  // content
       
  1710 		}
  1697 
  1711 
  1698     //if mime type=oma 2 dcf check extension separately
  1712     //if mime type=oma 2 dcf check extension separately
  1699     if ( aDataType.Des8().FindF( KOma2DcfContentType ) != KErrNotFound )
  1713     if ( aDataType.Des8().FindF( KOma2DcfContentType ) != KErrNotFound )
  1700         {
  1714         {
  1701         if ( NeedsToReplaceDcf2Extension( aFileName ) )
  1715         if ( NeedsToReplaceDcf2Extension( aFileName ) )