Greetings:
We are trying to develop a program that can do downloads of files from a http location using the download manager API.
Our platform is as follows:
Symbian OS 8.1a
S60 2nd Edition FP3 SDK
Nokia N70 Handset
We wrote the following code using the documentation from the "S60 Platform Download Manager API Developers Guide" documentation from this forum.
The files implementing the download calls are as follows:
CDownloadTestManager.h and CDownloadTestManager.cpp
Code:#ifndef CDOWNLOADTESTMANAGER_H #define CDOWNLOADTESTMANAGER_H // INCLUDES #include <e32std.h> #include <e32base.h> #include <downloadmgrclient.h> // CLASS DECLARATION /** * CCDownloadTestManager * */ class CCDownloadTestManager : public MHttpDownloadMgrObserver { public: // Constructors and destructor /** * Destructor. */ virtual ~CCDownloadTestManager(); /** * Two-phased constructor. */ static CCDownloadTestManager* NewL(); /** * Two-phased constructor. */ static CCDownloadTestManager* NewLC(); void Download(); private: /** * Constructor for performing 1st stage construction */ CCDownloadTestManager(); /** * EPOC default constructor for performing 2nd stage construction */ void ConstructL(); void HandleDMgrEventL (RHttpDownload &aDownload, THttpDownloadEvent aEvent); void Log(TDesC8& msg); RHttpDownloadMgr iDMgr; }; #endif // CDOWNLOADTESTMANAGER_H
and the main file uses an object of above as follows:Code:#include "CDownloadTestManager.h" #include "commdb.h" #include "rtimemethods.h" const TUid KMyAppUid = {0xE38EBD11}; CCDownloadTestManager::CCDownloadTestManager() { // No implementation required } CCDownloadTestManager::~CCDownloadTestManager() { iDMgr.Close(); } CCDownloadTestManager* CCDownloadTestManager::NewLC() { CCDownloadTestManager* self = new (ELeave) CCDownloadTestManager(); CleanupStack::PushL(self); self->ConstructL(); return self; } CCDownloadTestManager* CCDownloadTestManager::NewL() { CCDownloadTestManager* self = CCDownloadTestManager::NewLC(); CleanupStack::Pop(); // self; return self; } void CCDownloadTestManager::ConstructL() { // Connect to the Download Manager iDMgr.ConnectL( KMyAppUid,*this, ETrue ); // Create the UI Library Registry iDMgr.DeleteAll(); } void CCDownloadTestManager::Download() { // // Selecting the default Access Point (IAP) on handset // TUint32 IapId = 0; CCommsDatabase * cdb = CCommsDatabase::NewL(EDatabaseTypeIAP); CleanupStack::PushL(cdb); CCommsDbConnectionPrefTableView * commDBView = cdb->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionUnknown); if (commDBView->GotoFirstRecord() == KErrNone) { CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref; commDBView->ReadConnectionPreferenceL(pref); IapId = pref.iBearer.iIapId; } CleanupStack::PopAndDestroy(commDBView); CleanupStack::PopAndDestroy(cdb); User::LeaveIfError( iDMgr.SetIntAttribute( EDlMgrIap, IapId ) ); // // Set the URL for the download // _LIT8( KCodUrl, "http://202.164.36.66:80/mdms/downloads/sampletext.txt"); TBool retVal; TBuf8<256> URL(KCodUrl); RHttpDownload& download = iDMgr.CreateDownloadL(URL,retVal); // // Launch on startup // User::LeaveIfError(download.SetIntAttribute(EDlAttrAction, ELaunch)); if(retVal) { download.Start(); Log((TDesC8&)_L8("download started\n")); } else { Log((TDesC8&)_L8("download failed\n")); } } void CCDownloadTestManager::HandleDMgrEventL (RHttpDownload &aDownload, THttpDownloadEvent aEvent) { Log((TDesC8&)_L8("called\n")); } void CCDownloadTestManager::Log(TDesC8& msg) { RFs fs; fs.Connect(); RFile file; TInt result = file.Open(fs,_L("CRMADownloads.txt"), EFileWrite); if (result == KErrNotFound) { file.Create(fs,_L("CRMADownloads.txt"), EFileWrite); } TInt pos = 0; file.Seek(ESeekEnd,pos); TBuf8<256> wStr; wStr.Copy(RTimeMethods::GetCurrentTimeStamp()); wStr.Append(_L8(" - ")); wStr.Append(msg); wStr.Append(_L8("\n")); file.Write(wStr); file.Close(); fs.Close(); }
Our problem is that this program test does not perform as expected. The download gets started but there are no events returned to our test program through the "MHttpDownloadMgrObserver" interface.Code:CCDownloadTestManager * mgr = CCDownloadTestManager::NewL(); CleanupStack::PushL(mgr); mgr->Download(); User::After(30000000); CleanupStack::PopAndDestroy(mgr);
Is there an apparent problem with the code above. Kindly advise as to why our download does not get initiated programmatically whereas on the Nokia N70 its initiated just fine using the "Web=>Download" interface of the handset.
Note:
GPRS is enabled on the handset.
We did set the default IAP profile.
Your kind time and consideration stands to be appreciated.
Thanks.
Prabhjot.

Reply With Quote

