Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Downloading from the web using Download Manager Symbian API

From Wiki
Jump to: navigation, search
Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 XpressMusic, Nokia N97, Nokia N97 Mini
Platform(s): S60 3rd Edition FP2, S60 5th Edition
S60 5th Edition
S60 3rd Edition FP2
Keywords: RHttpDownloadMgr
Created: User:Kbwiki (03 Jun 2010)
Last edited: hamishwillee (01 Aug 2012)

Download Manager API can be used for handling download events, such as start, pause, and reset. It can also be used to move or delete downloaded content. For more details, see Download Manager API: Using the Download Manager API.


Header files

#include <DownloadMgrClient.h> //for S60 3rd FP2, S60 5th Edition

Library Files

LIBRARY DownloadMgr.lib

Code Snippet

Create a download manager session:

RHttpDownloadMgr iDMgr;
iDMgr.ConnectL( TUid::Uid( KThisAppUid ), *this, ETrue );

Create the UI Library Registry:

CDownloadMgrUiLibRegistry * iUiReg;
iUiReg = CDownloadMgrUiLibRegistry::NewL( iDMgr );

Install the User Interactions (dialogs) and get a pointer to them:

CDownloadMgrUiUserInteractions* idMgrUserInteractions;
idMgrUserInteractions = &iUiReg->RegisterUserInteractionsL();

Register a Downloads List:

CDownloadMgrUiDownloadsList * iMgrDownloadsList;
iMgrDownloadsList = &iUiReg->RegisterDownloadsListL();

The function HandleDMgrEventL() is called whenever a download begins, completes, pauses, or fails.

void CProgressiveDownloadAppUi::HandleDMgrEventL( RHttpDownload&  aDownload,
THttpDownloadEvent aEvent )
switch ( aEvent.iDownloadState )
case EHttpDlCreated:
case EHttpDlInprogress:
// iEikonEnv->InfoWinL(_L("Progress"),_L(" "));
case EHttpDlCompleted:
iEikonEnv->InfoWinL(_L("Completed"),_L(" "));
case EHttpDlFailed:
iEikonEnv->InfoWinL(_L("Failed"),_L(" "));
case EHttpDlPaused:
//DownloadPausedL( aDownload, aEvent );
default :
//iEikonEnv->InfoWinL(_L("Default"),_L(" "));

Starting the Download

The URL from where the file has to be downloaded. The filename could be any location, even memory card (e:).

TBuf8<128> url = _L8("http://abc/movie.3gp");
TFileName filename(_L("c:\\data\\movie.3gp"));

Create a new download subsession with the URL taken as the first parameter. isNewDl is true if Download is created. If the URL is already downloaded, it is set as false.

TBool isNewDl ;
RHttpDownload& dl = iDMgr.CreateDownloadL( url, isNewDl );

If isNewDl is true:

User::LeaveIfError( dl.Start() );

Closing the Download Manager session:


Sample Application

This page was last modified on 1 August 2012, at 04:40.
114 page views in the last 30 days.