browserutilities/downloadmgr/DownloadMgrUiLib/Src/CDownloadMgrUiDownloadsList.cpp
changeset 65 5bfc169077b2
parent 42 d39add9822e2
child 68 92a765b5b3e7
equal deleted inserted replaced
42:d39add9822e2 65:5bfc169077b2
    13 *
    13 *
    14 * Description:  Supports Download Menu and Downloads List
    14 * Description:  Supports Download Menu and Downloads List
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 
       
    19 
    18 // INCLUDE FILES
    20 // INCLUDE FILES
    19 #include    <browser_platform_variant.hrh>
    21 //#include <platform/mw/Browser_platform_variant.hrh>
    20 #include    <cdownloadmgruidownloadslist.h>
    22 #include    <Browser_platform_variant.hrh>
    21 #include    <cdownloadmgruilibregistry.h>
    23 #include    "CDownloadMgrUiDownloadsList.h"
    22 #include    <cdownloadmgruidownloadmenu.h>
    24 #include    "CDownloadMgrUiLibRegistry.h"
       
    25 #include    "CDownloadMgrUiDownloadMenu.h"
    23 #include    "CDownloadsListArray.h"
    26 #include    "CDownloadsListArray.h"
    24 #include    "CDownloadsListDlg.h"
    27 #include    "CDownloadsListDlg.h"
    25 #include    "AsyncEventHandlerArray.h"
    28 #include    "AsyncEventHandlerArray.h"
    26 #include    "DMgrUiLibPanic.h"
    29 #include    "DMgrUiLibPanic.h"
    27 #include    "DownloadMgrUiLib.hrh"
    30 #include    "DownloadMgrUiLib.hrh"
    37 #include    <gulicon.h>
    40 #include    <gulicon.h>
    38 #include    <uikon.hrh>
    41 #include    <uikon.hrh>
    39 #include    <AknServerApp.h>
    42 #include    <AknServerApp.h>
    40 #include    <UriUtils.h>
    43 #include    <UriUtils.h>
    41 
    44 
       
    45 // following line is temporary: AVKON dependency removal
       
    46 #undef BRDO_APP_GALLERY_SUPPORTED_FF
       
    47 
    42 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
    48 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
    43 #include    <MGXFileManagerFactory.h>
    49 #include    <MGXFileManagerFactory.h>
    44 #include    <CMGXFileManager.h>
    50 #include    <CMGXFileManager.h>
    45 #include    <MediaGalleryUID.h>  //Gallery UIDs
    51 #include    <MediaGalleryUID.h>  //Gallery UIDs
    46 #endif
    52 #endif
    47 
    53 
    48 #include    <DocumentHandler.h>
    54 #include    <DocumentHandler.h>
    49 #include    "bautils.h"
    55 #include    "bautils.h"
    50 #include    <browseruisdkcrkeys.h>
    56 #include    <BrowserUiSDKCRKeys.h>
    51 #include    <aknnotewrappers.h> 
    57 #include    <aknnotewrappers.h>
    52 #include    <StringLoader.h>
    58 #include    <StringLoader.h>
    53 #include    <apgtask.h>
    59 #include    <apgtask.h>
    54 
    60 
    55 
    61 
    56 
    62 
    66 // FORWARD DECLARATIONS
    72 // FORWARD DECLARATIONS
    67 class CDownloadsListExecuter;
    73 class CDownloadsListExecuter;
    68 
    74 
    69 // LOCAL FUNCTION PROTOTYPES
    75 // LOCAL FUNCTION PROTOTYPES
    70 
    76 
    71 /** 
    77 /**
    72 * Find the given download in the model and give back the ui data and the index.
    78 * Find the given download in the model and give back the ui data and the index.
    73 * It returns 0, if the given download is not found in aListModel and aIndex is set to KErrNotFound!
    79 * It returns 0, if the given download is not found in aListModel and aIndex is set to KErrNotFound!
    74 */
    80 */
    75 inline TDownloadUiData* FindDlUiData( CDownloadsListArray& aListModel, 
    81 inline TDownloadUiData* FindDlUiData( CDownloadsListArray& aListModel,
    76                                        RHttpDownload& aDownload,
    82                                        RHttpDownload& aDownload,
    77                                        TInt& aIndex );
    83                                        TInt& aIndex );
    78 
    84 
    79 #ifdef __WINS__
    85 #ifdef __WINS__
    80 TInt AskIapIdL( TUint32& aId );
    86 TInt AskIapIdL( TUint32& aId );
    85 */
    91 */
    86 NONSHARABLE_CLASS( CDownloadsListExtension ) : public CBase,
    92 NONSHARABLE_CLASS( CDownloadsListExtension ) : public CBase,
    87                                                public MDownloadHandlerObserver
    93                                                public MDownloadHandlerObserver
    88     {
    94     {
    89     public:  // Constructors and destructor
    95     public:  // Constructors and destructor
    90         
    96 
    91         /**
    97         /**
    92         * Two-phased constructor.
    98         * Two-phased constructor.
    93         */
    99         */
    94         static CDownloadsListExtension* NewL
   100         static CDownloadsListExtension* NewL
    95              ( CDownloadMgrUiDownloadsList& aDownloadsList );
   101              ( CDownloadMgrUiDownloadsList& aDownloadsList );
    96         
   102 
    97         /**
   103         /**
    98         * Destructor.
   104         * Destructor.
    99         */
   105         */
   100         virtual ~CDownloadsListExtension();
   106         virtual ~CDownloadsListExtension();
   101 
   107 
   152 
   158 
   153         /**
   159         /**
   154         * Start a progress info timer update.
   160         * Start a progress info timer update.
   155         */
   161         */
   156 		void StartProgressTimer();
   162 		void StartProgressTimer();
   157         
   163 
   158     protected: // Constructors
   164     protected: // Constructors
   159 
   165 
   160         /**
   166         /**
   161         * C++ default constructor.
   167         * C++ default constructor.
   162         */
   168         */
   185 		CPeriodic*		iUpdateProgressInfoTimer;
   191 		CPeriodic*		iUpdateProgressInfoTimer;
   186 
   192 
   187 		/*
   193 		/*
   188 		* callback function for the UpdateProgressInfo
   194 		* callback function for the UpdateProgressInfo
   189 		*/
   195 		*/
   190 		static TInt		UpdateProgressInfoCallback(TAny* aPtr); 
   196 		static TInt		UpdateProgressInfoCallback(TAny* aPtr);
   191     };
   197     };
   192 
   198 
   193 
   199 
   194 
   200 
   195 NONSHARABLE_CLASS( CDownloadsListExecuter ) : public CActive
   201 NONSHARABLE_CLASS( CDownloadsListExecuter ) : public CActive
   196     {
   202     {
   197     public:  // Constructors and destructor
   203     public:  // Constructors and destructor
   198         
   204 
   199         /**
   205         /**
   200         * Two-phased constructor.
   206         * Two-phased constructor.
   201         */
   207         */
   202         static CDownloadsListExecuter* NewL( CDownloadMgrUiDownloadsList& aDownloadsList, 
   208         static CDownloadsListExecuter* NewL( CDownloadMgrUiDownloadsList& aDownloadsList,
   203                                              CDownloadsListExecuter** aReferer );
   209                                              CDownloadsListExecuter** aReferer );
   204         
   210 
   205         /**
   211         /**
   206         * Two-phased constructor.
   212         * Two-phased constructor.
   207         */
   213         */
   208         static CDownloadsListExecuter* NewL( CDownloadMgrUiDownloadsList& aDownloadsList, 
   214         static CDownloadsListExecuter* NewL( CDownloadMgrUiDownloadsList& aDownloadsList,
   209                                              CDownloadsListExecuter** aReferer, 
   215                                              CDownloadsListExecuter** aReferer,
   210                                              RHttpDownload& aHighlightDl );
   216                                              RHttpDownload& aHighlightDl );
   211         
   217 
   212         /**
   218         /**
   213         * Destructor.
   219         * Destructor.
   214         */
   220         */
   215         virtual ~CDownloadsListExecuter();
   221         virtual ~CDownloadsListExecuter();
   216 
   222 
   217     public: // New
   223     public: // New
   218     
   224 
   219         /**
   225         /**
   220         * Invoke RunL.
   226         * Invoke RunL.
   221         */
   227         */
   222         void Start();
   228         void Start();
   223         
   229 
   224         /**
   230         /**
   225         * Check if the dialog already exists.
   231         * Check if the dialog already exists.
   226         */
   232         */
   227         TBool DialogExists() const;
   233         TBool DialogExists() const;
   228         
   234 
   229         /**
   235         /**
   230         * Get a reference. Panics if null!
   236         * Get a reference. Panics if null!
   231         */
   237         */
   232         CDownloadsListDlg& Dialog() const;
   238         CDownloadsListDlg& Dialog() const;
   233         
   239 
   234         /**
   240         /**
   235         * Execute the dialog now (wait dialog).
   241         * Execute the dialog now (wait dialog).
   236         */
   242         */
   237         void ExecuteLD();
   243         void ExecuteLD();
   238         
   244 
   239     private: // Constructors
   245     private: // Constructors
   240 
   246 
   241         /**
   247         /**
   242         * C++ default constructor.
   248         * C++ default constructor.
   243         */
   249         */
   244         CDownloadsListExecuter( CDownloadMgrUiDownloadsList& aDownloadsList, 
   250         CDownloadsListExecuter( CDownloadMgrUiDownloadsList& aDownloadsList,
   245                                 CDownloadsListExecuter** aReferer, RHttpDownload* aHighlightDl );
   251                                 CDownloadsListExecuter** aReferer, RHttpDownload* aHighlightDl );
   246 
   252 
   247         /**
   253         /**
   248         * By default Symbian 2nd phase constructor is private.
   254         * By default Symbian 2nd phase constructor is private.
   249         */
   255         */
   262         CDownloadsListDlg*          iDialog; ///< Not owned - only reference.
   268         CDownloadsListDlg*          iDialog; ///< Not owned - only reference.
   263         CDownloadsListExecuter**    iReferer;
   269         CDownloadsListExecuter**    iReferer;
   264         RHttpDownload* iHighlightDl; ///< Not owned.
   270         RHttpDownload* iHighlightDl; ///< Not owned.
   265         TBool iProgressiveDownload;
   271         TBool iProgressiveDownload;
   266     };
   272     };
   267     
   273 
   268     
   274 
   269     
   275 
   270 // -----------------------------------------------------------------------------
   276 // -----------------------------------------------------------------------------
   271 // CDownloadsListExecuter::CDownloadsListExecuter
   277 // CDownloadsListExecuter::CDownloadsListExecuter
   272 // -----------------------------------------------------------------------------
   278 // -----------------------------------------------------------------------------
   273 //
   279 //
   274 CDownloadsListExecuter::CDownloadsListExecuter
   280 CDownloadsListExecuter::CDownloadsListExecuter
   275     ( CDownloadMgrUiDownloadsList& aDownloadsList, 
   281     ( CDownloadMgrUiDownloadsList& aDownloadsList,
   276       CDownloadsListExecuter** aReferer, 
   282       CDownloadsListExecuter** aReferer,
   277       RHttpDownload* aHighlightDl ) 
   283       RHttpDownload* aHighlightDl )
   278 :   CActive( CActive::EPriorityHigh ), // EPriorityHigh to be visible ASAP.
   284 :   CActive( CActive::EPriorityHigh ), // EPriorityHigh to be visible ASAP.
   279     iDownloadsList( aDownloadsList ), 
   285     iDownloadsList( aDownloadsList ),
   280     iReferer( aReferer ),
   286     iReferer( aReferer ),
   281     iHighlightDl( aHighlightDl )
   287     iHighlightDl( aHighlightDl )
   282     {
   288     {
   283     CActiveScheduler::Add( this );
   289     CActiveScheduler::Add( this );
   284     }
   290     }
   297 // -----------------------------------------------------------------------------
   303 // -----------------------------------------------------------------------------
   298 //
   304 //
   299 CDownloadsListExecuter* CDownloadsListExecuter::NewL
   305 CDownloadsListExecuter* CDownloadsListExecuter::NewL
   300     ( CDownloadMgrUiDownloadsList& aDownloadsList, CDownloadsListExecuter** aReferer )
   306     ( CDownloadMgrUiDownloadsList& aDownloadsList, CDownloadsListExecuter** aReferer )
   301     {
   307     {
   302     CDownloadsListExecuter* self = 
   308     CDownloadsListExecuter* self =
   303         new (ELeave) CDownloadsListExecuter( aDownloadsList, aReferer, 0 );
   309         new (ELeave) CDownloadsListExecuter( aDownloadsList, aReferer, 0 );
   304     CleanupStack::PushL( self );
   310     CleanupStack::PushL( self );
   305     self->ConstructL();
   311     self->ConstructL();
   306     CleanupStack::Pop();
   312     CleanupStack::Pop();
   307     return self;
   313     return self;
   310 // -----------------------------------------------------------------------------
   316 // -----------------------------------------------------------------------------
   311 // CDownloadsListExecuter::NewL
   317 // CDownloadsListExecuter::NewL
   312 // -----------------------------------------------------------------------------
   318 // -----------------------------------------------------------------------------
   313 //
   319 //
   314 CDownloadsListExecuter* CDownloadsListExecuter::NewL
   320 CDownloadsListExecuter* CDownloadsListExecuter::NewL
   315     ( CDownloadMgrUiDownloadsList& aDownloadsList, 
   321     ( CDownloadMgrUiDownloadsList& aDownloadsList,
   316       CDownloadsListExecuter** aReferer, 
   322       CDownloadsListExecuter** aReferer,
   317       RHttpDownload& aHighlightDl )
   323       RHttpDownload& aHighlightDl )
   318     {
   324     {
   319     CDownloadsListExecuter* self = 
   325     CDownloadsListExecuter* self =
   320         new (ELeave) CDownloadsListExecuter
   326         new (ELeave) CDownloadsListExecuter
   321             ( aDownloadsList, aReferer, &aHighlightDl );
   327             ( aDownloadsList, aReferer, &aHighlightDl );
   322     CleanupStack::PushL( self );
   328     CleanupStack::PushL( self );
   323     self->ConstructL();
   329     self->ConstructL();
   324     CleanupStack::Pop();
   330     CleanupStack::Pop();
   378 // -----------------------------------------------------------------------------
   384 // -----------------------------------------------------------------------------
   379 //
   385 //
   380 void CDownloadsListExecuter::ExecuteLD()
   386 void CDownloadsListExecuter::ExecuteLD()
   381     {
   387     {
   382     CLOG_ENTERFN("CDownloadsListExecuter::ExecuteLD");
   388     CLOG_ENTERFN("CDownloadsListExecuter::ExecuteLD");
   383     
   389 
   384     delete iDialog;
   390     delete iDialog;
   385     iDialog = NULL;
   391     iDialog = NULL;
   386     iDialog = CDownloadsListDlg::NewL( iDownloadsList, iProgressiveDownload );
   392     iDialog = CDownloadsListDlg::NewL( iDownloadsList, iProgressiveDownload );
   387     // No leaving functions before ExecuteLD!
   393     // No leaving functions before ExecuteLD!
   388 
   394 
   389     // If there is download that should be highlighted:
   395     // If there is download that should be highlighted:
   390     if ( iHighlightDl )
   396     if ( iHighlightDl )
   391         {
   397         {
   392         iDialog->HighlightDownload( *iHighlightDl );
   398         iDialog->HighlightDownload( *iHighlightDl );
   393         }
   399         }
   394         
   400 
   395     // Execute wait dialog... While it is running, 'this' can be deleted:
   401     // Execute wait dialog... While it is running, 'this' can be deleted:
   396     TBool deleted( EFalse );
   402     TBool deleted( EFalse );
   397     iDeleted = &deleted;
   403     iDeleted = &deleted;
   398     TRAP_IGNORE( iDialog->ExecuteLD() );
   404     TRAP_IGNORE( iDialog->ExecuteLD() );
   399     iDeleted = 0; // No more needed.
   405     iDeleted = 0; // No more needed.
   406         {
   412         {
   407             if( !iDownloadsList.GetDownloadHide() )
   413             if( !iDownloadsList.GetDownloadHide() )
   408                 {
   414                 {
   409                 delete iDialog;
   415                 delete iDialog;
   410                 }
   416                 }
   411            
   417 
   412             iDownloadsList.SetDownloadListHide( EFalse );
   418             iDownloadsList.SetDownloadListHide( EFalse );
   413       
   419 
   414             iDialog = NULL;
   420             iDialog = NULL;
   415             // Reset owner pointer to this object.
   421             // Reset owner pointer to this object.
   416        	    if ( iReferer )
   422        	    if ( iReferer )
   417             {
   423             {
   418             *iReferer = 0;
   424             *iReferer = 0;
   419             CLOG_WRITE(" referer set was to 0");
   425             CLOG_WRITE(" referer set was to 0");
   420             }
   426             }
   421         // and delete this
   427         // and delete this
   422         delete this;
   428         delete this;
   423         }
   429         }
   424         
   430 
   425     CLOG_LEAVEFN("CDownloadsListExecuter::ExecuteLD");
   431     CLOG_LEAVEFN("CDownloadsListExecuter::ExecuteLD");
   426     }
   432     }
   427 
   433 
   428 // -----------------------------------------------------------------------------
   434 // -----------------------------------------------------------------------------
   429 // CDownloadsListExecuter::DoCancel
   435 // CDownloadsListExecuter::DoCancel
   451 // -----------------------------------------------------------------------------
   457 // -----------------------------------------------------------------------------
   452 //
   458 //
   453 TInt CDownloadsListExecuter::RunError(TInt /*aError*/)
   459 TInt CDownloadsListExecuter::RunError(TInt /*aError*/)
   454     {
   460     {
   455     CLOG_ENTERFN("CDownloadsListExecuter::RunError");
   461     CLOG_ENTERFN("CDownloadsListExecuter::RunError");
   456     
   462 
   457     // Reset owner pointer to this object.
   463     // Reset owner pointer to this object.
   458     if ( iReferer )
   464     if ( iReferer )
   459         {
   465         {
   460         *iReferer = 0;
   466         *iReferer = 0;
   461         }
   467         }
   462     delete this;
   468     delete this;
   463     
   469 
   464     CLOG_LEAVEFN("CDownloadsListExecuter::RunError");
   470     CLOG_LEAVEFN("CDownloadsListExecuter::RunError");
   465     return 0;
   471     return 0;
   466     }
   472     }
   467         
   473 
   468 // ============================ MEMBER FUNCTIONS ===============================
   474 // ============================ MEMBER FUNCTIONS ===============================
   469 
   475 
   470 // -----------------------------------------------------------------------------
   476 // -----------------------------------------------------------------------------
   471 // CDownloadsListExtension::CDownloadsListExtension
   477 // CDownloadsListExtension::CDownloadsListExtension
   472 // -----------------------------------------------------------------------------
   478 // -----------------------------------------------------------------------------
   473 //
   479 //
   474 CDownloadsListExtension::CDownloadsListExtension
   480 CDownloadsListExtension::CDownloadsListExtension
   475     ( CDownloadMgrUiDownloadsList& aDownloadsList ) 
   481     ( CDownloadMgrUiDownloadsList& aDownloadsList )
   476 :   iDownloadsList( aDownloadsList ),
   482 :   iDownloadsList( aDownloadsList ),
   477     iIapId( 0 ),
   483     iIapId( 0 ),
   478     iIapIdGotAndSet( ETrue )
   484     iIapIdGotAndSet( ETrue )
   479     {
   485     {
   480     }
   486     }
   494 // -----------------------------------------------------------------------------
   500 // -----------------------------------------------------------------------------
   495 //
   501 //
   496 CDownloadsListExtension* CDownloadsListExtension::NewL
   502 CDownloadsListExtension* CDownloadsListExtension::NewL
   497     ( CDownloadMgrUiDownloadsList& aDownloadsList )
   503     ( CDownloadMgrUiDownloadsList& aDownloadsList )
   498     {
   504     {
   499     CDownloadsListExtension* self = 
   505     CDownloadsListExtension* self =
   500         new (ELeave) CDownloadsListExtension( aDownloadsList );
   506         new (ELeave) CDownloadsListExtension( aDownloadsList );
   501     CleanupStack::PushL( self );
   507     CleanupStack::PushL( self );
   502     self->ConstructL();
   508     self->ConstructL();
   503     CleanupStack::Pop();
   509     CleanupStack::Pop();
   504     return self;
   510     return self;
   573         // Do nothing if visible?
   579         // Do nothing if visible?
   574         CLOG_WRITE(" already visible");
   580         CLOG_WRITE(" already visible");
   575         }
   581         }
   576     else
   582     else
   577         {
   583         {
   578         iDownloadsListExecuter = 
   584         iDownloadsListExecuter =
   579             CDownloadsListExecuter::NewL( iDownloadsList, &iDownloadsListExecuter );
   585             CDownloadsListExecuter::NewL( iDownloadsList, &iDownloadsListExecuter );
   580         iDownloadsListExecuter->ExecuteLD();
   586         iDownloadsListExecuter->ExecuteLD();
   581         }
   587         }
   582 
   588 
   583     CLOG_LEAVEFN("CDownloadsListExtension::DisplayDownloadsListL");
   589     CLOG_LEAVEFN("CDownloadsListExtension::DisplayDownloadsListL");
   596         // Do nothing if visible?
   602         // Do nothing if visible?
   597         CLOG_WRITE(" already visible");
   603         CLOG_WRITE(" already visible");
   598         }
   604         }
   599     else
   605     else
   600         {
   606         {
   601         iDownloadsListExecuter = 
   607         iDownloadsListExecuter =
   602             CDownloadsListExecuter::NewL( iDownloadsList, &iDownloadsListExecuter );
   608             CDownloadsListExecuter::NewL( iDownloadsList, &iDownloadsListExecuter );
   603         iDownloadsListExecuter->Start();
   609         iDownloadsListExecuter->Start();
   604         }
   610         }
   605 
   611 
   606     CLOG_LEAVEFN("CDownloadsListExtension::DisplayDownloadsListAsynchronouslyL");
   612     CLOG_LEAVEFN("CDownloadsListExtension::DisplayDownloadsListAsynchronouslyL");
   682 //
   688 //
   683 void CDownloadsListExtension::StartProgressTimer()
   689 void CDownloadsListExtension::StartProgressTimer()
   684 {
   690 {
   685 	iUpdateProgressInfoTimer->Start(
   691 	iUpdateProgressInfoTimer->Start(
   686 		0,
   692 		0,
   687 		KUpdateProgressInfoInterval,  
   693 		KUpdateProgressInfoInterval,
   688 		TCallBack( UpdateProgressInfoCallback, this ) );
   694 		TCallBack( UpdateProgressInfoCallback, this ) );
   689 }
   695 }
   690 
   696 
   691 
   697 
   692 // -----------------------------------------------------------------------------
   698 // -----------------------------------------------------------------------------
   743     CLOG_WRITE(" iEventHandlerArray");
   749     CLOG_WRITE(" iEventHandlerArray");
   744 	iIsTimerStarted = EFalse;
   750 	iIsTimerStarted = EFalse;
   745 	iProgressiveDownload = EFalse;
   751 	iProgressiveDownload = EFalse;
   746 	iRegistryModel.DownloadMgr().GetBoolAttribute(EDlMgrProgressiveDownload, iProgressiveDownload);
   752 	iRegistryModel.DownloadMgr().GetBoolAttribute(EDlMgrProgressiveDownload, iProgressiveDownload);
   747     CLOG_LEAVEFN("CDownloadMgrUiDownloadsList::ConstructL");
   753     CLOG_LEAVEFN("CDownloadMgrUiDownloadsList::ConstructL");
   748     
   754 
   749     //whether the platform supports gallery app or not; defined in browser_platfrom_variant.hrh
   755     //whether the platform supports gallery app or not; defined in browser_platfrom_variant.hrh
   750     #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
   756     #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
   751     iPlatformSupportsGallery = ETrue;
   757     iPlatformSupportsGallery = ETrue;
   752     #endif
   758     #endif
   753   
   759 
   754     }
   760     }
   755 
   761 
   756 // -----------------------------------------------------------------------------
   762 // -----------------------------------------------------------------------------
   757 // CDownloadMgrUiDownloadsList::NewL
   763 // CDownloadMgrUiDownloadsList::NewL
   758 // -----------------------------------------------------------------------------
   764 // -----------------------------------------------------------------------------
   759 //
   765 //
   760 CDownloadMgrUiDownloadsList* CDownloadMgrUiDownloadsList::NewL
   766 CDownloadMgrUiDownloadsList* CDownloadMgrUiDownloadsList::NewL
   761 ( CDownloadMgrUiLibRegistry& aRegistryModel )
   767 ( CDownloadMgrUiLibRegistry& aRegistryModel )
   762     {
   768     {
   763     CDownloadMgrUiDownloadsList* self = 
   769     CDownloadMgrUiDownloadsList* self =
   764         new ( ELeave ) CDownloadMgrUiDownloadsList( aRegistryModel );
   770         new ( ELeave ) CDownloadMgrUiDownloadsList( aRegistryModel );
   765     CleanupStack::PushL( self );
   771     CleanupStack::PushL( self );
   766     self->ConstructL();
   772     self->ConstructL();
   767     CleanupStack::Pop();
   773     CleanupStack::Pop();
   768     return self;
   774     return self;
   791     CLOG_WRITE(" iDownloadMenu");
   797     CLOG_WRITE(" iDownloadMenu");
   792     // iExtension should be the last deleted.
   798     // iExtension should be the last deleted.
   793     delete iExtension;
   799     delete iExtension;
   794     iExtension = 0;
   800     iExtension = 0;
   795     CLOG_WRITE(" iExtension");
   801     CLOG_WRITE(" iExtension");
   796     delete iAIWServiceHandler; 
   802     delete iAIWServiceHandler;
   797     CLOG_LEAVEFN("CDownloadMgrUiDownloadsList::~CDownloadMgrUiDownloadsList");
   803     CLOG_LEAVEFN("CDownloadMgrUiDownloadsList::~CDownloadMgrUiDownloadsList");
   798     }
   804     }
   799 
   805 
   800 // -----------------------------------------------------------------------------
   806 // -----------------------------------------------------------------------------
   801 // CDownloadMgrUiDownloadsList::DownloadMenu
   807 // CDownloadMgrUiDownloadsList::DownloadMenu
   802 // -----------------------------------------------------------------------------
   808 // -----------------------------------------------------------------------------
   803 //
   809 //
   804 EXPORT_C 
   810 EXPORT_C
   805 CDownloadMgrUiDownloadMenu& CDownloadMgrUiDownloadsList::DownloadMenu() const
   811 CDownloadMgrUiDownloadMenu& CDownloadMgrUiDownloadsList::DownloadMenu() const
   806     {
   812     {
   807     __ASSERT_DEBUG( iDownloadMenu, Panic( EUiLibPanNull ) );
   813     __ASSERT_DEBUG( iDownloadMenu, Panic( EUiLibPanNull ) );
   808     return(*iDownloadMenu);
   814     return(*iDownloadMenu);
   809     }
   815     }
   810 
   816 
   811 // -----------------------------------------------------------------------------
   817 // -----------------------------------------------------------------------------
   812 // CDownloadMgrUiDownloadsList::DisplayDownloadsListL
   818 // CDownloadMgrUiDownloadsList::DisplayDownloadsListL
   813 // -----------------------------------------------------------------------------
   819 // -----------------------------------------------------------------------------
   814 //
   820 //
   815 EXPORT_C 
   821 EXPORT_C
   816 void CDownloadMgrUiDownloadsList::DisplayDownloadsListL()
   822 void CDownloadMgrUiDownloadsList::DisplayDownloadsListL()
   817     {
   823     {
   818     CLOG_ENTERFN("CDownloadMgrUiDownloadsList::DisplayDownloadsListL");
   824     CLOG_ENTERFN("CDownloadMgrUiDownloadsList::DisplayDownloadsListL");
   819     
   825 
   820     long noMediaDls = 0;
   826     long noMediaDls = 0;
   821     iRegistryModel.DownloadMgr().GetIntAttribute( EDlMgrNoMediaDls, noMediaDls );
   827     iRegistryModel.DownloadMgr().GetIntAttribute( EDlMgrNoMediaDls, noMediaDls );
   822     TInt dlCount = iRegistryModel.DownloadMgr().CurrentDownloads().Count();
   828     TInt dlCount = iRegistryModel.DownloadMgr().CurrentDownloads().Count();
   823     
   829 
   824     if (dlCount > noMediaDls)
   830     if (dlCount > noMediaDls)
   825     	iExtension->DisplayDownloadsListAsynchronouslyL();
   831     	iExtension->DisplayDownloadsListAsynchronouslyL();
   826     
   832 
   827     CLOG_LEAVEFN("CDownloadMgrUiDownloadsList::DisplayDownloadsListL");
   833     CLOG_LEAVEFN("CDownloadMgrUiDownloadsList::DisplayDownloadsListL");
   828     }
   834     }
   829 
   835 
   830 // -----------------------------------------------------------------------------
   836 // -----------------------------------------------------------------------------
   831 // CDownloadMgrUiDownloadsList::DisplayDownloadsListL
   837 // CDownloadMgrUiDownloadsList::DisplayDownloadsListL
   841 
   847 
   842 // -----------------------------------------------------------------------------
   848 // -----------------------------------------------------------------------------
   843 // CDownloadMgrUiDownloadsList::CancelDisplayingDownloadsList
   849 // CDownloadMgrUiDownloadsList::CancelDisplayingDownloadsList
   844 // -----------------------------------------------------------------------------
   850 // -----------------------------------------------------------------------------
   845 //
   851 //
   846 EXPORT_C 
   852 EXPORT_C
   847 void CDownloadMgrUiDownloadsList::CancelDisplayingDownloadsList()
   853 void CDownloadMgrUiDownloadsList::CancelDisplayingDownloadsList()
   848     {
   854     {
   849     CLOG_ENTERFN("CDownloadMgrUiDownloadsList::CancelDisplayingDownloadsList");
   855     CLOG_ENTERFN("CDownloadMgrUiDownloadsList::CancelDisplayingDownloadsList");
   850     delete iDialog;
   856     delete iDialog;
   851     iDialog = 0;
   857     iDialog = 0;
   856 
   862 
   857 // -----------------------------------------------------------------------------
   863 // -----------------------------------------------------------------------------
   858 // CDownloadMgrUiDownloadsList::IsVisible
   864 // CDownloadMgrUiDownloadsList::IsVisible
   859 // -----------------------------------------------------------------------------
   865 // -----------------------------------------------------------------------------
   860 //
   866 //
   861 EXPORT_C 
   867 EXPORT_C
   862 TBool CDownloadMgrUiDownloadsList::IsVisible() const
   868 TBool CDownloadMgrUiDownloadsList::IsVisible() const
   863     {
   869     {
   864     return iExtension->IsDialogVisible();
   870     return iExtension->IsDialogVisible();
   865     }
   871     }
   866 
   872 
   867 // -----------------------------------------------------------------------------
   873 // -----------------------------------------------------------------------------
   868 // CDownloadMgrUiDownloadsList::Count
   874 // CDownloadMgrUiDownloadsList::Count
   869 // -----------------------------------------------------------------------------
   875 // -----------------------------------------------------------------------------
   870 //
   876 //
   871 EXPORT_C 
   877 EXPORT_C
   872 TInt CDownloadMgrUiDownloadsList::Count() const
   878 TInt CDownloadMgrUiDownloadsList::Count() const
   873     {
   879     {
   874     return ((iListModel!=NULL)?iListModel->Count():0);
   880     return ((iListModel!=NULL)?iListModel->Count():0);
   875     }
   881     }
   876 
   882 
   877 // Not yet supported functions
   883 // Not yet supported functions
   878 EXPORT_C 
   884 EXPORT_C
   879 void CDownloadMgrUiDownloadsList::GetIntAttributeL( const TUint /*aAttribute*/, TInt32& /*aValue*/ )
   885 void CDownloadMgrUiDownloadsList::GetIntAttributeL( const TUint /*aAttribute*/, TInt32& /*aValue*/ )
   880     {
   886     {
   881     User::Leave( KErrNotSupported );
   887     User::Leave( KErrNotSupported );
   882     }
   888     }
   883     
   889 
   884 EXPORT_C 
   890 EXPORT_C
   885 void CDownloadMgrUiDownloadsList::GetBoolAttributeL( const TUint /*aAttribute*/, TBool& /*aValue*/ )
   891 void CDownloadMgrUiDownloadsList::GetBoolAttributeL( const TUint /*aAttribute*/, TBool& /*aValue*/ )
   886     {
   892     {
   887     User::Leave( KErrNotSupported );
   893     User::Leave( KErrNotSupported );
   888     }
   894     }
   889     
   895 
   890 EXPORT_C 
   896 EXPORT_C
   891 void CDownloadMgrUiDownloadsList::GetStringAttributeL( const TUint /*aAttribute*/, TDes16& /*aValue*/  )
   897 void CDownloadMgrUiDownloadsList::GetStringAttributeL( const TUint /*aAttribute*/, TDes16& /*aValue*/  )
   892     {
   898     {
   893     User::Leave( KErrNotSupported );
   899     User::Leave( KErrNotSupported );
   894     }
   900     }
   895     
   901 
   896 EXPORT_C 
   902 EXPORT_C
   897 void CDownloadMgrUiDownloadsList::GetStringAttributeL( const TUint /*aAttribute*/, TDes8& /*aValue*/  )
   903 void CDownloadMgrUiDownloadsList::GetStringAttributeL( const TUint /*aAttribute*/, TDes8& /*aValue*/  )
   898     {
   904     {
   899     User::Leave( KErrNotSupported );
   905     User::Leave( KErrNotSupported );
   900     }
   906     }
   901     
   907 
   902 EXPORT_C 
   908 EXPORT_C
   903 void CDownloadMgrUiDownloadsList::SetIntAttributeL( const TUint /*aAttribute*/, TInt32 /*aValue*/ )
   909 void CDownloadMgrUiDownloadsList::SetIntAttributeL( const TUint /*aAttribute*/, TInt32 /*aValue*/ )
   904     {
   910     {
   905     User::Leave( KErrNotSupported );
   911     User::Leave( KErrNotSupported );
   906     }
   912     }
   907     
   913 
   908 EXPORT_C 
   914 EXPORT_C
   909 void CDownloadMgrUiDownloadsList::SetBoolAttributeL( const TUint /*aAttribute*/, TBool /*aValue*/ )
   915 void CDownloadMgrUiDownloadsList::SetBoolAttributeL( const TUint /*aAttribute*/, TBool /*aValue*/ )
   910     {
   916     {
   911     User::Leave( KErrNotSupported );
   917     User::Leave( KErrNotSupported );
   912     }
   918     }
   913     
   919 
   914 EXPORT_C 
   920 EXPORT_C
   915 void CDownloadMgrUiDownloadsList::SetStringAttributeL( const TUint /*aAttribute*/, const TDesC16& /*aValue*/ )
   921 void CDownloadMgrUiDownloadsList::SetStringAttributeL( const TUint /*aAttribute*/, const TDesC16& /*aValue*/ )
   916     {
   922     {
   917     User::Leave( KErrNotSupported );
   923     User::Leave( KErrNotSupported );
   918     }
   924     }
   919     
   925 
   920 EXPORT_C 
   926 EXPORT_C
   921 void CDownloadMgrUiDownloadsList::SetStringAttributeL( const TUint /*aAttribute*/, const TDesC8& /*aValue*/ )
   927 void CDownloadMgrUiDownloadsList::SetStringAttributeL( const TUint /*aAttribute*/, const TDesC8& /*aValue*/ )
   922     {
   928     {
   923     User::Leave( KErrNotSupported );
   929     User::Leave( KErrNotSupported );
   924     }
   930     }
   925     
   931 
   926 // -----------------------------------------------------------------------------
   932 // -----------------------------------------------------------------------------
   927 // CDownloadMgrUiDownloadsList::AddDownloadsToListModelL
   933 // CDownloadMgrUiDownloadsList::AddDownloadsToListModelL
   928 // -----------------------------------------------------------------------------
   934 // -----------------------------------------------------------------------------
   929 //
   935 //
   930 void CDownloadMgrUiDownloadsList::AddDownloadsToListModelL
   936 void CDownloadMgrUiDownloadsList::AddDownloadsToListModelL
   931 ( CDownloadsListArray& aLBModel, RHttpDownloadMgr& aDownloadMgr )
   937 ( CDownloadsListArray& aLBModel, RHttpDownloadMgr& aDownloadMgr )
   932     {
   938     {
   933     TInt downloads = aDownloadMgr.CurrentDownloads().Count();
   939     TInt downloads = aDownloadMgr.CurrentDownloads().Count();
   934     for ( TInt i = 0; i < downloads; ++i )
   940     for ( TInt i = 0; i < downloads; ++i )
   935         {
   941         {
   936         RHttpDownload* download = 
   942         RHttpDownload* download =
   937             (RHttpDownload*)(aDownloadMgr.CurrentDownloads().At(i));
   943             (RHttpDownload*)(aDownloadMgr.CurrentDownloads().At(i));
   938         // Extract the necessary information from 'download' and 
   944         // Extract the necessary information from 'download' and
   939         // add a list box item.
   945         // add a list box item.
   940         (void)AddDownloadToListModelL( aLBModel, *download );
   946         (void)AddDownloadToListModelL( aLBModel, *download );
   941         }
   947         }
   942     }
   948     }
   943 
   949 
   944 // -----------------------------------------------------------------------------
   950 // -----------------------------------------------------------------------------
   945 // CDownloadMgrUiDownloadsList::AddDownloadToListModelL
   951 // CDownloadMgrUiDownloadsList::AddDownloadToListModelL
   946 // This is a very expensive method, so when updating list box items, 
   952 // This is a very expensive method, so when updating list box items,
   947 // call the less expensive 'update' methods!
   953 // call the less expensive 'update' methods!
   948 // -----------------------------------------------------------------------------
   954 // -----------------------------------------------------------------------------
   949 //
   955 //
   950 TInt CDownloadMgrUiDownloadsList::AddDownloadToListModelL
   956 TInt CDownloadMgrUiDownloadsList::AddDownloadToListModelL
   951     ( CDownloadsListArray& aLBModel, RHttpDownload& aDownload )
   957     ( CDownloadsListArray& aLBModel, RHttpDownload& aDownload )
   959         // It is already on the list - do not add it again.
   965         // It is already on the list - do not add it again.
   960         CLOG_WRITE_FORMAT(" aDownload already on list (%d)",itemIndex);
   966         CLOG_WRITE_FORMAT(" aDownload already on list (%d)",itemIndex);
   961         }
   967         }
   962     else
   968     else
   963         {
   969         {
   964         // Do not add the download to the list if the storage 
   970         // Do not add the download to the list if the storage
   965         // media is not in the device.
   971         // media is not in the device.
   966         TBool noMedia( EFalse );
   972         TBool noMedia( EFalse );
   967         User::LeaveIfError( aDownload.GetBoolAttribute
   973         User::LeaveIfError( aDownload.GetBoolAttribute
   968                           ( EDlAttrNoMedia, noMedia ) );
   974                           ( EDlAttrNoMedia, noMedia ) );
   969         CLOG_WRITE_FORMAT(" EDlAttrNoMedia: %d",noMedia);
   975         CLOG_WRITE_FORMAT(" EDlAttrNoMedia: %d",noMedia);
   970         // Do not add the download to the list if it is hidden
   976         // Do not add the download to the list if it is hidden
   971         TBool isHidden( EFalse );
   977         TBool isHidden( EFalse );
   972         User::LeaveIfError( aDownload.GetBoolAttribute
   978         User::LeaveIfError( aDownload.GetBoolAttribute
   973                           ( EDlAttrHidden, isHidden ) );
   979                           ( EDlAttrHidden, isHidden ) );
   974         CLOG_WRITE_FORMAT(" EDlAttrHidden: %d",isHidden);
   980         CLOG_WRITE_FORMAT(" EDlAttrHidden: %d",isHidden);
   975         
   981 
   976         if ( noMedia || isHidden )
   982         if ( noMedia || isHidden )
   977             {
   983             {
   978             // Do not add it to the list - hide it from the user.
   984             // Do not add it to the list - hide it from the user.
   979             }
   985             }
   980         else
   986         else
   983             // Quite big structure, allocate it on the heap!
   989             // Quite big structure, allocate it on the heap!
   984             TDownloadUiData* dlData = new (ELeave) TDownloadUiData;
   990             TDownloadUiData* dlData = new (ELeave) TDownloadUiData;
   985             CleanupStack::PushL( dlData );
   991             CleanupStack::PushL( dlData );
   986 
   992 
   987             TInt err(KErrNone);
   993             TInt err(KErrNone);
   988             
   994 
   989             //      Get progress info
   995             //      Get progress info
   990             err = aDownload.GetIntAttribute
   996             err = aDownload.GetIntAttribute
   991                 ( EDlAttrState, dlData->iDownloadState );
   997                 ( EDlAttrState, dlData->iDownloadState );
   992             CLOG_WRITE_FORMAT(" EDlAttrState err: %d",err);
   998             CLOG_WRITE_FORMAT(" EDlAttrState err: %d",err);
   993             User::LeaveIfError( err );
   999             User::LeaveIfError( err );
   994             
  1000 
   995             //Changes for the bug JERI-7P8CF2
  1001             //Changes for the bug JERI-7P8CF2
   996             //Changes made in the server side to fix the video center receiving unexpected events
  1002             //Changes made in the server side to fix the video center receiving unexpected events
   997             //Reassigning these events back to the changes done in server side
  1003             //Reassigning these events back to the changes done in server side
   998             if(dlData->iDownloadState  == EHttpDlCompleted )
  1004             if(dlData->iDownloadState  == EHttpDlCompleted )
   999 		        {
  1005 		        {
  1013             CLOG_WRITE_FORMAT(" EDlAttrLength err: %d",err);
  1019             CLOG_WRITE_FORMAT(" EDlAttrLength err: %d",err);
  1014             if ( err != KErrNone && err != KErrNotFound )
  1020             if ( err != KErrNone && err != KErrNotFound )
  1015                 {
  1021                 {
  1016                 User::LeaveIfError( err );
  1022                 User::LeaveIfError( err );
  1017                 }
  1023                 }
  1018             
  1024 
  1019             // Number of media objects in download ( inalbum)?
  1025             // Number of media objects in download ( inalbum)?
  1020             err = aDownload.GetIntAttribute
  1026             err = aDownload.GetIntAttribute
  1021                 ( EDlAttrNumMediaObjects, dlData->iNumMediaObjects );
  1027                 ( EDlAttrNumMediaObjects, dlData->iNumMediaObjects );
  1022             CLOG_WRITE_FORMAT(" EDlAttrNumMediaObjects err: %d",err);
  1028             CLOG_WRITE_FORMAT(" EDlAttrNumMediaObjects err: %d",err);
  1023             User::LeaveIfError( err );
  1029             User::LeaveIfError( err );
  1024             
  1030 
  1025             //      Get file name
  1031             //      Get file name
  1026             // In case of album - if download is complete, query album name, 
  1032             // In case of album - if download is complete, query album name,
  1027             // otherwise query track name                
  1033             // otherwise query track name
  1028             if ((dlData->iNumMediaObjects > 1) &&
  1034             if ((dlData->iNumMediaObjects > 1) &&
  1029                 (EHttpDlMultipleMOCompleted == dlData->iDownloadState))
  1035                 (EHttpDlMultipleMOCompleted == dlData->iDownloadState))
  1030                 {
  1036                 {
  1031                 err = aDownload.GetStringAttribute
  1037                 err = aDownload.GetStringAttribute
  1032                     ( EDlAttrAlbumName, dlData->iName );
  1038                     ( EDlAttrAlbumName, dlData->iName );
  1033                 CLOG_WRITE_FORMAT(" EDlAttrAlbumName err: %d",err);    
  1039                 CLOG_WRITE_FORMAT(" EDlAttrAlbumName err: %d",err);
  1034                 }
  1040                 }
  1035             else
  1041             else
  1036                 {
  1042                 {
  1037                 err = aDownload.GetStringAttribute
  1043                 err = aDownload.GetStringAttribute
  1038                     ( EDlAttrName, dlData->iName );
  1044                     ( EDlAttrName, dlData->iName );
  1039                 CLOG_WRITE_FORMAT(" EDlAttrName err: %d",err);
  1045                 CLOG_WRITE_FORMAT(" EDlAttrName err: %d",err);
  1040                 }
  1046                 }
  1041                 
  1047 
  1042             if ( err != KErrNone && err != KErrNotFound )
  1048             if ( err != KErrNone && err != KErrNotFound )
  1043                 {
  1049                 {
  1044                 User::LeaveIfError( err );
  1050                 User::LeaveIfError( err );
  1045                 }
  1051                 }
  1046             CLOG_WRITE_FORMAT(" EDlAttrName: %S",&(dlData->iName));
  1052             CLOG_WRITE_FORMAT(" EDlAttrName: %S",&(dlData->iName));
  1047             
  1053 
  1048             // If download name is empty, use the file name got from URI
  1054             // If download name is empty, use the file name got from URI
  1049             if ( dlData->iName.Length() == 0 )
  1055             if ( dlData->iName.Length() == 0 )
  1050                 {
  1056                 {
  1051                 HBufC* url = HBufC::NewLC( KMaxUrlLength );
  1057                 HBufC* url = HBufC::NewLC( KMaxUrlLength );
  1052                 TPtr urlPtr = url->Des();
  1058                 TPtr urlPtr = url->Des();
  1106 
  1112 
  1107             // Is the download pausable?
  1113             // Is the download pausable?
  1108             User::LeaveIfError( aDownload.GetBoolAttribute
  1114             User::LeaveIfError( aDownload.GetBoolAttribute
  1109                 ( EDlAttrPausable, dlData->iPausable ) );
  1115                 ( EDlAttrPausable, dlData->iPausable ) );
  1110             CLOG_WRITE_FORMAT(" EDlAttrPausable: %d",dlData->iPausable);
  1116             CLOG_WRITE_FORMAT(" EDlAttrPausable: %d",dlData->iPausable);
  1111     
  1117 
  1112             // Is the download on an external/removable memory (like MMC)?
  1118             // Is the download on an external/removable memory (like MMC)?
  1113             err = aDownload.GetIntAttribute
  1119             err = aDownload.GetBoolAttribute
  1114                 ( EDlAttrDestRemovable, dlData->iExternalMemoryStatus );
  1120                 ( EDlAttrDestRemovable, dlData->iIsOnExternalMemory );
  1115             CLOG_WRITE_FORMAT(" EDlAttrDestRemovable err: %d",err);
  1121             CLOG_WRITE_FORMAT(" EDlAttrDestRemovable err: %d",err);
  1116             // 'err' is ignored.
  1122             // 'err' is ignored.
  1117             CLOG_WRITE_FORMAT(" EDlAttrDestRemovable: %d",dlData->iExternalMemoryStatus);
  1123             CLOG_WRITE_FORMAT(" EDlAttrDestRemovable: %d",dlData->iIsOnExternalMemory);
  1118 
  1124 
  1119             // Currently active media object's index (in album)?
  1125             // Currently active media object's index (in album)?
  1120             err = aDownload.GetIntAttribute
  1126             err = aDownload.GetIntAttribute
  1121                 ( EDlAttrActiveDownload, dlData->iActiveMoIndex );
  1127                 ( EDlAttrActiveDownload, dlData->iActiveMoIndex );
  1122             CLOG_WRITE_FORMAT(" EDlAttrActiveDownload err: %d",err);
  1128             CLOG_WRITE_FORMAT(" EDlAttrActiveDownload err: %d",err);
  1123             User::LeaveIfError( err );
  1129             User::LeaveIfError( err );
  1124     
  1130 
  1125             // First add the handler app's icon to model, so that we then 
  1131             // First add the handler app's icon to model, so that we then
  1126             // know the index of it that can then be set in the item text, 
  1132             // know the index of it that can then be set in the item text,
  1127             // which is then also added to the model.
  1133             // which is then also added to the model.
  1128             dlData->iIconIndex = 
  1134             dlData->iIconIndex =
  1129                 iListModel->AddHandlerAppIconL( dlData->iContentType );
  1135                 iListModel->AddHandlerAppIconL( dlData->iContentType );
  1130             CLOG_WRITE(" AddHandlerAppIconL OK");
  1136             CLOG_WRITE(" AddHandlerAppIconL OK");
  1131 
  1137 
  1132             // Add now the structure to the model:
  1138             // Add now the structure to the model:
  1133             itemIndex = aLBModel.AppendL( *dlData, aDownload );
  1139             itemIndex = aLBModel.AppendL( *dlData, aDownload );
  1172                 iListModel->Delete( index );
  1178                 iListModel->Delete( index );
  1173                 }
  1179                 }
  1174             else
  1180             else
  1175                 {
  1181                 {
  1176                 iListModel->Delete( index );
  1182                 iListModel->Delete( index );
  1177                               
  1183 
  1178                 // Update view
  1184                 // Update view
  1179                 if ( iExtension->IsDialogVisible() )
  1185                 if ( iExtension->IsDialogVisible() )
  1180                     {
  1186                     {
  1181                     iExtension->DlExecuter().Dialog().HandleModelChangeL( EDownloadRemoved, index );
  1187                     iExtension->DlExecuter().Dialog().HandleModelChangeL( EDownloadRemoved, index );
  1182                     CLOG_WRITE(" HandleModelChangeL OK");
  1188                     CLOG_WRITE(" HandleModelChangeL OK");
  1183                     }
  1189                     }
  1184                 }
  1190                 }
  1185             }
  1191             }
  1186         }
  1192         }
  1187     
  1193 
  1188     CLOG_LEAVEFN("CDownloadMgrUiDownloadsList::DeleteDownloadL");
  1194     CLOG_LEAVEFN("CDownloadMgrUiDownloadsList::DeleteDownloadL");
  1189     }
  1195     }
  1190 
  1196 
  1191 // -----------------------------------------------------------------------------
  1197 // -----------------------------------------------------------------------------
  1192 // CDownloadMgrUiDownloadsList::DeleteDownloadL
  1198 // CDownloadMgrUiDownloadsList::DeleteDownloadL
  1193 // -----------------------------------------------------------------------------
  1199 // -----------------------------------------------------------------------------
  1194 //
  1200 //
  1195 TBool CDownloadMgrUiDownloadsList::IsOneProgressive()
  1201 TBool CDownloadMgrUiDownloadsList::IsOneProgressive()
  1196    {
  1202    {
  1197    TBool anyOneProgress = EFalse; 
  1203    TBool anyOneProgress = EFalse;
  1198    if (iListModel == NULL)
  1204    if (iListModel == NULL)
  1199       {
  1205       {
  1200    	  return EFalse; 
  1206    	  return EFalse;
  1201       }
  1207       }
  1202    else 
  1208    else
  1203       {
  1209       {
  1204       TInt count = Count(); 
  1210       TInt count = Count();
  1205       for ( TInt i = 0; i < count; ++i )
  1211       for ( TInt i = 0; i < count; ++i )
  1206          {
  1212          {
  1207       	 RHttpDownload& download = iListModel->Download(i); 
  1213       	 RHttpDownload& download = iListModel->Download(i);
  1208          TInt err = download.GetBoolAttribute( EDlAttrProgressive, anyOneProgress );
  1214          TInt err = download.GetBoolAttribute( EDlAttrProgressive, anyOneProgress );
  1209           // If there is a COD download and check if it is attached. Then set it as attached while resuming
  1215           // If there is a COD download and check if it is attached. Then set it as attached while resuming
  1210          TBool isCodDownload;
  1216          TBool isCodDownload;
  1211          download.GetBoolAttribute(EDlAttrCodDownload,isCodDownload);
  1217          download.GetBoolAttribute(EDlAttrCodDownload,isCodDownload);
  1212          if(isCodDownload && anyOneProgress )
  1218          if(isCodDownload && anyOneProgress )
  1214             download.SetBoolAttribute( EDlAttrProgressive, ETrue );
  1220             download.SetBoolAttribute( EDlAttrProgressive, ETrue );
  1215             }
  1221             }
  1216          THttpProgressState state;
  1222          THttpProgressState state;
  1217          if( anyOneProgress )
  1223          if( anyOneProgress )
  1218          	{
  1224          	{
  1219          	download.GetIntAttribute(EDlAttrProgressState, (TInt32&)state);	
  1225          	download.GetIntAttribute(EDlAttrProgressState, (TInt32&)state);
  1220          	if(state == EHttpProgContentFileMoved || state == EHttpProgContentFileMovedAndDestFNChanged )
  1226          	if(state == EHttpProgContentFileMoved || state == EHttpProgContentFileMovedAndDestFNChanged )
  1221          	    {
  1227          	    {
  1222          	    anyOneProgress = 0;//once the move() has happened the progressive Download is finished
  1228          	    anyOneProgress = 0;//once the move() has happened the progressive Download is finished
  1223          	    }                  //and we can  bring MP to foreground and start another PD 
  1229          	    }                  //and we can  bring MP to foreground and start another PD
  1224            	}	
  1230            	}
  1225          CLOG_WRITE_FORMAT(" EDlAttrProgressive err: %d",err);
  1231          CLOG_WRITE_FORMAT(" EDlAttrProgressive err: %d",err);
  1226          if ( anyOneProgress ) 
  1232          if ( anyOneProgress )
  1227             return ETrue;      	 
  1233             return ETrue;
  1228          }
  1234          }
  1229       }
  1235       }
  1230    return anyOneProgress; 
  1236    return anyOneProgress;
  1231    }
  1237    }
  1232 
  1238 
  1233         
  1239 
  1234 // -----------------------------------------------------------------------------
  1240 // -----------------------------------------------------------------------------
  1235 // CDownloadMgrUiDownloadsList::NewDownloadCreatedL
  1241 // CDownloadMgrUiDownloadsList::NewDownloadCreatedL
  1236 // -----------------------------------------------------------------------------
  1242 // -----------------------------------------------------------------------------
  1237 //
  1243 //
  1238 void CDownloadMgrUiDownloadsList::NewDownloadCreatedL( RHttpDownload& aDownload )
  1244 void CDownloadMgrUiDownloadsList::NewDownloadCreatedL( RHttpDownload& aDownload )
  1261         }
  1267         }
  1262     else
  1268     else
  1263         {
  1269         {
  1264         // Create a local copy
  1270         // Create a local copy
  1265         TDownloadUiData dlData = *dlDataPtr;
  1271         TDownloadUiData dlData = *dlDataPtr;
  1266         
  1272 
  1267         // Track changed? We need to change icon of new track
  1273         // Track changed? We need to change icon of new track
  1268         TInt32 moIndex(0);
  1274         TInt32 moIndex(0);
  1269         User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrActiveDownload, moIndex ) );
  1275         User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrActiveDownload, moIndex ) );
  1270         TBool activeIndexChanged = (dlData.iActiveMoIndex != moIndex);
  1276         TBool activeIndexChanged = (dlData.iActiveMoIndex != moIndex);
  1271         
  1277 
  1272         // Update download state - this must always be done!
  1278         // Update download state - this must always be done!
  1273         dlData.iDownloadState = aEvent.iDownloadState;
  1279         dlData.iDownloadState = aEvent.iDownloadState;
  1274 		dlData.iProgressState = aEvent.iProgressState;
  1280 		dlData.iProgressState = aEvent.iProgressState;
  1275 		dlData.iActiveMoIndex = moIndex;
  1281 		dlData.iActiveMoIndex = moIndex;
  1276         aDownload.GetStringAttribute( EDlAttrName, dlData.iName );
  1282         aDownload.GetStringAttribute( EDlAttrName, dlData.iName );
  1277         // Permanent redirection changes the filename.
  1283         // Permanent redirection changes the filename.
  1278         if ( aEvent.iProgressState == EHttpProgRedirectedPermanently || 
  1284         if ( aEvent.iProgressState == EHttpProgRedirectedPermanently ||
  1279              aEvent.iProgressState == EHttpProgRedirectedTemporarily )
  1285              aEvent.iProgressState == EHttpProgRedirectedTemporarily )
  1280             {
  1286             {
  1281             CLOG_WRITE(" Redirection");
  1287             CLOG_WRITE(" Redirection");
  1282             }
  1288             }
  1283         else if ( aEvent.iProgressState == EHttpProgResponseHeaderReceived )
  1289         else if ( aEvent.iProgressState == EHttpProgResponseHeaderReceived )
  1284                 {
  1290         	{
  1285                 // Is the download on an external/removable memory (like MMC)?
  1291             // Is the download on an external/removable memory (like MMC)?
  1286                 // Return value is ignored.
  1292             aDownload.GetBoolAttribute
  1287                 aDownload.GetIntAttribute( EDlAttrDestRemovable, dlData.iExternalMemoryStatus );
  1293                 ( EDlAttrDestRemovable, dlData.iIsOnExternalMemory );
  1288                 CLOG_WRITE_FORMAT(" EDlAttrDestRemovable: %d",dlData.iExternalMemoryStatus);
  1294             // Return value is ignored.
  1289                 }
  1295             CLOG_WRITE_FORMAT(" EDlAttrDestRemovable: %d",dlData.iIsOnExternalMemory);
       
  1296         	}
  1290         else if ( aEvent.iProgressState == EHttpProgDlNameChanged )
  1297         else if ( aEvent.iProgressState == EHttpProgDlNameChanged )
  1291             {
  1298             {
  1292             CLOG_WRITE(" EHttpProgDlNameChanged");
  1299             CLOG_WRITE(" EHttpProgDlNameChanged");
  1293             }
  1300             }
  1294         
  1301 
  1295         if (( aEvent.iProgressState == EHttpProgContentTypeChanged ) || activeIndexChanged )
  1302         if (( aEvent.iProgressState == EHttpProgContentTypeChanged ) || activeIndexChanged )
  1296             {
  1303             {
  1297             // Update handler application icon
  1304             // Update handler application icon
  1298             // Also update the content type, because the handler application 
  1305             // Also update the content type, because the handler application
  1299             // icon depends from this.
  1306             // icon depends from this.
  1300             CLOG_WRITE_FORMAT(" EHttpProgContentTypeChanged: ActiveIndex - %d",dlData.iActiveMoIndex);
  1307             CLOG_WRITE_FORMAT(" EHttpProgContentTypeChanged: ActiveIndex - %d",dlData.iActiveMoIndex);
  1301             HBufC8* contentType = iUiUtils->ContentTypeL( aDownload, ETrue );
  1308             HBufC8* contentType = iUiUtils->ContentTypeL( aDownload, ETrue );
  1302             // Not pushed to cleanup stack - unnecessary.
  1309             // Not pushed to cleanup stack - unnecessary.
  1303             // There is a limit for dlData.iContentType
  1310             // There is a limit for dlData.iContentType
  1313             delete contentType;
  1320             delete contentType;
  1314             contentType = 0;
  1321             contentType = 0;
  1315             dlData.iIconIndex = iListModel->AddHandlerAppIconL( dlData.iContentType );
  1322             dlData.iIconIndex = iListModel->AddHandlerAppIconL( dlData.iContentType );
  1316             }
  1323             }
  1317         // Update the progress info.
  1324         // Update the progress info.
  1318         User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrDownloadedSize, 
  1325         User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrDownloadedSize,
  1319                                                        dlData.iDownloadedSize ) );
  1326                                                        dlData.iDownloadedSize ) );
  1320         User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrLength, 
  1327         User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrLength,
  1321                                                        dlData.iFullSize ) );
  1328                                                        dlData.iFullSize ) );
  1322         // Update the download ui data in the 'model'.
  1329         // Update the download ui data in the 'model'.
  1323         iListModel->UpdateL( index, dlData );
  1330         iListModel->UpdateL( index, dlData );
  1324         // Update the 'view'
  1331         // Update the 'view'
  1325         iExtension->DlExecuter().Dialog().HandleModelChangeL( EDownloadChanged, index );
  1332         iExtension->DlExecuter().Dialog().HandleModelChangeL( EDownloadChanged, index );
  1332 //
  1339 //
  1333 void CDownloadMgrUiDownloadsList::DownloadPausedL
  1340 void CDownloadMgrUiDownloadsList::DownloadPausedL
  1334     ( RHttpDownload& aDownload, THttpDownloadEvent aEvent )
  1341     ( RHttpDownload& aDownload, THttpDownloadEvent aEvent )
  1335     {
  1342     {
  1336     CLOG_ENTERFN("CDownloadMgrUiDownloadsList::DownloadPausedL");
  1343     CLOG_ENTERFN("CDownloadMgrUiDownloadsList::DownloadPausedL");
  1337     
  1344 
  1338     __ASSERT_DEBUG( iExtension->IsDialogVisible(), Panic( EUiLibPanPausedNotVisible ) );
  1345     __ASSERT_DEBUG( iExtension->IsDialogVisible(), Panic( EUiLibPanPausedNotVisible ) );
  1339     // First find the current download in the model.
  1346     // First find the current download in the model.
  1340     TInt index(0);
  1347     TInt index(0);
  1341     TDownloadUiData* dlDataPtr = FindDlUiData( *iListModel, aDownload, index );
  1348     TDownloadUiData* dlDataPtr = FindDlUiData( *iListModel, aDownload, index );
  1342     if ( !dlDataPtr )
  1349     if ( !dlDataPtr )
  1351         // Update download state - this must always be done!
  1358         // Update download state - this must always be done!
  1352         dlData.iDownloadState = aEvent.iDownloadState;
  1359         dlData.iDownloadState = aEvent.iDownloadState;
  1353 		dlData.iProgressState = aEvent.iProgressState;
  1360 		dlData.iProgressState = aEvent.iProgressState;
  1354 		User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrActiveDownload, dlData.iActiveMoIndex ) );
  1361 		User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrActiveDownload, dlData.iActiveMoIndex ) );
  1355 		aDownload.GetStringAttribute( EDlAttrName, dlData.iName );
  1362 		aDownload.GetStringAttribute( EDlAttrName, dlData.iName );
  1356         // Here we have to initialize the full size, if the 
  1363         // Here we have to initialize the full size, if the
  1357         // content-type header arrives!!
  1364         // content-type header arrives!!
  1358         if ( aEvent.iProgressState == EHttpContentTypeReceived )
  1365         if ( aEvent.iProgressState == EHttpContentTypeReceived )
  1359             {
  1366             {
  1360             TInt err = aDownload.GetIntAttribute( EDlAttrLength, dlData.iFullSize );
  1367             TInt err = aDownload.GetIntAttribute( EDlAttrLength, dlData.iFullSize );
  1361             if ( err != KErrNone && err != KErrNotFound )
  1368             if ( err != KErrNone && err != KErrNotFound )
  1362                 {
  1369                 {
  1363                 User::LeaveIfError( err );
  1370                 User::LeaveIfError( err );
  1364                 }
  1371                 }
  1365 
  1372 
  1366             // Also update the content type, because the handler application 
  1373             // Also update the content type, because the handler application
  1367             // icon depends from this.
  1374             // icon depends from this.
  1368             HBufC8* contentType = iUiUtils->ContentTypeL( aDownload, ETrue );
  1375             HBufC8* contentType = iUiUtils->ContentTypeL( aDownload, ETrue );
  1369             // Not pushed to cleanup stack - unnecessary.
  1376             // Not pushed to cleanup stack - unnecessary.
  1370             // There is a limit for dlData.iContentType
  1377             // There is a limit for dlData.iContentType
  1371             if ( contentType->Length() > KMaxContentTypeLength )
  1378             if ( contentType->Length() > KMaxContentTypeLength )
  1380             delete contentType;
  1387             delete contentType;
  1381             contentType = 0;
  1388             contentType = 0;
  1382             dlData.iIconIndex = iListModel->AddHandlerAppIconL( dlData.iContentType );
  1389             dlData.iIconIndex = iListModel->AddHandlerAppIconL( dlData.iContentType );
  1383             }
  1390             }
  1384 
  1391 
  1385         // Update downloaded size (introduced, because for non-pausable downloads 
  1392         // Update downloaded size (introduced, because for non-pausable downloads
  1386         // paused command sets downloaded size back to 0 kB).
  1393         // paused command sets downloaded size back to 0 kB).
  1387         User::LeaveIfError( aDownload.GetIntAttribute
  1394         User::LeaveIfError( aDownload.GetIntAttribute
  1388                           ( EDlAttrDownloadedSize, dlData.iDownloadedSize ) );
  1395                           ( EDlAttrDownloadedSize, dlData.iDownloadedSize ) );
  1389         
  1396 
  1390         // Update the download ui data in the 'model'.
  1397         // Update the download ui data in the 'model'.
  1391         iListModel->UpdateL( index, dlData );
  1398         iListModel->UpdateL( index, dlData );
  1392         // Update the 'view'
  1399         // Update the 'view'
  1393         iExtension->DlExecuter().Dialog().HandleModelChangeL( EDownloadChanged, index );
  1400         iExtension->DlExecuter().Dialog().HandleModelChangeL( EDownloadChanged, index );
  1394         // Also need to update the middle softkey 
  1401         // Also need to update the middle softkey
  1395         iExtension->DlExecuter().Dialog().HandleMiddleSoftKeyChangeL();        
  1402         iExtension->DlExecuter().Dialog().HandleMiddleSoftKeyChangeL();
  1396         }
  1403         }
  1397     
  1404 
  1398     CLOG_LEAVEFN("CDownloadMgrUiDownloadsList::DownloadPausedL");
  1405     CLOG_LEAVEFN("CDownloadMgrUiDownloadsList::DownloadPausedL");
  1399     }
  1406     }
  1400 
  1407 
  1401 // -----------------------------------------------------------------------------
  1408 // -----------------------------------------------------------------------------
  1402 // CDownloadMgrUiDownloadsList::DownloadCompletedL
  1409 // CDownloadMgrUiDownloadsList::DownloadCompletedL
  1421         TDownloadUiData dlData = *dlDataPtr;
  1428         TDownloadUiData dlData = *dlDataPtr;
  1422         // Update download state - this must always be done!
  1429         // Update download state - this must always be done!
  1423         dlData.iDownloadState = aEvent.iDownloadState;
  1430         dlData.iDownloadState = aEvent.iDownloadState;
  1424 		dlData.iProgressState = aEvent.iProgressState;
  1431 		dlData.iProgressState = aEvent.iProgressState;
  1425 		User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrActiveDownload, dlData.iActiveMoIndex ) );
  1432 		User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrActiveDownload, dlData.iActiveMoIndex ) );
  1426 		
  1433 
  1427 		// In case of Album download, change the name to Album name
  1434 		// In case of Album download, change the name to Album name
  1428 		if (dlData.iNumMediaObjects > 1)
  1435 		if (dlData.iNumMediaObjects > 1)
  1429 		    {
  1436 		    {
  1430 		    aDownload.GetStringAttribute( EDlAttrAlbumName, dlData.iName );
  1437 		    aDownload.GetStringAttribute( EDlAttrAlbumName, dlData.iName );
  1431 		    }
  1438 		    }
  1432 		else if (dlData.iProgressState == EHttpProgContentFileMovedAndDestFNChanged)
  1439 		else if (dlData.iProgressState == EHttpProgContentFileMovedAndDestFNChanged)
  1433 			// Filename changed, get the updated filename
  1440 			// Filename changed, get the updated filename
  1434 		    {
  1441 		    {
  1435 			CLOG_WRITE(" EHttpProgDlNameChanged");
  1442 			CLOG_WRITE(" EHttpProgDlNameChanged");
  1436  	        aDownload.GetStringAttribute( EDlAttrName, dlData.iName ); 
  1443  	        aDownload.GetStringAttribute( EDlAttrName, dlData.iName );
  1437 		    }
  1444 		    }
  1438 
  1445 
  1439         __ASSERT_DEBUG( aEvent.iDownloadState == EHttpDlMultipleMOCompleted, 
  1446         __ASSERT_DEBUG( aEvent.iDownloadState == EHttpDlMultipleMOCompleted,
  1440                         Panic( EUiLibPanDlStateNotCompleted ) );
  1447                         Panic( EUiLibPanDlStateNotCompleted ) );
  1441         
  1448 
  1442         if( dlData.iProgressState == EHttpProgContentFileMoved  || dlData.iProgressState == EHttpProgContentFileMovedAndDestFNChanged )
  1449         if( dlData.iProgressState == EHttpProgContentFileMoved  || dlData.iProgressState == EHttpProgContentFileMovedAndDestFNChanged )
  1443            {
  1450            {
  1444             HBufC8* contentType = iUiUtils->ContentTypeL( aDownload, ETrue, KFirstMoIndex );
  1451             HBufC8* contentType = iUiUtils->ContentTypeL( aDownload, ETrue, KFirstMoIndex );
  1445             if ( contentType->Length() > KMaxContentTypeLength )
  1452             if ( contentType->Length() > KMaxContentTypeLength )
  1446                 {
  1453                 {
  1450                 contentType = 0;
  1457                 contentType = 0;
  1451                 contentType = KNullDesC8().AllocL();
  1458                 contentType = KNullDesC8().AllocL();
  1452                 }
  1459                 }
  1453             dlData.iContentType.Copy( *contentType );
  1460             dlData.iContentType.Copy( *contentType );
  1454             delete contentType;
  1461             delete contentType;
  1455             dlData.iIconIndex = 
  1462             dlData.iIconIndex =
  1456                 iListModel->AddHandlerAppIconL( dlData.iContentType );  
  1463                 iListModel->AddHandlerAppIconL( dlData.iContentType );
  1457             
  1464 
  1458             }
  1465             }
  1459         // Unnecessary to update dlData.iDownloadedSize, as it is not displayed.
  1466         // Unnecessary to update dlData.iDownloadedSize, as it is not displayed.
  1460         // Update the download ui data in the 'model'.
  1467         // Update the download ui data in the 'model'.
  1461         iListModel->UpdateL( index, dlData );
  1468         iListModel->UpdateL( index, dlData );
  1462         // Update the 'view'
  1469         // Update the 'view'
  1463         iExtension->DlExecuter().Dialog().HandleModelChangeL( EDownloadChanged, index );
  1470         iExtension->DlExecuter().Dialog().HandleModelChangeL( EDownloadChanged, index );
  1464         // Also need to update the middle softkey 
  1471         // Also need to update the middle softkey
  1465         iExtension->DlExecuter().Dialog().HandleMiddleSoftKeyChangeL();
  1472         iExtension->DlExecuter().Dialog().HandleMiddleSoftKeyChangeL();
  1466         }
  1473         }
  1467     }
  1474     }
  1468 
  1475 
  1469 // -----------------------------------------------------------------------------
  1476 // -----------------------------------------------------------------------------
  1491         dlData.iDownloadState = aEvent.iDownloadState;
  1498         dlData.iDownloadState = aEvent.iDownloadState;
  1492 		dlData.iProgressState = aEvent.iProgressState;
  1499 		dlData.iProgressState = aEvent.iProgressState;
  1493 		User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrActiveDownload, dlData.iActiveMoIndex ) );
  1500 		User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrActiveDownload, dlData.iActiveMoIndex ) );
  1494 
  1501 
  1495         // By default, update the progress info. Only the downloaded size changes.
  1502         // By default, update the progress info. Only the downloaded size changes.
  1496         User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrDownloadedSize, 
  1503         User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrDownloadedSize,
  1497                                                        dlData.iDownloadedSize ) );
  1504                                                        dlData.iDownloadedSize ) );
  1498         // Update the download ui data in the 'model'.
  1505         // Update the download ui data in the 'model'.
  1499         iListModel->UpdateL( index, dlData );
  1506         iListModel->UpdateL( index, dlData );
  1500         // Update the 'view'
  1507         // Update the 'view'
  1501         iExtension->DlExecuter().Dialog().HandleModelChangeL( EDownloadChanged, index );
  1508         iExtension->DlExecuter().Dialog().HandleModelChangeL( EDownloadChanged, index );
  1525         dlData.iPausable = aPausable;
  1532         dlData.iPausable = aPausable;
  1526         // Update the download ui data in the 'model'.
  1533         // Update the download ui data in the 'model'.
  1527         iListModel->UpdateL( index, dlData );
  1534         iListModel->UpdateL( index, dlData );
  1528         }
  1535         }
  1529     }
  1536     }
  1530     
  1537 
  1531 // -----------------------------------------------------------------------------
  1538 // -----------------------------------------------------------------------------
  1532 // CDownloadMgrUiDownloadsList::HideMenu
  1539 // CDownloadMgrUiDownloadsList::HideMenu
  1533 // -----------------------------------------------------------------------------
  1540 // -----------------------------------------------------------------------------
  1534 //
  1541 //
  1535 void CDownloadMgrUiDownloadsList::HideMenu()
  1542 void CDownloadMgrUiDownloadsList::HideMenu()
  1570             {
  1577             {
  1571 				// Update progress info every KUpdateProgressInfoInterval
  1578 				// Update progress info every KUpdateProgressInfoInterval
  1572 				if (!iIsTimerStarted )
  1579 				if (!iIsTimerStarted )
  1573                 {
  1580                 {
  1574 					iIsTimerStarted = ETrue;
  1581 					iIsTimerStarted = ETrue;
  1575 					// start the timer. 
  1582 					// start the timer.
  1576 					iExtension->StartProgressTimer();
  1583 					iExtension->StartProgressTimer();
  1577                 }
  1584                 }
  1578 
  1585 
  1579 				if (iExtension->iIsUpdateInfoAllowed)
  1586 				if (iExtension->iIsUpdateInfoAllowed)
  1580                 {
  1587                 {
  1603             }
  1610             }
  1604 
  1611 
  1605         case EHttpDlMoved:
  1612         case EHttpDlMoved:
  1606             {
  1613             {
  1607             // Download moved to this session.
  1614             // Download moved to this session.
  1608             // Add it to the list 
  1615             // Add it to the list
  1609             NewDownloadCreatedL( aDownload );
  1616             NewDownloadCreatedL( aDownload );
  1610             break;
  1617             break;
  1611             }
  1618             }
  1612 
  1619 
  1613         case EHttpDlMediaRemoved:
  1620         case EHttpDlMediaRemoved:
  1614             {
  1621             {
  1615             // Remove the download from the list
  1622             // Remove the download from the list
  1616             DeleteDownloadL( aDownload );
  1623             DeleteDownloadL( aDownload );
  1617             break;
  1624             break;
  1618             }
  1625             }
  1619             
  1626 
  1620         case EHttpDlMediaInserted:
  1627         case EHttpDlMediaInserted:
  1621             {
  1628             {
  1622             // Add new download to the list
  1629             // Add new download to the list
  1623             NewDownloadCreatedL( aDownload );
  1630             NewDownloadCreatedL( aDownload );
  1624             break;
  1631             break;
  1625             }
  1632             }
  1626             
  1633 
  1627         case EHttpDlPausable:
  1634         case EHttpDlPausable:
  1628         case EHttpDlNonPausable:
  1635         case EHttpDlNonPausable:
  1629             {
  1636             {
  1630             // Update the download UI data
  1637             // Update the download UI data
  1631             PauseableStateChangedL( aDownload, aEvent.iDownloadState==EHttpDlPausable );
  1638             PauseableStateChangedL( aDownload, aEvent.iDownloadState==EHttpDlPausable );
  1681 // -----------------------------------------------------------------------------
  1688 // -----------------------------------------------------------------------------
  1682 //
  1689 //
  1683 void CDownloadMgrUiDownloadsList::PreLayoutDynInitL( CDownloadsListDlg& aDialog )
  1690 void CDownloadMgrUiDownloadsList::PreLayoutDynInitL( CDownloadsListDlg& aDialog )
  1684     {
  1691     {
  1685     CLOG_ENTERFN("CDownloadMgrUiDownloadsList::PreLayoutDynInitL");
  1692     CLOG_ENTERFN("CDownloadMgrUiDownloadsList::PreLayoutDynInitL");
  1686     
  1693 
  1687     __ASSERT_DEBUG( iExtension->IsDialogVisible(), Panic( EUiLibPanNull ) );
  1694     __ASSERT_DEBUG( iExtension->IsDialogVisible(), Panic( EUiLibPanNull ) );
  1688     
  1695 
  1689     delete iListModel;
  1696     delete iListModel;
  1690     iListModel = NULL;
  1697     iListModel = NULL;
  1691     iListModel = CDownloadsListArray::NewL();
  1698     iListModel = CDownloadsListArray::NewL();
  1692     CLOG_WRITE(" NewL OK");
  1699     CLOG_WRITE(" NewL OK");
  1693 
  1700 
  1721     if ( aiwServiceId != KAiwCmdNone )
  1728     if ( aiwServiceId != KAiwCmdNone )
  1722         {
  1729         {
  1723         HandleAIWCommandL(aCommandId, currDownload);
  1730         HandleAIWCommandL(aCommandId, currDownload);
  1724         return;
  1731         return;
  1725         }
  1732         }
  1726         
  1733 
  1727     switch ( aCommandId )
  1734     switch ( aCommandId )
  1728         {
  1735         {
  1729         case EAknSoftkeyOpen: // handle middlesoft key 
  1736         case EAknSoftkeyOpen: // handle middlesoft key
  1730             {
  1737             {
  1731             // First close the downloads list.
  1738             // First close the downloads list.
  1732             CancelDisplayingDownloadsList();
  1739             CancelDisplayingDownloadsList();
  1733             CLOG_WRITE(" CancelDisplayingDownloadsList OK");
  1740             CLOG_WRITE(" CancelDisplayingDownloadsList OK");
  1734 
  1741 
  1735 			if(iProgressiveDownload)
  1742 			if(iProgressiveDownload)
  1736 			{
  1743 			{
  1737             // check if it's pd supported 
  1744             // check if it's pd supported
  1738             TBool isPdSupported = EFalse; 
  1745             TBool isPdSupported = EFalse;
  1739             // Get the PD player application's UID for the download
  1746             // Get the PD player application's UID for the download
  1740             TUid pdPlayerUid = { 0 };    
  1747             TUid pdPlayerUid = { 0 };
  1741             HBufC8* contentType = iUiUtils->ContentTypeL( currDownload, ETrue, KFirstMoIndex  );
  1748             HBufC8* contentType = iUiUtils->ContentTypeL( currDownload, ETrue, KFirstMoIndex  );
  1742             TDataType dataType( *contentType );
  1749             TDataType dataType( *contentType );
  1743             delete contentType;
  1750             delete contentType;
  1744             contentType = NULL;          
  1751             contentType = NULL;
  1745             CDocumentHandler* docHandler = CDocumentHandler::NewLC();
  1752             CDocumentHandler* docHandler = CDocumentHandler::NewLC();
  1746             isPdSupported = docHandler->CanHandleProgressivelyL( dataType, pdPlayerUid );
  1753             isPdSupported = docHandler->CanHandleProgressivelyL( dataType, pdPlayerUid );
  1747             CleanupStack::PopAndDestroy( docHandler ); // docHandler
  1754             CleanupStack::PopAndDestroy( docHandler ); // docHandler
  1748             
  1755 
  1749             if ( isPdSupported && iUiUtils->IsNetworkPdCompatibleL() )
  1756             if ( isPdSupported && iUiUtils->IsNetworkPdCompatibleL() )
  1750                 {
  1757                 {
  1751                 // Get the UI data for the current download
  1758                 // Get the UI data for the current download
  1752                 TDownloadUiData& dlData = iListModel->DlUiData( aDialog.CurrentItemIndex() );
  1759                 TDownloadUiData& dlData = iListModel->DlUiData( aDialog.CurrentItemIndex() );
  1753                 TInt32 state( dlData.iProgressState );       
  1760                 TInt32 state( dlData.iProgressState );
  1754                 TBool isProgressively = ETrue;
  1761                 TBool isProgressively = ETrue;
  1755                 if ( state == EHttpProgContentFileMoved || state == EHttpProgContentFileMovedAndDestFNChanged )
  1762                 if ( state == EHttpProgContentFileMoved || state == EHttpProgContentFileMovedAndDestFNChanged )
  1756                     {
  1763                     {
  1757                     // this will be used to tell multimedia app that content file
  1764                     // this will be used to tell multimedia app that content file
  1758                     // has already been moved, and it does not need to attach
  1765                     // has already been moved, and it does not need to attach
  1759                     // to download - it can just read completed download from
  1766                     // to download - it can just read completed download from
  1760                     // filesystem.
  1767                     // filesystem.
  1761                     isProgressively = EFalse;                       
  1768                     isProgressively = EFalse;
  1762                     }
  1769                     }
  1763                 // First close the downloads list.
  1770                 // First close the downloads list.
  1764                 CancelDisplayingDownloadsList();
  1771                 CancelDisplayingDownloadsList();
  1765                 iUiUtils->LaunchPdAppL(currDownload, isProgressively);
  1772                 iUiUtils->LaunchPdAppL(currDownload, isProgressively);
  1766                 }
  1773                 }
  1767             else 
  1774             else
  1768                 {
  1775                 {
  1769                 iUiUtils->HandleContentL( currDownload, *iExtension );
  1776                 iUiUtils->HandleContentL( currDownload, *iExtension );
  1770                 CLOG_WRITE("HandleContentL OK");              
  1777                 CLOG_WRITE("HandleContentL OK");
  1771                 }
  1778                 }
  1772 			}
  1779 			}
  1773 		else
  1780 		else
  1774 			{
  1781 			{
  1775     	    iUiUtils->HandleContentL( currDownload, *iExtension );
  1782     	    iUiUtils->HandleContentL( currDownload, *iExtension );
  1776 	        CLOG_WRITE("HandleContentL OK");                        
  1783 	        CLOG_WRITE("HandleContentL OK");
  1777 			}
  1784 			}
  1778            break;
  1785            break;
  1779             }
  1786             }
  1780 
  1787 
  1781 
  1788 
  1784             // First close the downloads list.
  1791             // First close the downloads list.
  1785             CancelDisplayingDownloadsList();
  1792             CancelDisplayingDownloadsList();
  1786             CLOG_WRITE(" CancelDisplayingDownloadsList OK");
  1793             CLOG_WRITE(" CancelDisplayingDownloadsList OK");
  1787 
  1794 
  1788            iUiUtils->HandleContentL( currDownload, *iExtension );
  1795            iUiUtils->HandleContentL( currDownload, *iExtension );
  1789            CLOG_WRITE("HandleContentL OK");            	
  1796            CLOG_WRITE("HandleContentL OK");
  1790            // After the termination of the handler, download is removed 
  1797            // After the termination of the handler, download is removed
  1791            // from the list of downloads in NotifyHandlerExitL().
  1798            // from the list of downloads in NotifyHandlerExitL().
  1792             break;
  1799             break;
  1793             }
  1800             }
  1794             
  1801 
  1795         case EDownloadsListCmdPlay:
  1802         case EDownloadsListCmdPlay:
  1796             {
  1803             {
  1797 			#ifdef __DMGR_PD_TESTHARNESS
  1804 			#ifdef __DMGR_PD_TESTHARNESS
  1798                 // First close the downloads list.
  1805                 // First close the downloads list.
  1799                 CancelDisplayingDownloadsList();
  1806                 CancelDisplayingDownloadsList();
  1800 				iUiUtils->TestLaunchPdAppL(currDownload);
  1807 				iUiUtils->TestLaunchPdAppL(currDownload);
  1801 			#else
  1808 			#else
  1802 				// Get the UI data for the current download
  1809 				// Get the UI data for the current download
  1803                 TDownloadUiData& dlData = iListModel->DlUiData( aDialog.CurrentItemIndex() );
  1810                 TDownloadUiData& dlData = iListModel->DlUiData( aDialog.CurrentItemIndex() );
  1804                 TInt32 state( dlData.iProgressState );       
  1811                 TInt32 state( dlData.iProgressState );
  1805                 TBool isProgressively = ETrue;
  1812                 TBool isProgressively = ETrue;
  1806                 if ( state == EHttpProgContentFileMoved || state == EHttpProgContentFileMovedAndDestFNChanged )
  1813                 if ( state == EHttpProgContentFileMoved || state == EHttpProgContentFileMovedAndDestFNChanged )
  1807                     {
  1814                     {
  1808                     // this will be used to tell multimedia app that content file
  1815                     // this will be used to tell multimedia app that content file
  1809                     // has already been moved, and it does not need to attach
  1816                     // has already been moved, and it does not need to attach
  1810                     // to download - it can just read completed download from
  1817                     // to download - it can just read completed download from
  1811                     // filesystem.
  1818                     // filesystem.
  1812                     isProgressively = EFalse;                     	
  1819                     isProgressively = EFalse;
  1813                     }
  1820                     }
  1814                     // First close the downloads list.
  1821                     // First close the downloads list.
  1815                     CancelDisplayingDownloadsList();
  1822                     CancelDisplayingDownloadsList();
  1816 					if (iUiUtils->IsNetworkPdCompatibleL() )
  1823 					if (iUiUtils->IsNetworkPdCompatibleL() )
  1817 						{
  1824 						{
  1819 						}
  1826 						}
  1820 			#endif	//__DMGR_PD_TESTHARNESS
  1827 			#endif	//__DMGR_PD_TESTHARNESS
  1821 
  1828 
  1822             break;
  1829             break;
  1823             }
  1830             }
  1824             
  1831 
  1825         case EDownloadsListCmdSave:
  1832         case EDownloadsListCmdSave:
  1826             {
  1833             {
  1827             TBool saved = iUiUtils->SaveContentL( currDownload );
  1834             TBool saved = iUiUtils->SaveContentL( currDownload );
  1828             if ( saved )
  1835             if ( saved )
  1829                 {
  1836                 {
  1830                 // Remove the download from the Downloads List to 
  1837                 // Remove the download from the Downloads List to
  1831                 // avoid confusion...
  1838                 // avoid confusion...
  1832                 DeleteDownloadL( currDownload );
  1839                 DeleteDownloadL( currDownload );
  1833                 }
  1840                 }
  1834 	        // The save (moving) procedure is asynchronous!
  1841 	        // The save (moving) procedure is asynchronous!
  1835 	        // CUserInteractionsEventHandler handles 
  1842 	        // CUserInteractionsEventHandler handles
  1836 	        // EHttpDlCompleted/EHttpProgMovingContentFile and
  1843 	        // EHttpDlCompleted/EHttpProgMovingContentFile and
  1837 	        // EHttpDlCompleted/EHttpProgContentFileMoved.
  1844 	        // EHttpDlCompleted/EHttpProgContentFileMoved.
  1838             break;
  1845             break;
  1839             }
  1846             }
  1840 
  1847 
  1841         case EDownloadsListCmdDelete:
  1848         case EDownloadsListCmdDelete:
  1842             {
  1849             {
  1843             // Retrieve the full path to filename before deletion
  1850             // Retrieve the full path to filename before deletion
  1844             // this way we check if the the actuall content file was deleted or not, 
  1851             // this way we check if the the actuall content file was deleted or not,
  1845             // if not, we will manually delete it
  1852             // if not, we will manually delete it
  1846             HBufC* fileName = HBufC::NewLC( KMaxPath );
  1853             HBufC* fileName = HBufC::NewLC( KMaxPath );
  1847             TPtr fileNamePtr = fileName->Des();
  1854             TPtr fileNamePtr = fileName->Des();
  1848             User::LeaveIfError
  1855             User::LeaveIfError
  1849                ( currDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) );
  1856                ( currDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) );
  1871                           HBufC* infoPrompt = StringLoader::LoadLC( R_DMUL_ERROR_FILE_NOT_FOUND);
  1878                           HBufC* infoPrompt = StringLoader::LoadLC( R_DMUL_ERROR_FILE_NOT_FOUND);
  1872                           CAknInformationNote* note = new(ELeave)  CAknInformationNote();
  1879                           CAknInformationNote* note = new(ELeave)  CAknInformationNote();
  1873                           note->ExecuteLD(*infoPrompt);
  1880                           note->ExecuteLD(*infoPrompt);
  1874                           CleanupStack::PopAndDestroy(infoPrompt);
  1881                           CleanupStack::PopAndDestroy(infoPrompt);
  1875                          }
  1882                          }
  1876     			   // Do not wait until the delete event is reported through the 
  1883     			   // Do not wait until the delete event is reported through the
  1877     			   // observer callback, but update the list right now, 
  1884     			   // observer callback, but update the list right now,
  1878     			   // so the user will not be able to access and modify an already
  1885     			   // so the user will not be able to access and modify an already
  1879     			   // deleted download:
  1886     			   // deleted download:
  1880     			   DeleteDownloadL( currDownload );
  1887     			   DeleteDownloadL( currDownload );
  1881     			   TBool result( EFalse );
  1888     			   TBool result( EFalse );
  1882     			   RFs rfs;
  1889     			   RFs rfs;
  1890     			       result = BaflUtils::DeleteFile( rfs, fileNamePtr );
  1897     			       result = BaflUtils::DeleteFile( rfs, fileNamePtr );
  1891     			       }
  1898     			       }
  1892     			   CleanupStack::PopAndDestroy( &rfs );
  1899     			   CleanupStack::PopAndDestroy( &rfs );
  1893 
  1900 
  1894     			   // Notify Media Gallery about new media file
  1901     			   // Notify Media Gallery about new media file
  1895     			   
  1902 
  1896     			#ifdef BRDO_APP_GALLERY_SUPPORTED_FF   
  1903     			#ifdef BRDO_APP_GALLERY_SUPPORTED_FF
  1897     			
  1904 
  1898     			   CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL(
  1905     			   CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL(
  1899     			       CEikonEnv::Static()->FsSession() );
  1906     			       CEikonEnv::Static()->FsSession() );
  1900     			   if( fileNamePtr.Length() > 0 )
  1907     			   if( fileNamePtr.Length() > 0 )
  1901     			       {
  1908     			       {
  1902     			       TRAP_IGNORE( mgFileManager->UpdateL( fileNamePtr ) );
  1909     			       TRAP_IGNORE( mgFileManager->UpdateL( fileNamePtr ) );
  1904     			       }
  1911     			       }
  1905     			   else
  1912     			   else
  1906     			       {
  1913     			       {
  1907     			       TRAP_IGNORE( mgFileManager->UpdateL() );
  1914     			       TRAP_IGNORE( mgFileManager->UpdateL() );
  1908     			       }
  1915     			       }
  1909     			 
  1916 
  1910     			   delete mgFileManager;
  1917     			   delete mgFileManager;
  1911     			   mgFileManager = NULL;
  1918     			   mgFileManager = NULL;
  1912     			 
  1919 
  1913     			 #else
  1920     			 #else
  1914     			 
  1921 
  1915     			  if( fileNamePtr.Length() > 0 )
  1922     			  if( fileNamePtr.Length() > 0 )
  1916     			       {
  1923     			       {
  1917     			       TRAP_IGNORE( iUiUtils->UpdateDCFRepositoryL( fileNamePtr ) );
  1924     			       TRAP_IGNORE( iUiUtils->UpdateDCFRepositoryL( fileNamePtr ) );
  1918     			       }
  1925     			       }
  1919     			 
  1926 
  1920     			 #endif  
  1927     			 #endif
  1921     			   
  1928 
  1922                 	}
  1929                 	}
  1923                  else
  1930                  else
  1924     	           	{
  1931     	           	{
  1925     	           	DeleteDownloadL( currDownload );
  1932     	           	DeleteDownloadL( currDownload );
  1926     	           	} 
  1933     	           	}
  1927     			 }
  1934     			 }
  1928 
  1935 
  1929                CleanupStack::PopAndDestroy( fileName );
  1936                CleanupStack::PopAndDestroy( fileName );
  1930                break;
  1937                break;
  1931            }
  1938            }
  1961             for ( TInt i = 0; i < count; ++i )
  1968             for ( TInt i = 0; i < count; ++i )
  1962                 {
  1969                 {
  1963                 RHttpDownload& download = iListModel->Download(i);
  1970                 RHttpDownload& download = iListModel->Download(i);
  1964                 TInt32 dlState(0);
  1971                 TInt32 dlState(0);
  1965                 TInt err = download.GetIntAttribute( EDlAttrState, dlState );
  1972                 TInt err = download.GetIntAttribute( EDlAttrState, dlState );
  1966                 
  1973 
  1967                 //Changes for the bug JERI-7P8CF2
  1974                 //Changes for the bug JERI-7P8CF2
  1968                 //Changes made in the server side to fix the video center receiving unexpected events
  1975                 //Changes made in the server side to fix the video center receiving unexpected events
  1969                 //Reassigning these events back to the changes done in server side
  1976                 //Reassigning these events back to the changes done in server side
  1970                 if( !err && dlState  == EHttpDlCompleted )
  1977                 if( !err && dlState  == EHttpDlCompleted )
  1971 		            {
  1978 		            {
  1973 		            }
  1980 		            }
  1974                 else if( !err && dlState  == EHttpDlFailed )
  1981                 else if( !err && dlState  == EHttpDlFailed )
  1975 		            {
  1982 		            {
  1976 		    	     dlState  = EHttpDlMultipleMOFailed;
  1983 		    	     dlState  = EHttpDlMultipleMOFailed;
  1977 		            }
  1984 		            }
  1978                 
  1985 
  1979                 if ( !err && ( dlState == EHttpDlPaused || dlState == EHttpDlMultipleMOFailed ) )
  1986                 if ( !err && ( dlState == EHttpDlPaused || dlState == EHttpDlMultipleMOFailed ) )
  1980                     {
  1987                     {
  1981                     download.Start(); // return value is ignored.
  1988                     download.Start(); // return value is ignored.
  1982                     }
  1989                     }
  1983                 }
  1990                 }
  1994 	            if (err != KErrNone)
  2001 	            if (err != KErrNone)
  1995 	            	{
  2002 	            	{
  1996 	            	iIsCancelInProgress = EFalse;
  2003 	            	iIsCancelInProgress = EFalse;
  1997 	            	User::LeaveIfError(err);
  2004 	            	User::LeaveIfError(err);
  1998 	            	}
  2005 	            	}
  1999 	            
  2006 
  2000 	            if ( cancelled )
  2007 	            if ( cancelled )
  2001 	                {
  2008 	                {
  2002                     DeleteDownloadL( currDownload );
  2009 	                DeleteDownloadL( currDownload );
  2003                     
       
  2004 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF     
       
  2005                     TInt currentItemIndex = aDialog.CurrentItemIndex();
       
  2006                     if (currentItemIndex != -1)
       
  2007                         {   
       
  2008                         TInt Inprogress = iListModel->DownloadsCount
       
  2009                                       ( MASKED_DL_STATE(EHttpDlCreated) |
       
  2010                                         MASKED_DL_STATE(EHttpDlPaused) |
       
  2011                                         MASKED_DL_STATE(EHttpDlInprogress) |
       
  2012                                         MASKED_DL_STATE(EHttpDlMultipleMOFailed));
       
  2013                         if ( Inprogress > 1 )
       
  2014                             {
       
  2015                             aDialog.ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeyOptions, ETrue );
       
  2016                             } 
       
  2017                         else
       
  2018                             {
       
  2019                             aDialog.ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeyOptions, EFalse );
       
  2020                             }
       
  2021                         }
       
  2022 #endif                    
       
  2023 	                }
  2010 	                }
  2024 	            iIsCancelInProgress = EFalse;
  2011 	            iIsCancelInProgress = EFalse;
  2025             	}
  2012             	}
  2026             break;
  2013             break;
  2027             }
  2014             }
  2028             
  2015 
  2029         case EDownloadsListCmdCancelAll:
  2016         case EDownloadsListCmdCancelAll:
  2030         	{
  2017         	{
  2031             if (!iIsCancelInProgress)
  2018             if (!iIsCancelInProgress)
  2032             	{
  2019             	{
  2033             	iIsCancelInProgress = ETrue;
  2020             	iIsCancelInProgress = ETrue;
  2056         	break;
  2043         	break;
  2057         	}
  2044         	}
  2058 
  2045 
  2059         case EDownloadsListCmdGallery:
  2046         case EDownloadsListCmdGallery:
  2060             {
  2047             {
  2061             
  2048 
  2062 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
  2049 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
  2063             
  2050 
  2064             TVwsViewId id = TVwsViewId(
  2051             TVwsViewId id = TVwsViewId(
  2065                 TUid::Uid( KMediaGalleryUID3 ),
  2052                 TUid::Uid( KMediaGalleryUID3 ),
  2066                 TUid::Uid( KMediaGalleryListViewUID ) );
  2053                 TUid::Uid( KMediaGalleryListViewUID ) );
  2067 
  2054 
  2068             // By default, custom message is empty
  2055             // By default, custom message is empty
  2069             TPtrC8 customMessage( KNullDesC8 );
  2056             TPtrC8 customMessage( KNullDesC8 );
  2070 
  2057 
  2071             CEikonEnv::Static()->EikAppUi()->ActivateViewL( 
  2058             CEikonEnv::Static()->EikAppUi()->ActivateViewL(
  2072                     id, 
  2059                     id,
  2073                     TUid::Uid( KMediaGalleryCmdMoveFocusToAllFilesTab ),
  2060                     TUid::Uid( KMediaGalleryCmdMoveFocusToAllFilesTab ),
  2074                     customMessage );
  2061                     customMessage );
  2075 #endif                    
  2062 #endif
  2076             break;
  2063             break;
  2077             }
  2064             }
  2078       
  2065 
  2079         case EDownloadsListCmdFileManager:
  2066         case EDownloadsListCmdFileManager:
  2080             {
  2067             {
  2081  
  2068 
  2082             if ( iPlatformSupportsGallery )
  2069             if ( iPlatformSupportsGallery )
  2083                 {
  2070                 {
  2084             	LaunchFileManagerApplication();
  2071             	LaunchFileManagerApplication();
  2085                 }
  2072                 }
  2086             else
  2073             else
  2087                 {
  2074                 {
  2088             	CAiwServiceHandler* serviceHandler = CAiwServiceHandler::NewL();
  2075             	CAiwServiceHandler* serviceHandler = CAiwServiceHandler::NewL();
  2089                 serviceHandler->AttachL( R_DMUL_FILEMANAGER_AIW_INTEREST );
  2076                 serviceHandler->AttachL( R_DMUL_FILEMANAGER_AIW_INTEREST );
  2090             
  2077 
  2091                 CAiwGenericParamList* inParams = CAiwGenericParamList::NewLC();
  2078                 CAiwGenericParamList* inParams = CAiwGenericParamList::NewLC();
  2092              
  2079 
  2093                 //get the destination file path
  2080                 //get the destination file path
  2094                 HBufC* fileName = HBufC::NewLC( KMaxPath );
  2081                 HBufC* fileName = HBufC::NewLC( KMaxPath );
  2095                 TPtr fileNamePtr = fileName->Des();
  2082                 TPtr fileNamePtr = fileName->Des();
  2096                 User::LeaveIfError ( currDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) );
  2083                 User::LeaveIfError ( currDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) );
  2097                
  2084 
  2098                 // Locate the last '\\' character and remove the file name so that we will get the folder name
  2085                 // Locate the last '\\' character and remove the file name so that we will get the folder name
  2099                 TInt len = fileNamePtr.LocateReverse('\\');
  2086                 TInt len = fileNamePtr.LocateReverse('\\');
  2100                 TPtr ptr = fileNamePtr.LeftTPtr(len + 1);
  2087                 TPtr ptr = fileNamePtr.LeftTPtr(len + 1);
  2101             
  2088 
  2102                 // Append the directory name to be opened
  2089                 // Append the directory name to be opened
  2103                 inParams->AppendL(TAiwGenericParam(EGenericParamDir, TAiwVariant( ptr ) ) );
  2090                 inParams->AppendL(TAiwGenericParam(EGenericParamDir, TAiwVariant( ptr ) ) );
  2104                 //Append the sort method
  2091                 //Append the sort method
  2105                 inParams->AppendL(TAiwGenericParam(EGenericParamDir, TAiwVariant( KMostRecentSort ) ) );
  2092                 inParams->AppendL(TAiwGenericParam(EGenericParamDir, TAiwVariant( KMostRecentSort ) ) );
  2106                 //Append to define whether to open in standalone mode
  2093                 //Append to define whether to open in standalone mode
  2107                 inParams->AppendL(TAiwGenericParam(EGenericParamDir, TAiwVariant( KLauchStandAlone ) ) );
  2094                 inParams->AppendL(TAiwGenericParam(EGenericParamDir, TAiwVariant( KLauchStandAlone ) ) );
  2108     
  2095 
  2109                 TRAPD( err, serviceHandler->ExecuteServiceCmdL( KAiwCmdEdit, *inParams, serviceHandler->OutParamListL() ));
  2096                 TRAPD( err, serviceHandler->ExecuteServiceCmdL( KAiwCmdEdit, *inParams, serviceHandler->OutParamListL() ));
  2110             
  2097 
  2111     	   		CleanupStack::PopAndDestroy( fileName );
  2098     	   		CleanupStack::PopAndDestroy( fileName );
  2112             	CleanupStack::PopAndDestroy( inParams );
  2099             	CleanupStack::PopAndDestroy( inParams );
  2113         	
  2100 
  2114         	    delete serviceHandler;
  2101         	    delete serviceHandler;
  2115         	    
  2102 
  2116         	    //if there is any error, open the file manager in root folder
  2103         	    //if there is any error, open the file manager in root folder
  2117                 if (err != KErrNone)
  2104                 if (err != KErrNone)
  2118           	        {
  2105           	        {
  2119           	        LaunchFileManagerApplication();
  2106           	        LaunchFileManagerApplication();
  2120            		    }
  2107            		    }
  2121                 }
  2108                 }
  2122   
  2109 
  2123             break;
  2110             break;
  2124             }
  2111             }
  2125          
  2112 
  2126         default:
  2113         default:
  2127             {
  2114             {
  2128             break;
  2115             break;
  2129             }
  2116             }
  2130         }
  2117         }
  2131     }
  2118     }
  2132     
  2119 
  2133     
  2120 
  2134 // -----------------------------------------------------------------------------
  2121 // -----------------------------------------------------------------------------
  2135 // CDownloadMgrUiDownloadsList::LaunchFileManagerApplication
  2122 // CDownloadMgrUiDownloadsList::LaunchFileManagerApplication
  2136 // -----------------------------------------------------------------------------
  2123 // -----------------------------------------------------------------------------
  2137 //
  2124 //
  2138 
  2125 
  2139 void CDownloadMgrUiDownloadsList::LaunchFileManagerApplication()
  2126 void CDownloadMgrUiDownloadsList::LaunchFileManagerApplication()
  2140 {
  2127 {
  2141 	
  2128 
  2142     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
  2129     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
  2143     CRepository *repository=CRepository::NewL(KCRUidBrowser);
  2130     CRepository *repository=CRepository::NewL(KCRUidBrowser);
  2144     TInt fileManagerId;
  2131     TInt fileManagerId;
  2145     User::LeaveIfError(repository->Get(KFileManagerUid , fileManagerId ));
  2132     User::LeaveIfError(repository->Get(KFileManagerUid , fileManagerId ));
  2146     TUid id = TUid::Uid(fileManagerId);
  2133     TUid id = TUid::Uid(fileManagerId);
  2147     TApaTask task = taskList.FindApp( id );
  2134     TApaTask task = taskList.FindApp( id );
  2148     if ( task.Exists() )
  2135     if ( task.Exists() )
  2149         {
  2136         {
  2150         task.BringToForeground();
  2137         task.BringToForeground();
  2151         }
  2138         }
  2152     else 
  2139     else
  2153         {
  2140         {
  2154         RApaLsSession appArcSession;
  2141         RApaLsSession appArcSession;
  2155         User::LeaveIfError( appArcSession.Connect() );
  2142         User::LeaveIfError( appArcSession.Connect() );
  2156         CleanupClosePushL( appArcSession );
  2143         CleanupClosePushL( appArcSession );
  2157         TThreadId id1;
  2144         TThreadId id1;
  2158         User::LeaveIfError( appArcSession.StartDocument( KNullDesC, id, id1 ) );  
  2145         User::LeaveIfError( appArcSession.StartDocument( KNullDesC, id, id1 ) );
  2159         CleanupStack::PopAndDestroy( &appArcSession );
  2146         CleanupStack::PopAndDestroy( &appArcSession );
  2160         }
  2147         }
  2161 	
  2148 
  2162 }
  2149 }
  2163 
  2150 
  2164 
  2151 
  2165 // -----------------------------------------------------------------------------
  2152 // -----------------------------------------------------------------------------
  2166 // CDownloadMgrUiDownloadsList::DynInitMenuPaneL
  2153 // CDownloadMgrUiDownloadsList::DynInitMenuPaneL
  2167 // -----------------------------------------------------------------------------
  2154 // -----------------------------------------------------------------------------
  2168 //
  2155 //
  2169 void CDownloadMgrUiDownloadsList::DynInitMenuPaneL( CDownloadsListDlg& aDialog, 
  2156 void CDownloadMgrUiDownloadsList::DynInitMenuPaneL( CDownloadsListDlg& aDialog,
  2170                                                     TInt aResourceId, 
  2157                                                     TInt aResourceId,
  2171                                                     CEikMenuPane* aMenuPane )
  2158                                                     CEikMenuPane* aMenuPane )
  2172     {
  2159     {
  2173     CLOG_ENTERFN("CDownloadMgrUiDownloadsList::DynInitMenuPaneL");
  2160     CLOG_ENTERFN("CDownloadMgrUiDownloadsList::DynInitMenuPaneL");
  2174 
  2161 
  2175     __ASSERT_DEBUG( iExtension->IsDialogVisible(), Panic( EUiLibPanNull ) );
  2162     __ASSERT_DEBUG( iExtension->IsDialogVisible(), Panic( EUiLibPanNull ) );
  2181 
  2168 
  2182         TInt currentItemIndex = aDialog.CurrentItemIndex();
  2169         TInt currentItemIndex = aDialog.CurrentItemIndex();
  2183         __ASSERT_DEBUG( 0 <= currentItemIndex, Panic( EUiLibPanDLNegItemIndex ) );
  2170         __ASSERT_DEBUG( 0 <= currentItemIndex, Panic( EUiLibPanDLNegItemIndex ) );
  2184         RHttpDownload& currDownload = iListModel->Download( currentItemIndex );
  2171         RHttpDownload& currDownload = iListModel->Download( currentItemIndex );
  2185         CLOG_WRITE_FORMAT(" currDownload: 0x%x",&currDownload);
  2172         CLOG_WRITE_FORMAT(" currDownload: 0x%x",&currDownload);
  2186         
  2173 
  2187         // Get the UI data for the current download
  2174         // Get the UI data for the current download
  2188         TDownloadUiData& dlData = iListModel->DlUiData( aDialog.CurrentItemIndex() );
  2175         TDownloadUiData& dlData = iListModel->DlUiData( aDialog.CurrentItemIndex() );
  2189         TInt32 state( dlData.iDownloadState );
  2176         TInt32 state( dlData.iDownloadState );
  2190         CLOG_WRITE_FORMAT(" state: %d",state);
  2177         CLOG_WRITE_FORMAT(" state: %d",state);
  2191 
  2178 
  2192         // The moved state is only a temporary state - the server 
  2179         // The moved state is only a temporary state - the server
  2193         // sets the download's original state back right after it, 
  2180         // sets the download's original state back right after it,
  2194         // thus we query the state again:
  2181         // thus we query the state again:
  2195         if ( state == EHttpDlMoved )
  2182         if ( state == EHttpDlMoved )
  2196             {
  2183             {
  2197             User::LeaveIfError( currDownload.GetIntAttribute( EDlAttrState, state ) );
  2184             User::LeaveIfError( currDownload.GetIntAttribute( EDlAttrState, state ) );
  2198             
  2185 
  2199             //Changes for the bug JERI-7P8CF2
  2186             //Changes for the bug JERI-7P8CF2
  2200             //Changes made in the server side to fix the video center receiving unexpected events
  2187             //Changes made in the server side to fix the video center receiving unexpected events
  2201             //Reassigning these events back to the changes done in server side
  2188             //Reassigning these events back to the changes done in server side
  2202             if( state  == EHttpDlCompleted )
  2189             if( state  == EHttpDlCompleted )
  2203 		        {
  2190 		        {
  2205 		        }
  2192 		        }
  2206             else if(state  == EHttpDlFailed )
  2193             else if(state  == EHttpDlFailed )
  2207 		        {
  2194 		        {
  2208 		        state  = EHttpDlMultipleMOFailed;
  2195 		        state  = EHttpDlMultipleMOFailed;
  2209 		        }
  2196 		        }
  2210 		            
  2197 
  2211             CLOG_WRITE_FORMAT(" state re-query: %d",state);
  2198             CLOG_WRITE_FORMAT(" state re-query: %d",state);
  2212             }
  2199             }
  2213         __ASSERT_DEBUG( state != EHttpDlMoved, Panic( EUiLibPanStateIsStillMoved ) );        
  2200         __ASSERT_DEBUG( state != EHttpDlMoved, Panic( EUiLibPanStateIsStillMoved ) );
  2214         
  2201 
  2215         TBool wasCompleted   = state == EHttpDlMultipleMOCompleted;        
  2202         TBool wasCompleted   = state == EHttpDlMultipleMOCompleted;
  2216         
  2203 
  2217         // Get if it's theme         
  2204         // Get if it's theme
  2218         TInt isThemeType = 0; 
  2205         TInt isThemeType = 0;
  2219         HBufC8* contentType = HBufC8::NewLC(KMaxContentTypeLength);
  2206         HBufC8* contentType = HBufC8::NewLC(KMaxContentTypeLength);
  2220         TPtr8 contentTypePtr = contentType->Des(); 
  2207         TPtr8 contentTypePtr = contentType->Des();
  2221         User::LeaveIfError
  2208         User::LeaveIfError
  2222                 ( currDownload.GetStringAttribute( EDlAttrContentType, contentTypePtr ) );
  2209                 ( currDownload.GetStringAttribute( EDlAttrContentType, contentTypePtr ) );
  2223         isThemeType = !contentType->Compare(KSisxContentType);  
  2210         isThemeType = !contentType->Compare(KSisxContentType);
  2224         CleanupStack::PopAndDestroy( contentType );        
  2211         CleanupStack::PopAndDestroy( contentType );
  2225 		
  2212 
  2226     if ( aResourceId == R_DMUL_DOWNLOADSLIST_MENU )
  2213     if ( aResourceId == R_DMUL_DOWNLOADSLIST_MENU )
  2227         {
  2214         {
  2228         __ASSERT_DEBUG( 0<iListModel->Count(), Panic( EUiLibPanOptionsShownWhileNoDownloads ) );
  2215         __ASSERT_DEBUG( 0<iListModel->Count(), Panic( EUiLibPanOptionsShownWhileNoDownloads ) );
  2229 
  2216 
  2230         TBool isCreated     = state == EHttpDlCreated;
  2217         TBool isCreated     = state == EHttpDlCreated;
  2231         // The fix of PHAN-6KVK5R makes this line no longer necessary 
  2218         // The fix of PHAN-6KVK5R makes this line no longer necessary
  2232         // TBool isInProgress  = state == EHttpDlInprogress;
  2219         // TBool isInProgress  = state == EHttpDlInprogress;
  2233         TBool isPaused      = state == EHttpDlPaused;
  2220         TBool isPaused      = state == EHttpDlPaused;
  2234         TBool isCompleted   = state == EHttpDlMultipleMOCompleted;
  2221         TBool isCompleted   = state == EHttpDlMultipleMOCompleted;
  2235         TBool isFailed      = state == EHttpDlMultipleMOFailed;
  2222         TBool isFailed      = state == EHttpDlMultipleMOFailed;
  2236         TBool isDrmDownload = EFalse;
  2223         TBool isDrmDownload = EFalse;
  2248             }
  2235             }
  2249         TBool s60Supported( EFalse );
  2236         TBool s60Supported( EFalse );
  2250         TBool gallerySupported( EFalse );
  2237         TBool gallerySupported( EFalse );
  2251         s60Supported = iUiUtils->IsContentTypeSupportedL( dlData.iContentType );
  2238         s60Supported = iUiUtils->IsContentTypeSupportedL( dlData.iContentType );
  2252         gallerySupported = CDownloadUtils::IsGallerySupported(dlData.iContentType);
  2239         gallerySupported = CDownloadUtils::IsGallerySupported(dlData.iContentType);
  2253         CLOG_WRITE_FORMAT(" s60Supported: %d",s60Supported);       
  2240         CLOG_WRITE_FORMAT(" s60Supported: %d",s60Supported);
  2254         CLOG_WRITE_FORMAT(" gallerySupported: %d",gallerySupported);        
  2241         CLOG_WRITE_FORMAT(" gallerySupported: %d",gallerySupported);
  2255 
  2242 
  2256         TBool isCodDownload( EFalse );
  2243         TBool isCodDownload( EFalse );
  2257         TInt err = currDownload.GetBoolAttribute( EDlAttrCodDownload, isCodDownload );
  2244         TInt err = currDownload.GetBoolAttribute( EDlAttrCodDownload, isCodDownload );
  2258         CLOG_WRITE_FORMAT(" EDlAttrCodDownload err: %d",err);
  2245         CLOG_WRITE_FORMAT(" EDlAttrCodDownload err: %d",err);
  2259         
  2246 
  2260         TBool isCodPdDownload( EFalse );
  2247         TBool isCodPdDownload( EFalse );
  2261         err = currDownload.GetBoolAttribute( EDlAttrCodPdAvailable, isCodPdDownload );
  2248         err = currDownload.GetBoolAttribute( EDlAttrCodPdAvailable, isCodPdDownload );
  2262         CLOG_WRITE_FORMAT(" EDlAttrCodPdAvailable err: %d",err);
  2249         CLOG_WRITE_FORMAT(" EDlAttrCodPdAvailable err: %d",err);
  2263         
  2250 
  2264         // Get if it can be handled progressively 
  2251         // Get if it can be handled progressively
  2265         TBool canProgHandled = EFalse; 
  2252         TBool canProgHandled = EFalse;
  2266         TUid pdPlayerUid = { 0 };    
  2253         TUid pdPlayerUid = { 0 };
  2267         HBufC8* contentType = iUiUtils->ContentTypeL( currDownload, ETrue );
  2254         HBufC8* contentType = iUiUtils->ContentTypeL( currDownload, ETrue );
  2268         TDataType dataType( *contentType );
  2255         TDataType dataType( *contentType );
  2269         delete contentType;
  2256         delete contentType;
  2270         contentType = NULL;          
  2257         contentType = NULL;
  2271         CDocumentHandler* docHandler = CDocumentHandler::NewLC();
  2258         CDocumentHandler* docHandler = CDocumentHandler::NewLC();
  2272         canProgHandled = docHandler->CanHandleProgressivelyL( dataType, pdPlayerUid );
  2259         canProgHandled = docHandler->CanHandleProgressivelyL( dataType, pdPlayerUid );
  2273         CleanupStack::PopAndDestroy( docHandler ); // docHandler              
  2260         CleanupStack::PopAndDestroy( docHandler ); // docHandler
  2274 
  2261 
  2275 #ifndef BRDO_SINGLE_CLICK_ENABLED_FF        
       
  2276         //delete open file manager when download is not complete
  2262         //delete open file manager when download is not complete
  2277         if( !(isCompleted))
  2263         if( !(isCompleted))
  2278             {
  2264             {
  2279             aMenuPane->DeleteMenuItem( EDownloadsListCmdFileManager );    
  2265             aMenuPane->DeleteMenuItem( EDownloadsListCmdFileManager );
  2280             }
  2266             }
  2281             
  2267 
  2282         // For any gallery supported download,  "go to gallery" option should be displayed in the download list option when the download completes     
  2268         // For any gallery supported download,  "go to gallery" option should be displayed in the download list option when the download completes
  2283         
  2269 
  2284         
  2270 
  2285         if ( (!( isCompleted && s60Supported && gallerySupported ) ) || (!iPlatformSupportsGallery) )
  2271         if ( (!( isCompleted && s60Supported && gallerySupported ) ) || (!iPlatformSupportsGallery) )
  2286             {
  2272             {
  2287 			aMenuPane->DeleteMenuItem( EDownloadsListCmdGallery );
  2273 			aMenuPane->DeleteMenuItem( EDownloadsListCmdGallery );
  2288     		}
  2274     		}
  2289     		
  2275 
  2290         if ( !( isCompleted && s60Supported && gallerySupported && 
  2276         if ( !( isCompleted && s60Supported && gallerySupported &&
  2291               ( !isDrmDownload || ( isDrmDownload && isDrmRightsOnPhone ) ) ) )
  2277               ( !isDrmDownload || ( isDrmDownload && isDrmRightsOnPhone ) ) ) )
  2292             {
  2278             {
  2293             aMenuPane->DeleteMenuItem( EDownloadsListCmdUseAs );
  2279             aMenuPane->DeleteMenuItem( EDownloadsListCmdUseAs );
  2294 			}
  2280 			}
  2295     		
  2281 
  2296 	    else
  2282 	    else
  2297 	        {
  2283 	        {
  2298 	        TInt32 numMediaObjects = 0;
  2284 	        TInt32 numMediaObjects = 0;
  2299             User::LeaveIfError( currDownload.GetIntAttribute( EDlAttrNumMediaObjects, numMediaObjects ) );
  2285             User::LeaveIfError( currDownload.GetIntAttribute( EDlAttrNumMediaObjects, numMediaObjects ) );
  2300 	        if (numMediaObjects > KFirstMoIndex)
  2286 	        if (numMediaObjects > KFirstMoIndex)
  2301     	        {
  2287     	        {
  2302 	            aMenuPane->DeleteMenuItem( EDownloadsListCmdUseAs );
  2288 	            aMenuPane->DeleteMenuItem( EDownloadsListCmdUseAs );
  2303 	            }
  2289 	            }
  2304 	        }
  2290 	        }
  2305 	            
  2291 
  2306         if( iProgressiveDownload || isCompleted )
  2292         if( iProgressiveDownload || isCompleted )
  2307             {
  2293             {
  2308             if ( canProgHandled )
  2294             if ( canProgHandled )
  2309                 {
  2295                 {
  2310                 aMenuPane->DeleteMenuItem( EDownloadsListCmdOpen );           
  2296                 aMenuPane->DeleteMenuItem( EDownloadsListCmdOpen );
  2311                 if (isCodDownload && !isCompleted ) 
  2297                 if (isCodDownload && !isCompleted )
  2312                     {
  2298                     {
  2313                     if ( !( gallerySupported && canProgHandled  && isCodPdDownload &&
  2299                     if ( !( gallerySupported && canProgHandled  && isCodPdDownload &&
  2314                        ( !isDrmDownload || ( isDrmDownload && isDrmRightsOnPhone ) ) ) || (isPaused || isFailed))
  2300                        ( !isDrmDownload || ( isDrmDownload && isDrmRightsOnPhone ) ) ) || (isPaused || isFailed))
  2315                        aMenuPane->DeleteMenuItem( EDownloadsListCmdPlay );                
  2301                        aMenuPane->DeleteMenuItem( EDownloadsListCmdPlay );
  2316                     }
  2302                     }
  2317                     else 
  2303                     else
  2318                     {
  2304                     {
  2319                         if ( !( gallerySupported && canProgHandled &&
  2305                         if ( !( gallerySupported && canProgHandled &&
  2320                            ( !isDrmDownload || ( isDrmDownload && isDrmRightsOnPhone ))) || (isPaused || isFailed))           
  2306                            ( !isDrmDownload || ( isDrmDownload && isDrmRightsOnPhone ))) || (isPaused || isFailed))
  2321                            aMenuPane->DeleteMenuItem( EDownloadsListCmdPlay );	
  2307                            aMenuPane->DeleteMenuItem( EDownloadsListCmdPlay );
  2322                     }     
  2308                     }
  2323                 }
  2309                 }
  2324             else 
  2310             else
  2325                 {
  2311                 {
  2326                 aMenuPane->DeleteMenuItem( EDownloadsListCmdPlay );
  2312                 aMenuPane->DeleteMenuItem( EDownloadsListCmdPlay );
  2327             
  2313 
  2328                 if ( !( isCompleted && ( s60Supported ) && 
  2314                 if ( !( isCompleted && ( s60Supported ) &&
  2329                       ( !isDrmDownload || ( isDrmDownload && isDrmRightsOnPhone ) ) ) )
  2315                       ( !isDrmDownload || ( isDrmDownload && isDrmRightsOnPhone ) ) ) )
  2330                     {
  2316                     {
  2331                     aMenuPane->DeleteMenuItem( EDownloadsListCmdOpen );
  2317                     aMenuPane->DeleteMenuItem( EDownloadsListCmdOpen );
  2332                     }
  2318                     }
  2333                
  2319 
  2334          //there should not be open in menu when download is not complete and file is not supported by s60  or Gallery        
  2320          //there should not be open in menu when download is not complete and file is not supported by s60  or Gallery
  2335               /*  else if( isCompleted && ( !s60Supported && !gallerySupported))  
  2321               /*  else if( isCompleted && ( !s60Supported && !gallerySupported))
  2336                     {
  2322                     {
  2337                     aMenuPane->DeleteMenuItem( EDownloadsListCmdOpen );   
  2323                     aMenuPane->DeleteMenuItem( EDownloadsListCmdOpen );
  2338                     }*/
  2324                     }*/
  2339                 }
  2325                 }
  2340              }
  2326              }
  2341             
  2327 
  2342         else // if iProgressiveDownload == EFalse
  2328         else // if iProgressiveDownload == EFalse
  2343             {
  2329             {
  2344             aMenuPane->DeleteMenuItem( EDownloadsListCmdPlay );
  2330             aMenuPane->DeleteMenuItem( EDownloadsListCmdPlay );
  2345             
  2331 
  2346             if ( !( isCompleted && s60Supported && 
  2332             if ( !( isCompleted && s60Supported &&
  2347                   ( !isDrmDownload || ( isDrmDownload && isDrmRightsOnPhone ) ) ) )
  2333                   ( !isDrmDownload || ( isDrmDownload && isDrmRightsOnPhone ) ) ) )
  2348                 {
  2334                 {
  2349                 aMenuPane->DeleteMenuItem( EDownloadsListCmdOpen );
  2335                 aMenuPane->DeleteMenuItem( EDownloadsListCmdOpen );
  2350                 }
  2336                 }
  2351                       
  2337 
  2352             else if( isCompleted && !s60Supported && gallerySupported)  
  2338             else if( isCompleted && !s60Supported && gallerySupported)
  2353                 {
  2339                 {
  2354                 aMenuPane->DeleteMenuItem( EDownloadsListCmdOpen );   
  2340                 aMenuPane->DeleteMenuItem( EDownloadsListCmdOpen );
  2355                 }
  2341                 }
  2356             }
  2342             }
  2357             
  2343 
  2358         // ELFG-732DK3: There is no need to have save option since it's already saved 
  2344         // ELFG-732DK3: There is no need to have save option since it's already saved
  2359         aMenuPane->DeleteMenuItem( EDownloadsListCmdSave ); 
  2345         aMenuPane->DeleteMenuItem( EDownloadsListCmdSave );
  2360                     
  2346 
  2361         if ( !( isCompleted ) )
  2347         if ( !( isCompleted ) )
  2362             {
  2348             {
  2363             aMenuPane->DeleteMenuItem( EDownloadsListCmdDelete );
  2349             aMenuPane->DeleteMenuItem( EDownloadsListCmdDelete );
  2364             }
  2350             }
  2365         else
  2351         else
  2375 */
  2361 */
  2376         if ( !( isCreated || isPaused || isFailed ) )
  2362         if ( !( isCreated || isPaused || isFailed ) )
  2377             {
  2363             {
  2378             aMenuPane->DeleteMenuItem( EDownloadsListCmdResume );
  2364             aMenuPane->DeleteMenuItem( EDownloadsListCmdResume );
  2379             }
  2365             }
  2380         // Count paused downloads. Note that Creates and Failed downloads 
  2366         // Count paused downloads. Note that Creates and Failed downloads
  2381         // are also considered as Paused, and they can be resumed.
  2367         // are also considered as Paused, and they can be resumed.
  2382         TInt pausedCount = iListModel->DownloadsCount
  2368         TInt pausedCount = iListModel->DownloadsCount
  2383                            ( MASKED_DL_STATE(EHttpDlCreated) |
  2369                            ( MASKED_DL_STATE(EHttpDlCreated) |
  2384                              MASKED_DL_STATE(EHttpDlPaused) |
  2370                              MASKED_DL_STATE(EHttpDlPaused) |
  2385                              MASKED_DL_STATE(EHttpDlMultipleMOFailed) );
  2371                              MASKED_DL_STATE(EHttpDlMultipleMOFailed) );
  2386         CLOG_WRITE_FORMAT(" paused count: %d",pausedCount);
  2372         CLOG_WRITE_FORMAT(" paused count: %d",pausedCount);
  2387         //
  2373         //
  2388         if ( !( 1 < pausedCount ) )
  2374         if ( !( 1 < pausedCount ) )
  2389             {
  2375             {
  2390             aMenuPane->DeleteMenuItem( EDownloadsListCmdResumeAll );
  2376             aMenuPane->DeleteMenuItem( EDownloadsListCmdResumeAll );
  2391             } 
  2377             }
  2392             
  2378 
  2393         TInt downloadCount = iListModel->DownloadsCount
  2379         TInt downloadCount = iListModel->DownloadsCount
  2394                              ( MASKED_DL_STATE(EHttpDlCreated) |
  2380                              ( MASKED_DL_STATE(EHttpDlCreated) |
  2395                                MASKED_DL_STATE(EHttpDlInprogress)|
  2381                                MASKED_DL_STATE(EHttpDlInprogress)|
  2396                                MASKED_DL_STATE(EHttpDlPaused) );
  2382                                MASKED_DL_STATE(EHttpDlPaused) );
  2397         CLOG_WRITE_FORMAT(" download count: %d",downloadCount);
  2383         CLOG_WRITE_FORMAT(" download count: %d",downloadCount);
  2398         
  2384 
  2399         if ( !( 1 < downloadCount ) )
  2385         if ( !( 1 < downloadCount ) )
  2400             {
  2386             {
  2401             aMenuPane->DeleteMenuItem( EDownloadsListCmdCancelAll );
  2387             aMenuPane->DeleteMenuItem( EDownloadsListCmdCancelAll );
  2402             }              
  2388             }
  2403                              
  2389 
  2404        	if ( iPlatformSupportsGallery )
  2390        	if ( iPlatformSupportsGallery )
  2405        	    {
  2391        	    {
  2406        		if ( isCompleted && gallerySupported && s60Supported )
  2392        		if ( isCompleted && gallerySupported && s60Supported )
  2407                 {
  2393                 {
  2408                 aMenuPane->DeleteMenuItem( EDownloadsListCmdFileManager );
  2394                 aMenuPane->DeleteMenuItem( EDownloadsListCmdFileManager );
  2409                 }
  2395                 }
  2410             }
  2396        	    }
  2411 #else
  2397         }
  2412     // Count paused downloads. Note that Creates and Failed downloads 
  2398 
  2413             // are also considered as Paused, and they can be resumed.
  2399     if ( wasCompleted && !isThemeType )
  2414             TInt pausedCount = iListModel->DownloadsCount
  2400         {
  2415                                ( MASKED_DL_STATE(EHttpDlCreated) |
  2401         InitializeAIWPlugInMenusL( aResourceId, aMenuPane, currDownload );
  2416                                  MASKED_DL_STATE(EHttpDlPaused) |
       
  2417                                  MASKED_DL_STATE(EHttpDlMultipleMOFailed) );
       
  2418             CLOG_WRITE_FORMAT(" paused count: %d",pausedCount);
       
  2419             //
       
  2420             if ( !( 1 < pausedCount ) )
       
  2421                 {
       
  2422                 aMenuPane->DeleteMenuItem( EDownloadsListCmdResumeAll );
       
  2423                 } 
       
  2424                 
       
  2425             TInt downloadCount = iListModel->DownloadsCount
       
  2426                                  ( MASKED_DL_STATE(EHttpDlCreated) |
       
  2427                                    MASKED_DL_STATE(EHttpDlInprogress)|
       
  2428                                    MASKED_DL_STATE(EHttpDlPaused) );
       
  2429             CLOG_WRITE_FORMAT(" download count: %d",downloadCount);
       
  2430             
       
  2431             if ( !( 1 < downloadCount ) )
       
  2432                 {
       
  2433                 aMenuPane->DeleteMenuItem( EDownloadsListCmdCancelAll );
       
  2434                 }              
       
  2435 #endif          
       
  2436         }
       
  2437     if ( wasCompleted && !isThemeType ) 
       
  2438         {
       
  2439         InitializeAIWPlugInMenusL( aResourceId, aMenuPane, currDownload );		
       
  2440         }
  2402         }
  2441     CLOG_LEAVEFN("CDownloadMgrUiDownloadsList::DynInitMenuPaneL");
  2403     CLOG_LEAVEFN("CDownloadMgrUiDownloadsList::DynInitMenuPaneL");
  2442     }
  2404     }
  2443 
  2405 
  2444 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF
       
  2445 void CDownloadMgrUiDownloadsList::AIWPlugInMenusL(TInt aResourceId,CEikMenuPane* aMenuPane)
       
  2446     {
       
  2447     if( !iAIWServiceHandler )
       
  2448         {
       
  2449         AttachAIWInterestL();
       
  2450         }
       
  2451     RHttpDownload& currDownload = iListModel->Download( 0 );
       
  2452     InitializeAIWPlugInMenusL( aResourceId, aMenuPane, currDownload );  
       
  2453     }
       
  2454 #endif
       
  2455 // -----------------------------------------------------------------------------
  2406 // -----------------------------------------------------------------------------
  2456 // CDownloadMgrUiDownloadsList::OfferKeyEventL
  2407 // CDownloadMgrUiDownloadsList::OfferKeyEventL
  2457 // -----------------------------------------------------------------------------
  2408 // -----------------------------------------------------------------------------
  2458 //
  2409 //
  2459 TKeyResponse CDownloadMgrUiDownloadsList::OfferKeyEventL
  2410 TKeyResponse CDownloadMgrUiDownloadsList::OfferKeyEventL
  2489 
  2440 
  2490 // -----------------------------------------------------------------------------
  2441 // -----------------------------------------------------------------------------
  2491 // FindDlUiData
  2442 // FindDlUiData
  2492 // -----------------------------------------------------------------------------
  2443 // -----------------------------------------------------------------------------
  2493 //
  2444 //
  2494 inline TDownloadUiData* FindDlUiData( CDownloadsListArray& aListModel, 
  2445 inline TDownloadUiData* FindDlUiData( CDownloadsListArray& aListModel,
  2495                                        RHttpDownload& aDownload,
  2446                                        RHttpDownload& aDownload,
  2496                                        TInt& aIndex )
  2447                                        TInt& aIndex )
  2497     {
  2448     {
  2498     TInt err = aListModel.Find( aDownload, aIndex );
  2449     TInt err = aListModel.Find( aDownload, aIndex );
  2499     if ( err == KErrNotFound )
  2450     if ( err == KErrNotFound )
  2504     else
  2455     else
  2505         {
  2456         {
  2506         return &( aListModel.DlUiData( aIndex ) );
  2457         return &( aListModel.DlUiData( aIndex ) );
  2507         }
  2458         }
  2508     };
  2459     };
  2509     
  2460 
  2510 // -----------------------------------------------------------------------------
  2461 // -----------------------------------------------------------------------------
  2511 // CDownloadMgrDownloadsList::AttachAIWInterestL
  2462 // CDownloadMgrDownloadsList::AttachAIWInterestL
  2512 // -----------------------------------------------------------------------------
  2463 // -----------------------------------------------------------------------------
  2513 //
  2464 //
  2514 void CDownloadMgrUiDownloadsList::AttachAIWInterestL()
  2465 void CDownloadMgrUiDownloadsList::AttachAIWInterestL()
  2561     TAiwVariant fileNameVariant( fileNamePtr );
  2512     TAiwVariant fileNameVariant( fileNamePtr );
  2562     TAiwGenericParam genericParamFileName( EGenericParamFile, fileNameVariant );
  2513     TAiwGenericParam genericParamFileName( EGenericParamFile, fileNameVariant );
  2563 	aParams.AppendL( genericParamFileName );
  2514 	aParams.AppendL( genericParamFileName );
  2564 
  2515 
  2565 	HBufC* contentType = HBufC::NewLC(KMaxContentTypeLength);
  2516 	HBufC* contentType = HBufC::NewLC(KMaxContentTypeLength);
  2566 	TPtr contentTypePtr = contentType->Des(); 
  2517 	TPtr contentTypePtr = contentType->Des();
  2567     User::LeaveIfError
  2518     User::LeaveIfError
  2568                 ( aDownload.GetStringAttribute( EDlAttrContentType, contentTypePtr ) );
  2519                 ( aDownload.GetStringAttribute( EDlAttrContentType, contentTypePtr ) );
  2569     fileNameVariant.Set(contentTypePtr);
  2520     fileNameVariant.Set(contentTypePtr);
  2570     TAiwGenericParam genericParamMimeType( EGenericParamMIMEType, fileNameVariant );
  2521     TAiwGenericParam genericParamMimeType( EGenericParamMIMEType, fileNameVariant );
  2571     aParams.AppendL( genericParamMimeType );
  2522     aParams.AppendL( genericParamMimeType );
  2572     CleanupStack::PopAndDestroy( contentType );
  2523     CleanupStack::PopAndDestroy( contentType );
  2573     CleanupStack::PopAndDestroy( fileName );
  2524     CleanupStack::PopAndDestroy( fileName );
  2574    
  2525 
  2575     }
  2526     }
  2576     
  2527 
  2577 // -----------------------------------------------------------------------------
  2528 // -----------------------------------------------------------------------------
  2578 // CDownloadMgrUiDownloadsList::InitializeAIWPlugInMenusL
  2529 // CDownloadMgrUiDownloadsList::InitializeAIWPlugInMenusL
  2579 // -----------------------------------------------------------------------------
  2530 // -----------------------------------------------------------------------------
  2580 //
  2531 //
  2581 void CDownloadMgrUiDownloadsList::InitializeAIWPlugInMenusL( TInt aResourceId,
  2532 void CDownloadMgrUiDownloadsList::InitializeAIWPlugInMenusL( TInt aResourceId,
  2625     RArray<TUint32> idArray;
  2576     RArray<TUint32> idArray;
  2626     CleanupClosePushL( idArray );
  2577     CleanupClosePushL( idArray );
  2627 
  2578 
  2628     CDesCArrayFlat* nameArray = new (ELeave) CDesCArrayFlat(16);
  2579     CDesCArrayFlat* nameArray = new (ELeave) CDesCArrayFlat(16);
  2629     CleanupStack::PushL( nameArray );
  2580     CleanupStack::PushL( nameArray );
  2630     
  2581 
  2631     // Get IAP names and ids from the database
  2582     // Get IAP names and ids from the database
  2632     CCommsDatabase* TheDb = CCommsDatabase::NewL( EDatabaseTypeIAP );
  2583     CCommsDatabase* TheDb = CCommsDatabase::NewL( EDatabaseTypeIAP );
  2633     CleanupStack::PushL( TheDb );
  2584     CleanupStack::PushL( TheDb );
  2634 
  2585 
  2635     TheDb->ShowHiddenRecords();
  2586     TheDb->ShowHiddenRecords();
  2641     TInt res = view->GotoFirstRecord();
  2592     TInt res = view->GotoFirstRecord();
  2642     while( res == KErrNone )
  2593     while( res == KErrNone )
  2643     {
  2594     {
  2644         view->ReadTextL( TPtrC(COMMDB_NAME), name );
  2595         view->ReadTextL( TPtrC(COMMDB_NAME), name );
  2645         view->ReadUintL( TPtrC(COMMDB_ID), id );
  2596         view->ReadUintL( TPtrC(COMMDB_ID), id );
  2646         
  2597 
  2647         idArray.Insert( id, 0 );
  2598         idArray.Insert( id, 0 );
  2648         nameArray->InsertL( 0, name );
  2599         nameArray->InsertL( 0, name );
  2649 
  2600 
  2650         res = view->GotoNextRecord();
  2601         res = view->GotoNextRecord();
  2651         RDebug::Print(_L("IAP name, id: %S, %d"), &name, id);
  2602         RDebug::Print(_L("IAP name, id: %S, %d"), &name, id);
  2652     }
  2603     }
  2653     
  2604 
  2654     CleanupStack::PopAndDestroy( view ); // view
  2605     CleanupStack::PopAndDestroy( view ); // view
  2655     CleanupStack::PopAndDestroy( TheDb ); // TheDb
  2606     CleanupStack::PopAndDestroy( TheDb ); // TheDb
  2656     
  2607 
  2657     // Create listbox and PUSH it.
  2608     // Create listbox and PUSH it.
  2658     CEikTextListBox* list = new(ELeave) CAknSinglePopupMenuStyleListBox;
  2609     CEikTextListBox* list = new(ELeave) CAknSinglePopupMenuStyleListBox;
  2659     CleanupStack::PushL( list );
  2610     CleanupStack::PushL( list );
  2660     
  2611 
  2661     // Create popup list and PUSH it.
  2612     // Create popup list and PUSH it.
  2662     CAknPopupList* popupList = CAknPopupList::NewL(
  2613     CAknPopupList* popupList = CAknPopupList::NewL(
  2663         list, R_AVKON_SOFTKEYS_OK_EMPTY__OK,
  2614         list, R_AVKON_SOFTKEYS_OK_EMPTY__OK,
  2664         AknPopupLayouts::EMenuWindow);
  2615         AknPopupLayouts::EMenuWindow);
  2665     CleanupStack::PushL( popupList );
  2616     CleanupStack::PushL( popupList );
  2666     
  2617 
  2667     // initialize listbox.
  2618     // initialize listbox.
  2668     list->ConstructL( popupList, CEikListBox::ELeftDownInViewRect );
  2619     list->ConstructL( popupList, CEikListBox::ELeftDownInViewRect );
  2669     list->CreateScrollBarFrameL( ETrue );
  2620     list->CreateScrollBarFrameL( ETrue );
  2670     list->ScrollBarFrame()->SetScrollBarVisibilityL(
  2621     list->ScrollBarFrame()->SetScrollBarVisibilityL(
  2671         CEikScrollBarFrame::EOff,
  2622         CEikScrollBarFrame::EOff,
  2672         CEikScrollBarFrame::EAuto );
  2623         CEikScrollBarFrame::EAuto );
  2673     
  2624 
  2674     // Set listitems.
  2625     // Set listitems.
  2675     CTextListBoxModel* model = list->Model();
  2626     CTextListBoxModel* model = list->Model();
  2676     model->SetItemTextArray( nameArray );
  2627     model->SetItemTextArray( nameArray );
  2677     model->SetOwnershipType( ELbmDoesNotOwnItemArray );
  2628     model->SetOwnershipType( ELbmDoesNotOwnItemArray );
  2678     
  2629 
  2679     // Set title
  2630     // Set title
  2680     popupList->SetTitleL( _L("Select IAP:") );
  2631     popupList->SetTitleL( _L("Select IAP:") );
  2681     
  2632 
  2682     // Show popup list.
  2633     // Show popup list.
  2683     TInt popupOk = popupList->ExecuteLD();
  2634     TInt popupOk = popupList->ExecuteLD();
  2684     CleanupStack::Pop( popupList ); // popupList
  2635     CleanupStack::Pop( popupList ); // popupList
  2685     if ( popupOk )
  2636     if ( popupOk )
  2686         {
  2637         {
  2687         TInt index = list->CurrentItemIndex();
  2638         TInt index = list->CurrentItemIndex();
  2688         aId = idArray[index];
  2639         aId = idArray[index];
  2689         }
  2640         }
  2690     
  2641 
  2691     CleanupStack::PopAndDestroy( 3, &idArray );  // list, nameArray, idArray
  2642     CleanupStack::PopAndDestroy( 3, &idArray );  // list, nameArray, idArray
  2692     
  2643 
  2693     return popupOk;
  2644     return popupOk;
  2694     }
  2645     }
  2695 #endif // #ifdef __WINS__
  2646 #endif // #ifdef __WINS__
  2696 
  2647 
  2697 /* End of file. */
  2648 /* End of file. */