commonuis/CommonUi/src/DocDefaultHandler.cpp
branchRCL_3
changeset 20 d48ab3b357f1
parent 19 aecbbf00d063
child 21 978afdc0236f
equal deleted inserted replaced
19:aecbbf00d063 20:d48ab3b357f1
    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>
    38 #include <driveinfo.h>      //DriveInfo
    39 #include <driveinfo.h>      //DriveInfo
       
    40 #include <AknCommonDialogsDynMem.h>
    39 #include <coemain.h>
    41 #include <coemain.h>
       
    42 #include <rsfwmountman.h>
       
    43 #else
       
    44 #include "CAknMemorySelectionDialog.h" // CAknMemorySelectionDialog
    40 #endif
    45 #endif
    41 
    46 
    42 #include "pathinfo.h"               // PathInfo
    47 #include "pathinfo.h"               // PathInfo
    43 #include <featmgr.h>                // FeatureManager
    48 #include <featmgr.h>                // FeatureManager
    44 
    49 
    99         iSavedAsTemp( EFalse ),
   104         iSavedAsTemp( EFalse ),
   100         iServiceMode( aServiceMode ),
   105         iServiceMode( aServiceMode ),
   101         iStatus( KErrNone ),
   106         iStatus( KErrNone ),
   102         iUid( aUid ),
   107         iUid( aUid ),
   103         iOpenService( NULL ),
   108         iOpenService( NULL ),
   104         iMMCSaveAllowed ( ETrue )
   109         iMMCSaveAllowed ( ETrue ),
       
   110         iFileHandleSet( EFalse )
   105     {
   111     {
   106     }
   112     }
   107     
   113     
   108 // Destructor  
   114 // Destructor  
   109 //
   115 //
   542         return SetAndReturnStatus( KErrBadName );
   548         return SetAndReturnStatus( KErrBadName );
   543         
   549         
   544     iSourceFile = aFileName;
   550     iSourceFile = aFileName;
   545     return SetAndReturnStatus( KErrNone );
   551     return SetAndReturnStatus( KErrNone );
   546     }
   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 	}
   547 
   560 
   548 // ---------------------------------------------------------
   561 // ---------------------------------------------------------
   549 // CDocDefaultHandler::SetDestName()
   562 // CDocDefaultHandler::SetDestName()
   550 // Check the name and set iDestFile.
   563 // Check the name and set iDestFile.
   551 // ---------------------------------------------------------
   564 // ---------------------------------------------------------
  1121                     return KErrCancel;
  1134                     return KErrCancel;
  1122                     }
  1135                     }
  1123                 }
  1136                 }
  1124             path.Copy( iRootPath );
  1137             path.Copy( iRootPath );
  1125             }
  1138             }
       
  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
  1126         else 
  1183         else 
  1127             {
  1184             {
  1128             path.Copy( PathInfo::PhoneMemoryRootPath() );
  1185             path.Copy( PathInfo::PhoneMemoryRootPath() );
  1129             }
  1186             }
  1130 
  1187 
  1606         {
  1663         {
  1607         TInt ret = EFalse;
  1664         TInt ret = EFalse;
  1608         TBuf<6> ext;
  1665         TBuf<6> ext;
  1609 
  1666 
  1610 		CContent* content = NULL;
  1667 		CContent* content = NULL;
  1611         TRAPD(err,content = CContent::NewL( iSourceFile ));
  1668 		if( iFileHandleSet )
  1612 
  1669 			{
  1613 		if(err == KErrNone)
  1670 		    content = CContent::NewL( iFile );
  1614 			{	
  1671 		    iFile.Close();
  1615 			CleanupStack::PushL(content);
  1672 		    iFileHandleSet = EFalse;
  1616 			content->GetAttribute( ContentAccess::EIsProtected, ret  );
  1673 			}
  1617 			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 )
  1618 				{
  1690 				{
  1619 				content->GetAttribute( EFileType, ret );
  1691 				// change extension to .dcf
  1620             
  1692 				ext.Copy( KOma1DcfExtension );         
  1621 				#ifdef _DEBUG             
  1693 				ReplaceExtension( aFileName, ext );            
  1622 				RDebug::Print( _L("DocumentHandler: CDocDefaultHandler::CheckFileNameExtensionL: GetAttribute called, ret =%d"), ret);
  1694 				CleanupStack::PopAndDestroy();  // content
  1623 				#endif 
  1695 				return;            
  1624     
  1696 				}
  1625 				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 ) )
  1626 					{
  1702 					{
  1627 					// change extension to .dcf
  1703 				    ReplaceExtension( aFileName, ext );
  1628 					ext.Copy( KOma1DcfExtension );         
  1704 	                }
  1629 					ReplaceExtension( aFileName, ext );            
  1705 		        CleanupStack::PopAndDestroy();  // content
  1630 					CleanupStack::PopAndDestroy();  // content
  1706 			    return;            
  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 				}
  1707 				}
  1645 			CleanupStack::PopAndDestroy();  // content
       
  1646 			}
  1708 			}
  1647         }
  1709 		CleanupStack::PopAndDestroy();  // content
       
  1710 		}
  1648 
  1711 
  1649     //if mime type=oma 2 dcf check extension separately
  1712     //if mime type=oma 2 dcf check extension separately
  1650     if ( aDataType.Des8().FindF( KOma2DcfContentType ) != KErrNotFound )
  1713     if ( aDataType.Des8().FindF( KOma2DcfContentType ) != KErrNotFound )
  1651         {
  1714         {
  1652         if ( NeedsToReplaceDcf2Extension( aFileName ) )
  1715         if ( NeedsToReplaceDcf2Extension( aFileName ) )