×

Discussion Board

Results 1 to 15 of 15
  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    21

    Question Never receive Http::EResponseComplete

    hi all,

    I am trying to download a rss feed xml from links below:
    with code

    iSession.OpenL();
    iURL = HBufC8::NewL(aURLToLoad.Length());
    iURL->Des().Copy(aURLToLoad);
    User::LeaveIfError(iUriParser.Parse(*iURL));
    iTransaction = iSession.OpenTransactionL(iUriParser, *this, iSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable()));
    RHTTPHeaders headers = iTransaction.Request().GetHeaderCollection();

    _LIT8(KUserAgent, "Mozilla/4.0");
    _LIT8(KAccept, "text/*");
    AddHeaderL(headers, HTTP::EUserAgent, KUserAgent);
    AddHeaderL(headers, HTTP::EAccept, KAccept);
    iTransaction.SubmitL();
    For both link I managed to get the first 2 responses.
    EGotResponseHeaders
    EGotResponseBodyData
    EResponseComplete

    But For CNN link, I never get the "EResponseComplete". but from the debug console in carbride i see this statment:

    127.620 HTTPPLUGIN:MHFRunL: EGotResponseHeaders (4)
    127.620 HTTPPLUGIN:MHFRunL: EGotResponseBodyData (5)
    127.620 WSOCK: ServProvider: [15B68B5C] 4096 bytes requested, 4217 bytes unread
    127.620 WSOCK: ServProvider: [15B68B5C] received 4096 bytes, 121 bytes left
    127.620 WSOCK: ServProvider: [15B68B5C] 121 bytes requested, 121 bytes unread
    127.620 WSOCK: Protocol: [15B6B68C] 0 socket(s) have unread data
    127.620 WSOCK: ServProvider: [15B68B5C] 0 bytes in socket, 0 bytes unread
    127.625 WSOCK: ServProvider: [15B68B5C] received 121 bytes, 0 bytes left
    127.625 WSOCK: ServProvider: [15B68B5C] 0 bytes in socket, 0 bytes unread
    127.635 WSOCK: ServProvider: [15B68B5C] end of data, I guess
    127.635 HTTPPLUGIN:MHFRunL: EGotResponseBodyData (5)
    Anyone come across this? ( I dont think it exceeded size since the otehr one is much bigger)

    Thanks

  2. #2
    Regular Contributor
    Join Date
    Feb 2008
    Location
    Pune, India
    Posts
    340

    Re: Never receive Http::EResponseComplete

    Well, I don't have the answer for your question here but I would suggest you to use RHttpDownload to download the XML on to the handset. I don't understand why you are connecting to it. Here is the code to download the XML.

    Code:
     _LIT8( KCodUrl, "http://newsrss.bbc.co.uk/rss/newsonline_world_edition/americas/rss.xml");
     
     _LIT( KTempPath , "c:\\data\\rss.xml" );
    void  YourClass::DownloadXML()
        {
        
       // AccessPt retrievel from CommsDB
       
           TUint32 iapId(0);
                
           CCommsDatabase* cdb = CCommsDatabase::NewL(EDatabaseTypeIAP);
    	   CleanupStack::PushL(cdb);
    
    			CCommsDbConnectionPrefTableView* commDBView = cdb->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionOutgoing);
    			if(commDBView->GotoFirstRecord() == KErrNone)
    			{
    				CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
    				commDBView->ReadConnectionPreferenceL(pref);
    				iapId = pref.iBearer.iIapId;
    			}
    
    		CleanupStack::PopAndDestroy(commDBView);
    		CleanupStack::PopAndDestroy(cdb);
    		
    	 //Setting Attribute for download manger ( Access Point)
    	 
    	    User::LeaveIfError( iDMgr.SetIntAttribute( EDlMgrIap, (TInt32)iapId ) ); 
    	
    	    TBuf8<254> URL(KCodUrl);
    	    
    	 //Creation of download obj   
    				 
    	    RHttpDownload& download = iDMgr.CreateDownloadL(URL,retVal);
    	    
    	 // Setting attributes for download object
    	 
    	    TFileName filename(KTempPath );
    	    
    	    // Setting destination path for the downloaded file to be stored
    	    
            download.SetStringAttribute( EDlAttrDestFilename, filename );
    
            
    
            TBool silattr(ETrue);
            
         //download progress will be silent   
    
    	   download.SetBoolAttribute(EDlAttrSilent,silattr);  
    			
         // start downloading
         
         if(retVal)                
    				 {
    					TInt state = download.Start();
    				 }
    				 else
    				 {
    				  _LIT(Ktext,"Download creation failed");
    				  CAknInformationNote* informationNote;
                      informationNote = new ( ELeave ) CAknInformationNote;
                       informationNote->ExecuteLD(Ktext);
        			 }
    
    	
        }
    Regards,
    Sainagakishore Srikantham (Kishore)

    Don't Hope, KNOW!!! ---------- Visit me at http://ssnkishore.blogspot.com ----------

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    21

    Re: Never receive Http::EResponseComplete

    Thanks, ssn.kishore.

    I will try that out.

    The reason of downloading it was to want to display it as rss feed. But I search thought web, and read the document about the class below:
    CSenXmlReader* Readerp;

    It uses file as parameter, therefore, I thought it is necessary to download it to local before I can break it down...

  4. #4
    Regular Contributor
    Join Date
    Feb 2008
    Location
    Pune, India
    Posts
    340

    Re: Never receive Http::EResponseComplete

    Okay I understand the purpose but the code that you were using actually downloaded the file on the handset? Anyway, let me know in case you have a problem with the code I gave you.
    Regards,
    Sainagakishore Srikantham (Kishore)

    Don't Hope, KNOW!!! ---------- Visit me at http://ssnkishore.blogspot.com ----------

  5. #5
    Registered User
    Join Date
    Jun 2008
    Posts
    21

    Question Re: Never receive Http::EResponseComplete

    from the code you provided,
    one of the variable is not declared :
    iDMgr
    would it be a RHttpDownloadMgr?

  6. #6
    Regular Contributor
    Join Date
    Feb 2008
    Location
    Pune, India
    Posts
    340

    Re: Never receive Http::EResponseComplete

    Yes you are right. Instead, to save time use this...

    DownloadXML.h
    Code:
    #ifndef DOWNLOADXML_H_
    #define DOWNLOADXML_H_
    
    #include <downloadmgrclient.h> 
    #include <SWInstApi.h>
    #include <SWInstDefs.h>
    
    class CDownloadMgrUiDownloadsList;
    class CDownloadMgrUiLibRegistry;
    class CDownloadMgrUiUserInteractions;
    
    
    const TUid KMyApplnUid = {0x0E3D6204};
    
    
    class CDownloadXML : public MHttpDownloadMgrObserver 
    {
    	
    	public:
    		
    		/*!
    		@function NewL
    		
    		@discussion Create a CSilentInstEngine object
    		@result a pointer to the created instance of CSilentInstEngine
    		 */
    		static CDownloadXML* NewL();
    		/*!
    		@function NewLC
    		
    		@discussion Create a CSilentInstEngine object
    		@result a pointer to the created instance of CSilentInstEngine
    		 */
    		static CDownloadXML* NewLC();
    		
    		/*!
    		@function ~CSilentInstEngine
    		
    		@discussion Destroy the object and release all memory objects
    		 */
    		~CDownloadXML();
    	
    		// Fn to download XML from URL
    		void DownloadXMLDoc();
    	
    		//  To observe download events from MHttpDownloadMgrObserver
    		void HandleDMgrEventL (RHttpDownload &aDownload, THttpDownloadEvent aEvent);
    	
    	
    	private:
    		/*!
    		@function ConstructL
    		
    		@discussion  Perform the second phase construction of a CSilentInstEngine object
    			 */
    			void ConstructL();
    		
    			/*!
    		@function CSilentInstEngine
    		
    		@discussion Perform the first phase of two phase construction 
    			 */
    		CDownloadXML();
    	
    	private: //Data
    	
    		// Return value of download creation
    //		TInt retVal ;
    		TBool retVal;
    	
    		//Download manager to download the XML
    		RHttpDownloadMgr iDMgr;
    		//Registry to register ui component
    		CDownloadMgrUiLibRegistry * iUiReg;
    		// UI interaction component
    		CDownloadMgrUiUserInteractions* idMgrUserInteractions;
    		//Download list component
    		CDownloadMgrUiDownloadsList * iMgrDownloadsList;
    };
    	
    
    #endif /*DOWNLOADXML_H_*/
    DownloadXML.cpp
    Code:
    /*
    ============================================================================
     Name        : DownloadXML.cpp
     Part of     : Mobile RSS Reader
     Author      : Sainagakishore Srikantham
     Version     : 0.01
     Copyright   : All rights reserved
     Description : Download XML from a website
    ============================================================================
     */
    
    
    #include "DownloadXML.h"
    //#include "AOSync.h"
    
    #include <cdownloadmgruidownloadslist.h>
    #include <cdownloadmgruilibregistry.h> 
    #include <cdownloadmgruiuserinteractions.h> 
    #include <COMMDB.H>
    #include <aknnotewrappers.h> 
    
    // Change these descriptor values(Give the correct URL path and sisx name)
    
    _LIT8( KCodUrl, "http://newsrss.bbc.co.uk/rss/newsonline_world_edition/americas/rss.xml");
    
    _LIT( KTempPath , "c:\\data\\rss.xml" );
    
    
    CDownloadXML* CDownloadXML::NewL()
    {
    	CDownloadXML* self = CDownloadXML::NewLC();
    	CleanupStack::Pop(self);
    	return self;
    }
    
    CDownloadXML* CDownloadXML::NewLC()
    {
    	CDownloadXML* self = new (ELeave) CDownloadXML;
    	CleanupStack::PushL(self);
    	self->ConstructL();
    	return self;
    }
    
    CDownloadXML::CDownloadXML()
    {
    
    }
    
    void CDownloadXML::ConstructL()
    {
    
    	// Connect to download manager
    
    	iDMgr.ConnectL( KMyApplnUid, *this, ETrue );
    
    	iUiReg = CDownloadMgrUiLibRegistry::NewL( iDMgr );
    
    	idMgrUserInteractions = &iUiReg->RegisterUserInteractionsL();
    
    	iMgrDownloadsList = &iUiReg->RegisterDownloadsListL();
    
    	iDMgr.DeleteAll();
    }
    
    CDownloadXML::~CDownloadXML()
    { 
    	delete iUiReg;
    	iDMgr.Close();
    }
    
    // Function to download XML from URL    
    void  CDownloadXML::DownloadXMLDoc()
    {
    	// AccessPt retrievel from CommsDB
    
    	TUint32 iapId(0);
    
    	CCommsDatabase* cdb = CCommsDatabase::NewL(EDatabaseTypeIAP);
    	CleanupStack::PushL(cdb);
    
    	CCommsDbConnectionPrefTableView* commDBView = cdb->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionOutgoing);
    	if(commDBView->GotoFirstRecord() == KErrNone)
    	{
    		CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
    		commDBView->ReadConnectionPreferenceL(pref);
    		iapId = pref.iBearer.iIapId;
    	}
    
    	CleanupStack::PopAndDestroy(commDBView);
    	CleanupStack::PopAndDestroy(cdb);
    
    	//Setting Attribute for download manger ( Access Point)
    	User::LeaveIfError( iDMgr.SetIntAttribute( EDlMgrIap, (TInt32)iapId ) ); 
    
    	TBuf8<254> URL(KCodUrl);
    	//Creation of download obj   
    	RHttpDownload& download = iDMgr.CreateDownloadL(URL, retVal);
    
    	// Setting attributes for download object
    	TFileName filename(KTempPath );
    
    	// Setting destination path for the downloaded file to be stored
    	download.SetStringAttribute( EDlAttrDestFilename, filename );
    
    	TBool silattr(ETrue);
    
    	//download progress will be silent   
    	download.SetBoolAttribute(EDlAttrSilent,silattr);  
    
    	// start downloading
    	TInt state = download.Start();
    	
    /*	if(retVal)                
    	{
    		
    	}
    	else
    	{
    		_LIT(Ktext,"Download creation failed");
    		CAknInformationNote* informationNote;
    		informationNote = new ( ELeave ) CAknInformationNote;
    		informationNote->ExecuteLD(Ktext);
    	}*/
    }
    
    //  To observe download events from MHttpDownloadMgrObserver
    void CDownloadXML::HandleDMgrEventL (RHttpDownload &aDownload, THttpDownloadEvent aEvent)
    {
    	switch ( aEvent.iDownloadState )
    	{
    		case EHttpDlCreated:
    		{
    			break;
    		}
    		case EHttpDlInprogress:
    		{
    			break;
    		}
    		case EHttpDlCompleted:
    		{
    			_LIT(Ktext,"Done");
    			CAknInformationNote* informationNote;
    			informationNote = new ( ELeave ) CAknInformationNote;
    			informationNote->ExecuteLD(Ktext);
    			iDMgr.DeleteAll();
    			// On completion of download , call silent installation function
    			break;
    		}
    		case EHttpDlFailed:
    		{
    			_LIT(Kerr,"Downloading failed");
    			TInt32 iVal = 0L;	
    			TBuf<40> derror;
    
    			aDownload.GetIntAttribute(EDlAttrGlobalErrorId, iVal);
    			derror.Append(Kerr);
    			derror.AppendNum(iVal);
    
    			CAknInformationNote* informationNote;
    			informationNote = new ( ELeave ) CAknInformationNote;
    			informationNote->ExecuteLD(derror);
    
    			aDownload.Delete();
    			break;
    		}
    		case EHttpDlPaused:
    		{
    			break;
    		}
    
    		default :
    		{
    			break;
    		}
    	}
    }
    Regards,
    Sainagakishore Srikantham (Kishore)

    Don't Hope, KNOW!!! ---------- Visit me at http://ssnkishore.blogspot.com ----------

  7. #7
    Registered User
    Join Date
    Jun 2008
    Posts
    21

    Re: Never receive Http::EResponseComplete

    Do you know what cause the fail -19 .

    I did init those function like you did on Constructor, and then call DownloadXMl(). At the end

  8. #8
    Registered User
    Join Date
    Jun 2008
    Posts
    21

    Post Re: Never receive Http::EResponseComplete

    Actually, it was the same URL giving the error again... Not sure if extra control needed to be handle for this case.


    But Thanks, the other links are working as espected.
    Last edited by stephen.cheung; 2008-11-13 at 08:25.

  9. #9
    Registered User
    Join Date
    Jun 2008
    Posts
    21

    Exclamation Re: Never receive Http::EResponseComplete

    On the emulator it can run. But if install into the device.. It said I dont have "Required application access not granted"


    IS your class needed Capability: "Allfiles"

  10. #10
    Regular Contributor
    Join Date
    Feb 2008
    Location
    Pune, India
    Posts
    340

    Re: Never receive Http::EResponseComplete

    No it doesn't. It should work.
    Regards,
    Sainagakishore Srikantham (Kishore)

    Don't Hope, KNOW!!! ---------- Visit me at http://ssnkishore.blogspot.com ----------

  11. #11
    Registered User
    Join Date
    Jun 2008
    Posts
    21

    Red face Re: Never receive Http::EResponseComplete

    Thanks for your help.

    Finally, it can be installed into device. It turns out I have miss out the capability.

    Would this Download mechanism allow to save into private folder? Although it said Done in download, it doesnt look like it saved file in private folder.

    For saving into resource\apps\ it return download fail -46

    But storing in Data\folder\ I can read and write.

  12. #12
    Regular Contributor
    Join Date
    Feb 2008
    Location
    Pune, India
    Posts
    340

    Re: Never receive Http::EResponseComplete

    Well, you can always read and write into your application's private folder but not any other folder. I suggest you download it to a temporary folder or directly to C:\Data and delete it as soon as you're done with the file. C:\Data is not directly visible to the user and it shouldn't matter much.
    Regards,
    Sainagakishore Srikantham (Kishore)

    Don't Hope, KNOW!!! ---------- Visit me at http://ssnkishore.blogspot.com ----------

  13. #13
    Registered User
    Join Date
    Jun 2008
    Posts
    21

    Cool Re: Never receive Http::EResponseComplete

    Thanks for your suggestion

  14. #14
    Regular Contributor
    Join Date
    Feb 2008
    Location
    Pune, India
    Posts
    340

    Re: Never receive Http::EResponseComplete

    The pleasure is mine!
    Regards,
    Sainagakishore Srikantham (Kishore)

    Don't Hope, KNOW!!! ---------- Visit me at http://ssnkishore.blogspot.com ----------

  15. #15
    Registered User
    Join Date
    Jun 2008
    Posts
    21

    Re: Never receive Http::EResponseComplete

    For anyone interest, While using N95, I couldnt have the RHttpDownload download data to private folder. Therefore, I follow the indirect way
    like others do
    http://discussion.forum.nokia.com/fo...d.php?t=117724

    1)CFileMan::Copy
    2)CFileMan::Move
    3)RFile::rename
    etc...

Similar Threads

  1. Not Every phone receive SMS from WMA
    By youngboyguy in forum Mobile Java General
    Replies: 4
    Last Post: 2011-01-24, 04:56
  2. Replies: 10
    Last Post: 2009-05-04, 06:27
  3. What is the real problem to receive data calls with Nokia TDMA cel modems?
    By jackal_jr in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2002-12-09, 09:02
  4. What is the real problem to receive data calls with Nokia TDMA cell modem?
    By jackal_jr in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2002-12-04, 16:05
  5. Replies: 0
    Last Post: 2002-12-04, 15:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×