commonuis/CommonUi/src/DocDefaultHandler.cpp
branchRCL_3
changeset 19 aecbbf00d063
parent 18 fcdfafb36fe7
child 20 d48ab3b357f1
equal deleted inserted replaced
18:fcdfafb36fe7 19:aecbbf00d063
    33 #include "DocResourceFile.h"        // CDocResourceFile
    33 #include "DocResourceFile.h"        // CDocResourceFile
    34 
    34 
    35 #include <AiwGenericParam.h>        // Generic parameters
    35 #include <AiwGenericParam.h>        // Generic parameters
    36 
    36 
    37 #ifdef RD_MULTIPLE_DRIVE
    37 #ifdef RD_MULTIPLE_DRIVE
    38 #include <CAknMemorySelectionDialogMultiDrive.h>
       
    39 #include <driveinfo.h>      //DriveInfo
    38 #include <driveinfo.h>      //DriveInfo
    40 #include <AknCommonDialogsDynMem.h>
       
    41 #include <coemain.h>
    39 #include <coemain.h>
    42 #include <rsfwmountman.h>
       
    43 #else
       
    44 #include "CAknMemorySelectionDialog.h" // CAknMemorySelectionDialog
       
    45 #endif
    40 #endif
    46 
    41 
    47 #include "pathinfo.h"               // PathInfo
    42 #include "pathinfo.h"               // PathInfo
    48 #include <featmgr.h>                // FeatureManager
    43 #include <featmgr.h>                // FeatureManager
    49 
    44 
   104         iSavedAsTemp( EFalse ),
    99         iSavedAsTemp( EFalse ),
   105         iServiceMode( aServiceMode ),
   100         iServiceMode( aServiceMode ),
   106         iStatus( KErrNone ),
   101         iStatus( KErrNone ),
   107         iUid( aUid ),
   102         iUid( aUid ),
   108         iOpenService( NULL ),
   103         iOpenService( NULL ),
   109         iMMCSaveAllowed ( ETrue ),
   104         iMMCSaveAllowed ( ETrue )
   110         iFileHandleSet( EFalse )
       
   111     {
   105     {
   112     }
   106     }
   113     
   107     
   114 // Destructor  
   108 // Destructor  
   115 //
   109 //
   548         return SetAndReturnStatus( KErrBadName );
   542         return SetAndReturnStatus( KErrBadName );
   549         
   543         
   550     iSourceFile = aFileName;
   544     iSourceFile = aFileName;
   551     return SetAndReturnStatus( KErrNone );
   545     return SetAndReturnStatus( KErrNone );
   552     }
   546     }
   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 	}
       
   560 
   547 
   561 // ---------------------------------------------------------
   548 // ---------------------------------------------------------
   562 // CDocDefaultHandler::SetDestName()
   549 // CDocDefaultHandler::SetDestName()
   563 // Check the name and set iDestFile.
   550 // Check the name and set iDestFile.
   564 // ---------------------------------------------------------
   551 // ---------------------------------------------------------
  1134                     return KErrCancel;
  1121                     return KErrCancel;
  1135                     }
  1122                     }
  1136                 }
  1123                 }
  1137             path.Copy( iRootPath );
  1124             path.Copy( iRootPath );
  1138             }
  1125             }
  1139 #ifdef RD_MULTIPLE_DRIVE 
       
  1140         else if( (!CanOnlyBeSavedToPhoneMemoryL())&&(1 < GetAvailableDrivesCountL()) )
       
  1141         	{
       
  1142         	TFileName defaultFolder;
       
  1143             CAknMemorySelectionDialogMultiDrive* dlg =NULL;
       
  1144 			// Remote drives are not shown in the list of available drives.. FIX for error ANAE-76S7KX
       
  1145 	        dlg = CAknMemorySelectionDialogMultiDrive::NewL(ECFDDialogTypeBrowse,0,EFalse, 
       
  1146 	        			AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage | AknCommonDialogsDynMem::EMemoryTypeMMCExternal);
       
  1147 		    CleanupStack::PushL( dlg );
       
  1148 			TDriveNumber driveNumber;
       
  1149 		    TBool result(dlg->ExecuteL(driveNumber,&path,&defaultFolder));// driveNumber );
       
  1150 			CleanupStack::PopAndDestroy( dlg );
       
  1151 			if (!result)
       
  1152 				{
       
  1153 		        SetAndReturnStatus( KErrCancel );
       
  1154 		        return KErrCancel;
       
  1155 		        }
       
  1156            }
       
  1157 #else  
       
  1158         else if ( CanBeSavedToMmcL() )
       
  1159             {
       
  1160             CAknMemorySelectionDialog::TMemory mem( CAknMemorySelectionDialog::EPhoneMemory);
       
  1161             AddResourcesL();
       
  1162             TFileName defaultFolder;
       
  1163             CAknMemorySelectionDialog* memoryDialog = CAknMemorySelectionDialog::NewL(
       
  1164                                                             ECFDDialogTypeSave,
       
  1165                                                             R_DOCHANDLER_MEMORY_SELECTION_DIALOG,
       
  1166                                                             EFalse );
       
  1167             CleanupStack::PushL( memoryDialog );    
       
  1168             
       
  1169             TBool result( memoryDialog->ExecuteL( mem, &path, &defaultFolder ) );
       
  1170             if (!result)
       
  1171                 {
       
  1172                 RemoveResources();
       
  1173                 CleanupStack::PopAndDestroy();  // memoryDialog
       
  1174                 SetAndReturnStatus( KErrCancel );
       
  1175                 return KErrCancel;
       
  1176                 }
       
  1177 
       
  1178             CleanupStack::PopAndDestroy();  // memoryDialog
       
  1179 
       
  1180             RemoveResources();
       
  1181             }
       
  1182         #endif
       
  1183         else 
  1126         else 
  1184             {
  1127             {
  1185             path.Copy( PathInfo::PhoneMemoryRootPath() );
  1128             path.Copy( PathInfo::PhoneMemoryRootPath() );
  1186             }
  1129             }
  1187 
  1130 
  1663         {
  1606         {
  1664         TInt ret = EFalse;
  1607         TInt ret = EFalse;
  1665         TBuf<6> ext;
  1608         TBuf<6> ext;
  1666 
  1609 
  1667 		CContent* content = NULL;
  1610 		CContent* content = NULL;
  1668 		if( iFileHandleSet )
  1611         TRAPD(err,content = CContent::NewL( iSourceFile ));
  1669 			{
  1612 
  1670 		    content = CContent::NewL( iFile );
  1613 		if(err == KErrNone)
  1671 		    iFile.Close();
  1614 			{	
  1672 		    iFileHandleSet = EFalse;
  1615 			CleanupStack::PushL(content);
       
  1616 			content->GetAttribute( ContentAccess::EIsProtected, ret  );
       
  1617 			if ( ret )
       
  1618 				{
       
  1619 				content->GetAttribute( EFileType, ret );
       
  1620             
       
  1621 				#ifdef _DEBUG             
       
  1622 				RDebug::Print( _L("DocumentHandler: CDocDefaultHandler::CheckFileNameExtensionL: GetAttribute called, ret =%d"), ret);
       
  1623 				#endif 
       
  1624     
       
  1625 				if ( ret == EOma1Dcf )
       
  1626 					{
       
  1627 					// change extension to .dcf
       
  1628 					ext.Copy( KOma1DcfExtension );         
       
  1629 					ReplaceExtension( aFileName, ext );            
       
  1630 					CleanupStack::PopAndDestroy();  // content
       
  1631 					return;            
       
  1632 					}
       
  1633 				else if ( ret == EOma2Dcf )
       
  1634 	                {
       
  1635 		            // change extension to .odf if not already .o4a, .o4v or .odf
       
  1636 			        ext.Copy( KOma2DcfExtension );
       
  1637 				    if ( NeedsToReplaceDcf2Extension( aFileName ) )
       
  1638 					    {
       
  1639 						ReplaceExtension( aFileName, ext );
       
  1640 	                    }
       
  1641 		            CleanupStack::PopAndDestroy();  // content
       
  1642 			        return;            
       
  1643 				    }
       
  1644 				}
       
  1645 			CleanupStack::PopAndDestroy();  // content
  1673 			}
  1646 			}
  1674 		else
  1647         }
  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 )
       
  1690 				{
       
  1691 				// change extension to .dcf
       
  1692 				ext.Copy( KOma1DcfExtension );         
       
  1693 				ReplaceExtension( aFileName, ext );            
       
  1694 				CleanupStack::PopAndDestroy();  // content
       
  1695 				return;            
       
  1696 				}
       
  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 ) )
       
  1702 					{
       
  1703 				    ReplaceExtension( aFileName, ext );
       
  1704 	                }
       
  1705 		        CleanupStack::PopAndDestroy();  // content
       
  1706 			    return;            
       
  1707 				}
       
  1708 			}
       
  1709 		CleanupStack::PopAndDestroy();  // content
       
  1710 		}
       
  1711 
  1648 
  1712     //if mime type=oma 2 dcf check extension separately
  1649     //if mime type=oma 2 dcf check extension separately
  1713     if ( aDataType.Des8().FindF( KOma2DcfContentType ) != KErrNotFound )
  1650     if ( aDataType.Des8().FindF( KOma2DcfContentType ) != KErrNotFound )
  1714         {
  1651         {
  1715         if ( NeedsToReplaceDcf2Extension( aFileName ) )
  1652         if ( NeedsToReplaceDcf2Extension( aFileName ) )