×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Aug 2007
    Posts
    105

    GetNextDataPart called only once :(

    Hi all,

    I'm trying to implement an upload process indicator for an image upload via UMTS. Unfortunately this does not work, as the GetNextDataPart() of my data supplier is called only once, even though I return EFalse.

    Code:
    TBool CClientEngine::GetNextDataPart(TPtrC8& aDataPart)
    {
    TBool lastBuffer=ETrue;
    if(iPostData)
    	{
    	TInt totalSize=iPostData->Length();
    	TInt sentSize=iCurrentChunk*iChunkSize;
    	TInt chunkSize=totalSize-sentSize;
    	if (chunkSize>iChunkSize)
    		{
    		chunkSize=iChunkSize;
    		lastBuffer=EFalse;
    		}
    	else
    		lastBuffer=ETrue;
    	if (iChunkData)
    		delete iChunkData;
    	iChunkData=HBufC8::NewL(chunkSize);
    	ChunkData->Des().Copy(iPostData->Des().Ptr()+sentSize,chunkSize);
    
    	aDataPart.Set(iChunkData->Des());
    	iCurrentChunk++;
    	}
    return lastBuffer;
    }
    iPostData is not deleted during the transaction - I tried the same with a dummy function:

    Code:
    TBool CClientEngine::GetNextDataPart(TPtrC8& aDataPart)
    {
    	TInt chunkSize=10;
    	if (iChunkData)
    		delete iChunkData;
    	iChunkData=HBufC8::NewL(chunkSize);
    	aDataPart.Set(iChunkData->Des());
    	iCurrentChunk++;
    	return EFalse;
    }
    even here, the funcion is called only once and iCurrentChunk equals 1 all the time. The only way to finish my upload is to do it in one chunk only - if i set the chunk to iPostData so that aDataPart.Length equals OverallDataSize the transaction completes, EVEN THOUGH I still return EFalse. Anyone eyperienced the same or got any hints?

    Thanks to all of you,

    Chris

  2. #2
    Super Contributor
    Join Date
    Jul 2007
    Location
    ShenZhen, China
    Posts
    4,346

    Re: GetNextDataPart called only once :(

    for my test, it seems has some bugs.
    so I use OverallDataSize give full size. then GetNextDataPart will called times.
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  3. #3
    Regular Contributor
    Join Date
    Aug 2007
    Posts
    105

    Re: GetNextDataPart called only once :(

    hmm but that's what I've done - OverallDataSize returns the size of the whole thing, the chunks are smaller

  4. #4
    Regular Contributor
    Join Date
    Aug 2007
    Posts
    105

    Re: GetNextDataPart called only once :(

    I just don't get it to work I logged some stuff and found out that if OverallDataSize() returns a value different from KErrNotFound, the return value of GetNextDataPart() seems to be ignored.

    So i simply return KErrNotFound in OverallDataSize() and now GetNextDataPart() is called twice, afterwards RealeaseData() is called once.

    But no matter what I do - GetNextDataPart is called only twice Although Reset() is not called at all, I've got the thought that maybe the Data Supplier encounters an error, tries to resend the data once (thus the double-call of GetNextDataPart()) and then gives up. But I get no error (no EFailed or something like that).

    I thought that it might be a problem with the content-length header? This header should be set correctly if OverallDataSize() returns the correct size. As i wrote above, I can't return it, but I can't set the header correctly, either, because the SDK sais that any user-setting will be ignored for this field.

    Any ideas, anyone managed to send a chunked POST?

  5. #5
    Regular Contributor
    Join Date
    Aug 2007
    Posts
    105

    Re: GetNextDataPart called only once :(

    damn, I managed to do it. The trick is to return the whole data size AND to call NotifyNewRequestBodyPartL in GetNextDataPart() (I found this hint nowhere, but it makes the framework call the GetNextDataPart() again). For those interested, here's my working code:

    Code:
    TBool CClientEngine::GetNextDataPart(TPtrC8& aDataPart)
    	{
    	TBool lastBuffer=ETrue;
    	if(iPostData)
    		{
    		TInt totalSize=iPostData->Length();
    		TInt sentSize=iCurrentChunk*iChunkSize;
    		TInt chunkSize=totalSize-sentSize;
    		if (chunkSize>iChunkSize)
    			{
    			chunkSize=iChunkSize;
    			lastBuffer=EFalse;
    			}
    		else
    			lastBuffer=ETrue;
    		aDataPart.Set(iPostData->Des().Ptr()+sentSize,chunkSize);
    		}
    	return lastBuffer;
    	}
    
    void CClientEngine::ReleaseData()
    	{
    	iCurrentChunk++;
    	if (iCurrentChunk==iNumPostChunks)	// It's safe to delete iPostData now.
    		{
    		delete iPostData;
    		iPostData = NULL;
    		}
    	else
    		iTransaction.NotifyNewRequestBodyPartL();
    	}
    
    TInt CClientEngine::Reset()
    	{
    	iCurrentChunk=0;
    	return KErrNone;
    	}
    
    
    TInt CClientEngine::OverallDataSize()
    	{
    	if(iPostData)
    		return iPostData->Length();
    	else
    		return KErrNotFound ;
    	}

  6. #6
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    74

    Re: GetNextDataPart called only once :(

    Quote Originally Posted by -chris- View Post
    damn, I managed to do it. The trick is to return the whole data size AND to call NotifyNewRequestBodyPartL in GetNextDataPart() (I found this hint nowhere, but it makes the framework call the GetNextDataPart() again). For those interested, here's my working code:

    Code:
    TBool CClientEngine::GetNextDataPart(TPtrC8& aDataPart)
    	{
    	TBool lastBuffer=ETrue;
    	if(iPostData)
    		{
    		TInt totalSize=iPostData->Length();
    		TInt sentSize=iCurrentChunk*iChunkSize;
    		TInt chunkSize=totalSize-sentSize;
    		if (chunkSize>iChunkSize)
    			{
    			chunkSize=iChunkSize;
    			lastBuffer=EFalse;
    			}
    		else
    			lastBuffer=ETrue;
    		aDataPart.Set(iPostData->Des().Ptr()+sentSize,chunkSize);
    		}
    	return lastBuffer;
    	}
    
    void CClientEngine::ReleaseData()
    	{
    	iCurrentChunk++;
    	if (iCurrentChunk==iNumPostChunks)	// It's safe to delete iPostData now.
    		{
    		delete iPostData;
    		iPostData = NULL;
    		}
    	else
    		iTransaction.NotifyNewRequestBodyPartL();
    	}
    
    TInt CClientEngine::Reset()
    	{
    	iCurrentChunk=0;
    	return KErrNone;
    	}
    
    
    TInt CClientEngine::OverallDataSize()
    	{
    	if(iPostData)
    		return iPostData->Length();
    	else
    		return KErrNotFound ;
    	}
    Hi i am struggling in the same part..kindly help me..Can you post ur

    case THTTPEvent::EGotResponseBodyData: part and

    what is iCurrentChunk? and what is iChunkSize? in the above code...

Similar Threads

  1. exe - destructor not being called
    By nubiah in forum Symbian
    Replies: 4
    Last Post: 2007-07-27, 10:25
  2. Replies: 2
    Last Post: 2007-04-05, 00:48
  3. ActiveObject RunL is called just once
    By lskmao in forum Symbian
    Replies: 3
    Last Post: 2007-01-18, 15:15
  4. Errors building project in VS.2003
    By jensesaat in forum Symbian
    Replies: 11
    Last Post: 2006-11-13, 16:54
  5. Replies: 2
    Last Post: 2004-08-24, 20:04

Posting Permissions

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