browserutilities/downloadmgr/DownloadMgrUiLib/Src/CDownloadMgrUiDownloadsList.cpp
changeset 1 7c90e6132015
parent 0 dd21522fd290
child 10 a359256acfc6
equal deleted inserted replaced
0:dd21522fd290 1:7c90e6132015
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
       
    21 #include <platform/mw/Browser_platform_variant.hrh>
    21 #include    "CDownloadMgrUiDownloadsList.h"
    22 #include    "CDownloadMgrUiDownloadsList.h"
    22 #include    "CDownloadMgrUiLibRegistry.h"
    23 #include    "CDownloadMgrUiLibRegistry.h"
    23 #include    "CDownloadMgrUiDownloadMenu.h"
    24 #include    "CDownloadMgrUiDownloadMenu.h"
    24 #include    "CDownloadsListArray.h"
    25 #include    "CDownloadsListArray.h"
    25 #include    "CDownloadsListDlg.h"
    26 #include    "CDownloadsListDlg.h"
    37 #include    <eikmenup.h>
    38 #include    <eikmenup.h>
    38 #include    <gulicon.h>
    39 #include    <gulicon.h>
    39 #include    <uikon.hrh>
    40 #include    <uikon.hrh>
    40 #include    <AknServerApp.h>
    41 #include    <AknServerApp.h>
    41 #include    <UriUtils.h>
    42 #include    <UriUtils.h>
       
    43 
       
    44 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
    42 #include    <MGXFileManagerFactory.h>
    45 #include    <MGXFileManagerFactory.h>
    43 #include    <CMGXFileManager.h>
    46 #include    <CMGXFileManager.h>
    44 #include    <MediaGalleryUID.h>  //Gallery UIDs
    47 #include    <MediaGalleryUID.h>  //Gallery UIDs
       
    48 #endif
       
    49 
    45 #include    <DocumentHandler.h>
    50 #include    <DocumentHandler.h>
    46 #include    "bautils.h"
    51 #include    "bautils.h"
    47 #include    <BrowserUiSDKCRKeys.h>
    52 #include    <BrowserUiSDKCRKeys.h>
    48 #include    <aknnotewrappers.h> 
    53 #include    <aknnotewrappers.h> 
    49 #include    <StringLoader.h>
    54 #include    <StringLoader.h>
    52 
    57 
    53 
    58 
    54 
    59 
    55 // CONSTANTS
    60 // CONSTANTS
    56 const TInt KUpdateProgressInfoInterval   = 2*1000000;  // 2 sec
    61 const TInt KUpdateProgressInfoInterval   = 2*1000000;  // 2 sec
       
    62 
       
    63 const TInt KMostRecentSort  = 2;  // Most Recent Sort in File Manager
       
    64 const TInt KLauchStandAlone = 1;  // Launch the File Manager in Stand Alone Mode
    57 
    65 
    58 _LIT8(KSisxContentType, "x-epoc/x-sisx-app");
    66 _LIT8(KSisxContentType, "x-epoc/x-sisx-app");
    59 
    67 
    60 // FORWARD DECLARATIONS
    68 // FORWARD DECLARATIONS
    61 class CDownloadsListExecuter;
    69 class CDownloadsListExecuter;
   703 //
   711 //
   704 CDownloadMgrUiDownloadsList::CDownloadMgrUiDownloadsList
   712 CDownloadMgrUiDownloadsList::CDownloadMgrUiDownloadsList
   705     ( CDownloadMgrUiLibRegistry& aRegistryModel )
   713     ( CDownloadMgrUiLibRegistry& aRegistryModel )
   706 :   CDownloadMgrUiBase( aRegistryModel ),
   714 :   CDownloadMgrUiBase( aRegistryModel ),
   707     iIsVisible( EFalse ),
   715     iIsVisible( EFalse ),
   708     iIsCancelInProgress( EFalse )
   716     iIsCancelInProgress( EFalse ),
       
   717     iPlatformSupportsGallery( EFalse )
   709     {
   718     {
   710     }
   719     }
   711 
   720 
   712 // -----------------------------------------------------------------------------
   721 // -----------------------------------------------------------------------------
   713 // CDownloadMgrUiDownloadsList::ConstructL
   722 // CDownloadMgrUiDownloadsList::ConstructL
   729     CLOG_WRITE(" iEventHandlerArray");
   738     CLOG_WRITE(" iEventHandlerArray");
   730 	iIsTimerStarted = EFalse;
   739 	iIsTimerStarted = EFalse;
   731 	iProgressiveDownload = EFalse;
   740 	iProgressiveDownload = EFalse;
   732 	iRegistryModel.DownloadMgr().GetBoolAttribute(EDlMgrProgressiveDownload, iProgressiveDownload);
   741 	iRegistryModel.DownloadMgr().GetBoolAttribute(EDlMgrProgressiveDownload, iProgressiveDownload);
   733     CLOG_LEAVEFN("CDownloadMgrUiDownloadsList::ConstructL");
   742     CLOG_LEAVEFN("CDownloadMgrUiDownloadsList::ConstructL");
       
   743     
       
   744     //whether the platform supports gallery app or not; defined in browser_platfrom_variant.hrh
       
   745     #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
       
   746     iPlatformSupportsGallery = ETrue;
       
   747     #endif
       
   748   
   734     }
   749     }
   735 
   750 
   736 // -----------------------------------------------------------------------------
   751 // -----------------------------------------------------------------------------
   737 // CDownloadMgrUiDownloadsList::NewL
   752 // CDownloadMgrUiDownloadsList::NewL
   738 // -----------------------------------------------------------------------------
   753 // -----------------------------------------------------------------------------
  1872     			       result = BaflUtils::DeleteFile( rfs, fileNamePtr );
  1887     			       result = BaflUtils::DeleteFile( rfs, fileNamePtr );
  1873     			       }
  1888     			       }
  1874     			   CleanupStack::PopAndDestroy( &rfs );
  1889     			   CleanupStack::PopAndDestroy( &rfs );
  1875 
  1890 
  1876     			   // Notify Media Gallery about new media file
  1891     			   // Notify Media Gallery about new media file
       
  1892     			   
       
  1893     			#ifdef BRDO_APP_GALLERY_SUPPORTED_FF   
       
  1894     			
  1877     			   CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL(
  1895     			   CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL(
  1878     			       CEikonEnv::Static()->FsSession() );
  1896     			       CEikonEnv::Static()->FsSession() );
  1879     			   if( fileNamePtr.Length() > 0 )
  1897     			   if( fileNamePtr.Length() > 0 )
  1880     			       {
  1898     			       {
  1881     			       TRAP_IGNORE( mgFileManager->UpdateL( fileNamePtr ) );
  1899     			       TRAP_IGNORE( mgFileManager->UpdateL( fileNamePtr ) );
  1883     			       }
  1901     			       }
  1884     			   else
  1902     			   else
  1885     			       {
  1903     			       {
  1886     			       TRAP_IGNORE( mgFileManager->UpdateL() );
  1904     			       TRAP_IGNORE( mgFileManager->UpdateL() );
  1887     			       }
  1905     			       }
  1888 
  1906     			 
  1889     			   delete mgFileManager;
  1907     			   delete mgFileManager;
  1890     			   mgFileManager = NULL;
  1908     			   mgFileManager = NULL;
       
  1909     			 
       
  1910     			 #else
       
  1911     			 
       
  1912     			  if( fileNamePtr.Length() > 0 )
       
  1913     			       {
       
  1914     			       TRAP_IGNORE( iUiUtils->UpdateDCFRepositoryL( fileNamePtr ) );
       
  1915     			       }
       
  1916     			 
       
  1917     			 #endif  
  1891     			   
  1918     			   
  1892                 	}
  1919                 	}
  1893                  else
  1920                  else
  1894     	           	{
  1921     	           	{
  1895     	           	DeleteDownloadL( currDownload );
  1922     	           	DeleteDownloadL( currDownload );
  2002         	break;
  2029         	break;
  2003         	}
  2030         	}
  2004 
  2031 
  2005         case EDownloadsListCmdGallery:
  2032         case EDownloadsListCmdGallery:
  2006             {
  2033             {
       
  2034             
       
  2035 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
       
  2036             
  2007             TVwsViewId id = TVwsViewId(
  2037             TVwsViewId id = TVwsViewId(
  2008                 TUid::Uid( KMediaGalleryUID3 ),
  2038                 TUid::Uid( KMediaGalleryUID3 ),
  2009                 TUid::Uid( KMediaGalleryListViewUID ) );
  2039                 TUid::Uid( KMediaGalleryListViewUID ) );
  2010 
  2040 
  2011             // By default, custom message is empty
  2041             // By default, custom message is empty
  2013 
  2043 
  2014             CEikonEnv::Static()->EikAppUi()->ActivateViewL( 
  2044             CEikonEnv::Static()->EikAppUi()->ActivateViewL( 
  2015                     id, 
  2045                     id, 
  2016                     TUid::Uid( KMediaGalleryCmdMoveFocusToAllFilesTab ),
  2046                     TUid::Uid( KMediaGalleryCmdMoveFocusToAllFilesTab ),
  2017                     customMessage );
  2047                     customMessage );
       
  2048 #endif                    
  2018             break;
  2049             break;
  2019             }
  2050             }
  2020       
  2051       
  2021         case EDownloadsListCmdFileManager:
  2052         case EDownloadsListCmdFileManager:
  2022             {
  2053             {
       
  2054  
       
  2055             if ( iPlatformSupportsGallery )
       
  2056                 {
       
  2057             	LaunchFileManagerApplication();
       
  2058                 }
       
  2059             else
       
  2060                 {
       
  2061             	CAiwServiceHandler* serviceHandler = CAiwServiceHandler::NewL();
       
  2062                 serviceHandler->AttachL( R_DMUL_FILEMANAGER_AIW_INTEREST );
  2023             
  2063             
  2024             TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
  2064                 CAiwGenericParamList* inParams = CAiwGenericParamList::NewLC();
  2025             CRepository *repository=CRepository::NewL(KCRUidBrowser);
  2065              
  2026             TInt fileManagerId;
  2066                 //get the destination file path
  2027             User::LeaveIfError(repository->Get(KFileManagerUid , fileManagerId ));
  2067                 HBufC* fileName = HBufC::NewLC( KMaxPath );
  2028             TUid id = TUid::Uid(fileManagerId);
  2068                 TPtr fileNamePtr = fileName->Des();
  2029             TApaTask task = taskList.FindApp( id );
  2069                 User::LeaveIfError ( currDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) );
  2030             if ( task.Exists() )
  2070                
  2031             {
  2071                 // Locate the last '\\' character and remove the file name so that we will get the folder name
  2032             task.BringToForeground();
  2072                 TInt len = fileNamePtr.LocateReverse('\\');
  2033             }
  2073                 TPtr ptr = fileNamePtr.LeftTPtr(len + 1);
  2034             else 
  2074             
  2035             {
  2075                 // Append the directory name to be opened
  2036             RApaLsSession appArcSession;
  2076                 inParams->AppendL(TAiwGenericParam(EGenericParamDir, TAiwVariant( ptr ) ) );
  2037             User::LeaveIfError( appArcSession.Connect() );
  2077                 //Append the sort method
  2038             CleanupClosePushL( appArcSession );
  2078                 inParams->AppendL(TAiwGenericParam(EGenericParamDir, TAiwVariant( KMostRecentSort ) ) );
  2039             TThreadId id1;
  2079                 //Append to define whether to open in standalone mode
  2040             User::LeaveIfError( appArcSession.StartDocument( KNullDesC, id, id1 ) );  
  2080                 inParams->AppendL(TAiwGenericParam(EGenericParamDir, TAiwVariant( KLauchStandAlone ) ) );
  2041             CleanupStack::PopAndDestroy( &appArcSession );
  2081     
  2042             }
  2082                 TRAPD( err, serviceHandler->ExecuteServiceCmdL( KAiwCmdEdit, *inParams, serviceHandler->OutParamListL() ));
       
  2083             
       
  2084     	   		CleanupStack::PopAndDestroy( fileName );
       
  2085             	CleanupStack::PopAndDestroy( inParams );
       
  2086         	
       
  2087         	    delete serviceHandler;
       
  2088         	    
       
  2089         	    //if there is any error, open the file manager in root folder
       
  2090                 if (err != KErrNone)
       
  2091           	        {
       
  2092           	        LaunchFileManagerApplication();
       
  2093            		    }
       
  2094                 }
       
  2095   
  2043             break;
  2096             break;
  2044             }
  2097             }
  2045          
  2098          
  2046         default:
  2099         default:
  2047             {
  2100             {
  2048             break;
  2101             break;
  2049             }
  2102             }
  2050         }
  2103         }
  2051     }
  2104     }
       
  2105     
       
  2106     
       
  2107 // -----------------------------------------------------------------------------
       
  2108 // CDownloadMgrUiDownloadsList::LaunchFileManagerApplication
       
  2109 // -----------------------------------------------------------------------------
       
  2110 //
       
  2111 
       
  2112 void CDownloadMgrUiDownloadsList::LaunchFileManagerApplication()
       
  2113 {
       
  2114 	
       
  2115     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
  2116     CRepository *repository=CRepository::NewL(KCRUidBrowser);
       
  2117     TInt fileManagerId;
       
  2118     User::LeaveIfError(repository->Get(KFileManagerUid , fileManagerId ));
       
  2119     TUid id = TUid::Uid(fileManagerId);
       
  2120     TApaTask task = taskList.FindApp( id );
       
  2121     if ( task.Exists() )
       
  2122         {
       
  2123         task.BringToForeground();
       
  2124         }
       
  2125     else 
       
  2126         {
       
  2127         RApaLsSession appArcSession;
       
  2128         User::LeaveIfError( appArcSession.Connect() );
       
  2129         CleanupClosePushL( appArcSession );
       
  2130         TThreadId id1;
       
  2131         User::LeaveIfError( appArcSession.StartDocument( KNullDesC, id, id1 ) );  
       
  2132         CleanupStack::PopAndDestroy( &appArcSession );
       
  2133         }
       
  2134 	
       
  2135 }
       
  2136 
  2052 
  2137 
  2053 // -----------------------------------------------------------------------------
  2138 // -----------------------------------------------------------------------------
  2054 // CDownloadMgrUiDownloadsList::DynInitMenuPaneL
  2139 // CDownloadMgrUiDownloadsList::DynInitMenuPaneL
  2055 // -----------------------------------------------------------------------------
  2140 // -----------------------------------------------------------------------------
  2056 //
  2141 //
  2165             {
  2250             {
  2166             aMenuPane->DeleteMenuItem( EDownloadsListCmdFileManager );    
  2251             aMenuPane->DeleteMenuItem( EDownloadsListCmdFileManager );    
  2167             }
  2252             }
  2168             
  2253             
  2169         // For any gallery supported download,  "go to gallery" option should be displayed in the download list option when the download completes     
  2254         // For any gallery supported download,  "go to gallery" option should be displayed in the download list option when the download completes     
  2170         if ( !( isCompleted && s60Supported && gallerySupported ) )
  2255         
       
  2256         
       
  2257         if ( (!( isCompleted && s60Supported && gallerySupported ) ) || (!iPlatformSupportsGallery) )
  2171             {
  2258             {
  2172 			aMenuPane->DeleteMenuItem( EDownloadsListCmdGallery );
  2259 			aMenuPane->DeleteMenuItem( EDownloadsListCmdGallery );
  2173     		}
  2260     		}
  2174     		
  2261     		
  2175         if ( !( isCompleted && s60Supported && gallerySupported && 
  2262         if ( !( isCompleted && s60Supported && gallerySupported && 
  2282         CLOG_WRITE_FORMAT(" download count: %d",downloadCount);
  2369         CLOG_WRITE_FORMAT(" download count: %d",downloadCount);
  2283         
  2370         
  2284         if ( !( 1 < downloadCount ) )
  2371         if ( !( 1 < downloadCount ) )
  2285             {
  2372             {
  2286             aMenuPane->DeleteMenuItem( EDownloadsListCmdCancelAll );
  2373             aMenuPane->DeleteMenuItem( EDownloadsListCmdCancelAll );
  2287             }                               
  2374             }              
  2288        	
  2375                              
  2289         if ( isCompleted && gallerySupported && s60Supported )
  2376        	if ( iPlatformSupportsGallery )
  2290             {
  2377        	    {
  2291             aMenuPane->DeleteMenuItem( EDownloadsListCmdFileManager );
  2378        		if ( isCompleted && gallerySupported && s60Supported )
  2292             }  
  2379                 {
       
  2380                 aMenuPane->DeleteMenuItem( EDownloadsListCmdFileManager );
       
  2381                 }
       
  2382        	    }
  2293         }
  2383         }
  2294         
  2384         
  2295     if ( wasCompleted && !isThemeType ) 
  2385     if ( wasCompleted && !isThemeType ) 
  2296         {
  2386         {
  2297         InitializeAIWPlugInMenusL( aResourceId, aMenuPane, currDownload );		
  2387         InitializeAIWPlugInMenusL( aResourceId, aMenuPane, currDownload );