Namespaces
Variants
Actions

Downloading from the web using Download Manager Symbian API

Jump to: navigation, search
Article Metadata

Code Example
Tested with
Devices(s): Nokia 5800 XpressMusic, Nokia N97, Nokia N97 Mini

Compatibility
Platform(s): S60 3rd Edition FP2, S60 5th Edition

Article
Keywords: RHttpDownloadMgr
Created: User:Kbwiki (03 Jun 2010)
Last edited: hamishwillee (01 Aug 2012)
==Overview==

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.


Contents

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:
{
iMgrDownloadsList->DisplayDownloadsListL();
break;
}
case EHttpDlInprogress:
{
// iEikonEnv->InfoWinL(_L("Progress"),_L(" "));
break;
}
case EHttpDlCompleted:
{
iEikonEnv->InfoWinL(_L("Completed"),_L(" "));
break;
}
case EHttpDlFailed:
{
iEikonEnv->InfoWinL(_L("Failed"),_L(" "));
break;
}
case EHttpDlPaused:
{
//DownloadPausedL( aDownload, aEvent );
break;
}
default :
{
//iEikonEnv->InfoWinL(_L("Default"),_L(" "));
break;
}
}
}

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"));
iDMgr.SetStringAttribute(EDlAttrDestFilename,filename);

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:

iDMgr.DeleteAll();
iDMgr.Close();

Sample Application

File:ProgressiveDownload.zip

This page was last modified on 1 August 2012, at 07:40.
315 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved